2016-03-08 12:15:14

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 0/5] gpio: of: Add error handling and support for multiple gpio in gpio-hog

This series enhance the error print by adding error number in print message,
handle the error if gpio_hogd() fails and returns error to caller, and
add the support of multiple GPIOs to be passed from property "gpios" under
gpio hogd node.

Laxman Dewangan (5):
gpio: of: Scan available child node for gpio-hog
gpio: gpiolib: Print error number if gpio hog failed
gpio: of: Return error if gpio hog configuration failed
gpio: of: Add support to have multiple gpios in gpio-hog
gpio: DT: Rephrase property "gpios" of hog node to support multiple
gpios

Documentation/devicetree/bindings/gpio/gpio.txt | 6 +-
drivers/gpio/gpiolib-of.c | 73 +++++++++++++++++++------
drivers/gpio/gpiolib.c | 9 +--
3 files changed, 63 insertions(+), 25 deletions(-)

--
2.1.4


2016-03-08 12:15:21

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 1/5] gpio: of: Scan available child node for gpio-hog

Look for child node which are available when iterating for
gpio hog node for request/set GPIO initial configuration
during OF gpio chip registration.

Signed-off-by: Laxman Dewangan <[email protected]>
---
drivers/gpio/gpiolib-of.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 42a4bb7..f2ba1a4 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -210,7 +210,7 @@ static void of_gpiochip_scan_gpios(struct gpio_chip *chip)
enum gpio_lookup_flags lflags;
enum gpiod_flags dflags;

- for_each_child_of_node(chip->of_node, np) {
+ for_each_available_child_of_node(chip->of_node, np) {
if (!of_property_read_bool(np, "gpio-hog"))
continue;

--
2.1.4

2016-03-08 12:15:29

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 2/5] gpio: gpiolib: Print error number if gpio hog failed

Print the error number of GPIO hog failed during
its configurations. This helps in identifying the
failure without instrumenting the code.

Signed-off-by: Laxman Dewangan <[email protected]>
---
drivers/gpio/gpiolib.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bc788b9..7575ebb 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2621,15 +2621,16 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,

local_desc = gpiochip_request_own_desc(chip, hwnum, name);
if (IS_ERR(local_desc)) {
- pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
- name, chip->label, hwnum);
+ status = PTR_ERR(local_desc);
+ pr_err("requesting hog GPIO %s, chip %s, offset %d failed %d\n",
+ name, chip->label, hwnum, status);
return PTR_ERR(local_desc);
}

status = gpiod_configure_flags(desc, name, dflags);
if (status < 0) {
- pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n",
- name, chip->label, hwnum);
+ pr_err("setup of hog GPIO %s chip %s, offset %d failed %d\n",
+ name, chip->label, hwnum, status);
gpiochip_free_own_desc(desc);
return status;
}
--
2.1.4

2016-03-08 12:15:37

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 3/5] gpio: of: Return error if gpio hog configuration failed

If GPIO hog configuration failed while adding OF based
gpiochip() then return the error instead of ignoring it.

This helps of properly handling the gpio driver dependency.

When adding the gpio hog nodes for NVIDIA's Tegra210 platforms,
the gpio_hogd() fails with EPROBE_DEFER because pinctrl is not
ready at this time and gpio_request() for Tegra GPIO driver
returns error. The error was not causing the Tegra GPIO driver
to fail as the error was getting ignored.

Signed-off-by: Laxman Dewangan <[email protected]>
Cc: Benoit Parrot <[email protected]>
Cc: Alexandre Courbot <[email protected]>
---
drivers/gpio/gpiolib-of.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index f2ba1a4..d81dbd8 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -201,14 +201,16 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
*
* This is only used by of_gpiochip_add to request/set GPIO initial
* configuration.
+ * It retures error if it fails otherwise 0 on success.
*/
-static void of_gpiochip_scan_gpios(struct gpio_chip *chip)
+static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
{
struct gpio_desc *desc = NULL;
struct device_node *np;
const char *name;
enum gpio_lookup_flags lflags;
enum gpiod_flags dflags;
+ int ret;

for_each_available_child_of_node(chip->of_node, np) {
if (!of_property_read_bool(np, "gpio-hog"))
@@ -218,9 +220,12 @@ static void of_gpiochip_scan_gpios(struct gpio_chip *chip)
if (IS_ERR(desc))
continue;

- if (gpiod_hog(desc, name, lflags, dflags))
- continue;
+ ret = gpiod_hog(desc, name, lflags, dflags);
+ if (ret < 0)
+ return ret;
}
+
+ return 0;
}

