From patchwork Thu May 25 08:33:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 766887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wYN064Mhqz9s8N for ; Thu, 25 May 2017 18:36:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="M3gAR3Su"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933208AbdEYIgU (ORCPT ); Thu, 25 May 2017 04:36:20 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:33893 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936949AbdEYIeA (ORCPT ); Thu, 25 May 2017 04:34:00 -0400 Received: by mail-wr0-f169.google.com with SMTP id j27so14357877wre.1 for ; Thu, 25 May 2017 01:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lai4qKvuAKmAwyI9c4phndIi/mhED9Wg6rpczRQkImU=; b=M3gAR3Su4lXUeAtGArm0sIRNwXt+4M58DyNgPfUK+8012jZ/Gr2oe6r+/U5NSHciHv df7VvRGmryzcs33ShJWFh6PJLyqJrGkYVX/YtL0zqg15McB0HKslAW8lGDNmhCTiD37Q 50rfTGhkZTZRSKIrpBEWtf4JjPR0taIJIExtDygmYdIYOjydERZ//1j6ii2ucfUCa1Vk v+eIw6b1ZKHEHGFhxzx+yPCsIJP7GrXK7xfFgDksFtT6ZydGBHK3DRJXuX5Wk8+cJGv+ uwxAZ+/a8Rxk10ZwQ3s6iBXUoY4B9vjwkAaNMQVJ5pEPhL0TmpJXbm5A5HDG0ssF1Uf6 PRbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lai4qKvuAKmAwyI9c4phndIi/mhED9Wg6rpczRQkImU=; b=P4tYojY9vWciI+UV1XQoLxLB7qBrxoRmqEv8Xd+EOVEl9eWCtNDJcKEkXsFnBcygbQ UBNR94yy7hpkANJwixf6spJ2lKm1Rm6VNyA91xM1K3/RsLIHH80HJ5uqua+MtBofYPxz th+zAn+/O9ooI8D2A00knpknq/QmXf06BXFmQDvH0n63vULcuFPlkAT+AbXBDaO5lgMn FtWufkT3cJ7THxd5I0/cxSRdf2Ggjpof+dAmfdCxeZAynDjd4ATDJQ3vcovp9EfYb+R/ xCvtGZcNGb3bJ7dq/15QGJmXct/n8EAhvgoNynXX/4l8iloBkQb7+7ixgPYxMb36mnyJ a/zw== X-Gm-Message-State: AODbwcCYueOwNuZ2PFgw6ddrWnIu7FpNDE4tQi9tOdLckerBIQZmnW2z 9l1TfyAy49VKMteA X-Received: by 10.223.178.150 with SMTP id g22mr21233291wrd.158.1495701239070; Thu, 25 May 2017 01:33:59 -0700 (PDT) Received: from bgdev-debian.lan (dynamic-194-228-20-36.ipv4.broadband.iol.cz. [194.228.20.36]) by smtp.gmail.com with ESMTPSA id m38sm8933813wrm.4.2017.05.25.01.33.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 May 2017 01:33:58 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Alexandre Courbot , Bamvor Jian Zhang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 04/10] gpio: mockup: support irqmask and irqunmask Date: Thu, 25 May 2017 10:33:41 +0200 Message-Id: <1495701227-28809-5-git-send-email-brgl@bgdev.pl> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1495701227-28809-1-git-send-email-brgl@bgdev.pl> References: <1495701227-28809-1-git-send-email-brgl@bgdev.pl> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Even though this is a testing module, be nice and actually implement these functions. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index c17578e..ba8d62a 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -41,6 +41,7 @@ enum { struct gpio_mockup_line_status { int dir; bool value; + bool irq_enabled; }; struct gpio_mockup_irq_context { @@ -142,12 +143,21 @@ static int gpio_mockup_to_irq(struct gpio_chip *chip, unsigned int offset) return chip->irq_base + offset; } -/* - * While we should generally support irqmask and irqunmask, this driver is - * for testing purposes only so we don't care. - */ -static void gpio_mockup_irqmask(struct irq_data *d) { } -static void gpio_mockup_irqunmask(struct irq_data *d) { } +static void gpio_mockup_irqmask(struct irq_data *data) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + + chip->lines[data->irq - gc->irq_base].irq_enabled = false; +} + +static void gpio_mockup_irqunmask(struct irq_data *data) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + + chip->lines[data->irq - gc->irq_base].irq_enabled = true; +} static struct irq_chip gpio_mockup_irqchip = { .name = GPIO_MOCKUP_NAME, @@ -178,6 +188,7 @@ static int gpio_mockup_irqchip_setup(struct device *dev, for (i = 0; i < gc->ngpio; i++) { irq_set_chip(irq_base + i, gc->irqchip); + irq_set_chip_data(irq_base + i, gc); irq_set_handler(irq_base + i, &handle_simple_irq); irq_modify_status(irq_base + i, IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); @@ -206,6 +217,9 @@ static ssize_t gpio_mockup_event_write(struct file *file, chip = priv->chip; gc = &chip->gc; + if (!chip->lines[priv->offset].irq_enabled) + return size; + if (copy_from_user(&buf, usr_buf, 1)) return -EFAULT;