Re: [PATCH v7 08/39] soc: Add SoC driver for Cirrus ep93xx

From: Nikita Shubin
Date: Tue Feb 13 2024 - 04:38:32 EST


Hello Andy!

On Sun, 2024-02-04 at 18:52 +0200, andy.shevchenko@xxxxxxxxx wrote:
> Thu, Jan 18, 2024 at 11:20:51AM +0300, Nikita Shubin kirjoitti:
> > Add an SoC driver for the ep93xx. Currently there is only one thing
> > not fitting into any other framework, and that is the swlock
> > setting.
> >
> > Used for clock settings, pinctrl and restart.
>
> ...
>
> > +static struct auxiliary_device *ep93xx_adev_alloc(struct device
> > *parent, const char *name,
> > +                                                 struct
> > ep93xx_map_info *info)
> > +{
> > +       struct ep93xx_regmap_adev *rdev;
> > +       struct auxiliary_device *adev;
> > +       int ret;
> > +
> > +       rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
> > +       if (!rdev)
> > +               return ERR_PTR(-ENOMEM);
>
> Use __free() ?
> (You already included cleanup.h for other cases, why not using it
> here?)

Why should i want this ? I don't want rdev beeing freed on out of scope
- rdev is freed in ep93xx_adev_release().

But thank you, i've noticed a bug - i should free rdev and not adev
both in ep93xx_adev_alloc() and ep93xx_adev_release().

>
> > +       rdev->map = info->map;
> > +       rdev->base = info->base;
> > +       rdev->lock = &info->lock;
> > +       rdev->write = ep93xx_regmap_write;
> > +       rdev->update_bits = ep93xx_regmap_update_bits;
> > +
> > +       adev = &rdev->adev;
> > +       adev->name = name;
> > +       adev->dev.parent = parent;
> > +       adev->dev.release = ep93xx_adev_release;
> > +
> > +       ret = auxiliary_device_init(adev);
> > +       if (ret) {
> > +               kfree(adev);
> > +               return ERR_PTR(ret);
> > +       }
> > +
> > +       return adev;
> > +}
>
> ...
>
> > +       model = (enum
> > ep93xx_soc_model)(uintptr_t)of_device_get_match_data(dev);
>
> I believe Rob wants to get rid of of_device.h or at least of this
> call (see his
> patches to convert this API to use device_get_match_data() instead).
>

Noted - thanks !