Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp6898172imm; Sun, 20 May 2018 13:17:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqmCT80ooDCx1jWsgSgzZQXyKNKeZfjB3KThNuWU6pmm+vzFavu6+caKU/6IrWIxGtkJCAV X-Received: by 2002:a17:902:700a:: with SMTP id y10-v6mr17948884plk.265.1526847465022; Sun, 20 May 2018 13:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526847464; cv=none; d=google.com; s=arc-20160816; b=r26dy/OLoeYmSG+EqB7P7i8oBw0vnAo4IcHv+RiIzwfExC5j+BchHFml2Z9Z6lZnko 5AstG5HPoaCWn6egKynrhNai6iBrtJVSaVfuRFJkKk4ooUKBlukHHuzvMuY79zyAm2XT FD2yEmckFDBy27RjV14dKK1NyB9OpG4wgpbZb89DFpKoUlsoppGONG0/+Y9KtmpenPnn 9J0zCeUZydao+/lZkngRTH2M2rjGeLaEXfjbUSY+60dEVRlO7y/y/ZCjoYsTUm7tCQ+t HbklxYKG21PKvkbnzKHYCAjP/sUrU8ih+xYEC9KqlAjUq+oVMLq1PdDuKsrXReJi8hCl zywA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ffomXAhHtCE/+bFrQP4XahPClF/VokyJDj5D9ZgieUI=; b=epoQMfIvqUjA8wlcMvj+X4iUhZfDwv18kejgHjRQnG7p4F2cor4QpiCWGKgiecmbuI Gwt3GvKrwGzPsbkXL6/K+wTSIA7iwr9TzHLtcj8YHMJks4r1EAd1M0dRSLcGeQDSCCgI EVDMLEfCqV2SH9n4ZNRUM3kZk1oMIQBdYiwQ75or2XsCF4FiRbwu8uiZsC8K4bvf3fxC +IgkTyWF83VPjiZ5Q1IpybYyCSorpmTlXVGLe0KRLH7yWL8M5jXJ7S+T8GvS7M2vA4va wS/UW0k5l++92g/bO20iWsVY/JGezjQ5pgMOGKcZrCWy8UNRCGELS1qndqVjFQ1lsohW 5dTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BLbzpbrm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si12334933pln.72.2018.05.20.13.17.28; Sun, 20 May 2018 13:17:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BLbzpbrm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751521AbeETURR (ORCPT + 99 others); Sun, 20 May 2018 16:17:17 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:38271 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067AbeETURO (ORCPT ); Sun, 20 May 2018 16:17:14 -0400 Received: by mail-pg0-f65.google.com with SMTP id n9-v6so5425822pgq.5; Sun, 20 May 2018 13:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ffomXAhHtCE/+bFrQP4XahPClF/VokyJDj5D9ZgieUI=; b=BLbzpbrmCW7GZMzDtHr1Xr11NtSmK+/bX3O8Ud4tLZ9sa/4/MqaPdRAgAk+e4HQvfN xQ/1ZUZ2x8xWh0/TVlZNT+73mLFTg6QJhOrfz9Jtjiby/OxygrCx5r1haYlpwGkGWHkF 31KhDLpKO4g4Eg2zsPE0K/auZo+1zuQrc43Z7dVFoqoHGAXhJeeVPrlj2XyiSoOisCDx 0LmWVhpwmqDRlVcGmj/da4S92QRXs4i5YwNDfW0F4QVTUMT0rn0lMdb04iUSz8SgfNEx l4uUiv7JjJgpQtT/sk0EHE1tPMxGNHjEhJEqPk79Q/apARI8OIiOUm3j62g2vfMmv6th 9k+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ffomXAhHtCE/+bFrQP4XahPClF/VokyJDj5D9ZgieUI=; b=hBdxleWABIqxczAQ1kAn+ir1Y7qo+PuQ5XncX0i9TFv/qN/ZJPSrRYdcQ5Cb8Bp3C5 gIvSaDofHJAHEa6fku+28pOWXFYBB5GV+ybNh5e6pttaMS4oUJdv9MfZAMEHQOI36tVw osmqK59993CcrM6BhnmfyDcS4nUDfzj2fB7ylEDL3SlIrmt+laNDXjNrLW6jgEqd9NJF 4StEgl2V4Z+4+B5UH04YRrtkDXsrxQx2G5Rsm6xoIYTUJt/ZKxkLppbydRWNfN6qbZjF MtTU2tkYtBWzREML/QPwmOx1oK2a6m+79opM4rqgTJwg7gxsK/ZYrCgOEILccwWkjZZP 6V+A== X-Gm-Message-State: ALKqPwf+1WZ4rlKeZ/H1TzMazx3nUQbyNcCOLaOtgpDv5c5UHtFSrcLh ecssKzzt03jG98dGhlIxwETnG4CI X-Received: by 2002:a63:8bca:: with SMTP id j193-v6mr12964502pge.300.1526847433737; Sun, 20 May 2018 13:17:13 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id o84-v6sm27766829pfi.27.2018.05.20.13.17.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 May 2018 13:17:12 -0700 (PDT) Date: Sun, 20 May 2018 13:17:10 -0700 From: Dmitry Torokhov To: Janusz Krzysztofik Cc: Tony Lindgren , Boris Brezillon , Tomi Valkeinen , Mark Brown , Aaro Koskinen , Richard Weinberger , Peter Ujfalusi , Jarkko Nikula , Liam Girdwood , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 2/6] Input: ams_delta_serio: use GPIO lookup table Message-ID: <20180520201710.GB119427@dtor-ws> References: <20180518210954.29044-1-jmkrzyszt@gmail.com> <20180518210954.29044-2-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180518210954.29044-2-jmkrzyszt@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Janusz, On Fri, May 18, 2018 at 11:09:50PM +0200, Janusz Krzysztofik wrote: > 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; Since you are doing the conversion: it does not appear that all these are necessarily GPIOs; for example should not power be gpio-regulator and data be simply expressed as IRQ resource? And the driver to be converted into a platform driver? I think this needs to be done first, because otherwise you are committing to a certain binding and will have hard time changing it later. Thanks. > > 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); > -- > 2.16.1 > -- Dmitry