Message ID | 1427385240-6086-6-git-send-email-s.hauer@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Mar 26, 2015 at 04:53:52PM +0100, Sascha Hauer wrote: > Inline update_temperature into its only caller to make the code > more readable. I am not sure I understand how this is improving readability, can you please elaborate? The way it is now it is more modular at least. > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- > drivers/thermal/thermal_core.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index ebca854..6d0fdad 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -431,11 +431,15 @@ exit: > } > EXPORT_SYMBOL_GPL(thermal_zone_get_temp); > > -static void update_temperature(struct thermal_zone_device *tz) > +void thermal_zone_device_update(struct thermal_zone_device *tz) > { > + int count; > unsigned long temp; > int ret; > > + if (!tz->ops->get_temp) > + return; > + > ret = thermal_zone_get_temp(tz, &temp); > if (ret) { > dev_warn(&tz->device, "failed to read out thermal zone %d\n", > @@ -451,16 +455,6 @@ static void update_temperature(struct thermal_zone_device *tz) > trace_thermal_temperature(tz); > dev_dbg(&tz->device, "last_temperature=%lu, current_temperature=%lu\n", > tz->last_temperature, tz->temperature); > -} > - > -void thermal_zone_device_update(struct thermal_zone_device *tz) > -{ > - int count; > - > - if (!tz->ops->get_temp) > - return; > - > - update_temperature(tz); > > for (count = 0; count < tz->trips; count++) > handle_thermal_trip(tz, count); > -- > 2.1.4 >
On Mon, Apr 06, 2015 at 07:23:08PM -0700, Eduardo Valentin wrote: > On Thu, Mar 26, 2015 at 04:53:52PM +0100, Sascha Hauer wrote: > > Inline update_temperature into its only caller to make the code > > more readable. > > I am not sure I understand how this is improving readability, can you > please elaborate? It improves readability because the reader does not have to lookup the definition of update_temperature but can instead just read through. The function name "update_temperature" does not give new information either, so I thought inlining the code is a good idea. Anyway, I can skip this patch if you want. Sascha
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index ebca854..6d0fdad 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -431,11 +431,15 @@ exit: } EXPORT_SYMBOL_GPL(thermal_zone_get_temp); -static void update_temperature(struct thermal_zone_device *tz) +void thermal_zone_device_update(struct thermal_zone_device *tz) { + int count; unsigned long temp; int ret; + if (!tz->ops->get_temp) + return; + ret = thermal_zone_get_temp(tz, &temp); if (ret) { dev_warn(&tz->device, "failed to read out thermal zone %d\n", @@ -451,16 +455,6 @@ static void update_temperature(struct thermal_zone_device *tz) trace_thermal_temperature(tz); dev_dbg(&tz->device, "last_temperature=%lu, current_temperature=%lu\n", tz->last_temperature, tz->temperature); -} - -void thermal_zone_device_update(struct thermal_zone_device *tz) -{ - int count; - - if (!tz->ops->get_temp) - return; - - update_temperature(tz); for (count = 0; count < tz->trips; count++) handle_thermal_trip(tz, count);
Inline update_temperature into its only caller to make the code more readable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- drivers/thermal/thermal_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)