/**
@@ -442,9 +447,7 @@ int of_gpiochip_add(struct gpio_chip *chip)

of_node_get(chip->of_node);

- of_gpiochip_scan_gpios(chip);
-
- return 0;
+ return of_gpiochip_scan_gpios(chip);
}

void of_gpiochip_remove(struct gpio_chip *chip)
--
2.1.4

2016-03-08 12:15:47

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 5/5] gpio: DT: Rephrase property "gpios" of hog node to support multiple gpios

The property "gpios" of GPIO hog node support the multiple GPIO entries.
Rephrase the details of this property for this new support.

Signed-off-by: Laxman Dewangan <[email protected]>
---
Documentation/devicetree/bindings/gpio/gpio.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt
index 069cdf6..ea5d7df 100644
--- a/Documentation/devicetree/bindings/gpio/gpio.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio.txt
@@ -162,9 +162,9 @@ gpio-controller's driver probe function.
Each GPIO hog definition is represented as a child node of the GPIO controller.
Required properties:
- gpio-hog: A property specifying that this child node represent a GPIO hog.
-- gpios: Store the GPIO information (id, flags, ...). Shall contain the
- number of cells specified in its parent node (GPIO controller
- node).
+- gpios: Store the GPIO information (id, flags, ...). Multiple GPIOs are
+ possible to list here. Shall contain the number of cells
+ specified in its parent node (GPIO controller node) per GPIOs.
Only one of the following properties scanned in the order shown below.
This means that when multiple properties are present they will be searched
in the order presented below and the first match is taken as the intended
--
2.1.4

2016-03-08 12:16:13

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog

The child node for gpio hogs under gpio controller's node
provide the mechanism to automatic GPIO request and
configuration as part of the gpio-controller's driver
probe function.

Currently, property "gpio" takes one gpios for such
configuration. Add support to have multiple GPIOs in
this property so that multiple GPIOs of gpio-controller
can be configured by this mechanism with one child node.

Signed-off-by: Laxman Dewangan <[email protected]>
Cc: Benoit Parrot <[email protected]>
Cc: Alexandre Courbot <[email protected]>
---
drivers/gpio/gpiolib-of.c | 64 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index d81dbd8..0e4e8fd 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -118,6 +118,21 @@ int of_get_named_gpio_flags(struct device_node *np, const char *list_name,
}
EXPORT_SYMBOL(of_get_named_gpio_flags);

+static int of_gpio_get_gpio_cells_size(struct device_node *chip_np)
+{
+ u32 ncells;
+ int ret;
+
+ ret = of_property_read_u32(chip_np, "#gpio-cells", &ncells);
+ if (ret)
+ return ret;
+
+ if (ncells > MAX_PHANDLE_ARGS)
+ return -EINVAL;
+
+ return ncells;
+}
+
/**
* of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API
* @np: device node to get GPIO from
@@ -131,6 +146,7 @@ EXPORT_SYMBOL(of_get_named_gpio_flags);
*/
static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
const char **name,
+ int gpio_index,
enum gpio_lookup_flags *lflags,
enum gpiod_flags *dflags)
{
@@ -139,8 +155,8 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
struct gg_data gg_data = {
.flags = &xlate_flags,
};
- u32 tmp;
- int i, ret;
+ int ncells;
+ int i, start_index, ret;

chip_np = np->parent;
if (!chip_np)
@@ -150,17 +166,16 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
*lflags = 0;
*dflags = 0;

- ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp);
- if (ret)
- return ERR_PTR(ret);
+ ncells = of_gpio_get_gpio_cells_size(chip_np);
+ if (ncells < 0)
+ return ERR_PTR(ncells);

- if (tmp > MAX_PHANDLE_ARGS)
- return ERR_PTR(-EINVAL);
+ start_index = ncells * gpio_index;

- gg_data.gpiospec.args_count = tmp;
+ gg_data.gpiospec.args_count = ncells;
gg_data.gpiospec.np = chip_np;
- for (i = 0; i < tmp; i++) {
- ret = of_property_read_u32_index(np, "gpios", i,
+ for (i = 0; i < ncells; i++) {
+ ret = of_property_read_u32_index(np, "gpios", start_index + i,
&gg_data.gpiospec.args[i]);
if (ret)
return ERR_PTR(ret);
@@ -211,18 +226,37 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
enum gpio_lookup_flags lflags;
enum gpiod_flags dflags;
int ret;
+ int i, ncells, ngpios;
+
+ ncells = of_gpio_get_gpio_cells_size(chip->of_node);
+ if (ncells < 0)
+ return 0;

for_each_available_child_of_node(chip->of_node, np) {
if (!of_property_read_bool(np, "gpio-hog"))
continue;

- desc = of_parse_own_gpio(np, &name, &lflags, &dflags);
- if (IS_ERR(desc))
+ ngpios = of_property_count_u32_elems(np, "gpios");
+ if (ngpios < 0)
+ continue;
+
+ if (ngpios % ncells) {
+ dev_warn(chip->parent,
+ "GPIOs entries are not proper in gpios\n");
continue;
+ }
+
+ ngpios /= ncells;
+ for (i = 0; i < ngpios; i++) {
+ desc = of_parse_own_gpio(np, &name, i,
+ &lflags, &dflags);
+ if (IS_ERR(desc))
+ continue;

- ret = gpiod_hog(desc, name, lflags, dflags);
- if (ret < 0)
- return ret;
+ ret = gpiod_hog(desc, name, lflags, dflags);
+ if (ret < 0)
+ return ret;
+ }
}

return 0;
--
2.1.4

2016-03-08 12:29:07

by Vladimir Zapolskiy

[permalink] [raw]
Subject: Re: [PATCH 2/5] gpio: gpiolib: Print error number if gpio hog failed

On 08.03.2016 14:02, Laxman Dewangan wrote:
> Print the error number of GPIO hog failed during
> its configurations. This helps in identifying the
> failure without instrumenting the code.
>
> Signed-off-by: Laxman Dewangan <[email protected]>
> ---
> drivers/gpio/gpiolib.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index bc788b9..7575ebb 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2621,15 +2621,16 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
>
> local_desc = gpiochip_request_own_desc(chip, hwnum, name);
> if (IS_ERR(local_desc)) {
> - pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
> - name, chip->label, hwnum);
> + status = PTR_ERR(local_desc);
> + pr_err("requesting hog GPIO %s, chip %s, offset %d failed %d\n",
> + name, chip->label, hwnum, status);
> return PTR_ERR(local_desc);

You can do "return status;" now.

> }
>
> status = gpiod_configure_flags(desc, name, dflags);
> if (status < 0) {
> - pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n",
> - name, chip->label, hwnum);
> + pr_err("setup of hog GPIO %s chip %s, offset %d failed %d\n",
> + name, chip->label, hwnum, status);
> gpiochip_free_own_desc(desc);
> return status;
> }
>

--
With best wishes,
Vladimir

2016-03-08 14:19:23

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 1/5] gpio: of: Scan available child node for gpio-hog

On Tue, Mar 08, 2016 at 05:32:04PM +0530, Laxman Dewangan wrote:
> Look for child node which are available when iterating for
> gpio hog node for request/set GPIO initial configuration
> during OF gpio chip registration.
>
> Signed-off-by: Laxman Dewangan <[email protected]>
> ---
> drivers/gpio/gpiolib-of.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 42a4bb7..f2ba1a4 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -210,7 +210,7 @@ static void of_gpiochip_scan_gpios(struct gpio_chip *chip)
> enum gpio_lookup_flags lflags;
> enum gpiod_flags dflags;
>
> - for_each_child_of_node(chip->of_node, np) {
> + for_each_available_child_of_node(chip->of_node, np) {
> if (!of_property_read_bool(np, "gpio-hog"))
> continue;

Makes sense:

Reviewed-by: Thierry Reding <[email protected]>


Attachments:
(No filename) (927.00 B)
signature.asc (819.00 B)
Download all attachments

2016-03-08 14:22:39

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 2/5] gpio: gpiolib: Print error number if gpio hog failed

On Tue, Mar 08, 2016 at 05:32:05PM +0530, Laxman Dewangan wrote:
> Print the error number of GPIO hog failed during
> its configurations. This helps in identifying the
> failure without instrumenting the code.

Please use up all 72 characters per line at your disposal. Excessively
short lines are hard to read.

> Signed-off-by: Laxman Dewangan <[email protected]>
> ---
> drivers/gpio/gpiolib.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index bc788b9..7575ebb 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2621,15 +2621,16 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
>
> local_desc = gpiochip_request_own_desc(chip, hwnum, name);
> if (IS_ERR(local_desc)) {
> - pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
> - name, chip->label, hwnum);
> + status = PTR_ERR(local_desc);
> + pr_err("requesting hog GPIO %s, chip %s, offset %d failed %d\n",
> + name, chip->label, hwnum, status);

I find this type of format hard to read. I prefer a semi-colon to
separate the message from the failure reason (i.e. error code).

Besides that I don't understand why you're dropping the parentheses
around the "chip %s, offset %d", I found that easier on the eye.

Thierry


Attachments:
(No filename) (1.31 kB)
signature.asc (819.00 B)
Download all attachments

2016-03-08 14:23:36

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 3/5] gpio: of: Return error if gpio hog configuration failed

On Tue, Mar 08, 2016 at 05:32:06PM +0530, Laxman Dewangan wrote:
> If GPIO hog configuration failed while adding OF based
> gpiochip() then return the error instead of ignoring it.
>
> This helps of properly handling the gpio driver dependency.
>
> When adding the gpio hog nodes for NVIDIA's Tegra210 platforms,
> the gpio_hogd() fails with EPROBE_DEFER because pinctrl is not
> ready at this time and gpio_request() for Tegra GPIO driver
> returns error. The error was not causing the Tegra GPIO driver
> to fail as the error was getting ignored.
>
> Signed-off-by: Laxman Dewangan <[email protected]>
> Cc: Benoit Parrot <[email protected]>
> Cc: Alexandre Courbot <[email protected]>
> ---
> drivers/gpio/gpiolib-of.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)

Reviewed-by: Thierry Reding <[email protected]>


Attachments:
(No filename) (850.00 B)
signature.asc (819.00 B)
Download all attachments

2016-03-08 15:46:03

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 2/5] gpio: gpiolib: Print error number if gpio hog failed


On Tuesday 08 March 2016 07:52 PM, Thierry Reding wrote:
> On Tue, Mar 08, 2016 at 05:32:05PM +0530, Laxman Dewangan wrote:
>
>> Signed-off-by: Laxman Dewangan <[email protected]>
>> ---
>> drivers/gpio/gpiolib.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>> index bc788b9..7575ebb 100644
>> --- a/drivers/gpio/gpiolib.c
>> +++ b/drivers/gpio/gpiolib.c
>> @@ -2621,15 +2621,16 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
>>
>> local_desc = gpiochip_request_own_desc(chip, hwnum, name);
>> if (IS_ERR(local_desc)) {
>> - pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
>> - name, chip->label, hwnum);
>> + status = PTR_ERR(local_desc);
>> + pr_err("requesting hog GPIO %s, chip %s, offset %d failed %d\n",
>> + name, chip->label, hwnum, status);
> I find this type of format hard to read. I prefer a semi-colon to
> separate the message from the failure reason (i.e. error code).
>
> Besides that I don't understand why you're dropping the parentheses
> around the "chip %s, offset %d", I found that easier on the eye.
>
>


I did to accommodate the 3 extra character ( %d) for string format on
that line as it was already near to 80 column.
Just did not want to split in multiple lines.

2016-03-09 06:29:08

by Markus Pargmann

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog

Hi,

On Tue, Mar 08, 2016 at 05:32:07PM +0530, Laxman Dewangan wrote:
> The child node for gpio hogs under gpio controller's node
> provide the mechanism to automatic GPIO request and
> configuration as part of the gpio-controller's driver
> probe function.
>
> Currently, property "gpio" takes one gpios for such
> configuration. Add support to have multiple GPIOs in
> this property so that multiple GPIOs of gpio-controller
> can be configured by this mechanism with one child node.

So if I read this correctly you want to have multiple GPIOs with the
same line name? Why don't you use multiple child nodes with individual
line names?

Best Regards,

Markus

>
> Signed-off-by: Laxman Dewangan <[email protected]>
> Cc: Benoit Parrot <[email protected]>
> Cc: Alexandre Courbot <[email protected]>
> ---
> drivers/gpio/gpiolib-of.c | 64 ++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 49 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index d81dbd8..0e4e8fd 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -118,6 +118,21 @@ int of_get_named_gpio_flags(struct device_node *np, const char *list_name,
> }
> EXPORT_SYMBOL(of_get_named_gpio_flags);
>
> +static int of_gpio_get_gpio_cells_size(struct device_node *chip_np)
> +{
> + u32 ncells;
> + int ret;
> +
> + ret = of_property_read_u32(chip_np, "#gpio-cells", &ncells);
> + if (ret)
> + return ret;
> +
> + if (ncells > MAX_PHANDLE_ARGS)
> + return -EINVAL;
> +
> + return ncells;
> +}
> +
> /**
> * of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API
> * @np: device node to get GPIO from
> @@ -131,6 +146,7 @@ EXPORT_SYMBOL(of_get_named_gpio_flags);
> */
> static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
> const char **name,
> + int gpio_index,
> enum gpio_lookup_flags *lflags,
> enum gpiod_flags *dflags)
> {
> @@ -139,8 +155,8 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
> struct gg_data gg_data = {
> .flags = &xlate_flags,
> };
> - u32 tmp;
> - int i, ret;
> + int ncells;
> + int i, start_index, ret;
>
> chip_np = np->parent;
> if (!chip_np)
> @@ -150,17 +166,16 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
> *lflags = 0;
> *dflags = 0;
>
> - ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp);
> - if (ret)
> - return ERR_PTR(ret);
> + ncells = of_gpio_get_gpio_cells_size(chip_np);
> + if (ncells < 0)
> + return ERR_PTR(ncells);
>
> - if (tmp > MAX_PHANDLE_ARGS)
> - return ERR_PTR(-EINVAL);
> + start_index = ncells * gpio_index;
>
> - gg_data.gpiospec.args_count = tmp;
> + gg_data.gpiospec.args_count = ncells;
> gg_data.gpiospec.np = chip_np;
> - for (i = 0; i < tmp; i++) {
> - ret = of_property_read_u32_index(np, "gpios", i,
> + for (i = 0; i < ncells; i++) {
> + ret = of_property_read_u32_index(np, "gpios", start_index + i,
> &gg_data.gpiospec.args[i]);
> if (ret)
> return ERR_PTR(ret);
> @@ -211,18 +226,37 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
> enum gpio_lookup_flags lflags;
> enum gpiod_flags dflags;
> int ret;
> + int i, ncells, ngpios;
> +
> + ncells = of_gpio_get_gpio_cells_size(chip->of_node);
> + if (ncells < 0)
> + return 0;
>
> for_each_available_child_of_node(chip->of_node, np) {
> if (!of_property_read_bool(np, "gpio-hog"))
> continue;
>
> - desc = of_parse_own_gpio(np, &name, &lflags, &dflags);
> - if (IS_ERR(desc))
> + ngpios = of_property_count_u32_elems(np, "gpios");
> + if (ngpios < 0)
> + continue;
> +
> + if (ngpios % ncells) {
> + dev_warn(chip->parent,
> + "GPIOs entries are not proper in gpios\n");
> continue;
> + }
> +
> + ngpios /= ncells;
> + for (i = 0; i < ngpios; i++) {
> + desc = of_parse_own_gpio(np, &name, i,
> + &lflags, &dflags);
> + if (IS_ERR(desc))
> + continue;
>
> - ret = gpiod_hog(desc, name, lflags, dflags);
> - if (ret < 0)
> - return ret;
> + ret = gpiod_hog(desc, name, lflags, dflags);
> + if (ret < 0)
> + return ret;
> + }
> }
>
> return 0;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


Attachments:
(No filename) (4.61 kB)
signature.asc (819.00 B)
Download all attachments

2016-03-09 13:33:57

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog


On Wednesday 09 March 2016 11:58 AM, Markus Pargmann wrote:
> * PGP Signed by an unknown key
>
> Hi,
>
> On Tue, Mar 08, 2016 at 05:32:07PM +0530, Laxman Dewangan wrote:
>> The child node for gpio hogs under gpio controller's node
>> provide the mechanism to automatic GPIO request and
>> configuration as part of the gpio-controller's driver
>> probe function.
>>
>> Currently, property "gpio" takes one gpios for such
>> configuration. Add support to have multiple GPIOs in
>> this property so that multiple GPIOs of gpio-controller
>> can be configured by this mechanism with one child node.
> So if I read this correctly you want to have multiple GPIOs with the
> same line name? Why don't you use multiple child nodes with individual
> line names?
>
There is cases on which particular functional configuration needs sets
of GPIO to set. On this case, making sub node for each GPIOs creates
lots of sub-nodes and add complexity on readability, usability and
maintainability.
Example: for my board, I wanted to set GPIO H2 to input and H0 and H1 to
be output high.
Instead of three nodes, I can have two here:
gpio@0,6000d000 {
wlan_input {
gpio-hog;
gpios = <TEGRA_GPIO(H, 2) 0>;
input;
};

wlan_output {
gpio-hog;
gpios = <TEGRA_GPIO(H, 0) 0 TEGRA_GPIO(H, 1) 0>;
output-high;
};
};

So here I am grouping the multiple output GPIO together.

This looks much similar if we have many GPIOs for one type of
configurations.

Even it looks better if we have something:
gpio@0,6000d000 {
wlan_control {
gpio-hog;
gpios-input = <TEGRA_GPIO(H, 2) 0>;
gpios-output-high = <TEGRA_GPIO(H, 0) 0
TEGRA_GPIO(H, 1) 0>;
};
};

2016-03-09 17:07:35

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH 2/5] gpio: gpiolib: Print error number if gpio hog failed

On 03/08/2016 08:32 AM, Laxman Dewangan wrote:
>
> On Tuesday 08 March 2016 07:52 PM, Thierry Reding wrote:
>> On Tue, Mar 08, 2016 at 05:32:05PM +0530, Laxman Dewangan wrote:
>>
>>> Signed-off-by: Laxman Dewangan <[email protected]>
>>> ---
>>> drivers/gpio/gpiolib.c | 9 +++++----
>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>>> index bc788b9..7575ebb 100644
>>> --- a/drivers/gpio/gpiolib.c
>>> +++ b/drivers/gpio/gpiolib.c
>>> @@ -2621,15 +2621,16 @@ int gpiod_hog(struct gpio_desc *desc, const
>>> char *name,
>>> local_desc = gpiochip_request_own_desc(chip, hwnum, name);
>>> if (IS_ERR(local_desc)) {
>>> - pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
>>> - name, chip->label, hwnum);
>>> + status = PTR_ERR(local_desc);
>>> + pr_err("requesting hog GPIO %s, chip %s, offset %d failed
>>> %d\n",
>>> + name, chip->label, hwnum, status);
>> I find this type of format hard to read. I prefer a semi-colon to
>> separate the message from the failure reason (i.e. error code).
>>
>> Besides that I don't understand why you're dropping the parentheses
>> around the "chip %s, offset %d", I found that easier on the eye.
>
> I did to accommodate the 3 extra character ( %d) for string format on
> that line as it was already near to 80 column.
> Just did not want to split in multiple lines.

Note that strings shouldn't be split across lines since it makes it
harder to grep for them. This is one case where the 80-column limit
isn't strict, within reason.

2016-03-09 17:11:20

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH 3/5] gpio: of: Return error if gpio hog configuration failed

On 03/08/2016 05:02 AM, Laxman Dewangan wrote:
> If GPIO hog configuration failed while adding OF based
> gpiochip() then return the error instead of ignoring it.
>
> This helps of properly handling the gpio driver dependency.
>
> When adding the gpio hog nodes for NVIDIA's Tegra210 platforms,
> the gpio_hogd() fails with EPROBE_DEFER because pinctrl is not
> ready at this time and gpio_request() for Tegra GPIO driver
> returns error. The error was not causing the Tegra GPIO driver
> to fail as the error was getting ignored.

> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c

> @@ -218,9 +220,12 @@ static void of_gpiochip_scan_gpios(struct gpio_chip *chip)
> if (IS_ERR(desc))
> continue;
>
> - if (gpiod_hog(desc, name, lflags, dflags))
> - continue;
> + ret = gpiod_hog(desc, name, lflags, dflags);
> + if (ret < 0)
> + return ret;
> }
> +
> + return 0;
> }

If there are multiple child nodes (which the code above is looping
over), and the hog for entries 0, 1, 2 succeed and the hog for entry 3
fails, don't you need to go back and unhog for nodes 0..2 so that the
next time this function is called, those hogs won't already be in place
thus preventing them from being hogged the second time around? Or does
hogging not take ownership of the resource and thus prevent it from
being acquired again?

2016-03-09 17:17:38

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog

On 03/09/2016 06:20 AM, Laxman Dewangan wrote:
>
> On Wednesday 09 March 2016 11:58 AM, Markus Pargmann wrote:
>> * PGP Signed by an unknown key
>>
>> Hi,
>>
>> On Tue, Mar 08, 2016 at 05:32:07PM +0530, Laxman Dewangan wrote:
>>> The child node for gpio hogs under gpio controller's node
>>> provide the mechanism to automatic GPIO request and
>>> configuration as part of the gpio-controller's driver
>>> probe function.
>>>
>>> Currently, property "gpio" takes one gpios for such
>>> configuration. Add support to have multiple GPIOs in
>>> this property so that multiple GPIOs of gpio-controller
>>> can be configured by this mechanism with one child node.
>> So if I read this correctly you want to have multiple GPIOs with the
>> same line name? Why don't you use multiple child nodes with individual
>> line names?
>>
> There is cases on which particular functional configuration needs sets
> of GPIO to set. On this case, making sub node for each GPIOs creates
> lots of sub-nodes and add complexity on readability, usability and
> maintainability.
> Example: for my board, I wanted to set GPIO H2 to input and H0 and H1 to
> be output high.
> Instead of three nodes, I can have two here:
> gpio@0,6000d000 {
> wlan_input {
> gpio-hog;
> gpios = <TEGRA_GPIO(H, 2) 0>;
> input;
> };
>
> wlan_output {
> gpio-hog;
> gpios = <TEGRA_GPIO(H, 0) 0 TEGRA_GPIO(H, 1) 0>;
> output-high;
> };
> };
>
> So here I am grouping the multiple output GPIO together.
>
> This looks much similar if we have many GPIOs for one type of
> configurations.
>
> Even it looks better if we have something:
> gpio@0,6000d000 {
> wlan_control {
> gpio-hog;
> gpios-input = <TEGRA_GPIO(H, 2) 0>;
> gpios-output-high = <TEGRA_GPIO(H, 0) 0
> TEGRA_GPIO(H, 1) 0>;
> };
> };

The problem with that is the description used when acquiring the GPIO is
just "wlan_input", "wlan_output", or "wlan_control". There's nothing to
indicate what those individual pins do (perhaps one is a reset signal,
one is a regulator enable, etc.?) By requiring separate nodes for each
GPIO, then the node name can provide a meaningful semantic
name/description for each GPIO, which provides much more information.

If the approach in this patch is acceptable though, I think you want to
update the description of "gpios" (in the GPIO hog definition section)
in Documentation/devicetree/bindings/gpio/gpio.txt to mention that
multiple GPIO entries are legal. Right now it says that property much
contain exactly #gpio-cells, not a multiple of #gpio-cells.

2016-03-09 17:19:03

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH 5/5] gpio: DT: Rephrase property "gpios" of hog node to support multiple gpios

