Re: [PATCH V3 15/20] cxl: Add a routine to find cxl root decoder on cxl bus using cxl port

Neeraj Kumar
2025-10-06T04:55:06Z

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

On 24/09/25 11:11AM, Dave Jiang wrote:
>
>> +struct cxl_root_decoder *cxl_find_root_decoder_by_port(struct cxl_port *port)
>> +{
>> + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
>> + struct device *dev;
>> +
>> + if (!cxl_root)
>> + return NULL;
>> +
>> + dev = device_find_child(&cxl_root->port.dev, NULL, match_root_decoder);
>> + if (!dev)
>> + return NULL;
>> +
>> + /* Release device ref taken via device_find_child() */
>> + put_device(dev);
>
>Should the caller release the device reference instead?
>
>DJ

Actually caller of this function wants to find root decoder information from cxl_port.
So in order to find root decoder we have used device_find_child() which internally
takes device ref. Therefore, just after finding the appropriate dev, I am releasing
device ref.
Its like taking device ref temporarly and releasing it then and there after finding
proper root decoder.
I believe, Releasing device ref from caller would make it look little out of context.

Regards,
Neeraj

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]