From patchwork Mon Oct 30 17:40:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10032957 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 2B80B60291 for ; Mon, 30 Oct 2017 17:40:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19D2C28903 for ; Mon, 30 Oct 2017 17:40:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EBD928915; Mon, 30 Oct 2017 17:40:59 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2A34288B9 for ; Mon, 30 Oct 2017 17:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932720AbdJ3Rk4 (ORCPT ); Mon, 30 Oct 2017 13:40:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40610 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932673AbdJ3Rkz (ORCPT ); Mon, 30 Oct 2017 13:40:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 498DC13AA2; Mon, 30 Oct 2017 17:40:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 498DC13AA2 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com Received: from shalem.localdomain.com (ovpn-116-133.ams2.redhat.com [10.36.116.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE2A2600C9; Mon, 30 Oct 2017 17:40:51 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v3 1/4] Input: gpio_keys - store a pointer to driver_data in button_data Date: Mon, 30 Oct 2017 18:40:47 +0100 Message-Id: <20171030174050.30375-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 30 Oct 2017 17:40:55 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of a pointer to the input_dev, store a pointer the gpio_keys_drvdata struct in struct gpio_button_data, so that per button ISRs can access the entire driver-data struct and we don't need to store a copy of global state (e.g. the suspended flag) for each button. Signed-off-by: Hans de Goede --- Changes in v3: -This is a new patch in v3 of this patch-set --- drivers/input/keyboard/gpio_keys.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 87e613dc33b8..36ab7daba957 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -31,9 +31,11 @@ #include #include +struct gpio_keys_drvdata; + struct gpio_button_data { const struct gpio_keys_button *button; - struct input_dev *input; + struct gpio_keys_drvdata *ddata; struct gpio_desc *gpiod; unsigned short *code; @@ -360,7 +362,7 @@ static const struct attribute_group gpio_keys_attr_group = { static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) { const struct gpio_keys_button *button = bdata->button; - struct input_dev *input = bdata->input; + struct input_dev *input = bdata->ddata->input; unsigned int type = button->type ?: EV_KEY; int state; @@ -388,19 +390,20 @@ static void gpio_keys_gpio_work_func(struct work_struct *work) gpio_keys_gpio_report_event(bdata); if (bdata->button->wakeup) - pm_relax(bdata->input->dev.parent); + pm_relax(bdata->ddata->input->dev.parent); } static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) { struct gpio_button_data *bdata = dev_id; + struct input_dev *input = bdata->ddata->input; BUG_ON(irq != bdata->irq); if (bdata->button->wakeup) { const struct gpio_keys_button *button = bdata->button; - pm_stay_awake(bdata->input->dev.parent); + pm_stay_awake(input->dev.parent); if (bdata->suspended && (button->type == 0 || button->type == EV_KEY)) { /* @@ -408,7 +411,7 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) * already released by the time we got interrupt * handler to run. */ - input_report_key(bdata->input, button->code, 1); + input_report_key(input, button->code, 1); } } @@ -422,7 +425,7 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) static void gpio_keys_irq_timer(struct timer_list *t) { struct gpio_button_data *bdata = from_timer(bdata, t, release_timer); - struct input_dev *input = bdata->input; + struct input_dev *input = bdata->ddata->input; unsigned long flags; spin_lock_irqsave(&bdata->lock, flags); @@ -437,7 +440,7 @@ static void gpio_keys_irq_timer(struct timer_list *t) static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) { struct gpio_button_data *bdata = dev_id; - struct input_dev *input = bdata->input; + struct input_dev *input = bdata->ddata->input; unsigned long flags; BUG_ON(irq != bdata->irq); @@ -446,7 +449,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) if (!bdata->key_pressed) { if (bdata->button->wakeup) - pm_wakeup_event(bdata->input->dev.parent, 0); + pm_wakeup_event(input->dev.parent, 0); input_event(input, EV_KEY, *bdata->code, 1); input_sync(input); @@ -493,7 +496,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, int irq; int error; - bdata->input = input; + bdata->ddata = ddata; bdata->button = button; spin_lock_init(&bdata->lock);