* [PATCH] gpio: Fix wrong pointer type in pca953x
@ 2011-02-22 8:56 Dirk Eibach
2011-02-22 12:36 ` Dan Carpenter
0 siblings, 1 reply; 6+ messages in thread
From: Dirk Eibach @ 2011-02-22 8:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Dirk Eibach
pca953x_get_alt_pdata() uses uint16_t* as result type for
of_get_property(), but numeric of values are u32.
Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
drivers/gpio/pca953x.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index a261972..d79e031 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -448,7 +448,7 @@ pca953x_get_alt_pdata(struct i2c_client *client)
{
struct pca953x_platform_data *pdata;
struct device_node *node;
- const uint16_t *val;
+ const u32 *val;
node = client->dev.of_node;
if (node == NULL)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: Fix wrong pointer type in pca953x
2011-02-22 8:56 [PATCH] gpio: Fix wrong pointer type in pca953x Dirk Eibach
@ 2011-02-22 12:36 ` Dan Carpenter
2011-02-22 12:52 ` Eibach, Dirk
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-02-22 12:36 UTC (permalink / raw)
To: Dirk Eibach; +Cc: linux-kernel
On Tue, Feb 22, 2011 at 09:56:50AM +0100, Dirk Eibach wrote:
> struct pca953x_platform_data *pdata;
> struct device_node *node;
> - const uint16_t *val;
> + const u32 *val;
>
This should probably be signed? We compare it against zero later on.
if (*val < 0)
dev_warn(&client->dev,
"invalid gpio-base in device tree\n");
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] gpio: Fix wrong pointer type in pca953x
2011-02-22 12:36 ` Dan Carpenter
@ 2011-02-22 12:52 ` Eibach, Dirk
2011-02-22 13:28 ` [PATCH v2] " Dirk Eibach
2011-02-24 9:20 ` [PATCH v3] " Dirk Eibach
2 siblings, 0 replies; 6+ messages in thread
From: Eibach, Dirk @ 2011-02-22 12:52 UTC (permalink / raw)
To: linux-kernel
> > struct pca953x_platform_data *pdata;
> > struct device_node *node;
> > - const uint16_t *val;
> > + const u32 *val;
> >
>
> This should probably be signed? We compare it against zero later on.
>
> if (*val < 0)
> dev_warn(&client->dev,
> "invalid gpio-base in device
> tree\n");
Good catch.
of property values are generally unsigned. The whole check is bogus
here. Will supply updated patch later.
> regards,
> dan carpenter
Cheers
Dirk
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] gpio: Fix wrong pointer type in pca953x
2011-02-22 12:36 ` Dan Carpenter
2011-02-22 12:52 ` Eibach, Dirk
@ 2011-02-22 13:28 ` Dirk Eibach
2011-02-24 9:20 ` [PATCH v3] " Dirk Eibach
2 siblings, 0 replies; 6+ messages in thread
From: Dirk Eibach @ 2011-02-22 13:28 UTC (permalink / raw)
To: linux-kernel; +Cc: error27, Dirk Eibach
pca953x_get_alt_pdata() uses uint16_t* as result type for
of_get_property(), but numeric of values are u32.
Checking for negative values is bogus because of-property
values are unsigned by definition.
Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
Changes since v1:
- removed bogus check for negative property values
drivers/gpio/pca953x.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index a261972..8acbfe9 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -448,7 +448,7 @@ pca953x_get_alt_pdata(struct i2c_client *client)
{
struct pca953x_platform_data *pdata;
struct device_node *node;
- const uint16_t *val;
+ const u32 *val;
node = client->dev.of_node;
if (node == NULL)
@@ -462,13 +462,8 @@ pca953x_get_alt_pdata(struct i2c_client *client)
pdata->gpio_base = -1;
val = of_get_property(node, "linux,gpio-base", NULL);
- if (val) {
- if (*val < 0)
- dev_warn(&client->dev,
- "invalid gpio-base in device tree\n");
- else
- pdata->gpio_base = *val;
- }
+ if (val)
+ pdata->gpio_base = *val;
val = of_get_property(node, "polarity", NULL);
if (val)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3] gpio: Fix wrong pointer type in pca953x
2011-02-22 12:36 ` Dan Carpenter
2011-02-22 12:52 ` Eibach, Dirk
2011-02-22 13:28 ` [PATCH v2] " Dirk Eibach
@ 2011-02-24 9:20 ` Dirk Eibach
2011-02-24 15:56 ` Grant Likely
2 siblings, 1 reply; 6+ messages in thread
From: Dirk Eibach @ 2011-02-24 9:20 UTC (permalink / raw)
To: linux-kernel; +Cc: error27, grant.likely, Dirk Eibach
pca953x_get_alt_pdata() uses uint16_t* as result type for
of_get_property(), but numeric of values are __be32.
Checking for negative values is bogus because of-property
values are unsigned by definition.
Instead check for proper property size.
Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
Changes since v1:
- removed bogus check for negative property values
Changes since v2:
- assume big-endian properties
- check property size
drivers/gpio/pca953x.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index a261972..694b0f9 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -448,7 +448,8 @@ pca953x_get_alt_pdata(struct i2c_client *client)
{
struct pca953x_platform_data *pdata;
struct device_node *node;
- const uint16_t *val;
+ const __be32 *val;
+ int size;
node = client->dev.of_node;
if (node == NULL)
@@ -461,13 +462,13 @@ pca953x_get_alt_pdata(struct i2c_client *client)
}
pdata->gpio_base = -1;
- val = of_get_property(node, "linux,gpio-base", NULL);
+ val = of_get_property(node, "linux,gpio-base", &size);
if (val) {
- if (*val < 0)
- dev_warn(&client->dev,
- "invalid gpio-base in device tree\n");
+ if (size != sizeof(*val))
+ dev_warn(&client->dev, "%s: wrong linux,gpio-base\n",
+ node->full_name);
else
- pdata->gpio_base = *val;
+ pdata->gpio_base = be32_to_cpup(val);
}
val = of_get_property(node, "polarity", NULL);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] gpio: Fix wrong pointer type in pca953x
2011-02-24 9:20 ` [PATCH v3] " Dirk Eibach
@ 2011-02-24 15:56 ` Grant Likely
0 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2011-02-24 15:56 UTC (permalink / raw)
To: Dirk Eibach; +Cc: linux-kernel, error27
On Thu, Feb 24, 2011 at 10:20:43AM +0100, Dirk Eibach wrote:
> pca953x_get_alt_pdata() uses uint16_t* as result type for
> of_get_property(), but numeric of values are __be32.
>
> Checking for negative values is bogus because of-property
> values are unsigned by definition.
> Instead check for proper property size.
>
> Signed-off-by: Dirk Eibach <eibach@gdsys.de>
Applied, thanks.
g.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-02-24 15:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22 8:56 [PATCH] gpio: Fix wrong pointer type in pca953x Dirk Eibach
2011-02-22 12:36 ` Dan Carpenter
2011-02-22 12:52 ` Eibach, Dirk
2011-02-22 13:28 ` [PATCH v2] " Dirk Eibach
2011-02-24 9:20 ` [PATCH v3] " Dirk Eibach
2011-02-24 15:56 ` Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox