Message ID | 170449247973.3779673.15088722836135359275.stgit@djiang5-mobl3 |
---|---|
State | Accepted |
Commit | 321dd36c286b3f982b341ce9a273b0f66f0e00ed |
Headers | show |
Series | cxl: find_cxl_root() related cleanups | expand |
On 05.01.24 15:07:59, Dave Jiang wrote: > Use scope-based resource management __free() macro to drop the open coded > put_device() in cxl_endpoint_port_probe(). > > Reviewed-by: Ira Weiny <ira.weiny@intel.com> > Signed-off-by: Dave Jiang <dave.jiang@intel.com> > --- > v6: > - Cleanup put_device() > v5: > - Update commit log (Dan) > v4: > - Don't check return value of find_cxl_root() per comment. (Dan) > --- > drivers/cxl/port.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c > index 4f3a08fdc9e9..97c21566677a 100644 > --- a/drivers/cxl/port.c > +++ b/drivers/cxl/port.c > @@ -94,7 +94,6 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) > struct cxl_endpoint_dvsec_info info = { .port = port }; > struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev); > struct cxl_dev_state *cxlds = cxlmd->cxlds; > - struct cxl_root *cxl_root; > struct cxl_hdm *cxlhdm; > struct cxl_port *root; > int rc; > @@ -131,7 +130,8 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) > * This can't fail in practice as CXL root exit unregisters all > * descendant ports and that in turn synchronizes with cxl_port_probe() > */ > - cxl_root = find_cxl_root(port); > + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); Same here, definition is not at the beginning of the block. > + > root = &cxl_root->port; root var can be dropped. -Robert > > /* > @@ -139,7 +139,6 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) > * assemble regions from committed decoders > */ > device_for_each_child(&port->dev, root, discover_region); > - put_device(&root->dev); > > return 0; > } > >
diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index 4f3a08fdc9e9..97c21566677a 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -94,7 +94,6 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) struct cxl_endpoint_dvsec_info info = { .port = port }; struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev); struct cxl_dev_state *cxlds = cxlmd->cxlds; - struct cxl_root *cxl_root; struct cxl_hdm *cxlhdm; struct cxl_port *root; int rc; @@ -131,7 +130,8 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) * This can't fail in practice as CXL root exit unregisters all * descendant ports and that in turn synchronizes with cxl_port_probe() */ - cxl_root = find_cxl_root(port); + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); + root = &cxl_root->port; /* @@ -139,7 +139,6 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) * assemble regions from committed decoders */ device_for_each_child(&port->dev, root, discover_region); - put_device(&root->dev); return 0; }