cxl/region: Use __free(put_device) in find_pos_and_ways()

Use __free(put_device) for the switch decoder reference returned by
device_find_child() instead of releasing it with an open-coded
put_device().

This matches the scoped device reference handling used elsewhere in
the file.

Suggested-by: Li Ming <ming.li@zohomail.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/550db1771b3d30277988d3e575f1a6893a26b0ae.1784931354.git.alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
This commit is contained in:
Alison Schofield 2026-07-24 15:28:02 -07:00 committed by Dave Jiang
parent 15da704b73
commit bad0aa134b

View File

@ -1914,15 +1914,14 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range,
{
struct cxl_switch_decoder *cxlsd;
struct cxl_port *parent;
struct device *dev;
int rc = -ENXIO;
parent = parent_port_of(port);
if (!parent)
return rc;
dev = device_find_child(&parent->dev, range,
match_switch_decoder_by_range);
struct device *dev __free(put_device) =
device_find_child(&parent->dev, range, match_switch_decoder_by_range);
if (!dev) {
dev_err(port->uport_dev,
"failed to find decoder mapping %#llx-%#llx\n",
@ -1945,8 +1944,6 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range,
dev_name(&port->dev),
dev_name(port->parent_dport->dport_dev), dev_name(dev));
put_device(dev);
return rc;
}