[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <685e6544.5d0a0220.20cf55.9440@mx.google.com>
Date: Fri, 27 Jun 2025 11:32:46 +0200
From: Christian Marangi <ansuelsmth@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Uwe Kleine-König <ukleinek@...nel.org>,
linux-kernel@...r.kernel.org, linux-pwm@...r.kernel.org,
Benjamin Larsson <benjamin.larsson@...exis.eu>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
Lorenzo Bianconi <lorenzo@...nel.org>
Subject: Re: [PATCH v18] pwm: airoha: Add support for EN7581 SoC
On Fri, Jun 27, 2025 at 11:58:04AM +0300, Andy Shevchenko wrote:
> On Fri, Jun 27, 2025 at 12:47:53AM +0200, Christian Marangi wrote:
> > From: Benjamin Larsson <benjamin.larsson@...exis.eu>
> >
> > Introduce driver for PWM module available on EN7581 SoC.
>
> ...
>
> > + * Copyright 2025 Markus Gothe <markus.gothe@...exis.eu>
> > + * Christian Marangi <ansuelsmth@...il.com>
>
> I'm not sure you can change the copyright line like this. I would rather expect
>
> * Copyright 2012 Markus Gothe <markus.gothe@...exis.eu>
> * Copyright 2025 Christian Marangi <ansuelsmth@...il.com>
>
> (Sorry, I forgot the exact original year there, but you got the point)
>
> ...
>
> > + /* Global mutex to protect bucket used refcount_t */
> > + struct mutex mutex;
>
> This makes a little sense. Either you use refcount_t (which is atomic) or
> use mutex + regular variable.
>
Using a regular variable I lose all the benefits of refcount_t with
underflow and other checks.
> ...
>
> > + /*
> > + * It is necessary to explicitly shift out all zeros after muxing
> > + * to initialize the shift register before enabling PWM
> > + * mode because in PWM mode SIPO will not start shifting until
> > + * it needs to output a non-zero value (bit 31 of led_data
> > + * indicates shifting in progress and it must return to zero
> > + * before led_data can be written or PWM mode can be set)
>
> Missing period at the end.
>
> > + */
>
> ...
>
> > +static void airoha_pwm_disable(struct airoha_pwm *pc, struct pwm_device *pwm)
> > +{
> > + /* Disable PWM and release the bucket */
> > + airoha_pwm_config_flash_map(pc, pwm->hwpwm, -1);
> > + airoha_pwm_release_bucket_config(pc, pwm->hwpwm);
> > +
> > + clear_bit(pwm->hwpwm, pc->initialized);
> > +
> > + /* If no SIPO is used, disable the shift register chip */
> > + if (find_next_bit(pc->initialized, AIROHA_PWM_MAX_CHANNELS,
> > + AIROHA_PWM_NUM_GPIO) >= AIROHA_PWM_NUM_GPIO)
>
> This can be rewritten as
>
> if (!bitmap_read(pc->initialized, AIROHA_PWM_NUM_GPIO, AIROHA_PWM_NUM_SIPO))
>
> (seems to me that the above code is buggy and has to have a check against the
> full size of bitmap).
>
Yes I'm confused by find_next_bit. Is the nbits part the rest of the bit
or the full size of the bitmap?
Google suggest it should be the full size of the bitmap but I wasn't so
sure. Anyway I will use bitmap_read since it seems more readable.
> > + regmap_clear_bits(pc->regmap, AIROHA_PWM_REG_SIPO_FLASH_MODE_CFG,
> > + AIROHA_PWM_SERIAL_GPIO_FLASH_MODE);
> > +}
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
--
Ansuel
Powered by blists - more mailing lists