[PATCH v4 2/6] PCI: spacemit-k1: Add multiple PHY handles support
Alex Elder
elder at riscstar.com
Fri Jul 10 05:51:05 PDT 2026
On 7/9/26 2:16 AM, Andy Shevchenko wrote:
>> + if (IS_ERR(k1->phy[i])) {
>> + if (PTR_ERR(k1->phy[i]) == -ENODEV)
>> + break;
>> +
>> + return PTR_ERR(k1->phy[i]);
>> + }
> if (PTR_ERR(k1->phy[i]) == -ENODEV)
> break;
> if (IS_ERR(k1->phy[i]))
> return PTR_ERR(k1->phy[i]);
I'm not sure this is a huge improvement. Checking IS_ERR()
before using PTR_ERR() is comforting (a little along the
lines of the other issue you mentioned--assigning a result
before checking for an error). Anyway, it's a little bit
of an ugly construct no matter how you do it. Here's another
possible way to do it.
k1->phy[i] = devm_of_phy_get_by_index(dev, node, i);
if (!IS_ERR(k1->phy[i]))
continue;
ret = PTR_ERR(k1->phy[i]);
if (ret == -ENODEV)
break;
return ret;
-Alex
More information about the linux-riscv
mailing list