From patchwork Fri Jul 22 08:42:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Reid X-Patchwork-Id: 9243191 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 ABC6060756 for ; Fri, 22 Jul 2016 08:52:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BF002074F for ; Fri, 22 Jul 2016 08:52:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90C2C27E71; Fri, 22 Jul 2016 08:52:22 +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 3B7672074F for ; Fri, 22 Jul 2016 08:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751572AbcGVIwS (ORCPT ); Fri, 22 Jul 2016 04:52:18 -0400 Received: from 203-59-230-133.perm.iinet.net.au ([203.59.230.133]:38134 "EHLO preid-centos7.electromag.com.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751441AbcGVIwR (ORCPT ); Fri, 22 Jul 2016 04:52:17 -0400 X-Greylist: delayed 570 seconds by postgrey-1.27 at vger.kernel.org; Fri, 22 Jul 2016 04:52:16 EDT Received: by preid-centos7.electromag.com.au (Postfix, from userid 1000) id 499EF300D960A; Fri, 22 Jul 2016 16:42:43 +0800 (AWST) From: Phil Reid To: sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org, linux-pm@vger.kernel.org Cc: Phil Reid Subject: [PATCH 2/4] power: sbs-battery: Request threaded irq and fix dev callback cookie Date: Fri, 22 Jul 2016 16:42:36 +0800 Message-Id: <1469176958-69804-3-git-send-email-preid@electromag.com.au> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1469176958-69804-1-git-send-email-preid@electromag.com.au> References: <1469176958-69804-1-git-send-email-preid@electromag.com.au> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the battery detect gpio can not be used with a chained interrupt controller that requires threaded irq handlers. Use threaded irq instead. In addition this was not going to be working at present because chip->power_supply is assigned after the request irq call. Signed-off-by: Phil Reid --- drivers/power/sbs-battery.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/power/sbs-battery.c b/drivers/power/sbs-battery.c index 20f3be6..f9012ed 100644 --- a/drivers/power/sbs-battery.c +++ b/drivers/power/sbs-battery.c @@ -162,7 +162,6 @@ struct sbs_info { bool is_present; bool gpio_detect; bool enable_detection; - int irq; int last_state; int poll_time; struct delayed_work work; @@ -661,7 +660,8 @@ done: static irqreturn_t sbs_irq(int irq, void *devid) { - struct power_supply *battery = devid; + struct sbs_info *chip = devid; + struct power_supply *battery = chip->power_supply; power_supply_changed(battery); @@ -869,9 +869,9 @@ static int sbs_probe(struct i2c_client *client, goto skip_gpio; } - rc = request_irq(irq, sbs_irq, + rc = devm_request_threaded_irq(&client->dev, irq, NULL, sbs_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - dev_name(&client->dev), chip->power_supply); + dev_name(&client->dev), chip); if (rc) { dev_warn(&client->dev, "Failed to request irq: %d\n", rc); gpio_free(pdata->battery_detect); @@ -879,8 +879,6 @@ static int sbs_probe(struct i2c_client *client, goto skip_gpio; } - chip->irq = irq; - skip_gpio: /* * Before we register, we might need to make sure we can actually talk @@ -915,8 +913,6 @@ skip_gpio: return 0; exit_psupply: - if (chip->irq) - free_irq(chip->irq, chip->power_supply); if (chip->gpio_detect) gpio_free(pdata->battery_detect); @@ -927,8 +923,6 @@ static int sbs_remove(struct i2c_client *client) { struct sbs_info *chip = i2c_get_clientdata(client); - if (chip->irq) - free_irq(chip->irq, chip->power_supply); if (chip->gpio_detect) gpio_free(chip->pdata->battery_detect);