From patchwork Mon Oct 10 16:42:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 9369735 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 1EF046048F for ; Mon, 10 Oct 2016 16:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F559296A3 for ; Mon, 10 Oct 2016 16:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02A8A2972E; Mon, 10 Oct 2016 16:43:40 +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=unavailable 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 9DFE6296A3 for ; Mon, 10 Oct 2016 16:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753043AbcJJQm7 (ORCPT ); Mon, 10 Oct 2016 12:42:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33548 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbcJJQm5 (ORCPT ); Mon, 10 Oct 2016 12:42:57 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F40D3F1F6; Mon, 10 Oct 2016 16:42:57 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9AGgb2V021567; Mon, 10 Oct 2016 12:42:55 -0400 From: Benjamin Tissoires To: Wolfram Sang , Dmitry Torokhov Cc: Jean Delvare , Jonathan Corbet , KT Liao , linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 7/8] Input: elan_i2c - store the irq in struct elan_tp_data Date: Mon, 10 Oct 2016 18:42:34 +0200 Message-Id: <1476117755-8113-8-git-send-email-benjamin.tissoires@redhat.com> In-Reply-To: <1476117755-8113-1-git-send-email-benjamin.tissoires@redhat.com> References: <1476117755-8113-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Oct 2016 16:42:57 +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 And make sure we have one available. Signed-off-by: Benjamin Tissoires --- new in v4 --- drivers/input/mouse/elan_i2c_core.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index d15b338..6f16eb4 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -62,6 +62,7 @@ struct elan_tp_data { struct i2c_client *client; struct input_dev *input; struct regulator *vcc; + int irq; const struct elan_transport_ops *ops; @@ -457,7 +458,7 @@ static int elan_update_firmware(struct elan_tp_data *data, dev_dbg(&client->dev, "Starting firmware update....\n"); - disable_irq(client->irq); + disable_irq(data->irq); data->in_fw_update = true; retval = __elan_update_firmware(data, fw); @@ -471,7 +472,7 @@ static int elan_update_firmware(struct elan_tp_data *data, } data->in_fw_update = false; - enable_irq(client->irq); + enable_irq(data->irq); return retval; } @@ -599,7 +600,7 @@ static ssize_t calibrate_store(struct device *dev, if (retval) return retval; - disable_irq(client->irq); + disable_irq(data->irq); data->mode |= ETP_ENABLE_CALIBRATE; retval = data->ops->set_mode(client, data->mode); @@ -645,7 +646,7 @@ out_disable_calibrate: retval = error; } out: - enable_irq(client->irq); + enable_irq(data->irq); mutex_unlock(&data->sysfs_mutex); return retval ?: count; } @@ -711,7 +712,7 @@ static ssize_t acquire_store(struct device *dev, struct device_attribute *attr, if (retval) return retval; - disable_irq(client->irq); + disable_irq(data->irq); data->baseline_ready = false; @@ -753,7 +754,7 @@ out_disable_calibrate: retval = error; } out: - enable_irq(client->irq); + enable_irq(data->irq); mutex_unlock(&data->sysfs_mutex); return retval ?: count; } @@ -1026,6 +1027,9 @@ static int elan_probe(struct i2c_client *client, struct elan_tp_data *data; unsigned long irqflags; int error; + int irq; + + irq = client->irq; if (IS_ENABLED(CONFIG_MOUSE_ELAN_I2C_I2C) && i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { @@ -1041,6 +1045,11 @@ static int elan_probe(struct i2c_client *client, return -EIO; } + if (irq <= 0) { + dev_err(dev, "no IRQ provided.\n"); + return -ENODEV; + } + data = devm_kzalloc(&client->dev, sizeof(struct elan_tp_data), GFP_KERNEL); if (!data) @@ -1049,6 +1058,7 @@ static int elan_probe(struct i2c_client *client, i2c_set_clientdata(client, data); data->ops = transport_ops; + data->irq = irq; data->client = client; init_completion(&data->fw_completion); mutex_init(&data->sysfs_mutex); @@ -1121,12 +1131,12 @@ static int elan_probe(struct i2c_client *client, */ irqflags = client->dev.of_node ? 0 : IRQF_TRIGGER_FALLING; - error = devm_request_threaded_irq(&client->dev, client->irq, + error = devm_request_threaded_irq(&client->dev, data->irq, NULL, elan_isr, irqflags | IRQF_ONESHOT, client->name, data); if (error) { - dev_err(&client->dev, "cannot register irq=%d\n", client->irq); + dev_err(&client->dev, "cannot register irq=%d\n", data->irq); return error; } @@ -1179,12 +1189,12 @@ static int __maybe_unused elan_suspend(struct device *dev) if (ret) return ret; - disable_irq(client->irq); + disable_irq(data->irq); if (device_may_wakeup(dev)) { ret = elan_sleep(data); /* Enable wake from IRQ */ - data->irq_wake = (enable_irq_wake(client->irq) == 0); + data->irq_wake = (enable_irq_wake(data->irq) == 0); } else { ret = elan_disable_power(data); } @@ -1200,7 +1210,7 @@ static int __maybe_unused elan_resume(struct device *dev) int error; if (device_may_wakeup(dev) && data->irq_wake) { - disable_irq_wake(client->irq); + disable_irq_wake(data->irq); data->irq_wake = false; } @@ -1215,7 +1225,7 @@ static int __maybe_unused elan_resume(struct device *dev) dev_err(dev, "initialize when resuming failed: %d\n", error); err: - enable_irq(data->client->irq); + enable_irq(data->irq); return error; }