linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] gpio-charger: add devicetree support
@ 2014-09-21 20:05 Heiko Stuebner
  2014-09-21 20:05 ` [PATCH v2 1/3] dt-bindings: document gpio-charger bindings Heiko Stuebner
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Heiko Stuebner @ 2014-09-21 20:05 UTC (permalink / raw)
  To: sre, dbaryshkov, dwmw2
  Cc: linux-pm, linux-kernel, devicetree, robh+dt, mark.rutland,
	pawel.moll, ijc+devicetree, galak, dianders, heiko

This series adds devicetree support to the gpio-charger and fixes a small
issue with the return value of gpio_get_value.

changes since v1:
- adapt binding example to show how the charger fits into the
  power-supplies structure

Heiko Stuebner (3):
  dt-bindings: document gpio-charger bindings
  power: gpio-charger: add device tree support
  power: gpio-charger: do not use gpio value directly

 .../bindings/power_supply/gpio-charger.txt         | 27 +++++++++
 drivers/power/gpio-charger.c                       | 68 ++++++++++++++++++++--
 2 files changed, 91 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power_supply/gpio-charger.txt

-- 
1.9.0


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

* [PATCH v2 1/3] dt-bindings: document gpio-charger bindings
  2014-09-21 20:05 [PATCH v2 0/3] gpio-charger: add devicetree support Heiko Stuebner
@ 2014-09-21 20:05 ` Heiko Stuebner
  2014-09-22 16:51   ` Doug Anderson
  2014-09-21 20:05 ` [PATCH v2 2/3] power: gpio-charger: add device tree support Heiko Stuebner
  2014-09-21 20:05 ` [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly Heiko Stuebner
  2 siblings, 1 reply; 9+ messages in thread
From: Heiko Stuebner @ 2014-09-21 20:05 UTC (permalink / raw)
  To: sre, dbaryshkov, dwmw2
  Cc: linux-pm, linux-kernel, devicetree, robh+dt, mark.rutland,
	pawel.moll, ijc+devicetree, galak, dianders, heiko,
	Heiko Stuebner

From: Heiko Stuebner <heiko.stuebner@bq.com>

This documents the binding for the gpio-charger power-supply.

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
---
 .../bindings/power_supply/gpio-charger.txt         | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/gpio-charger.txt

diff --git a/Documentation/devicetree/bindings/power_supply/gpio-charger.txt b/Documentation/devicetree/bindings/power_supply/gpio-charger.txt
new file mode 100644
index 0000000..adbb5dc
--- /dev/null
+++ b/Documentation/devicetree/bindings/power_supply/gpio-charger.txt
@@ -0,0 +1,27 @@
+gpio-charger
+
+Required properties :
+ - compatible : "gpio-charger"
+ - gpios : GPIO indicating the charger presence.
+   See GPIO binding in bindings/gpio/gpio.txt .
+ - charger-type : power supply type, one of
+     unknown
+     battery
+     ups
+     mains
+     usb-sdp (USB standard downstream port)
+     usb-dcp (USB dedicated charging port)
+     usb-cdp (USB charging downstream port)
+     usb-aca (USB accessory charger adapter)
+
+Example:
+
+	usb_charger: charger {
+		compatible = "gpio-charger";
+		charger-type = "usb-sdp";
+		gpios = <&gpf0 2 0 0 0>;
+	}
+
+	battery {
+		power-supplies = <&usb_charger>;
+	};
-- 
1.9.0


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

* [PATCH v2 2/3] power: gpio-charger: add device tree support
  2014-09-21 20:05 [PATCH v2 0/3] gpio-charger: add devicetree support Heiko Stuebner
  2014-09-21 20:05 ` [PATCH v2 1/3] dt-bindings: document gpio-charger bindings Heiko Stuebner
