linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: gpio_keys - Use of_property_read_u32
@ 2011-08-31  7:32 Tobias Klauser
  2011-09-09 18:10 ` Dmitry Torokhov
  2011-09-19  9:09 ` [PATCH v2] " Tobias Klauser
  0 siblings, 2 replies; 7+ messages in thread
From: Tobias Klauser @ 2011-08-31  7:32 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Grant Likely, David Jander, linux-input, devicetree-discuss

Use the of_property_read_u32 helper function to retreive u32 values
from the device tree. Also do not pass the len parameter to
of_get_property if it isn't checked afterwards.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
 drivers/input/keyboard/gpio_keys.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 67df91a..e913294 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -462,7 +462,6 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 	int i;
 	struct gpio_keys_button *buttons;
 	const u32 *reg;
-	int len;
 
 	node = dev->of_node;
 	if (node == NULL)
@@ -470,7 +469,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 
 	memset(pdata, 0, sizeof *pdata);
 
-	pdata->rep = !!of_get_property(node, "autorepeat", &len);
+	pdata->rep = !!of_get_property(node, "autorepeat", NULL);
 
 	/* First count the subnodes */
 	pdata->nbuttons = 0;
@@ -498,22 +497,25 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 		buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
 		buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-		reg = of_get_property(pp, "linux,code", &len);
-		if (!reg) {
+		if (of_property_read_u32(pp, "linux,code", &reg))
 			dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
 			goto out_fail;
 		}
-		buttons[i].code = be32_to_cpup(reg);
+		buttons[i].code = reg;
 
-		buttons[i].desc = of_get_property(pp, "label", &len);
+		buttons[i].desc = of_get_property(pp, "label", NULL);
 
-		reg = of_get_property(pp, "linux,input-type", &len);
-		buttons[i].type = reg ? be32_to_cpup(reg) : EV_KEY;
+		if (of_property_read_u32(pp, "linux,input-type", &reg) == 0)
+			buttons[i].type = reg;
+		else
+			buttons[i].type = EV_KEY;
 
 		buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
 
-		reg = of_get_property(pp, "debounce-interval", &len);
-		buttons[i].debounce_interval = reg ? be32_to_cpup(reg) : 5;
+		if (of_property_read_u32(pp, "debounce-interval", &reg) == 0)
+			buttons[i].debounce_interval = reg;
+		else
+			buttons[i].debounce_interval = 5;
 
 		i++;
 	}
-- 
1.7.5.4


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

* Re: [PATCH] Input: gpio_keys - Use of_property_read_u32
  2011-08-31  7:32 [PATCH] Input: gpio_keys - Use of_property_read_u32 Tobias Klauser
@ 2011-09-09 18:10 ` Dmitry Torokhov
  2011-09-19  9:09 ` [PATCH v2] " Tobias Klauser
  1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2011-09-09 18:10 UTC (permalink / raw)
  To: Tobias Klauser
  Cc: Grant Likely, David Jander, linux-input, devicetree-discuss

On Wed, Aug 31, 2011 at 09:32:25AM +0200, Tobias Klauser wrote:
> Use the of_property_read_u32 helper function to retreive u32 values
> from the device tree. Also do not pass the len parameter to
> of_get_property if it isn't checked afterwards.
> 

Applied, thanks Tobias.

-- 
Dmitry

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

* [PATCH v2] Input: gpio_keys - Use of_property_read_u32
  2011-08-31  7:32 [PATCH] Input: gpio_keys - Use of_property_read_u32 Tobias Klauser
  2011-09-09 18:10 ` Dmitry Torokhov
@ 2011-09-19  9:09 ` Tobias Klauser
  2011-09-20  1:26   ` Stephen Rothwell
  1 sibling, 1 reply; 7+ messages in thread
From: Tobias Klauser @ 2011-09-19  9:09 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Stephen Rothwell, linux-input

Use the of_property_read_u32 helper function to retreive u32 values
from the device tree. Also do not pass the len parameter to
of_get_property if it isn't checked afterwards.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
v2: Fix build failure caused by a missing opening brace (reported by
    Stephen Rothwell)

 drivers/input/keyboard/gpio_keys.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 67df91a..e913294 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -462,7 +462,6 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 	int i;
 	struct gpio_keys_button *buttons;
 	const u32 *reg;
-	int len;
 
 	node = dev->of_node;
 	if (node == NULL)
@@ -470,7 +469,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 
 	memset(pdata, 0, sizeof *pdata);
 
-	pdata->rep = !!of_get_property(node, "autorepeat", &len);
+	pdata->rep = !!of_get_property(node, "autorepeat", NULL);
 
 	/* First count the subnodes */
 	pdata->nbuttons = 0;
@@ -498,22 +497,25 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 		buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
 		buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-		reg = of_get_property(pp, "linux,code", &len);
-		if (!reg) {
+		if (of_property_read_u32(pp, "linux,code", &reg)) {
 			dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
 			goto out_fail;
 		}
-		buttons[i].code = be32_to_cpup(reg);
+		buttons[i].code = reg;
 
-		buttons[i].desc = of_get_property(pp, "label", &len);
+		buttons[i].desc = of_get_property(pp, "label", NULL);
 
-		reg = of_get_property(pp, "linux,input-type", &len);
-		buttons[i].type = reg ? be32_to_cpup(reg) : EV_KEY;
+		if (of_property_read_u32(pp, "linux,input-type", &reg) == 0)
+			buttons[i].type = reg;
+		else
+			buttons[i].type = EV_KEY;
 
 		buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
 
-		reg = of_get_property(pp, "debounce-interval", &len);
-		buttons[i].debounce_interval = reg ? be32_to_cpup(reg) : 5;
+		if (of_property_read_u32(pp, "debounce-interval", &reg) == 0)
+			buttons[i].debounce_interval = reg;
+		else
+			buttons[i].debounce_interval = 5;
 
 		i++;
 	}
-- 
1.7.5.4


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

* Re: [PATCH v2] Input: gpio_keys - Use of_property_read_u32
  2011-09-19  9:09 ` [PATCH v2] " Tobias Klauser
