From: David Daney <ddaney@caviumnetworks.com>
To: Milton Miller <miltonm@bga.com>
Cc: devicetree-discuss@lists.ozlabs.org, grant.likely@secretlab.ca,
linux-kernel@vger.kernel.org,
"netdev@vger.kernel.org Cyril Chemparathy" <cyril@ti.com>,
Arnaud Patard <arnaud.patard@rtp-net.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [1/2] of/phylib: Use device tree properties to initialize Marvell PHYs.
Date: Thu, 18 Nov 2010 09:40:58 -0800 [thread overview]
Message-ID: <4CE5652A.7060508@caviumnetworks.com> (raw)
In-Reply-To: <marvell-phy@mdm.bga.com>
On 11/17/2010 09:38 PM, Milton Miller wrote:
[...]
>> +static int marvell_of_reg_init(struct phy_device *phydev)
>> +{
>> + const __be32 *paddr;
>> + int len, i, saved_page, current_page, page_changed, ret;
>> +
>> + if (!phydev->dev.of_node)
>> + return 0;
>> +
>> + paddr = of_get_property(phydev->dev.of_node, "marvell,reg-init",&len);
>> + if (!paddr || len< (2 * sizeof(u32)))
>> + return 0;
>> +
>> + saved_page = phy_read(phydev, 22);
>> + if (saved_page< 0)
>> + return saved_page;
>> + page_changed = 0;
>> + current_page = saved_page;
>> +
>> + ret = 0;
>> + len /= sizeof(u32);
>> + for (i = 0; i< len / 2; i += 2) {
>
> i< len - 1 would execute all the register inits specified in the property.
>
Right, a bit of a snafu I think. I will fix it.
>> + u32 reg_spec = be32_to_cpup(&paddr[i]);
>> + u32 val_spec = be32_to_cpup(&paddr[i + 1]);
>> + u16 reg = reg_spec& 0xffff;
>> + u16 reg_page = reg_spec>> 16;
>> + u16 val_bits = val_spec& 0xffff;
>> + u16 mask = val_spec>> 16;
>> + int val;
>> +
>
> While the outcome is the same, this code also mixes sizeof(u32)
> with __be32 pointer math.
I will think about how to make it more consistent.
Thank you for looking at it,
David Daney
WARNING: multiple messages have this Message-ID (diff)
From: David Daney <ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>
To: Milton Miller <miltonm-ogEGBHC/i9Y@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cyril
Chemparathy" <cyril-l0cyMroinI0@public.gmane.org>,
Arnaud Patard
<arnaud.patard-dQbF7i+pzddAfugRpC6u6w@public.gmane.org>
Subject: Re: [1/2] of/phylib: Use device tree properties to initialize Marvell PHYs.
Date: Thu, 18 Nov 2010 09:40:58 -0800 [thread overview]
Message-ID: <4CE5652A.7060508@caviumnetworks.com> (raw)
In-Reply-To: <marvell-phy-kM9DGJe42AJBDgjK7y7TUQ@public.gmane.org>
On 11/17/2010 09:38 PM, Milton Miller wrote:
[...]
>> +static int marvell_of_reg_init(struct phy_device *phydev)
>> +{
>> + const __be32 *paddr;
>> + int len, i, saved_page, current_page, page_changed, ret;
>> +
>> + if (!phydev->dev.of_node)
>> + return 0;
>> +
>> + paddr = of_get_property(phydev->dev.of_node, "marvell,reg-init",&len);
>> + if (!paddr || len< (2 * sizeof(u32)))
>> + return 0;
>> +
>> + saved_page = phy_read(phydev, 22);
>> + if (saved_page< 0)
>> + return saved_page;
>> + page_changed = 0;
>> + current_page = saved_page;
>> +
>> + ret = 0;
>> + len /= sizeof(u32);
>> + for (i = 0; i< len / 2; i += 2) {
>
> i< len - 1 would execute all the register inits specified in the property.
>
Right, a bit of a snafu I think. I will fix it.
>> + u32 reg_spec = be32_to_cpup(&paddr[i]);
>> + u32 val_spec = be32_to_cpup(&paddr[i + 1]);
>> + u16 reg = reg_spec& 0xffff;
>> + u16 reg_page = reg_spec>> 16;
>> + u16 val_bits = val_spec& 0xffff;
>> + u16 mask = val_spec>> 16;
>> + int val;
>> +
>
> While the outcome is the same, this code also mixes sizeof(u32)
> with __be32 pointer math.
I will think about how to make it more consistent.
Thank you for looking at it,
David Daney
next prev parent reply other threads:[~2010-11-18 17:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-17 23:54 [PATCH 0/2] of/phylib: Use device tree properties for PHY configuration David Daney
2010-11-17 23:54 ` David Daney
2010-11-17 23:54 ` [PATCH 1/2] of/phylib: Use device tree properties to initialize Marvell PHYs David Daney
2010-11-17 23:54 ` David Daney
2010-11-18 0:01 ` David Daney
2010-11-18 0:01 ` David Daney
[not found] ` <1290038071-13296-2-git-send-email-ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>
2010-11-18 5:38 ` [1/2] " Milton Miller
2010-11-18 17:40 ` David Daney [this message]
2010-11-18 17:40 ` David Daney
2010-11-18 19:32 ` [PATCH 1/2] " Cyril Chemparathy
2010-11-18 20:40 ` Grant Likely
2010-11-18 20:40 ` Grant Likely
2010-11-18 23:48 ` David Daney
2010-11-18 23:48 ` David Daney
2010-11-19 0:39 ` Grant Likely
2010-11-19 0:39 ` Grant Likely
2010-11-17 23:54 ` [PATCH 2/2] phylib: Add support for Marvell 88E1149R devices David Daney
2010-11-17 23:54 ` David Daney
2010-11-18 19:46 ` David Miller
2010-11-18 19:46 ` David Miller
2010-11-18 20:44 ` Grant Likely
2010-11-18 20:44 ` Grant Likely
2010-11-18 20:57 ` David Miller
2010-11-18 20:57 ` David Miller
2010-11-18 21:06 ` David Daney
2010-11-18 21:06 ` David Daney
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=4CE5652A.7060508@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=arnaud.patard@rtp-net.org \
--cc=benh@kernel.crashing.org \
--cc=cyril@ti.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=miltonm@bga.com \
/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.