@ 2014-09-21 20:05 ` Heiko Stuebner
  2014-09-22 16:48   ` Doug Anderson
  2014-09-21 20:05 ` [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly Heiko Stuebner
  2 siblings, 1 reply; 9+ messages in thread
From: Heiko Stuebner @ 2014-09-21 20:05 UTC (permalink / raw)
  To: sre, dbaryshkov, dwmw2
  Cc: linux-pm, linux-kernel, devicetree, robh+dt, mark.rutland,
	pawel.moll, ijc+devicetree, galak, dianders, heiko,
	Heiko Stuebner

From: Heiko Stuebner <heiko.stuebner@bq.com>

Add the ability to parse gpio-charger data from a devicetree node.

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
---
 drivers/power/gpio-charger.c | 66 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 3 deletions(-)

diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index a0024b2..5fe6879 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -22,6 +22,8 @@
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
 #include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #include <linux/power/gpio-charger.h>
 
@@ -69,17 +71,68 @@ static enum power_supply_property gpio_charger_properties[] = {
 	POWER_SUPPLY_PROP_ONLINE,
 };
 
+static
+struct gpio_charger_platform_data *gpio_charger_parse_dt(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	struct gpio_charger_platform_data *pdata;
+	const char *chargetype;
+	enum of_gpio_flags flags;
+	int ret;
+
+	if (!np)
+		return ERR_PTR(-ENOENT);
+
+	pdata = devm_kzalloc(dev, sizeof(struct gpio_charger_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	pdata->name = np->name;
+
+	pdata->gpio = of_get_gpio_flags(np, 0, &flags);
+	pdata->gpio_active_low = flags & OF_GPIO_ACTIVE_LOW;
+
+	pdata->type = POWER_SUPPLY_TYPE_UNKNOWN;
+	ret = of_property_read_string(np, "charger-type", &chargetype);
+	if (ret >= 0) {
+		if (!strncmp("unknown", chargetype, 7))
+			pdata->type = POWER_SUPPLY_TYPE_UNKNOWN;
+		else if (!strncmp("battery", chargetype, 7))
+			pdata->type = POWER_SUPPLY_TYPE_BATTERY;
+		else if (!strncmp("ups", chargetype, 3))
+			pdata->type = POWER_SUPPLY_TYPE_UPS;
+		else if (!strncmp("mains", chargetype, 5))
+			pdata->type = POWER_SUPPLY_TYPE_MAINS;
+		else if (!strncmp("usb-sdp", chargetype, 7))
+			pdata->type = POWER_SUPPLY_TYPE_USB;
+		else if (!strncmp("usb-dcp", chargetype, 7))
+			pdata->type = POWER_SUPPLY_TYPE_USB_DCP;
+		else if (!strncmp("usb-cdp", chargetype, 7))
+			pdata->type = POWER_SUPPLY_TYPE_USB_CDP;
+		else if (!strncmp("usb-aca", chargetype, 7))
+			pdata->type = POWER_SUPPLY_TYPE_USB_ACA;
+		else
+			dev_warn(dev, "unknown charger type %s\n", chargetype);
+	}
+
+	return pdata;
+}
+
 static int gpio_charger_probe(struct platform_device *pdev)
 {
-	const struct gpio_charger_platform_data *pdata = pdev->dev.platform_data;
+	struct gpio_charger_platform_data *pdata = pdev->dev.platform_data;
 	struct gpio_charger *gpio_charger;
 	struct power_supply *charger;
 	int ret;
 	int irq;
 
 	if (!pdata) {
-		dev_err(&pdev->dev, "No platform data\n");
-		return -EINVAL;
+		pdata = gpio_charger_parse_dt(&pdev->dev);
+		if (IS_ERR(pdata)) {
+			dev_err(&pdev->dev, "No platform data\n");
+			return -EINVAL;
+		}
 	}
 
 	if (!gpio_is_valid(pdata->gpio)) {
@@ -189,6 +242,12 @@ static int gpio_charger_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops,
 		gpio_charger_suspend, gpio_charger_resume);
 
+static const struct of_device_id gpio_charger_match[] = {
+	{ .compatible = "gpio-charger" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, gpio_charger_match);
+
 static struct platform_driver gpio_charger_driver = {
 	.probe = gpio_charger_probe,
 	.remove = gpio_charger_remove,
@@ -196,6 +255,7 @@ static struct platform_driver gpio_charger_driver = {
 		.name = "gpio-charger",
 		.owner = THIS_MODULE,
 		.pm = &gpio_charger_pm_ops,
+		.of_match_table = of_match_ptr(gpio_charger_match),
 	},
 };
 
-- 
1.9.0


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

* [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly
  2014-09-21 20:05 [PATCH v2 0/3] gpio-charger: add devicetree support Heiko Stuebner
  2014-09-21 20:05 ` [PATCH v2 1/3] dt-bindings: document gpio-charger bindings Heiko Stuebner
  2014-09-21 20:05 ` [PATCH v2 2/3] power: gpio-charger: add device tree support Heiko Stuebner
@ 2014-09-21 20:05 ` Heiko Stuebner
  2014-09-22 16:50   ` Doug Anderson
  2 siblings, 1 reply; 9+ messages in thread
From: Heiko Stuebner @ 2014-09-21 20:05 UTC (permalink / raw)
  To: sre, dbaryshkov, dwmw2
  Cc: linux-pm, linux-kernel, devicetree, robh+dt, mark.rutland,
	pawel.moll, ijc+devicetree, galak, dianders, heiko,
	Heiko Stuebner

From: Heiko Stuebner <heiko.stuebner@bq.com>

Some gpio implementations return interesting values for gpio_get_value when
the value is not 0 - as seen on a imx6sl board. Therefore do not use the
value returned from gpio_get_value directly but simply check for 0 or not 0.

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
---
 drivers/power/gpio-charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index 5fe6879..ce99a29 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -57,7 +57,7 @@ static int gpio_charger_get_property(struct power_supply *psy,
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_ONLINE:
-		val->intval = gpio_get_value_cansleep(pdata->gpio);
+		val->intval = gpio_get_value_cansleep(pdata->gpio) ? 1 : 0;
 		val->intval ^= pdata->gpio_active_low;
 		break;
 	default:
-- 
1.9.0


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

* Re: [PATCH v2 2/3] power: gpio-charger: add device tree support
  2014-09-21 20:05 ` [PATCH v2 2/3] power: gpio-charger: add device tree support Heiko Stuebner
