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: [RFC PATCH 0/1] gpio: Handle NULL pointers gracefully
Date: Sat, 30 May 2020 03:33:54 +0530	[thread overview]
Message-ID: <20200529220355.4396-1-p.yadav@ti.com> (raw)

Hi,

Patch [0] added 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.

We 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. Linux does not generally trust
drivers and usually verifies anything it gets from them. And FWIW, I see
that the clk and phy subsystems in U-Boot also perform checks like this.

The downside of the checks is of course that they increase code size.
They might also slightly decrease performance. The benefit is that we
don't burden drivers with taking care of this.

The patch itself is based on a similar patch by Jean-Jacques.

[0] https://patchwork.ozlabs.org/project/uboot/patch/20200529213808.2815-2-p.yadav at ti.com/

Pratyush Yadav (1):
  gpio: Handle NULL pointers gracefully

 drivers/gpio/Kconfig       |  9 ++++
 drivers/gpio/gpio-uclass.c | 86 ++++++++++++++++++++++++++++++++++----
 include/asm-generic/gpio.h |  2 +-
 3 files changed, 88 insertions(+), 9 deletions(-)

--
2.26.2

             reply	other threads:[~2020-05-29 22:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 22:03 Pratyush Yadav [this message]
2020-05-29 22:03 ` [RFC PATCH 1/1] gpio: Handle NULL pointers gracefully Pratyush Yadav
2020-06-01 17:08   ` Simon Glass
2020-06-08 12:37     ` 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=20200529220355.4396-1-p.yadav@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