On 8.01.2025 2:28 AM, Stephen Boyd wrote: > Allow drivers to modify the 'struct device' for a device node by > splitting of_platform_device_create_pdata() into two functions. The > first function, of_platform_device_alloc(), allocates the platform > device and the second function, of_platform_device_add(), adds the > platform device to the platform bus. SoC power management drivers can > use these APIs to allocate a platform device for a node underneath the > soc node, attach pmdomains and/or set the device as runtime PM active, > and finally add the platform device to the platform bus. > > Cc: Rob Herring <robh@xxxxxxxxxx> > Cc: Saravana Kannan <saravanak@xxxxxxxxxx> > Cc: <devicetree@xxxxxxxxxxxxxxx> > Cc: Bjorn Andersson <andersson@xxxxxxxxxx> > Cc: Konrad Dybcio <konradybcio@xxxxxxxxxx> > Cc: <linux-arm-msm@xxxxxxxxxxxxxxx> > Signed-off-by: Stephen Boyd <swboyd@xxxxxxxxxxxx> > --- [...] > +/** > + * of_platform_device_add - Add an of_device to the platform bus > + * @ofdev: of_device to add > + * > + * Return: 0 on success, negative errno on failure. > + */ > +int of_platform_device_add(struct platform_device *ofdev) > +{ > + struct device_node *np = ofdev->dev.of_node; > + int ret; > + > + pr_debug("adding platform device: %pOF\n", np); > + > + ret = of_device_add(ofdev); > + if (ret) { > + platform_device_put(ofdev); > + of_node_clear_flag(np, OF_POPULATED); > + } > + > + return ret; > +} > +EXPORT_SYMBOL(of_platform_device_add); > + > /** > * of_platform_device_create_pdata - Alloc, initialize and register an of_device > * @np: pointer to node to create device for > @@ -154,29 +214,19 @@ static struct platform_device *of_platform_device_create_pdata( > void *platform_data, > struct device *parent) > { > + int ret; > struct platform_device *dev; ultranit: you kept the reverse order above, please keep ret last too Konrad