Re: [PATCH] phy: can-transceiver: Re-instate "mux-states" property presence check

From: Vincent Mailhol
Date: Thu Mar 20 2025 - 07:39:03 EST


On 20/03/2025 at 19:25, Geert Uytterhoeven wrote:
> Hi Vincent,

(...)

>> On 19/03/2025 at 22:27, Geert Uytterhoeven wrote:
>>> On the Renesas Gray Hawk Single development board:
>>>
>>> can-transceiver-phy can-phy0: /can-phy0: failed to get mux-state (0)
>>>
>>> "mux-states" is an optional property for CAN transceivers. However,
>>> mux_get() always prints an error message in case of an error, including
>>> when the property is not present, confusing the user.
>>
>> Hmmm, I understand why you are doing this patch. But on the long term,
>> wouldn't it make more sense to have a devm_mux_state_get_optional()? Or
>> maybe add a property somewhere to inform devm_mux_state_get() that this
>> is optional?
>>
>> Regardless, just see this as an open question. I am OK with the approach
>> of your patch.
>
> Alternatively, we can be proactive and add a temporary local wrapper:
>
> /* Dummy wrapper until optional muxes are supported */
> static inline struct mux_state *
> devm_mux_state_get_optional(struct device *dev, const char *mux_name)
> {
> if (!of_property_present(dev->of_node, "mux-states"))
> return NULL;
>
> return devm_mux_state_get(dev, mux_name);
> }
>
> and call that instead? Then the probe function needs no future changes
> when the real devm_mux_state_get_optional() arrives.

This looks like a more elegant and more long term solution!

Yours sincerely,
Vincent Mailhol