[PATCH v3 101/108] drm/bridge: ti-sn65dsi86: Make use of devm_pwmchip_alloc() function
Doug Anderson
dianders at chromium.org
Tue Nov 21 15:15:51 UTC 2023
Hi,
On Tue, Nov 21, 2023 at 5:52 AM Uwe Kleine-König
<u.kleine-koenig at pengutronix.de> wrote:
>
> This prepares the pwm driver of the ti-sn65dsi86 to further changes of
> the pwm core outlined in the commit introducing devm_pwmchip_alloc().
> There is no intended semantical change and the driver should behave as
> before.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> ---
> drivers/gpu/drm/bridge/ti-sn65dsi86.c | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> index c45c07840f64..cd40530ffd71 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> @@ -197,7 +197,7 @@ struct ti_sn65dsi86 {
> DECLARE_BITMAP(gchip_output, SN_NUM_GPIOS);
> #endif
> #if defined(CONFIG_PWM)
> - struct pwm_chip pchip;
> + struct pwm_chip *pchip;
> bool pwm_enabled;
> atomic_t pwm_pin_busy;
> #endif
> @@ -1372,7 +1372,8 @@ static void ti_sn_pwm_pin_release(struct ti_sn65dsi86 *pdata)
>
> static struct ti_sn65dsi86 *pwm_chip_to_ti_sn_bridge(struct pwm_chip *chip)
> {
> - return container_of(chip, struct ti_sn65dsi86, pchip);
> + struct ti_sn65dsi86 **pdata = pwmchip_priv(chip);
> + return *pdata;
> }
>
> static int ti_sn_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> @@ -1585,22 +1586,28 @@ static const struct pwm_ops ti_sn_pwm_ops = {
> static int ti_sn_pwm_probe(struct auxiliary_device *adev,
> const struct auxiliary_device_id *id)
> {
> + struct pwm_chip *chip;
> struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent);
>
> - pdata->pchip.dev = pdata->dev;
> - pdata->pchip.ops = &ti_sn_pwm_ops;
> - pdata->pchip.npwm = 1;
> - pdata->pchip.of_xlate = of_pwm_single_xlate;
> - pdata->pchip.of_pwm_n_cells = 1;
> + /* XXX: should this better use adev->dev instead of pdata->dev? */
> + pdata->pchip = chip = devm_pwmchip_alloc(pdata->dev, 1, sizeof(&pdata));
Yes, it should be "adev->dev". See recent commits like commit
7b821db95140 ("drm/bridge: ti-sn65dsi86: Associate DSI device lifetime
with auxiliary device").
I also think the size you're passing is technically wrong. The private
data you're storing is a pointer to a "struct ti_sn65dsi86". The size
of that is "sizeof(pdata)", not "sizeof(&pdata)".
Other than the above, this looks OK to me. Once the dependencies are
in I'd be happy to apply this to drm-misc. I could also "Ack" it for
landing in other trees and I _think_ that would be OK (the driver
isn't changing much and it's unlikely to cause conflicts), though
technically the Ack would be more legit from one of the drm-misc
maintainers [1].
[1] https://drm.pages.freedesktop.org/maintainer-tools/repositories.html?highlight=maxime#the-drm-misc-repository
More information about the dri-devel
mailing list