Re: [PATCH v9 18/24] as3645a: Switch to fwnode property API

2017-09-11 Thread Jacek Anaszewski
Hi Sakari,

On 09/09/2017 11:36 PM, Sakari Ailus wrote:
> Hi Jacek,
> 
> On Sat, Sep 09, 2017 at 09:06:41PM +0200, Jacek Anaszewski wrote:
>> Hi Sakari,
>>
>> I've come across this patch only by a chance. I believe that merging
>> leds-as3645a.c patches via media tree is not going to be a persistent
>> pattern. At least we haven't agreed on that, and in any case I should
>> have a possibility to give my ack for this patch.
> 
> Correct. The reason the previous patches went through linux-media was
> because these patches dependend on other patches only in linux-media at the
> time. This is no longer the case (the three as3645a patches I'd like to get
> in as fixes are another matter but let's discuss that separately).
> 
>>
>> Would you mind also adding linux-leds list on cc when touching areas
>> related to LED/flash devices?
> 
> I added this patch to this version of the set and missed cc'ing it to
> linux-leds. I think I'll send it there separately once the 17th patch (ACPI
> support) has been reviewed. The two are loosely related to the rest of the
> patches in the set but there's no hard dependency.

Right, they are loosely related, but cross-posting anything having "LED"
in its contents to linux-leds list would be understandable if not
desirable :-) Just to keep LED people in sync.

-- 
Best regards,
Jacek Anaszewski


Re: [PATCH v9 18/24] as3645a: Switch to fwnode property API

2017-09-09 Thread Sakari Ailus
Hi Jacek,

On Sat, Sep 09, 2017 at 09:06:41PM +0200, Jacek Anaszewski wrote:
> Hi Sakari,
> 
> I've come across this patch only by a chance. I believe that merging
> leds-as3645a.c patches via media tree is not going to be a persistent
> pattern. At least we haven't agreed on that, and in any case I should
> have a possibility to give my ack for this patch.

Correct. The reason the previous patches went through linux-media was
because these patches dependend on other patches only in linux-media at the
time. This is no longer the case (the three as3645a patches I'd like to get
in as fixes are another matter but let's discuss that separately).

> 
> Would you mind also adding linux-leds list on cc when touching areas
> related to LED/flash devices?

I added this patch to this version of the set and missed cc'ing it to
linux-leds. I think I'll send it there separately once the 17th patch (ACPI
support) has been reviewed. The two are loosely related to the rest of the
patches in the set but there's no hard dependency.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH v9 18/24] as3645a: Switch to fwnode property API

2017-09-09 Thread Jacek Anaszewski
Hi Sakari,

I've come across this patch only by a chance. I believe that merging
leds-as3645a.c patches via media tree is not going to be a persistent
pattern. At least we haven't agreed on that, and in any case I should
have a possibility to give my ack for this patch.

Would you mind also adding linux-leds list on cc when touching areas
related to LED/flash devices?

Thanks in advance.

Best regards,
Jacek Anaszewski

On 09/08/2017 03:18 PM, Sakari Ailus wrote:
> Switch the as3645a from OF to the fwnode property API. Also add ACPI
> support.
> 
> Signed-off-by: Sakari Ailus 
> ---
>  drivers/leds/leds-as3645a.c | 81 
> +
>  1 file changed, 46 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
> index 605e0c64e974..2e73c3f818f1 100644
> --- a/drivers/leds/leds-as3645a.c
> +++ b/drivers/leds/leds-as3645a.c
> @@ -25,7 +25,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  
>  #include 
> @@ -148,8 +148,8 @@ struct as3645a {
>   struct v4l2_flash *vf;
>   struct v4l2_flash *vfind;
>  
> - struct device_node *flash_node;
> - struct device_node *indicator_node;
> + struct fwnode_handle *flash_node;
> + struct fwnode_handle *indicator_node;
>  
>   struct as3645a_config cfg;
>  
> @@ -492,30 +492,33 @@ static int as3645a_detect(struct as3645a *flash)
>  
>  static int as3645a_parse_node(struct as3645a *flash,
> struct as3645a_names *names,
> -   struct device_node *node)
> +   struct fwnode_handle *fwnode)
>  {
>   struct as3645a_config *cfg = &flash->cfg;
> - struct device_node *child;
> + struct fwnode_handle *child;
>   const char *name;
> + const char *str;
>   int rval;
>  
> - for_each_child_of_node(node, child) {
> + fwnode_for_each_child_node(fwnode, child) {
>   u32 id = 0;
>  
> - of_property_read_u32(child, "reg", &id);
> + fwnode_property_read_u32(
> + child, is_of_node(child) ? "reg" : "led", &id);
>  
>   switch (id) {
>   case AS_LED_FLASH:
> - flash->flash_node = of_node_get(child);
> + flash->flash_node = child;
>   break;
>   case AS_LED_INDICATOR:
> - flash->indicator_node = of_node_get(child);
> + flash->indicator_node = child;
>   break;
>   default:
>   dev_warn(&flash->client->dev,
>"unknown LED %u encountered, ignoring\n", id);
>   break;
>   }
> + fwnode_handle_get(child);
>   }
>  
>   if (!flash->flash_node) {
> @@ -523,14 +526,18 @@ static int as3645a_parse_node(struct as3645a *flash,
>   return -ENODEV;
>   }
>  
> - rval = of_property_read_string(flash->flash_node, "label", &name);
> - if (!rval)
> + rval = fwnode_property_read_string(flash->flash_node, "label", &name);
> + if (!rval) {
>   strlcpy(names->flash, name, sizeof(names->flash));
> - else
> + } else if (is_of_node(fwnode)) {
>   snprintf(names->flash, sizeof(names->flash),
> -  "%s:flash", node->name);
> +  "%s:flash", to_of_node(fwnode)->name);
> + } else {
> + dev_err(&flash->client->dev, "flash node has no label!\n");
> + return -EINVAL;
> + }
>  
> - rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",
> + rval = fwnode_property_read_u32(flash->flash_node, "flash-timeout-us",
>   &cfg->flash_timeout_us);
>   if (rval < 0) {
>   dev_err(&flash->client->dev,
> @@ -538,7 +545,7 @@ static int as3645a_parse_node(struct as3645a *flash,
>   goto out_err;
>   }
>  
> - rval = of_property_read_u32(flash->flash_node, "flash-max-microamp",
> + rval = fwnode_property_read_u32(flash->flash_node, "flash-max-microamp",
>   &cfg->flash_max_ua);
>   if (rval < 0) {
>   dev_err(&flash->client->dev,
> @@ -546,7 +553,7 @@ static int as3645a_parse_node(struct as3645a *flash,
>   goto out_err;
>   }
>  
> - rval = of_property_read_u32(flash->flash_node, "led-max-microamp",
> + rval = fwnode_property_read_u32(flash->flash_node, "led-max-microamp",
>   &cfg->assist_max_ua);
>   if (rval < 0) {
>   dev_err(&flash->client->dev,
> @@ -554,10 +561,10 @@ static int as3645a_parse_node(struct as3645a *flash,
>   goto out_err;
>   }
>  
> - of_property_read_u32(flash->flash_node, "voltage-reference",
> + fwnode_property_read_u32(flash->flash_node, "voltage-reference",
> 

Re: [PATCH v9 18/24] as3645a: Switch to fwnode property API

2017-09-09 Thread Pavel Machek
On Fri 2017-09-08 16:18:16, Sakari Ailus wrote:
> Switch the as3645a from OF to the fwnode property API. Also add ACPI
> support.
> 
> Signed-off-by: Sakari Ailus 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH v9 18/24] as3645a: Switch to fwnode property API

2017-09-08 Thread Sakari Ailus
Switch the as3645a from OF to the fwnode property API. Also add ACPI
support.

Signed-off-by: Sakari Ailus 
---
 drivers/leds/leds-as3645a.c | 81 +
 1 file changed, 46 insertions(+), 35 deletions(-)

diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index 605e0c64e974..2e73c3f818f1 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -148,8 +148,8 @@ struct as3645a {
struct v4l2_flash *vf;
struct v4l2_flash *vfind;
 
-   struct device_node *flash_node;
-   struct device_node *indicator_node;
+   struct fwnode_handle *flash_node;
+   struct fwnode_handle *indicator_node;
 
struct as3645a_config cfg;
 
@@ -492,30 +492,33 @@ static int as3645a_detect(struct as3645a *flash)
 
 static int as3645a_parse_node(struct as3645a *flash,
  struct as3645a_names *names,
- struct device_node *node)
+ struct fwnode_handle *fwnode)
 {
struct as3645a_config *cfg = &flash->cfg;
-   struct device_node *child;
+   struct fwnode_handle *child;
const char *name;
+   const char *str;
int rval;
 
-   for_each_child_of_node(node, child) {
+   fwnode_for_each_child_node(fwnode, child) {
u32 id = 0;
 
-   of_property_read_u32(child, "reg", &id);
+   fwnode_property_read_u32(
+   child, is_of_node(child) ? "reg" : "led", &id);
 
switch (id) {
case AS_LED_FLASH:
-   flash->flash_node = of_node_get(child);
+   flash->flash_node = child;
break;
case AS_LED_INDICATOR:
-   flash->indicator_node = of_node_get(child);
+   flash->indicator_node = child;
break;
default:
dev_warn(&flash->client->dev,
 "unknown LED %u encountered, ignoring\n", id);
break;
}
+   fwnode_handle_get(child);
}
 
if (!flash->flash_node) {
@@ -523,14 +526,18 @@ static int as3645a_parse_node(struct as3645a *flash,
return -ENODEV;
}
 
-   rval = of_property_read_string(flash->flash_node, "label", &name);
-   if (!rval)
+   rval = fwnode_property_read_string(flash->flash_node, "label", &name);
+   if (!rval) {
strlcpy(names->flash, name, sizeof(names->flash));
-   else
+   } else if (is_of_node(fwnode)) {
snprintf(names->flash, sizeof(names->flash),
-"%s:flash", node->name);
+"%s:flash", to_of_node(fwnode)->name);
+   } else {
+   dev_err(&flash->client->dev, "flash node has no label!\n");
+   return -EINVAL;
+   }
 
-   rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",
+   rval = fwnode_property_read_u32(flash->flash_node, "flash-timeout-us",
&cfg->flash_timeout_us);
if (rval < 0) {
dev_err(&flash->client->dev,
@@ -538,7 +545,7 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   rval = of_property_read_u32(flash->flash_node, "flash-max-microamp",
+   rval = fwnode_property_read_u32(flash->flash_node, "flash-max-microamp",
&cfg->flash_max_ua);
if (rval < 0) {
dev_err(&flash->client->dev,
@@ -546,7 +553,7 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   rval = of_property_read_u32(flash->flash_node, "led-max-microamp",
+   rval = fwnode_property_read_u32(flash->flash_node, "led-max-microamp",
&cfg->assist_max_ua);
if (rval < 0) {
dev_err(&flash->client->dev,
@@ -554,10 +561,10 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   of_property_read_u32(flash->flash_node, "voltage-reference",
+   fwnode_property_read_u32(flash->flash_node, "voltage-reference",
 &cfg->voltage_reference);
 
-   of_property_read_u32(flash->flash_node, "ams,input-max-microamp",
+   fwnode_property_read_u32(flash->flash_node, "ams,input-max-microamp",
 &cfg->peak);
cfg->peak = AS_PEAK_mA_TO_REG(cfg->peak);
 
@@ -567,14 +574,18 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   rval = of_property_read_string(flash->indicator_node, "label", &name);
-   if (!rval)
+   rval = fwnode_property_read_string(flash->indicator_nod