Skip to content

Commit 278167f

Browse files
mcgrofaxboe
authored andcommitted
block: add __must_check for *add_disk*() callers
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ecaf97f commit 278167f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

block/genhd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ static void disk_scan_partitions(struct gendisk *disk)
394394
* This function registers the partitioning information in @disk
395395
* with the kernel.
396396
*/
397-
int device_add_disk(struct device *parent, struct gendisk *disk,
398-
const struct attribute_group **groups)
397+
int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
398+
const struct attribute_group **groups)
399399

400400
{
401401
struct device *ddev = disk_to_dev(disk);
@@ -544,7 +544,7 @@ int device_add_disk(struct device *parent, struct gendisk *disk,
544544
out_free_ext_minor:
545545
if (disk->major == BLOCK_EXT_MAJOR)
546546
blk_free_ext_minor(disk->first_minor);
547-
return WARN_ON_ONCE(ret); /* keep until all callers handle errors */
547+
return ret;
548548
}
549549
EXPORT_SYMBOL(device_add_disk);
550550

include/linux/genhd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ static inline dev_t disk_devt(struct gendisk *disk)
205205
void disk_uevent(struct gendisk *disk, enum kobject_action action);
206206

207207
/* block/genhd.c */
208-
int device_add_disk(struct device *parent, struct gendisk *disk,
209-
const struct attribute_group **groups);
210-
static inline int add_disk(struct gendisk *disk)
208+
int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
209+
const struct attribute_group **groups);
210+
static inline int __must_check add_disk(struct gendisk *disk)
211211
{
212212
return device_add_disk(NULL, disk, NULL);
213213
}

0 commit comments

Comments
 (0)