Re: [PATCH v7 06/10] i2c: Introduce OF component probe function

From: Andy Shevchenko
Date: Mon Sep 16 2024 - 06:14:01 EST


On Fri, Sep 13, 2024 at 04:43:04PM -0700, Doug Anderson wrote:
> On Wed, Sep 11, 2024 at 12:28 AM Chen-Yu Tsai <wenst@xxxxxxxxxxxx> wrote:

...

> > +static int i2c_of_probe_enable_node(struct device *dev, struct device_node *node)
> > +{
> > + int ret;
> > +
> > + dev_info(dev, "Enabling %pOF\n", node);
> > +
> > + struct of_changeset *ocs __free(kfree) = kzalloc(sizeof(*ocs), GFP_KERNEL);
> > + if (!ocs)
> > + return -ENOMEM;
>
> I guess the kernel lets you mix code and declarations now? I'm still
> used to all declarations being together but maybe I'm old school... I
> would have put the "dev_info" below the allocation...

In general yes, but we don't allow it everywhere for everything,
we have two exceptions:
1) for-loops;
2) __free() RAII.


--
With Best Regards,
Andy Shevchenko