Skip to content

Commit f2546eb

Browse files
djbwdavejiang
authored andcommitted
cxl/mem: Drop @host argument to devm_cxl_add_memdev()
In all cases the device that created the 'struct cxl_dev_state' instance is also the device to host the devm cleanup of devm_cxl_add_memdev(). This simplifies the function prototype, and limits a degree of freedom of the API. Cc: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com> Tested-by: Alejandro Lucero <alucerop@amd.com> Link: https://patch.msgid.link/20251216005616.3090129-6-dan.j.williams@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 6e1d219 commit f2546eb

5 files changed

Lines changed: 10 additions & 12 deletions

File tree

drivers/cxl/core/memdev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,7 @@ static struct cxl_memdev *cxl_memdev_autoremove(struct cxl_memdev *cxlmd)
10931093
* Core helper for devm_cxl_add_memdev() that wants to both create a device and
10941094
* assert to the caller that upon return cxl_mem::probe() has been invoked.
10951095
*/
1096-
struct cxl_memdev *__devm_cxl_add_memdev(struct device *host,
1097-
struct cxl_dev_state *cxlds)
1096+
struct cxl_memdev *__devm_cxl_add_memdev(struct cxl_dev_state *cxlds)
10981097
{
10991098
struct device *dev;
11001099
int rc;

drivers/cxl/cxlmem.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ static inline bool is_cxl_endpoint(struct cxl_port *port)
9595
return is_cxl_memdev(port->uport_dev);
9696
}
9797

98-
struct cxl_memdev *__devm_cxl_add_memdev(struct device *host,
99-
struct cxl_dev_state *cxlds);
100-
struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
101-
struct cxl_dev_state *cxlds);
98+
struct cxl_memdev *__devm_cxl_add_memdev(struct cxl_dev_state *cxlds);
99+
struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds);
102100
int devm_cxl_sanitize_setup_notifier(struct device *host,
103101
struct cxl_memdev *cxlmd);
104102
struct cxl_memdev_state;

drivers/cxl/mem.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,18 @@ static int cxl_mem_probe(struct device *dev)
165165

166166
/**
167167
* devm_cxl_add_memdev - Add a CXL memory device
168-
* @host: devres alloc/release context and parent for the memdev
169168
* @cxlds: CXL device state to associate with the memdev
170169
*
171170
* Upon return the device will have had a chance to attach to the
172171
* cxl_mem driver, but may fail if the CXL topology is not ready
173172
* (hardware CXL link down, or software platform CXL root not attached)
173+
*
174+
* The parent of the resulting device and the devm context for allocations is
175+
* @cxlds->dev.
174176
*/
175-
struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
176-
struct cxl_dev_state *cxlds)
177+
struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds)
177178
{
178-
return __devm_cxl_add_memdev(host, cxlds);
179+
return __devm_cxl_add_memdev(cxlds);
179180
}
180181
EXPORT_SYMBOL_NS_GPL(devm_cxl_add_memdev, "CXL");
181182

drivers/cxl/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
10061006
if (rc)
10071007
dev_dbg(&pdev->dev, "No CXL Features discovered\n");
10081008

1009-
cxlmd = devm_cxl_add_memdev(&pdev->dev, cxlds);
1009+
cxlmd = devm_cxl_add_memdev(cxlds);
10101010
if (IS_ERR(cxlmd))
10111011
return PTR_ERR(cxlmd);
10121012

tools/testing/cxl/test/mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
17671767

17681768
cxl_mock_add_event_logs(&mdata->mes);
17691769

1770-
cxlmd = devm_cxl_add_memdev(&pdev->dev, cxlds);
1770+
cxlmd = devm_cxl_add_memdev(cxlds);
17711771
if (IS_ERR(cxlmd))
17721772
return PTR_ERR(cxlmd);
17731773

0 commit comments

Comments
 (0)