From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com
Cc: keith.busch@intel.com, "Arnd Bergmann" <arnd@arndb.de>,
"Matias Bjørling" <m@bjorling.me>
Subject: [PATCH 7/7] lightnvm: propagate device_add() error code
Date: Fri, 16 Sep 2016 14:25:09 +0200 [thread overview]
Message-ID: <1474028709-30260-8-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1474028709-30260-1-git-send-email-m@bjorling.me>
From: Arnd Bergmann <arnd@arndb.de>
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>
---
drivers/lightnvm/lightnvm.h | 2 +-
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 93f1aac..305c181 100644
--- a/drivers/lightnvm/lightnvm.h
+++ b/drivers/lightnvm/lightnvm.h
@@ -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);
diff --git a/drivers/lightnvm/sysfs.c b/drivers/lightnvm/sysfs.c
index 72ad089..0338c27 100644
--- a/drivers/lightnvm/sysfs.c
+++ b/drivers/lightnvm/sysfs.c
@@ -174,6 +174,8 @@ static struct device_type nvm_type = {
int nvm_sysfs_register_dev(struct nvm_dev *dev)
{
+ int ret;
+
if (!dev->parent_dev)
return 0;
@@ -181,11 +183,12 @@ int nvm_sysfs_register_dev(struct nvm_dev *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)
--
2.1.4
next prev parent reply other threads:[~2016-09-16 12:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 12:25 [GIT PULL 0/7] LightNVM pull request for 4.9 Matias Bjørling
2016-09-16 12:25 ` [PATCH 1/7] lightnvm: NVM should depend on HAS_DMA Matias Bjørling
2016-09-16 12:25 ` [PATCH 2/7] nvme: refactor namespaces to support non-gendisk devices Matias Bjørling
2016-09-16 12:25 ` [PATCH 3/7] null_blk: refactor " Matias Bjørling
2016-09-16 12:25 ` [PATCH 4/7] blk-mq: register device instead of disk Matias Bjørling
2016-09-16 12:25 ` [PATCH 5/7] lightnvm: control life of nvm_dev in driver Matias Bjørling
2016-09-16 12:25 ` [PATCH 6/7] lightnvm: expose device geometry through sysfs Matias Bjørling
2016-09-16 12:25 ` Matias Bjørling [this message]
2016-09-21 14:14 ` [GIT PULL 0/7] LightNVM pull request for 4.9 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474028709-30260-8-git-send-email-m@bjorling.me \
--to=m@bjorling.me \
--cc=arnd@arndb.de \
--cc=axboe@fb.com \
--cc=keith.busch@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).