From patchwork Fri May 18 21:09:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10412163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B832060230 for ; Fri, 18 May 2018 21:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A59EB28AB7 for ; Fri, 18 May 2018 21:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99D3F28AF1; Fri, 18 May 2018 21:10:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2AD4428AB7 for ; Fri, 18 May 2018 21:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1NelT7lKHZGCXATxVJluH9GCS504tsLWZBcbrZ54xjE=; b=BAEA2l+Of4A8eXvbYbn23kQSJg yqouhtrWUicJ1Eta4KIEoF5DFBhpUxnUtgQ1uOArvJTDuYU6s6tVebdZz7SeTPVJz1PDy5+Wjmcsv 4Pgv4tZdxeguaz/I9Vz9Ck7j/kouhwgoDKHNHApChe3vMg8DOjDkjzR6tzIraIEl8NK1b/VarvLFt 6/PTSIg1FJ1uJhXfM+SWKQGkDbu6cr/ghHeyeNWFCciwJ4DgCkOqC1SVJd3pkZnPp+KPmKFR2VO/S IuFwANQ1mYl3OcurNWUqenq7014UWYmFQSv1fUD1mfdDwqHN4wo+ZD+wAZkGfO1dku4a7WJT2JMoY 6mDF4jPw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJmdv-0003Pa-7S; Fri, 18 May 2018 21:10:27 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJmdf-00027U-Li; Fri, 18 May 2018 21:10:13 +0000 Received: by mail-lf0-x242.google.com with SMTP id j193-v6so15869097lfg.6; Fri, 18 May 2018 14:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B6aqZwxP+OJ/Kv0tGiJH5UJdVCPy/mS72mZDCiwri10=; b=mL4LkNuFdC6x2CMYdFBIdQ2kHq6dzUms07dREnKjQUehYo1IhTPL98JuSctop9QUEg 1BdX/G+W2RHkR9HroCVRxJ8uGtG8mxZ0MFoQ90tI5rHNMSkxUryeSnCtXDYbrXuwYXh5 qrCqzTpuRB1r385TW1qILZDdGGfVRLGx98SSiCEvAodMOXB22C1AQ/ViXR96paMTXioX UsBo7fdNcTm6x1FFDDJ/2Rov6fsAZjOVykjY0vH1y8ZvAjCpDfXZn9DHG6LkVVg1ay2I FTlzSK9EiJR5atkJbz3Huz+j9Lx8YwaEdth32EKjKEhVEuMjpmMkZhDovp7btFMM7wYw pz4w== 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=B6aqZwxP+OJ/Kv0tGiJH5UJdVCPy/mS72mZDCiwri10=; b=nUMsSQyK91Yq+hs6pN1jOWHsMe0HNplorRjJcs87cEeC2O0DzKKor1/FaRulsf+4VI 8miAYBi9n7VRFpdiv/9+DKHTl9hIymSZnYXg8AOhgysO2CAh44lZj+c0ZieYhY2N+ODa 4cXK8NNbCUmmXgIPcI+frZixEGkjTCiA2oez/mR5fBaRalWmKfcRfMJx1duU2IZXbg9R 3IeAhTaerPVuhO+Ta25FImMJvXR9SOPMi6Jssx+p2OQH3oSfiXijLxmtPrQh4kUFTmm+ LHI3zJpqFnhtR/8oXXiIfDTx29JUEDxE6N6Cg/Mi4H2GyluzGn1QOJ1ccD1e+rgjTDaG 5QQQ== X-Gm-Message-State: ALKqPwfkI/aLmVsDNkmu5D3QaeuZNJlFwdQlmez+eUzxXnqnmGR/LhV6 jyWzVHXdFKp9KRMtUcwNVgg= X-Google-Smtp-Source: AB8JxZpuZe1VD1NyOVLRB/2ywuNN2LMdZIcO9AnKLVGsiIuXKOLU3E2/xKZrxx+nn8/F0Myw4rnS8g== X-Received: by 2002:a2e:6c10:: with SMTP id h16-v6mr6515303ljc.81.1526677802302; Fri, 18 May 2018 14:10:02 -0700 (PDT) Received: from localhost.localdomain (apn-31-0-34-132.dynamic.gprs.plus.pl. [31.0.34.132]) by smtp.gmail.com with ESMTPSA id 23-v6sm2057026lfw.64.2018.05.18.14.09.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 14:10:01 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren , Dmitry Torokhov , Boris Brezillon , Tomi Valkeinen , Mark Brown Subject: [PATCH 2/6] Input: ams_delta_serio: use GPIO lookup table Date: Fri, 18 May 2018 23:09:50 +0200 Message-Id: <20180518210954.29044-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518210954.29044-1-jmkrzyszt@gmail.com> References: <20180518210954.29044-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180518_141011_718443_BE023D3A X-CRM114-Status: GOOD ( 15.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, Aaro Koskinen , Richard Weinberger , Janusz Krzysztofik , Liam Girdwood , linux-kernel@vger.kernel.org, Peter Ujfalusi , linux-mtd@lists.infradead.org, Jarkko Nikula , linux-input@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Now as the Amstrad Delta board provides GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and use the table to locate required GPIO pins. Declare static variables for storing GPIO descriptors and replace gpio_ functions with their gpiod_ equivalents. Pin naming used by the driver should be followed while respective GPIO lookup table is initialized by a board init code. Created and tested against linux-4.17-rc3, on top of patch 1/6 "ARM: OMAP1: ams-delta: add GPIO lookup tables" Signed-off-by: Janusz Krzysztofik --- drivers/input/serio/ams_delta_serio.c | 98 +++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 3df501c3421b..dd1f8f118c08 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -20,14 +20,13 @@ * However, when used with the E3 mailboard that producecs non-standard * scancodes, a custom key table must be prepared and loaded from userspace. */ -#include +#include #include #include #include #include #include -#include #include @@ -36,6 +35,10 @@ MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); MODULE_LICENSE("GPL"); static struct serio *ams_delta_serio; +static struct gpio_desc *gpiod_data; +static struct gpio_desc *gpiod_clock; +static struct gpio_desc *gpiod_power; +static struct gpio_desc *gpiod_dataout; static int check_data(int data) { @@ -92,7 +95,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) static int ams_delta_serio_open(struct serio *serio) { /* enable keyboard */ - gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1); + gpiod_set_value(gpiod_power, 1); return 0; } @@ -100,32 +103,9 @@ static int ams_delta_serio_open(struct serio *serio) static void ams_delta_serio_close(struct serio *serio) { /* disable keyboard */ - gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0); + gpiod_set_value(gpiod_power, 0); } -static const struct gpio ams_delta_gpios[] __initconst_or_module = { - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATA, - .flags = GPIOF_DIR_IN, - .label = "serio-data", - }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK, - .flags = GPIOF_DIR_IN, - .label = "serio-clock", - }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, - .flags = GPIOF_OUT_INIT_LOW, - .label = "serio-power", - }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT, - .flags = GPIOF_OUT_INIT_LOW, - .label = "serio-dataout", - }, -}; - static int __init ams_delta_serio_init(void) { int err; @@ -145,36 +125,62 @@ static int __init ams_delta_serio_init(void) strlcpy(ams_delta_serio->phys, "GPIO/serio0", sizeof(ams_delta_serio->phys)); - err = gpio_request_array(ams_delta_gpios, - ARRAY_SIZE(ams_delta_gpios)); - if (err) { - pr_err("ams_delta_serio: Couldn't request gpio pins\n"); + gpiod_data = gpiod_get(NULL, "data", GPIOD_IN); + if (IS_ERR(gpiod_data)) { + err = PTR_ERR(gpiod_data); + pr_err("%s: 'data' GPIO request failed (%d)\n", __func__, + err); goto serio; } + gpiod_clock = gpiod_get(NULL, "clock", GPIOD_IN); + if (IS_ERR(gpiod_clock)) { + err = PTR_ERR(gpiod_clock); + pr_err("%s: 'clock' GPIO request failed (%d)\n", __func__, + err); + goto gpio_data; + } + gpiod_power = gpiod_get(NULL, "power", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_power)) { + err = PTR_ERR(gpiod_power); + pr_err("%s: 'power' GPIO request failed (%d)\n", __func__, + err); + goto gpio_clock; + } + gpiod_dataout = gpiod_get(NULL, "dataout", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_dataout)) { + err = PTR_ERR(gpiod_dataout); + pr_err("%s: 'dataout' GPIO request failed (%d)\n", + __func__, err); + goto gpio_power; + } - err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), - ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, - "ams-delta-serio", 0); + err = request_irq(gpiod_to_irq(gpiod_clock), + ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, + "ams-delta-serio", 0); if (err < 0) { - pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", - gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); - goto gpio; + pr_err("%s: 'clock' GPIO interrupt request failed (%d)\n", + __func__, err); + goto gpio_dataout; } /* * Since GPIO register handling for keyboard clock pin is performed * at FIQ level, switch back from edge to simple interrupt handler * to avoid bad interaction. */ - irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), - handle_simple_irq); + irq_set_handler(gpiod_to_irq(gpiod_clock), handle_simple_irq); serio_register_port(ams_delta_serio); dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name); return 0; -gpio: - gpio_free_array(ams_delta_gpios, - ARRAY_SIZE(ams_delta_gpios)); +gpio_dataout: + gpiod_put(gpiod_dataout); +gpio_power: + gpiod_put(gpiod_power); +gpio_clock: + gpiod_put(gpiod_clock); +gpio_data: + gpiod_put(gpiod_data); serio: kfree(ams_delta_serio); return err; @@ -184,8 +190,10 @@ module_init(ams_delta_serio_init); static void __exit ams_delta_serio_exit(void) { serio_unregister_port(ams_delta_serio); - free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); - gpio_free_array(ams_delta_gpios, - ARRAY_SIZE(ams_delta_gpios)); + free_irq(gpiod_to_irq(gpiod_clock), 0); + gpiod_put(gpiod_dataout); + gpiod_put(gpiod_power); + gpiod_put(gpiod_clock); + gpiod_put(gpiod_data); } module_exit(ams_delta_serio_exit);