From: Liam Breck <liam@networkimprov.net>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Sebastian Reichel <sre@kernel.org>,
linux-pm@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
Liam Breck <kernel@networkimprov.net>
Subject: Re: [PATCH v4 4/4] power: bq24190_charger: Delay before polling reset flag
Date: Sat, 8 Apr 2017 12:25:41 -0700 [thread overview]
Message-ID: <CAKvHMgSzSg98JkfwhSCcLoVhBedND3w0UqTeeCP=HwbGVSJSJQ@mail.gmail.com> (raw)
In-Reply-To: <0ce727cf-7871-89a8-7bec-7915f2699a73@redhat.com>
On Sat, Apr 8, 2017 at 2:58 AM, Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 07-04-17 23:46, Liam Breck wrote:
>>
>> Hi Hans,
>>
>> On Thu, Apr 6, 2017 at 12:20 AM, Hans de Goede <hdegoede@redhat.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> On 06-04-17 05:10, Liam Breck wrote:
>>>>
>>>>
>>>> From: Liam Breck <kernel@networkimprov.net>
>>>>
>>>> On chip reset, polling loop was reading reset register immediately.
>>>> Instead, call udelay() before reading chip register.
>>>
>>>
>>>
>>> Can you extend the commit message to explain why udelay is being
>>> called ? IOW what is the problem with reading the register
>>> immediately which this patch addresses ?
>>
>>
>> I thought I'd read that reset isn't instantaneous, but in testing it
>> seems to be. So I will revert to the original post-reset delay, and
>> change udelay() to usleep_range(10, 20). Any thoughts on those
>> numbers?
>
>
> Using usleep makes no sense for such short delays, so I would stick
> with udelay.
>
> More importantly you still have not explained why we need to delay
> *at all* esp. such a short delay, 10us is a single bit at 100kHz i2c
> so the set bq24190 register-pointer part of the i2c transfer which
> happens before reading back the reset-bit alone takes 20 times as
> long as the delay.
>
> I still don't understand why a delay is needed at all, what are
> you trying to achieve with this delay ? Are you seeing a specific
> problem you are trying to fix ?
A loop with udelay(10) was in the code already, because at manual
9.5.1.2 the note for bit 7 says "Back to 0 after register reset".
But I think you're right, we don't need to loop checking this; I'll
just return -EIO (?) if bit 7 isn't 0 -- which presumably means
charger is kaput.
>
>
>
>
>>
>>
>>
>>>
>>>
>>>
>>>
>>>>
>>>> Cc: Tony Lindgren <tony@atomide.com>
>>>> Cc: Hans de Goede <hdegoede@redhat.com>
>>>> Signed-off-by: Liam Breck <kernel@networkimprov.net>
>>>> ---
>>>> drivers/power/supply/bq24190_charger.c | 8 ++------
>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/power/supply/bq24190_charger.c
>>>> b/drivers/power/supply/bq24190_charger.c
>>>> index fa29cb3..71a796e 100644
>>>> --- a/drivers/power/supply/bq24190_charger.c
>>>> +++ b/drivers/power/supply/bq24190_charger.c
>>>> @@ -543,18 +543,14 @@ static int bq24190_register_reset(struct
>>>> bq24190_dev_info *bdi)
>>>>
>>>> /* Reset bit will be cleared by hardware so poll until it is */
>>>> do {
>>>> + udelay(10);
>>>> ret = bq24190_read_mask(bdi, BQ24190_REG_POC,
>>>> BQ24190_REG_POC_RESET_MASK,
>>>> BQ24190_REG_POC_RESET_SHIFT,
>>>> &v);
>>>> if (ret < 0)
>>>> return ret;
>>>> -
>>>> - if (!v)
>>>> - break;
>>>> -
>>>> - udelay(10);
>>>> - } while (--limit);
>>>> + } while (v && --limit);
>>>>
>>>> if (!limit)
>>>> return -EIO;
>>>>
>>>
>
next prev parent reply other threads:[~2017-04-08 19:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 3:10 [PATCH v4 0/4] BQ24190 charger fixes Liam Breck
2017-04-06 3:10 ` [PATCH v4 1/4] power: bq24190_charger: Limit over/under voltage fault logging Liam Breck
2017-04-06 7:12 ` Hans de Goede
2017-04-06 3:10 ` [PATCH v4 2/4] power: bq24190_charger: Clean up extcon code Liam Breck
2017-04-06 7:17 ` Hans de Goede
2017-04-07 22:27 ` Liam Breck
2017-04-08 10:02 ` Hans de Goede
2017-04-08 19:09 ` Liam Breck
2017-04-08 20:05 ` Hans de Goede
2017-04-10 9:03 ` Liam Breck
2017-04-10 9:11 ` Hans de Goede
2017-04-06 3:10 ` [PATCH v4 3/4] power: bq24190_charger: Uniform pm_runtime_get() failure handling Liam Breck
2017-04-06 7:19 ` Hans de Goede
2017-04-06 3:10 ` [PATCH v4 4/4] power: bq24190_charger: Delay before polling reset flag Liam Breck
2017-04-06 7:20 ` Hans de Goede
2017-04-07 21:46 ` Liam Breck
2017-04-08 9:58 ` Hans de Goede
2017-04-08 19:25 ` Liam Breck [this message]
2017-04-08 20:14 ` Hans de Goede
2017-04-08 20:46 ` Liam Breck
2017-04-08 20:48 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKvHMgSzSg98JkfwhSCcLoVhBedND3w0UqTeeCP=HwbGVSJSJQ@mail.gmail.com' \
--to=liam@networkimprov.net \
--cc=hdegoede@redhat.com \
--cc=kernel@networkimprov.net \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).