Re: [RFC PATCH 1/6] iio: inkern: fix return value in devm_of_iio_channel_get_by_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2022-06-03 at 13:16 +0200, Andy Shevchenko wrote:
> On Thu, Jun 2, 2022 at 4:04 PM Nuno Sá <nuno.sa@xxxxxxxxxx> wrote:
> > 
> > of_iio_channel_get_by_name() can either return NULL or an error
> > pointer
> > so that only doing IS_ERR() is not enough. Fix it by checking the
> > NULL
> > pointer case and return -ENODEV in that case. Note this is done
> > like this
> > so that users of the function (which only check for error pointers)
> > do
> > not need to be changed. This is not ideal since we are losing error
> > codes
> > and as such, in a follow up change, things will be unified so that
> > of_iio_channel_get_by_name() only returns error codes.
> 
> ...
> 
> >         channel = of_iio_channel_get_by_name(np, channel_name);
> > -       if (IS_ERR(channel))
> > +       if (IS_ERR_OR_NULL(channel)) {
> > +               if (!channel)
> > +                       return ERR_PTR(-ENODEV);
> >                 return channel;
> > +       }
> 
> Why not make it not nested, i.e. just adding two lines after the
> existing check?
> if (!channel)
>   return -ENODEV;
> 
> 

I see, well yeah I guess I can do it so the diff is even smaller...

- Nuno Sá





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux