* [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data
@ 2019-04-15 14:48 Sumeet Pawnikar
2019-04-15 16:28 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Sumeet Pawnikar @ 2019-04-15 14:48 UTC (permalink / raw)
To: rui.zhang, edubezval, daniel.lezcano, srinivas.pandruvada
Cc: linux-pm, linux-kernel, andriy.shevchenko, sumeet.r.pawnikar
From: "Pawnikar, Sumeet R" <sumeet.r.pawnikar@intel.com>
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.
Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
---
.../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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data
2019-04-15 14:48 [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data Sumeet Pawnikar
@ 2019-04-15 16:28 ` Andy Shevchenko
2019-04-22 8:46 ` Zhang Rui
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2019-04-15 16:28 UTC (permalink / raw)
To: Sumeet Pawnikar
Cc: rui.zhang, edubezval, daniel.lezcano, srinivas.pandruvada,
linux-pm, linux-kernel
On Mon, Apr 15, 2019 at 08:18:30PM +0530, Sumeet Pawnikar wrote:
> From: "Pawnikar, Sumeet R" <sumeet.r.pawnikar@intel.com>
>
> 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@intel.com>
> Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
> ---
> .../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
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data
2019-04-15 16:28 ` Andy Shevchenko
@ 2019-04-22 8:46 ` Zhang Rui
2019-04-22 8:55 ` Zhang Rui
0 siblings, 1 reply; 5+ messages in thread
From: Zhang Rui @ 2019-04-22 8:46 UTC (permalink / raw)
To: Andy Shevchenko, Sumeet Pawnikar
Cc: edubezval, daniel.lezcano, srinivas.pandruvada, linux-pm, linux-kernel
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@intel.com>
> >
> > 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@intel.com>
>
Thanks, patch applied.
-rui
> >
> > Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
> > ---
> > .../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
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data
2019-04-22 8:46 ` Zhang Rui
@ 2019-04-22 8:55 ` Zhang Rui
2019-04-24 11:19 ` Pawnikar, Sumeet R
0 siblings, 1 reply; 5+ messages in thread
From: Zhang Rui @ 2019-04-22 8:55 UTC (permalink / raw)
To: Andy Shevchenko, Sumeet Pawnikar
Cc: edubezval, daniel.lezcano, srinivas.pandruvada, linux-pm, linux-kernel
On 一, 2019-04-22 at 16:46 +0800, Zhang Rui wrote:
> 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@intel.com>
> > >
just one comment, the author name you used is not consistent with the
name you used for your Signed-off-by 'Pawnikar, Sumeet R <sumeet.r.pawn
ikar@intel.com>', and checkpatch complains about missing Signed-off-by
from patch author.
Please fix your gitconfig and run checkpatch before sending next time.
thanks,
rui
> > > 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@intel.com>
> >
> Thanks, patch applied.
>
> -rui
> >
> > >
> > >
> > > Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
> > > ---
> > > .../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
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data
2019-04-22 8:55 ` Zhang Rui
@ 2019-04-24 11:19 ` Pawnikar, Sumeet R
0 siblings, 0 replies; 5+ messages in thread
From: Pawnikar, Sumeet R @ 2019-04-24 11:19 UTC (permalink / raw)
To: Zhang, Rui, Shevchenko, Andriy
Cc: edubezval, daniel.lezcano, srinivas.pandruvada, linux-pm, linux-kernel
>-----Original Message-----
>From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
>owner@vger.kernel.org] On Behalf Of Zhang Rui
>Sent: Monday, April 22, 2019 2:26 PM
>To: Shevchenko, Andriy <andriy.shevchenko@intel.com>; Pawnikar, Sumeet R
><sumeet.r.pawnikar@intel.com>
>Cc: edubezval@gmail.com; daniel.lezcano@linaro.org;
>srinivas.pandruvada@linux.intel.com; linux-pm@vger.kernel.org; linux-
>kernel@vger.kernel.org
>Subject: Re: [PATCH] thermal: intel: int340x: processor_thermal_device:
>simplify to get driver data
>
>On 一, 2019-04-22 at 16:46 +0800, Zhang Rui wrote:
>> 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@intel.com>
>> > >
>just one comment, the author name you used is not consistent with the name
>you used for your Signed-off-by 'Pawnikar, Sumeet R <sumeet.r.pawn
>ikar@intel.com>', and checkpatch complains about missing Signed-off-by from
>patch author.
>Please fix your gitconfig and run checkpatch before sending next time.
>
Sure, will fix this going forward.
Thanks,
Sumeet.
>thanks,
>rui
>
>> > > 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@intel.com>
>> >
>> Thanks, patch applied.
>>
>> -rui
>> >
>> > >
>> > >
>> > > Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
>> > > ---
>> > > .../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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-24 11:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 14:48 [PATCH] thermal: intel: int340x: processor_thermal_device: simplify to get driver data Sumeet Pawnikar
2019-04-15 16:28 ` Andy Shevchenko
2019-04-22 8:46 ` Zhang Rui
2019-04-22 8:55 ` Zhang Rui
2019-04-24 11:19 ` Pawnikar, Sumeet R
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).