mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
cxl/region: Constify cxl_region_resource_contains()
The call to cxl_region_resource_contains() in hmem_register_cxl_device() need not cast away 'const'. The problem is the usage of the bus_for_each_dev() API which does not mark its @data parameter as 'const'. Switch to bus_find_device() which does take 'const' @data, fixup cxl_region_resource_contains() and its caller. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://patch.msgid.link/20260327052821.440749-5-dan.j.williams@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
This commit is contained in:
@@ -4225,9 +4225,9 @@ static int cxl_region_setup_poison(struct cxl_region *cxlr)
|
||||
return devm_add_action_or_reset(dev, remove_debugfs, dentry);
|
||||
}
|
||||
|
||||
static int region_contains_resource(struct device *dev, void *data)
|
||||
static int region_contains_resource(struct device *dev, const void *data)
|
||||
{
|
||||
struct resource *res = data;
|
||||
const struct resource *res = data;
|
||||
struct cxl_region *cxlr;
|
||||
struct cxl_region_params *p;
|
||||
|
||||
@@ -4246,11 +4246,12 @@ static int region_contains_resource(struct device *dev, void *data)
|
||||
return resource_contains(p->res, res) ? 1 : 0;
|
||||
}
|
||||
|
||||
bool cxl_region_contains_resource(struct resource *res)
|
||||
bool cxl_region_contains_resource(const struct resource *res)
|
||||
{
|
||||
guard(rwsem_read)(&cxl_rwsem.region);
|
||||
return bus_for_each_dev(&cxl_bus_type, NULL, res,
|
||||
region_contains_resource) != 0;
|
||||
struct device *dev __free(put_device) = bus_find_device(
|
||||
&cxl_bus_type, NULL, res, region_contains_resource);
|
||||
return !!dev;
|
||||
}
|
||||
EXPORT_SYMBOL_FOR_MODULES(cxl_region_contains_resource, "dax_hmem");
|
||||
|
||||
|
||||
+2
-2
@@ -941,7 +941,7 @@ struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev);
|
||||
int cxl_add_to_region(struct cxl_endpoint_decoder *cxled);
|
||||
struct cxl_dax_region *to_cxl_dax_region(struct device *dev);
|
||||
u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa);
|
||||
bool cxl_region_contains_resource(struct resource *res);
|
||||
bool cxl_region_contains_resource(const struct resource *res);
|
||||
#else
|
||||
static inline bool is_cxl_pmem_region(struct device *dev)
|
||||
{
|
||||
@@ -964,7 +964,7 @@ static inline u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline bool cxl_region_contains_resource(struct resource *res)
|
||||
static inline bool cxl_region_contains_resource(const struct resource *res)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ static int hmem_register_cxl_device(struct device *host, int target_nid,
|
||||
IORES_DESC_CXL) == REGION_DISJOINT)
|
||||
return 0;
|
||||
|
||||
if (cxl_region_contains_resource((struct resource *)res)) {
|
||||
if (cxl_region_contains_resource(res)) {
|
||||
dev_dbg(host, "CXL claims resource, dropping: %pr\n", res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user