Message ID | 20240704125643.22946-2-hdegoede@redhat.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | i2c-i801 / dell-lis3lv02d: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-lis3lv02d | expand |
Hi Hans, ... > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -1521,7 +1521,18 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > dev_set_name(&adap->dev, "i2c-%d", adap->nr); > adap->dev.bus = &i2c_bus_type; > adap->dev.type = &i2c_adapter_type; > - res = device_register(&adap->dev); > + device_initialize(&adap->dev); > + > + /* > + * This adapter can be used as a parent immediately after device_add(), > + * setup runtime-pm (especially ignore-children) before hand. > + */ > + device_enable_async_suspend(&adap->dev); > + pm_runtime_no_callbacks(&adap->dev); > + pm_suspend_ignore_children(&adap->dev, true); > + pm_runtime_enable(&adap->dev); > + > + res = device_add(&adap->dev); I see a pattern here around in the kernel: device_initialize(...) ... device_add(...) which makes the device_register() helper not that useful. Perhaps for the future we could add a device_register_fn() where we pass the reference of a function that does whatever lies in between the initialize and the add... food for thoughts. As of now, looks good to me: Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Thanks, Andi > if (res) { > pr_err("adapter '%s': can't register device (%d)\n", adap->name, res); > goto out_list; > @@ -1533,11 +1544,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > if (res) > goto out_reg; > > - device_enable_async_suspend(&adap->dev); > - pm_runtime_no_callbacks(&adap->dev); > - pm_suspend_ignore_children(&adap->dev, true); > - pm_runtime_enable(&adap->dev); > - > res = i2c_init_recovery(adap); > if (res == -EPROBE_DEFER) > goto out_reg; > -- > 2.45.1 >
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index db0d1ac82910..c4517d97a49f 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1521,7 +1521,18 @@ static int i2c_register_adapter(struct i2c_adapter *adap) dev_set_name(&adap->dev, "i2c-%d", adap->nr); adap->dev.bus = &i2c_bus_type; adap->dev.type = &i2c_adapter_type; - res = device_register(&adap->dev); + device_initialize(&adap->dev); + + /* + * This adapter can be used as a parent immediately after device_add(), + * setup runtime-pm (especially ignore-children) before hand. + */ + device_enable_async_suspend(&adap->dev); + pm_runtime_no_callbacks(&adap->dev); + pm_suspend_ignore_children(&adap->dev, true); + pm_runtime_enable(&adap->dev); + + res = device_add(&adap->dev); if (res) { pr_err("adapter '%s': can't register device (%d)\n", adap->name, res); goto out_list; @@ -1533,11 +1544,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) if (res) goto out_reg; - device_enable_async_suspend(&adap->dev); - pm_runtime_no_callbacks(&adap->dev); - pm_suspend_ignore_children(&adap->dev, true); - pm_runtime_enable(&adap->dev); - res = i2c_init_recovery(adap); if (res == -EPROBE_DEFER) goto out_reg;