public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: mfd: silence compiler warning in sec-core.c
@ 2014-03-05 10:59 Pankaj Dubey
  2014-03-10 15:07 ` Lee Jones
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Pankaj Dubey @ 2014-03-05 10:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: lee.jones, sameo, sbkim73, Pankaj Dubey

When used 64bit compiler GCC warns as
drivers/mfd/sec-core.c:199:10: warning:
cast from pointer to integer of different size [-Wpointer-to-int-cast]

This patch fixes this by type-casting "match->data" into "long" before
converting into "int"

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 drivers/mfd/sec-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index a139798..2e7580bd 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -187,7 +187,7 @@ static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
 	if (i2c->dev.of_node) {
 		const struct of_device_id *match;
 		match = of_match_node(sec_dt_match, i2c->dev.of_node);
-		return (int)match->data;
+		return (int)(long)match->data;
 	}
 #endif
 	return (int)id->driver_data;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-05 10:59 [PATCH] drivers: mfd: silence compiler warning in sec-core.c Pankaj Dubey
@ 2014-03-10 15:07 ` Lee Jones
  2014-03-11  2:28   ` Pankaj Dubey
  2014-03-12  6:37 ` [PATCH v2] " Pankaj Dubey
  2014-03-13  2:14 ` [PATCH v3] " Pankaj Dubey
  2 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2014-03-10 15:07 UTC (permalink / raw)
  To: Pankaj Dubey; +Cc: linux-kernel, sameo, sbkim73

> When used 64bit compiler GCC warns as
> drivers/mfd/sec-core.c:199:10: warning:
> cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
> This patch fixes this by type-casting "match->data" into "long" before
> converting into "int"
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  drivers/mfd/sec-core.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
> index a139798..2e7580bd 100644
> --- a/drivers/mfd/sec-core.c
> +++ b/drivers/mfd/sec-core.c
> @@ -187,7 +187,7 @@ static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
>  	if (i2c->dev.of_node) {
>  		const struct of_device_id *match;
>  		match = of_match_node(sec_dt_match, i2c->dev.of_node);
> -		return (int)match->data;
> +		return (int)(long)match->data;

I think using an unsigned long would be better.

>  	}
>  #endif
>  	return (int)id->driver_data;

Doesn't this give you the same error?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-10 15:07 ` Lee Jones
@ 2014-03-11  2:28   ` Pankaj Dubey
  2014-03-11  6:46     ` Lee Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Pankaj Dubey @ 2014-03-11  2:28 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, sameo, sbkim73

On 03/11/2014 12:07 AM, Lee Jones wrote:
>> When used 64bit compiler GCC warns as
>> drivers/mfd/sec-core.c:199:10: warning:
>> cast from pointer to integer of different size [-Wpointer-to-int-cast]
>>
>> This patch fixes this by type-casting "match->data" into "long" before
>> converting into "int"
>>
>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>> ---
>>   drivers/mfd/sec-core.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
>> index a139798..2e7580bd 100644
>> --- a/drivers/mfd/sec-core.c
>> +++ b/drivers/mfd/sec-core.c
>> @@ -187,7 +187,7 @@ static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
>>   	if (i2c->dev.of_node) {
>>   		const struct of_device_id *match;
>>   		match = of_match_node(sec_dt_match, i2c->dev.of_node);
>> -		return (int)match->data;
>> +		return (int)(long)match->data;
> I think using an unsigned long would be better.

I could have done that but since "sec_i2c_get_driver_data" return type is
"int" for me it make sense to return "int", and it does not make much sense
to change this function signature as return value is used only for getting
variant type. Also same has been done in "max8998_i2c_get_driver_data", if
you still think it's better to typecast into "unsigned long" or
"kernel_ulong_t" please let me know I will change accordingly.

>>   	}
>>   #endif
>>   	return (int)id->driver_data;
> Doesn't this give you the same error?
>
No. As id->driver_data is of type "kernel_ulong_t" and not a pointer.


-- 
Best Regards,
Pankaj Dubey


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-11  2:28   ` Pankaj Dubey
@ 2014-03-11  6:46     ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2014-03-11  6:46 UTC (permalink / raw)
  To: Pankaj Dubey; +Cc: linux-kernel, sameo, sbkim73

> >>When used 64bit compiler GCC warns as
> >>drivers/mfd/sec-core.c:199:10: warning:
> >>cast from pointer to integer of different size [-Wpointer-to-int-cast]
> >>
> >>This patch fixes this by type-casting "match->data" into "long" before
> >>converting into "int"
> >>
> >>Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> >>---
> >>  drivers/mfd/sec-core.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
> >>index a139798..2e7580bd 100644
> >>--- a/drivers/mfd/sec-core.c
> >>+++ b/drivers/mfd/sec-core.c
> >>@@ -187,7 +187,7 @@ static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
> >>  	if (i2c->dev.of_node) {
> >>  		const struct of_device_id *match;
> >>  		match = of_match_node(sec_dt_match, i2c->dev.of_node);
> >>-		return (int)match->data;
> >>+		return (int)(long)match->data;
> >I think using an unsigned long would be better.
> 
> I could have done that but since "sec_i2c_get_driver_data" return type is
> "int" for me it make sense to return "int", and it does not make much sense
> to change this function signature as return value is used only for getting
> variant type. Also same has been done in "max8998_i2c_get_driver_data", if
> you still think it's better to typecast into "unsigned long" or
> "kernel_ulong_t" please let me know I will change accordingly.

I'd prefer to change the whole thing to unsigned long, based only on
the fact that a) it's a trivial piece of work and b) for consistency
with other MFD drivers who have recently suffered the same issues.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-05 10:59 [PATCH] drivers: mfd: silence compiler warning in sec-core.c Pankaj Dubey
  2014-03-10 15:07 ` Lee Jones
