Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 1/3] gpiolib: make names array and its values const

2 views
Skip to first unread message

Uwe Kleine-König

unread,
Feb 8, 2010, 4:20:03 AM2/8/10
to
gpiolib doesn't need to modify the names and I assume most initializers
use sting constants that shouldn't be modified anyhow.

Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>
Cc: Kevin Wells <kevin...@nxp.com>
---
drivers/gpio/gpiolib.c | 2 +-
drivers/gpio/pca953x.c | 2 +-
include/asm-generic/gpio.h | 2 +-
include/linux/i2c/pca953x.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a25ad28..8543685 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -716,7 +716,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)
unsigned long flags;
struct gpio_desc *desc;
int status = -EINVAL;
- char *ioname = NULL;
+ const char *ioname = NULL;

/* can't export until sysfs is available ... */
if (!gpio_class.p) {
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 6a2fb3f..4faeca4 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -56,7 +56,7 @@ struct pca953x_chip {
struct i2c_client *client;
struct pca953x_platform_data *dyn_pdata;
struct gpio_chip gpio_chip;
- char **names;
+ const char *const *names;
};

static int pca953x_write_reg(struct pca953x_chip *chip, int reg, uint16_t val)
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 485eeb6..37af893 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -98,7 +98,7 @@ struct gpio_chip {
struct gpio_chip *chip);
int base;
u16 ngpio;
- char **names;
+ const char *const *names;
unsigned can_sleep:1;
unsigned exported:1;
};
diff --git a/include/linux/i2c/pca953x.h b/include/linux/i2c/pca953x.h
index 81736d6..4630fab 100644
--- a/include/linux/i2c/pca953x.h
+++ b/include/linux/i2c/pca953x.h
@@ -15,5 +15,5 @@ struct pca953x_platform_data {
int (*teardown)(struct i2c_client *client,
unsigned gpio, unsigned ngpio,
void *context);
- char **names;
+ const char *const *names;
};
--
1.6.6

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

Uwe Kleine-König

unread,
Feb 8, 2010, 4:20:03 AM2/8/10
to
Hello,

On Mon, Feb 08, 2010 at 10:09:40AM +0100, Uwe Kleine-K�nig wrote:
> Signed-off-by: Uwe Kleine-K�nig <u.klein...@pengutronix.de>
> ---
> include/asm-generic/gpio.h | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> index 37af893..abdb5d3 100644
> --- a/include/asm-generic/gpio.h
> +++ b/include/asm-generic/gpio.h
> @@ -60,7 +60,8 @@ struct module;
> * @names: if set, must be an array of strings to use as alternative
> * names for the GPIOs in this chip. Any entry in the array
> * may be NULL if there is no alias for the GPIO, however the
> - * array must be @ngpio entries long.
> + * array must be @ngpio entries long. A name can include a single printk
> + * format specifier for an unsigned int.
probably add: "It is substituted by the actual number of the gpio."

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K�nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

Uwe Kleine-König

unread,
Feb 8, 2010, 4:20:03 AM2/8/10
to
Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>

---
include/asm-generic/gpio.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 37af893..abdb5d3 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -60,7 +60,8 @@ struct module;
* @names: if set, must be an array of strings to use as alternative
* names for the GPIOs in this chip. Any entry in the array
* may be NULL if there is no alias for the GPIO, however the
- * array must be @ngpio entries long.
+ * array must be @ngpio entries long. A name can include a single printk
+ * format specifier for an unsigned int.

*
* A gpio_chip can help platforms abstract various sources of GPIOs so
* they can all be accessed through a common programing interface.
--
1.6.6

Uwe Kleine-König

unread,
Feb 8, 2010, 4:20:03 AM2/8/10
to
Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>
---
drivers/gpio/gpiolib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8543685..20988c8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -747,7 +747,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)
struct device *dev;

dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
- desc, ioname ? ioname : "gpio%d", gpio);
+ desc, ioname ? ioname : "gpio%u", gpio);
if (!IS_ERR(dev)) {
status = sysfs_create_group(&dev->kobj,
&gpio_attr_group);

Baruch Siach

unread,
Feb 8, 2010, 4:40:02 AM2/8/10
to
Hi Uwe,

On Mon, Feb 08, 2010 at 10:09:38AM +0100, Uwe Kleine-K�nig wrote:
> gpiolib doesn't need to modify the names and I assume most initializers
> use sting constants that shouldn't be modified anyhow.

s/sting/string/

>
> Signed-off-by: Uwe Kleine-K�nig <u.klein...@pengutronix.de>


> Cc: Kevin Wells <kevin...@nxp.com>
> ---

[snip]

baruch

--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

Uwe Kleine-König

unread,
Feb 8, 2010, 4:50:02 AM2/8/10
to
Hi Baruch,

On Mon, Feb 08, 2010 at 11:37:24AM +0200, Baruch Siach wrote:
> Hi Uwe,
>
> On Mon, Feb 08, 2010 at 10:09:38AM +0100, Uwe Kleine-K�nig wrote:
> > gpiolib doesn't need to modify the names and I assume most initializers
> > use sting constants that shouldn't be modified anyhow.
>
> s/sting/string/

Thanks, fixed in my tree.

BTW, you can get the updated series at

git://git.pengutronix.de/git/ukl/linux-2.6.git gpiolib/names

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K�nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

Uwe Kleine-König

unread,
Feb 24, 2010, 5:40:01 AM2/24/10
to
Hi David,

what do you think about these three patches? Should I resend?

Best regards
Uwe

The following changes since commit 6339204ecc2aa2067a99595522de0403f0854bb8:
Linus Torvalds (1):
Merge branch 'for-linus' of git://git.kernel.org/.../viro/vfs-2.6

are available in the git repository at:

git://git.pengutronix.de/git/ukl/linux-2.6.git gpiolib/names

Uwe Kleine-K�nig (3):
gpiolib: make names array and its values const
gpiolib: a gpio is unsigned, so use %u to print it
gpiolib: document that names can contain printk format specifiers

drivers/gpio/gpiolib.c | 4 ++--
drivers/gpio/pca953x.c | 2 +-
include/asm-generic/gpio.h | 6 ++++--
include/linux/i2c/pca953x.h | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)