@ 2014-09-22 16:48   ` Doug Anderson
  2014-09-23 12:03     ` Heiko Stübner
  0 siblings, 1 reply; 9+ messages in thread
From: Doug Anderson @ 2014-09-22 16:48 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: sre, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm,
	linux-kernel, devicetree, Rob Herring, Mark Rutland, Pawel Moll,
	Ian Campbell, Kumar Gala, Heiko Stuebner

Heiko

On Sun, Sep 21, 2014 at 1:05 PM, Heiko Stuebner <heiko@sntech.de> wrote:
> From: Heiko Stuebner <heiko.stuebner@bq.com>
>
> Add the ability to parse gpio-charger data from a devicetree node.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
> ---
>  drivers/power/gpio-charger.c | 66 ++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 63 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
> index a0024b2..5fe6879 100644
> --- a/drivers/power/gpio-charger.c
> +++ b/drivers/power/gpio-charger.c
> @@ -22,6 +22,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/power_supply.h>
>  #include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
>
>  #include <linux/power/gpio-charger.h>
>
> @@ -69,17 +71,68 @@ static enum power_supply_property gpio_charger_properties[] = {
>         POWER_SUPPLY_PROP_ONLINE,
>  };
>
> +static
> +struct gpio_charger_platform_data *gpio_charger_parse_dt(struct device *dev)
> +{
> +       struct device_node *np = dev->of_node;
> +       struct gpio_charger_platform_data *pdata;
> +       const char *chargetype;
> +       enum of_gpio_flags flags;
> +       int ret;
> +
> +       if (!np)
> +               return ERR_PTR(-ENOENT);
> +
> +       pdata = devm_kzalloc(dev, sizeof(struct gpio_charger_platform_data),

nit: sizeof(*pdata) is smaller / cleaner.

> +                            GFP_KERNEL);
> +       if (!pdata)
> +               return ERR_PTR(-ENOMEM);
> +
> +       pdata->name = np->name;
> +
> +       pdata->gpio = of_get_gpio_flags(np, 0, &flags);

It would be nice to check the gpio for errors here, including handling
the possibility of EPROBE_DEFER.


> +       pdata->gpio_active_low = flags & OF_GPIO_ACTIVE_LOW;
> +
> +       pdata->type = POWER_SUPPLY_TYPE_UNKNOWN;
> +       ret = of_property_read_string(np, "charger-type", &chargetype);
> +       if (ret >= 0) {
> +               if (!strncmp("unknown", chargetype, 7))
> +                       pdata->type = POWER_SUPPLY_TYPE_UNKNOWN;
> +               else if (!strncmp("battery", chargetype, 7))
> +                       pdata->type = POWER_SUPPLY_TYPE_BATTERY;
> +               else if (!strncmp("ups", chargetype, 3))
> +                       pdata->type = POWER_SUPPLY_TYPE_UPS;
> +               else if (!strncmp("mains", chargetype, 5))
> +                       pdata->type = POWER_SUPPLY_TYPE_MAINS;
> +               else if (!strncmp("usb-sdp", chargetype, 7))
> +                       pdata->type = POWER_SUPPLY_TYPE_USB;
> +               else if (!strncmp("usb-dcp", chargetype, 7))
> +                       pdata->type = POWER_SUPPLY_TYPE_USB_DCP;
> +               else if (!strncmp("usb-cdp", chargetype, 7))
> +                       pdata->type = POWER_SUPPLY_TYPE_USB_CDP;
> +               else if (!strncmp("usb-aca", chargetype, 7))
> +                       pdata->type = POWER_SUPPLY_TYPE_USB_ACA;
> +               else
> +                       dev_warn(dev, "unknown charger type %s\n", chargetype);
> +       }
> +
> +       return pdata;
> +}
> +
>  static int gpio_charger_probe(struct platform_device *pdev)
>  {
> -       const struct gpio_charger_platform_data *pdata = pdev->dev.platform_data;
> +       struct gpio_charger_platform_data *pdata = pdev->dev.platform_data;

Do you really need to remove const?  If I remember correctly the const
here is not saying that the variable "pdata" won't change but that the
data pointed to by pdata won't change.  I think that's still the case
(from the perspective of this function).


>         struct gpio_charger *gpio_charger;
>         struct power_supply *charger;
>         int ret;
>         int irq;
>
>         if (!pdata) {
> -               dev_err(&pdev->dev, "No platform data\n");
> -               return -EINVAL;
> +               pdata = gpio_charger_parse_dt(&pdev->dev);
> +               if (IS_ERR(pdata)) {
> +                       dev_err(&pdev->dev, "No platform data\n");
> +                       return -EINVAL;

Probably should pass back the error code since it might be
EPROBE_DEFER.  ...and <sigh> I guess you need the special case of
"don't print if it's EPROBE_DEFER".  I almost wish we had a helper
function for that.  ;)


> +               }
>         }
>
>         if (!gpio_is_valid(pdata->gpio)) {
> @@ -189,6 +242,12 @@ static int gpio_charger_resume(struct device *dev)
>  static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops,
>                 gpio_charger_suspend, gpio_charger_resume);
>
> +static const struct of_device_id gpio_charger_match[] = {
> +       { .compatible = "gpio-charger" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, gpio_charger_match);
> +
>  static struct platform_driver gpio_charger_driver = {
>         .probe = gpio_charger_probe,
>         .remove = gpio_charger_remove,
> @@ -196,6 +255,7 @@ static struct platform_driver gpio_charger_driver = {
>                 .name = "gpio-charger",
>                 .owner = THIS_MODULE,
>                 .pm = &gpio_charger_pm_ops,
> +               .of_match_table = of_match_ptr(gpio_charger_match),

Given that you don't have any #ifdefs with "CONFIG_OF", I think
gpio_charger_match will always exist.  It seems like you should remove
the of_match_ptr or add some #ifdefs.  I can't quite keep up with what
the currently suggested best practice is here, though.

-Doug

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

* Re: [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly
  2014-09-21 20:05 ` [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly Heiko Stuebner
@ 2014-09-22 16:50   ` Doug Anderson
  0 siblings, 0 replies; 9+ messages in thread
From: Doug Anderson @ 2014-09-22 16:50 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: sre, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm,
	linux-kernel, devicetree, Rob Herring, Mark Rutland, Pawel Moll,
	Ian Campbell, Kumar Gala, Heiko Stuebner

Heiko,

On Sun, Sep 21, 2014 at 1:05 PM, Heiko Stuebner <heiko@sntech.de> wrote:
> From: Heiko Stuebner <heiko.stuebner@bq.com>
>
> Some gpio implementations return interesting values for gpio_get_value when
> the value is not 0 - as seen on a imx6sl board. Therefore do not use the
> value returned from gpio_get_value directly but simply check for 0 or not 0.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
> ---
>  drivers/power/gpio-charger.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
> index 5fe6879..ce99a29 100644
> --- a/drivers/power/gpio-charger.c
> +++ b/drivers/power/gpio-charger.c
> @@ -57,7 +57,7 @@ static int gpio_charger_get_property(struct power_supply *psy,
>
>         switch (psp) {
>         case POWER_SUPPLY_PROP_ONLINE:
> -               val->intval = gpio_get_value_cansleep(pdata->gpio);
> +               val->intval = gpio_get_value_cansleep(pdata->gpio) ? 1 : 0;

There is a common practice about using "!!" for this.  AKA:
"val->intval = !!gpio_get_value_cansleep(pdata->gpio);".

>                 val->intval ^= pdata->gpio_active_low;

It seems like while you're at it you could also fix
"pdata->gpio_active_low" to have the "!!", just to be safe.

...if you don't fix this, perhaps you should fix your last patch to
add a "!!", like:

  pdata->gpio_active_low = !!(flags & OF_GPIO_ACTIVE_LOW);

...technically OF_GPIO_ACTIVE_LOW is 0x1 so it's not a bug, but...

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

* Re: [PATCH v2 1/3] dt-bindings: document gpio-charger bindings
  2014-09-21 20:05 ` [PATCH v2 1/3] dt-bindings: document gpio-charger bindings Heiko Stuebner
@ 2014-09-22 16:51   ` Doug Anderson
  0 siblings, 0 replies; 9+ messages in thread
From: Doug Anderson @ 2014-09-22 16:51 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: sre, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm,
	linux-kernel, devicetree, Rob Herring, Mark Rutland, Pawel Moll,
	Ian Campbell, Kumar Gala, Heiko Stuebner

Heiko,

On Sun, Sep 21, 2014 at 1:05 PM, Heiko Stuebner <heiko@sntech.de> wrote:
> From: Heiko Stuebner <heiko.stuebner@bq.com>
>
> This documents the binding for the gpio-charger power-supply.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
> ---
>  .../bindings/power_supply/gpio-charger.txt         | 27 ++++++++++++++++++++++
>  1 file changed, 27 insertions(+)

It is not an area I'm an expert on, but this seems pretty reasonable to me.

Reviewed-by: Doug Anderson <dianders@chromium.org>

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

* Re: [PATCH v2 2/3] power: gpio-charger: add device tree support
  2014-09-22 16:48   ` Doug Anderson
@ 2014-09-23 12:03     ` Heiko Stübner
  2014-09-23 15:59       ` Doug Anderson
  0 siblings, 1 reply; 9+ messages in thread
From: Heiko Stübner @ 2014-09-23 12:03 UTC (permalink / raw)
  To: Doug Anderson
  Cc: sre, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm,
	linux-kernel, devicetree, Rob Herring, Mark Rutland, Pawel Moll,
	Ian Campbell, Kumar Gala

Am Montag, 22. September 2014, 09:48:33 schrieb Doug Anderson:
> > @@ -196,6 +255,7 @@ static struct platform_driver gpio_charger_driver = {
> > 
> >                 .name = "gpio-charger",
> >                 .owner = THIS_MODULE,
> >                 .pm = &gpio_charger_pm_ops,
> > 
> > +               .of_match_table = of_match_ptr(gpio_charger_match),
> 
> Given that you don't have any #ifdefs with "CONFIG_OF", I think
> gpio_charger_match will always exist.  It seems like you should remove
> the of_match_ptr or add some #ifdefs.  I can't quite keep up with what
> the currently suggested best practice is here, though.

I've kept the of_match_ptr in v3. The dt parsing functions (of_read_foo,...) 
define stubs for the !CONFIG_OF case which we use here in this case and 
of_match_ptr is also defined differently for both OF and !OF, so it feels like 
it should be there ;-)


Heiko

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

* Re: [PATCH v2 2/3] power: gpio-charger: add device tree support
  2014-09-23 12:03     ` Heiko Stübner
@ 2014-09-23 15:59       ` Doug Anderson
  0 siblings, 0 replies; 9+ messages in thread
From: Doug Anderson @ 2014-09-23 15:59 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: sre, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm,
	linux-kernel, devicetree, Rob Herring, Mark Rutland, Pawel Moll,
	Ian Campbell, Kumar Gala

Heiko,

On Tue, Sep 23, 2014 at 5:03 AM, Heiko Stübner <heiko@sntech.de> wrote:
> Am Montag, 22. September 2014, 09:48:33 schrieb Doug Anderson:
>> > @@ -196,6 +255,7 @@ static struct platform_driver gpio_charger_driver = {
>> >
>> >                 .name = "gpio-charger",
>> >                 .owner = THIS_MODULE,
>> >                 .pm = &gpio_charger_pm_ops,
>> >
>> > +               .of_match_table = of_match_ptr(gpio_charger_match),
>>
>> Given that you don't have any #ifdefs with "CONFIG_OF", I think
>> gpio_charger_match will always exist.  It seems like you should remove
>> the of_match_ptr or add some #ifdefs.  I can't quite keep up with what
>> the currently suggested best practice is here, though.
>
> I've kept the of_match_ptr in v3. The dt parsing functions (of_read_foo,...)
> define stubs for the !CONFIG_OF case which we use here in this case and
> of_match_ptr is also defined differently for both OF and !OF, so it feels like
> it should be there ;-)

...I was thinking you'd get a compile-time warning about
gpio_charger_match not being used.  ...but I can't seem to trigger it
with my compiler settings.  In any case, I'm fairly certain that in
the !CONFIG_OF case (plus non-module case) that "gpio_charger_match"
will be defined but not used in your code.

I was under the impression that of_match_ptr was defined differently
for OF and !OF so that you could use it in the case where the
structure itself (gpio_charger_match) had #ifdefs around it...

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

end of thread, other threads:[~2014-09-23 15:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-21 20:05 [PATCH v2 0/3] gpio-charger: add devicetree support Heiko Stuebner
2014-09-21 20:05 ` [PATCH v2 1/3] dt-bindings: document gpio-charger bindings Heiko Stuebner
2014-09-22 16:51   ` Doug Anderson
2014-09-21 20:05 ` [PATCH v2 2/3] power: gpio-charger: add device tree support Heiko Stuebner
2014-09-22 16:48   ` Doug Anderson
2014-09-23 12:03     ` Heiko Stübner
2014-09-23 15:59       ` Doug Anderson
2014-09-21 20:05 ` [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly Heiko Stuebner
2014-09-22 16:50   ` Doug Anderson

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).