[2/2] PM/Domains: Replace plain integer with NULL pointer in domain.c file

Message ID 1341903738-1791-2-git-send-email-sachin.kamat@linaro.org
State Accepted
Headers show

Commit Message

Sachin Kamat July 10, 2012, 7:02 a.m.
Fixes the following sparse warning:
drivers/base/power/domain.c:1679:55: warning: Using plain integer as NULL pointer

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/base/power/domain.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Rafael J. Wysocki July 10, 2012, 5:24 p.m. | #1
On Tuesday, July 10, 2012, Sachin Kamat wrote:
> Fixes the following sparse warning:
> drivers/base/power/domain.c:1679:55: warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/base/power/domain.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 4f8e0d2..8d67417 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1676,7 +1676,7 @@ int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td)
>  
>  	if (dev->power.subsys_data->domain_data) {
>  		gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
> -		gpd_data->ops = (struct gpd_dev_ops){ 0 };
> +		gpd_data->ops = (struct gpd_dev_ops){ NULL };

This doesn't seem to be correct, because gpd_data->ops is not a pointer.

Thanks,
Rafael


>  		if (clear_td)
>  			gpd_data->td = (struct gpd_timing_data){ 0 };
>  
>
Sachin Kamat July 11, 2012, 4:16 a.m. | #2
On 10/07/2012, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Tuesday, July 10, 2012, Sachin Kamat wrote:
>> Fixes the following sparse warning:
>> drivers/base/power/domain.c:1679:55: warning: Using plain integer as NULL
>> pointer
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> ---
>>  drivers/base/power/domain.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
>> index 4f8e0d2..8d67417 100644
>> --- a/drivers/base/power/domain.c
>> +++ b/drivers/base/power/domain.c
>> @@ -1676,7 +1676,7 @@ int __pm_genpd_remove_callbacks(struct device *dev,
>> bool clear_td)
>>
>>  	if (dev->power.subsys_data->domain_data) {
>>  		gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
>> -		gpd_data->ops = (struct gpd_dev_ops){ 0 };
>> +		gpd_data->ops = (struct gpd_dev_ops){ NULL };
>
> This doesn't seem to be correct, because gpd_data->ops is not a pointer.

struct gpd_dev_ops (gpd_data->ops) being a structure of function
pointers (as shown below), I thought it would be appropriate to
initialise the members to NULL instead of 0.

struct gpd_dev_ops {
    int (*start)(struct device *dev);
    int (*stop)(struct device *dev);
    int (*save_state)(struct device *dev);
    int (*restore_state)(struct device *dev);
    int (*suspend)(struct device *dev);
    int (*suspend_late)(struct device *dev);
    int (*resume_early)(struct device *dev);
    int (*resume)(struct device *dev);
    int (*freeze)(struct device *dev);
    int (*freeze_late)(struct device *dev);
    int (*thaw_early)(struct device *dev);
    int (*thaw)(struct device *dev);
    bool (*active_wakeup)(struct device *dev);
};



>
> Thanks,
> Rafael
>
>
>>  		if (clear_td)
>>  			gpd_data->td = (struct gpd_timing_data){ 0 };
>>
>>
>
>
Rafael J. Wysocki July 11, 2012, 9:22 a.m. | #3
On Wednesday, July 11, 2012, Sachin Kamat wrote:
> On 10/07/2012, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Tuesday, July 10, 2012, Sachin Kamat wrote:
> >> Fixes the following sparse warning:
> >> drivers/base/power/domain.c:1679:55: warning: Using plain integer as NULL
> >> pointer
> >>
> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> >> ---
> >>  drivers/base/power/domain.c |    2 +-
> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> >> index 4f8e0d2..8d67417 100644
> >> --- a/drivers/base/power/domain.c
> >> +++ b/drivers/base/power/domain.c
> >> @@ -1676,7 +1676,7 @@ int __pm_genpd_remove_callbacks(struct device *dev,
> >> bool clear_td)
> >>
> >>  	if (dev->power.subsys_data->domain_data) {
> >>  		gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
> >> -		gpd_data->ops = (struct gpd_dev_ops){ 0 };
> >> +		gpd_data->ops = (struct gpd_dev_ops){ NULL };
> >
> > This doesn't seem to be correct, because gpd_data->ops is not a pointer.
> 
> struct gpd_dev_ops (gpd_data->ops) being a structure of function
> pointers (as shown below), I thought it would be appropriate to
> initialise the members to NULL instead of 0.

Ah, OK.  So perhaps it would be useful to put a comma after the NULL?

Rafael


> struct gpd_dev_ops {
>     int (*start)(struct device *dev);
>     int (*stop)(struct device *dev);
>     int (*save_state)(struct device *dev);
>     int (*restore_state)(struct device *dev);
>     int (*suspend)(struct device *dev);
>     int (*suspend_late)(struct device *dev);
>     int (*resume_early)(struct device *dev);
>     int (*resume)(struct device *dev);
>     int (*freeze)(struct device *dev);
>     int (*freeze_late)(struct device *dev);
>     int (*thaw_early)(struct device *dev);
>     int (*thaw)(struct device *dev);
>     bool (*active_wakeup)(struct device *dev);
> };
Sachin Kamat July 11, 2012, 9:25 a.m. | #4
On 11/07/2012, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Wednesday, July 11, 2012, Sachin Kamat wrote:
>> On 10/07/2012, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>> > On Tuesday, July 10, 2012, Sachin Kamat wrote:
>> >> Fixes the following sparse warning:
>> >> drivers/base/power/domain.c:1679:55: warning: Using plain integer as
>> >> NULL
>> >> pointer
>> >>
>> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> >> ---
>> >>  drivers/base/power/domain.c |    2 +-
>> >>  1 files changed, 1 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
>> >> index 4f8e0d2..8d67417 100644
>> >> --- a/drivers/base/power/domain.c
>> >> +++ b/drivers/base/power/domain.c
>> >> @@ -1676,7 +1676,7 @@ int __pm_genpd_remove_callbacks(struct device
>> >> *dev,
>> >> bool clear_td)
>> >>
>> >>  	if (dev->power.subsys_data->domain_data) {
>> >>  		gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
>> >> -		gpd_data->ops = (struct gpd_dev_ops){ 0 };
>> >> +		gpd_data->ops = (struct gpd_dev_ops){ NULL };
>> >
>> > This doesn't seem to be correct, because gpd_data->ops is not a
>> > pointer.
>>
>> struct gpd_dev_ops (gpd_data->ops) being a structure of function
>> pointers (as shown below), I thought it would be appropriate to
>> initialise the members to NULL instead of 0.
>
> Ah, OK.  So perhaps it would be useful to put a comma after the NULL?
>
I would prefer to leave it at that (without comma). However if you
think adding a comma would be appropriate, I can send you the updated
patch. Please let me know.


> Rafael
>
>
>> struct gpd_dev_ops {
>>     int (*start)(struct device *dev);
>>     int (*stop)(struct device *dev);
>>     int (*save_state)(struct device *dev);
>>     int (*restore_state)(struct device *dev);
>>     int (*suspend)(struct device *dev);
>>     int (*suspend_late)(struct device *dev);
>>     int (*resume_early)(struct device *dev);
>>     int (*resume)(struct device *dev);
>>     int (*freeze)(struct device *dev);
>>     int (*freeze_late)(struct device *dev);
>>     int (*thaw_early)(struct device *dev);
>>     int (*thaw)(struct device *dev);
>>     bool (*active_wakeup)(struct device *dev);
>> };
>
Rafael J. Wysocki July 11, 2012, 9:48 a.m. | #5
On Wednesday, July 11, 2012, Sachin Kamat wrote:
> On 11/07/2012, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Wednesday, July 11, 2012, Sachin Kamat wrote:
> >> On 10/07/2012, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> >> > On Tuesday, July 10, 2012, Sachin Kamat wrote:
> >> >> Fixes the following sparse warning:
> >> >> drivers/base/power/domain.c:1679:55: warning: Using plain integer as
> >> >> NULL
> >> >> pointer
> >> >>
> >> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> >> >> ---
> >> >>  drivers/base/power/domain.c |    2 +-
> >> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >> >>
> >> >> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> >> >> index 4f8e0d2..8d67417 100644
> >> >> --- a/drivers/base/power/domain.c
> >> >> +++ b/drivers/base/power/domain.c
> >> >> @@ -1676,7 +1676,7 @@ int __pm_genpd_remove_callbacks(struct device
> >> >> *dev,
> >> >> bool clear_td)
> >> >>
> >> >>  	if (dev->power.subsys_data->domain_data) {
> >> >>  		gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
> >> >> -		gpd_data->ops = (struct gpd_dev_ops){ 0 };
> >> >> +		gpd_data->ops = (struct gpd_dev_ops){ NULL };
> >> >
> >> > This doesn't seem to be correct, because gpd_data->ops is not a
> >> > pointer.
> >>
> >> struct gpd_dev_ops (gpd_data->ops) being a structure of function
> >> pointers (as shown below), I thought it would be appropriate to
> >> initialise the members to NULL instead of 0.
> >
> > Ah, OK.  So perhaps it would be useful to put a comma after the NULL?
> >
> I would prefer to leave it at that (without comma). However if you
> think adding a comma would be appropriate, I can send you the updated
> patch. Please let me know.

OK, I'll apply your original patch.

Thanks,
Rafael


> >> struct gpd_dev_ops {
> >>     int (*start)(struct device *dev);
> >>     int (*stop)(struct device *dev);
> >>     int (*save_state)(struct device *dev);
> >>     int (*restore_state)(struct device *dev);
> >>     int (*suspend)(struct device *dev);
> >>     int (*suspend_late)(struct device *dev);
> >>     int (*resume_early)(struct device *dev);
> >>     int (*resume)(struct device *dev);
> >>     int (*freeze)(struct device *dev);
> >>     int (*freeze_late)(struct device *dev);
> >>     int (*thaw_early)(struct device *dev);
> >>     int (*thaw)(struct device *dev);
> >>     bool (*active_wakeup)(struct device *dev);
> >> };
> >
> 
> 
>

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 4f8e0d2..8d67417 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1676,7 +1676,7 @@  int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td)
 
 	if (dev->power.subsys_data->domain_data) {
 		gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
-		gpd_data->ops = (struct gpd_dev_ops){ 0 };
+		gpd_data->ops = (struct gpd_dev_ops){ NULL };
 		if (clear_td)
 			gpd_data->td = (struct gpd_timing_data){ 0 };