* linux-next: manual merge of the pwm tree with the leds tree
@ 2014-05-22 9:24 Stephen Rothwell
2014-05-23 7:19 ` Thierry Reding
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Rothwell @ 2014-05-22 9:24 UTC (permalink / raw)
To: Thierry Reding
Cc: linux-next, linux-kernel, Alexandre Belloni, Russell King,
Bryan Wu
[-- Attachment #1: Type: text/plain, Size: 4368 bytes --]
Hi Thierry,
Today's linux-next merge of the pwm tree got a conflict in
drivers/leds/leds-pwm.c between commit 5f7b03dc2ab5 ("leds: leds-pwm:
provide a common function to setup a single led-pwm device") from the
leds tree and commit 81225bed3273 ("leds: leds-pwm: retrieve configured
PWM period") from the pwm tree.
I fixed it up (I think - see below) and can carry the fix as necessary
(no action is required).
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
diff --cc drivers/leds/leds-pwm.c
index f5cf1b0f2748,aa770ec1e892..000000000000
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@@ -96,75 -92,55 +96,75 @@@ static void led_pwm_cleanup(struct led_
}
}
-static int led_pwm_create_of(struct platform_device *pdev,
- struct led_pwm_priv *priv)
+static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
+ struct led_pwm *led, struct device_node *child)
{
- struct device_node *child;
+ struct led_pwm_data *led_data = &priv->leds[priv->num_leds];
int ret;
- for_each_child_of_node(pdev->dev.of_node, child) {
- struct led_pwm_data *led_dat = &priv->leds[priv->num_leds];
+ led_data->active_low = led->active_low;
- led_data->period = led->pwm_period_ns;
+ led_data->cdev.name = led->name;
+ led_data->cdev.default_trigger = led->default_trigger;
+ led_data->cdev.brightness_set = led_pwm_set;
+ led_data->cdev.brightness = LED_OFF;
+ led_data->cdev.max_brightness = led->max_brightness;
+ led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
- led_dat->cdev.name = of_get_property(child, "label",
- NULL) ? : child->name;
+ if (child)
+ led_data->pwm = devm_of_pwm_get(dev, child, NULL);
+ else
+ led_data->pwm = devm_pwm_get(dev, led->name);
+ if (IS_ERR(led_data->pwm)) {
+ ret = PTR_ERR(led_data->pwm);
+ dev_err(dev, "unable to request PWM for %s: %d\n",
+ led->name, ret);
+ return ret;
+ }
- if (child)
- led_data->period = pwm_get_period(led_data->pwm);
- led_dat->pwm = devm_of_pwm_get(&pdev->dev, child, NULL);
- if (IS_ERR(led_dat->pwm)) {
- dev_err(&pdev->dev, "unable to request PWM for %s\n",
- led_dat->cdev.name);
- ret = PTR_ERR(led_dat->pwm);
- goto err;
- }
- /* Get the period from PWM core when n*/
- led_dat->period = pwm_get_period(led_dat->pwm);
++ led_data->period = pwm_get_period(led_data->pwm);
++ if (!led_data->period && (led->pwm_period_ns > 0))
++ led_data->period = led->pwm_period_ns;
- led_dat->cdev.default_trigger = of_get_property(child,
- "linux,default-trigger", NULL);
- of_property_read_u32(child, "max-brightness",
- &led_dat->cdev.max_brightness);
+ led_data->can_sleep = pwm_can_sleep(led_data->pwm);
+ if (led_data->can_sleep)
+ INIT_WORK(&led_data->work, led_pwm_work);
+
+ ret = led_classdev_register(dev, &led_data->cdev);
+ if (ret == 0) {
+ priv->num_leds++;
+ } else {
+ dev_err(dev, "failed to register PWM led for %s: %d\n",
+ led->name, ret);
+ }
+
+ return ret;
+}
+
+static int led_pwm_create_of(struct device *dev, struct led_pwm_priv *priv)
+{
+ struct device_node *child;
+ struct led_pwm led;
+ int ret = 0;
+
+ memset(&led, 0, sizeof(led));
- led_dat->cdev.brightness_set = led_pwm_set;
- led_dat->cdev.brightness = LED_OFF;
- led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
+ for_each_child_of_node(dev->of_node, child) {
+ led.name = of_get_property(child, "label", NULL) ? :
+ child->name;
- led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
- if (led_dat->can_sleep)
- INIT_WORK(&led_dat->work, led_pwm_work);
+ led.default_trigger = of_get_property(child,
+ "linux,default-trigger", NULL);
+ led.active_low = of_property_read_bool(child, "active-low");
+ of_property_read_u32(child, "max-brightness",
+ &led.max_brightness);
- ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed to register for %s\n",
- led_dat->cdev.name);
+ ret = led_pwm_add(dev, priv, &led, child);
+ if (ret) {
of_node_put(child);
- goto err;
+ break;
}
- priv->num_leds++;
}
- return 0;
-err:
- led_pwm_cleanup(priv);
-
return ret;
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: linux-next: manual merge of the pwm tree with the leds tree
2014-05-22 9:24 linux-next: manual merge of the pwm tree with the leds tree Stephen Rothwell
@ 2014-05-23 7:19 ` Thierry Reding
2014-05-23 8:42 ` Alexandre Belloni
0 siblings, 1 reply; 3+ messages in thread
From: Thierry Reding @ 2014-05-23 7:19 UTC (permalink / raw)
To: Stephen Rothwell
Cc: linux-next, linux-kernel, Alexandre Belloni, Russell King,
Bryan Wu
[-- Attachment #1: Type: text/plain, Size: 5115 bytes --]
On Thu, May 22, 2014 at 07:24:23PM +1000, Stephen Rothwell wrote:
> Hi Thierry,
>
> Today's linux-next merge of the pwm tree got a conflict in
> drivers/leds/leds-pwm.c between commit 5f7b03dc2ab5 ("leds: leds-pwm:
> provide a common function to setup a single led-pwm device") from the
> leds tree and commit 81225bed3273 ("leds: leds-pwm: retrieve configured
> PWM period") from the pwm tree.
>
> I fixed it up (I think - see below) and can carry the fix as necessary
> (no action is required).
The resolution below looks good to me. Thanks!
Alexandre, Bryan, as far as I can tell there are no dependencies between
this patch and the rest of the series that Alexandre sent, so perhaps it
would be a better idea to take this particular patch via Bryan's leds
tree?
Then again the resolution looks like something that Linus can reasonably
handle, so maybe things are fine as-is.
Thierry
>
> --
> Cheers,
> Stephen Rothwell sfr@canb.auug.org.au
>
> diff --cc drivers/leds/leds-pwm.c
> index f5cf1b0f2748,aa770ec1e892..000000000000
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@@ -96,75 -92,55 +96,75 @@@ static void led_pwm_cleanup(struct led_
> }
> }
>
> -static int led_pwm_create_of(struct platform_device *pdev,
> - struct led_pwm_priv *priv)
> +static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
> + struct led_pwm *led, struct device_node *child)
> {
> - struct device_node *child;
> + struct led_pwm_data *led_data = &priv->leds[priv->num_leds];
> int ret;
>
> - for_each_child_of_node(pdev->dev.of_node, child) {
> - struct led_pwm_data *led_dat = &priv->leds[priv->num_leds];
> + led_data->active_low = led->active_low;
> - led_data->period = led->pwm_period_ns;
> + led_data->cdev.name = led->name;
> + led_data->cdev.default_trigger = led->default_trigger;
> + led_data->cdev.brightness_set = led_pwm_set;
> + led_data->cdev.brightness = LED_OFF;
> + led_data->cdev.max_brightness = led->max_brightness;
> + led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
>
> - led_dat->cdev.name = of_get_property(child, "label",
> - NULL) ? : child->name;
> + if (child)
> + led_data->pwm = devm_of_pwm_get(dev, child, NULL);
> + else
> + led_data->pwm = devm_pwm_get(dev, led->name);
> + if (IS_ERR(led_data->pwm)) {
> + ret = PTR_ERR(led_data->pwm);
> + dev_err(dev, "unable to request PWM for %s: %d\n",
> + led->name, ret);
> + return ret;
> + }
>
> - if (child)
> - led_data->period = pwm_get_period(led_data->pwm);
> - led_dat->pwm = devm_of_pwm_get(&pdev->dev, child, NULL);
> - if (IS_ERR(led_dat->pwm)) {
> - dev_err(&pdev->dev, "unable to request PWM for %s\n",
> - led_dat->cdev.name);
> - ret = PTR_ERR(led_dat->pwm);
> - goto err;
> - }
> - /* Get the period from PWM core when n*/
> - led_dat->period = pwm_get_period(led_dat->pwm);
> ++ led_data->period = pwm_get_period(led_data->pwm);
> ++ if (!led_data->period && (led->pwm_period_ns > 0))
> ++ led_data->period = led->pwm_period_ns;
>
> - led_dat->cdev.default_trigger = of_get_property(child,
> - "linux,default-trigger", NULL);
> - of_property_read_u32(child, "max-brightness",
> - &led_dat->cdev.max_brightness);
> + led_data->can_sleep = pwm_can_sleep(led_data->pwm);
> + if (led_data->can_sleep)
> + INIT_WORK(&led_data->work, led_pwm_work);
> +
> + ret = led_classdev_register(dev, &led_data->cdev);
> + if (ret == 0) {
> + priv->num_leds++;
> + } else {
> + dev_err(dev, "failed to register PWM led for %s: %d\n",
> + led->name, ret);
> + }
> +
> + return ret;
> +}
> +
> +static int led_pwm_create_of(struct device *dev, struct led_pwm_priv *priv)
> +{
> + struct device_node *child;
> + struct led_pwm led;
> + int ret = 0;
> +
> + memset(&led, 0, sizeof(led));
>
> - led_dat->cdev.brightness_set = led_pwm_set;
> - led_dat->cdev.brightness = LED_OFF;
> - led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> + for_each_child_of_node(dev->of_node, child) {
> + led.name = of_get_property(child, "label", NULL) ? :
> + child->name;
>
> - led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
> - if (led_dat->can_sleep)
> - INIT_WORK(&led_dat->work, led_pwm_work);
> + led.default_trigger = of_get_property(child,
> + "linux,default-trigger", NULL);
> + led.active_low = of_property_read_bool(child, "active-low");
> + of_property_read_u32(child, "max-brightness",
> + &led.max_brightness);
>
> - ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "failed to register for %s\n",
> - led_dat->cdev.name);
> + ret = led_pwm_add(dev, priv, &led, child);
> + if (ret) {
> of_node_put(child);
> - goto err;
> + break;
> }
> - priv->num_leds++;
> }
>
> - return 0;
> -err:
> - led_pwm_cleanup(priv);
> -
> return ret;
> }
>
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: linux-next: manual merge of the pwm tree with the leds tree
2014-05-23 7:19 ` Thierry Reding
@ 2014-05-23 8:42 ` Alexandre Belloni
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2014-05-23 8:42 UTC (permalink / raw)
To: Thierry Reding
Cc: Stephen Rothwell, linux-next, linux-kernel, Russell King,
Bryan Wu
On 23/05/2014 at 09:19:41 +0200, Thierry Reding wrote :
> On Thu, May 22, 2014 at 07:24:23PM +1000, Stephen Rothwell wrote:
> > Hi Thierry,
> >
> > Today's linux-next merge of the pwm tree got a conflict in
> > drivers/leds/leds-pwm.c between commit 5f7b03dc2ab5 ("leds: leds-pwm:
> > provide a common function to setup a single led-pwm device") from the
> > leds tree and commit 81225bed3273 ("leds: leds-pwm: retrieve configured
> > PWM period") from the pwm tree.
> >
> > I fixed it up (I think - see below) and can carry the fix as necessary
> > (no action is required).
>
> The resolution below looks good to me. Thanks!
>
> Alexandre, Bryan, as far as I can tell there are no dependencies between
> this patch and the rest of the series that Alexandre sent, so perhaps it
> would be a better idea to take this particular patch via Bryan's leds
> tree?
>
> Then again the resolution looks like something that Linus can reasonably
> handle, so maybe things are fine as-is.
>
I'm fine with either solution, tell me if you want me to rebase my
patch.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-23 8:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 9:24 linux-next: manual merge of the pwm tree with the leds tree Stephen Rothwell
2014-05-23 7:19 ` Thierry Reding
2014-05-23 8:42 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox