From patchwork Thu Sep 15 15:53:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9334141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35677601C2 for ; Thu, 15 Sep 2016 15:53:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BA6529A01 for ; Thu, 15 Sep 2016 15:53:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2059429A0C; Thu, 15 Sep 2016 15:53:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5117329A01 for ; Thu, 15 Sep 2016 15:53:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754364AbcIOPxk (ORCPT ); Thu, 15 Sep 2016 11:53:40 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:50864 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754313AbcIOPxg (ORCPT ); Thu, 15 Sep 2016 11:53:36 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue003) with ESMTPA (Nemesis) id 0M9LBa-1brl2O3JCI-00Ciyt; Thu, 15 Sep 2016 17:53:26 +0200 From: Arnd Bergmann To: Matias Bjorling Cc: Arnd Bergmann , "Simon A. F. Lund" , =?UTF-8?q?Matias=20Bj=C3=B8rling?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] lightnvm: propagate device_add() error code Date: Thu, 15 Sep 2016 17:53:12 +0200 Message-Id: <20160915155325.3009409-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:WugEmp55n9Bkgb90t4pAATjoQEx8VO6X5h55+jfxVC2v8befKDw yegThbYIO7WH8n60fk04nL9so8HYO6PzL6PGcCVVJn1znzztYYYsCR0B+89A4qqWFI3l8w5 cJ4aK3BYRYpo91mPY9QjVKfNIctENN6QgmxABdDtC5ieWifw6f/ekTXAEIXj7wo+LwzpRWv IOwFX86THjKV80Qd9Zf2A== X-UI-Out-Filterresults: notjunk:1; V01:K0:gxLUj21RG/A=:Tmp4l7rhV+WgXguUuT2ro3 hoXVgC/qbiFaGgC+N4E9ZQ9OLxuQALYnGLfy2IYFBZkHByUwXJ+FJRr9fuAgJbS3jiFd+vf6R Y4U99J7in4ur9PX/aezSE+tfEK2JU2a94MeC3t3ow+vOsim3xKpKqneQwSsLlJMyVoNGnG8gg hnCqYmllVb32EpSyGHcUK9PMiG0JvF1Xi8LojeHoMX5uSmQu2c76xMB5DcISjmqgsSEe0ospK 2Ioc90S9KBrtVfHlT3bBR0oXNyCqf08ZJsu1ETeDgwx90FdO/Vb9FxqWXtx2dSjXPlC1OoGRd cHH+Di8jRn+vJFKv3hnmfHJsIldGrid38ENLm38WNu7XodGEc5BNkZIld8noA7qp7e6GtdeeC Mk2wMS6FVUPU0wdS0UmYd/gRSHeDWpKvvYwqSBb60Z1YG5b7yGM3Dd+Gl5K6ZXwNOsz+65ctD nsXzNRhRMHltgVS80cPplCdPXsnZigA53hcfbTedpVGj0H/u+JL+BzjYby2JS31iuHCITHD9y LrUpcaUkMZKGM3ZVxRra9Dl0vipreejBoP5gCiNUgIk6EWsu3jJHyCganw4F2Pm/gGNTYJ7d3 Z8ydFdWiMVOWf09fudWakzMetLwJXhbnBRct9THMB2lIywcxml3ChiMCQLfEun5jz+pbzw0ye ENmBEm7sogEQ6OTXP2KKSVPiK/2dB/TAvKaSZ/tQOmF41Hoq1p1FDWJvDBIMP2mMYwuI= Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Fixes: 38c9e260b9f9 ("lightnvm: expose device geometry through sysfs") --- 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 93f1aacc9f02..305c181509a6 100644 --- a/drivers/lightnvm/lightnvm.h +++ b/drivers/lightnvm/lightnvm.h @@ -24,7 +24,7 @@ #include /* 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 72ad089c0269..0338c27ab95a 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)