lkml.org 
[lkml]   [2023]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 2/2] gpio: mlxbf3: Support add_pin_ranges()
On Thu, Aug 17, 2023 at 12:28 AM Asmaa Mnebhi <asmaa@nvidia.com> wrote:
>
> > > v1->v2:
> > > - No changes.
> >
> > Is this correct?
> Ah my apologies, I added the wrong comment here. I put it in "v2 1/2".
>
> > > +static int mlxbf3_gpio_add_pin_ranges(struct gpio_chip *chip) {
> > > + unsigned int id = 0;
> > > + int ret;
> > > +
> > > + if (chip->ngpio % MLXBF3_GPIO_MAX_PINS_PER_BLOCK)
> > > + id = 1;
> >
> > This id calculation seems wrong to me as I said in v1 review.
> > Why do you think the above is what you want and not just working by luck?
>
> I would like to get the gpio block id which can only be 0 or 1 on BlueField-3 (only 2 gpio blocks, one with 32 gpio pins and one with 24 gpio pins).
> The above logic was an "easy" way for me to get the gpio block id. Then the pin_base for each gpio block is:
> pin_base = id * MLXBF3_GPIO_MAX_PINS_PER_BLOCK

It's fragile. Use a direct case switch for that, which will be more
explicit and robust (however still can fail for any new chip
revision/version where it might be a different GPIO layout).

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2023-08-17 10:23    [W:0.079 / U:1.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site