]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dax: move dax_pgoff_to_phys from [drivers/dax/] device.c to bus.c
authorJohn Groves <john@groves.net>
Fri, 27 Mar 2026 21:04:08 +0000 (21:04 +0000)
committerIra Weiny <ira.weiny@intel.com>
Mon, 30 Mar 2026 13:20:47 +0000 (08:20 -0500)
This function will be used by both device.c and fsdev.c, but both are
loadable modules. Moving to bus.c puts it in core and makes it available
to both.

No code changes - just relocated.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: John Groves <john@groves.net>
Link: https://patch.msgid.link/0100019d311c90eb-a582ff97-93ba-49f3-8140-6c5c4bf8bc62-000000@email.amazonses.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
drivers/dax/bus.c
drivers/dax/device.c

index c94c09622516e023073174115a7d2a872669973b..1b412264bb365d997d86b0ac114f24f3f62ccf88 100644 (file)
@@ -1417,6 +1417,26 @@ static const struct device_type dev_dax_type = {
        .groups = dax_attribute_groups,
 };
 
+/* see "strong" declaration in tools/testing/nvdimm/dax-dev.c */
+__weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
+                             unsigned long size)
+{
+       for (int i = 0; i < dev_dax->nr_range; i++) {
+               struct dev_dax_range *dax_range = &dev_dax->ranges[i];
+               struct range *range = &dax_range->range;
+               phys_addr_t phys;
+
+               if (!in_range(pgoff, dax_range->pgoff, PHYS_PFN(range_len(range))))
+                       continue;
+               phys = PFN_PHYS(pgoff - dax_range->pgoff) + range->start;
+               if (phys + size - 1 <= range->end)
+                       return phys;
+               break;
+       }
+       return -1;
+}
+EXPORT_SYMBOL_GPL(dax_pgoff_to_phys);
+
 static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data)
 {
        struct dax_region *dax_region = data->dax_region;
index 528e81240c4d451496c27cd1dc331d77c922eb3b..2d2dbfd35e94496b00d50add106cd4dabd1e72e1 100644 (file)
@@ -57,29 +57,6 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
                           vma->vm_file, func);
 }
 
-/* see "strong" declaration in tools/testing/nvdimm/dax-dev.c */
-__weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
-               unsigned long size)
-{
-       int i;
-
-       for (i = 0; i < dev_dax->nr_range; i++) {
-               struct dev_dax_range *dax_range = &dev_dax->ranges[i];
-               struct range *range = &dax_range->range;
-               unsigned long long pgoff_end;
-               phys_addr_t phys;
-
-               pgoff_end = dax_range->pgoff + PHYS_PFN(range_len(range)) - 1;
-               if (pgoff < dax_range->pgoff || pgoff > pgoff_end)
-                       continue;
-               phys = PFN_PHYS(pgoff - dax_range->pgoff) + range->start;
-               if (phys + size - 1 <= range->end)
-                       return phys;
-               break;
-       }
-       return -1;
-}
-
 static void dax_set_mapping(struct vm_fault *vmf, unsigned long pfn,
                              unsigned long fault_size)
 {