All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Matthew McClain <mmcclain@noprivs.com>
Cc: Sai Kumar Cholleti <skmr537@gmail.com>,
	bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] gpio: exar set value handling for hw with gpio pull-up or pull-down
Date: Mon, 4 Nov 2024 15:25:30 +0200	[thread overview]
Message-ID: <ZyjLSmtwyPiD9-r5@black.fi.intel.com> (raw)
In-Reply-To: <00bc04c5-a424-4d68-b7cd-7ad9e586409a@noprivs.com>

On Tue, Aug 13, 2024 at 10:07:37AM -0500, Matthew McClain wrote:
> On 8/12/24 12:22, Andy Shevchenko wrote:
> > On Tue, Jul 30, 2024 at 07:16:10PM +0530, Sai Kumar Cholleti wrote:
> >
> > Please, refer to the functions in the text as func(), e.g.
> exar_set_value().
> > Use proper acronym, i.e. GPIO (capitalised).
> 
> We will update the patch and send a new version out if the current
> approach is acceptable.
> 
> >> Before the gpio direction is changed from input to output,
> >> exar_set_value is set to 1, but since direction is input when
> >> exar_set_value is called, _regmap_update_bits reads a 1 due to an
> >> external pull-up.  When force_write is not set (regmap_set_bits has
> >> force_write = false), the value is not written.  When the direction is
> >> then changed, the gpio becomes an output with the value of 0 (the
> >> hardware default).
> >>
> >> regmap_write_bits sets force_write = true, so the value is always
> >> written by exar_set_value and an external pull-up doesn't affect the
> >> outcome of setting direction = high.
> 
> > Okay, shouldn't you instead mark the respective registers as volatile or
> so?
> > I believe regmap has some settings for this case. But I haven't checked
> myself.
> 
> Unfortunately, in addition to marking the regmap volatile, we'd need to
> define reg_update_bits which means we'd be partially undoing the work
> from 36fb7218e87833b17e3042e77f3b102c75129e8f to reuse regmap locking
> and update functions.
> 
> Below is the relevant section of _regmap_update_bits().
> 
> static int _regmap_update_bits(struct regmap *map, unsigned int reg,
>                                unsigned int mask, unsigned int val,
>                                bool *change, bool force_write)
> ...
>         if (regmap_volatile(map, reg) && map->reg_update_bits) {
> ...
>         } else {
> ...
>                 if (force_write || (tmp != orig) || map->force_write_field)
> {
>                         ret = _regmap_write(map, reg, tmp);
>                         if (ret == 0 && change)
>                                 *change = true;
> ...
> 
> I suspect this might be a common problem with other GPIO drivers as
> well.

Sorry, this message went to cracks somehow. Can you update the commit
message and comments as mentioned above, add Fixes tag and send a v2
for a review. Also use 'gpio: exar: ...' in the Subject.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-11-04 13:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 13:46 [PATCH] gpio: exar set value handling for hw with gpio pull-up or pull-down Sai Kumar Cholleti
2024-08-01 15:18 ` Matthew McClain
2024-08-12 17:22 ` Andy Shevchenko
2024-08-13 15:07   ` Matthew McClain
2024-11-04 13:25     ` Andy Shevchenko [this message]
2024-11-04 15:47       ` [PATCH v2] gpio: exar: set value when external pull-up or pull-down is present Sai Kumar Cholleti
2024-11-04 18:56         ` Andy Shevchenko
2024-11-05  7:15           ` [PATCH v3] " Sai Kumar Cholleti
2024-11-05 14:39             ` Andy Shevchenko
2024-11-12 15:30               ` Andy Shevchenko
2024-11-18 11:00                 ` Bartosz Golaszewski
2024-11-18 12:34                   ` Andy Shevchenko
2024-11-19 13:50                     ` sai kumar
2024-11-21  8:10             ` Bartosz Golaszewski

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=ZyjLSmtwyPiD9-r5@black.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mmcclain@noprivs.com \
    --cc=skmr537@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.