Re: [PATCH v4 2/6] PCI: spacemit-k1: Add multiple PHY handles support
From: Alex Elder
Date: Fri Jul 10 2026 - 08:44:22 EST
On 7/10/26 5:55 AM, Inochi Amaoto wrote:
In fact it is already 0 here. But I am not understand why you thing is wrong.Isn't it already 0? Semantically code is wrong in a flow (not in the result).I guess you think 0 is a valid number? I can not understand what you thing+ k1->phy_count = i;This doesn't seem correct to me, I would expect phy_count to be assigned only
+ if (k1->phy_count == 0)
+ return -EINVAL;
+
+ return 0;
when it's valid. (Yes, perhaps 0 is the same as it was, but semantically it's
different 0 in this case.)
Assign this to 0 if there is no phy is fine to me, which shows there is 0
vaild phy found.
Could you explain it in detail? (Maybe you think it is not good to return
-EINVAL?)
What Andy is saying is that assigning the value of phy_count
before checking that it is valid is not the expected order of
things.
The point is about best practice, not about the end result.
Best practice would be "don't touch anything if the return
value will indicate an error."
And therefore, better coding practice would be to check for
a bad value, and only after that has been done should you
assign the k1->phy_count value.
-Alex