@ 2011-09-20  1:26   ` Stephen Rothwell
  2011-09-20  6:25     ` Tobias Klauser
  2011-09-20  6:26     ` Dmitry Torokhov
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Rothwell @ 2011-09-20  1:26 UTC (permalink / raw)
  To: Tobias Klauser; +Cc: Dmitry Torokhov, linux-input

[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]

Hi Tobias,

On Mon, 19 Sep 2011 11:09:51 +0200 Tobias Klauser <tklauser@distanz.ch> wrote:
>
> Use the of_property_read_u32 helper function to retreive u32 values
> from the device tree. Also do not pass the len parameter to
> of_get_property if it isn't checked afterwards.
> 
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
> v2: Fix build failure caused by a missing opening brace (reported by
>     Stephen Rothwell)

Sure, but it will still generate all the warnings I reported as "reg" is
the wrong type now.

drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_get_devtree_pdata':
drivers/input/keyboard/gpio_keys.c:500:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
drivers/input/keyboard/gpio_keys.c:504:19: warning: assignment makes integer from pointer without a cast
drivers/input/keyboard/gpio_keys.c:508:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
drivers/input/keyboard/gpio_keys.c:509:20: warning: assignment makes integer from pointer without a cast
drivers/input/keyboard/gpio_keys.c:515:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
drivers/input/keyboard/gpio_keys.c:516:33: warning: assignment makes integer from pointer without a cast

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCH v2] Input: gpio_keys - Use of_property_read_u32
  2011-09-20  1:26   ` Stephen Rothwell
@ 2011-09-20  6:25     ` Tobias Klauser
  2011-09-20  6:26     ` Dmitry Torokhov
  1 sibling, 0 replies; 7+ messages in thread
From: Tobias Klauser @ 2011-09-20  6:25 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Dmitry Torokhov, linux-input

Hi Stephen

Sorry for the messup!

On 2011-09-20 at 03:26:27 +0200, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> On Mon, 19 Sep 2011 11:09:51 +0200 Tobias Klauser <tklauser@distanz.ch> wrote:
> >
> > Use the of_property_read_u32 helper function to retreive u32 values
> > from the device tree. Also do not pass the len parameter to
> > of_get_property if it isn't checked afterwards.
> > 
> > Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> > ---
> > v2: Fix build failure caused by a missing opening brace (reported by
> >     Stephen Rothwell)
> 
> Sure, but it will still generate all the warnings I reported as "reg" is
> the wrong type now.
> 
> drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_get_devtree_pdata':
> drivers/input/keyboard/gpio_keys.c:500:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> drivers/input/keyboard/gpio_keys.c:504:19: warning: assignment makes integer from pointer without a cast
> drivers/input/keyboard/gpio_keys.c:508:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> drivers/input/keyboard/gpio_keys.c:509:20: warning: assignment makes integer from pointer without a cast
> drivers/input/keyboard/gpio_keys.c:515:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> drivers/input/keyboard/gpio_keys.c:516:33: warning: assignment makes integer from pointer without a cast

Stupid me was compiling iwht the wrong .config (which hasn't CONFIG_OF
set) all the time, that's why I never noticed any of the
errors/warnings in the part I actually changed.

Sorry, I'll send another patch, hopefully the final one.

Thanks a lot for your help
Tobias

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

* Re: [PATCH v2] Input: gpio_keys - Use of_property_read_u32
  2011-09-20  1:26   ` Stephen Rothwell
  2011-09-20  6:25     ` Tobias Klauser
