drivers: mfd: silence compiler warning in sec-core.c
PATCH 1/1 drivers: mfd: silence compiler warning in sec-core.c
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"
--- drivers/mfd/sec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/sec-core.c +1 -1
@@ -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;
Signature · 1 line
1.7.9.5
Quoted 17 lines
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 <[email protected]>--- drivers/mfd/sec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mfd/sec-core.c +0
-0
drivers/mfd/sec-core.c static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, · line 190
Quoted 5 lines
drivers/mfd/sec-core.c +1
-1@@ -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.
drivers/mfd/sec-core.c static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, · line 193
Quoted 3 lines
drivers/mfd/sec-core.c +0
-0}#endif return (int )id->driver_data;
Doesn't this give you the same error?
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 12 lines · Lee Jones
Quoted 12 lines
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 <[email protected]>--- drivers/mfd/sec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines
drivers/mfd/sec-core.c static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, · line 190
Quoted 10 lines
drivers/mfd/sec-core.c +1
-1@@ -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.
Quoted 5 lines
drivers/mfd/sec-core.c static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, · line 193
Quoted 3 lines
drivers/mfd/sec-core.c +0
-0}#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.
Signature · 2 lines
Best Regards, Pankaj Dubey
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
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 <[email protected]>--- drivers/mfd/sec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 11 lines
drivers/mfd/sec-core.c static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, · line 190
Quoted 10 lines
drivers/mfd/sec-core.c +1
-1@@ -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.
Quoted 6 lines
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.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 1/1 drivers: mfd: silence compiler warning in sec-core.c
In reply to Pankaj DubeyWhen 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]
--- drivers/mfd/sec-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mfd/sec-core.c +3 -3
@@ -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,
Signature · 1 line
1.7.9.5
Quoted 24 lines · 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 <[email protected]>--- drivers/mfd/sec-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/mfd/sec-core.c +1
-1@@ -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;
drivers/mfd/sec-core.c static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( · line 226
Quoted 10 lines
drivers/mfd/sec-core.c +2
-2match =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'.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v3 1/1 drivers: mfd: silence compiler warning in sec-core.c
In reply to Pankaj DubeyWhen 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]
--- drivers/mfd/sec-core.c | 6 +++--- include/linux/mfd/samsung/core.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mfd/sec-core.c +3 -3
@@ -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,
include/linux/mfd/samsung/core.h +1 -1
@@ -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; };
Signature · 1 line
1.7.10.4
Quoted 6 lines
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 <[email protected]>---
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.
Quoted 3 lines
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.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog