Skip to content

Commit 98856b2

Browse files
davejiangdjbw
authored andcommitted
cxl: Introduce put_cxl_root() helper
Add a helper function put_cxl_root() to maintain symmetry for find_cxl_root() function instead of relying on open coding of the put_device() in order to dereference the 'struct device' that happens via get_device() in find_cxl_root(). Suggested-by: Robert Richter <rrichter@amd.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Robert Richter <rrichter@amd.com> Link: https://lore.kernel.org/r/170449245417.3779673.4566146351673989387.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 185c1a4 commit 98856b2

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/cxl/core/port.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,15 @@ struct cxl_port *find_cxl_root(struct cxl_port *port)
986986
}
987987
EXPORT_SYMBOL_NS_GPL(find_cxl_root, CXL);
988988

989+
void put_cxl_root(struct cxl_root *cxl_root)
990+
{
991+
if (!cxl_root)
992+
return;
993+
994+
put_device(&cxl_root->port.dev);
995+
}
996+
EXPORT_SYMBOL_NS_GPL(put_cxl_root, CXL);
997+
989998
static struct cxl_dport *find_dport(struct cxl_port *port, int id)
990999
{
9911000
struct cxl_dport *dport;

drivers/cxl/cxl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,9 @@ struct cxl_port *devm_cxl_add_port(struct device *host,
735735
struct cxl_root *devm_cxl_add_root(struct device *host,
736736
const struct cxl_root_ops *ops);
737737
struct cxl_port *find_cxl_root(struct cxl_port *port);
738+
void put_cxl_root(struct cxl_root *cxl_root);
739+
DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_cxl_root(_T))
740+
738741
int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd);
739742
void cxl_bus_rescan(void);
740743
void cxl_bus_drain(void);

0 commit comments

Comments
 (0)