All of lore.kernel.org
 help / color / mirror / Atom feed
From: srinivas.kandagatla@linaro.org (Srinivas Kandagatla)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/5] phy: miphy28lp: Provide support for the MiPHY28lp Generic PHY
Date: Thu, 14 Aug 2014 13:15:34 +0100	[thread overview]
Message-ID: <53ECA866.2080306@linaro.org> (raw)
In-Reply-To: <1407944075-8093-4-git-send-email-gabriel.fernandez@linaro.org>

Hi Gabi,

I did not review the full patchset but this function caught my attention..

> +};
> +
> +static int miphy28lp_get_ressource_byname(struct device_node *child,
> +					  char *name, struct resource *res)
> +{

s/miphy28lp_get_ressource_byname/miphy28lp_get_resource_byname

> +	int index, ret = 0, count = 0;
> +	int reg_tuple_size;
> +	const __be32 *p;
> +
> +	reg_tuple_size = (of_n_addr_cells(child) +
> +			of_n_size_cells(child)) * sizeof(u32);
> +
> +	p = of_get_property(child, "reg", &count);
> +	if (count % reg_tuple_size != 0)
> +		ret = -EINVAL;
> +
> +	count /= reg_tuple_size;
> +
> +	for (index = 0; index < count; index++) {
> +		const char *rname = NULL;
> +
> +		ret = of_property_read_string_index(child, "reg-names",
> +						    index, &rname);
> +		if (!strcmp(name, rname))
> +			return of_address_to_resource(child, index, res);
> +	}
> +
> +	return 1;
This function looks bit complicated, can't we just use:

	index = of_property_match_string(np, "reg-names", rname);
	if (index < 0)
		return -ENODEV;

	return of_address_to_resource(child, index, res);



--srini

WARNING: multiple messages have this Message-ID (diff)
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Gabriel FERNANDEZ <gabriel.fernandez@st.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Srinivas Kandagatla <srinivas.kandagatla@gmail.com>,
	Maxime Coquelin <maxime.coquelin@st.com>,
	Patrice Chotard <patrice.chotard@st.com>,
	Russell King <linux@arm.linux.org.uk>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Grant Likely <grant.likely@linaro.org>
Cc: devicetree@vger.kernel.org,
	alexandre torgue <alexandre.torgue@st.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Gabriel Fernandez <gabriel.fernandez@linaro.org>,
	kernel@stlinux.com
Subject: Re: [PATCH 3/5] phy: miphy28lp: Provide support for the MiPHY28lp Generic PHY
Date: Thu, 14 Aug 2014 13:15:34 +0100	[thread overview]
Message-ID: <53ECA866.2080306@linaro.org> (raw)
In-Reply-To: <1407944075-8093-4-git-send-email-gabriel.fernandez@linaro.org>

Hi Gabi,

I did not review the full patchset but this function caught my attention..

> +};
> +
> +static int miphy28lp_get_ressource_byname(struct device_node *child,
> +					  char *name, struct resource *res)
> +{

s/miphy28lp_get_ressource_byname/miphy28lp_get_resource_byname

> +	int index, ret = 0, count = 0;
> +	int reg_tuple_size;
> +	const __be32 *p;
> +
> +	reg_tuple_size = (of_n_addr_cells(child) +
> +			of_n_size_cells(child)) * sizeof(u32);
> +
> +	p = of_get_property(child, "reg", &count);
> +	if (count % reg_tuple_size != 0)
> +		ret = -EINVAL;
> +
> +	count /= reg_tuple_size;
> +
> +	for (index = 0; index < count; index++) {
> +		const char *rname = NULL;
> +
> +		ret = of_property_read_string_index(child, "reg-names",
> +						    index, &rname);
> +		if (!strcmp(name, rname))
> +			return of_address_to_resource(child, index, res);
> +	}
> +
> +	return 1;
This function looks bit complicated, can't we just use:

	index = of_property_match_string(np, "reg-names", rname);
	if (index < 0)
		return -ENODEV;

	return of_address_to_resource(child, index, res);



--srini

  reply	other threads:[~2014-08-14 12:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 15:34 [PATCH 0/5] phy: miphy28lp: Introduce support for MiPHY28lp Gabriel FERNANDEZ
2014-08-13 15:34 ` Gabriel FERNANDEZ
2014-08-13 15:34 ` Gabriel FERNANDEZ
2014-08-13 15:34 ` [PATCH 1/5] phy: miphy28lp: Add Device Tree bindings for the MiPHY28lp Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-20 14:56   ` Kishon Vijay Abraham I
2014-08-20 14:56     ` Kishon Vijay Abraham I
2014-08-20 14:56     ` Kishon Vijay Abraham I
2014-08-21  7:12     ` Gabriel Fernandez
2014-08-21  7:12       ` Gabriel Fernandez
2014-08-13 15:34 ` [PATCH 2/5] phy: miphy28lp: Add MiPHY28lp header file for DT x Driver defines Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-20 14:53   ` Kishon Vijay Abraham I
2014-08-20 14:53     ` Kishon Vijay Abraham I
2014-08-20 14:53     ` Kishon Vijay Abraham I
2014-08-21  7:12     ` Gabriel Fernandez
2014-08-21  7:12       ` Gabriel Fernandez
2014-08-21  7:12       ` Gabriel Fernandez
2014-08-13 15:34 ` [PATCH 3/5] phy: miphy28lp: Provide support for the MiPHY28lp Generic PHY Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-14 12:15   ` Srinivas Kandagatla [this message]
2014-08-14 12:15     ` Srinivas Kandagatla
2014-08-14 12:37     ` Gabriel Fernandez
2014-08-14 12:37       ` Gabriel Fernandez
2014-08-20 14:58   ` Kishon Vijay Abraham I
2014-08-20 14:58     ` Kishon Vijay Abraham I
2014-08-20 14:58     ` Kishon Vijay Abraham I
2014-08-21  7:12     ` Gabriel Fernandez
2014-08-21  7:12       ` Gabriel Fernandez
2014-08-13 15:34 ` [PATCH 4/5] ARM: DT: STi: STiH407: Add DT node for MiPHY28lp Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-13 15:34 ` [PATCH 5/5] ARM: multi_v7_defconfig: Enable MiPHY28lp - ST's Generic (SATA, PCIe & USB3) PHY Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ
2014-08-13 15:34   ` Gabriel FERNANDEZ

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=53ECA866.2080306@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.