All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH] v4l: mt9v032: Add OF support
Date: Mon, 09 Mar 2015 12:57:18 +0100	[thread overview]
Message-ID: <54FD8A9E.6040303@samsung.com> (raw)
In-Reply-To: <20150309105744.GD11954@valkosipuli.retiisi.org.uk>

Hi Sakari,

On 09/03/15 11:57, Sakari Ailus wrote:
>>> +static struct mt9v032_platform_data *
>>> +mt9v032_get_pdata(struct i2c_client *client)
>>> +{
>>> +	struct mt9v032_platform_data *pdata;
>>> +	struct v4l2_of_endpoint endpoint;
>>> +	struct device_node *np;
>>> +	struct property *prop;
>>> +
>>> +	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
>>> +		return client->dev.platform_data;
>>> +
>>> +	np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
>>> +	if (!np)
>>> +		return NULL;
>>> +
>>> +	if (v4l2_of_parse_endpoint(np, &endpoint) < 0)
>>> +		goto done;
>>> +
>>> +	pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
>>> +	if (!pdata)
>>> +		goto done;
>>> +
>>> +	prop = of_find_property(np, "link-freqs", NULL);
>>
>> I suspect you meant "link-frequencies" here ?
> 
> Yes. I wonder if it'd make sense to add this to struct v4l2_of_endpoint. I
> can write a patch for that.

I don't have strong preference, sooner or later we will need to
add it there, so code duplication can be avoided. I guess it makes
sense to add such code already with a first user of it.

>>> +	if (prop) {
>>> +		size_t size = prop->length / 8;
>>> +		u64 *link_freqs;
>>> +
>>> +		link_freqs = devm_kzalloc(&client->dev,
>>> +					  size * sizeof(*link_freqs),
>>> +					  GFP_KERNEL);
>>> +		if (!link_freqs)
>>> +			goto done;
>>> +
>>> +		if (of_property_read_u64_array(np, "link-frequencies",
>>> +					       link_freqs, size) < 0)
>>> +			goto done;
>>> +
>>> +		pdata->link_freqs = link_freqs;
>>> +		pdata->link_def_freq = link_freqs[0];
>>> +	}
> 
> If you're interested in just a single value, you can use
> of_property_read_u64().
> 
>>> +	pdata->clk_pol = !!(endpoint.bus.parallel.flags &
>>> +			    V4L2_MBUS_PCLK_SAMPLE_RISING);
>>> +
>>> +done:
>>> +	of_node_put(np);
>>> +	return pdata;
>>> +}

-- 
Regards,
Sylwester

  reply	other threads:[~2015-03-09 11:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-08 13:45 [PATCH] v4l: mt9v032: Add OF support Laurent Pinchart
2015-03-09  9:45 ` Carlos Sanmartín Bustos
     [not found]   ` <CAPW4HR1WJPWg64GwitxCPK2jop0CntS1UtsOu_0VjCz0BEke6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-09 11:19     ` Laurent Pinchart
2015-03-09 11:19       ` Laurent Pinchart
2015-03-09 16:03       ` Carlos Sanmartín Bustos
2015-03-09 16:03         ` Carlos Sanmartín Bustos
2015-03-09 10:35 ` Sylwester Nawrocki
2015-03-09 10:57   ` Sakari Ailus
2015-03-09 11:57     ` Sylwester Nawrocki [this message]
     [not found]   ` <54FD7788.2020709-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-03-09 11:29     ` Laurent Pinchart
2015-03-09 11:29       ` Laurent Pinchart
2015-03-09 12:22       ` Sylwester Nawrocki
     [not found]         ` <54FD9074.8050600-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-03-12 23:41           ` Laurent Pinchart
2015-03-12 23:41             ` Laurent Pinchart

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=54FD8A9E.6040303@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.