Re: [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data

From: Zhang Rui
Date: Mon Apr 22 2019 - 04:46:43 EST


On ä, 2019-04-15 at 19:28 +0300, Andy Shevchenko wrote:
> On Mon, Apr 15, 2019 at 08:18:30PM +0530, Sumeet Pawnikar wrote:
> >
> > From: "Pawnikar, Sumeet R" <sumeet.r.pawnikar@xxxxxxxxx>
> >
> > This simplifies getting the 'driver_data' from 'struct device'
> > directly.
> > Going through platform_device or pci_dev is not required. Also
> > removes
> > condition check as the private data stored with dev pointer, means
> > irrespective of enumeration mode, we can use dev_get_drvdata().
> > This removes the unnecessary step back and forth.
> >
> Indeed, good clean up!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>
Thanks, patch applied.

-rui
> >
> > Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@xxxxxxxxx>
> > ---
> > Â.../int340x_thermal/processor_thermal_device.cÂÂÂÂÂ|ÂÂÂ11 +-------
> > ---
> > Â1 file changed, 1 insertion(+), 10 deletions(-)
> >
> > diff --git
> > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > index 8e1cf4d..2a7cbaa 100644
> > ---
> > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > +++
> > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > @@ -81,22 +81,13 @@ enum proc_thermal_emum_mode_type {
> > Â struct device_attribute
> > *attr, \
> > Â char *buf) \
> > Â{ \
> > - struct pci_dev *pci_dev; \
> > - struct platform_device *pdev; \
> > - struct proc_thermal_device *proc_dev; \
> > + struct proc_thermal_device *proc_dev =
> > dev_get_drvdata(dev); \
> > Â \
> > Â if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \
> > Â dev_warn(dev, "Attempted to get power limit before
> > device was initialized!\n"); \
> > Â return 0; \
> > Â } \
> > Â \
> > - if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) {
> > \
> > - pdev = to_platform_device(dev); \
> > - proc_dev = platform_get_drvdata(pdev); \
> > - } else { \
> > - pci_dev = to_pci_dev(dev); \
> > - proc_dev = pci_get_drvdata(pci_dev); \
> > - } \
> > Â return sprintf(buf, "%lu\n",\
> > Â (unsigned long)proc_dev->power_limits[index].suffix *
> > 1000); \
> > Â}
> > --Â
> > 1.7.9.5
> >