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: 101772 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp470113qgf; Fri, 16 Sep 2016 05:26:20 -0700 (PDT) X-Received: by 10.66.148.167 with SMTP id tt7mr22643889pab.21.1474028780575; Fri, 16 Sep 2016 05:26:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i70si17389820pfk.182.2016.09.16.05.26.20; Fri, 16 Sep 2016 05:26:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bjorling.me; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935099AbcIPM0I (ORCPT + 27 others); Fri, 16 Sep 2016 08:26:08 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:33344 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934928AbcIPMZm (ORCPT ); Fri, 16 Sep 2016 08:25:42 -0400 Received: by mail-pa0-f66.google.com with SMTP id oz2so3431599pac.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=NRFbV5yWJLHVe4kE84YC6jNuQfCrrbos6L4pPfcDpEl1cBpVC3/yzdOI/8a7L7wVGf LXTRk6koGmXnk4K5DxDUuTd72rQV3eJLkooqJX+hmehGAtRwW1AIbemSiPnUaZhDjKpL v06fD4g0XokWzt9ikh6OJi2EQDoLidTjEI2TG2X5xRog+VCfyfg0CUK42rHgYGgKrbJ/ emrUvfUQCqWWwUjamyYFVuo8VQ7xbEqAwUrPxd9vbgkOTGfcQPlADP8DAlnLAvioO4e8 D4Hk3n3XUcs+svNNscDrXahHmgHHstzw10qCUcMlu4hlb30P4bcWBtZlEHZo9tejotJb GLhw== X-Gm-Message-State: AE9vXwPCii97HHAHX7xOGdVA9Ro5HhAVSmsRIL18IYa6FCJUWN2QzejjvvZA6A5z88OAWQ== 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_Bj=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?= =?utf-8?q?_Bj=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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.1.4 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)