Skip to content

Commit

Permalink
lightnvm: propagate device_add() error code
Browse files Browse the repository at this point in the history
device_add() may fail, and all callers are supposed to check the
return value, but one new user in lightnvm doesn't:

drivers/lightnvm/sysfs.c: In function 'nvm_sysfs_register_dev':
drivers/lightnvm/sysfs.c:184:2: error: ignoring return value of 'device_add',
  declared with attribute warn_unused_result [-Werror=unused-result]

This changes the caller to propagate any error codes, which avoids
the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 38c9e260b9f9 ("lightnvm: expose device geometry through sysfs")
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Arnd Bergmann authored and Jens Axboe committed Sep 21, 2016
1 parent 40267ef commit 1e3aeae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/lightnvm/lightnvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <linux/lightnvm.h>

/* core -> sysfs.c */
int nvm_sysfs_register_dev(struct nvm_dev *);
int __must_check nvm_sysfs_register_dev(struct nvm_dev *);
void nvm_sysfs_unregister_dev(struct nvm_dev *);
int nvm_sysfs_register(void);
void nvm_sysfs_unregister(void);
Expand Down
9 changes: 6 additions & 3 deletions drivers/lightnvm/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,21 @@ static struct device_type nvm_type = {

int nvm_sysfs_register_dev(struct nvm_dev *dev)
{
int ret;

if (!dev->parent_dev)
return 0;

dev->dev.parent = dev->parent_dev;
dev_set_name(&dev->dev, "%s", dev->name);
dev->dev.type = &nvm_type;
device_initialize(&dev->dev);
device_add(&dev->dev);
ret = device_add(&dev->dev);

blk_mq_register_dev(&dev->dev, dev->q);
if (!ret)
blk_mq_register_dev(&dev->dev, dev->q);

return 0;
return ret;
}

void nvm_sysfs_unregister_dev(struct nvm_dev *dev)
Expand Down

0 comments on commit 1e3aeae

Please sign in to comment.