Re: [RFC PATCH 1/5] net: macb: Check MDIO state before read/write and use timeouts

From: Harini Katakam
Date: Thu May 03 2018 - 06:59:02 EST


Hi Claudiu,

On Thu, May 3, 2018 at 3:38 PM, Claudiu Beznea
<Claudiu.Beznea@xxxxxxxxxxxxx> wrote:
>
>
> On 22.03.2018 15:51, harinikatakamlinux@xxxxxxxxx wrote:
>> From: Harini Katakam <harinik@xxxxxxxxxx>
>>
<snip>
>> + ulong timeout;
>> +
>> + timeout = jiffies + msecs_to_jiffies(1000);
>> + /* wait for end of transfer */
>> + do {
>> + if (MACB_BFEXT(IDLE, macb_readl(bp, NSR)))
>> + break;
>> +
>> + cpu_relax();
>> + } while (!time_after_eq(jiffies, timeout));
>> +
>> + if (time_after_eq(jiffies, timeout)) {
>> + netdev_err(bp->dev, "wait for end of transfer timed out\n");
>> + return -ETIMEDOUT;
>> + }
>
> Wouldn't be cleaner to keep it in this way:
>
> while (!MACB_BFEXT(IDLE, macb_readl(bp, NSR))) {
> if (time_after_eq(jiffies, timeout) {
> netdev_err(bp->dev, "wait for end of transfer timed out\n");
> return -ETIMEDOUT;
> }
> cpu_relax();
> }
>

Thanks for the review.
Sure, will update in next version.

Regards,
Harini