@ 2011-09-20  6:26     ` Dmitry Torokhov
  2011-09-20 12:54       ` Tobias Klauser
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Torokhov @ 2011-09-20  6:26 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Tobias Klauser, linux-input

On Tue, Sep 20, 2011 at 11:26:27AM +1000, Stephen Rothwell wrote:
> Hi Tobias,
> 
> On Mon, 19 Sep 2011 11:09:51 +0200 Tobias Klauser <tklauser@distanz.ch> wrote:
> >
> > Use the of_property_read_u32 helper function to retreive u32 values
> > from the device tree. Also do not pass the len parameter to
> > of_get_property if it isn't checked afterwards.
> > 
> > Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> > ---
> > v2: Fix build failure caused by a missing opening brace (reported by
> >     Stephen Rothwell)
> 
> Sure, but it will still generate all the warnings I reported as "reg" is
> the wrong type now.
> 
> drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_get_devtree_pdata':
> drivers/input/keyboard/gpio_keys.c:500:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> drivers/input/keyboard/gpio_keys.c:504:19: warning: assignment makes integer from pointer without a cast
> drivers/input/keyboard/gpio_keys.c:508:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> drivers/input/keyboard/gpio_keys.c:509:20: warning: assignment makes integer from pointer without a cast
> drivers/input/keyboard/gpio_keys.c:515:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> drivers/input/keyboard/gpio_keys.c:516:33: warning: assignment makes integer from pointer without a cast
> 

I think the following shoudl fix it, I am going to fold it into original
path.

Thanks.

-- 
Dmitry

Input: gpio-keys - fix compile issues

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/keyboard/gpio_keys.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index e913294..ed1ed46 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -461,7 +461,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 	struct device_node *node, *pp;
 	int i;
 	struct gpio_keys_button *buttons;
-	const u32 *reg;
+	u32 reg;
 
 	node = dev->of_node;
 	if (node == NULL)
@@ -497,7 +497,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
 		buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
 		buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-		if (of_property_read_u32(pp, "linux,code", &reg))
+		if (of_property_read_u32(pp, "linux,code", &reg)) {
 			dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
 			goto out_fail;
 		}

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

* Re: [PATCH v2] Input: gpio_keys - Use of_property_read_u32
  2011-09-20  6:26     ` Dmitry Torokhov
@ 2011-09-20 12:54       ` Tobias Klauser
  0 siblings, 0 replies; 7+ messages in thread
From: Tobias Klauser @ 2011-09-20 12:54 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Stephen Rothwell, linux-input

Hi Dmitry

On 2011-09-20 at 08:26:04 +0200, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Tue, Sep 20, 2011 at 11:26:27AM +1000, Stephen Rothwell wrote:
> > On Mon, 19 Sep 2011 11:09:51 +0200 Tobias Klauser <tklauser@distanz.ch> wrote:
> > >
> > > Use the of_property_read_u32 helper function to retreive u32 values
> > > from the device tree. Also do not pass the len parameter to
> > > of_get_property if it isn't checked afterwards.
> > > 
> > > Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> > > ---
> > > v2: Fix build failure caused by a missing opening brace (reported by
> > >     Stephen Rothwell)
> > 
> > Sure, but it will still generate all the warnings I reported as "reg" is
> > the wrong type now.
> > 
> > drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_get_devtree_pdata':
> > drivers/input/keyboard/gpio_keys.c:500:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> > include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> > drivers/input/keyboard/gpio_keys.c:504:19: warning: assignment makes integer from pointer without a cast
> > drivers/input/keyboard/gpio_keys.c:508:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> > include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> > drivers/input/keyboard/gpio_keys.c:509:20: warning: assignment makes integer from pointer without a cast
> > drivers/input/keyboard/gpio_keys.c:515:3: warning: passing argument 3 of 'of_property_read_u32' from incompatible pointer type
> > include/linux/of.h:268:19: note: expected 'u32 *' but argument is of type 'const u32 **'
> > drivers/input/keyboard/gpio_keys.c:516:33: warning: assignment makes integer from pointer without a cast
> > 
> 
> I think the following shoudl fix it, I am going to fold it into original
> path.

Thanks a lot for fixing this and sorry for the messup.

Thanks
Tobias

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

end of thread, other threads:[~2011-09-20 12:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-31  7:32 [PATCH] Input: gpio_keys - Use of_property_read_u32 Tobias Klauser
2011-09-09 18:10 ` Dmitry Torokhov
2011-09-19  9:09 ` [PATCH v2] " Tobias Klauser
2011-09-20  1:26   ` Stephen Rothwell
2011-09-20  6:25     ` Tobias Klauser
2011-09-20  6:26     ` Dmitry Torokhov
2011-09-20 12:54       ` Tobias Klauser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).