From patchwork Tue Nov 20 13:40:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1000501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="GMZx0Psq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zn0G1RQYz9s8F for ; Wed, 21 Nov 2018 00:40:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728128AbeKUAJz (ORCPT ); Tue, 20 Nov 2018 19:09:55 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53625 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbeKUAJy (ORCPT ); Tue, 20 Nov 2018 19:09:54 -0500 Received: by mail-wm1-f65.google.com with SMTP id g131so2155495wmg.3 for ; Tue, 20 Nov 2018 05:40:41 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=I3XR93gU33hxYcwYMkEu/ryYmiKAEB02yg8F22DDwto=; b=GMZx0PsqkEiYLCW9AwCVQu/hz8O3A/81SJuuSeYRGx49vLLuiTHFfbTDqD6swynVo1 JBCB9jS9DQDtQIFe8SObBZQaFt1fcMKw03B5ZEqNTKgcQxJxXCiF1PJLCqLzv/scAXGl Shc2U8lDosTnj/fxidWaSYVwSSm8krCrwkfuadXOseP0LSSandHVgusPsAMaQqSZK8eN q062yCii6XpOwFwyF1vNb8zZD9V8pAelHNoE5CNXShyU7cnwmuck4Mnh4DB3X6yJuCFt pMCtAMKHMDhjRY2MTkf/1fCvtuowGkMht5AP/LdtN44w0c521AQGfE2t733vB97vQyaV q7ew== 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:mime-version:content-transfer-encoding; bh=I3XR93gU33hxYcwYMkEu/ryYmiKAEB02yg8F22DDwto=; b=CiwUP6b6u7wls00aWfO5T8esrm7kBeB1PisZvS5LJwShzwdq1swHrz90Xy8bVTMBlj cSWlFv4tFzkrTVvp5RZLHB1BALtUzQ7HP40nEfluXQPtk5o6KAvjsqSyakZhjsYpA+74 u1zT9LG0CrBkxAgZjAANyqEaqUZfUUwkYcpXqDn0NhVehNfrV2vfkZniZSARmtd3Lf7F j+Ju1sEWAIfZmUcu0U3tWXhpgfytgr2lS/Er8SqQvyFdTRIfqI0fb/TtEi8Xjs2RKlHE QN3OE3nDgIqrlg2xVuuEmky9Yq7IpGRL45i7I/d7s+0RIVasm8p+3uixcuI9pLRBvc03 IyEw== X-Gm-Message-State: AGRZ1gI2IbbQQOItZEFd1KfVNwH4nyMIIpe90uLPpN9GLHhhHSsFEZME JRUAJQ+cHGa21XIBt7IUfvaG9w== X-Google-Smtp-Source: AFSGD/WRIcokyYwqsqYKLzG3DHlnk2/L1hyKiWCc1w5YjMFP6skX+tde5mepXm7hnMyXXqlE37uQYA== X-Received: by 2002:a1c:5585:: with SMTP id j127-v6mr2070605wmb.127.1542721240793; Tue, 20 Nov 2018 05:40:40 -0800 (PST) Received: from debian-brgl.home (lfbn-mar-1-609-89.w90-118.abo.wanadoo.fr. [90.118.185.89]) by smtp.gmail.com with ESMTPSA id j129-v6sm36962901wmb.47.2018.11.20.05.40.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:40:40 -0800 (PST) From: Bartosz Golaszewski To: Thomas Gleixner , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/2] irq/irq_sim: provide irq_sim_fire_edge() Date: Tue, 20 Nov 2018 14:40:31 +0100 Message-Id: <20181120134032.31645-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120134032.31645-1-brgl@bgdev.pl> References: <20181120134032.31645-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski The irq_sim irqchip doesn't allow to configure the sensitivity so every call to irq_sim_fire() fires a dummy interrupt. This used to not matter for gpio-mockup (one of the irq_sim users) until commit fa38869b0161 ("gpiolib: Don't support irq sharing for userspace") which made it impossible for gpio-mockup to ignore certain events (e.g. only receive notifications about rising edge events). Introduce a specialized variant of irq_sim_fire() which takes another argument called edge. allowing to specify the trigger type for the dummy interrupt. Signed-off-by: Bartosz Golaszewski Acked-by: Marc Zyngier --- include/linux/irq_sim.h | 2 ++ kernel/irq/irq_sim.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h index 4500d453a63e..f55148e77792 100644 --- a/include/linux/irq_sim.h +++ b/include/linux/irq_sim.h @@ -22,6 +22,7 @@ struct irq_sim_work_ctx { struct irq_sim_irq_ctx { int irqnum; bool enabled; + int edge; }; struct irq_sim { @@ -36,6 +37,7 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim, unsigned int num_irqs); void irq_sim_fini(struct irq_sim *sim); void irq_sim_fire(struct irq_sim *sim, unsigned int offset); +void irq_sim_fire_edge(struct irq_sim *sim, unsigned int offset, int edge); int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset); #endif /* _LINUX_IRQ_SIM_H */ diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c index 98a20e1594ce..a9330050f751 100644 --- a/kernel/irq/irq_sim.c +++ b/kernel/irq/irq_sim.c @@ -25,10 +25,20 @@ static void irq_sim_irqunmask(struct irq_data *data) irq_ctx->enabled = true; } +static int irq_sim_set_type(struct irq_data *data, unsigned int type) +{ + struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data); + + irq_ctx->edge = type & IRQ_TYPE_EDGE_BOTH; + + return 0; +} + static struct irq_chip irq_sim_irqchip = { .name = "irq_sim", .irq_mask = irq_sim_irqmask, .irq_unmask = irq_sim_irqunmask, + .irq_set_type = irq_sim_set_type, }; static void irq_sim_handle_irq(struct irq_work *work) @@ -161,12 +171,28 @@ EXPORT_SYMBOL_GPL(devm_irq_sim_init); */ void irq_sim_fire(struct irq_sim *sim, unsigned int offset) { - if (sim->irqs[offset].enabled) { + /* Don't care about the edge. */ + irq_sim_fire_edge(sim, offset, IRQ_TYPE_EDGE_BOTH); +} +EXPORT_SYMBOL_GPL(irq_sim_fire); + +/** + * irq_sim_fire_edge - Enqueue an interrupt, specify the edge. + * + * @sim: The interrupt simulator object. + * @offset: Offset of the simulated interrupt which should be fired. + * edge: Edge of the interrupt (IRQ_TYPE_EDGE_RISING/FALLING). + */ +void irq_sim_fire_edge(struct irq_sim *sim, unsigned int offset, int edge) +{ + struct irq_sim_irq_ctx *irq = &sim->irqs[offset]; + + if (irq->enabled && (irq->edge & edge)) { set_bit(offset, sim->work_ctx.pending); irq_work_queue(&sim->work_ctx.work); } } -EXPORT_SYMBOL_GPL(irq_sim_fire); +EXPORT_SYMBOL_GPL(irq_sim_fire_edge); /** * irq_sim_irqnum - Get the allocated number of a dummy interrupt. From patchwork Tue Nov 20 13:40:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1000502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="qvTWc1lR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zn0H6DzTz9sCh for ; Wed, 21 Nov 2018 00:40:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728125AbeKUAJ4 (ORCPT ); Tue, 20 Nov 2018 19:09:56 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38356 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbeKUAJz (ORCPT ); Tue, 20 Nov 2018 19:09:55 -0500 Received: by mail-wm1-f68.google.com with SMTP id k198so2291345wmd.3 for ; Tue, 20 Nov 2018 05:40:42 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=nmnEbWBrxg7vL8jw6YxuuzUlYQ5AMTGgBKEryzY0enE=; b=qvTWc1lRZBfF6jKDFeXEVUHjKglpShD3SOlVQx0TEPCYMdGBK+O3Wi0BIvpSiZtSCT jBt8J4WFMK4zkjsXTb61cGyteX/aY1WPloYgtNKpyu8EUSq2cYEVEmN3I1jGvwfDJudB Wz3fJXxAGOq05q9lbkVwuzV/Z9QfBY+aVIPZ1UujqOYsQNLGgcvHXwaklXRvF6psArL+ kVALJj6Ft0eHd7cdRrxZC3sZAKP60dccxAQMt0cEI3UkoEaZHqeT+7A4xvJf0LSotvlu TagZ1EXjWhMdXSJUzvwB6ofK8FKFCTkE/emM3SiFdWJFf1ngiYpMrqz9jlq9UF76TjE6 uHlA== 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:mime-version:content-transfer-encoding; bh=nmnEbWBrxg7vL8jw6YxuuzUlYQ5AMTGgBKEryzY0enE=; b=InY3CvS+H1eD9nlgU95FXy+BZB29KLNwdfPy6/jeBp0mWwpNjyB/NuwsFfEwDZnQYJ gNZwZp/f4Z/7kr/rpKVCoGF3xq3orEOUr+NKUs1hsb2iz43LUJiWc0wjBGjIsJm0IDm0 HUa6w39ijH6QRI1+4g13wjDar7E2th65Zie0vaomlXxVgHMB2qPxSKOq6z6/hZYJPe/B juSRjgDbr+Z4QFMymvyeR28q+A2Mi/adDrncGgNHqdWKYLGD1XyTtn+Vj5SEggtmZtkt V1zy7jrzUNMLqUoTVk5cogg93i6UVlWcdB7ZirpXTaa55ueuxyfnUMWueAyxOoSimsRD Y/JQ== X-Gm-Message-State: AGRZ1gIJdUbdqSbzaL5Y68VHp5ePFHRITIpR2bJ1fbIOmdxipGO//uDA XBG+LJZ7sIY2MuIqPNlxOIBSXA== X-Google-Smtp-Source: AFSGD/WPPSbwlhUZHarQ6057OZYheWiUKvei0lG/L7uBh4GXdda2VLuL09I2CY+A66m8aIseGuwUYA== X-Received: by 2002:a1c:38c5:: with SMTP id f188-v6mr2197204wma.19.1542721241912; Tue, 20 Nov 2018 05:40:41 -0800 (PST) Received: from debian-brgl.home (lfbn-mar-1-609-89.w90-118.abo.wanadoo.fr. [90.118.185.89]) by smtp.gmail.com with ESMTPSA id j129-v6sm36962901wmb.47.2018.11.20.05.40.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 05:40:41 -0800 (PST) From: Bartosz Golaszewski To: Thomas Gleixner , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/2] gpio: mockup: use irq_sim_fire_edge() Date: Tue, 20 Nov 2018 14:40:32 +0100 Message-Id: <20181120134032.31645-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120134032.31645-1-brgl@bgdev.pl> References: <20181120134032.31645-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski We now have a specialized variant of irq_sim_fire() - use it in gpio-mockup so that we only generate events of types that were requested with the LINEEVENT ioctl(). Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index a4c054cf9c5f..18563d2c7876 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -199,7 +199,7 @@ static ssize_t gpio_mockup_event_write(struct file *file, struct gpio_mockup_chip *chip; struct seq_file *sfile; struct gpio_desc *desc; - int rv, val; + int rv, val, edge; rv = kstrtoint_from_user(usr_buf, size, 0, &val); if (rv) @@ -213,7 +213,8 @@ static ssize_t gpio_mockup_event_write(struct file *file, chip = priv->chip; gpiod_set_value_cansleep(desc, val); - irq_sim_fire(&chip->irqsim, priv->offset); + edge = val == 0 ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; + irq_sim_fire_edge(&chip->irqsim, priv->offset, edge); return size; }