@ 2014-03-12  6:37 ` Pankaj Dubey
  2014-03-12  9:43   ` Lee Jones
  2014-03-13  2:14 ` [PATCH v3] " Pankaj Dubey
  2 siblings, 1 reply; 8+ messages in thread
From: Pankaj Dubey @ 2014-03-12  6:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: lee.jones, sameo, sbkim73, Pankaj Dubey

When used 64bit compiler GCC warns as
drivers/mfd/sec-core.c:199:10: warning:
cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 drivers/mfd/sec-core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index e467108..3c9fd5d 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -210,17 +210,17 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata(
 }
 #endif
 
-static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
+static inline unsigned long sec_i2c_get_driver_data(struct i2c_client *i2c,
 						const struct i2c_device_id *id)
 {
 #ifdef CONFIG_OF
 	if (i2c->dev.of_node) {
 		const struct of_device_id *match;
 		match = of_match_node(sec_dt_match, i2c->dev.of_node);
-		return (int)match->data;
+		return (unsigned long)match->data;
 	}
 #endif
-	return (int)id->driver_data;
+	return id->driver_data;
 }
 
 static int sec_pmic_probe(struct i2c_client *i2c,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-12  6:37 ` [PATCH v2] " Pankaj Dubey
@ 2014-03-12  9:43   ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2014-03-12  9:43 UTC (permalink / raw)
  To: Pankaj Dubey; +Cc: linux-kernel, sameo, sbkim73

On Wed, 12 Mar 2014, Pankaj Dubey wrote:

> When used 64bit compiler GCC warns as
> drivers/mfd/sec-core.c:199:10: warning:
> cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  drivers/mfd/sec-core.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
> index e467108..3c9fd5d 100644
> --- a/drivers/mfd/sec-core.c
> +++ b/drivers/mfd/sec-core.c
> @@ -210,17 +210,17 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata(
>  }
>  #endif
>  
> -static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
> +static inline unsigned long sec_i2c_get_driver_data(struct i2c_client *i2c,
>  						const struct i2c_device_id *id)
>  {
>  #ifdef CONFIG_OF
>  	if (i2c->dev.of_node) {
>  		const struct of_device_id *match;
>  		match = of_match_node(sec_dt_match, i2c->dev.of_node);
> -		return (int)match->data;
> +		return (unsigned long)match->data;
>  	}
>  #endif
> -	return (int)id->driver_data;
> +	return id->driver_data;
>  }
>  
>  static int sec_pmic_probe(struct i2c_client *i2c,

You also need to change the 'type' attribute in 'struct
sec_pmic_dev'.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-05 10:59 [PATCH] drivers: mfd: silence compiler warning in sec-core.c Pankaj Dubey
  2014-03-10 15:07 ` Lee Jones
  2014-03-12  6:37 ` [PATCH v2] " Pankaj Dubey
@ 2014-03-13  2:14 ` Pankaj Dubey
  2014-03-13  8:03   ` Lee Jones
  2 siblings, 1 reply; 8+ messages in thread
From: Pankaj Dubey @ 2014-03-13  2:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: lee.jones, sameo, sbkim73, Pankaj Dubey

When used 64bit compiler GCC warns as
drivers/mfd/sec-core.c:199:10: warning:
cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 drivers/mfd/sec-core.c           |    6 +++---
 include/linux/mfd/samsung/core.h |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index ce32538..c6088c5 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -189,17 +189,17 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata(
 }
 #endif
 
-static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
+static inline unsigned long sec_i2c_get_driver_data(struct i2c_client *i2c,
 						const struct i2c_device_id *id)
 {
 #ifdef CONFIG_OF
 	if (i2c->dev.of_node) {
 		const struct of_device_id *match;
 		match = of_match_node(sec_dt_match, i2c->dev.of_node);
-		return (int)match->data;
+		return (unsigned long)match->data;
 	}
 #endif
-	return (int)id->driver_data;
+	return id->driver_data;
 }
 
 static int sec_pmic_probe(struct i2c_client *i2c,
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index a30b53c..05d584b 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -51,7 +51,7 @@ struct sec_pmic_dev {
 	struct regmap_irq_chip_data *irq_data;
 
 	int ono;
-	int type;
+	unsigned long type;
 	bool wakeup;
 	bool wtsr_smpl;
 };
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] drivers: mfd: silence compiler warning in sec-core.c
  2014-03-13  2:14 ` [PATCH v3] " Pankaj Dubey
@ 2014-03-13  8:03   ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2014-03-13  8:03 UTC (permalink / raw)
  To: Pankaj Dubey; +Cc: linux-kernel, sameo, sbkim73

> When used 64bit compiler GCC warns as
> drivers/mfd/sec-core.c:199:10: warning:
> cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---

When submitting multiple versions, it's really helpful to keep a
simple, bullet-point change log here. It aids the review process and
omits the requirement to keep the history of every patch submittion in
a Maintainer's head.

>  drivers/mfd/sec-core.c           |    6 +++---
>  include/linux/mfd/samsung/core.h |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)

Patch looks good now. Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-13  8:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-05 10:59 [PATCH] drivers: mfd: silence compiler warning in sec-core.c Pankaj Dubey
2014-03-10 15:07 ` Lee Jones
2014-03-11  2:28   ` Pankaj Dubey
2014-03-11  6:46     ` Lee Jones
2014-03-12  6:37 ` [PATCH v2] " Pankaj Dubey
2014-03-12  9:43   ` Lee Jones
2014-03-13  2:14 ` [PATCH v3] " Pankaj Dubey
2014-03-13  8:03   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox