[1/2] of/phylib: Use device tree properties to initialize Marvell PHYs.

David Daney ddaney at caviumnetworks.com
Fri Nov 19 04:40:58 EST 2010


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


More information about the devicetree-discuss mailing list