block: cleanup how md_autodetect_dev is called
authorChristoph Hellwig <hch@lst.de>
Tue, 24 Mar 2020 07:25:19 +0000 (08:25 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 24 Mar 2020 13:57:08 +0000 (07:57 -0600)
Add a new include/linux/raid/detect.h header to declare the
md_autodetect_dev prototype which can be shared between md and
the partition code.  Then use IS_BUILTIN to call it instead of the
ifdef magic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/partition-generic.c
drivers/md/md.c
include/linux/raid/detect.h [new file with mode: 0644]

index fef6bacb2bbbeb5906d8cbb253945d3741aa5689..4d771ae835edae06f29cc1e2356fe2d331ac84d5 100644 (file)
 #include <linux/ctype.h>
 #include <linux/genhd.h>
 #include <linux/blktrace_api.h>
+#include <linux/raid/detect.h>
 #include "blk.h"
 
 #include "partitions/check.h"
 
-#ifdef CONFIG_BLK_DEV_MD
-extern void md_autodetect_dev(dev_t dev);
-#endif
 static ssize_t part_partition_show(struct device *dev,
                                   struct device_attribute *attr, char *buf)
 {
@@ -407,10 +404,10 @@ static bool blk_add_partition(struct gendisk *disk, struct block_device *bdev,
                return true;
        }
 
-#ifdef CONFIG_BLK_DEV_MD
-       if (state->parts[p].flags & ADDPART_FLAG_RAID)
+       if (IS_BUILTIN(CONFIG_BLK_DEV_MD) &&
+           (state->parts[p].flags & ADDPART_FLAG_RAID))
                md_autodetect_dev(part_to_dev(part)->devt);
-#endif
+
        return true;
 }
 
index 8238fb64f87fb4e5741213c28fcd7787ead05fe3..1c7193715f073b96848b6a827f942b7e0e3ded60 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/delay.h>
 #include <linux/raid/md_p.h>
 #include <linux/raid/md_u.h>
+#include <linux/raid/detect.h>
 #include <linux/slab.h>
 #include <linux/percpu-refcount.h>
 
diff --git a/include/linux/raid/detect.h b/include/linux/raid/detect.h
new file mode 100644 (file)
index 0000000..37dd3f4
--- /dev/null
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+void md_autodetect_dev(dev_t dev);