Skip to content

Commit 174ebec

Browse files
djbwtorvalds
authored andcommitted
device-dax: move instance creation parameters to 'struct dev_dax_data'
In preparation for adding more parameters to instance creation, move existing parameters to a new struct. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Vishal Verma <vishal.l.verma@intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Brice Goglin <Brice.Goglin@inria.fr> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Dave Jiang <dave.jiang@intel.com> Cc: David Airlie <airlied@linux.ie> Cc: David Hildenbrand <david@redhat.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Jason Gunthorpe <jgg@mellanox.com> Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Jia He <justin.he@arm.com> Cc: Joao Martins <joao.m.martins@oracle.com> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Mike Rapoport <rppt@linux.ibm.com> Cc: Paul Mackerras <paulus@ozlabs.org> Cc: Pavel Tatashin <pasha.tatashin@soleen.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Wei Yang <richard.weiyang@linux.alibaba.com> Cc: Will Deacon <will@kernel.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Hulk Robot <hulkci@huawei.com> Cc: Jason Yan <yanaijie@huawei.com> Cc: "Jérôme Glisse" <jglisse@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: kernel test robot <lkp@intel.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Link: https://lkml.kernel.org/r/159643099411.4062302.1337305960720423895.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ec82690 commit 174ebec

4 files changed

Lines changed: 30 additions & 17 deletions

File tree

‎drivers/dax/bus.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,24 +395,24 @@ static void unregister_dev_dax(void *dev)
395395
put_device(dev);
396396
}
397397

398-
struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
399-
struct dev_pagemap *pgmap, enum dev_dax_subsys subsys)
398+
struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
400399
{
400+
struct dax_region *dax_region = data->dax_region;
401401
struct device *parent = dax_region->dev;
402402
struct dax_device *dax_dev;
403403
struct dev_dax *dev_dax;
404404
struct inode *inode;
405405
struct device *dev;
406406
int rc = -ENOMEM;
407407

408-
if (id < 0)
408+
if (data->id < 0)
409409
return ERR_PTR(-EINVAL);
410410

411411
dev_dax = kzalloc(sizeof(*dev_dax), GFP_KERNEL);
412412
if (!dev_dax)
413413
return ERR_PTR(-ENOMEM);
414414

415-
memcpy(&dev_dax->pgmap, pgmap, sizeof(*pgmap));
415+
memcpy(&dev_dax->pgmap, data->pgmap, sizeof(struct dev_pagemap));
416416

417417
/*
418418
* No 'host' or dax_operations since there is no access to this
@@ -438,13 +438,13 @@ struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
438438

439439
inode = dax_inode(dax_dev);
440440
dev->devt = inode->i_rdev;
441-
if (subsys == DEV_DAX_BUS)
441+
if (data->subsys == DEV_DAX_BUS)
442442
dev->bus = &dax_bus_type;
443443
else
444444
dev->class = dax_class;
445445
dev->parent = parent;
446446
dev->type = &dev_dax_type;
447-
dev_set_name(dev, "dax%d.%d", dax_region->id, id);
447+
dev_set_name(dev, "dax%d.%d", dax_region->id, data->id);
448448

449449
rc = device_add(dev);
450450
if (rc) {
@@ -464,7 +464,7 @@ struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
464464

465465
return ERR_PTR(rc);
466466
}
467-
EXPORT_SYMBOL_GPL(__devm_create_dev_dax);
467+
EXPORT_SYMBOL_GPL(devm_create_dev_dax);
468468

469469
static int match_always_count;
470470

‎drivers/dax/bus.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
1313
struct resource *res, int target_node, unsigned int align);
1414

1515
enum dev_dax_subsys {
16-
DEV_DAX_BUS,
16+
DEV_DAX_BUS = 0, /* zeroed dev_dax_data picks this by default */
1717
DEV_DAX_CLASS,
1818
};
1919

20-
struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
21-
struct dev_pagemap *pgmap, enum dev_dax_subsys subsys);
20+
struct dev_dax_data {
21+
struct dax_region *dax_region;
22+
struct dev_pagemap *pgmap;
23+
enum dev_dax_subsys subsys;
24+
int id;
25+
};
2226

23-
static inline struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
24-
int id, struct dev_pagemap *pgmap)
25-
{
26-
return __devm_create_dev_dax(dax_region, id, pgmap, DEV_DAX_BUS);
27-
}
27+
struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
2828

2929
/* to be deleted when DEV_DAX_CLASS is removed */
3030
struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys);

‎drivers/dax/hmem/hmem.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ static int dax_hmem_probe(struct platform_device *pdev)
1111
struct dev_pagemap pgmap = { };
1212
struct dax_region *dax_region;
1313
struct memregion_info *mri;
14+
struct dev_dax_data data;
1415
struct dev_dax *dev_dax;
1516
struct resource *res;
1617

@@ -26,7 +27,12 @@ static int dax_hmem_probe(struct platform_device *pdev)
2627
if (!dax_region)
2728
return -ENOMEM;
2829

29-
dev_dax = devm_create_dev_dax(dax_region, 0, &pgmap);
30+
data = (struct dev_dax_data) {
31+
.dax_region = dax_region,
32+
.id = 0,
33+
.pgmap = &pgmap,
34+
};
35+
dev_dax = devm_create_dev_dax(&data);
3036
if (IS_ERR(dev_dax))
3137
return PTR_ERR(dev_dax);
3238

‎drivers/dax/pmem/core.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys)
1414
resource_size_t offset;
1515
struct nd_pfn_sb *pfn_sb;
1616
struct dev_dax *dev_dax;
17+
struct dev_dax_data data;
1718
struct nd_namespace_io *nsio;
1819
struct dax_region *dax_region;
1920
struct dev_pagemap pgmap = { };
@@ -57,7 +58,13 @@ struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys)
5758
if (!dax_region)
5859
return ERR_PTR(-ENOMEM);
5960

60-
dev_dax = __devm_create_dev_dax(dax_region, id, &pgmap, subsys);
61+
data = (struct dev_dax_data) {
62+
.dax_region = dax_region,
63+
.id = id,
64+
.pgmap = &pgmap,
65+
.subsys = subsys,
66+
};
67+
dev_dax = devm_create_dev_dax(&data);
6168

6269
/* child dev_dax instances now own the lifetime of the dax_region */
6370
dax_region_put(dax_region);

0 commit comments

Comments
 (0)