Re: [PATCH 3/4] hwmon: Add support for Amphenol ChipCap 2

From: Javier Carrasco
Date: Thu Nov 09 2023 - 03:59:11 EST




On 09.11.23 09:40, Krzysztof Kozlowski wrote:
> On 08/11/2023 17:35, Javier Carrasco wrote:
>>>> +
>>>> + data->regulator = devm_regulator_get_optional(dev, "vdd");
>>>> + if (!IS_ERR(data->regulator)) {
>>>> + ret = cc2_retrive_alarm_config(data);
>>>> + if (ret)
>>>> + goto cleanup;
>>>> + } else {
>>>> + /* No access to EEPROM without regulator: no alarm control */
>>>
>>> Test your code with deferred probe. Are you sure you handle it
>>> correctly? To me, it looks like you handle deferred probe the same as
>>> any error.
>>>
>> The -EPROBE_DEFER is propagated to the probe function and it is the
>> returned value. I clarified the error path in v2 so no error messages
>
> Really?
>
> I see:
> if (!IS_ERR(data->regulator)) {
> // so you do not go here
> } else {
> goto dev_register;
> }
> dev_register is not error path. So how do you return EPROBE_DEFER?
>
> Which line of code does it?
>
EPROBE_DEFER is returned if the command window was missed, which is
checked in cc2_retrieve_alarm_config() (there is a typo I just corrected
-> cc2_retrive_alarm_config() in the current version). It could then
happen where you added a comment, but not because
devm_regulator_get_optional() failed.

Are you expecting a probe deferring if devm_regulator_get_optional()
fails as well? Like if the regulator is still not ready when the
function is called.
>> are displayed in that case, going directly to the dev_err_probe in the
>> probe cleanup.
>> When the EPROBE_DEFER error is returned, the probe function is deferred
>> and called again later on, which is the desired behavior.
>>
>
>
> Best regards,
> Krzysztof
>
Best regards,
Javier Carrasco