public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pratyush Yadav <p.yadav@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 0/2] gpio: Add a managed API
Date: Mon, 1 Jun 2020 16:52:01 +0530	[thread overview]
Message-ID: <20200601112201.bnaerveuox5he4y6@ti.com> (raw)
In-Reply-To: <CAPnjgZ0gobFotr1UBov8CQoJ_yQua8H9epGysMpeYxYcP_mb3g@mail.gmail.com>

On 31/05/20 08:08AM, Simon Glass wrote:
> Hi Pratyush,
> 
> On Fri, 29 May 2020 at 15:39, Pratyush Yadav <p.yadav@ti.com> wrote:
> >
> > Hi,
> >
> > This is a re-submission of Jean-Jacques' earlier work in October last
> > year. It can be found at [0]. The goal is to facilitate porting drivers
> > from the linux kernel. Most of the series will be about adding managed
> > API to existing infrastructure (GPIO, reset, regmap (already
> > submitted)).
> >
> > This particular series is about GPIOs. It adds a managed API using the
> > API as Linux. To make it 100% compatible with linux, there is a small
> > deviation from u-boot's way of naming the gpio lists: the managed
> > equivalent of gpio_request_by_name(..,"blabla-gpios", ...) is
> > devm_gpiod_get_index(..., "blabla", ...)
> >
> > Changes in v2:
> > - The original series had a patch that checked for NULL pointers in the
> >   core GPIO functions. The checks were needed because of the addition of
> >   devm_gpiod_get_index_optional() which would return NULL when when no
> >   GPIO was assigned to the requested function. This is convenient for
> >   drivers that need to handle optional GPIOs.
> >
> >   Simon argued that those should be behind a Kconfig option because of
> >   code size concerns. He also argued against implicit return in the
> >   macro that checked for the optional GPIOs.
> >
> >   This submission removes the controversial patch so that base
> >   functionality can get unblocked.
> >
> >   We still need to take a stance on who is responsible for the NULL
> >   check: the driver or the GPIO core? Do we want to trust drivers to
> >   take care of the NULL checks, or do we want to distrust them and make
> >   sure they don't send us anything bogus in the GPIO core. For now the
> >   responsibility lies on the drivers by default. I will send a separate
> >   RFC of the NULL check patch and we can probably discuss the issue
> >   there.
> >
> > [0] https://patchwork.ozlabs.org/project/uboot/cover/20191001115130.18886-1-jjhiblot at ti.com/
> >
> > Jean-Jacques Hiblot (2):
> >   drivers: gpio: Add a managed API to get a GPIO from the device-tree
> >   test: gpio: Add tests for the managed API
> >
> >  arch/sandbox/dts/test.dts  |  10 ++++
> >  drivers/gpio/gpio-uclass.c |  70 +++++++++++++++++++++++++
> >  include/asm-generic/gpio.h |  47 +++++++++++++++++
> >  test/dm/gpio.c             | 102 +++++++++++++++++++++++++++++++++++++
> >  4 files changed, 229 insertions(+)
> >
> > --
> > 2.26.2
> >
> 
> The first question I have is why do you want to allocate the gpio_desc
> and return it? Doesn't the caller have a place for that in its private
> struct?

Ask the Linux folks that ;-)

The main aim of this series is to make it easier to port and maintain 
drivers from Linux. The less changes we have to make when porting a 
driver, the easier it is to port future fixes and features.

Linux drivers (like the TI J721E WIZ [0] for which this effort is mainly 
being made) use these APIs. FWIW, the docs in Linux say the optional 
wrappers to the functions are added as a convenience for drivers that 
need to handle optional GPIOs.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/phy/ti/phy-j721e-wiz.c

-- 
Regards,
Pratyush Yadav
Texas Instruments India

  reply	other threads:[~2020-06-01 11:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 21:38 [PATCH v2 0/2] gpio: Add a managed API Pratyush Yadav
2020-05-29 21:38 ` [PATCH v2 1/2] drivers: gpio: Add a managed API to get a GPIO from the device-tree Pratyush Yadav
2020-06-16 23:37   ` Simon Glass
2020-06-17  7:59     ` Pratyush Yadav
2020-06-26  1:12   ` Simon Glass
2020-05-29 21:38 ` [PATCH v2 2/2] test: gpio: Add tests for the managed API Pratyush Yadav
2020-06-17  3:11   ` Simon Glass
2020-05-31 14:08 ` [PATCH v2 0/2] gpio: Add a " Simon Glass
2020-06-01 11:22   ` Pratyush Yadav [this message]
2020-06-01 14:45     ` Simon Glass
2020-06-08 18:05       ` Pratyush Yadav
2020-06-17  3:11         ` Simon Glass

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=20200601112201.bnaerveuox5he4y6@ti.com \
    --to=p.yadav@ti.com \
    --cc=u-boot@lists.denx.de \
    /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