--
Pengutronix e.K. | Uwe Kleine-K�nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

Uwe Kleine-König

unread,
Mar 22, 2010, 4:50:02 PM3/22/10
to
Hi Andrew,

On Mon, Feb 08, 2010 at 10:09:38AM +0100, Uwe Kleine-König wrote:
> gpiolib doesn't need to modify the names and I assume most initializers
> use sting constants that shouldn't be modified anyhow.
>
> Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>
> Cc: Kevin Wells <kevin...@nxp.com>
> ---
> drivers/gpio/gpiolib.c | 2 +-
> drivers/gpio/pca953x.c | 2 +-
> include/asm-generic/gpio.h | 2 +-
> include/linux/i2c/pca953x.h | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)

I haven't received feed back for these patches. Would you care to take
them? If yes, should I resend? Alternatively you can get them from

git://git.pengutronix.de/git/ukl/linux-2.6.git gpiolib/names

whatever is easiest for you ...

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |


Industrial Linux Solutions | http://www.pengutronix.de/ |

Uwe Kleine-König

unread,
Mar 23, 2010, 6:30:02 AM3/23/10
to
Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>
---
include/asm-generic/gpio.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index bc0c14d..fb1ecf8 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -60,7 +60,9 @@ struct module;


* @names: if set, must be an array of strings to use as alternative
* names for the GPIOs in this chip. Any entry in the array
* may be NULL if there is no alias for the GPIO, however the
- * array must be @ngpio entries long.
+ * array must be @ngpio entries long. A name can include a single printk

+ * format specifier for an unsigned int. It is substituted by the actual
+ * number of the gpio.


*
* A gpio_chip can help platforms abstract various sources of GPIOs so
* they can all be accessed through a common programing interface.
--

1.7.0

Uwe Kleine-König

unread,
Mar 23, 2010, 6:30:01 AM3/23/10
to
gpiolib doesn't need to modify the names and I assume most initializers
use string constants that shouldn't be modified anyhow.

Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>
Cc: Kevin Wells <kevin...@nxp.com>
---
drivers/gpio/gpiolib.c | 2 +-
drivers/gpio/pca953x.c | 2 +-
include/asm-generic/gpio.h | 2 +-
include/linux/i2c/pca953x.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6d1b866..03e82d5 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -720,7 +720,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)


unsigned long flags;
struct gpio_desc *desc;
int status = -EINVAL;
- char *ioname = NULL;
+ const char *ioname = NULL;

/* can't export until sysfs is available ... */
if (!gpio_class.p) {
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c

index ab5daab..60553d0 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -72,7 +72,7 @@ struct pca953x_chip {


struct i2c_client *client;
struct pca953x_platform_data *dyn_pdata;
struct gpio_chip gpio_chip;
- char **names;
+ const char *const *names;
};

static int pca953x_write_reg(struct pca953x_chip *chip, int reg, uint16_t val)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 979c6a5..bc0c14d 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h


@@ -98,7 +98,7 @@ struct gpio_chip {
struct gpio_chip *chip);
int base;
u16 ngpio;
- char **names;
+ const char *const *names;
unsigned can_sleep:1;
unsigned exported:1;
};
diff --git a/include/linux/i2c/pca953x.h b/include/linux/i2c/pca953x.h

index d5c5a60..139ba52 100644
--- a/include/linux/i2c/pca953x.h
+++ b/include/linux/i2c/pca953x.h
@@ -24,7 +24,7 @@ struct pca953x_platform_data {


int (*teardown)(struct i2c_client *client,
unsigned gpio, unsigned ngpio,
void *context);
- char **names;
+ const char *const *names;
};

#endif /* _LINUX_PCA953X_H */
--
1.7.0

Uwe Kleine-König

unread,
Mar 23, 2010, 6:30:01 AM3/23/10
to
Signed-off-by: Uwe Kleine-König <u.klein...@pengutronix.de>
---
drivers/gpio/gpiolib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 03e82d5..548b71e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -751,7 +751,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)


struct device *dev;

dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
- desc, ioname ? ioname : "gpio%d", gpio);
+ desc, ioname ? ioname : "gpio%u", gpio);
if (!IS_ERR(dev)) {
status = sysfs_create_group(&dev->kobj,
&gpio_attr_group);
--

1.7.0

0 new messages