On 03/08/2016 05:02 AM, Laxman Dewangan wrote:
> The property "gpios" of GPIO hog node support the multiple GPIO entries.
> Rephrase the details of this property for this new support.

Oh, I see the document is updated here. I think either patch 4 and 5
should be swapped so the docs are updated first, or this should be
squashed into patch 4.

2016-03-10 07:11:19

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 2/5] gpio: gpiolib: Print error number if gpio hog failed


On Wednesday 09 March 2016 10:37 PM, Stephen Warren wrote:
> On 03/08/2016 08:32 AM, Laxman Dewangan wrote:
>>
>> On Tuesday 08 March 2016 07:52 PM, Thierry Reding wrote:
>>> On Tue, Mar 08, 2016 at 05:32:05PM +0530, Laxman Dewangan wrote:
>>>
>>>> Signed-off-by: Laxman Dewangan <[email protected]>
>>>> ---
>>>> drivers/gpio/gpiolib.c | 9 +++++----
>>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>>>> index bc788b9..7575ebb 100644
>>>> --- a/drivers/gpio/gpiolib.c
>>>> +++ b/drivers/gpio/gpiolib.c
>>>> @@ -2621,15 +2621,16 @@ int gpiod_hog(struct gpio_desc *desc, const
>>>> char *name,
>>>> local_desc = gpiochip_request_own_desc(chip, hwnum, name);
>>>> if (IS_ERR(local_desc)) {
>>>> - pr_err("requesting hog GPIO %s (chip %s, offset %d)
>>>> failed\n",
>>>> - name, chip->label, hwnum);
>>>> + status = PTR_ERR(local_desc);
>>>> + pr_err("requesting hog GPIO %s, chip %s, offset %d failed
>>>> %d\n",
>>>> + name, chip->label, hwnum, status);
>>> I find this type of format hard to read. I prefer a semi-colon to
>>> separate the message from the failure reason (i.e. error code).
>>>
>>> Besides that I don't understand why you're dropping the parentheses
>>> around the "chip %s, offset %d", I found that easier on the eye.
>>
>> I did to accommodate the 3 extra character ( %d) for string format on
>> that line as it was already near to 80 column.
>> Just did not want to split in multiple lines.
>
> Note that strings shouldn't be split across lines since it makes it
> harder to grep for them. This is one case where the 80-column limit
> isn't strict, within reason.

OK, so not change the existing string, just add new format.


2016-03-10 07:15:29

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 3/5] gpio: of: Return error if gpio hog configuration failed


On Wednesday 09 March 2016 10:41 PM, Stephen Warren wrote:
> On 03/08/2016 05:02 AM, Laxman Dewangan wrote:
>> If GPIO hog configuration failed while adding OF based
>> gpiochip() then return the error instead of ignoring it.
>>
>> This helps of properly handling the gpio driver dependency.
>>
>> When adding the gpio hog nodes for NVIDIA's Tegra210 platforms,
>> the gpio_hogd() fails with EPROBE_DEFER because pinctrl is not
>> ready at this time and gpio_request() for Tegra GPIO driver
>> returns error. The error was not causing the Tegra GPIO driver
>> to fail as the error was getting ignored.
>
>> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
>
>> @@ -218,9 +220,12 @@ static void of_gpiochip_scan_gpios(struct
>> gpio_chip *chip)
>> if (IS_ERR(desc))
>> continue;
>>
>> - if (gpiod_hog(desc, name, lflags, dflags))
>> - continue;
>> + ret = gpiod_hog(desc, name, lflags, dflags);
>> + if (ret < 0)
>> + return ret;
>> }
>> +
>> + return 0;
>> }
>
> If there are multiple child nodes (which the code above is looping
> over), and the hog for entries 0, 1, 2 succeed and the hog for entry 3
> fails, don't you need to go back and unhog for nodes 0..2 so that the
> next time this function is called, those hogs won't already be in
> place thus preventing them from being hogged the second time around?
> Or does hogging not take ownership of the resource and thus prevent it
> from being acquired again?

The gpiolib take care per the error handling:

status = of_gpiochip_add(chip);
if (status)
goto err_remove_chip;

:::
err_remove_chip:
acpi_gpiochip_remove(chip);
gpiochip_free_hogs(chip);
of_gpiochip_remove(chip);


2016-03-10 07:20:35

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog


On Wednesday 09 March 2016 10:47 PM, Stephen Warren wrote:
> On 03/09/2016 06:20 AM, Laxman Dewangan wrote:
>>
>> On Wednesday 09 March 2016 11:58 AM, Markus Pargmann wrote:
>>> * PGP Signed by an unknown key
>>>
>>> Hi,
>>>
>>> On Tue, Mar 08, 2016 at 05:32:07PM +0530, Laxman Dewangan wrote:
>>>> The child node for gpio hogs under gpio controller's node
>>>> provide the mechanism to automatic GPIO request and
>>>> configuration as part of the gpio-controller's driver
>>>> probe function.
>>>>
>>>> Currently, property "gpio" takes one gpios for such
>>>> configuration. Add support to have multiple GPIOs in
>>>> this property so that multiple GPIOs of gpio-controller
>>>> can be configured by this mechanism with one child node.
>>> So if I read this correctly you want to have multiple GPIOs with the
>>> same line name? Why don't you use multiple child nodes with individual
>>> line names?
>>>
>> There is cases on which particular functional configuration needs sets
>> of GPIO to set. On this case, making sub node for each GPIOs creates
>> lots of sub-nodes and add complexity on readability, usability and
>> maintainability.
>> Example: for my board, I wanted to set GPIO H2 to input and H0 and H1 to
>> be output high.
>> Instead of three nodes, I can have two here:
>> gpio@0,6000d000 {
>> wlan_input {
>> gpio-hog;
>> gpios = <TEGRA_GPIO(H, 2) 0>;
>> input;
>> };
>>
>> wlan_output {
>> gpio-hog;
>> gpios = <TEGRA_GPIO(H, 0) 0 TEGRA_GPIO(H, 1) 0>;
>> output-high;
>> };
>> };
> >
>> So here I am grouping the multiple output GPIO together.
>>
>> This looks much similar if we have many GPIOs for one type of
>> configurations.
>>
>> Even it looks better if we have something:
>> gpio@0,6000d000 {
>> wlan_control {
>> gpio-hog;
>> gpios-input = <TEGRA_GPIO(H, 2) 0>;
>> gpios-output-high = <TEGRA_GPIO(H, 0) 0
>> TEGRA_GPIO(H, 1) 0>;
>> };
>> };
>
> The problem with that is the description used when acquiring the GPIO
> is just "wlan_input", "wlan_output", or "wlan_control". There's
> nothing to indicate what those individual pins do (perhaps one is a
> reset signal, one is a regulator enable, etc.?) By requiring separate
> nodes for each GPIO, then the node name can provide a meaningful
> semantic name/description for each GPIO, which provides much more
> information.
>

