Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Dan Williams and committed by
Dave Jiang
471d8844 b6a61d5b

+9 -8
+6 -5
drivers/cxl/core/region.c
··· 4225 4225 return devm_add_action_or_reset(dev, remove_debugfs, dentry); 4226 4226 } 4227 4227 4228 - static int region_contains_resource(struct device *dev, void *data) 4228 + static int region_contains_resource(struct device *dev, const void *data) 4229 4229 { 4230 - struct resource *res = data; 4230 + const struct resource *res = data; 4231 4231 struct cxl_region *cxlr; 4232 4232 struct cxl_region_params *p; 4233 4233 ··· 4246 4246 return resource_contains(p->res, res) ? 1 : 0; 4247 4247 } 4248 4248 4249 - bool cxl_region_contains_resource(struct resource *res) 4249 + bool cxl_region_contains_resource(const struct resource *res) 4250 4250 { 4251 4251 guard(rwsem_read)(&cxl_rwsem.region); 4252 - return bus_for_each_dev(&cxl_bus_type, NULL, res, 4253 - region_contains_resource) != 0; 4252 + struct device *dev __free(put_device) = bus_find_device( 4253 + &cxl_bus_type, NULL, res, region_contains_resource); 4254 + return !!dev; 4254 4255 } 4255 4256 EXPORT_SYMBOL_FOR_MODULES(cxl_region_contains_resource, "dax_hmem"); 4256 4257
+2 -2
drivers/cxl/cxl.h
··· 941 941 int cxl_add_to_region(struct cxl_endpoint_decoder *cxled); 942 942 struct cxl_dax_region *to_cxl_dax_region(struct device *dev); 943 943 u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa); 944 - bool cxl_region_contains_resource(struct resource *res); 944 + bool cxl_region_contains_resource(const struct resource *res); 945 945 #else 946 946 static inline bool is_cxl_pmem_region(struct device *dev) 947 947 { ··· 964 964 { 965 965 return 0; 966 966 } 967 - static inline bool cxl_region_contains_resource(struct resource *res) 967 + static inline bool cxl_region_contains_resource(const struct resource *res) 968 968 { 969 969 return false; 970 970 }
+1 -1
drivers/dax/hmem/hmem.c
··· 159 159 IORES_DESC_CXL) == REGION_DISJOINT) 160 160 return 0; 161 161 162 - if (cxl_region_contains_resource((struct resource *)res)) { 162 + if (cxl_region_contains_resource(res)) { 163 163 dev_dbg(host, "CXL claims resource, dropping: %pr\n", res); 164 164 return 0; 165 165 }