Message ID | 20191210145345.11616-7-sudeep.holla@arm.com |
---|---|
State | New |
Headers | show |
Series | firmware: arm_scmi: Add support for multiple device per protocol | expand |
On 10/12/2019 14:53, Sudeep Holla wrote: > The scmi bus now supports multiple device per protocol. So, in order to > initialise each device and it's attributes, it's better to pass scmi_device > pointer to the protocol initialise function rather than scmi_handle. > scmi_handle can be still fetched from the scmi_device pointer. > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > drivers/firmware/arm_scmi/bus.c | 6 +++--- > drivers/firmware/arm_scmi/clock.c | 3 ++- > drivers/firmware/arm_scmi/perf.c | 3 ++- > drivers/firmware/arm_scmi/power.c | 3 ++- > drivers/firmware/arm_scmi/reset.c | 3 ++- > drivers/firmware/arm_scmi/sensors.c | 3 ++- > include/linux/scmi_protocol.h | 2 +- > 7 files changed, 14 insertions(+), 9 deletions(-) > > diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c > index 3714e6307b05..f619da2634a6 100644 > --- a/drivers/firmware/arm_scmi/bus.c > +++ b/drivers/firmware/arm_scmi/bus.c > @@ -51,13 +51,13 @@ static int scmi_dev_match(struct device *dev, struct device_driver *drv) > return 0; > } > > -static int scmi_protocol_init(int protocol_id, struct scmi_handle *handle) > +static int scmi_protocol_init(int protocol_id, struct scmi_device *dev) > { > scmi_prot_init_fn_t fn = idr_find(&scmi_protocols, protocol_id); > > if (unlikely(!fn)) > return -EINVAL; > - return fn(handle); > + return fn(dev); > } > As talked offline, for the same reasons of comments in 03/15, it seems to me that here we are slipping device specific initialization stuff into the protocol_init function which should be called once for all for every protocol. BTW, scmi_dev is used just to extract the handle here, beside version caching in following patches. Cheers Cristian > static int scmi_dev_probe(struct device *dev) > @@ -74,7 +74,7 @@ static int scmi_dev_probe(struct device *dev) > if (!scmi_dev->handle) > return -EPROBE_DEFER; > > - ret = scmi_protocol_init(scmi_dev->protocol_id, scmi_dev->handle); > + ret = scmi_protocol_init(scmi_dev->protocol_id, scmi_dev); > if (ret) > return ret; > > diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c > index 922b22aaaf84..6c24eb8a4e68 100644 > --- a/drivers/firmware/arm_scmi/clock.c > +++ b/drivers/firmware/arm_scmi/clock.c > @@ -310,11 +310,12 @@ static struct scmi_clk_ops clk_ops = { > .disable = scmi_clock_disable, > }; > > -static int scmi_clock_protocol_init(struct scmi_handle *handle) > +static int scmi_clock_protocol_init(struct scmi_device *dev) > { > u32 version; > int clkid, ret; > struct clock_info *cinfo; > + struct scmi_handle *handle = dev->handle; > > if (handle->clk_ops && handle->clk_priv) > return 0; /* initialised already for the first device */ > diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c > index 55c2a4c21ccb..4f02bfba98ba 100644 > --- a/drivers/firmware/arm_scmi/perf.c > +++ b/drivers/firmware/arm_scmi/perf.c > @@ -704,11 +704,12 @@ static struct scmi_perf_ops perf_ops = { > .est_power_get = scmi_dvfs_est_power_get, > }; > > -static int scmi_perf_protocol_init(struct scmi_handle *handle) > +static int scmi_perf_protocol_init(struct scmi_device *dev) > { > int domain; > u32 version; > struct scmi_perf_info *pinfo; > + struct scmi_handle *handle = dev->handle; > > if (handle->perf_ops && handle->perf_priv) > return 0; /* initialised already for the first device */ > diff --git a/drivers/firmware/arm_scmi/power.c b/drivers/firmware/arm_scmi/power.c > index 9a7593238b8f..5a8faa369d82 100644 > --- a/drivers/firmware/arm_scmi/power.c > +++ b/drivers/firmware/arm_scmi/power.c > @@ -179,11 +179,12 @@ static struct scmi_power_ops power_ops = { > .state_get = scmi_power_state_get, > }; > > -static int scmi_power_protocol_init(struct scmi_handle *handle) > +static int scmi_power_protocol_init(struct scmi_device *dev) > { > int domain; > u32 version; > struct scmi_power_info *pinfo; > + struct scmi_handle *handle = dev->handle; > > if (handle->power_ops && handle->power_priv) > return 0; /* initialised already for the first device */ > diff --git a/drivers/firmware/arm_scmi/reset.c b/drivers/firmware/arm_scmi/reset.c > index 809dc8faee1e..438d74a2c80a 100644 > --- a/drivers/firmware/arm_scmi/reset.c > +++ b/drivers/firmware/arm_scmi/reset.c > @@ -189,11 +189,12 @@ static struct scmi_reset_ops reset_ops = { > .deassert = scmi_reset_domain_deassert, > }; > > -static int scmi_reset_protocol_init(struct scmi_handle *handle) > +static int scmi_reset_protocol_init(struct scmi_device *dev) > { > int domain; > u32 version; > struct scmi_reset_info *pinfo; > + struct scmi_handle *handle = dev->handle; > > if (handle->reset_ops && handle->reset_priv) > return 0; /* initialised already for the first device */ > diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c > index b7f92c37c8a4..afa51bedfa5d 100644 > --- a/drivers/firmware/arm_scmi/sensors.c > +++ b/drivers/firmware/arm_scmi/sensors.c > @@ -271,10 +271,11 @@ static struct scmi_sensor_ops sensor_ops = { > .reading_get = scmi_sensor_reading_get, > }; > > -static int scmi_sensors_protocol_init(struct scmi_handle *handle) > +static int scmi_sensors_protocol_init(struct scmi_device *dev) > { > u32 version; > struct sensors_info *sinfo; > + struct scmi_handle *handle = dev->handle; > > if (handle->sensor_ops && handle->sensor_priv) > return 0; /* initialised already for the first device */ > diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h > index 5c873a59b387..b676825e6eb0 100644 > --- a/include/linux/scmi_protocol.h > +++ b/include/linux/scmi_protocol.h > @@ -316,6 +316,6 @@ static inline void scmi_driver_unregister(struct scmi_driver *driver) {} > #define module_scmi_driver(__scmi_driver) \ > module_driver(__scmi_driver, scmi_register, scmi_unregister) > > -typedef int (*scmi_prot_init_fn_t)(struct scmi_handle *); > +typedef int (*scmi_prot_init_fn_t)(struct scmi_device *); > int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn); > void scmi_protocol_unregister(int protocol_id); > -- > 2.17.1 >
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 3714e6307b05..f619da2634a6 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -51,13 +51,13 @@ static int scmi_dev_match(struct device *dev, struct device_driver *drv) return 0; } -static int scmi_protocol_init(int protocol_id, struct scmi_handle *handle) +static int scmi_protocol_init(int protocol_id, struct scmi_device *dev) { scmi_prot_init_fn_t fn = idr_find(&scmi_protocols, protocol_id); if (unlikely(!fn)) return -EINVAL; - return fn(handle); + return fn(dev); } static int scmi_dev_probe(struct device *dev) @@ -74,7 +74,7 @@ static int scmi_dev_probe(struct device *dev) if (!scmi_dev->handle) return -EPROBE_DEFER; - ret = scmi_protocol_init(scmi_dev->protocol_id, scmi_dev->handle); + ret = scmi_protocol_init(scmi_dev->protocol_id, scmi_dev); if (ret) return ret; diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 922b22aaaf84..6c24eb8a4e68 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -310,11 +310,12 @@ static struct scmi_clk_ops clk_ops = { .disable = scmi_clock_disable, }; -static int scmi_clock_protocol_init(struct scmi_handle *handle) +static int scmi_clock_protocol_init(struct scmi_device *dev) { u32 version; int clkid, ret; struct clock_info *cinfo; + struct scmi_handle *handle = dev->handle; if (handle->clk_ops && handle->clk_priv) return 0; /* initialised already for the first device */ diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 55c2a4c21ccb..4f02bfba98ba 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -704,11 +704,12 @@ static struct scmi_perf_ops perf_ops = { .est_power_get = scmi_dvfs_est_power_get, }; -static int scmi_perf_protocol_init(struct scmi_handle *handle) +static int scmi_perf_protocol_init(struct scmi_device *dev) { int domain; u32 version; struct scmi_perf_info *pinfo; + struct scmi_handle *handle = dev->handle; if (handle->perf_ops && handle->perf_priv) return 0; /* initialised already for the first device */ diff --git a/drivers/firmware/arm_scmi/power.c b/drivers/firmware/arm_scmi/power.c index 9a7593238b8f..5a8faa369d82 100644 --- a/drivers/firmware/arm_scmi/power.c +++ b/drivers/firmware/arm_scmi/power.c @@ -179,11 +179,12 @@ static struct scmi_power_ops power_ops = { .state_get = scmi_power_state_get, }; -static int scmi_power_protocol_init(struct scmi_handle *handle) +static int scmi_power_protocol_init(struct scmi_device *dev) { int domain; u32 version; struct scmi_power_info *pinfo; + struct scmi_handle *handle = dev->handle; if (handle->power_ops && handle->power_priv) return 0; /* initialised already for the first device */ diff --git a/drivers/firmware/arm_scmi/reset.c b/drivers/firmware/arm_scmi/reset.c index 809dc8faee1e..438d74a2c80a 100644 --- a/drivers/firmware/arm_scmi/reset.c +++ b/drivers/firmware/arm_scmi/reset.c @@ -189,11 +189,12 @@ static struct scmi_reset_ops reset_ops = { .deassert = scmi_reset_domain_deassert, }; -static int scmi_reset_protocol_init(struct scmi_handle *handle) +static int scmi_reset_protocol_init(struct scmi_device *dev) { int domain; u32 version; struct scmi_reset_info *pinfo; + struct scmi_handle *handle = dev->handle; if (handle->reset_ops && handle->reset_priv) return 0; /* initialised already for the first device */ diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index b7f92c37c8a4..afa51bedfa5d 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -271,10 +271,11 @@ static struct scmi_sensor_ops sensor_ops = { .reading_get = scmi_sensor_reading_get, }; -static int scmi_sensors_protocol_init(struct scmi_handle *handle) +static int scmi_sensors_protocol_init(struct scmi_device *dev) { u32 version; struct sensors_info *sinfo; + struct scmi_handle *handle = dev->handle; if (handle->sensor_ops && handle->sensor_priv) return 0; /* initialised already for the first device */ diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 5c873a59b387..b676825e6eb0 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -316,6 +316,6 @@ static inline void scmi_driver_unregister(struct scmi_driver *driver) {} #define module_scmi_driver(__scmi_driver) \ module_driver(__scmi_driver, scmi_register, scmi_unregister) -typedef int (*scmi_prot_init_fn_t)(struct scmi_handle *); +typedef int (*scmi_prot_init_fn_t)(struct scmi_device *); int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn); void scmi_protocol_unregister(int protocol_id);
The scmi bus now supports multiple device per protocol. So, in order to initialise each device and it's attributes, it's better to pass scmi_device pointer to the protocol initialise function rather than scmi_handle. scmi_handle can be still fetched from the scmi_device pointer. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- drivers/firmware/arm_scmi/bus.c | 6 +++--- drivers/firmware/arm_scmi/clock.c | 3 ++- drivers/firmware/arm_scmi/perf.c | 3 ++- drivers/firmware/arm_scmi/power.c | 3 ++- drivers/firmware/arm_scmi/reset.c | 3 ++- drivers/firmware/arm_scmi/sensors.c | 3 ++- include/linux/scmi_protocol.h | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) -- 2.17.1