On this case, we have already property "line-name" and passed the name
of the gpio via this property.
The property names is "line-name" which is good for one string. We can
support other property "line-names" with multiple string per GPIO index.

line-names = "wlan-reset", "wlan-enable";


> If the approach in this patch is acceptable though, I think you want
> to update the description of "gpios" (in the GPIO hog definition
> section) in Documentation/devicetree/bindings/gpio/gpio.txt to mention
> that multiple GPIO entries are legal. Right now it says that property
> much contain exactly #gpio-cells, not a multiple of #gpio-cells.

I have 5th patch for this and will rearrange series as you suggested on
5th patch.


2016-03-10 11:17:18

by Markus Pargmann

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog

On Thursday 10 March 2016 12:37:32 Laxman Dewangan wrote:
>
> On Wednesday 09 March 2016 10:47 PM, Stephen Warren wrote:
> > On 03/09/2016 06:20 AM, Laxman Dewangan wrote:
> >>
> >> On Wednesday 09 March 2016 11:58 AM, Markus Pargmann wrote:
> >>> * PGP Signed by an unknown key
> >>>
> >>> Hi,
> >>>
> >>> On Tue, Mar 08, 2016 at 05:32:07PM +0530, Laxman Dewangan wrote:
> >>>> The child node for gpio hogs under gpio controller's node
> >>>> provide the mechanism to automatic GPIO request and
> >>>> configuration as part of the gpio-controller's driver
> >>>> probe function.
> >>>>
> >>>> Currently, property "gpio" takes one gpios for such
> >>>> configuration. Add support to have multiple GPIOs in
> >>>> this property so that multiple GPIOs of gpio-controller
> >>>> can be configured by this mechanism with one child node.
> >>> So if I read this correctly you want to have multiple GPIOs with the
> >>> same line name? Why don't you use multiple child nodes with individual
> >>> line names?
> >>>
> >> There is cases on which particular functional configuration needs sets
> >> of GPIO to set. On this case, making sub node for each GPIOs creates
> >> lots of sub-nodes and add complexity on readability, usability and
> >> maintainability.
> >> Example: for my board, I wanted to set GPIO H2 to input and H0 and H1 to
> >> be output high.
> >> Instead of three nodes, I can have two here:
> >> gpio@0,6000d000 {
> >> wlan_input {
> >> gpio-hog;
> >> gpios = <TEGRA_GPIO(H, 2) 0>;
> >> input;
> >> };
> >>
> >> wlan_output {
> >> gpio-hog;
> >> gpios = <TEGRA_GPIO(H, 0) 0 TEGRA_GPIO(H, 1) 0>;
> >> output-high;
> >> };
> >> };
> > >
> >> So here I am grouping the multiple output GPIO together.
> >>
> >> This looks much similar if we have many GPIOs for one type of
> >> configurations.
> >>
> >> Even it looks better if we have something:
> >> gpio@0,6000d000 {
> >> wlan_control {
> >> gpio-hog;
> >> gpios-input = <TEGRA_GPIO(H, 2) 0>;
> >> gpios-output-high = <TEGRA_GPIO(H, 0) 0
> >> TEGRA_GPIO(H, 1) 0>;
> >> };
> >> };
> >
> > The problem with that is the description used when acquiring the GPIO
> > is just "wlan_input", "wlan_output", or "wlan_control". There's
> > nothing to indicate what those individual pins do (perhaps one is a
> > reset signal, one is a regulator enable, etc.?) By requiring separate
> > nodes for each GPIO, then the node name can provide a meaningful
> > semantic name/description for each GPIO, which provides much more
> > information.
> >
>
> On this case, we have already property "line-name" and passed the name
> of the gpio via this property.
> The property names is "line-name" which is good for one string. We can
> support other property "line-names" with multiple string per GPIO index.
>
> line-names = "wlan-reset", "wlan-enable";

There is currently a discussion about the future bindings for subnodes in GPIO
controller nodes. Please have a look at these two mail threads:

"Device tree binding documentation for gpio-switch"
"gpio: of: Add support to have multiple gpios in gpio-hog"

Best Regards,

Markus

>
>
> > If the approach in this patch is acceptable though, I think you want
> > to update the description of "gpios" (in the GPIO hog definition
> > section) in Documentation/devicetree/bindings/gpio/gpio.txt to mention
> > that multiple GPIO entries are legal. Right now it says that property
> > much contain exactly #gpio-cells, not a multiple of #gpio-cells.
>
> I have 5th patch for this and will rearrange series as you suggested on
> 5th patch.
>
>
>

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2016-03-10 12:07:30

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog


