Re: [PATCH net-next RESEND v5] net: qcom/emac: Find sgmii_ops by device_for_each_child()

From: quic_zijuhu
Date: Thu Oct 03 2024 - 13:10:23 EST


On 10/3/2024 9:39 PM, Paolo Abeni wrote:
>> @@ -356,10 +363,14 @@ int emac_sgmii_config(struct platform_device
>> *pdev, struct emac_adapter *adpt)
>>       int ret;
>>         if (has_acpi_companion(&pdev->dev)) {
>> +        struct emac_match_data match_data = {
>> +            .sgmii_ops = &phy->sgmii_ops,
>> +            .target_device = NULL,
>> +        };
>>           struct device *dev;
>>   -        dev = device_find_child(&pdev->dev, &phy->sgmii_ops,
>> -                    emac_sgmii_acpi_match);
>> +        device_for_each_child(&pdev->dev, &match_data,
>> emac_sgmii_acpi_match);
>> +        dev = match_data.target_device;
>>             if (!dev) {
>>               dev_warn(&pdev->dev, "cannot find internal phy node\n");
>
>
> I'm sorry for the late feedback. I agree with Greg, I think it would
> more clear removing the get_device() from the match function and add it
> here, after the 'if (!dev) {' statement.
>

Thank you for helping me understand those good suggestions.
will correct it within next revision.

> Thanks,
>
> Paolo