From patchwork Fri Sep 16 12:25:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9335719 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 781006077F for ; Fri, 16 Sep 2016 12:27:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A2AD29F7E for ; Fri, 16 Sep 2016 12:27:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DA7229F7F; Fri, 16 Sep 2016 12:27:22 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 DD9D629F6F for ; Fri, 16 Sep 2016 12:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934911AbcIPM0E (ORCPT ); Fri, 16 Sep 2016 08:26:04 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33343 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934931AbcIPMZn (ORCPT ); Fri, 16 Sep 2016 08:25:43 -0400 Received: by mail-pa0-f68.google.com with SMTP id oz2so3431597pac.0 for ; Fri, 16 Sep 2016 05:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m6BQK6TVCVWQHWdELbmY3NsyyOA2kZ+bCBk1xnxTI9E=; b=N2px5DslDvVAYuzT7aiFd04pk9AHij68YCXlTfx1625V6nRIWUN2KABqdHNszTejft iXQOJ2W5Mx3PWEHsfbLy/ZyhdwGR0fkJ3MGYkqex+aRc1gowSLOxi+e6YqsPlkzI3mqF BftYXw+QIBjgMwRoUBMqhHmiwUNvj6o2wYNmY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m6BQK6TVCVWQHWdELbmY3NsyyOA2kZ+bCBk1xnxTI9E=; b=N+XpK5D17kyY+E8wpXgO1oS6DRAw/jSOl6QTzYlm3CZ/73akcrzTpU/OfGvgEEup5H P7hMK/+eipNe0IVFNbHPM+setZLVN+A0c1JpDCWnRquUUYkcyt/jSWjcKxQhkZxsufSK UOlFTb9Ss/Q9a5TNd7ebmegLPiD+HR1MHFKG7I3bfJh6CSRxaUF97kb/7ZTI/g7WgPAC QrT59kXUAFTu7hbLm4SYM8w07NVrZyV4j1AnvGK43T8tDmnYqrO2+Br4/eE/V2MjtNo1 /P84L8kGlbqAd1/ba8VQ88efP9P0C352zmPKnLh4jaOyz8e4u2A5PLXnkpvwaHGllTqt xuyw== X-Gm-Message-State: AE9vXwMlKjAIBu/gh/fTV0/Wv0oWTuVx6+1fgbJ/8IianKuYQSvwfB3MS9vvghPFxARxPg== X-Received: by 10.66.149.138 with SMTP id ua10mr4883867pab.146.1474028742330; Fri, 16 Sep 2016 05:25:42 -0700 (PDT) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 3sm52129423pfz.33.2016.09.16.05.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Sep 2016 05:25:41 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: keith.busch@intel.com, Arnd Bergmann , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 7/7] lightnvm: propagate device_add() error code Date: Fri, 16 Sep 2016 14:25:09 +0200 Message-Id: <1474028709-30260-8-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1474028709-30260-1-git-send-email-m@bjorling.me> References: <1474028709-30260-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 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 From: Arnd Bergmann 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") Signed-off-by: Matias Bjørling --- 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 /* 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)