All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v1 1/3] drivers: reset: Handle gracefully NULL pointers
Date: Sun, 31 May 2020 08:08:53 -0600	[thread overview]
Message-ID: <CAPnjgZ3bLdSSffoO2Uef5U348_UuNZ6TJUmx1+ocwrXSLaMG2g@mail.gmail.com> (raw)
In-Reply-To: <20200527171205.rjmzduwd6bfwhdtj@ti.com>

Hi Pratyush,

On Wed, 27 May 2020 at 11:12, Pratyush Yadav <p.yadav@ti.com> wrote:
>
> Hi Simon,
>
> On 29/10/19 07:48PM, Simon Glass wrote:
> > Hi Jean-Jacques,
> >
> > On Mon, 30 Sep 2019 at 08:31, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> > >
> > > Prepare the way for a managed reset API by handling NULL pointers without
> > > crashing nor failing.
> > >
> > > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> > > ---
> > >
> > >  drivers/reset/reset-uclass.c | 30 +++++++++++++++++-------------
> > >  1 file changed, 17 insertions(+), 13 deletions(-)
> >
> > Same comment here about code size / Kconfig option.
>
> A lot of the changes below are ternary operators. I'm not sure how to
> put them behind a Kconfig option to reduce code size. Do you want me to
> change the NULL check to a separate if() block to put behind an #ifdef?
>
> One way of doing this is like in this patch [0]. The other would be to
> wrap individual if statements in #ifdef, which tends to hurt
> readability.

Well for this I would really favour:

  int reset_request(struct reset_ctl *reset_ctl)
  {
     struct reset_ops *ops;

if (!result_ctl)
    return 0;

ops = reset_dev_ops(reset_ctl->dev);

But why allow result_ctl to be NULL? You should explain that in your
commit message.

> > -     struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
> > +     struct reset_ops *ops = reset_dev_ops(reset_ctl);
> >
> >       debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
> >
> > -     return ops->request(reset_ctl);
> > +     return ops->request ? ops->request(reset_ctl) : 0;
> >  }
> >
>
> [0] https://patchwork.ozlabs.org/project/uboot/patch/20191001115130.18886-2-jjhiblot at ti.com/

[..]

Regards,
Simon

  reply	other threads:[~2020-05-31 14:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 14:24 [U-Boot] [PATCH v1 0/3] reset: Add a managed API Jean-Jacques Hiblot
2019-09-30 14:24 ` [U-Boot] [PATCH v1 1/3] drivers: reset: Handle gracefully NULL pointers Jean-Jacques Hiblot
2019-10-30  1:48   ` Simon Glass
2020-05-27 17:12     ` Pratyush Yadav
2020-05-31 14:08       ` Simon Glass [this message]
2019-09-30 14:24 ` [U-Boot] [PATCH v1 2/3] drivers: reset: Add a managed API to get reset controllers from the DT Jean-Jacques Hiblot
2019-10-30  1:48   ` Simon Glass
2019-11-04 15:17     ` Jean-Jacques Hiblot
2019-11-05 16:33       ` Simon Glass
2019-11-05 16:42         ` Simon Goldschmidt
2019-11-05 17:27           ` Jean-Jacques Hiblot
2019-09-30 14:24 ` [U-Boot] [PATCH v1 3/3] test: reset: Add tests for the managed API Jean-Jacques Hiblot

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=CAPnjgZ3bLdSSffoO2Uef5U348_UuNZ6TJUmx1+ocwrXSLaMG2g@mail.gmail.com \
    --to=sjg@chromium.org \
    --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 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.