lkml.org 
[lkml]   [2020]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next v3 2/4] net: phy: Add a helper to return the index for of the internal delay
From
Date
Andrew

On 5/26/20 7:42 PM, Andrew Lunn wrote:
>> +/**
>> + * phy_get_delay_index - returns the index of the internal delay
>> + * @phydev: phy_device struct
>> + * @delay_values: array of delays the PHY supports
>> + * @size: the size of the delay array
>> + * @int_delay: the internal delay to be looked up
>> + * @descending: if the delay array is in descending order
>> + *
>> + * Returns the index within the array of internal delay passed in.
>> + * Return errno if the delay is invalid or cannot be found.
>> + */
>> +s32 phy_get_delay_index(struct phy_device *phydev, int *delay_values, int size,
>> + int int_delay, bool descending)
>> +{
>> + if (int_delay < 0)
>> + return -EINVAL;
>> +
>> + if (size <= 0)
>> + return -EINVAL;
>> +
>> + if (descending)
>> + return phy_find_descending_delay(phydev, delay_values, size,
>> + int_delay);
>> +
>> + return phy_find_ascending_delay(phydev, delay_values, size, int_delay);
>> +}
>> +EXPORT_SYMBOL(phy_get_delay_index);
> Do we really need this ascending vs descending? This array is not
> coming from device tree of anything, it is a static list in the PHY
> driver. I would just define it needs to be ascending and be done.

I was thinking about the constraints of having just an ascending array
helper.

If there is a PHY out there that has a descending delay array then this
function is not a helper.

Then the PHY driver now has to implement a descending search or extend
out this helper to do the same.

I can just keep it ascending for now but this helper may need to be
updated in the future to accommodate any PHYs with descending delay arrays.

Dan


> Andrew

\
 
 \ /
  Last update: 2020-05-27 14:14    [W:0.059 / U:0.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site