[PATCH RFC net-next v2 03/12] net: mdio: mdiobus_register: update validation test
Michael Walle
michael at walle.cc
Tue Jan 3 02:21:08 PST 2023
Hi Russell,
Am 2023-01-03 11:13, schrieb Russell King (Oracle):
> On Wed, Dec 28, 2022 at 12:07:19AM +0100, Michael Walle wrote:
>> + if (!bus || !bus->name)
>> + return -EINVAL;
>> +
>> + /* An access method always needs both read and write operations */
>> + if ((bus->read && !bus->write) ||
>> + (!bus->read && bus->write) ||
>> + (bus->read_c45 && !bus->write_c45) ||
>> + (!bus->read_c45 && bus->write_c45))
>
> I wonder whether the following would be even more readable:
>
> if (!bus->read != !bus->write || !bus->read_c45 != !bus->write_c45)
That's what Andrew had originally. But there was a comment from Sergey
[1]
which I agree with. I had a hard time wrapping my head around that, so I
just listed all the possible bad cases.
I don't have a strong opinion, though.
> which essentially asserts that the boolean of !method for the read and
> write methods must match.
Maybe with that as a comment?
-michael
[1]
https://lore.kernel.org/netdev/ae79823f-3697-feee-32e6-645c6f4b4e93@omp.ru/
More information about the Linux-mediatek
mailing list