block: add __must_check for *add_disk*() callers
authorLuis Chamberlain <mcgrof@kernel.org>
Wed, 10 Nov 2021 00:29:49 +0000 (16:29 -0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Nov 2021 02:19:34 +0000 (19:19 -0700)
Now that we have done a spring cleaning on all drivers and added
error checking / handling, let's keep it that way and ensure
no new drivers fail to stick with it.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20211110002949.999380-1-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c
include/linux/genhd.h

index ca2fbab..c5392cc 100644 (file)
@@ -394,8 +394,8 @@ static void disk_scan_partitions(struct gendisk *disk)
  * This function registers the partitioning information in @disk
  * with the kernel.
  */
-int device_add_disk(struct device *parent, struct gendisk *disk,
-                    const struct attribute_group **groups)
+int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
+                                const struct attribute_group **groups)
 
 {
        struct device *ddev = disk_to_dev(disk);
@@ -544,7 +544,7 @@ out_disk_release_events:
 out_free_ext_minor:
        if (disk->major == BLOCK_EXT_MAJOR)
                blk_free_ext_minor(disk->first_minor);
-       return WARN_ON_ONCE(ret); /* keep until all callers handle errors */
+       return ret;
 }
 EXPORT_SYMBOL(device_add_disk);
 
index 462634b..74c4102 100644 (file)
@@ -205,9 +205,9 @@ static inline dev_t disk_devt(struct gendisk *disk)
 void disk_uevent(struct gendisk *disk, enum kobject_action action);
 
 /* block/genhd.c */
-int device_add_disk(struct device *parent, struct gendisk *disk,
-               const struct attribute_group **groups);
-static inline int add_disk(struct gendisk *disk)
+int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
+                                const struct attribute_group **groups);
+static inline int __must_check add_disk(struct gendisk *disk)
 {
        return device_add_disk(NULL, disk, NULL);
 }