diff options
author | Arnd Bergmann <arnd@arndb.de> | 2016-09-16 08:25:09 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-09-21 09:57:32 -0400 |
commit | 1e3aeae4ea710023dda2a6b780183ee371d1a796 (patch) | |
tree | fef9caecf2ae190102f2c2c9a5b8e49d111d3a8f | |
parent | 40267efddc296190d50c61d96daf277151447cf6 (diff) |
lightnvm: propagate device_add() error code
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>
-rw-r--r-- | drivers/lightnvm/lightnvm.h | 2 | ||||
-rw-r--r-- | drivers/lightnvm/sysfs.c | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/drivers/lightnvm/lightnvm.h b/drivers/lightnvm/lightnvm.h index 93f1aacc9f02..305c181509a6 100644 --- a/drivers/lightnvm/lightnvm.h +++ b/drivers/lightnvm/lightnvm.h | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/lightnvm.h> | 24 | #include <linux/lightnvm.h> |
25 | 25 | ||
26 | /* core -> sysfs.c */ | 26 | /* core -> sysfs.c */ |
27 | int nvm_sysfs_register_dev(struct nvm_dev *); | 27 | int __must_check nvm_sysfs_register_dev(struct nvm_dev *); |
28 | void nvm_sysfs_unregister_dev(struct nvm_dev *); | 28 | void nvm_sysfs_unregister_dev(struct nvm_dev *); |
29 | int nvm_sysfs_register(void); | 29 | int nvm_sysfs_register(void); |
30 | void nvm_sysfs_unregister(void); | 30 | void nvm_sysfs_unregister(void); |
diff --git a/drivers/lightnvm/sysfs.c b/drivers/lightnvm/sysfs.c index 72ad089c0269..0338c27ab95a 100644 --- a/drivers/lightnvm/sysfs.c +++ b/drivers/lightnvm/sysfs.c | |||
@@ -174,6 +174,8 @@ static struct device_type nvm_type = { | |||
174 | 174 | ||
175 | int nvm_sysfs_register_dev(struct nvm_dev *dev) | 175 | int nvm_sysfs_register_dev(struct nvm_dev *dev) |
176 | { | 176 | { |
177 | int ret; | ||
178 | |||
177 | if (!dev->parent_dev) | 179 | if (!dev->parent_dev) |
178 | return 0; | 180 | return 0; |
179 | 181 | ||
@@ -181,11 +183,12 @@ int nvm_sysfs_register_dev(struct nvm_dev *dev) | |||
181 | dev_set_name(&dev->dev, "%s", dev->name); | 183 | dev_set_name(&dev->dev, "%s", dev->name); |
182 | dev->dev.type = &nvm_type; | 184 | dev->dev.type = &nvm_type; |
183 | device_initialize(&dev->dev); | 185 | device_initialize(&dev->dev); |
184 | device_add(&dev->dev); | 186 | ret = device_add(&dev->dev); |
185 | 187 | ||
186 | blk_mq_register_dev(&dev->dev, dev->q); | 188 | if (!ret) |
189 | blk_mq_register_dev(&dev->dev, dev->q); | ||
187 | 190 | ||
188 | return 0; | 191 | return ret; |
189 | } | 192 | } |
190 | 193 | ||
191 | void nvm_sysfs_unregister_dev(struct nvm_dev *dev) | 194 | void nvm_sysfs_unregister_dev(struct nvm_dev *dev) |