On 2023/4/14 2:38, Stephen Boyd wrote: > Quoting Xingyu Wu (2023-04-13 06:31:12) >> On 2023/4/13 12:04, Stephen Boyd wrote: >> > diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c b/drivers/clk/starfive/clk-starfive-jh7110-sys.c >> > index 5ec210644e1d..851b93d0f371 100644 >> > --- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c >> > +++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c >> > @@ -11,6 +11,9 @@ >> > #include <linux/init.h> >> > #include <linux/io.h> >> > #include <linux/platform_device.h> >> > +#include <linux/slab.h> >> > + >> > +#include <soc/starfive/reset-starfive-jh71x0.h> >> > >> > #include <dt-bindings/clock/starfive,jh7110-crg.h> >> > >> > @@ -335,26 +338,32 @@ static void jh7110_reset_unregister_adev(void *_adev) >> > struct auxiliary_device *adev = _adev; >> > >> > auxiliary_device_delete(adev); >> > + auxiliary_device_uninit(adev); >> > } >> > >> > static void jh7110_reset_adev_release(struct device *dev) >> > { >> > struct auxiliary_device *adev = to_auxiliary_dev(dev); >> > + struct jh71x0_reset_adev *rdev = to_jh71x0_reset_adev(adev); >> > >> > - auxiliary_device_uninit(adev); >> > + kfree(rdev); >> > } >> > >> > int jh7110_reset_controller_register(struct jh71x0_clk_priv *priv, >> > const char *adev_name, >> > u32 adev_id) >> > { >> > + struct jh71x0_reset_adev *rdev; >> > struct auxiliary_device *adev; >> > int ret; >> > >> > - adev = devm_kzalloc(priv->dev, sizeof(*adev), GFP_KERNEL); >> > - if (!adev) >> > + rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); >> >> Can there use 'devm_kzalloc'? Are you not using this because the struct is public and clock driver >> and reset driver both use it. But I think the both clock driver and reset driver are the same >> device and can use 'devm_kzalloc'. > > No. The release function for the auxiliary_device is supposed to free > the memory. It shouldn't be tied to the lifetime of anything like the > lifetime of the clk driver being bound. Get it. Thanks. Best regards, Xingyu Wu