On Thursday 10 March 2016 04:46 PM, Markus Pargmann wrote:
> On Thursday 10 March 2016 12:37:32 Laxman Dewangan wrote:
>> On Wednesday 09 March 2016 10:47 PM, Stephen Warren wrote:
>>> On 03/09/2016 06:20 AM, Laxman Dewangan wrote:
>>> The problem with that is the description used when acquiring the GPIO
>>> is just "wlan_input", "wlan_output", or "wlan_control". There's
>>> nothing to indicate what those individual pins do (perhaps one is a
>>> reset signal, one is a regulator enable, etc.?) By requiring separate
>>> nodes for each GPIO, then the node name can provide a meaningful
>>> semantic name/description for each GPIO, which provides much more
>>> information.
>>>
>> On this case, we have already property "line-name" and passed the name
>> of the gpio via this property.
>> The property names is "line-name" which is good for one string. We can
>> support other property "line-names" with multiple string per GPIO index.
>>
>> line-names = "wlan-reset", "wlan-enable";
> There is currently a discussion about the future bindings for subnodes in GPIO
> controller nodes. Please have a look at these two mail threads:
>
> "Device tree binding documentation for gpio-switch"
> "gpio: of: Add support to have multiple gpios in gpio-hog"

Second one is this patch only. Is it by intention?

The binding details about the gpio-switch and names are given by
property "lable". I think property "label" is standard way of going
forward i.e. I post similar patch for gpio-keys device name from DT
after got review comment.

So here, we can have the gpio names under property "label" or "labels".


Or am I missing anything?

2016-03-17 15:47:07

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog

On Thu, Mar 10, 2016 at 05:23:55PM +0530, Laxman Dewangan wrote:
>
> On Thursday 10 March 2016 04:46 PM, Markus Pargmann wrote:
> >On Thursday 10 March 2016 12:37:32 Laxman Dewangan wrote:
> >>On Wednesday 09 March 2016 10:47 PM, Stephen Warren wrote:
> >>>On 03/09/2016 06:20 AM, Laxman Dewangan wrote:
> >>>The problem with that is the description used when acquiring the GPIO
> >>>is just "wlan_input", "wlan_output", or "wlan_control". There's
> >>>nothing to indicate what those individual pins do (perhaps one is a
> >>>reset signal, one is a regulator enable, etc.?) By requiring separate
> >>>nodes for each GPIO, then the node name can provide a meaningful
> >>>semantic name/description for each GPIO, which provides much more
> >>>information.

I agree.

> >>On this case, we have already property "line-name" and passed the name
> >>of the gpio via this property.
> >>The property names is "line-name" which is good for one string. We can
> >>support other property "line-names" with multiple string per GPIO index.
> >>
> >>line-names = "wlan-reset", "wlan-enable";

Then what happens when someone wants to selectively disable gpio hogs?

status = "okay", "disabled", "okay";

While I often push things to fewer nodes and more compact descriptions,
I don't think that is the right direction in this case.

> >There is currently a discussion about the future bindings for subnodes in GPIO
> >controller nodes. Please have a look at these two mail threads:
> >
> > "Device tree binding documentation for gpio-switch"
> > "gpio: of: Add support to have multiple gpios in gpio-hog"
>
> Second one is this patch only. Is it by intention?
>
> The binding details about the gpio-switch and names are given by property
> "lable". I think property "label" is standard way of going forward i.e. I
> post similar patch for gpio-keys device name from DT after got review
> comment.
>
> So here, we can have the gpio names under property "label" or "labels".

label is standard. labels you just made up.

> Or am I missing anything?

The point is the more one off changes I see that are all inter-related,
the less willing I am to accept any that don't consider all the cases.
The inter-relationship here is how do we describe gpio lines that don't
otherwise have a connection to another node and how to deal with them if
that changes.

Rob

2016-03-17 17:58:00

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH 4/5] gpio: of: Add support to have multiple gpios in gpio-hog


On Thursday 17 March 2016 09:16 PM, Rob Herring wrote:
> On Thu, Mar 10, 2016 at 05:23:55PM +0530, Laxman Dewangan wrote:
>>>> On this case, we have already property "line-name" and passed the name
>>>> of the gpio via this property.
>>>> The property names is "line-name" which is good for one string. We can
>>>> support other property "line-names" with multiple string per GPIO index.
>>>>
>>>> line-names = "wlan-reset", "wlan-enable";
> Then what happens when someone wants to selectively disable gpio hogs?
>
> status = "okay", "disabled", "okay";
>
> While I often push things to fewer nodes and more compact descriptions,
> I don't think that is the right direction in this case.

I dont think we need to support the individual gpio to be enable/disable
by status.
We need to support the status property at node level only. if individual
gpio need to be enabled/disabled by status then it need to break in
different hog nodes.

This is same as like we have in pincontrol where we can provide the list
of pin names for some configuration under same node.


>>> There is currently a discussion about the future bindings for subnodes in GPIO
>>> controller nodes. Please have a look at these two mail threads:
>>>
>>> "Device tree binding documentation for gpio-switch"
>>> "gpio: of: Add support to have multiple gpios in gpio-hog"
>> Second one is this patch only. Is it by intention?
>>
>> The binding details about the gpio-switch and names are given by property
>> "lable". I think property "label" is standard way of going forward i.e. I
>> post similar patch for gpio-keys device name from DT after got review
>> comment.
>>
>> So here, we can have the gpio names under property "label" or "labels".
> label is standard. labels you just made up.

Yaah, lables for plural only. Otherwise no issue with "label".

>
>> Or am I missing anything?
> The point is the more one off changes I see that are all inter-related,
> the less willing I am to accept any that don't consider all the cases.
> The inter-relationship here is how do we describe gpio lines that don't
> otherwise have a connection to another node and how to deal with them if
> that changes.