public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-leds@vger.kernel.org, linux-media@vger.kernel.org,
	kyungmin.park@samsung.com, pavel@ucw.cz, cooloney@gmail.com,
	rpurdie@rpsys.net, s.nawrocki@samsung.com,
	Andrzej Hajda <a.hajda@samsung.com>,
	Lee Jones <lee.jones@linaro.org>,
	Chanwoo Choi <cw00.choi@samsung.com>
Subject: Re: [PATCH v5 03/10] leds: Add support for max77693 mfd flash cell
Date: Wed, 15 Apr 2015 16:07:49 +0200	[thread overview]
Message-ID: <552E70B5.1060406@samsung.com> (raw)
In-Reply-To: <20150415093007.GG27451@valkosipuli.retiisi.org.uk>

Hi Sakari,

Thanks for the review.

On 04/15/2015 11:30 AM, Sakari Ailus wrote:
> Hi Jacek,
>
> On Wed, Apr 15, 2015 at 08:48:33AM +0200, Jacek Anaszewski wrote:
> ...
>> +static int max77693_led_parse_dt(struct max77693_led_device *led,
>> +				struct max77693_led_config_data *cfg)
>> +{
>> +	struct device *dev = &led->pdev->dev;
>> +	struct max77693_sub_led *sub_leds = led->sub_leds;
>> +	struct device_node *node = dev->of_node, *child_node;
>> +	struct property *prop;
>> +	u32 led_sources[2];
>> +	int i, ret, fled_id;
>> +
>> +	of_property_read_u32(node, "maxim,boost-mode", &cfg->boost_mode);
>> +	of_property_read_u32(node, "maxim,boost-mvout", &cfg->boost_vout);
>> +	of_property_read_u32(node, "maxim,mvsys-min", &cfg->low_vsys);
>> +
>> +	for_each_available_child_of_node(node, child_node) {
>> +		prop = of_find_property(child_node, "led-sources", NULL);
>> +		if (prop) {
>> +			const __be32 *srcs = NULL;
>> +
>> +			for (i = 0; i < ARRAY_SIZE(led_sources); ++i) {
>> +				srcs = of_prop_next_u32(prop, srcs,
>> +							&led_sources[i]);
>> +				if (!srcs)
>> +					break;
>> +			}
>> +		} else {
>> +			dev_err(dev,
>> +				"led-sources DT property missing\n");
>> +			return -EINVAL;
>
> If you exit the loop in the middle, I think you'll need to do
> of_node_put(child_node) first.

Not all drivers seem to stick to this, but I checked and this is
indeed required. Not intuitive though.

>> +		}
>> +
>> +		if (i == 2) {
>> +			fled_id = FLED1;
>> +			led->fled_mask = FLED1_IOUT | FLED2_IOUT;
>> +		} else if (led_sources[0] == FLED1) {
>> +			fled_id = FLED1;
>> +			led->fled_mask |= FLED1_IOUT;
>> +		} else if (led_sources[0] == FLED2) {
>> +			fled_id = FLED2;
>> +			led->fled_mask |= FLED2_IOUT;
>> +		} else {
>> +			dev_err(dev,
>> +				"Wrong led-sources DT property value.\n");
>> +			return -EINVAL;
>
> Same here.
>
>> +		}
>> +
>> +		sub_leds[fled_id].fled_id = fled_id;
>> +
>> +		cfg->label[fled_id] =
>> +			of_get_property(child_node, "label", NULL) ? :
>> +						child_node->name;
>
> I think you should copy the string here, or keep a reference to child_node.

Many led drivers does the same. I am wondering whether this is a bug.

> of_property_read_string() might be useful.
>
>> +
>> +		ret = of_property_read_u32(child_node, "led-max-microamp",
>> +					&cfg->iout_torch_max[fled_id]);
>> +		if (ret < 0) {
>> +			cfg->iout_torch_max[fled_id] = TORCH_IOUT_MIN;
>> +			dev_warn(dev, "led-max-microamp DT property missing\n");
>> +		}
>> +
>> +		ret = of_property_read_u32(child_node, "flash-max-microamp",
>> +					&cfg->iout_flash_max[fled_id]);
>> +		if (ret < 0) {
>> +			cfg->iout_flash_max[fled_id] = FLASH_IOUT_MIN;
>> +			dev_warn(dev,
>> +				 "flash-max-microamp DT property missing\n");
>> +		}
>> +
>> +		ret = of_property_read_u32(child_node, "flash-max-timeout-us",
>> +					&cfg->flash_timeout_max[fled_id]);
>> +		if (ret < 0) {
>> +			cfg->flash_timeout_max[fled_id] = FLASH_TIMEOUT_MIN;
>> +			dev_warn(dev,
>> +				 "flash-max-timeout-us DT property missing\n");
>> +		}
>> +
>> +		if (++cfg->num_leds == 2 ||
>> +		    (max77693_fled_used(led, FLED1) &&
>> +		     max77693_fled_used(led, FLED2)))
>
> of_node_put(child_node);
>
>> +			break;
>> +	}
>> +
>> +	if (cfg->num_leds == 0) {
>> +		dev_err(dev, "No DT child node found for connected LED(s).\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	return 0;
>
> With these matters addressed,
>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>


-- 
Best Regards,
Jacek Anaszewski

  reply	other threads:[~2015-04-15 14:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15  6:48 [PATCH v5 00/10] LED / flash API integration Jacek Anaszewski
2015-04-15  6:48 ` [PATCH v5 01/10] leds: unify the location of led-trigger API Jacek Anaszewski
2015-04-15  8:32   ` Sakari Ailus
2015-04-15  6:48 ` [PATCH v5 02/10] DT: Add documentation for the mfd Maxim max77693 Jacek Anaszewski
2015-04-15  8:33   ` Sakari Ailus
2015-04-29 12:34   ` Lee Jones
2015-04-29 12:59     ` Jacek Anaszewski
2015-04-29 13:16       ` Lee Jones
2015-04-15  6:48 ` [PATCH v5 03/10] leds: Add support for max77693 mfd flash cell Jacek Anaszewski
2015-04-15  9:30   ` Sakari Ailus
2015-04-15 14:07     ` Jacek Anaszewski [this message]
2015-04-15  6:48 ` [PATCH v5 04/10] DT: Add documentation for the Skyworks AAT1290 Jacek Anaszewski
2015-04-19 12:05   ` Sakari Ailus
2015-04-15  6:48 ` [PATCH v5 05/10] leds: Add driver for AAT1290 flash LED controller Jacek Anaszewski
2015-04-15  6:48 ` [PATCH v5 06/10] media: Add registration helpers for V4L2 flash sub-devices Jacek Anaszewski
2015-04-23  7:40   ` Sakari Ailus
2015-04-23 15:10     ` Jacek Anaszewski
2015-04-23 21:52       ` Sakari Ailus
2015-04-24 10:29         ` Jacek Anaszewski
2015-04-24 11:56           ` Sakari Ailus
2015-04-15  6:48 ` [PATCH v5 07/10] Documentation: leds: Add description of v4l2-flash sub-device Jacek Anaszewski
2015-04-15  6:48 ` [PATCH v5 08/10] leds: max77693: add support for V4L2 Flash sub-device Jacek Anaszewski
2015-04-15  6:48 ` [PATCH v5 09/10] DT: aat1290: Document handling external strobe sources Jacek Anaszewski
2015-04-15  6:48 ` [PATCH v5 10/10] leds: aat1290: add support for V4L2 Flash sub-device Jacek Anaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=552E70B5.1060406@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=a.hajda@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rpurdie@rpsys.net \
    --cc=s.nawrocki@samsung.com \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox