From patchwork Wed Jan 23 14:15:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029971 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="saNW4+Am"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6lz2bxKz9sBQ for ; Thu, 24 Jan 2019 01:16:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbfAWOPx (ORCPT ); Wed, 23 Jan 2019 09:15:53 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37151 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfAWOPw (ORCPT ); Wed, 23 Jan 2019 09:15:52 -0500 Received: by mail-wm1-f67.google.com with SMTP id g67so2098001wmd.2 for ; Wed, 23 Jan 2019 06:15:51 -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=WQ66DLEKc/MG0DXybe6MWB+l9aGMWDp/DgE2ls7LES8=; b=saNW4+Amy3TnKB0zLgHSHhGJk6MQOZKunNRlGdRHPvYQVLby7qVAzz+IFyufQWJ7S+ oe1VOSjHW8KPcopwEjmtQjij7NBFTjRSAZ74vyafdUbvV2/58FdDPfSjpbqUMi/CxPFf phgR1ykWQ0fd2GPlpU/Iv/Sim29IZ/sbf4EuMAdYYYtdG+vtUYyuu8aQieTk7x3bJZuX uEKmSrOc+Ldj+MNrJIevMM9d6P8Ioh9vzc2EHjtwg0Dh7xg6PC3inXktcGI3s4INfJuu yac1PhNbSBwEXGyan+ueeGbqZOvqxCYlRthk4n2zKBx0vnXhWrHQMKCQcjDcahATEnG5 pNRA== 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=WQ66DLEKc/MG0DXybe6MWB+l9aGMWDp/DgE2ls7LES8=; b=dkgxph6ia7+VmVxlQsUMruecX2zafAb12zS2B5UcQxOy537khmZ6dEWSYNnOr6OkQn Kqa8gCF8HgDGqzcx6RbZs5j2HYUGNjwibKKTCicBnPEDfQPT8euDrL1tk0V9RlQGhK+G byavDdbrq+jRtewaa85nmStAyVbd670x5NvOoHFTcoqqgvVuZYqJi3Iilg9y6lvFnmvF atBdmDdYBqdg+YnqCSwueyOl8NlSCvlWJxPmo3awZou2LwrW0smTHizdvUL6gxx+h/z/ 940ABkkIVH5/cK5XneaRSKTaKwdl3biZcw1bLIABzrwC90SLGJYMjZPLSXBWLkZAUgt2 /YkA== X-Gm-Message-State: AJcUukf+aqqO1n6yiAQeIwuw5jFm9gFBwJoF2UeHk4LzfjF6g8/aCLp3 GMd7VbZ5lUMrlBSkBqmnmNdsnQ== X-Google-Smtp-Source: ALg8bN4h2Oar7UWGtZl83vS4bpMJvuZCqmhytFUocnIlDAoCnH1Z7eOhCsq7/0hUPTQ959COxj9aZg== X-Received: by 2002:a1c:9dc4:: with SMTP id g187mr2987014wme.152.1548252946644; Wed, 23 Jan 2019 06:15:46 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:46 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/9] irq/irq_sim: don't share the irq_chip structure between simulators Date: Wed, 23 Jan 2019 15:15:30 +0100 Message-Id: <20190123141538.29408-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 want to support multiple instances of irq_sim. Make struct irq_chip part of the irq_sim structure. Signed-off-by: Bartosz Golaszewski --- include/linux/irq_sim.h | 2 ++ kernel/irq/irq_sim.c | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h index 4500d453a63e..eda132c22b57 100644 --- a/include/linux/irq_sim.h +++ b/include/linux/irq_sim.h @@ -6,6 +6,7 @@ #ifndef _LINUX_IRQ_SIM_H #define _LINUX_IRQ_SIM_H +#include #include #include @@ -25,6 +26,7 @@ struct irq_sim_irq_ctx { }; struct irq_sim { + struct irq_chip chip; struct irq_sim_work_ctx work_ctx; int irq_base; unsigned int irq_count; diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c index 98a20e1594ce..b732e4e2e45b 100644 --- a/kernel/irq/irq_sim.c +++ b/kernel/irq/irq_sim.c @@ -25,12 +25,6 @@ static void irq_sim_irqunmask(struct irq_data *data) irq_ctx->enabled = true; } -static struct irq_chip irq_sim_irqchip = { - .name = "irq_sim", - .irq_mask = irq_sim_irqmask, - .irq_unmask = irq_sim_irqunmask, -}; - static void irq_sim_handle_irq(struct irq_work *work) { struct irq_sim_work_ctx *work_ctx; @@ -74,6 +68,10 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs) return sim->irq_base; } + sim->chip.name = "irq_sim"; + sim->chip.irq_mask = irq_sim_irqmask; + sim->chip.irq_unmask = irq_sim_irqunmask; + sim->work_ctx.pending = bitmap_zalloc(num_irqs, GFP_KERNEL); if (!sim->work_ctx.pending) { kfree(sim->irqs); @@ -84,7 +82,7 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs) for (i = 0; i < num_irqs; i++) { sim->irqs[i].irqnum = sim->irq_base + i; sim->irqs[i].enabled = false; - irq_set_chip(sim->irq_base + i, &irq_sim_irqchip); + irq_set_chip(sim->irq_base + i, &sim->chip); irq_set_chip_data(sim->irq_base + i, &sim->irqs[i]); irq_set_handler(sim->irq_base + i, &handle_simple_irq); irq_modify_status(sim->irq_base + i, From patchwork Wed Jan 23 14:15:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029974 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="rmSa0x51"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6mC5lXHz9s4s for ; Thu, 24 Jan 2019 01:16:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbfAWOPu (ORCPT ); Wed, 23 Jan 2019 09:15:50 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34459 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfAWOPt (ORCPT ); Wed, 23 Jan 2019 09:15:49 -0500 Received: by mail-wr1-f67.google.com with SMTP id f7so2668630wrp.1 for ; Wed, 23 Jan 2019 06:15:48 -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=u1cvKiJKGLS50bVRlMfC4FARes9V6DDs6i6g/M3Az2U=; b=rmSa0x51VYbRz8O9mIOaDkYOIvrbZX5kf4I2ybvzFOenjtXU2TBU+a1QGc+JTwLtZ7 kIeubIhLf+AwpKuQWNORHAax7AeYXbkHCFR0jjn5Si/FBzs+prZKSAaD23y1W0oeBFgZ BdXsM9ft2M/UdhNpkeMXUZiR84mP2PnFOo5UK5XSPXZ79SOIu/y0bPR9n1ybRgLWsiiu mIhwj7CeAaL+Pp3brXqyNh+FFyfzyhTrTJjaZEg8bZl0salqSKIZ+t6jrXUSgN3u8GtV GvW2dUzi2q3i507wsX7zZP66gdb6UgwMmrAi53RPLxC82bb8/TzmA6cOi3WhA2FJHAJd E0ng== 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=u1cvKiJKGLS50bVRlMfC4FARes9V6DDs6i6g/M3Az2U=; b=iLdaPuL4K2PIOvunAeB9/BsVTFU1efIC0eU75cHGETjjRj89nxfq7Vxh/z5r6mTxk0 G73ywJCKp55zehpdzij8sYrXKZb5CU1BVb7dpCzDVad3PBIjhXjoYm/HVFvveO5Oi26y tlXveLdfp6A14zGQ5jPDlEtTuxFOmVJH3vZUrs6qexDbd65LbSb1rHuNL3TDbiqqObWw b/eij9vP2/koD4w+OACNlsgyg2kYJnxq3225tWJ4wa7WotGrfBnawuV+L1RrqYEiFsjW fYgiRYedxpH1ohHlW1OHpWuE2BaeYHOfVC+be3cDjW17t2nZSs4yc1im0etQM6zLH4pY jv3A== X-Gm-Message-State: AJcUukeF4WvpG0njQQDxaffeDvef0dwzPc4KitFWNX6ZkYBzQrpvnHpP oh8ksjFf30AljXebNMrZfKyUvA== X-Google-Smtp-Source: ALg8bN6kwSpdDH8h4W3437pzNAYU6xRbAUMRU6hdIkRPsTV16Oo7mQNrmqZY4fR2hb6ER+UvxGJrgg== X-Received: by 2002:a5d:664a:: with SMTP id f10mr2953315wrw.311.1548252947720; Wed, 23 Jan 2019 06:15:47 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:47 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/9] irq/irq_sim: use irq domain Date: Wed, 23 Jan 2019 15:15:31 +0100 Message-Id: <20190123141538.29408-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 Delegate the offset to virq number mapping to the provided framework instead of handling it locally. Signed-off-by: Bartosz Golaszewski --- include/linux/irq_sim.h | 6 +-- kernel/irq/irq_sim.c | 94 +++++++++++++++++++++++++++++------------ 2 files changed, 71 insertions(+), 29 deletions(-) diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h index eda132c22b57..b96c2f752320 100644 --- a/include/linux/irq_sim.h +++ b/include/linux/irq_sim.h @@ -8,6 +8,7 @@ #include #include +#include #include /* @@ -21,16 +22,15 @@ struct irq_sim_work_ctx { }; struct irq_sim_irq_ctx { - int irqnum; bool enabled; }; struct irq_sim { struct irq_chip chip; + struct irq_domain *domain; struct irq_sim_work_ctx work_ctx; - int irq_base; + int virq_base; unsigned int irq_count; - struct irq_sim_irq_ctx *irqs; }; int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs); diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c index b732e4e2e45b..2bcdbab1bc5a 100644 --- a/kernel/irq/irq_sim.c +++ b/kernel/irq/irq_sim.c @@ -44,6 +44,43 @@ static void irq_sim_handle_irq(struct irq_work *work) } } +static int irq_sim_domain_map(struct irq_domain *domain, + unsigned int virq, irq_hw_number_t hw) +{ + struct irq_sim *sim = domain->host_data; + struct irq_sim_irq_ctx *ctx; + + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + irq_set_chip(virq, &sim->chip); + irq_set_chip_data(virq, ctx); + irq_set_handler(virq, handle_simple_irq); + irq_modify_status(virq, IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); + + return 0; +} + +static void irq_sim_domain_free(struct irq_domain *domain, + unsigned int virq, unsigned int num_irqs) +{ + struct irq_sim_irq_ctx *ctx; + struct irq_data *irq; + int i; + + for (i = 0; i < num_irqs; i++) { + irq = irq_domain_get_irq_data(domain, virq + i); + ctx = irq_data_get_irq_chip_data(irq); + kfree(ctx); + } +} + +static const struct irq_domain_ops irq_sim_domain_ops = { + .map = irq_sim_domain_map, + .free = irq_sim_domain_free, +}; + /** * irq_sim_init - Initialize the interrupt simulator: allocate a range of * dummy interrupts. @@ -56,16 +93,15 @@ static void irq_sim_handle_irq(struct irq_work *work) */ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs) { - int i; - - sim->irqs = kmalloc_array(num_irqs, sizeof(*sim->irqs), GFP_KERNEL); - if (!sim->irqs) + sim->virq_base = irq_alloc_descs(-1, 0, num_irqs, 0); + if (sim->virq_base < 0) + return sim->virq_base; + + sim->domain = irq_domain_add_legacy(NULL, num_irqs, sim->virq_base, + 0, &irq_sim_domain_ops, sim); + if (!sim->domain) { + irq_free_descs(sim->virq_base, num_irqs); return -ENOMEM; - - sim->irq_base = irq_alloc_descs(-1, 0, num_irqs, 0); - if (sim->irq_base < 0) { - kfree(sim->irqs); - return sim->irq_base; } sim->chip.name = "irq_sim"; @@ -74,25 +110,15 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs) sim->work_ctx.pending = bitmap_zalloc(num_irqs, GFP_KERNEL); if (!sim->work_ctx.pending) { - kfree(sim->irqs); - irq_free_descs(sim->irq_base, num_irqs); + irq_domain_remove(sim->domain); + irq_free_descs(sim->virq_base, num_irqs); return -ENOMEM; } - for (i = 0; i < num_irqs; i++) { - sim->irqs[i].irqnum = sim->irq_base + i; - sim->irqs[i].enabled = false; - irq_set_chip(sim->irq_base + i, &sim->chip); - irq_set_chip_data(sim->irq_base + i, &sim->irqs[i]); - irq_set_handler(sim->irq_base + i, &handle_simple_irq); - irq_modify_status(sim->irq_base + i, - IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); - } - init_irq_work(&sim->work_ctx.work, irq_sim_handle_irq); sim->irq_count = num_irqs; - return sim->irq_base; + return sim->virq_base; } EXPORT_SYMBOL_GPL(irq_sim_init); @@ -106,8 +132,8 @@ void irq_sim_fini(struct irq_sim *sim) { irq_work_sync(&sim->work_ctx.work); bitmap_free(sim->work_ctx.pending); - irq_free_descs(sim->irq_base, sim->irq_count); - kfree(sim->irqs); + irq_domain_free_irqs(sim->virq_base, sim->irq_count); + irq_domain_remove(sim->domain); } EXPORT_SYMBOL_GPL(irq_sim_fini); @@ -151,6 +177,20 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim, } EXPORT_SYMBOL_GPL(devm_irq_sim_init); +static struct irq_sim_irq_ctx * +irq_sim_get_ctx(struct irq_sim *sim, unsigned int offset) +{ + struct irq_sim_irq_ctx *ctx; + struct irq_data *irq; + int virq; + + virq = irq_find_mapping(sim->domain, offset); + irq = irq_domain_get_irq_data(sim->domain, virq); + ctx = irq_data_get_irq_chip_data(irq); + + return ctx; +} + /** * irq_sim_fire - Enqueue an interrupt. * @@ -159,7 +199,9 @@ EXPORT_SYMBOL_GPL(devm_irq_sim_init); */ void irq_sim_fire(struct irq_sim *sim, unsigned int offset) { - if (sim->irqs[offset].enabled) { + struct irq_sim_irq_ctx *ctx = irq_sim_get_ctx(sim, offset); + + if (ctx->enabled) { set_bit(offset, sim->work_ctx.pending); irq_work_queue(&sim->work_ctx.work); } @@ -175,6 +217,6 @@ EXPORT_SYMBOL_GPL(irq_sim_fire); */ int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset) { - return sim->irqs[offset].irqnum; + return irq_find_mapping(sim->domain, offset); } EXPORT_SYMBOL_GPL(irq_sim_irqnum); From patchwork Wed Jan 23 14:15:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029973 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="U87ItS5a"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6m34gWtz9s9G for ; Thu, 24 Jan 2019 01:16:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbfAWOPv (ORCPT ); Wed, 23 Jan 2019 09:15:51 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39299 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726996AbfAWOPv (ORCPT ); Wed, 23 Jan 2019 09:15:51 -0500 Received: by mail-wr1-f67.google.com with SMTP id t27so2628386wra.6 for ; Wed, 23 Jan 2019 06:15:49 -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=phuvz1JRrnRqzpouEYay5SFWuk0hSkE+vMxZP22Ixuo=; b=U87ItS5afQ2NJJPquJR1Qsy6Eu3bpCXJ6IiL5592nf2nyvppRdz1wibZ8H8JybiySB AsQQUV1MU44mnFlQ/tb+gDc0KI6PijFbp5O31xgmvk+qcbiJ7R6PP67rJIpDRr0OhgLH uC95ymur/CD2kelBkzEC+n0aB8pWF0HzCeEGmWcOEXgdN9lBL5R3bgsODulemMjW3SYR TvlZgX0OIEMAd1oTrGIydU4FlPX0YCGf91y3SexKjUbpsr6Iyx/Qejme512gguzHkdE/ 0+Wim82BiT9BVcMVtsyJcA7j3BdxVI4OM7g3EhoowCRxuseW33BxZUUzFtwttFep09yv Z7GA== 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=phuvz1JRrnRqzpouEYay5SFWuk0hSkE+vMxZP22Ixuo=; b=C/LTL/SrjH2tysos8qx2RHQB2hID+K/la0VpU0M8sY0Fph9KvwRW+W5pVGaRIkma2/ X2sP86oClLY466D/Gv+Hh1rlWmb5gtqqDW+uC/iPDP1rXmIxurCsoiOv9VllRDm2RccB q82ptvVuLLhtJMXclJuMEjJKiQOZi34Kl3Eiq95VYrtX3sze2VAph7IDcrstPkoBnfqD DsvLVW468zRKWDNDbsICHL6503sW4XD5NkCxsZ5xcWUF2F6W5Tj1aXtfIgjBiFAlO2Om ojmtK+0k0pCEHDtZMYgrOMz4XLISn6iJUNzwAYRpod1aJj/Bfhf+T3OLHnuN+IhaVCZN gVvw== X-Gm-Message-State: AJcUukfoQ1lYYcyfWdFn6EbbMEOjL1Kk9R+wH9wkJwJRLCAvNOFtjzAQ ko3oeE1LtY1OYa0UJVflcE4kJg== X-Google-Smtp-Source: ALg8bN7xlucqJUCuaZiyp44b+7+HpCE7qf8DC9M8BNfNOvc0WCs045/gqAt+0xO9gPunU3SCU/ZaEA== X-Received: by 2002:adf:db01:: with SMTP id s1mr2918433wri.214.1548252948785; Wed, 23 Jan 2019 06:15:48 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:48 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 3/9] irq/irq_sim: provide irq_sim_get_type() Date: Wed, 23 Jan 2019 15:15:32 +0100 Message-Id: <20190123141538.29408-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 Provide a helper that allows users to retrieve the configured flow type of dummy interrupts. That allows certain users to decide whether an irq needs to be fired depending on its edge/level/... configuration. Signed-off-by: Bartosz Golaszewski --- include/linux/irq_sim.h | 2 ++ kernel/irq/irq_sim.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h index b96c2f752320..782dfc599632 100644 --- a/include/linux/irq_sim.h +++ b/include/linux/irq_sim.h @@ -23,6 +23,7 @@ struct irq_sim_work_ctx { struct irq_sim_irq_ctx { bool enabled; + unsigned int type; }; struct irq_sim { @@ -39,5 +40,6 @@ int devm_irq_sim_init(struct device *dev, struct irq_sim *sim, void irq_sim_fini(struct irq_sim *sim); void irq_sim_fire(struct irq_sim *sim, unsigned int offset); int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset); +int irq_sim_get_type(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 2bcdbab1bc5a..9168e7100559 100644 --- a/kernel/irq/irq_sim.c +++ b/kernel/irq/irq_sim.c @@ -25,6 +25,15 @@ 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->type = type; + + return 0; +} + static void irq_sim_handle_irq(struct irq_work *work) { struct irq_sim_work_ctx *work_ctx; @@ -107,6 +116,7 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs) sim->chip.name = "irq_sim"; sim->chip.irq_mask = irq_sim_irqmask; sim->chip.irq_unmask = irq_sim_irqunmask; + sim->chip.irq_set_type = irq_sim_set_type; sim->work_ctx.pending = bitmap_zalloc(num_irqs, GFP_KERNEL); if (!sim->work_ctx.pending) { @@ -220,3 +230,18 @@ int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset) return irq_find_mapping(sim->domain, offset); } EXPORT_SYMBOL_GPL(irq_sim_irqnum); + +/** + * irq_sim_get_type - Get the configured flow type of a dummy interrupt. + * + * @sim: The interrupt simulator object. + * @offset: Offset of the simulated interrupt for which to retrieve + * the type. + */ +int irq_sim_get_type(struct irq_sim *sim, unsigned int offset) +{ + struct irq_sim_irq_ctx *ctx = irq_sim_get_ctx(sim, offset); + + return ctx->type; +} +EXPORT_SYMBOL_GPL(irq_sim_get_type); From patchwork Wed Jan 23 14:15:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029972 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="uGpUQW0t"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6m25h8gz9s7h for ; Thu, 24 Jan 2019 01:16:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727291AbfAWOQa (ORCPT ); Wed, 23 Jan 2019 09:16:30 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51328 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbfAWOPx (ORCPT ); Wed, 23 Jan 2019 09:15:53 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so2146088wmj.1 for ; Wed, 23 Jan 2019 06:15:50 -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=lxsbnWY+u5ZD2HJ8Gj47byZdwyvd+a73Kv/KMI9VfHI=; b=uGpUQW0tYNkDz+t0BNndB2i4PWinvJadgy4277/VcnjfkcKOPd0x1RHrgZmGGSARqw 46JYT5OZuBBtwAtC1sSC3z/zd0M8imvbEzgnZtiULEOEs29HzpR8dQCSrqtSzkfm78zA pv+aMeXt+cbvFJMEkBE/74ovNGGiQ2B9VQwZ68DOyl4oH6CwsPgpz9ky5KrW4SNecILv qjZlAvaFvLTXw2RwwSSjqCsBqz3cuIrMQeIYMxwJEINgjB26nPIsdOk3J9LfC6N3A3Pa MWujK8tYZWAlhHvMzM5q53MeO6rEIcSGSdqVncCdU8DuKHPXAw2DHTB+VbqRJBiZYThm 5LhA== 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=lxsbnWY+u5ZD2HJ8Gj47byZdwyvd+a73Kv/KMI9VfHI=; b=eSgZro2JtD3nEiwPygFHoNGhp5mCWBkpCN5fYAZ5zcrDzE+nDFkktKx5ah/aEZDwx3 b894Woc0/qENrzh0pF57W58vDdTundkK5MH/Lc1RT5BwF7ejLPYlBN13ua2ginPezhDX nmhVlCYqAQV5RcZGgohh2zQf7HgO6wKCMpyyWYfiMTzVwicXzHtijZ2ngunesl+GI7Kb nEKT3MnaapqsuMC0QeyRJHab2qGUVxBs9tJp6cvFe1Lv0Wa1VMDAd3UWi85W50gJ3WUJ hUh8aZNbpv9pqFG7GzOs+LXGyiMQzARNcAGXM9pwstmmcwh4idCktD4ZyaDHl6Bjr9RJ OIZw== X-Gm-Message-State: AJcUukccnqI9ESf2a4K91kpPbXnmhbwjepFMo3YUN69QzBKwXJfGUleo sCcGJI9Rn/YY6NMZDqxff7w7nQ== X-Google-Smtp-Source: ALg8bN4OXc8aT70YhNURo9o0CEY4ZRYfzv2KtxkGiyevA9M6RVXjnot5ZG4nSh2jdvcv4AiBV7zvhw== X-Received: by 2002:a1c:b456:: with SMTP id d83mr3035253wmf.115.1548252950171; Wed, 23 Jan 2019 06:15:50 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:49 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 4/9] gpio: mockup: add locking Date: Wed, 23 Jan 2019 15:15:33 +0100 Message-Id: <20190123141538.29408-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 While no user reported any race condition problems with gpio-mockup, let's be on the safe side and use a mutex when performing any changes on the dummy chip structures. Suggested-by: Uwe Kleine-König Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 50 ++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 6a50f9f59c90..b4c1de6acf74 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -54,6 +54,7 @@ struct gpio_mockup_chip { struct gpio_mockup_line_status *lines; struct irq_sim irqsim; struct dentry *dbg_dir; + struct mutex lock; }; struct gpio_mockup_dbgfs_private { @@ -82,29 +83,53 @@ static int gpio_mockup_range_ngpio(unsigned int index) return gpio_mockup_ranges[index * 2 + 1]; } -static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) +static int __gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); return chip->lines[offset].value; } -static void gpio_mockup_set(struct gpio_chip *gc, - unsigned int offset, int value) +static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) +{ + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + int val; + + mutex_lock(&chip->lock); + val = __gpio_mockup_get(gc, offset); + mutex_unlock(&chip->lock); + + return val; +} + +static void __gpio_mockup_set(struct gpio_chip *gc, + unsigned int offset, int value) { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); chip->lines[offset].value = !!value; } +static void gpio_mockup_set(struct gpio_chip *gc, + unsigned int offset, int value) +{ + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + + mutex_lock(&chip->lock); + __gpio_mockup_set(gc, offset, value); + mutex_unlock(&chip->lock); +} + static void gpio_mockup_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); unsigned int bit; + mutex_lock(&chip->lock); for_each_set_bit(bit, mask, gc->ngpio) - gpio_mockup_set(gc, bit, test_bit(bit, bits)); - + __gpio_mockup_set(gc, bit, test_bit(bit, bits)); + mutex_unlock(&chip->lock); } static int gpio_mockup_dirout(struct gpio_chip *gc, @@ -112,8 +137,10 @@ static int gpio_mockup_dirout(struct gpio_chip *gc, { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); - gpio_mockup_set(gc, offset, value); + mutex_lock(&chip->lock); chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT; + __gpio_mockup_set(gc, offset, value); + mutex_unlock(&chip->lock); return 0; } @@ -122,7 +149,9 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset) { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + mutex_lock(&chip->lock); chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN; + mutex_unlock(&chip->lock); return 0; } @@ -130,8 +159,13 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset) static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset) { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + int direction; - return !chip->lines[offset].dir; + mutex_lock(&chip->lock); + direction = !chip->lines[offset].dir; + mutex_unlock(&chip->lock); + + return direction; } static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset) @@ -283,6 +317,8 @@ static int gpio_mockup_probe(struct platform_device *pdev) return -ENOMEM; } + mutex_init(&chip->lock); + gc = &chip->gc; gc->base = base; gc->ngpio = ngpio; From patchwork Wed Jan 23 14:15:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029970 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="V1qHlobF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6ly4DKZz9s9G for ; Thu, 24 Jan 2019 01:16:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbfAWOQ3 (ORCPT ); Wed, 23 Jan 2019 09:16:29 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35429 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726946AbfAWOPy (ORCPT ); Wed, 23 Jan 2019 09:15:54 -0500 Received: by mail-wm1-f67.google.com with SMTP id t200so2128455wmt.0 for ; Wed, 23 Jan 2019 06:15:52 -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=7qysfTh5siwOfbKv1X9ginQ3UPSZFJeCzUUMvaoxNkY=; b=V1qHlobFyH0W19DrIw4NtoCcPhHkZE6Se59gihjX67LDovB5M23zUYK88eY4kylWBr wioAmbcVIidXbaaPmdPKsF1YHc4z+3qJ8PZdTmhRmc3FS65GjmkOS6n73CM9yviswWuS Epo6WVm7qFPFUC026hKDmVmd+eZYonk0baNrtgUPy25bxymuOek7DrVNkHC3JS0l+vmC lBIsGPNDO+Os5pr16IVd+I6Vdrxm+JxXij+uM8XvJUTgJYuZuEmcrdFlaKXKuzjCMuXR pfFovvvHZ7Bn5c6c/HFmKbPiqu0VWOFV4y65yfYAEy/rmnn1fiFkjuDda4Z1Gfx5evyP E93g== 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=7qysfTh5siwOfbKv1X9ginQ3UPSZFJeCzUUMvaoxNkY=; b=lwNvGXXkyZjgv9EOM8AcJEdKZ5X3qehQYCBBp+4YfpQJoY2t11Ih9+a/xhe7Cy+hf+ QFER0lTO6aIlsIEXdlK56P1rsUatdNpx76k9IB6DFv7blALIX+C3x3+LcU/ljkSG7wrk K95rUyCQ+mpbVXABydcxuhQU2EVSc45EvwARdZlazEYlKDk0tpCXcqqXj3ZY7kUwbU1q PBrRe//L6mJYHaJlT5d8IG5gyEvagXTxjHyHkmFUUlnJJ8vRHSn/PfHZ3tEhoZNq+lln nom0CG7N54e4vBdEgbY8tyt3pOBt3+ht0VilAM4RAbSjj4L0nqTMTdLu14pkWU3w/a45 ppTw== X-Gm-Message-State: AJcUukeIj6CYzZRifGUaTe/RzDLzLdPZHxKtbs9gUUXXIz8Rgk696D8J +kOBWHGjPlNlLuL+2Ds7Eo0/Bg== X-Google-Smtp-Source: ALg8bN6UXBoh4tXqrK10S2G+XEmMgtbXbaLd8rrv++BsgqtuMr+Rr9xc7qAY7gJV/G3RUicH1X8IUg== X-Received: by 2002:a7b:c24c:: with SMTP id b12mr2697326wmj.29.1548252951851; Wed, 23 Jan 2019 06:15:51 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:50 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 5/9] gpio: mockup: implement get_multiple() Date: Wed, 23 Jan 2019 15:15:34 +0100 Message-Id: <20190123141538.29408-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 We already support set_multiple(). Implement get_multiple() as well. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index b4c1de6acf74..1c945c967f60 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -102,6 +102,22 @@ static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) return val; } +static int gpio_mockup_get_multiple(struct gpio_chip *gc, + unsigned long *mask, unsigned long *bits) +{ + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + unsigned int bit, val; + + mutex_lock(&chip->lock); + for_each_set_bit(bit, mask, gc->ngpio) { + val = __gpio_mockup_get(gc, bit); + __assign_bit(bit, bits, val); + } + mutex_unlock(&chip->lock); + + return 0; +} + static void __gpio_mockup_set(struct gpio_chip *gc, unsigned int offset, int value) { @@ -327,6 +343,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) gc->parent = dev; gc->get = gpio_mockup_get; gc->set = gpio_mockup_set; + gc->get_multiple = gpio_mockup_get_multiple; gc->set_multiple = gpio_mockup_set_multiple; gc->direction_output = gpio_mockup_dirout; gc->direction_input = gpio_mockup_dirin; From patchwork Wed Jan 23 14:15:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029969 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="S0Yq48Ww"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6lk157dz9s7T for ; Thu, 24 Jan 2019 01:16:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727009AbfAWOQN (ORCPT ); Wed, 23 Jan 2019 09:16:13 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45946 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfAWOPz (ORCPT ); Wed, 23 Jan 2019 09:15:55 -0500 Received: by mail-wr1-f65.google.com with SMTP id t6so2591817wrr.12 for ; Wed, 23 Jan 2019 06:15:53 -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=oFYrT2wnMCaEZTFTRohnQPMYE3Q3Qh5QyDn+YPY7eC4=; b=S0Yq48Wwkiz0nDNRMwZQ+sUgdA3QpUt/wkY0HGeC1Jmnh3izX/lLJfTNmFyAj5uQIC X7WIF2JJLkSsj1FX3tcNDi+ibIgEVsiU1dVtS/IIqbJUcNQ7unRUPBteFRw0TOMawTeg 0cR9j/vFK+XCaJvg1ojqzHN1B4F4F0NwzNojZlw1I7aZOeTMZ/FSycsDi9SET/qJSDta c5tOGjezgFH7V512uroepc1jxghEJarlpAZ88zlgbfjORb7FIQF2DS9JMU78WITrAgbO Wh5H821UD3WA7xsPTraD2xrVhDerhkQA/mrzrG66zMg1LW1SjDaG1okIsCpva6JOD7U2 jp0A== 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=oFYrT2wnMCaEZTFTRohnQPMYE3Q3Qh5QyDn+YPY7eC4=; b=rTjWwrDOwFWNXn+73J0youL0YVYFKN9q6IM6ukl7RHsjAmy112oAUBqBYzOxJ4vvhr 19PHG8Iw2WyHHBarSrWe0aDhu99lTET6MhF160VDjDKkS2hGrto0TJJYekV53gG6XPMf t+MRmJC19M8RW9X6P9oPdaBHWTrF1/22tLW8qRANNIjfhwi0GjO39tvB5TPTYHDsN38y soYtcWvrQZCKw0iTg+a7SZDa/T+bzisr2vq9XDPJ5lazNk0+qqesZg1fAzvUru/ygJIZ b026gCvpDLxIZSXucz5s4nd3TLgOKXvXLXl5JbvnrNXUC926PF0tugSsawMK7YYDRrEf R4ZQ== X-Gm-Message-State: AJcUukcr7J4NlCwOBnIxnQdNKtte2tfCp6+Mtm03q3jTafkg1Umb2BD9 XBu9qUy1w91kEC2tTL61lGwIDQ== X-Google-Smtp-Source: ALg8bN43+Q+f31kwPkEI+sVZw6DA/sV5YjYlydvRFHM+fQ2rCw7LhV9D+yTV2V3OV4PAiQM3UelAQA== X-Received: by 2002:adf:9542:: with SMTP id 60mr2909985wrs.60.1548252952879; Wed, 23 Jan 2019 06:15:52 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:52 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 6/9] gpio: mockup: don't create the debugfs link named after the label Date: Wed, 23 Jan 2019 15:15:35 +0100 Message-Id: <20190123141538.29408-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 User-space tests no longer use it and we're breaking the interface anyway. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 1c945c967f60..0317917a3678 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -234,7 +234,7 @@ static void gpio_mockup_debugfs_setup(struct device *dev, struct gpio_mockup_chip *chip) { struct gpio_mockup_dbgfs_private *priv; - struct dentry *evfile, *link; + struct dentry *evfile; struct gpio_chip *gc; const char *devname; char *name; @@ -247,10 +247,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev, if (IS_ERR_OR_NULL(chip->dbg_dir)) goto err; - link = debugfs_create_symlink(gc->label, gpio_mockup_dbg_dir, devname); - if (IS_ERR_OR_NULL(link)) - goto err; - for (i = 0; i < gc->ngpio; i++) { name = devm_kasprintf(dev, GFP_KERNEL, "%d", i); if (!name) From patchwork Wed Jan 23 14:15:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029965 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="oCKWYjVV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6lM6Zypz9s9G for ; Thu, 24 Jan 2019 01:15:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbfAWOP4 (ORCPT ); Wed, 23 Jan 2019 09:15:56 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:56204 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbfAWOPz (ORCPT ); Wed, 23 Jan 2019 09:15:55 -0500 Received: by mail-wm1-f66.google.com with SMTP id y139so2110865wmc.5 for ; Wed, 23 Jan 2019 06:15:54 -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=Z770VfwimnPEUjTF5L5saIw2a2GAQPLZtqYgE1wTw+k=; b=oCKWYjVVwVFKVwJgc+LY6lR9zTKix2d5fs4v7joJxm0kxkWNdZNnG15w0kbLjXUNZy ArSH6985R1J604kDYcghQiRrwz1Prp8OpcdwTFj76+kWeA1+rr7c2TxE7FWPL4XZ1MIC BzfoQHBiM/TyB0a8XHZjJdgt0k94sg+1P7G5y0KQZC3+j9SvpywA2OqynNOMxoUR9Ui7 rCjhny93Hskzf+HYRgsL8Xus3nHizplpEHYJeWdHTRGiDf2TlorOrrF5L3Q+uQPTYyIB TuPoXjRRjt/BT73lEeLtXbxjiFADR8WQ5TMD3+w8LEUffSASLCOSUCyYBoYSKFQv6Vi8 OAkQ== 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=Z770VfwimnPEUjTF5L5saIw2a2GAQPLZtqYgE1wTw+k=; b=Jeq14XBda9H6y6GCRUUByjfIX57HPI1LD3Ms9Lm0D+HDuYbDzsgAHdUS7ozrBsGanW /9oFtehyH831mmSNynw8HWmApUwlSvPYuLNwkSKjbaszu1VZKnD0Rr1nIWH2xNer/8oD tH3hDA8CD/dVA9lc2SGSmXZ3GAde19aVofaBHwOi1WTU4Mm9Ga9SesrbFG+MkrgmEt6X vNdb9uVYR3L7Ev8IRTJkHTfAIQPveyouqx1Pl1Yj9mrWK7Z3L3EQJ0aPBcgvRoKoF15o iGWzQyNB63Uqz/uWCFGja9yKWdhtKpga2/Jqieaxoh5j5Aqm11apnprU88hftnaP17N1 Zq8g== X-Gm-Message-State: AJcUukcx9XcX0MrGe2tT9Nxtf+VTjNbBJpOgDi/UrxUIw4wKjDwRcjxy dzZVzebxuSz2i/svTTRyQUzSvQ== X-Google-Smtp-Source: ALg8bN6ZiIfPXtdkG7rpCXLW/usPBmqSFbV0Sh0oYZeS++iEImwmFIASPZk8ESEDZiJUEnbcYz4qPg== X-Received: by 2002:a7b:c44d:: with SMTP id l13mr2979096wmi.144.1548252954021; Wed, 23 Jan 2019 06:15:54 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:53 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 7/9] gpio: mockup: change the type of 'offset' to unsigned int Date: Wed, 23 Jan 2019 15:15:36 +0100 Message-Id: <20190123141538.29408-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 This field can never be negative. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 0317917a3678..433adb3b4617 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -60,7 +60,7 @@ struct gpio_mockup_chip { struct gpio_mockup_dbgfs_private { struct gpio_mockup_chip *chip; struct gpio_desc *desc; - int offset; + unsigned int offset; }; static int gpio_mockup_ranges[GPIO_MOCKUP_MAX_RANGES]; From patchwork Wed Jan 23 14:15:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029967 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="ox6ry/Cu"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6lX1pRcz9s7T for ; Thu, 24 Jan 2019 01:16:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727195AbfAWOP5 (ORCPT ); Wed, 23 Jan 2019 09:15:57 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37648 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfAWOP5 (ORCPT ); Wed, 23 Jan 2019 09:15:57 -0500 Received: by mail-wr1-f67.google.com with SMTP id s12so2641959wrt.4 for ; Wed, 23 Jan 2019 06:15:55 -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=758F2G6mHwZtHqDlM/wuN9QC0Q3bwGTIieLyA4J0jgo=; b=ox6ry/CuI12etkFm4WDAmMwu0mXBDuOJ4lHU7XPGiMhPw1aPXZ6Wo+FIuM4wApFHbP fa4wdGWuF9SdiCb0VhN2tVki8Vgx7QbTuAxYgtQwj+HHIqc7toNluMut1Ncnw2mkkODl FOI5W/zLcNLz8+xnU6d31Y9Ql0V5UX5twySkfO2uHCI2olacIJAlflrzBcDsI4UfwRm5 myZDA9yz0Fu5FyILY+jFxC/Gaj+jbX2O8Q7/P+80ZvebcizskE2t9xs3v/zhVKNZmyob jM/RMqmLxe/wsaUnPNlJL3G4qhpIg2afWhl75NsR/FRKjKnznt46oqz3hbGiwDXCrGXM 7/5w== 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=758F2G6mHwZtHqDlM/wuN9QC0Q3bwGTIieLyA4J0jgo=; b=tn2Nj/G9H5oAOBG15YpdWRvPeRAaOoyqel0X0xgTtRjH+MIdsAs9ehsASqMYG4E9+p CkDcZads22+naFbMOeNqKRi693rYO6zu7QhwF23by9h34U79SZDhK7PsevZJp5SpuQZa rs+GEjNnl74EM7V2iEeiBtSJfL3VxPkhA9rJos2vfYTje8aaRYNTPu+MDUxQAqdIei28 rDzuneUjqJC5ZB6m1GVNxyKmElIgfVgGzkYznhp0mFtILBUG8gvn3Hs5PlNbgjZ30TFx brIjiWH32HocSNsPFikmwg3i+s9LhQBgRnAabxYbPY3MR739SvdduIuTO1bgL5QFIr7d J3zQ== X-Gm-Message-State: AJcUukdxpe97BYSCz0xtAmHf1NdrPEKl9LlHFpvTqidBeOqa+Q8Ld/wo qElM8BD0AwE3co38s/ksUhw/9g== X-Google-Smtp-Source: ALg8bN4bmnrlVydvG7UIZy4ZDYQr7FgwlSjaN5f0TvVLgzWxgSNhSVQsSNvZNuY5dIl4lPPd5Cb/qg== X-Received: by 2002:a5d:4b01:: with SMTP id v1mr2890432wrq.5.1548252955121; Wed, 23 Jan 2019 06:15:55 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:54 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 8/9] gpio: mockup: change the signature of unlocked get/set helpers Date: Wed, 23 Jan 2019 15:15:37 +0100 Message-Id: <20190123141538.29408-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 unlocked variants only get called from places where we already have the pointer to the underlying gpio_mockup_chip structure, so take it as parameter instead of struct gpio_chip. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 433adb3b4617..c498b0fbbec8 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -83,10 +83,9 @@ static int gpio_mockup_range_ngpio(unsigned int index) return gpio_mockup_ranges[index * 2 + 1]; } -static int __gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) +static int __gpio_mockup_get(struct gpio_mockup_chip *chip, + unsigned int offset) { - struct gpio_mockup_chip *chip = gpiochip_get_data(gc); - return chip->lines[offset].value; } @@ -96,7 +95,7 @@ static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) int val; mutex_lock(&chip->lock); - val = __gpio_mockup_get(gc, offset); + val = __gpio_mockup_get(chip, offset); mutex_unlock(&chip->lock); return val; @@ -110,7 +109,7 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc, mutex_lock(&chip->lock); for_each_set_bit(bit, mask, gc->ngpio) { - val = __gpio_mockup_get(gc, bit); + val = __gpio_mockup_get(chip, bit); __assign_bit(bit, bits, val); } mutex_unlock(&chip->lock); @@ -118,11 +117,9 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc, return 0; } -static void __gpio_mockup_set(struct gpio_chip *gc, +static void __gpio_mockup_set(struct gpio_mockup_chip *chip, unsigned int offset, int value) { - struct gpio_mockup_chip *chip = gpiochip_get_data(gc); - chip->lines[offset].value = !!value; } @@ -132,7 +129,7 @@ static void gpio_mockup_set(struct gpio_chip *gc, struct gpio_mockup_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->lock); - __gpio_mockup_set(gc, offset, value); + __gpio_mockup_set(chip, offset, value); mutex_unlock(&chip->lock); } @@ -144,7 +141,7 @@ static void gpio_mockup_set_multiple(struct gpio_chip *gc, mutex_lock(&chip->lock); for_each_set_bit(bit, mask, gc->ngpio) - __gpio_mockup_set(gc, bit, test_bit(bit, bits)); + __gpio_mockup_set(chip, bit, test_bit(bit, bits)); mutex_unlock(&chip->lock); } @@ -155,7 +152,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc, mutex_lock(&chip->lock); chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT; - __gpio_mockup_set(gc, offset, value); + __gpio_mockup_set(chip, offset, value); mutex_unlock(&chip->lock); return 0; From patchwork Wed Jan 23 14:15:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1029968 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="lVKAXl+s"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43l6lY1yxDz9sBn for ; Thu, 24 Jan 2019 01:16:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725995AbfAWOQI (ORCPT ); Wed, 23 Jan 2019 09:16:08 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41768 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbfAWOP5 (ORCPT ); Wed, 23 Jan 2019 09:15:57 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so2624972wrs.8 for ; Wed, 23 Jan 2019 06:15:56 -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=J5KSV3ziNybYTZ8uWoEllizkkf7KNygL/2Y9AB2R1io=; b=lVKAXl+sH4MgPdy9dIGIKleYdxhLHa1MQ9/IDsvvo4q+SuWng1FR+vS1cDq8WbH8vD lIGSMTLIJrl/ipmjv8bau+GqEJ4RqQlBbn04cAOYOS+TuWp3F+/NVH7VNfbzJ+rTDptd H5NzwD6M/uHI72cctEVtp9BZQgl5WmpEjpM4/D4zZ0ulEKVHEKKr1F0dV2e8dvBLFeJV m5fGFECPBy1BU61uIwxcz9P7rTrgS6DSF6nNk8ft2q6FUE8gnsf9H/eytY7W6U01e4Uv tTtrEuAYyHXGh6+sR0lbm60fZeRBeuYZvzphTo7CXOhNxJcFGcr3m4i7aPmPzvWNRtKc JqFA== 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=J5KSV3ziNybYTZ8uWoEllizkkf7KNygL/2Y9AB2R1io=; b=oNUb8QHJye9mb9ekaFXM2cG37jb32x8EVm4OBW+SPFCZ7iZP2AV93irxumFeD4majU 9Xwryar9+uPu+UuxuRL94mRngKesnAfMrJgL8Y+TTTNbxNcyR3W7vXjxofEEeFYBd7lO 4S8g1OcTo7mAlrSYR/+qV21g64sJamJcLrxwA65RVJJnjKDQuhQ+325Nj0nrDkwY2bvb A7cEakvXZUeahQkDXddjeMCbLRluXwG/WR47w06+f+tivInhL8Fb525bPki51dng76Do Urrba96G9eUk6nH3EBMmd5bNZ0uKwvmzvouQT4kOUztV/K+x0Khzt3wrQsfeYFswlsPr sF1g== X-Gm-Message-State: AJcUukdnUW3S5h9KG5W1cWxVdxwOY+cXlQjvsFEur68iJO9KOq57GiVA WAUo7BMiTgupC1adyWFnPUkk6w== X-Google-Smtp-Source: ALg8bN7fztgGY1xIAWjhH1T70kljs/gr97mp84iz/H0PGb39IeYOkE6ait84QzhI0+w1qG158O60+w== X-Received: by 2002:adf:891a:: with SMTP id s26mr2965672wrs.44.1548252956130; Wed, 23 Jan 2019 06:15:56 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a8sm29072997wme.23.2019.01.23.06.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 06:15:55 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Thomas Gleixner , Marc Zyngier , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 9/9] gpio: mockup: rework debugfs interface Date: Wed, 23 Jan 2019 15:15:38 +0100 Message-Id: <20190123141538.29408-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123141538.29408-1-brgl@bgdev.pl> References: <20190123141538.29408-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 Modify the way the debugfs interface works in gpio-mockup. Introduce the concept of dummy pull config which will keep the mockup lines in known state. The pull values can be modified by writing to the debugfs files corresponding to lines. Lines in input mode always report the current pull value, lines in output mode change the line value but it will revert back to the one specified by current pull when released. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 114 ++++++++++++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index c498b0fbbec8..a981ecd7c291 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -47,6 +47,7 @@ enum { struct gpio_mockup_line_status { int dir; int value; + int pull; }; struct gpio_mockup_chip { @@ -188,15 +189,56 @@ static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset) return irq_sim_irqnum(&chip->irqsim, offset); } -static ssize_t gpio_mockup_event_write(struct file *file, - const char __user *usr_buf, - size_t size, loff_t *ppos) +static void gpio_mockup_free(struct gpio_chip *gc, unsigned int offset) +{ + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + + __gpio_mockup_set(chip, offset, chip->lines[offset].pull); +} + +static ssize_t gpio_mockup_debugfs_read(struct file *file, + char __user *usr_buf, + size_t size, loff_t *ppos) +{ + struct gpio_mockup_dbgfs_private *priv; + struct gpio_mockup_chip *chip; + struct seq_file *sfile; + struct gpio_chip *gc; + char buf[3]; + int val, rv; + + if (*ppos != 0) + return 0; + + sfile = file->private_data; + priv = sfile->private; + chip = priv->chip; + gc = &chip->gc; + + val = gpio_mockup_get(gc, priv->offset); + snprintf(buf, sizeof(buf), "%d\n", val); + + rv = copy_to_user(usr_buf, buf, sizeof(buf)); + if (rv) + return rv; + + return sizeof(buf) - 1; +} + +static ssize_t gpio_mockup_debugfs_write(struct file *file, + const char __user *usr_buf, + size_t size, loff_t *ppos) { struct gpio_mockup_dbgfs_private *priv; struct gpio_mockup_chip *chip; struct seq_file *sfile; struct gpio_desc *desc; - int rv, val; + unsigned int irq_type; + struct gpio_chip *gc; + int rv, val, curr; + + if (*ppos != 0) + return -EINVAL; rv = kstrtoint_from_user(usr_buf, size, 0, &val); if (rv) @@ -206,24 +248,67 @@ static ssize_t gpio_mockup_event_write(struct file *file, sfile = file->private_data; priv = sfile->private; - desc = priv->desc; chip = priv->chip; + gc = &chip->gc; + desc = &gc->gpiodev->descs[priv->offset]; + + mutex_lock(&chip->lock); + + if (!test_bit(FLAG_IS_OUT, &desc->flags)) { + if (test_bit(FLAG_REQUESTED, &desc->flags)) { + curr = __gpio_mockup_get(chip, priv->offset); + if (curr == val) + goto out; - gpiod_set_value_cansleep(desc, val); - irq_sim_fire(&chip->irqsim, priv->offset); + irq_type = irq_sim_get_type(&chip->irqsim, + priv->offset); + + if ((val == 0 && (irq_type & IRQ_TYPE_EDGE_FALLING)) || + (val == 1 && (irq_type & IRQ_TYPE_EDGE_RISING))) + irq_sim_fire(&chip->irqsim, priv->offset); + } + + __gpio_mockup_set(chip, priv->offset, val); + } + +out: + chip->lines[priv->offset].pull = val; + mutex_unlock(&chip->lock); return size; } -static int gpio_mockup_event_open(struct inode *inode, struct file *file) +static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file) { return single_open(file, NULL, inode->i_private); } -static const struct file_operations gpio_mockup_event_ops = { +/* + * Each mockup chip is represented by a directory named after the chip's device + * name under /sys/kernel/debug/gpio-mockup/. Each line is represented by + * a file using the line's offset as the name under the chip's directory. + * + * Reading from the line's file yields the current *value*, writing to the + * line's file changes the current *pull*. Default pull for mockup lines is + * down. + * + * Examples: + * - when a line pulled down is requested in output mode and driven high, its + * value will return to 0 once it's released + * - when the line is requested in output mode and driven high, writing 0 to + * the corresponding debugfs file will change the pull to down but the + * reported value will still be 1 until the line is released + * - line requested in input mode always reports the same value as its pull + * configuration + * - when the line is requested in input mode and monitored for events, writing + * the same value to the debugfs file will be a noop, while writing the + * opposite value will generate a dummy interrupt with an appropriate edge + */ +static const struct file_operations gpio_mockup_debugfs_ops = { .owner = THIS_MODULE, - .open = gpio_mockup_event_open, - .write = gpio_mockup_event_write, + .open = gpio_mockup_debugfs_open, + .read = gpio_mockup_debugfs_read, + .write = gpio_mockup_debugfs_write, .llseek = no_llseek, }; @@ -258,7 +343,7 @@ static void gpio_mockup_debugfs_setup(struct device *dev, priv->desc = &gc->gpiodev->descs[i]; evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv, - &gpio_mockup_event_ops); + &gpio_mockup_debugfs_ops); if (IS_ERR_OR_NULL(evfile)) goto err; } @@ -266,7 +351,7 @@ static void gpio_mockup_debugfs_setup(struct device *dev, return; err: - dev_err(dev, "error creating debugfs event files\n"); + dev_err(dev, "error creating debugfs files\n"); } static int gpio_mockup_name_lines(struct device *dev, @@ -342,6 +427,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) gc->direction_input = gpio_mockup_dirin; gc->get_direction = gpio_mockup_get_direction; gc->to_irq = gpio_mockup_to_irq; + gc->free = gpio_mockup_free; chip->lines = devm_kcalloc(dev, gc->ngpio, sizeof(*chip->lines), GFP_KERNEL); @@ -415,7 +501,7 @@ static int __init gpio_mockup_init(void) return -EINVAL; } - gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup-event", NULL); + gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL); if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) gpio_mockup_err("error creating debugfs directory\n");