From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987AbbIOUxg (ORCPT ); Tue, 15 Sep 2015 16:53:36 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:38068 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbbIOUxf (ORCPT ); Tue, 15 Sep 2015 16:53:35 -0400 Subject: Re: [PATCH v4 7/7] power: bq27xxx_battery: Add interrupt handling support To: Andreas Dannenberg References: <1442265973-32261-1-git-send-email-afd@ti.com> <1442265973-32261-8-git-send-email-afd@ti.com> <20150915184714.GB18055@beast> CC: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Dan Murphy , , From: "Andrew F. Davis" Message-ID: <55F88532.5010507@ti.com> Date: Tue, 15 Sep 2015 15:53:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150915184714.GB18055@beast> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/15/2015 01:47 PM, Andreas Dannenberg wrote: > On Mon, Sep 14, 2015 at 04:26:13PM -0500, Andrew F. Davis wrote: >> Some devices have a pin that can generate an interrupt when >> the battery's status changes. Add an interrupt handler to >> read the new battery status. >> >> Signed-off-by: Andrew F. Davis >> --- >> drivers/power/bq27xxx_battery.c | 23 +++++++++++++++++++++++ >> 1 file changed, 23 insertions(+) >> >> diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/bq27xxx_battery.c >> index 10be8a6..29fdcd7 100644 >> --- a/drivers/power/bq27xxx_battery.c >> +++ b/drivers/power/bq27xxx_battery.c >> @@ -48,6 +48,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include >> @@ -732,6 +733,15 @@ static void bq27xxx_battery_update(struct bq27xxx_device_info *di) >> di->last_update = jiffies; >> } >> >> +static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data) >> +{ >> + struct bq27xxx_device_info *di = data; >> + >> + bq27xxx_battery_update(di); >> + >> + return IRQ_HANDLED; >> +} >> + >> static void bq27xxx_battery_poll(struct work_struct *work) >> { >> struct bq27xxx_device_info *di = >> @@ -1137,6 +1147,19 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client, >> >> i2c_set_clientdata(client, di); >> >> + if (client->irq) { >> + retval = devm_request_threaded_irq(&client->dev, client->irq, >> + NULL, bq27xxx_battery_irq_handler_thread, >> + IRQF_ONESHOT, >> + name, di); > > Hi Andrew, > I think it'll be better if you explicitly specify the rising vs. falling > edge interrupt flags according to exactly what the bq27xxx will trigger > on to ensure the corresponding GPIO module is always configured properly. > That was how I was going to have it, but this may be device dependent, so I decided to leave it up to the interrupt controller and set it with DT: interrupts = <28 IRQ_TYPE_EDGE_FALLING>; > While we are at it, was the platform-data based initialization in > conjunction with interrupts tested? > The only time we initialize with platform-data is when we are wired with HDQ, in that case this IRQ code does not get called, so nothing changes. Regards, Andrew > Regards, > > -- > Andreas Dannenberg > Texas Instruments Inc > > >> + if (retval) { >> + dev_err(&client->dev, >> + "Unable to register IRQ %d error %d\n", >> + client->irq, retval); >> + return retval; >> + } >> + } >> + >> return 0; >> >> batt_failed: >> -- >> 1.9.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-pm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html