From 2c720b492c59b070930aa1be8bef6e256d3bf4b2 Mon Sep 17 00:00:00 2001 From: "Ricardo B. Marliere" Date: Mon, 19 Feb 2024 09:47:28 -0300 Subject: dax: constify the struct device_type usage Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the dax_mapping_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime. Cc: Greg Kroah-Hartman Signed-off-by: Ricardo B. Marliere Reviewed-by: Dave Jiang Link: https://lore.kernel.org/r/20240219-device_cleanup-dax-v1-1-6b319ee89dc2@marliere.net Signed-off-by: Ira Weiny --- drivers/dax/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 797e1ebff299..018f81ec82ac 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -818,7 +818,7 @@ static const struct attribute_group *dax_mapping_attribute_groups[] = { NULL, }; -static struct device_type dax_mapping_type = { +static const struct device_type dax_mapping_type = { .release = dax_mapping_release, .groups = dax_mapping_attribute_groups, }; -- cgit v1.2.3 From 9566b89295196996bce57bf307bc634cb0713cec Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 6 Mar 2024 07:27:37 -0700 Subject: nvdimm: remove nd_integrity_init nd_integrity_init is only called from a single place. Open code it there, and use IS_ENABLED to remove the need for an extra stub. Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20240306142739.237234-2-hch@lst.de Signed-off-by: Ira Weiny --- drivers/nvdimm/btt.c | 12 ++++++++---- drivers/nvdimm/core.c | 30 ------------------------------ drivers/nvdimm/nd.h | 1 - 3 files changed, 8 insertions(+), 35 deletions(-) (limited to 'drivers') diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 4d0c527e8576..8e855b4e3e38 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1514,10 +1515,13 @@ static int btt_blk_init(struct btt *btt) blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_disk->queue); blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, btt->btt_disk->queue); - if (btt_meta_size(btt)) { - rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); - if (rc) - goto out_cleanup_disk; + if (btt_meta_size(btt) && IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)) { + struct blk_integrity bi = { + .tuple_size = btt_meta_size(btt), + .tag_size = btt_meta_size(btt), + }; + blk_integrity_register(btt->btt_disk, &bi); + blk_queue_max_integrity_segments(btt->btt_disk->queue, 1); } set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9); diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index d91799b71d23..2023a661bbb0 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -508,35 +507,6 @@ int nvdimm_bus_add_badrange(struct nvdimm_bus *nvdimm_bus, u64 addr, u64 length) } EXPORT_SYMBOL_GPL(nvdimm_bus_add_badrange); -#ifdef CONFIG_BLK_DEV_INTEGRITY -int nd_integrity_init(struct gendisk *disk, unsigned long meta_size) -{ - struct blk_integrity bi; - - if (meta_size == 0) - return 0; - - memset(&bi, 0, sizeof(bi)); - - bi.tuple_size = meta_size; - bi.tag_size = meta_size; - - blk_integrity_register(disk, &bi); - blk_queue_max_integrity_segments(disk->queue, 1); - - return 0; -} -EXPORT_SYMBOL(nd_integrity_init); - -#else /* CONFIG_BLK_DEV_INTEGRITY */ -int nd_integrity_init(struct gendisk *disk, unsigned long meta_size) -{ - return 0; -} -EXPORT_SYMBOL(nd_integrity_init); - -#endif - static __init int libnvdimm_init(void) { int rc; diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h index ae2078eb6a62..2dbb1dca17b5 100644 --- a/drivers/nvdimm/nd.h +++ b/drivers/nvdimm/nd.h @@ -489,7 +489,6 @@ enum nd_async_mode { ND_ASYNC, }; -int nd_integrity_init(struct gendisk *disk, unsigned long meta_size); void wait_nvdimm_bus_probe_idle(struct device *dev); void nd_device_register(struct device *dev); void nd_device_unregister(struct device *dev, enum nd_async_mode mode); -- cgit v1.2.3 From 1e97469678a0987174d8bec0d955b67e0048ac84 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 6 Mar 2024 07:27:38 -0700 Subject: nvdimm/btt: always set max_integrity_segments max_integrity_segments is just a hardware/driver limit and can be safely set even when integrity data is not supported. Set it in the initial queue_limits passed to blk_alloc_disk to simplify the driver. Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20240306142739.237234-3-hch@lst.de Signed-off-by: Ira Weiny --- drivers/nvdimm/btt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 8e855b4e3e38..1e5aedaf8c7b 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1500,6 +1500,7 @@ static int btt_blk_init(struct btt *btt) struct queue_limits lim = { .logical_block_size = btt->sector_size, .max_hw_sectors = UINT_MAX, + .max_integrity_segments = 1, }; int rc; @@ -1521,7 +1522,6 @@ static int btt_blk_init(struct btt *btt) .tag_size = btt_meta_size(btt), }; blk_integrity_register(btt->btt_disk, &bi); - blk_queue_max_integrity_segments(btt->btt_disk->queue, 1); } set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9); -- cgit v1.2.3 From 41147b006be2174b825a54b0620ecf4cc7ec5c84 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 15 Apr 2024 11:19:28 +0100 Subject: dax: remove redundant assignment to variable rc The variable rc is being assigned an value and then is being re-assigned a new value in the next statement. The assignment is redundant and can be removed. Cleans up clang scan build warning: drivers/dax/bus.c:1207:2: warning: Value stored to 'rc' is never read [deadcode.DeadStores] Signed-off-by: Colin Ian King Reviewed-by: Alison Schofield Reviewed-by: Dave Jiang Reviewed-by: Vishal Verma Link: https://lore.kernel.org/r/20240415101928.484143-1-colin.i.king@gmail.com Signed-off-by: Ira Weiny --- drivers/dax/bus.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 018f81ec82ac..6ec5db8013e8 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1204,7 +1204,6 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr, if (rc) return rc; - rc = -ENXIO; rc = down_write_killable(&dax_region_rwsem); if (rc) return rc; -- cgit v1.2.3