Re: [PATCH] drivers: mfd: silence compiler warning in sec-core.c

From: Pankaj Dubey
Date: Mon Mar 10 2014 - 22:12:10 EST


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@xxxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/