From patchwork Fri Sep 21 07:29:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03E6A14BD for ; Fri, 21 Sep 2018 07:32:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE32B2DE4D for ; Fri, 21 Sep 2018 07:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D21002DE50; Fri, 21 Sep 2018 07:32:01 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6550D2DE4D for ; Fri, 21 Sep 2018 07:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rWe8YM0yd+xoy3h6PPKECknuPAONRlAVf+sECU7hVQM=; b=DJ1tYci1IeJO6HetkVr6JFwNG9 4ypE7OFYfnerpZnjThGVivRt4rkN/I67wVuv5CYp2StRqrXEoQB/h/xu+nJDuiuuAsoeCgyM6Anr6 XLdvrjeA1wqYa7blO0v5am2jcyWz1VJC90Jqie5Ev2w26DrenmHOd6hiq9wBSiEPlFvCEtUulUSqO HCJIwtJL9yFxqNgEWxoxXAEHqNS1T/ixxEWrt95xWYtNzES8dbsguRU2Xne4QJOWP4vS+/YtjGo2T xSH41qJD8U6kFs77OHmmtV6gIelpGTrOth08i9IFJ9LqmyZkyQZziVfrpqQ5hhoIsi1v0vh9XpjeQ Rlz1/IWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fun-0008AD-48; Fri, 21 Sep 2018 07:31:49 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsh-00066W-Ns for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:44 +0000 Received: by mail-wm1-x343.google.com with SMTP id f21-v6so1924682wmc.5 for ; Fri, 21 Sep 2018 00:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6JdxSWkz3pHnb2fNllglZS2DOqO298ZYcJuckKV8dz4=; b=CBDVl5qOB9JQYOEHqBjET5xhNurapJvIkATKWAAMwmg9gt9a+5eQDMqcyrKfeHO7fq Jfc+cjC8ORm7vSZ8DsSTsFuci+2eZCT3x+4iEy9FDLOAsNYLfLLHQzK1IJgtLxM/9mfu /eTZKTnEANm7C4nKN4X09xMfH8N4/V/o0OcLeqCGX05/vvo4PhW1jGBUapUqhRIY42wA ZQFyfX/Fsy7J6oNkfBXivtHg6BoSP2n8hHuUvD+i8nYJskpk3Ud6/JScS3DlMx8DzRci P+K421WjXPi76mOXc5D8iVCcfBUOqm57yKKoeBzj5si/S4/urnCxIOiS6voFh9nHjgKD Bnjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6JdxSWkz3pHnb2fNllglZS2DOqO298ZYcJuckKV8dz4=; b=LGEH2tN+odX+tRSZFnWVvkXU+bs/KN8q5tGlpbhciMoqrnNzzacHFo2ru8h/Cfecvh hHcNf/PZTM+GoO/TkO+wvBHc16zXcN5VmcJ9L/fnhxeXc5J3eQ59uaY9FN3Cx35/m8cW PdjBcdDapNJujD094wxSx7pNyImp84ZF65PK3ylXrqWtP4Fe7SyR4NavP2kEgHhXiLLV DxSo0dlgpAqIWtdStfZxRg36NB7jupWytaFNrDxJ5NNxqJau9hQsTtdvC08XkKespIZD tg8LnydO2c3nq5h8ALnayC+eHhbCFOX6bEsFwi0WJ/B+Gt9YhishN5Wlcragp8giN5lG +b4w== X-Gm-Message-State: APzg51CKOhBERHgNAXZlmHO4bxpgfL22n7+3lOpkgJ9sdH+1MFJd4bKu KPhi0WNNLbqL/Moy4X+njbt8g5zE95Q= X-Google-Smtp-Source: ANB0VdZfKA924IcvzbN2d1seyZe/z6U1lhE9+XVw3x5/HGA4kOtqS5bSGQ4IP0wEA1pTUHoVfdD+SA== X-Received: by 2002:a1c:2351:: with SMTP id j78-v6mr5813004wmj.68.1537514967931; Fri, 21 Sep 2018 00:29:27 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:27 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 01/22] nvmem: provide nvmem_dev_name() Date: Fri, 21 Sep 2018 09:29:00 +0200 Message-Id: <20180921072921.19387-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002939_790510_C3966215 X-CRM114-Status: GOOD ( 14.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Kernel users don't have any means of checking the names of nvmem devices. Add a routine that returns the name of the nvmem provider. This will be useful for future nvmem notifier subscribers - otherwise they can't check what device is being added/removed. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 13 +++++++++++++ include/linux/nvmem-consumer.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 6f064002f439..11afa3b6d551 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1343,6 +1343,19 @@ int nvmem_device_write(struct nvmem_device *nvmem, } EXPORT_SYMBOL_GPL(nvmem_device_write); +/** + * nvmem_dev_name() - Get the name of a given nvmem device. + * + * @nvmem: nvmem device. + * + * Return: name of the nvmem device. + */ +const char *nvmem_dev_name(struct nvmem_device *nvmem) +{ + return dev_name(&nvmem->dev); +} +EXPORT_SYMBOL_GPL(nvmem_dev_name); + static int __init nvmem_init(void) { return bus_register(&nvmem_bus_type); diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 4e85447f7860..0389fe00b177 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -55,6 +55,8 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); +const char *nvmem_dev_name(struct nvmem_device *nvmem); + #else static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, @@ -143,6 +145,12 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem, { return -ENOSYS; } + +static inline const char *nvmem_dev_name(struct nvmem_device *nvmem) +{ + return NULL; +} + #endif /* CONFIG_NVMEM */ #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) From patchwork Fri Sep 21 07:29:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CACF157B for ; Fri, 21 Sep 2018 07:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12D832DCDA for ; Fri, 21 Sep 2018 07:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03DB22DE96; Fri, 21 Sep 2018 07:35:39 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7CF742DCDA for ; Fri, 21 Sep 2018 07:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eaZ8koKWUKlxCc71fLKYqhN9zMgQjyCL7eDNp1C8uBw=; b=TMs2QuQFtkKgjfr61X+De/IB8k PpN63PrJXCs97CLEHy7ar7CVpvsVk0MVy5Q28L3Gug5tpwrDiVdvIo4LlQb1yNPFMikeVR5DTgfUE +NZiv8ROsPw9dsTnq3sHjkqfbrTTCb59Hq93UEYrWLErQ8RnK3mi+0zIiwzvhrey79vT5ZXU/8rkh vf8/w5IBmsfHy5QaNbx0s7zCfmmnqdfERyF6/Oxc6tx9QOQALyRWlTMRAKD8QFCvkY5P7GByEgIR0 5fTyDPnPtLDanE1SKohe8CuvuXajaF/rM3+t2tyFNEfAiVF3/Eoke4kYf2dM4DYJ6+uIOFYwCEmls A2bx+lZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3FyI-0001YG-8c; Fri, 21 Sep 2018 07:35:26 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsj-00066X-3W for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:45 +0000 Received: by mail-wm1-x342.google.com with SMTP id j192-v6so2069968wmj.1 for ; Fri, 21 Sep 2018 00:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wwb26KwBGg36MP0eft6G8PNCPf95gO7oxvKFski7A98=; b=wxWexZB4kP7cU/JrD9UskQY2t8x3GcolcAbUbg0shuaFsZHeMyFbN7TXvWA6jTYWpx ba+7rgiU0hZzcSCCQ2twL8oTQBYsKAFg/Mw2XK9tVveLyL+XBvaY5puODkHm+HMgQZc/ KAtt6f4LnZd+bIk5/ObMfo361yzlAT7c+g6iN1/od8G0dgMXyGTQi2/7ZNL4LwZo2Ibw h1j33gKEcUr3ZqP/jX9IThNPttUaT60cRbzT9baZU/IY33VUxi2HZgkYMKdZY+NdVdRn q5jKKP22m+p6SU2w0VDeV6Pjfe8lzs5DpzZM1lvnllaOqu/Aosg83kAJStLNq2WhmUOs SziA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wwb26KwBGg36MP0eft6G8PNCPf95gO7oxvKFski7A98=; b=n4LmVDW31xgfgMKF7OJxd/zxCi2i53xkJF2pzuwUWs3YZm0wreL3nR/1xYhhbuCgz7 grySZRO6kwUeyAELqnHkkvcA3RRVWJ+k+TdZ6Cokk9OXEqqGk5PSNZ9pDYNWStmwggTo RngnJDioN3coIcjGY8oJQOlcmVEUeAGldFriGr4cb5uM3WiAY5lzjrqwxnBotNYw282o tS/kDUTHAZeP6pA3vcW/0sewXiueoYiPnWatoJugIsd5Kbo/dplEeXFujqjrxdFgbcX0 J6ftI2U0F86Ak645655IVxFQH+/v+2+Nj1q/foTTBGOcN8W2cWlnRhXW/WATnyEGuUNj VOWA== X-Gm-Message-State: ABuFfohcjet+mOWu5pn9ToOjo2uHYeNe+7/d1Hs1T57WPsXdNauyFhAC b5td5/+wBbPTMl61V9XJIvP0AQ== X-Google-Smtp-Source: ANB0Vdb1HpPW7YHS+cmTRJbTymNZy7pbV/qtYf1Mtb/NyXjdCTv9Ty9/+J9iaLUfpWF7rilZXIzwPw== X-Received: by 2002:a1c:114:: with SMTP id 20-v6mr5723392wmb.4.1537514969243; Fri, 21 Sep 2018 00:29:29 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:28 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 02/22] nvmem: remove the name field from struct nvmem_device Date: Fri, 21 Sep 2018 09:29:01 +0200 Message-Id: <20180921072921.19387-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002941_208372_BDD0D6C1 X-CRM114-Status: GOOD ( 15.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski This field is never set and is only used in a single error message. Remove the field and use nvmem_dev_name() instead. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 11afa3b6d551..72313a1d215f 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -26,7 +26,6 @@ #include struct nvmem_device { - const char *name; struct module *owner; struct device dev; int stride; @@ -652,7 +651,7 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, if (!try_module_get(nvmem->owner)) { dev_err(&nvmem->dev, "could not increase module refcount for cell %s\n", - nvmem->name); + nvmem_dev_name(nvmem)); mutex_lock(&nvmem_mutex); nvmem->users--; From patchwork Fri Sep 21 07:29:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44B2614BD for ; Fri, 21 Sep 2018 07:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B7472DE4D for ; Fri, 21 Sep 2018 07:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F1192DE50; Fri, 21 Sep 2018 07:32:42 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D67072DE4D for ; Fri, 21 Sep 2018 07:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XJMJseNlX9A62+xtQXOmzT1TUa2HI6cZBj4CV5OK/Ro=; b=OYxV1KRzdGTOWvYu281KBVvuNc AmBnVfCxwzEM0rkRg/BclZkEPSztnk3+/SYfnpaXXDWiqGuUe9TTYilhzJf5aTlEp5loyzsMPt9UM zkPf5/ygPd4pRolOkU5usOvYouAVq7syJ3AryvRT9h6Nq88petS7kki+eZOg5wGR2ZqlSkhG/+bF7 /o4VHjXSOZiZGtyWRjFk3xg3z3LqAOaLrugKBHc4mN4UtEIDjJs9JYoctE5BchY9H40lCUvY3pED+ 7DUY216vleY/BHmzwNSpnekpAeRplZI4XzfNNQAyZdPR7H29GNO+1k7YHYItf1O3y3PK8PFqKpgRj YVe9GgnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3FvX-0008Ps-I1; Fri, 21 Sep 2018 07:32:35 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsj-00066d-3h for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:45 +0000 Received: by mail-wm1-x342.google.com with SMTP id 207-v6so2019213wme.5 for ; Fri, 21 Sep 2018 00:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gmEHeYY9IxtEv7acXzK+EsVXEYGbLWE40bwPjEV+sgg=; b=l6jgU5P/BpJ7tfErgDdxo+DIvV6gu9MqTS3Nbm+PsliH0m0rSnpXHDG2cflUpFNW/g rKrnXWPtAa9y1Ns3jMotD3npuU9EyQvVtSrIxJiSJBm5BLhofb+ezV8ajKXuSiSZnwtG G1l+53S3XVKZ0UMippHKLTudbEsycLMD9LcIyAhKE6W/BIHuK5ptkuWHe/YwnHbw7pPQ QY5lJ4rkLnb2mrB3cIaSAU+u5bAFLQ7oD9kR16WRRjElHj43GJ4726FBX5m0p8zpnbtQ 6C15xHkOPLjA4oBk0sAgmE2qOuU1nD2jnEJPkWxR4UFr6zDaonpBgkZhAnc7pcSnstFI Pdeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gmEHeYY9IxtEv7acXzK+EsVXEYGbLWE40bwPjEV+sgg=; b=AejDl8DYLEOZdoSMi1QJrRyK4JSA1E+PKFL/E8lks02FFwlewfMsvbihGtAdOADVww vWgGZdmS222Zg+X1nXfAQF1QvLjsGL2bHQNUpT18kUDHUBx1UNtmX5k8+p+yA1yCdIxK cvXmDEDBw034vT1lwI9ndmOTnclpGImYcesbr1yuK+8U5kE12RT6Xy1V9+wbhAcscV92 AEq2RFFm7LZlC7aU5qQReVCOtyIBpLkq4c5B4KyWAMPTFilwoMVCS0USFjMhRMOuzbSB 9am3DsMAnw1nuqC3hm7PiJU7CsBb+WSAzCay4WT3gVlNwPzmtQisxPqwKlkdbSI73mQ6 skSw== X-Gm-Message-State: ABuFfoi7bAVUo3p+or7AWDu5Ud4wOMf9paKFGzrVfbMEEUprdtsXOePX eWyxALppxLoWP+mTNhXv+ixa2g== X-Google-Smtp-Source: ANB0VdalTkxcVlFQ7DvPAfBjMeQqyt3wRVglDERNsjjncaIP2Ywcu0uwymzJl7B2C3jOdWoTGZT00A== X-Received: by 2002:a1c:e00a:: with SMTP id x10-v6mr5953217wmg.58.1537514970522; Fri, 21 Sep 2018 00:29:30 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:30 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 03/22] nvmem: use list_for_each_entry_safe in nvmem_device_remove_all_cells() Date: Fri, 21 Sep 2018 09:29:02 +0200 Message-Id: <20180921072921.19387-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002941_182070_409E0F13 X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Use the provided helper for iterating over list entries without having to use the list_entry() macro. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 72313a1d215f..0e963d83a099 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -308,14 +308,11 @@ static void nvmem_cell_drop(struct nvmem_cell *cell) static void nvmem_device_remove_all_cells(const struct nvmem_device *nvmem) { - struct nvmem_cell *cell; - struct list_head *p, *n; + struct nvmem_cell *cell, *p; - list_for_each_safe(p, n, &nvmem_cells) { - cell = list_entry(p, struct nvmem_cell, node); + list_for_each_entry_safe(cell, p, &nvmem_cells, node) if (cell->nvmem == nvmem) nvmem_cell_drop(cell); - } } static void nvmem_cell_add(struct nvmem_cell *cell) From patchwork Fri Sep 21 07:29:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD9B9112B for ; Fri, 21 Sep 2018 07:48:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC6282D8C6 for ; Fri, 21 Sep 2018 07:48:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A07462D8D0; Fri, 21 Sep 2018 07:48:40 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D0AE2D8C6 for ; Fri, 21 Sep 2018 07:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fBjIzu9HithaCJS7diMsBaDn7/MKlJDJ0750QWLeYcI=; b=G2qfwlzSFlA22l+CR6wrwobjWY EFbZP9RaMstfsOQYG29m2K7Z6N5RhVXBmiu/YAOIkqHsVy8ktipnFp6ceHjVQKG4fL2+iW0B0qU35 qTopaabBue0tCQe0p9lOvtzPLW9b7uXZxWughQg8GP2qjwQic/Ja9tx6gQZ67X2YjdVn+6o0B3BRW xaYWtEUCwc6k7J4ZeUt4idRuxa5bChg5e1tDcjF8zk0ElnchxYzbuWkQqAXOuAntIxsNbAxYcMROF 29PSAh9w0wkUvEG1sPl0FPuKO3sWXxQmB/b4AmLO8rcCNk5v4m7SG5wnVCQ9WR+NQKnk9ibhJyiRX qPSdjtIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3GB0-00021g-N3; Fri, 21 Sep 2018 07:48:34 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsl-00066u-L8 for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:57 +0000 Received: by mail-wr1-x443.google.com with SMTP id j26-v6so11802322wre.2 for ; Fri, 21 Sep 2018 00:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rrkXqSITKs+bXSvh4K/fOwEuHASH/0tAlKDmrUdOv7o=; b=Nmyx41um0e7xupLaKrIDpj2WKtTeI6umZiADdUYg+ScHh9Rcid7FV29qoqnh+fjKlP 4lOFYK10fnECkDtgq82jNz1AQ++hDkeVy4rl1CGCPYFSZFKE05AvmFL7FbU1YBM3SKjx IM72FdmyXtzA4RMa7SA0XQnQ67sK9b2FIMsCZ1kWm7cJS4xW4fc5pdMpvAJoCdoFbtdc t2+LpzTXSMRaBRYVS0PUx8qL9zFMlAIFuD2y9e8d0WP4UsQcuN60WyMGIuW2G2nN8Ux/ QNC0FpCEv8NFslCGj02khu6oxY4EbkfUBiKlKdMjeVPY4QHH5GlIENU7WrpG3O8FNQKn wV+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rrkXqSITKs+bXSvh4K/fOwEuHASH/0tAlKDmrUdOv7o=; b=gX70dkd/KSaYEMgwRIpczG7Vkbx27OUqYsHlqQoaD7etixMm6/I3EDODu4e3+B8LgC OcyKX7GbYJPChvP/x1cmEotuVC/AHeQcgsUREpDJkb9znvyckw367zrqnIYEqEXBLE/m U9mY+1OxDUalkwUh12cqpY4nS1Wb0Mu5eFXOQ4t6gMw6FDup2biirIlC7Ukp7TM6dvtS TjfBfav78mOnoZAGhuV3sCUF6gw2mBDoUBnO+Ur3a/C6LPhfCW9D0FzDNhX2Cu5UOfJE /2BQI3a3fxX1COjXCP/1yArpM0NyQY0WzFBGAV4Y+l+kQEYjMPDkDCxzpQ0DOrjIqGdE Eqyg== X-Gm-Message-State: APzg51CwBRQdlgvLM5mursb7wyWoCOkBzQqgRZ4VxK581S9Ox0XwdySV b6OL437+SR1B4/l+37DkyAxAAw== X-Google-Smtp-Source: ANB0Vda2CrwffrLvwl2u80N0gqL2x1jbTzX02dRmDJRKRGTYMF2A/2x9lEVpqA9qCKuQYAvXu8Mjhw== X-Received: by 2002:adf:fc44:: with SMTP id e4-v6mr10262811wrs.9.1537514971870; Fri, 21 Sep 2018 00:29:31 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:31 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 04/22] nvmem: remove a stray newline Date: Fri, 21 Sep 2018 09:29:03 +0200 Message-Id: <20180921072921.19387-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002943_737609_2E361D52 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski There are two empty lines between devm_nvmem_unregister() and __nvmem_device_get(). Remove one. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 0e963d83a099..1ced9caa811b 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -613,7 +613,6 @@ int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) } EXPORT_SYMBOL(devm_nvmem_unregister); - static struct nvmem_device *__nvmem_device_get(struct device_node *np, struct nvmem_cell **cellp, const char *cell_id) From patchwork Fri Sep 21 07:29:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEACA14BD for ; Fri, 21 Sep 2018 07:33:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96AD62DE96 for ; Fri, 21 Sep 2018 07:33:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88FE42DE9C; Fri, 21 Sep 2018 07:33:40 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FB8A2DE96 for ; Fri, 21 Sep 2018 07:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XKEyYWC3SdtsP5LWi1sULZ60AkJSh9v79POHpElnacQ=; b=PULckkN1q0erZfrDBB99fV4AHj QTUuY+K+T8X33hhGwGRqJmZe3Fl96nFyVlJghii3oc9zrqV4HQ+xgGrke0b71uC0Y0mPfP9a7HaUi 4ZJPwzutv6bh63KfiO6ts9792saIdeYoRYL1KxL8hCdA6R9WD5FGE11z1RGepknVd3+nMEje5xX38 4r7kkVrV79wl0lw36mjlX8VqAiBXk0/AK2/XBiZ0aFx14M3drAJBQSsF3PyR0vI+Df77PL2SAYpX1 zVPsYp8FZ6fT/YOgD84jKHELyjRkUBTzXTt0ynvSNN3mTKavLzXeHvbqtayWgvaqTbCwlvDn+nER0 OXMHQ4Wg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3FwP-0000G1-65; Fri, 21 Sep 2018 07:33:29 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsj-00066y-3f for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:45 +0000 Received: by mail-wm1-x342.google.com with SMTP id f21-v6so1924929wmc.5 for ; Fri, 21 Sep 2018 00:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d9TDNBlE9LOCCIoo/ZC3FoSnNdXa8lDWsSssw/xuKi8=; b=mG3uP22uDBcDg0Edcn7LKupQ+Tafi0s7wh9UzjW0wwgHHmStkCV9AYiWTlnTMq/iE/ PnTZgifm1yFLWQDLuH3d2BwmEGmre4VLHCrWCUcUOeg4+pU3zfdHjBn33IqOelhi0B++ GIONRtawGkju43VirDjuFz/JuhkdCqBpLvLQnYPu0ta6VMOoHMSDnxaFhdL2ffrbSAhr TAXa6SzftNyXHrwPOGlHwkvyg2rVu4eJRVy4rkARryBH9SyKjWXzY74lSzxGX4IEaAzd rShsSOy6NcK3bLDi/IzvaS+xZJiHHk6d2e1wWZDaZELcpM+3VcFhRDXlPXw2VxKUzKBa 64xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d9TDNBlE9LOCCIoo/ZC3FoSnNdXa8lDWsSssw/xuKi8=; b=IufSR6rPXrvey190fcGoJyBeqzXEBSip2kYfNuPVqPgrKD1fPWLd+ovVe/Y7tZlt68 yIgkpOg+nBSCnD/+M0NNx+a8evAtSB90VzcEr205VuW8E9ca8OoFeXGxRLsNQvqdtqe/ iQqDBhpfamMsF8nfHRlBhAbqwPSJMBrI47welCDAvjq4Ku3pdHW9dCS1xAZZ5m8HiBg0 3vLeudjY0wQmvGJVvSk62JNXsI6KIPs9CGIEPDkS/jMSS/iQemv31nYEOVITzye+QNIL pCVDKPZXP5LMYzyFXn8YDcTkOhlKp1kivrW0m9seGbcMiRIb+3VWfISB6jtu/gHMg1/f 3Akw== X-Gm-Message-State: APzg51BRW/SLt4+Cb2lPj/49X+uMMvhYNR8itCYu/1/qGGCIW2IjIhL9 f1xxYSgd5CXoRd4vgvmh3sMu1Q== X-Google-Smtp-Source: ANB0VdZX8LW1YXBy5fOyahMvBiRYl+R4D2EPZHAWtdzv4huEjBrzMnaS+4vktR3fFZyiZAvbYbFF9Q== X-Received: by 2002:a1c:40d5:: with SMTP id n204-v6mr5923803wma.44.1537514973217; Fri, 21 Sep 2018 00:29:33 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:32 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 05/22] nvmem: check the return value of nvmem_add_cells() Date: Fri, 21 Sep 2018 09:29:04 +0200 Message-Id: <20180921072921.19387-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002941_182062_B6B2B9BE X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski This function can fail so check its return value in nvmem_register() and act accordingly. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 1ced9caa811b..0ef84441ebe5 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -512,11 +512,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) goto err_device_del; } - if (config->cells) - nvmem_add_cells(nvmem, config->cells, config->ncells); + if (config->cells) { + rval = nvmem_add_cells(nvmem, config->cells, config->ncells); + if (rval) + goto err_teardown_compat; + } return nvmem; +err_teardown_compat: + if (config->compat) + device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); err_device_del: device_del(&nvmem->dev); err_put_device: From patchwork Fri Sep 21 07:29:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6FB6814BD for ; Fri, 21 Sep 2018 07:30:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 515842DE4A for ; Fri, 21 Sep 2018 07:30:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 449E62DE50; Fri, 21 Sep 2018 07:30:04 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E1BB2DE4A for ; Fri, 21 Sep 2018 07:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KAhHyESB9K3TZXTYLGXnDWjk21hvaM/s6dCyHhdbD9s=; b=sIRot4yf6FkP46F5xxvezkn9/U Hi/2Ba+HyTc/eTnpi5EszHgHTr7D81aT9eP6Exu6Yr1U+2Hqub3swjp5lreQuCEkDcfGLSo1UWOuY hF0qZRl1e89JnT0LUp3OPpnvhNkq9HNf/ofJRlTMJiX1rUUeQAl3cKrN98ZGZ4K11WHUTyF72ALM/ u65mNzXdL9EKhodL7/qzA5lVEalqkz3aNQr7/aEIpBeMNqTqiK5/plm1Ak+I4F4SFsaCITXQOMuf1 3SQc7s7G84q/B3YQOPpXUbapxsca6vJ5BQU1NgxsnOKKPEOE11hTn7woaBkPx8JX1NKhbqWKzMoF0 gfC07kAA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsp-0006Cd-6l; Fri, 21 Sep 2018 07:29:47 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsh-00067Y-BX for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:41 +0000 Received: by mail-wm1-x344.google.com with SMTP id 207-v6so2019447wme.5 for ; Fri, 21 Sep 2018 00:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qilqxEjxudzJVMWNjYeBFxyC20AgStI3tn0cY3uUaXY=; b=QXLJacYotp0D8kOLUA+bKuhvbsyrcLzt06gEKl1jD+g/f1Wku5M/X+HrlSDc5meezh io6rBgQZy7ljVZdCzk9MPu+93g20LBgJfF1P8idJFILBp96pmVPZ2f3X9fCUR/jaXoK4 tp6pJlfsSN7zV6RH3IP1uT2IsSY4qcOaSDpKrxVfDXk/x7MRussjNgVGnCkyarSb44f2 bXnHszeqAoYQY9XiXym4aRoQn6fRVzXQwYeGjvOnuRWyHRHBz5tJutx40ztUG1gH7z7A FKUHLYyP+r+5xaS/ILV5tJE4tPUxzlxAs/bcV6ayelAOGSTQjDTJpqDoPLjTDLI7Z0PE q6RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qilqxEjxudzJVMWNjYeBFxyC20AgStI3tn0cY3uUaXY=; b=gwTXWlz0NcMpD20AWAm4+YcuqgCdfzmd1ag+zfl2XJDrWFfAgxhsHL2wxKL4rTRWKV 3SDT/luM5M6VIGAdj0aaVru4NJK/fRBM/Jut8Tg8NVAUt+e5aJpeXOWG+XbSpyIS8MCR TkJHYVX/Ql5puOQEkyUy/yd3qvcnkMqaZ2DaA09zyeOMoav5Wosv7w4rkMcl1PpQapiP 0DXNcQlwELspXTuL0/WnjtsBknLgMcWXMA6fYo0uXPWSmhcnDPLPeKeqrgrjzs65cxgc 6yYlDYxupgw3ZajGzr6FiFRGF7ef0T8m5QKau1eO9GCMS1y8Pu2YTiFxYeak2pEFpEM1 6xIA== X-Gm-Message-State: APzg51Craztl1B9bjGKuTpoTShNU9fYKm2RwB+Iy8YDmG0rrev6eFVyv ruv7HhDlKB4FgjvI2btUWTUluw== X-Google-Smtp-Source: ANB0VdaTn/DLgZNz0Zxqs7v0Tm2x/PV3TIyKd8uAO0OV0kbEkFA9v26GB6gwPeIGE8RTjSPISkb59w== X-Received: by 2002:a1c:610b:: with SMTP id v11-v6mr6186846wmb.20.1537514974589; Fri, 21 Sep 2018 00:29:34 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:33 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 06/22] nvmem: use kref Date: Fri, 21 Sep 2018 09:29:05 +0200 Message-Id: <20180921072921.19387-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002939_406869_D6776042 X-CRM114-Status: GOOD ( 17.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Use kref for reference counting. Use an approach similar to the one seen in the common clock subsystem: don't actually destroy the nvmem device until the last user puts it. This way we can get rid of the users check from nvmem_unregister(). Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 0ef84441ebe5..920b56e500cc 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,7 @@ struct nvmem_device { int stride; int word_size; int id; - int users; + struct kref refcnt; size_t size; bool read_only; int flags; @@ -463,6 +464,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) return ERR_PTR(rval); } + kref_init(&nvmem->refcnt); + nvmem->id = rval; nvmem->owner = config->owner; if (!nvmem->owner && config->dev->driver) @@ -532,6 +535,20 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) } EXPORT_SYMBOL_GPL(nvmem_register); +static void nvmem_device_release(struct kref *kref) +{ + struct nvmem_device *nvmem; + + nvmem = container_of(kref, struct nvmem_device, refcnt); + + if (nvmem->flags & FLAG_COMPAT) + device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); + + nvmem_device_remove_all_cells(nvmem); + device_del(&nvmem->dev); + put_device(&nvmem->dev); +} + /** * nvmem_unregister() - Unregister previously registered nvmem device * @@ -541,19 +558,7 @@ EXPORT_SYMBOL_GPL(nvmem_register); */ int nvmem_unregister(struct nvmem_device *nvmem) { - mutex_lock(&nvmem_mutex); - if (nvmem->users) { - mutex_unlock(&nvmem_mutex); - return -EBUSY; - } - mutex_unlock(&nvmem_mutex); - - if (nvmem->flags & FLAG_COMPAT) - device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); - - nvmem_device_remove_all_cells(nvmem); - device_del(&nvmem->dev); - put_device(&nvmem->dev); + kref_put(&nvmem->refcnt, nvmem_device_release); return 0; } @@ -647,7 +652,6 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, } } - nvmem->users++; mutex_unlock(&nvmem_mutex); if (!try_module_get(nvmem->owner)) { @@ -655,22 +659,18 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, "could not increase module refcount for cell %s\n", nvmem_dev_name(nvmem)); - mutex_lock(&nvmem_mutex); - nvmem->users--; - mutex_unlock(&nvmem_mutex); - return ERR_PTR(-EINVAL); } + kref_get(&nvmem->refcnt); + return nvmem; } static void __nvmem_device_put(struct nvmem_device *nvmem) { module_put(nvmem->owner); - mutex_lock(&nvmem_mutex); - nvmem->users--; - mutex_unlock(&nvmem_mutex); + kref_put(&nvmem->refcnt, nvmem_device_release); } static struct nvmem_device *nvmem_find(const char *name) From patchwork Fri Sep 21 07:29:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 776DC157B for ; Fri, 21 Sep 2018 07:48:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67CE12D8C6 for ; Fri, 21 Sep 2018 07:48:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BD8B2D8D0; Fri, 21 Sep 2018 07:48:36 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A51472D8CD for ; Fri, 21 Sep 2018 07:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/+1Tv2CThbK9LQSwtUSMFNqkF5HIyzBheAFOHuFADjI=; b=KE5SEtwI1oTKC79db3E64Xkw4y 0pohw7fteoQj26Bh5wGCBY7+nnlzLDZCAY+F5PqmsvDF4Tu7qGmv7gxD7MM4ZRs8SjZzzydJKG9EP 85apFbwSA+owrTUmNLyKGe0gHn4psSrjlaf6olBGdh5IyIgS93fYJMD9GYqL2j1eisC7ZdSNvMS8N eme+jLO+2z26KacmlfNUEKFdtSnAH1sbKOdakATgV3+lKdKHcDtcxN3hdAo27qZ5+TQ4/wEYQV+wL V1P47QhfH1fXVxJooubLBWuO2zLAdhXV8NGvIb0ch7GnEySGpBIV6nzvtnOR3iIm+qZYf9Ei4OPo6 ACc/k1vQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3GAv-0001zM-81; Fri, 21 Sep 2018 07:48:29 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsj-000683-3e for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:47 +0000 Received: by mail-wm1-x342.google.com with SMTP id q8-v6so2035897wmq.4 for ; Fri, 21 Sep 2018 00:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7pNB/YkN9hno7KdXunbmQOYsXKCGrUI9TMuetzklSpo=; b=e+TNNLb3r0E+A+rjJohde9ukPt4XsdbaYNspA8fLg1x7J285Fg2XWo8/NGkqVaCWuv MS4ARjZy/MBbOvAHzEG6a5fS8LVda1DzH4Fie857AGtDztGUJEAR1uLLLpSXWNUlJkng wRyWNL06Sk9VVgLHPOaXXqsXH5btz959Ke3t0oEGwI4gAx6oi3J/tOdM5IMp6VOWsxOv KRX6i324o0q2jozQDph3b/lvJE7ABxysJ385tzC2kzVh+VcuDczjQRP+5pigWYS02xBC badCseLVISinBgRzE6gZ1OC/acZbu9osg0x0DwsDbaS2SUEGP106ioIh9ko44DAnJXzB M6fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7pNB/YkN9hno7KdXunbmQOYsXKCGrUI9TMuetzklSpo=; b=O+Sv74s52iYABy+oiqD+ALHVxW0Dk0TaF/UA725Qz81M+qNrN66/1Z9pVwpknkyCVM 1Re02jxTQ4z+C66YQp+dpo0otTY1z4Eh5wN1qlE0/VG1aolhZ5wz6+p8ZHUNgLjTCNBp 2Ij80naBL8Veo46MpVtlnaBP/L0EMtkWTtx66I4d65EHais4xIqUr2K1GXCbBcR7i0xV 0nzixdy9SXcINzmKQCiceu1oLuwo/zom/ZAMj65y/WgZFLPxeurXS2SoVlNAbb0Ave3J Y9JPZyNEYy7j/9EyKl8DnhOhWxGQL0yKdxOovx9CLY8YkrjznoWXwjOH35KhMsGat6MX PWuA== X-Gm-Message-State: APzg51A21sUNvzRsINI9wX2WIjcT7QY/MxW4Kz35E731v/fEqrfpyU4L +i6HlnrHiy4DH/3ZvWug6VvgtBpWtKE= X-Google-Smtp-Source: ANB0VdZOPAkkhry5s7XS9BMeBWEjzcYT1eW4RHLwems3GiFvysccgYweRBEimNI439E7/4sYKecSkg== X-Received: by 2002:a1c:4d09:: with SMTP id o9-v6mr6166328wmh.134.1537514976009; Fri, 21 Sep 2018 00:29:36 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:35 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 07/22] nvmem: sunxi_sid: return -ENOMEM if kzalloc() fails Date: Fri, 21 Sep 2018 09:29:06 +0200 Message-Id: <20180921072921.19387-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002941_226635_52BD2D48 X-CRM114-Status: GOOD ( 15.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski The driver currently returns -EINVAL if kzalloc() fails in probe(). Change it to -ENOMEM as it should be. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/sunxi_sid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index d020f89248fd..4d0b7e72aa2e 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -187,7 +187,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) randomness = kzalloc(size, GFP_KERNEL); if (!randomness) { - ret = -EINVAL; + ret = -ENOMEM; goto err_unreg_nvmem; } From patchwork Fri Sep 21 07:29:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 015C4157B for ; Fri, 21 Sep 2018 07:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19B528E70 for ; Fri, 21 Sep 2018 07:37:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D59572DD1C; Fri, 21 Sep 2018 07:37:24 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7098228E70 for ; Fri, 21 Sep 2018 07:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QIHig6eAn3C7zWzy65C+r95ky0rJNy2GSO7hEMK7NCc=; b=XOo29xaV2mqeS/0AeiXk3ICiKW duB8RMCmMgby233L+N+z1Iqg22T26ipx0F5GokX5xJJLgZrI34JkYusjPCnrJd4J3JD0VkGtmlJpM X4QMoIw5Efc76QoUk7IielEGGgSXmGzoyn0oNz3yi1cDc4u9zYvi42OE1bkk6sX2MXlAIuTv8Eyb1 bAMm1OxDWf3IpoJsXGUIm/92ptPw6PaF7OeJ/JslEdUNCgdB/aZab6DFOp/T60Ra6GAeJUVJbXz4X UXNEskguPxntFfnYubpe10BEBNfN3g1Gw1uQwcWYRUb5BBlDT4bimvVTzvdLmx6oqYd83uEXZW0Ev Ulu1hhQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G00-0002sZ-Px; Fri, 21 Sep 2018 07:37:12 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsr-00068D-8E for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:59 +0000 Received: by mail-wm1-x341.google.com with SMTP id y2-v6so1961139wma.1 for ; Fri, 21 Sep 2018 00:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M9taBHuR1Z2o6Tp/6FUEDxrf8r9YUt6RGonYwMvTT5A=; b=oCugQ6gwXvRsc2UIC+RG8MmONx3NUkjg4a/p0bGHG9TO/wdlEITqtJcK9Hf2hTGR8T uCo+rUvHzCpgb2AMs3g158285BvcIYIQgMoY3XIN912fAmqyn5oCHFhakNwfnDeK9VRR x7LHqwzjGm07f/UKA4Gnm24/3d6iQ1gUfQaM0qKWTnEiLH8FcCXqicnl1o/znySoL2tx Z8orQBxVbK9Rr8AlwCRLpR+xB/dziBlIcW2aZgibwBihaO80z0IhmuWmI3bKdbWkPSZU qpLbHvyKpCh0PwAp/RGouihpu60UwmgcwIIBZi3zhzAjmbCgzGRM2KQMVONI5VR7TnIR gA2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=M9taBHuR1Z2o6Tp/6FUEDxrf8r9YUt6RGonYwMvTT5A=; b=pHl1HpzQU/4NAmWMiO8r23vX4ZFgsZbPVAvu7WfGGyhi7DvKtegxaHoPpQHp209NuH H73JV5ZrgXAKeB9rCGVlZxJYfGWVrKp5Ym/K8CkcAXcu7soEN3Q6Dq7ul4Mi7yIyXL0J R7Vg5Cb3FjMfOSfAqZ4ZxyCgwb9mjHZOOUGhV4tVusjos/18a8z2aXlTm0eBwjdzLFgo AbWORW14rrYaTCPWAFAbKaGrj4/jB8k+Y7VxX3pDGzII3UZ03uKvIVHvxDEgQ+1YE8j0 vmRgNmhp20fli7Enov/agYYsjJQ9Zv84X0sNyx+E1c85l3lcw7luS9JJIq4svoZ3KI64 zCGw== X-Gm-Message-State: APzg51CcLVa6OOXSTdiTRNv5vpPEZX9PCEtc5KI5jcmSBpZN8C4HUQep a2VloE47u1+z9rsuSA0WY0vLAA== X-Google-Smtp-Source: ANB0VdZcGTpFp6UI558LMYBQU6ptf92xWFRytC5PU27p0YcZqQ+G9hvBW1PA29Jub+7tlVOJKqSXEg== X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr5955726wmb.14.1537514977318; Fri, 21 Sep 2018 00:29:37 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:36 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 08/22] nvmem: sunxi_sid: use devm_nvmem_register() Date: Fri, 21 Sep 2018 09:29:07 +0200 Message-Id: <20180921072921.19387-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002949_346565_16D68BB7 X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Use the resource managed variant of nvmem_register(). Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/sunxi_sid.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index 4d0b7e72aa2e..1310f8af37f8 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -181,15 +181,13 @@ static int sunxi_sid_probe(struct platform_device *pdev) else econfig.reg_read = sunxi_sid_read; econfig.priv = sid; - nvmem = nvmem_register(&econfig); + nvmem = devm_nvmem_register(dev, &econfig); if (IS_ERR(nvmem)) return PTR_ERR(nvmem); randomness = kzalloc(size, GFP_KERNEL); - if (!randomness) { - ret = -ENOMEM; - goto err_unreg_nvmem; - } + if (!randomness) + return -ENOMEM; for (i = 0; i < size; i++) econfig.reg_read(sid, i, &randomness[i], 1); @@ -200,17 +198,6 @@ static int sunxi_sid_probe(struct platform_device *pdev) platform_set_drvdata(pdev, nvmem); return 0; - -err_unreg_nvmem: - nvmem_unregister(nvmem); - return ret; -} - -static int sunxi_sid_remove(struct platform_device *pdev) -{ - struct nvmem_device *nvmem = platform_get_drvdata(pdev); - - return nvmem_unregister(nvmem); } static const struct sunxi_sid_cfg sun4i_a10_cfg = { @@ -243,7 +230,6 @@ MODULE_DEVICE_TABLE(of, sunxi_sid_of_match); static struct platform_driver sunxi_sid_driver = { .probe = sunxi_sid_probe, - .remove = sunxi_sid_remove, .driver = { .name = "eeprom-sunxi-sid", .of_match_table = sunxi_sid_of_match, From patchwork Fri Sep 21 07:29:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFA1F14BD for ; Fri, 21 Sep 2018 07:34:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C542B2DE9D for ; Fri, 21 Sep 2018 07:34:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B56422DEA3; Fri, 21 Sep 2018 07:34:29 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2729A2DE9D for ; Fri, 21 Sep 2018 07:34:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=G/OgudrqnlaJKDPcEsO1ngPAck7SlmjDTUB/eooLbTU=; b=FCOf3HRXuamGUAMIWCthzUrNFu TQrvCL3zlCvIPeuGIJX92woaTkErNa1V+nIZjh9DS5EzVCAiAkz6QAtqERQk1qo4WNatrNzL8BYkX HRBkAomFCpzAUJEMqSxoZQ+mDf6+UGK922l7fo3A+VIgA+Ujxw4xgapUIy5Xr+CLHH7xKvcGSPhpR 3QW9E4ltG3gxa4TjwEqeRz8PYYiitQUbOlqmeUxyh2Edx/H1fojJyntPZInMPhxAWshFdDQYdFpvW pY08gjFdRs9JQt5/nqK3RB3wXeEiCFABuC5Y+X5EmF6LtIDTTg835RtquEtkhMhKJwaXd6TKE1OMy 5I5HjsxA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3FxF-0000Xs-Vi; Fri, 21 Sep 2018 07:34:22 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsh-00068Y-VC for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:45 +0000 Received: by mail-wm1-x343.google.com with SMTP id r1-v6so3413458wmh.0 for ; Fri, 21 Sep 2018 00:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1PFkzde7HIbembuPSuldz/+wF0MJkUfGiNxQy31YmBk=; b=i231+IxAyqeewuI6FRJLxRAlLAAwSFCHtXsWp5PlllpgdCAX9yYhJOYRtYLwrw3Zbm i5S3lQF6GbryZORNYmAMDXk/2rdksU1fxf/YEEcC4/j7TH5vd1a+PmF6jGDFDQBZ+cAs xcUZKD2FUBr8lzTBPV/4oEDgS34u8LkHCYqNIAtZWsKQNA2xpB+3WHWxb9p/DoCw7fKR 4CGbbhD+qvNfpBIZYPZqKBIvCp+BkL9iTTpGTOjnvZLuxgRENfQX0IxBBhgN6i1W6yiI uHAouoz3llf4otVEbJHgUZRiONiJgzP+1o41X5q7ZDnjXNWjfPDnxKvGoTYLQtxfHMno MrJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1PFkzde7HIbembuPSuldz/+wF0MJkUfGiNxQy31YmBk=; b=Zn4bg07o8gd1RcFratJQKeXBSgNR6hjA7J1I9aDSaFJSh+UiwmzyOc3BvGEkxSy9il PrtFhl5nHi7LmDp6JjRqVq4Nmb7YRW1rb0YbL/2sIptBBGeEZ9i1WkJAJV+G6UgsaaDT 5aIrNsUJGFzchpRtAZyNy+TwUrW/bn5rWEILDZyjj8qqexApcfyRCvFT8Rz3qP6aAVKj /lDi8IodxLTRX8vLo3nabk3IIbgwYxojroEJbz/3x55ycz8jb4eLZG9ekWDvN8TL8RPO Uj/rWe1luWS8EDuziGtQdkyBQxTx1nZxguj2Sw4w82mbYSCKyiLiqQrACWa8MD9KT8eu 9Msw== X-Gm-Message-State: APzg51C+0e9+P+fbRGKHB1q0cYLVT5iHhEbd2LKzc3dlm1/YENsNgUtq ZH2T3ZBsFTmYmZ4jiiv2FFGKLg== X-Google-Smtp-Source: ANB0VdaaLH/AaEF1wpclJhrCO36R7z9db1y8MZkKgRfgocLQ07rqwvgauUQ8+ijJCPn1w0aFzQyG5A== X-Received: by 2002:a1c:6386:: with SMTP id x128-v6mr5762292wmb.104.1537514978651; Fri, 21 Sep 2018 00:29:38 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:38 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 09/22] nvmem: lpc18xx_eeprom: use devm_nvmem_register() Date: Fri, 21 Sep 2018 09:29:08 +0200 Message-Id: <20180921072921.19387-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002940_043932_88D0C227 X-CRM114-Status: GOOD ( 14.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Use the managed version of nvmem_register(). Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/lpc18xx_eeprom.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/nvmem/lpc18xx_eeprom.c b/drivers/nvmem/lpc18xx_eeprom.c index a9534a6e8636..b42dbaddb419 100644 --- a/drivers/nvmem/lpc18xx_eeprom.c +++ b/drivers/nvmem/lpc18xx_eeprom.c @@ -236,7 +236,7 @@ static int lpc18xx_eeprom_probe(struct platform_device *pdev) lpc18xx_nvmem_config.dev = dev; lpc18xx_nvmem_config.priv = eeprom; - eeprom->nvmem = nvmem_register(&lpc18xx_nvmem_config); + eeprom->nvmem = devm_nvmem_register(dev, &lpc18xx_nvmem_config); if (IS_ERR(eeprom->nvmem)) { ret = PTR_ERR(eeprom->nvmem); goto err_clk; @@ -257,10 +257,6 @@ static int lpc18xx_eeprom_remove(struct platform_device *pdev) struct lpc18xx_eeprom_dev *eeprom = platform_get_drvdata(pdev); int ret; - ret = nvmem_unregister(eeprom->nvmem); - if (ret < 0) - return ret; - clk_disable_unprepare(eeprom->clk); return 0; From patchwork Fri Sep 21 07:29:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F03D414BD for ; Fri, 21 Sep 2018 07:38:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D96122C653 for ; Fri, 21 Sep 2018 07:38:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C99CD2C68D; Fri, 21 Sep 2018 07:38:05 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D8812C653 for ; Fri, 21 Sep 2018 07:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=V4U/VlmG5JWS3uODLSAR0HE88DftOmP2cW2rKHjWQRM=; b=b/VDdgmU7mwe6eEzZI8BsM+AHY 5WKEVT8yPK47rwoYMQjKUQpMqxIqBb6tmuhhrYBb00Mkb2b2Il2306exjlG2zRhetaIXtHFUDcyiO 8QGpLO7iROMS21cJHyk1WNBAtcp/UwQcrjxjZ0/b30aLJkI6P0YjzO087ybtG13mGgH2JVezKy+kw 4QbdPfmohReMKRq+wNnxeCW+SZDXkoOtmQYQDVuc2n9VsnM13ojRCAEbUtEkIa6yb1LCn+3/2PkEd N0xZVJcQeyvuv3VQU/dp7AV9y7sIXhDiUzstSQfJgETD0kEeMnIgblutSaaa7aDngiV53WtqY3Zdw AfT8E6Gg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G0g-0003DF-Up; Fri, 21 Sep 2018 07:37:55 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fst-00069Y-8v for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:29:59 +0000 Received: by mail-wm1-x344.google.com with SMTP id f21-v6so1925253wmc.5 for ; Fri, 21 Sep 2018 00:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=enYwgS0Z/OX0ykxo6KT1YIz+qVBOPAuLng+TvhpgC2Q=; b=ax9QBPqEHiCyAwwF9/F83G6RkY/zwF0zAVw4bJMCA1u1VBs4Vy6ldq+YfmdcLOfzO+ otZHdHSQo7uKd68dRs9RAOWOR7hV3GfJZ/mwv4p7GArn5WVEicO5U886Tt5k1XQk7IaY 4e1AmPKXXzgcwKBnbyvkevLCKKG/0J3hNSMG3wQMN+1GpLYdQ1A2iPSjKD4lF9/WlO3y qV5Es+vp7uDcxclX5NZeDbY7v9ZHHqd33JWiHlxpPKramRuVO98kBj2Fw+tRWoJwoUly /3Ukifj1mwgxhNuGmDv1NnPN++uzZeqaG7JzgXJfHFBKEuM3NmM4ds8lybkuar27m/Xe cd3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=enYwgS0Z/OX0ykxo6KT1YIz+qVBOPAuLng+TvhpgC2Q=; b=o60Uj5imXuWKTl3drzlglumitoFtC6GI9a7sS4frVzCIdrn9d2qHOodNO5ofJ345DS QnLbHIuqrGF3BdgZNJ+bpPPAq7LmBuvpBXmC9Da3aPjCZXvJd0YcBFXUVwxbyyC+FeVg BCu08u6mxFQxYp+fpKOf+DZGjNNfnSfTbR3/vsPrIjGq3imnB3zmYjOs+jodQvdYHqnX PtW+YLYbS6zAQdwXwxGXT57dTvufG1M1+BnR/MolPOtWIUjdCUDVA+RkmLpTSZ5LqsgQ 235q4G/UTkDcPCv3VZL/65pyyzDoXjrHV0xVVimVZbicmUV1ByGZr0KBF74yGkbFHymL 0/uw== X-Gm-Message-State: APzg51B6wYpA9y2e+HG4J+l9Ezfa0W/AmYW4HI012QlqcxG6WZ0Fubxu +peWDPd7Qyn/IJDipdYFX72hmw== X-Google-Smtp-Source: ANB0VdYVG3Hut091dxcPYAon/AW+q0CXTIGK9gN4AZuJZ11+Ckt6Rc5TXLYEijShq/9FbJTyefoz8g== X-Received: by 2002:a1c:88a:: with SMTP id 132-v6mr6142987wmi.9.1537514979956; Fri, 21 Sep 2018 00:29:39 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:39 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 10/22] nvmem: mxs-ocotp: use devm_nvmem_register() Date: Fri, 21 Sep 2018 09:29:09 +0200 Message-Id: <20180921072921.19387-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002951_371668_C850BC57 X-CRM114-Status: GOOD ( 14.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Use the resource managed variant of nvmem_register(); Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/mxs-ocotp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/mxs-ocotp.c b/drivers/nvmem/mxs-ocotp.c index 7018e2ef5714..53122f59c4b2 100644 --- a/drivers/nvmem/mxs-ocotp.c +++ b/drivers/nvmem/mxs-ocotp.c @@ -177,7 +177,7 @@ static int mxs_ocotp_probe(struct platform_device *pdev) ocotp_config.size = data->size; ocotp_config.priv = otp; ocotp_config.dev = dev; - otp->nvmem = nvmem_register(&ocotp_config); + otp->nvmem = devm_nvmem_register(dev, &ocotp_config); if (IS_ERR(otp->nvmem)) { ret = PTR_ERR(otp->nvmem); goto err_clk; @@ -199,7 +199,7 @@ static int mxs_ocotp_remove(struct platform_device *pdev) clk_unprepare(otp->clk); - return nvmem_unregister(otp->nvmem); + return 0; } static struct platform_driver mxs_ocotp_driver = { From patchwork Fri Sep 21 07:29:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C209614BD for ; Fri, 21 Sep 2018 07:38:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5C42DB6C for ; Fri, 21 Sep 2018 07:38:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A22C02DBBC; Fri, 21 Sep 2018 07:38:50 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F3BE2DB6C for ; Fri, 21 Sep 2018 07:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ZeGkaZQN8jmyo5GN39GxMHYM9M0CrUdPD328mfkMFhY=; b=jZb++b/2TkbrF5C6DksV5IkKM4 YpKgVJlBSM4MkV5H/D4M3kmQ9QNZvss+TGh1muub5xSFxEYY2e6bG6qGKBlfdhK2maLLHbVt2c1wa 0QMztJoMpj6Jx102lngiUvmF5ED5T+YBK4x8YyjIq25hYzHjnWMrb1/nEfjmPVENeFstJIiO2Z3Uy MSfjmIEm2PbDrmMwHnKBbIy//oFazuSY8nt5MbrUnrDdvWRr4TgbcK9Z8XQpdbBY4DeajUI6hxJMT SZn4/lKaMzGzjGr+R3GkPFYN/2ETchyZOo4B/v4guP6QGnPDc729nJeB/8QaAO5xHWDey7dFZjahp weiS6oOw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G1K-0003Tj-Jv; Fri, 21 Sep 2018 07:38:34 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsv-0006BC-1F for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:06 +0000 Received: by mail-wr1-x442.google.com with SMTP id k5-v6so11776949wre.10 for ; Fri, 21 Sep 2018 00:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z6J0lcIe6xsRLogfR590wyd3HYBi8XsWqZR0RfEWiDM=; b=Akx5S0Z82xq1MbncYzTFkwHgy5iwYVtLczSIMjJbOzn8qoos+tGCX4uj52tFfjbB0f GbS0TX1d/VROuNnrJnmprt3qpU8JmbT7d/UyhtDP6l3YU2fQ/cPLDrG7Msekvy62yjxm 5EfJxIq4NFZdcOU+DrEeV9PylCbJpcUE0jUi4/hPYFGmJKY2VvicKvNivUl1yORaFI5s Ucq38QsllX1rcSrKMWghsdVvFUOYgQJXa6QX8uSe+jxeOYi+1nGcUGo2RddhuFsNIXeX kGtcgKmlLRmPT1aOff1nHRk2hLph2MqbKDtOBe2+0U0zKPsH6rfT/DrLWi1b+qcvhUSZ I2oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z6J0lcIe6xsRLogfR590wyd3HYBi8XsWqZR0RfEWiDM=; b=RWy5zMyA0Mwcz2bMfrMnFTPL4hMpZxmfgfDolkxDQItrycUqeRETavwbuOvL9RXniT qsUXhsWREkBLMqKgqHV2fFzAa3BPXRrlkACccNydo2W7hkiHvk0rrR3e7ZF7Io4ZT4Ny 6829GodLVaZTQ/4w6XcRja8Teb4nIHHwbsDNL2MUnnIp1SvvxSw4sw85Fga3TxeJ8bnC cAgV5jNWG8rVjVdNtNnTKa/Ym1kkcRAi8UG24eGPYddhc2wyVOGdqzpmxUDmVlkKY7L2 l1Z2gDOT1bCvGkHm/UcEfzOOFuK6qMm1FfB+ftbbDd8ZIMyNvxDGh9sIYy20Bv4brrZh L0hg== X-Gm-Message-State: APzg51COIH8pG/FBj0xuaF+H7FoSd76+eBalLa78Cx4yL/feG8J9THfw Fu8iy/YWxwT5WDwo8UVGqlSFQw== X-Google-Smtp-Source: ANB0Vdaq55vrhHmz5f5pWEZkhj14bLhOZoM4CqivPiNClz4+9ymd7vlGk9z6b5ddRtOBnAHIez2TEg== X-Received: by 2002:a5d:438d:: with SMTP id i13-v6mr37187271wrq.156.1537514981276; Fri, 21 Sep 2018 00:29:41 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:40 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 11/22] nvmem: change the signature of nvmem_unregister() Date: Fri, 21 Sep 2018 09:29:10 +0200 Message-Id: <20180921072921.19387-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002953_225447_85541C04 X-CRM114-Status: GOOD ( 16.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski We switched the nvmem framework to using kref instead of manually checking the current number of users in nvmem_unregister() so this function can no longer fail. We also converted all remaining users that still checked the return value of nvmem_unregister() to using devm_nvmem_register(). Make the routine return void. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 8 ++------ include/linux/nvmem-provider.h | 9 +++------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 920b56e500cc..bd14d04782cd 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -553,20 +553,16 @@ static void nvmem_device_release(struct kref *kref) * nvmem_unregister() - Unregister previously registered nvmem device * * @nvmem: Pointer to previously registered nvmem device. - * - * Return: Will be an negative on error or a zero on success. */ -int nvmem_unregister(struct nvmem_device *nvmem) +void nvmem_unregister(struct nvmem_device *nvmem) { kref_put(&nvmem->refcnt, nvmem_device_release); - - return 0; } EXPORT_SYMBOL_GPL(nvmem_unregister); static void devm_nvmem_release(struct device *dev, void *res) { - WARN_ON(nvmem_unregister(*(struct nvmem_device **)res)); + nvmem_unregister(*(struct nvmem_device **)res); } /** diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 24def6ad09bb..0f357d0c1e75 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -70,7 +70,7 @@ struct nvmem_config { #if IS_ENABLED(CONFIG_NVMEM) struct nvmem_device *nvmem_register(const struct nvmem_config *cfg); -int nvmem_unregister(struct nvmem_device *nvmem); +void nvmem_unregister(struct nvmem_device *nvmem); struct nvmem_device *devm_nvmem_register(struct device *dev, const struct nvmem_config *cfg); @@ -87,10 +87,7 @@ static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) return ERR_PTR(-ENOSYS); } -static inline int nvmem_unregister(struct nvmem_device *nvmem) -{ - return -ENOSYS; -} +static inline void nvmem_unregister(struct nvmem_device *nvmem) {} static inline struct nvmem_device * devm_nvmem_register(struct device *dev, const struct nvmem_config *c) @@ -101,7 +98,7 @@ devm_nvmem_register(struct device *dev, const struct nvmem_config *c) static inline int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) { - return nvmem_unregister(nvmem); + return -ENOSYS; } From patchwork Fri Sep 21 07:29:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609243 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94450112B for ; Fri, 21 Sep 2018 07:48:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D4F2D8D0 for ; Fri, 21 Sep 2018 07:48:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78EAD2D8D4; Fri, 21 Sep 2018 07:48:45 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6D452D8D0 for ; Fri, 21 Sep 2018 07:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9uBaKVswk2v7Ge72Hl6SJmaljW2r+meaybxFKXBUt8g=; b=k86e39jYa5GgGqPEeXiDofaxy/ NQEizwDVmC4oA0ccNurlr2PIH8PxxHyNr7tXIdCqyEf1BRdsPLKxPaxBlvVXCmpMznGt77xHSCwzW 7Y8GcJpBuA5gaX4xQRSGlFFoGct9EtQBtM1tN4CXXVXixjZVnjoKa1EU679gjlO1iX6Vt0OezQ6bm qNLWMfWZ6hOl2rFd5Ri/k3XMNaYBZi5NCRZbcw/izTlaoB5FKpf2vfftiQg482KP2gXbqAyo4owl8 tm8U2pYFieurn8JoRLa50sV+4+5YJYuZ7t9bQWSzfIiWGngVqAvBQLcVGmUnYOHgRk9YhcQLNRShN i2YNqfKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3GB5-00024W-CJ; Fri, 21 Sep 2018 07:48:39 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsw-0006BU-JZ for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:27 +0000 Received: by mail-wr1-x441.google.com with SMTP id t15so3887078wrx.1 for ; Fri, 21 Sep 2018 00:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hoddC+Dlb2GKPuc7IWS3Y2zKJ7N6bVfp66wSSHaZPhM=; b=wedoI0GaOk1fft9KPdfKQTJatgnlpJOHFZTUwUalyoKaSQUCBVGYntTkK1tnBKaWSO p+gqH/SHR5/FSwqMIKvNWyDCjHAU/J5kLIk2wq1tCImmMKLGf1hP3sIxhziv5w17sCdz 9SqcEDpsrWmeXhE7kiF/j9Vdu2fcW3WoUlsneeRNnXTdNylQ+0P68kF/uA1jSH1UGEKu sR353docIKiDGoxykJnF+ZnMr4AYS07UqTjunpSOJutitHZfCrbDAbdpYXlg0Qc2PTcO lwaM24IPLlprWSEQFkxNycrRY4EiE3Ql1rre7H9PrxcVIKbGw3RmSjJF6XKLIDljw3+P cDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hoddC+Dlb2GKPuc7IWS3Y2zKJ7N6bVfp66wSSHaZPhM=; b=izUGuKPCllWuYBjnCm+ZPd1hbyYMuwQfAgqO+gbz/btls3G07oq2Ndy4dM2g+0zZbR Y+Z0bmbD3E8VriT+n3OuS1C0FwHMxxeBP1ucp2u4mYBUYmLrhkwfxNWP6Eu88ejrHAup QrLdQc/6UCxBbLY8MQeftYhlZcs98VLjPiMk2jVHXXH3NAXN0nwHAaLSWNWxnaWhqA07 cQkPp1gAcKCrPbNb7lqEExebUS/UEcgliW80Pn7osmvVZ6YDX2CNcaV8aRInMewnt/5l hkHlcSG+hS1ViCi2IEc8F0U8PSkBKPqExQAn9tPCDel28lZG/OkazDyKGGNqEZqtolSf Wp8A== X-Gm-Message-State: APzg51CSRFtG5j6O24vwVy1Nu8008ITbD4Cnk6OohwvtXBM5Y5gYHd1w GwO+RK5FpLoRaRigduNXa824dw== X-Google-Smtp-Source: ANB0Vdbk3aAH8sCSHOW2+wM9qLH7OlLkBrFJQOtd1JE94haxWdwyJGErlZPPRwswdDj/UHUyKetw2A== X-Received: by 2002:adf:b726:: with SMTP id l38-v6mr33391602wre.115.1537514982750; Fri, 21 Sep 2018 00:29:42 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:42 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 12/22] nvmem: remove the global cell list Date: Fri, 21 Sep 2018 09:29:11 +0200 Message-Id: <20180921072921.19387-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002954_725667_1AAC57C8 X-CRM114-Status: GOOD ( 21.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Nvmem subsystem keeps a global list of cells that, for non-DT systems, can only be referenced by cell name, which makes it impossible to have more than one nvmem device with cells named the same. This patch makes every nvmem device the owner of the list of its cells. This effectively removes the support for non-DT systems, but it will be reintroduced following a different approach in subsequent patches. This isn't a problem as support for board files in nvmem is currently broken anyway: any user that would try to get an nvmem cell from the global cell list would remove the cell after the calling nvmem_cell_put(). This can cause anything from a subsequent user not being able to get the cell to double free errors if more users hold reference to the same cell at the same time. Fortunately there are no such users which allows us to rework this part. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 64 +++++++++++--------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index bd14d04782cd..ee794613024c 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -38,6 +38,7 @@ struct nvmem_device { int flags; struct bin_attribute eeprom; struct device *base_dev; + struct list_head cells; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; void *priv; @@ -58,9 +59,6 @@ struct nvmem_cell { static DEFINE_MUTEX(nvmem_mutex); static DEFINE_IDA(nvmem_ida); -static LIST_HEAD(nvmem_cells); -static DEFINE_MUTEX(nvmem_cells_mutex); - #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key eeprom_lock_key; #endif @@ -282,28 +280,11 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np) return to_nvmem_device(d); } -static struct nvmem_cell *nvmem_find_cell(const char *cell_id) -{ - struct nvmem_cell *p; - - mutex_lock(&nvmem_cells_mutex); - - list_for_each_entry(p, &nvmem_cells, node) - if (!strcmp(p->name, cell_id)) { - mutex_unlock(&nvmem_cells_mutex); - return p; - } - - mutex_unlock(&nvmem_cells_mutex); - - return NULL; -} - static void nvmem_cell_drop(struct nvmem_cell *cell) { - mutex_lock(&nvmem_cells_mutex); + mutex_lock(&nvmem_mutex); list_del(&cell->node); - mutex_unlock(&nvmem_cells_mutex); + mutex_unlock(&nvmem_mutex); kfree(cell); } @@ -311,16 +292,15 @@ static void nvmem_device_remove_all_cells(const struct nvmem_device *nvmem) { struct nvmem_cell *cell, *p; - list_for_each_entry_safe(cell, p, &nvmem_cells, node) - if (cell->nvmem == nvmem) - nvmem_cell_drop(cell); + list_for_each_entry_safe(cell, p, &nvmem->cells, node) + nvmem_cell_drop(cell); } static void nvmem_cell_add(struct nvmem_cell *cell) { - mutex_lock(&nvmem_cells_mutex); - list_add_tail(&cell->node, &nvmem_cells); - mutex_unlock(&nvmem_cells_mutex); + mutex_lock(&nvmem_mutex); + list_add_tail(&cell->node, &cell->nvmem->cells); + mutex_unlock(&nvmem_mutex); } static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem, @@ -465,6 +445,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) } kref_init(&nvmem->refcnt); + INIT_LIST_HEAD(&nvmem->cells); nvmem->id = rval; nvmem->owner = config->owner; @@ -626,29 +607,14 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, { struct nvmem_device *nvmem = NULL; - mutex_lock(&nvmem_mutex); - - if (np) { - nvmem = of_nvmem_find(np); - if (!nvmem) { - mutex_unlock(&nvmem_mutex); - return ERR_PTR(-EPROBE_DEFER); - } - } else { - struct nvmem_cell *cell = nvmem_find_cell(cell_id); - - if (cell) { - nvmem = cell->nvmem; - *cellp = cell; - } - - if (!nvmem) { - mutex_unlock(&nvmem_mutex); - return ERR_PTR(-ENOENT); - } - } + if (!np) + return ERR_PTR(-ENOENT); + mutex_lock(&nvmem_mutex); + nvmem = of_nvmem_find(np); mutex_unlock(&nvmem_mutex); + if (!nvmem) + return ERR_PTR(-EPROBE_DEFER); if (!try_module_get(nvmem->owner)) { dev_err(&nvmem->dev, From patchwork Fri Sep 21 07:29:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5FC41390 for ; Fri, 21 Sep 2018 07:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2CDB2DE2B for ; Fri, 21 Sep 2018 07:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C66832DE96; Fri, 21 Sep 2018 07:42:20 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 696742DE2B for ; Fri, 21 Sep 2018 07:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LhLGnUwImh+3n9gZTxx8BLPO7K7V4I9fn0pMyiG3HFE=; b=k22mgSU+7vNjrfJooJt6Fg9U3z cGj8Nxn1vs2Vw9ZUZYnhueY9K3J3+87hCjNHeOZn3BvNvwObVBDtPFiDrG8nbc34LYXmpSzbpEJLc AwoRxZGIqxDrwiqJoe9QRqukqs8Ozk8kO53+pNcPvHdIZ9AF3j/Dk8b4Hj8UsUHh6UhPHGNNzMmPP FEpbLxi0iD50Bg6dChAEhCr5y0nkSzdsQ52SmD1V9vAUIO/MbeqyPctY12pc3pSidiO43WZ21QvNU rPFgmWmNqKToCQCDlheqH0rgU5Q/Q3Xm3NrjRkbVcagr+pp+Q/pRMX8KfuOlAK0LfJlwTmhNQT9w+ y1t3A/Kw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G4k-0006CO-2X; Fri, 21 Sep 2018 07:42:06 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsw-0006C5-Je for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:32 +0000 Received: by mail-wr1-x441.google.com with SMTP id u12-v6so11787404wrr.4 for ; Fri, 21 Sep 2018 00:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aecfarjoeDMcu1kl6u1BGN19//Di9TtONvHVMnCvVhw=; b=YYWZtmW2Hk1saQg8NQO+fU2JnvJcZCBkQuJ/WDK7QxAleMMmDgWi3DGPqb6BOrhEoX LhfdP3ece/qPXgXQlQiEFNq69zYiFNiXDs9mrkWt/Jg+ejoiyUTB+0KlgU5GqZYOsMvR u+FskGSqYyDcQS6z47Zru9VYz6xm3uQwGzcRunJ+n0s8psY7DOFqGOjPVbhUIi60SL4h uJNRvRIiqyicZ9Gx44x8kxclfWhc1GPZ2dMOR5RrgQdm57gycK0W8vmR8/aHaDonTpoM 1CSRIk7Xz/XQgBFzL9o5bqghCE200xkCmTRwpDKkXX0rXKDrXjt+wG0B6OEmC7rYIamg kQyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aecfarjoeDMcu1kl6u1BGN19//Di9TtONvHVMnCvVhw=; b=KBRAFtQTGq8tK04oj4htOY5FwBW/c1druCqfGsP2GKwRxqGTU6tCJ/FdL4TPzf0jOt c+7sFo4nKDL2A3TkJMb1U0xsO8opvMj84dLSZ4PN6KuaAG0UIF5/xCZWZrFf5DW5K5m5 /LRi/+JgLPUxofwgpcqLhH5Uom3fEyfU8cHQLup5jTIPZWS5qmuIRMZ/nCX5u2VHXl01 REiTglrmpmFkmnAmSOvelyunv2nG7obYTFYlaGHsjzpkIf4sYy+2Z5P0hsGGoyLQW383 Qg+16I9tAB3xYR4R116YDjsIdHJHTef4TZd4AOgRIX8GEm546kwWNAFBeGcU6hjqiii3 PRfw== X-Gm-Message-State: APzg51APg7aawkOhO9X5H6Cq1fvjuOJTHzr9+W83jf6ujGOm0V3N0xWl JnKPgKWZVArp5R4EMeMwPzNfS76eX/c= X-Google-Smtp-Source: ANB0VdbMaeAx4c6C9b/PzBPPdB+ZwRVw+6OkPxQO90FmXUbnMoj67MK430vh+VBxtIdTjFQ/944LfQ== X-Received: by 2002:adf:8024:: with SMTP id 33-v6mr36029974wrk.16.1537514984101; Fri, 21 Sep 2018 00:29:44 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:43 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 13/22] nvmem: add support for cell info Date: Fri, 21 Sep 2018 09:29:12 +0200 Message-Id: <20180921072921.19387-14-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002954_730319_771D48F3 X-CRM114-Status: GOOD ( 21.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Add new structs and routines allowing users to define nvmem cells from machine code. This global list of entries is parsed when a provider is registered and cells are associated with the relevant nvmem_device struct. A possible improvement for the future is to allow users to register cell tables after the nvmem provider has been registered by updating the cell list at each call to nvmem_(add|del)_cell_table(). Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 72 ++++++++++++++++++++++++++++++++++ include/linux/nvmem-provider.h | 33 +++++++++++----- 2 files changed, 96 insertions(+), 9 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ee794613024c..8e0108806e65 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -59,6 +59,9 @@ struct nvmem_cell { static DEFINE_MUTEX(nvmem_mutex); static DEFINE_IDA(nvmem_ida); +static DEFINE_MUTEX(nvmem_cell_mutex); +static LIST_HEAD(nvmem_cell_tables); + #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key eeprom_lock_key; #endif @@ -416,6 +419,43 @@ static int nvmem_setup_compat(struct nvmem_device *nvmem, return 0; } +static int nvmem_add_cells_from_table(struct nvmem_device *nvmem) +{ + const struct nvmem_cell_info *info; + struct nvmem_cell_table *table; + struct nvmem_cell *cell; + int rval = 0, i; + + mutex_lock(&nvmem_cell_mutex); + list_for_each_entry(table, &nvmem_cell_tables, node) { + if (strcmp(nvmem_dev_name(nvmem), table->nvmem_name) == 0) { + for (i = 0; i < table->ncells; i++) { + info = &table->cells[i]; + + cell = kzalloc(sizeof(*cell), GFP_KERNEL); + if (!cell) { + rval = -ENOMEM; + goto out; + } + + rval = nvmem_cell_info_to_nvmem_cell(nvmem, + info, + cell); + if (rval) { + kfree(cell); + goto out; + } + + nvmem_cell_add(cell); + } + } + } + +out: + mutex_unlock(&nvmem_cell_mutex); + return rval; +} + /** * nvmem_register() - Register a nvmem device for given nvmem_config. * Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem @@ -502,8 +542,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) goto err_teardown_compat; } + rval = nvmem_add_cells_from_table(nvmem); + if (rval) + goto err_remove_cells; + return nvmem; +err_remove_cells: + nvmem_device_remove_all_cells(nvmem); err_teardown_compat: if (config->compat) device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); @@ -1306,6 +1352,32 @@ int nvmem_device_write(struct nvmem_device *nvmem, } EXPORT_SYMBOL_GPL(nvmem_device_write); +/** + * nvmem_add_cell_table() - register a table of cell info entries + * + * @table: table of cell info entries + */ +void nvmem_add_cell_table(struct nvmem_cell_table *table) +{ + mutex_lock(&nvmem_cell_mutex); + list_add_tail(&table->node, &nvmem_cell_tables); + mutex_unlock(&nvmem_cell_mutex); +} +EXPORT_SYMBOL_GPL(nvmem_add_cell_table); + +/** + * nvmem_del_cell_table() - remove a previously registered cell info table + * + * @table: table of cell info entries + */ +void nvmem_del_cell_table(struct nvmem_cell_table *table) +{ + mutex_lock(&nvmem_cell_mutex); + list_del(&table->node); + mutex_unlock(&nvmem_cell_mutex); +} +EXPORT_SYMBOL_GPL(nvmem_del_cell_table); + /** * nvmem_dev_name() - Get the name of a given nvmem device. * diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 0f357d0c1e75..5c9f205cac8f 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -67,6 +67,25 @@ struct nvmem_config { struct device *base_dev; }; +/** + * struct nvmem_cell_table - NVMEM cell definitions for given provider + * + * @nvmem_name: Provider name. + * @cells: Array of cell definitions. + * @ncells: Number of cell definitions in the array. + * @node: List node. + * + * This structure together with related helper functions is provided for users + * that don't can't access the nvmem provided structure but wish to register + * cell definitions for it e.g. board files registering an EEPROM device. + */ +struct nvmem_cell_table { + const char *nvmem_name; + const struct nvmem_cell_info *cells; + size_t ncells; + struct list_head node; +}; + #if IS_ENABLED(CONFIG_NVMEM) struct nvmem_device *nvmem_register(const struct nvmem_config *cfg); @@ -77,9 +96,9 @@ struct nvmem_device *devm_nvmem_register(struct device *dev, int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem); -int nvmem_add_cells(struct nvmem_device *nvmem, - const struct nvmem_cell_info *info, - int ncells); +void nvmem_add_cell_table(struct nvmem_cell_table *table); +void nvmem_del_cell_table(struct nvmem_cell_table *table); + #else static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) @@ -102,12 +121,8 @@ devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) } -static inline int nvmem_add_cells(struct nvmem_device *nvmem, - const struct nvmem_cell_info *info, - int ncells) -{ - return -ENOSYS; -} +static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {} +static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {} #endif /* CONFIG_NVMEM */ #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */ From patchwork Fri Sep 21 07:29:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84B061390 for ; Fri, 21 Sep 2018 07:43:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 705152DC83 for ; Fri, 21 Sep 2018 07:43:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 621752DC81; Fri, 21 Sep 2018 07:43:39 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DBBAE2DC81 for ; Fri, 21 Sep 2018 07:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SrXfYeRTVMBix2PahzWqCByFUbfsm9caJ/C81TRuwAw=; b=cFe8AjQ2WPaklHrL8h4gUx3DUp 5d4b8YC7JcVq67TSCUCRsmrtfITR2/oe+ZJb386ebapInr/ej27woLYnlUERJRE7/ZwS2pMgHuJYr GpYKjas4vBQCGUv6w3TEzQnDZZnbiULC8OfqxQOurOBt3EQB32/tcOSK0H+aE6AN3iVbdI4qTVL/v pCFVGPBr88m00kXrEHV4eUaCPznifyhIWBT+OeLKENSliFI7Nm3IuNBxqm7twOGssr1CRHk0ZZrOo 3OoeEhkIfqohR5uVW8FEMCh6R0NGx+5OJ7+d3PQkHDzkI1YoAF3W+HeW8OgoWyObdOmvjIwLu4IL9 QBcgqWXg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G69-00073M-KH; Fri, 21 Sep 2018 07:43:33 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsz-0006Cs-E3 for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:47 +0000 Received: by mail-wr1-x42d.google.com with SMTP id t15so3887194wrx.1 for ; Fri, 21 Sep 2018 00:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Be+bUwosJuE1ERPG9AJV32lzBv2PqNG4G/ac7NezZwE=; b=V/JOSc6f3QprrAiVwkVbGvMRnOUE+aTmfHSaKRUNuaXTo6/Ah3sCbAIK21+cAiC+zb Mr6ISnUKQoWR6US4BP+pEzOWymXXV4/OPHv6CQJZJ8MgDzPCLTNN9aY8vFsRWypajL/q 805M1Z2qy6jK3qx+pTU/zMpZNJOPCDoPZhosgy/E9FLN0M4HSWbFF8WHrPCB9S1u5UcD qGAcnjtWGEpRXjbY6e4yrzaXdMRkUCq67QoASjzUbcNjwuYe4Pt50qKXthavLa28/Z5k strLfKHyG2iMBfB6wN3w1WBmeQDZFOgiV5yvvPtj0gnmRm/FZlikcv4nvwIfKkAwaMSH y0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Be+bUwosJuE1ERPG9AJV32lzBv2PqNG4G/ac7NezZwE=; b=caDUcp6pG4tXbtF7Qldqk4PmKIpk+V0Z+2kHcRhVBFjLRGuY4ZNK+aLmZNd7WnsfVz PFxGkfextMQoL4jU3wnFKgTCs0OhwTFdKZmnoNZp6wj1gEuBq3qYErVlijy0lj1Ax+VQ dp5pRsdGTZknMUPaOuQcaRVXNPc+lOw0Sq1LqW4YXiaIZg8uD91ZQJ4c+DRE/6XOk5qL i/As1rGJN2UgComrBhPVUpQInZtfY9OtQbczIslXps80ImOa0Q0N0SZ/qQ0q48UMEnRA BH/QEEOqjFYfwKuCxxbqfPxjudn28dej4n1Qavhr1frux5aCz0/l5BwT0G0JGJzdrxPJ T1sg== X-Gm-Message-State: APzg51CM2bFKiBIZmEZaOal2Quz/rHUTPjy1WZvciB1qfqZe1HogQVAE fwRbiKQpSVFnvOGxxN2KH72JfA== X-Google-Smtp-Source: ANB0VdZlbtXNBEXP3plkysRoacCfIZHCWlGTB0FXAgTCywQptvzi6fUmkpMf0ZyQONIhx6nN69tbEQ== X-Received: by 2002:a5d:4e4c:: with SMTP id r12-v6mr36201403wrt.27.1537514985447; Fri, 21 Sep 2018 00:29:45 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:44 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 14/22] nvmem: resolve cells from DT at registration time Date: Fri, 21 Sep 2018 09:29:13 +0200 Message-Id: <20180921072921.19387-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002957_578265_14D626C7 X-CRM114-Status: GOOD ( 18.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Currently we're creating a new cell structure everytime a DT user calls nvmem_cell_get(). Change this behavior by resolving the cells during nvmem provider registration and adding all cells to the provider's list. Make of_nvmem_cell_get() just parse the phandle and look the cell up in the relevant provider's list. Don't drop the cell in nvmem_cell_put(). Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 123 ++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 48 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 8e0108806e65..74b6b97680d5 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -456,6 +456,73 @@ static int nvmem_add_cells_from_table(struct nvmem_device *nvmem) return rval; } +static struct nvmem_cell * +nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index) +{ + struct nvmem_cell *cell = NULL; + int i = 0; + + mutex_lock(&nvmem_mutex); + list_for_each_entry(cell, &nvmem->cells, node) { + if (index == i++) + break; + } + mutex_unlock(&nvmem_mutex); + + return cell; +} + +static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) +{ + struct device_node *parent, *child; + struct device *dev = &nvmem->dev; + struct nvmem_cell *cell; + const __be32 *addr; + int len; + + parent = dev->of_node; + + for_each_child_of_node(parent, child) { + addr = of_get_property(child, "reg", &len); + if (!addr || (len < 2 * sizeof(u32))) { + dev_err(dev, "nvmem: invalid reg on %pOF\n", child); + return -EINVAL; + } + + cell = kzalloc(sizeof(*cell), GFP_KERNEL); + if (!cell) + return -ENOMEM; + + cell->nvmem = nvmem; + cell->offset = be32_to_cpup(addr++); + cell->bytes = be32_to_cpup(addr); + cell->name = child->name; + + addr = of_get_property(child, "bits", &len); + if (addr && len == (2 * sizeof(u32))) { + cell->bit_offset = be32_to_cpup(addr++); + cell->nbits = be32_to_cpup(addr); + } + + if (cell->nbits) + cell->bytes = DIV_ROUND_UP( + cell->nbits + cell->bit_offset, + BITS_PER_BYTE); + + if (!IS_ALIGNED(cell->offset, nvmem->stride)) { + dev_err(dev, "cell %s unaligned to nvmem stride %d\n", + cell->name, nvmem->stride); + /* Cells already added will be freed later. */ + kfree(cell); + return -EINVAL; + } + + nvmem_cell_add(cell); + } + + return 0; +} + /** * nvmem_register() - Register a nvmem device for given nvmem_config. * Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem @@ -546,6 +613,10 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; + rval = nvmem_add_cells_from_of(nvmem); + if (rval) + goto err_remove_cells; + return nvmem; err_remove_cells: @@ -848,10 +919,8 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *name) { struct device_node *cell_np, *nvmem_np; - struct nvmem_cell *cell; struct nvmem_device *nvmem; - const __be32 *addr; - int rval, len; + struct nvmem_cell *cell; int index = 0; /* if cell name exists, find index to the name */ @@ -871,54 +940,13 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, if (IS_ERR(nvmem)) return ERR_CAST(nvmem); - addr = of_get_property(cell_np, "reg", &len); - if (!addr || (len < 2 * sizeof(u32))) { - dev_err(&nvmem->dev, "nvmem: invalid reg on %pOF\n", - cell_np); - rval = -EINVAL; - goto err_mem; - } - - cell = kzalloc(sizeof(*cell), GFP_KERNEL); + cell = nvmem_find_cell_by_index(nvmem, index); if (!cell) { - rval = -ENOMEM; - goto err_mem; - } - - cell->nvmem = nvmem; - cell->offset = be32_to_cpup(addr++); - cell->bytes = be32_to_cpup(addr); - cell->name = cell_np->name; - - addr = of_get_property(cell_np, "bits", &len); - if (addr && len == (2 * sizeof(u32))) { - cell->bit_offset = be32_to_cpup(addr++); - cell->nbits = be32_to_cpup(addr); - } - - if (cell->nbits) - cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, - BITS_PER_BYTE); - - if (!IS_ALIGNED(cell->offset, nvmem->stride)) { - dev_err(&nvmem->dev, - "cell %s unaligned to nvmem stride %d\n", - cell->name, nvmem->stride); - rval = -EINVAL; - goto err_sanity; + __nvmem_device_put(nvmem); + return ERR_PTR(-ENOENT); } - nvmem_cell_add(cell); - return cell; - -err_sanity: - kfree(cell); - -err_mem: - __nvmem_device_put(nvmem); - - return ERR_PTR(rval); } EXPORT_SYMBOL_GPL(of_nvmem_cell_get); #endif @@ -1024,7 +1052,6 @@ void nvmem_cell_put(struct nvmem_cell *cell) struct nvmem_device *nvmem = cell->nvmem; __nvmem_device_put(nvmem); - nvmem_cell_drop(cell); } EXPORT_SYMBOL_GPL(nvmem_cell_put); From patchwork Fri Sep 21 07:29:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0CF014BD for ; Fri, 21 Sep 2018 07:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC56B2DE2B for ; Fri, 21 Sep 2018 07:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EC872DE4C; Fri, 21 Sep 2018 07:41:36 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 65C642DE2B for ; Fri, 21 Sep 2018 07:41:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Od12vXb/K6I6C2QiFnA+nr43Fu93UUyy4KZWVUeIE7c=; b=mCm3RtFJ69GKE3mbyCxNua+5eN /GUB5CKGK5nSE8bhJWnuZyztLcZHxTd1XSVYyjGaOJdPi/d9VKdk+zG9l1AgpCLtrMgnMi/mhlV/K u6C8XyGtg4H6THUgBv9RutI0rtGCVsqMswYId8Sl0FxnJ075BK9XfKvIFwOo1Wikkx/5q0j60r6Mn vw0/KmC2vUY6i5iA9ei+urJWDVFhM4eskbVSZPZtNhi0vPryFDsgC0OSNKwIRh03SQwmCoT/p4rfx KQRu6fuUif5cZRibGL85hMRleF1JXOZuJlrAW2zNGkkw9EOTgCQ09Gu2mgatbh2NCpXT6Kk+qFrFd sC9KmU3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G43-0005qw-6j; Fri, 21 Sep 2018 07:41:23 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsv-0006DB-1n for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:33 +0000 Received: by mail-wr1-x442.google.com with SMTP id n11-v6so572831wro.0 for ; Fri, 21 Sep 2018 00:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yhfUANQZnkHZWIDyJh+01IANuGDRTPnVUVkFPYr0+yM=; b=feSsRjyjSXfwiTcaHZzuVTIkLwadWbDoKNUNOFgF4zcX9SJnTXe8hobUI9ipdQBonw 4OvaYcviMwS8kjn0qrMLCNN3XME7kEEWYVaOr//QtV88o8kliPh1uiAbZpMrQGhDNwoN GD3MvA9+hVxtcmpWhPooNN5K0HDLb+9OHC+ZEabwEj55aNQ4838bTIXkUhI4llGw9TbU RGqXFVROfEA/MhYvbgvoIqjowqp7Xh/h1LO93jAZhJL7MV2XP5qYNQMWSzKHfcsXyaMM yS0LnsM4RQ5mjbE8vYZxPdFU2lGbDRi0Eu/o+5yyIrcHGga5jnwuyOGln6TIi8ivthR+ WYWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yhfUANQZnkHZWIDyJh+01IANuGDRTPnVUVkFPYr0+yM=; b=r7khC+8TLZvCgRHN7en3yz90YhLcGLZFkOJ+TfuKE3INq6cWAkldfW3loKGYFoVZn1 aW9wPdJJtVm8d1z57BZLG/NFW8s1AlkYFg/avHaZLh6QO2yY5/lxsGavqOTTyvDuI+EB oSsWoHkG3ld6W6zDrJu7+cornUMAh5k46yg5BxOwE2Xy4bKnBXtDBbT9pU4GMrE86BpZ pg04b4Rq6NC8f0enHiu6xcQaW0U7MkGG6yNoXbyRurrGmnPvwJT+nKBQwXYTuK9Y5Tsh 6quXR6Yrk5Kv6PRu583S4oQJqusPcsQepWgq/Sm5JpVLxJCuOCsIarZW/cPvQnpPW4pp +Acw== X-Gm-Message-State: APzg51BwcIBUWWho8tbBblJ/r2OmNc8uFH0oP/54PLjcTBu1dgtu8BJG JivdFRLpLfxylvPLMzg7G0ACmw== X-Google-Smtp-Source: ANB0VdaqeweNAZ7NR42Lm5y5PlcIkbppKiZ0yjw+BJ1FGLLZUIArbm2XkRDamr09FaRu9kigsln3NA== X-Received: by 2002:a5d:69d1:: with SMTP id s17-v6mr37396029wrw.77.1537514986900; Fri, 21 Sep 2018 00:29:46 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:46 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 15/22] nvmem: add support for cell lookups from machine code Date: Fri, 21 Sep 2018 09:29:14 +0200 Message-Id: <20180921072921.19387-16-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002953_195041_29307FC2 X-CRM114-Status: GOOD ( 23.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Add a way for machine code users to associate devices with nvmem cells. This restores the support for non-DT systems but following a different approach. Cells must now be associated with devices using provided routines and data structures before they can be retrieved using nvmem_cell_get(). It's still possible to define cells statically in nvmem_config but cells created this way still need to be associated with consumers using lookup entries. Note that nvmem_find() must be moved higher in the source file as we want to call it from __nvmem_device_get() for devices that don't have a device node. The signature of __nvmem_device_get() is also changed as it's no longer used to retrieve cells. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 129 ++++++++++++++++++++++++++------- include/linux/nvmem-consumer.h | 28 +++++++ 2 files changed, 131 insertions(+), 26 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 74b6b97680d5..9cc86d131e1e 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -62,6 +62,9 @@ static DEFINE_IDA(nvmem_ida); static DEFINE_MUTEX(nvmem_cell_mutex); static LIST_HEAD(nvmem_cell_tables); +static DEFINE_MUTEX(nvmem_lookup_mutex); +static LIST_HEAD(nvmem_lookup_list); + #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key eeprom_lock_key; #endif @@ -283,6 +286,18 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np) return to_nvmem_device(d); } +static struct nvmem_device *nvmem_find(const char *name) +{ + struct device *d; + + d = bus_find_device_by_name(&nvmem_bus_type, NULL, name); + + if (!d) + return NULL; + + return to_nvmem_device(d); +} + static void nvmem_cell_drop(struct nvmem_cell *cell) { mutex_lock(&nvmem_mutex); @@ -472,6 +487,21 @@ nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index) return cell; } +static struct nvmem_cell * +nvmem_find_cell_by_name(struct nvmem_device *nvmem, const char *cell_id) +{ + struct nvmem_cell *cell = NULL; + + mutex_lock(&nvmem_mutex); + list_for_each_entry(cell, &nvmem->cells, node) { + if (strcmp(cell_id, cell->name) == 0) + break; + } + mutex_unlock(&nvmem_mutex); + + return cell; +} + static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) { struct device_node *parent, *child; @@ -719,16 +749,12 @@ int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) EXPORT_SYMBOL(devm_nvmem_unregister); static struct nvmem_device *__nvmem_device_get(struct device_node *np, - struct nvmem_cell **cellp, - const char *cell_id) + const char *nvmem_name) { struct nvmem_device *nvmem = NULL; - if (!np) - return ERR_PTR(-ENOENT); - mutex_lock(&nvmem_mutex); - nvmem = of_nvmem_find(np); + nvmem = np ? of_nvmem_find(np) : nvmem_find(nvmem_name); mutex_unlock(&nvmem_mutex); if (!nvmem) return ERR_PTR(-EPROBE_DEFER); @@ -752,18 +778,6 @@ static void __nvmem_device_put(struct nvmem_device *nvmem) kref_put(&nvmem->refcnt, nvmem_device_release); } -static struct nvmem_device *nvmem_find(const char *name) -{ - struct device *d; - - d = bus_find_device_by_name(&nvmem_bus_type, NULL, name); - - if (!d) - return ERR_PTR(-ENOENT); - - return to_nvmem_device(d); -} - #if IS_ENABLED(CONFIG_OF) /** * of_nvmem_device_get() - Get nvmem device from a given id @@ -786,7 +800,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id) if (!nvmem_np) return ERR_PTR(-EINVAL); - return __nvmem_device_get(nvmem_np, NULL, NULL); + return __nvmem_device_get(nvmem_np, NULL); } EXPORT_SYMBOL_GPL(of_nvmem_device_get); #endif @@ -890,15 +904,43 @@ struct nvmem_device *devm_nvmem_device_get(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(devm_nvmem_device_get); -static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id) +static struct nvmem_cell * +nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) { - struct nvmem_cell *cell = NULL; + struct nvmem_cell *cell = ERR_PTR(-ENOENT); + struct nvmem_cell_lookup *lookup; struct nvmem_device *nvmem; + const char *dev_id; - nvmem = __nvmem_device_get(NULL, &cell, cell_id); - if (IS_ERR(nvmem)) - return ERR_CAST(nvmem); + if (!dev) + return ERR_PTR(-EINVAL); + + dev_id = dev_name(dev); + + mutex_lock(&nvmem_lookup_mutex); + + list_for_each_entry(lookup, &nvmem_lookup_list, node) { + if ((strcmp(lookup->dev_id, dev_id) == 0) && + (strcmp(lookup->con_id, con_id) == 0)) { + /* This is the right entry. */ + nvmem = __nvmem_device_get(NULL, lookup->nvmem_name); + if (!nvmem) { + /* Provider may not be registered yet. */ + cell = ERR_PTR(-EPROBE_DEFER); + goto out; + } + + cell = nvmem_find_cell_by_name(nvmem, + lookup->cell_name); + if (!cell) { + __nvmem_device_put(nvmem); + goto out; + } + } + } +out: + mutex_unlock(&nvmem_lookup_mutex); return cell; } @@ -935,7 +977,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, if (!nvmem_np) return ERR_PTR(-EINVAL); - nvmem = __nvmem_device_get(nvmem_np, NULL, NULL); + nvmem = __nvmem_device_get(nvmem_np, NULL); of_node_put(nvmem_np); if (IS_ERR(nvmem)) return ERR_CAST(nvmem); @@ -975,7 +1017,7 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id) if (!cell_id) return ERR_PTR(-EINVAL); - return nvmem_cell_get_from_list(cell_id); + return nvmem_cell_get_from_lookup(dev, cell_id); } EXPORT_SYMBOL_GPL(nvmem_cell_get); @@ -1405,6 +1447,41 @@ void nvmem_del_cell_table(struct nvmem_cell_table *table) } EXPORT_SYMBOL_GPL(nvmem_del_cell_table); +/** + * nvmem_add_cell_lookups() - register a list of cell lookup entries + * + * @entries: array of cell lookup entries + * @nentries: number of cell lookup entries in the array + */ +void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) +{ + int i; + + mutex_lock(&nvmem_lookup_mutex); + for (i = 0; i < nentries; i++) + list_add_tail(&entries[i].node, &nvmem_lookup_list); + mutex_unlock(&nvmem_lookup_mutex); +} +EXPORT_SYMBOL_GPL(nvmem_add_cell_lookups); + +/** + * nvmem_del_cell_lookups() - remove a list of previously added cell lookup + * entries + * + * @entries: array of cell lookup entries + * @nentries: number of cell lookup entries in the array + */ +void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) +{ + int i; + + mutex_lock(&nvmem_lookup_mutex); + for (i = 0; i < nentries; i++) + list_del(&entries[i].node); + mutex_unlock(&nvmem_lookup_mutex); +} +EXPORT_SYMBOL_GPL(nvmem_del_cell_lookups); + /** * nvmem_dev_name() - Get the name of a given nvmem device. * diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 0389fe00b177..27eee3945405 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -29,6 +29,24 @@ struct nvmem_cell_info { unsigned int nbits; }; +/** + * struct nvmem_cell_lookup - cell lookup entry + * + * @nvmem_name: Name of the provider. + * @cell_name: Name of the nvmem cell as defined in the name field of + * struct nvmem_cell_info. + * @dev_id: Name of the consumer device that will be associated with + * this cell. + * @con_id: Connector id for this cell lookup. + */ +struct nvmem_cell_lookup { + const char *nvmem_name; + const char *cell_name; + const char *dev_id; + const char *con_id; + struct list_head node; +}; + #if IS_ENABLED(CONFIG_NVMEM) /* Cell based interface */ @@ -57,6 +75,11 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem, const char *nvmem_dev_name(struct nvmem_device *nvmem); +void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, + size_t nentries); +void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, + size_t nentries); + #else static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, @@ -151,6 +174,11 @@ static inline const char *nvmem_dev_name(struct nvmem_device *nvmem) return NULL; } +static inline void +nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) {} +static inline void +nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) {} + #endif /* CONFIG_NVMEM */ #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) From patchwork Fri Sep 21 07:29:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4072814BD for ; Fri, 21 Sep 2018 07:39:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DAB02DBE3 for ; Fri, 21 Sep 2018 07:39:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 210032DC6D; Fri, 21 Sep 2018 07:39:19 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9852B2DBE3 for ; Fri, 21 Sep 2018 07:39:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6rqIHAVz8dCEdzoedI9vEAJiPyDTyvIHPrjWfOPP8HY=; b=Pq7YLcxIvnJU9QICVcBxHGei6f zpWJfv0TghofMZim6mq5nvSnJx6vWfoq3pDl8elKxv0uWADKELhhkWoePFAsMz3tVYfY+JUaBvccm fUlK6AC/bO4Y6tfgXgvoVJk4k/BV5BqQbIStHCRZqFTmY/yOJydk/ycrvVzITULxs76E36rGoNQba aJKAaJu11r7GntFLs0ptuMRSIMmnCcd1wGTKyduXQbo4h4QTlimE5MnmI5/BcoimFOOnWdYAFshRM HjQ26P6q6FRA96pK3OTD2W6BISiWFj/Fgf0LJhvG+vZosMIHJkBhwnMOIrAIV/UdYpwvvztrEj7iK 4KKT714A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G1x-0003kQ-FH; Fri, 21 Sep 2018 07:39:13 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsw-0006De-KR for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:24 +0000 Received: by mail-wr1-x441.google.com with SMTP id v17-v6so11785943wrr.9 for ; Fri, 21 Sep 2018 00:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rjARCe3NpsJLpu+gwm8Y4x+0pJknacrTsP46NqsklWs=; b=nrl0ZmzFXKV1C2dHT2G+p10w+heILcFor2W+NM5qN7CgCgjv1OsLYmDDtjR5/haaJl +c//cpqEP8jAIsCY29Fulgr0VzOmKLAbgR77mGFiBb17oMQgwSExDg7KgUDudPC6bEY5 s134IalH1vMybPrCDZgOWCUjqgmzslGKYEYIeFcy11EiSypauYgMuVD3Zt92UYwDhpwj xc8GchyYlZALU7ukamoDf9namr6cIrQz2IH4MP/TrKpLNF5EscTcKZOeAPTfIPZJysKf 47xg1UgHQe0zj1jCnk3CoeOWSW6+RW20Od1tdK+wPeqCS7R5vaYnksm9Gw/AlDY7MV4t fGtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rjARCe3NpsJLpu+gwm8Y4x+0pJknacrTsP46NqsklWs=; b=gVr6aCvKFC8Dsb0qWtWoF3jbMyqdnKTJ/JjdUXZ3GvoyYBGn22apZulvwhFvEh9GRp 0ClPj8Dk0/bxcqrKvtNUkBtc1YrWfw2lXZtovgFKcG0vsrzVxmL2sASyB8kSNCLfgCYo JkOfcIM3NdVmm+lwjkUfktxOK3V+1w9AqHGMsbpBurstYvQate5hrbF/wNxKt2SNdM1X amvX11y2p9jT8B1fF0DCRf98QlnSosn+t1qNss+v5fyfyhhSbtReqR77l099I+NL6yIc tARx4m5DXObysPTNevq+/JdirFiSAPxN0+7M8vwswIcSPTLEZ3jMneDfJasEcxVyt1wM K9ow== X-Gm-Message-State: APzg51Dpy68v42n/qm0mOF8lYvrtQq2aLbVR7cezVUWU7lcT+prlp1yA LzDC4Db1UAIKfE0V/VqmKGMy9g== X-Google-Smtp-Source: ANB0Vdav5OfRgQsR3mjSOueeXCMx0dNd3X2ZogTEP48htDbmJ1HVY310M6PUYAoafiOD1j+qUSLcHw== X-Received: by 2002:adf:f984:: with SMTP id f4-v6mr37339731wrr.105.1537514988246; Fri, 21 Sep 2018 00:29:48 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:47 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 16/22] Documentation: nvmem: document cell tables and lookup entries Date: Fri, 21 Sep 2018 09:29:15 +0200 Message-Id: <20180921072921.19387-17-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002954_700834_B20FEF8A X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Document the new nvmem kernel APIs. Signed-off-by: Bartosz Golaszewski --- Documentation/nvmem/nvmem.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/nvmem/nvmem.txt b/Documentation/nvmem/nvmem.txt index 8d8d8f58f96f..fc2fe4b18655 100644 --- a/Documentation/nvmem/nvmem.txt +++ b/Documentation/nvmem/nvmem.txt @@ -58,6 +58,37 @@ static int qfprom_probe(struct platform_device *pdev) It is mandatory that the NVMEM provider has a regmap associated with its struct device. Failure to do would return error code from nvmem_register(). +Users of board files can define and register nvmem cells using the +nvmem_cell_table struct: + +static struct nvmem_cell_info foo_nvmem_cells[] = { + { + .name = "macaddr", + .offset = 0x7f00, + .bytes = ETH_ALEN, + } +}; + +static struct nvmem_cell_table foo_nvmem_cell_table = { + .nvmem_name = "i2c-eeprom", + .cells = foo_nvmem_cells, + .ncells = ARRAY_SIZE(foo_nvmem_cells), +}; + +nvmem_add_cell_table(&foo_nvmem_cell_table); + +Additionally it is possible to create nvmem cell lookup entries and register +them with the nvmem framework from machine code as shown in the example below: + +static struct nvmem_cell_lookup foo_nvmem_lookup = { + .nvmem_name = "i2c-eeprom", + .cell_name = "macaddr", + .dev_id = "foo_mac.0", + .con_id = "mac-address", +}; + +nvmem_add_cell_lookups(&foo_nvmem_lookup, 1); + NVMEM Consumers +++++++++++++++ From patchwork Fri Sep 21 07:29:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC7D1390 for ; Fri, 21 Sep 2018 07:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B96512DDB2 for ; Fri, 21 Sep 2018 07:40:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA20F2DE2B; Fri, 21 Sep 2018 07:40:48 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F9FA2DDB2 for ; Fri, 21 Sep 2018 07:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EBkXH5NzT48pipWWBrsGMBi/s0RL8BHukT7LGnp/qIQ=; b=ma3rKk7DJoCBQFASPB0AqDi57s +REWWvQeHQeeFbiqbeD0eNe0kj31evH2vb7ADnMNIt4LxFCRF2RgWWx0koJOJo/Z0EZ9R8e0k3B2J T7ZHavlZbz1Xsoy1oVee6wrzVC+kI24MG1EgBu/SdxoqbNd3OsOYQZVyMJ1fQxuDOwdOt937CicrP n54XLQVeHnWaM9TMHGNIaLEIx/dYXkFYhxCzDifdwDwWqbnVWw6h4JBxVMY87r3xqoj9jW4iL42UM wxljHhNAMSA28Xe8bEke1ky5bxUSCXXMNNrKhPgtiRzMRxTcYpYgRMRhaXZXqQKMS3ngo/epjWtUP Alefqkfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G3P-0005Z8-D3; Fri, 21 Sep 2018 07:40:43 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Fsw-0006EE-Jx for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:33 +0000 Received: by mail-wr1-x441.google.com with SMTP id e1-v6so11813566wrt.3 for ; Fri, 21 Sep 2018 00:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xUWytVeU60Ge4e6flnnEzHifvO92bv3CXt84Mfa/t9w=; b=1kelKcN85PVPFbfriiaT/5vJv5kew2sG7xwtrELs4OyRVDzJFARgYelKQYEPPmks/h fqVoEHz8POEh1azTUq+nUEX9o1G7O9pWfYTC+SN6gJjwqt5Xp1OSag/I60gkvYh86Ta3 0rXEK6PuQFR+ILSWtG2YRwsqeUEJpcSE9DaioVfzx86GpZ4IMlVI8aoIUeDQ870cmvVO tBivGWyktcfm9HvyP5nSRe/mgdk9kCdkDicGfgC+ACawvMugEFZj++tvvZdt2yPGVimO IUcxbm7uGER5FMoVu/i75XWOyVJ6qnYIMlm3PwtbYuN390+LlG/waXfRbQhCZtEfPDnS U0gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xUWytVeU60Ge4e6flnnEzHifvO92bv3CXt84Mfa/t9w=; b=gHKZ3i2tSBXnZKQElQn3g86tsd57tuuu3pu1kSBsA5Jk/MWr2DgEFsRESPsZcbG2oY DRlOsSITFIOaEC5V+OqQQAJ1rlB7OqbLmsPTUQJePqK88gdA1Yg0Xn7EHTCWGiBvbSci hKSRpVXdkeX4wT+75O7QSvmCg38tK/LhyLtrTzOvSYjHSdb/d3Ac7f6Br5H4PknAvU5C GoP2HwILkZ+RJ9GpQORrJ90tRFuZdCa8W1cFd+7xekIDwM93L5zj3H1TNQRsAnzSb642 3unjdSPWZbufQB3H+F/anqnm9Hc7gFt3DUo0dvNUSau6UT0BYsgB/lpV4JzJfn1c8HwY Oc3Q== X-Gm-Message-State: APzg51BdEuBfcu7BNdL7Y6qLulqEZHXFdKHJ//k54HbGA3+QOjwzVWZ8 Wr/aVgSqL9mXR9h4YWLUVz7dAg== X-Google-Smtp-Source: ANB0Vdab0At+8/ADEKqlpJ8V3wuE6/aZXFQDvAWhgaZB7V2uI9jHLCSS8hDu1mRAAXG9lZD5jh07Kg== X-Received: by 2002:adf:a299:: with SMTP id s25-v6mr12717273wra.100.1537514989619; Fri, 21 Sep 2018 00:29:49 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:49 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 17/22] nvmem: add a notifier chain Date: Fri, 21 Sep 2018 09:29:16 +0200 Message-Id: <20180921072921.19387-18-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_002954_723612_FE29A1AF X-CRM114-Status: GOOD ( 15.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Add a blocking notifier chain with four events (add and remove for both devices and cells) so that users can get notified about the addition of nvmem resources they're waiting for. We'll use this instead of the at24 setup callback in the mityomapl138 board file. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 36 ++++++++++++++++++++++++++++++++++ include/linux/nvmem-consumer.h | 21 ++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 9cc86d131e1e..da441019b609 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -65,6 +65,8 @@ static LIST_HEAD(nvmem_cell_tables); static DEFINE_MUTEX(nvmem_lookup_mutex); static LIST_HEAD(nvmem_lookup_list); +static BLOCKING_NOTIFIER_HEAD(nvmem_notifier); + #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key eeprom_lock_key; #endif @@ -300,6 +302,7 @@ static struct nvmem_device *nvmem_find(const char *name) static void nvmem_cell_drop(struct nvmem_cell *cell) { + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_REMOVE, cell); mutex_lock(&nvmem_mutex); list_del(&cell->node); mutex_unlock(&nvmem_mutex); @@ -319,6 +322,7 @@ static void nvmem_cell_add(struct nvmem_cell *cell) mutex_lock(&nvmem_mutex); list_add_tail(&cell->node, &cell->nvmem->cells); mutex_unlock(&nvmem_mutex); + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell); } static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem, @@ -434,6 +438,32 @@ static int nvmem_setup_compat(struct nvmem_device *nvmem, return 0; } +/** + * nvmem_register_notifier() - Register a notifier block for nvmem events. + * + * @nb: notifier block to be called on nvmem events. + * + * Return: 0 on success, negative error number on failure. + */ +int nvmem_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&nvmem_notifier, nb); +} +EXPORT_SYMBOL_GPL(nvmem_register_notifier); + +/** + * nvmem_unregister_notifier() - Unregister a notifier block for nvmem events. + * + * @nb: notifier block to be unregistered. + * + * Return: 0 on success, negative error number on failure. + */ +int nvmem_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&nvmem_notifier, nb); +} +EXPORT_SYMBOL_GPL(nvmem_unregister_notifier); + static int nvmem_add_cells_from_table(struct nvmem_device *nvmem) { const struct nvmem_cell_info *info; @@ -647,6 +677,10 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; + rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); + if (rval) + goto err_remove_cells; + return nvmem; err_remove_cells: @@ -669,6 +703,8 @@ static void nvmem_device_release(struct kref *kref) nvmem = container_of(kref, struct nvmem_device, refcnt); + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_REMOVE, nvmem); + if (nvmem->flags & FLAG_COMPAT) device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 27eee3945405..0326b52e906b 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -14,6 +14,7 @@ #include #include +#include struct device; struct device_node; @@ -47,6 +48,13 @@ struct nvmem_cell_lookup { struct list_head node; }; +enum { + NVMEM_ADD = 1, + NVMEM_REMOVE, + NVMEM_CELL_ADD, + NVMEM_CELL_REMOVE, +}; + #if IS_ENABLED(CONFIG_NVMEM) /* Cell based interface */ @@ -80,6 +88,9 @@ void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries); +int nvmem_register_notifier(struct notifier_block *nb); +int nvmem_unregister_notifier(struct notifier_block *nb); + #else static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, @@ -179,6 +190,16 @@ nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) {} static inline void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) {} +static inline int nvmem_register_notifier(struct notifier_block *nb) +{ + return -ENOSYS; +} + +static inline int nvmem_unregister_notifier(struct notifier_block *nb) +{ + return -ENOSYS; +} + #endif /* CONFIG_NVMEM */ #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) From patchwork Fri Sep 21 07:29:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3510112B for ; Fri, 21 Sep 2018 07:45:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FBD62DC81 for ; Fri, 21 Sep 2018 07:45:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B992DC8C; Fri, 21 Sep 2018 07:45:03 +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=-0.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,URIBL_DBL_ABUSE_MALW autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C23632DC81 for ; Fri, 21 Sep 2018 07:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cHy6PKcXBmYRV2qgmVevt6u7U2CTfSSFT8FelFvcpIE=; b=NuS/bZt2TOD+BmrDAVeQC1BY1U mUguguzkDpf23ZsAMT72DxZFR/h1pLMqFCUZ88+I8g7rs6BnfjDyvMD+2yCizr9uHtJbCs6DOXzS8 tTgtVThCiFZOa+Q3+Vlgw6CF0xZ/hnOfbZKoxzbfHhZto/mFc5c9TY2kKd036rKncJnG8H0P/jbXg YVGLdlCmt6mVKbl2jAwVv12W8KnXqfOBL4Gd7LD90oOAWmECksF9RnGUpn2ulVZLRxOQcMu0RkOP6 Ov6huNTE81zgERwkAEJZi6W1JC/CB86m2Rk+aLDScyeTACVWiSPx1S36QaG/C63bllMbmXJHFz1tA eEMzc5vg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G7V-0007Zr-JM; Fri, 21 Sep 2018 07:44:57 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Ft4-0006Es-GR for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:52 +0000 Received: by mail-wm1-x341.google.com with SMTP id y2-v6so1961802wma.1 for ; Fri, 21 Sep 2018 00:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ujFzkuZMMLmXfVfLF2lfmeu9c3YEpE3NecX6O1UeHlg=; b=OvbxD4w48xlLdUjHcuGu7BF18SmgVQUlpff9bmPW0urV3p91CPt//5rIVYaL8so5af cvoiwx9KQBgHHLbGTmxLK8xx2iFU1tATNF8vXDwrU4OzIwrp3jEwiIJTjGHGp21rvds2 EHABchHXxEuk87dLL8WFG42+4rpX3rGwC6AkIkR2VakokgzB6ujhouXbKm6T3K34Zvt8 QUSLisIBRZEACAFQfYDc8Nj5608CPWpVj63Wnj6e+0hWjGKMaZs4jfqVbaVCoLbXRrfx EW16d21kIqtNlU1EcHlOI9DCRqCh3rQeUVNvyVXrUycrKPoEfPQjw9JydehVcwM9+bAW 8lEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ujFzkuZMMLmXfVfLF2lfmeu9c3YEpE3NecX6O1UeHlg=; b=l4oRh41aYWiyLmFWpGalKv5XORkkySdgCoHI3XBHrR4EFc1qqGFvOzkzSW+6b5Au+8 fBcbq38FRzAt3O6R6Vmf+qTmJASzUptyg61nBUiyQK+OKLsC1iwOBF5ZE0QDm+A0EKTO t0KxjvjStrAlD5RBlF2+totEfuCyzCrOwG0UGymI7iiV20tm3uPiJu8X4xqVObqiMLiQ J0/UqVR4UAPxZbf+UHTB6ZJDWGGKdIxDMWOc/DznqzkHOKjqTuh5rM0TNJDywBCQPN5E UIWycZPSzMccqlL0Rjccs5IWA4elLghb41WESmdnOo9tXRCcgfTl4uJyylwg4TNjTBvo vbuA== X-Gm-Message-State: APzg51B6Z1h4XYlXquw7V1JGO8Q7JoVanAKI4VHNvJ/FALiTXlIo2SNO 3H9quwCvflDNe4G+0N43Ma2WBg== X-Google-Smtp-Source: ANB0VdazdE6y91UPIGNmhvum39ncgjWGTXJ4b85md0eIb1eh9ts6RljZsZqcWsz+ht99a4CbuWn8Iw== X-Received: by 2002:a1c:e70b:: with SMTP id e11-v6mr5705782wmh.22.1537514991003; Fri, 21 Sep 2018 00:29:51 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:50 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 18/22] nvmem: use SPDX license identifiers Date: Fri, 21 Sep 2018 09:29:17 +0200 Message-Id: <20180921072921.19387-19-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_003002_679895_DE0A7CE1 X-CRM114-Status: GOOD ( 14.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Use SPDX license identiefiers to core nvmem files and remove GPL 2.0 license boilerplate. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 10 +--------- include/linux/nvmem-consumer.h | 5 +---- include/linux/nvmem-provider.h | 5 +---- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index da441019b609..ea05219e60b4 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1,17 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * nvmem framework core. * * Copyright (C) 2015 Srinivas Kandagatla * Copyright (C) 2013 Maxime Ripard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 0326b52e906b..d18caae2f7ac 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * nvmem framework consumer. * * Copyright (C) 2015 Srinivas Kandagatla * Copyright (C) 2013 Maxime Ripard - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. */ #ifndef _LINUX_NVMEM_CONSUMER_H diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 5c9f205cac8f..8ae012f6545a 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * nvmem framework provider. * * Copyright (C) 2015 Srinivas Kandagatla * Copyright (C) 2013 Maxime Ripard - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. */ #ifndef _LINUX_NVMEM_PROVIDER_H From patchwork Fri Sep 21 07:29:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D7D6112B for ; Fri, 21 Sep 2018 07:46:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC712DC81 for ; Fri, 21 Sep 2018 07:46:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F2562DCB2; Fri, 21 Sep 2018 07:46:10 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF9F82DC81 for ; Fri, 21 Sep 2018 07:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GBButyXCp/8ww/foRxoE5NNvea0p8HjOZ7MBag3nTxw=; b=pi/VKyR2thW+mu1m/B40Z3I19w /neL1uY4DSGBbbo6frfRLzkoRCzf8/bWJ9olP6eJ5BNya6p0H/8kjAwFJgQYcOaZu31NxvJHtR2EP Ulm+cLhtiArcJ1sM73YbVefRmIDkCctKxNH4A6piuWsbMQts5Pbu6gB3fFRVYMwZmhnKCsUCi1/BA 0gxG25VG30FZ+P3q1PFRlsPs8DhR2lY0r9uYGnKp+WaUiVGkTKGX6BQ+jZNioAtt0/4mQRHTkFdWG ajDtJ2o7ih7g00ysFecvJu1DoKx+p6mLgxlmUf8o2vPH0GcHBbbWyUzmYxVvXipwGT+TbI+AOk5dX AZGpIEcQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G8S-0000oI-T1; Fri, 21 Sep 2018 07:45:56 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Ft5-0006FK-SO for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:55 +0000 Received: by mail-wr1-x442.google.com with SMTP id e1-v6so11813710wrt.3 for ; Fri, 21 Sep 2018 00:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SWhvTRaZMO6GTmTkXjZ+oIHfexV3W/J/b8cNASj1ylQ=; b=DP058y81EJvsq2aD5kS6Re4lfr7AHZsYlED+yh8MxGWdHXMi0JdHGe3EZanAr+xR1G dRjCKHqVkVbqPPIshJfDUc5cWFLtKT25msI6pIuRX4y+HgImI0KTteMgHSlSngv9VcPB Cvc9GjZVQ1xH7aOLLRlIwwvf/wV5dgFM17Xd8qkx7wPNJtChKG/HvhXxvv99084ltfC2 4/ReqK3xgWtYi832NDCe9ZmFqlJYUpGMuCK2cR315lMx7NJEXrNsv/ak8LiF6K1hdZoD gAVitlVM/s9L0RkqYsp+t9ua35UeP0H9+HxX6HxNR+IiHMk0IH+KeF80hv74kcwTIo0a looA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SWhvTRaZMO6GTmTkXjZ+oIHfexV3W/J/b8cNASj1ylQ=; b=HBnKQWeG7fejwkbTOv4iXLRKR5g0siZukhBPoJ7QAayWQD8czdjyt+lgEXxcEA1oBg y5H+Ww9mTn16lnKj+POB6OJw3nLQT08zLctfSp2pcSl4qYP6ToT+3iYbdMEi3i1bn6Lm cSL6m4YzYUsHoQwI3GTjEw2QH+SGwWRNA/vtKBgMs1DzQ3xgdAE1joVJWkgNhm/0+PYf Ve+1aQgF5uV5AZ7qWqTKWn9YjGcs3/y1M4Icz72q8azwZ0hH7PUpanW7So3+5vTMe0U0 EUZ0ulVxc2SQpw6Ngw9Q6ptw58ZhffG7hl7BgoZWu212PoblZH7UxEch3mRqk4gtG3fh Sq9w== X-Gm-Message-State: APzg51CJsq03BtYenV9VzTIEDTctK51shjKENH3GmyJ4yzx4WHXBfgi3 CGksSyE8d8kB4X2di98LuIat1w== X-Google-Smtp-Source: ANB0VdZu6hzVt7AtJJ93odoQjYkqPVf94rlR0dn8TWfq6mtP95O+CjksaTw9X/gU4LciiEobGBK+Cg== X-Received: by 2002:adf:bd90:: with SMTP id l16-v6mr37047008wrh.250.1537514992321; Fri, 21 Sep 2018 00:29:52 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:51 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 19/22] nvmem: make the naming of arguments in nvmem_cell_get() consistent Date: Fri, 21 Sep 2018 09:29:18 +0200 Message-Id: <20180921072921.19387-20-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_003004_007759_832A5E42 X-CRM114-Status: GOOD ( 18.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski The argument representing the cell name in the nvmem_cell_get() family of functions is not consistend between function prototypes and definitions. Name it 'id' in all those routines. This is in line with other frameworks and can represent both the DT cell name from the nvmem-cell-names property as well as the con_id field from cell lookup entries. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 27 ++++++++++++++------------- include/linux/nvmem-consumer.h | 12 ++++++------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ea05219e60b4..ff21402fbd7d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -977,16 +977,15 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id * * @np: Device tree node that uses the nvmem cell. - * @name: nvmem cell name from nvmem-cell-names property, or NULL - * for the cell at index 0 (the lone cell with no accompanying - * nvmem-cell-names property). + * @id: nvmem cell name from nvmem-cell-names property, or NULL + * for the cell at index 0 (the lone cell with no accompanying + * nvmem-cell-names property). * * Return: Will be an ERR_PTR() on error or a valid pointer * to a struct nvmem_cell. The nvmem_cell will be freed by the * nvmem_cell_put(). */ -struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, - const char *name) +struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) { struct device_node *cell_np, *nvmem_np; struct nvmem_device *nvmem; @@ -994,8 +993,8 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, int index = 0; /* if cell name exists, find index to the name */ - if (name) - index = of_property_match_string(np, "nvmem-cell-names", name); + if (id) + index = of_property_match_string(np, "nvmem-cell-names", id); cell_np = of_parse_phandle(np, "nvmem-cells", index); if (!cell_np) @@ -1025,27 +1024,29 @@ EXPORT_SYMBOL_GPL(of_nvmem_cell_get); * nvmem_cell_get() - Get nvmem cell of device form a given cell name * * @dev: Device that requests the nvmem cell. - * @cell_id: nvmem cell name to get. + * @id: nvmem cell name to get (this corresponds with the name from the + * nvmem-cell-names property for DT systems and with the con_id from + * the lookup entry for non-DT systems). * * Return: Will be an ERR_PTR() on error or a valid pointer * to a struct nvmem_cell. The nvmem_cell will be freed by the * nvmem_cell_put(). */ -struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id) +struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id) { struct nvmem_cell *cell; if (dev->of_node) { /* try dt first */ - cell = of_nvmem_cell_get(dev->of_node, cell_id); + cell = of_nvmem_cell_get(dev->of_node, id); if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) return cell; } - /* NULL cell_id only allowed for device tree; invalid otherwise */ - if (!cell_id) + /* NULL cell id only allowed for device tree; invalid otherwise */ + if (!id) return ERR_PTR(-EINVAL); - return nvmem_cell_get_from_lookup(dev, cell_id); + return nvmem_cell_get_from_lookup(dev, id); } EXPORT_SYMBOL_GPL(nvmem_cell_get); diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index d18caae2f7ac..e17617fa034f 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -55,8 +55,8 @@ enum { #if IS_ENABLED(CONFIG_NVMEM) /* Cell based interface */ -struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *name); -struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *name); +struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id); +struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *id); void nvmem_cell_put(struct nvmem_cell *cell); void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell); void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len); @@ -91,13 +91,13 @@ int nvmem_unregister_notifier(struct notifier_block *nb); #else static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, - const char *name) + const char *id) { return ERR_PTR(-ENOSYS); } static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, - const char *name) + const char *id) { return ERR_PTR(-ENOSYS); } @@ -201,12 +201,12 @@ static inline int nvmem_unregister_notifier(struct notifier_block *nb) #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, - const char *name); + const char *id); struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *name); #else static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, - const char *name) + const char *id) { return ERR_PTR(-ENOSYS); } From patchwork Fri Sep 21 07:29:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C7F4112B for ; Fri, 21 Sep 2018 07:46:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B5FA2DC81 for ; Fri, 21 Sep 2018 07:46:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D69D2DC8C; Fri, 21 Sep 2018 07:46:44 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BECB32DC81 for ; Fri, 21 Sep 2018 07:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oiYPkMngD0DNKGnq2STU9/41Y1Q7q0e1nTCUO51RHyM=; b=qbLLaA+pIAKfZGhBMqLQmhzwe1 6nErVeQppY2UAEopQZ4tsXc4V2PLM7j7ZBQbb0KqDfsRdRygTeYsISujVlpoiAPz3/DzjQ0kjj3+k cGN1xm9MwngqHEf0G29hHkgdFtwHZWVE+Hqna2yafdDziOiX5gGeGChpAfT857WPyRngMS7lVdZFe E5n7sAK+GizyRoG7SmUght/2BxgP8qC4IujR4ffyOL/nMz5WU5y/huGy8Z479LKXwuPlI3kP5blFS vVnb4hrJD+Qc30IOprFrNzfIHwO+yJGhgYI8x0tKLZNSpMBIW5VsaiBDQXhsLb3xnDMINeub4uJy9 PEo5vg1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G91-000144-Go; Fri, 21 Sep 2018 07:46:31 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Ft7-0006GB-JM for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:31:00 +0000 Received: by mail-wr1-x444.google.com with SMTP id j8-v6so8064287wrw.5 for ; Fri, 21 Sep 2018 00:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T3JwPT9aoVeFiw7lwEM5tGc15cd9dEB7wdw3Rm9T4Ac=; b=cyCJgE39z3uNe10IH6WoV5lHS3nTLCMJiNRYcYaFvOSo6L7dHiCMtdAJzA50jU5oiY m3mLtied89U5vLdY9RiYbg6TAtfiD1rW5ZKEHjDAU3V17AAAWUD7S1OP1VAKnIFmJ3VY wSECvQn5Gz3u30TSljY/BWKPDpnWIlGRaRUkLPR3h/yR2bzMH/QhHoFfilSPVTOF2YDN AofSkWnKhY5nEzrTNa63pJ0gy6yzxKUwioXKbVei09SDyOQMSZ6DDQqSlFTGeGYBgo3S +ZST2FAZMoTc4gCyz9Uxi0PRG9Xng6gG4htP+D2sMNX2YzhVfE036682xz3KVO5ACh/t QjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T3JwPT9aoVeFiw7lwEM5tGc15cd9dEB7wdw3Rm9T4Ac=; b=pyzkFrxBsnqmT2bd4zruSZMtQRPnZAoQQek9gc8BgUQuvyqRc+kObO+pvCT425fphA jq2gIdFOPymkXyvHb7jMP60N/kLY0lKsv4fei/ePQs3NSgLrugxSI74KKaBzL51t9GtJ 9HVpy2a4/guMKbzHh1DXEdwcrcwHm6sL2SJ2oPKu3ArvVZAOWTBJQ6P82r84NJweERYM ReGVgpvLpZwXARQpwjqjJeb45JaqJ9T+vBDTog9hzVRqBjgAG3ErinXmAoQW8N3C4AgK /lfN5wQfQLt+W/OmmLaCxZTfOOJsfbJ80uGmMM+b9e/fjxgDvNmfatAVdhjTgK4LVv1u tVyw== X-Gm-Message-State: APzg51BBUUjuaahIge63IiX9F1CorZcXdYt2FH2rziXs1f6URjNxwxkK oyDUayQXb2F4k7nqCS5JYakxig== X-Google-Smtp-Source: ANB0VdZk0lLT+z2B9JRqsDhPBHsRFqWQa8sDVG5d5y0Tj0yzyXw3eQukRVQEcQaZESwRi18Xd7Ut0A== X-Received: by 2002:adf:b2d7:: with SMTP id g81-v6mr10068281wrd.48.1537514993658; Fri, 21 Sep 2018 00:29:53 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:53 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 20/22] nvmem: use EOPNOTSUPP instead of ENOSYS Date: Fri, 21 Sep 2018 09:29:19 +0200 Message-Id: <20180921072921.19387-21-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_003005_720633_FE843595 X-CRM114-Status: GOOD ( 14.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Checkpatch emits warnings when using ENOSYS. Some of the frameworks started using EOPNOTSUPP as return values for API functions when given subsystem is disabled in Kconfig. Signed-off-by: Bartosz Golaszewski --- include/linux/nvmem-consumer.h | 30 +++++++++++++++--------------- include/linux/nvmem-provider.h | 5 ++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index e17617fa034f..312bfa5efd80 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -93,13 +93,13 @@ int nvmem_unregister_notifier(struct notifier_block *nb); static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *id) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline void devm_nvmem_cell_put(struct device *dev, @@ -113,31 +113,31 @@ static inline void nvmem_cell_put(struct nvmem_cell *cell) static inline void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline int nvmem_cell_write(struct nvmem_cell *cell, const char *buf, size_t len) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline struct nvmem_device *nvmem_device_get(struct device *dev, const char *name) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline struct nvmem_device *devm_nvmem_device_get(struct device *dev, const char *name) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline void nvmem_device_put(struct nvmem_device *nvmem) @@ -153,28 +153,28 @@ static inline ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline const char *nvmem_dev_name(struct nvmem_device *nvmem) @@ -189,12 +189,12 @@ nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) {} static inline int nvmem_register_notifier(struct notifier_block *nb) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline int nvmem_unregister_notifier(struct notifier_block *nb) { - return -ENOSYS; + return -EOPNOTSUPP; } #endif /* CONFIG_NVMEM */ @@ -208,13 +208,13 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *name) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } #endif /* CONFIG_NVMEM && CONFIG_OF */ diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 8ae012f6545a..1e3283c2af77 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -100,7 +100,7 @@ void nvmem_del_cell_table(struct nvmem_cell_table *table); static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline void nvmem_unregister(struct nvmem_device *nvmem) {} @@ -114,8 +114,7 @@ devm_nvmem_register(struct device *dev, const struct nvmem_config *c) static inline int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) { - return -ENOSYS; - + return -EOPNOTSUPP; } static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {} From patchwork Fri Sep 21 07:29:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C80751390 for ; Fri, 21 Sep 2018 07:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B576D2DC81 for ; Fri, 21 Sep 2018 07:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A91072DC8C; Fri, 21 Sep 2018 07:44:27 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D3292DC81 for ; Fri, 21 Sep 2018 07:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zphstlY7zima8OgHmmnlQzj5QkpahY6ra+B8zhbKgPA=; b=rDAJftHufa17M/Fa0u93Kfj+hp f55ErKGR1DBYjKx5U8wSwbUE4Av6oE2YCchRpAAZf4B6YwjpaiyzRgBLho+8MUrRuz8PkFMgxgaNw h9+wPn02elCizPQZktemrHYW7tSeDJkvMEke6Vg2xpgNQpBnb7nDssE8QGx/GfsiFiLQStUv3SBfj xcw+Mogk8LkVn5tueZg6ctKL4MGqfEsVxx6UrP0Ll9Hd2xBmMvw2k2CEPL9jxu6lbiLe5IEfPwF24 97xERXgl0rCtdLUUHmS0aUbX/a0sUZwJQeGKyCK/nXSknnMx3G31x4jI8x1xlS3PhNJnrPyqFBKmg B70wb+6A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G6p-0007Je-J9; Fri, 21 Sep 2018 07:44:15 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Ft7-0006HR-JP for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:48 +0000 Received: by mail-wr1-x444.google.com with SMTP id u12-v6so11787884wrr.4 for ; Fri, 21 Sep 2018 00:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bgOE1ULQMMWfipJCdPWyqE18ogCrSsaTmNT0nDozskM=; b=Ew56mpX8JcOajDhnDoagv/zlPqozRf+XrJ7N0l26sBl5oTPCI/MRRAv8L+Yc9Gi0rJ AdhfJ7P+LOg/jSP6kr0c6Nr4PQ7xyXwxbxySUEDMc3/gbaqh1sm+yVhIbA8305jfZIFt JboGV8DC6SpjEDLrmPOPWFF8py5Ah6lEkSAb7qv7HXYZ4cLNQdsTnSJ+ia2FEnWK9Aui 1/8Kt+R9bCBgk4ZPi9cJePjVfjLLE6yNw+hZ2Md+N8iQZsPg4zRV3VC1H9zD4PEJK+Gl jVujRpuC2btIZW501e/wg3E1GRHvquINxteekYP4eky718I+A6PiqWfExp1PUxDzYnng kFTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bgOE1ULQMMWfipJCdPWyqE18ogCrSsaTmNT0nDozskM=; b=k/DomxtUHrfj6LyWwFRBfFr1PicBQ1wkdFE2RBBibDcvQ4xV2g2a5KOJUe/r9MEzPW EUuP/i3K2EMth0fpRe/E3cYiA17AjZEXiJrnWUqf5cgmCoPrE+ojgTmwoiWkGoZLAB1T kXIni76H3SVayN0Ziki80ljCcxLf71UKHKK8zG28gXtAXPNSkq08LKPhx5/kZfbjDIz6 PqxpBeK/evPIDUf2KZvQ2uXdiha0UQ19fDFwh+y0CwJOtEeYxKKTXkEwz3Khhet4v0xs 4sK8FXrCOo4sCoNMLCXSNtcIuctLLSzdkDTBCBPRwkOMcgy+FjwzNuQzatMNwoOC5lPp 9fOw== X-Gm-Message-State: APzg51C3T9G/Unq3bm07bIBPsa6upx5PWgIBGrLNazsknAVIt57BSbGY BGk8rMUNXFZecCe8hragoVxEb+CRg2Q= X-Google-Smtp-Source: ANB0Vdbr5FjcvHNfz971aTXuZ+68jEtvCpG6PCBzVT8r8JmKfHIqtFLjatCFHAB3ncQJfzkEtwjXVA== X-Received: by 2002:a5d:68c9:: with SMTP id p9-v6mr36816891wrw.108.1537514995004; Fri, 21 Sep 2018 00:29:55 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:54 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 21/22] nvmem: fix commenting style Date: Fri, 21 Sep 2018 09:29:20 +0200 Message-Id: <20180921072921.19387-22-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_003005_673649_D15715DB X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Remove a redundant '*/' as pointed out by checkpatch. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ff21402fbd7d..e44a1860a2b3 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1374,7 +1374,7 @@ EXPORT_SYMBOL_GPL(nvmem_device_cell_read); * @buf: buffer to be written to cell. * * Return: length of bytes written or negative error code on failure. - * */ + */ int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf) { @@ -1430,7 +1430,7 @@ EXPORT_SYMBOL_GPL(nvmem_device_read); * @buf: buffer to be written. * * Return: length of bytes written or negative error code on failure. - * */ + */ int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf) From patchwork Fri Sep 21 07:29:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10609227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCFDB14BD for ; Fri, 21 Sep 2018 07:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B99172DC35 for ; Fri, 21 Sep 2018 07:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABBBF2DC48; Fri, 21 Sep 2018 07:43:03 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34A2C2DC35 for ; Fri, 21 Sep 2018 07:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=C4QHXdks/gNkcPS3RiRiy8MUsDTjJbjX5hGaRdFKoXw=; b=SsxnGVhkgpp1W/SVOPDlYyT8J/ tvLGGIypNQIpZIA5mBvZ4OXfBzy6M0Aq2Z7l33MbjQUD4VkG7LumssOxlbrNH/bHiH/2fQpxBWrOM dhSffxAO7y27l5i2Yv/pixKKwSRi3PPzaNXQXpOtImoNZCH/uPz2wveMrIuOMq0WMPt4yBVyW9eMv MPQqh07ovyLCiHy4PctqPIzmLy8yW/IpQPcG3m7WTtHCZtf3uvIzSM7y57K7eANg+jqUAQuoERrku /udmEcCzEARfi20vFVXCbFDu8CimWmBHelb9DSP7iypwdp4HuqfkjLoiJMsaISs/hHatN503U4J49 iF3ectXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3G5S-0006bt-7l; Fri, 21 Sep 2018 07:42:50 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Ft4-0006IG-Hq for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 07:30:43 +0000 Received: by mail-wm1-x341.google.com with SMTP id s12-v6so1965061wmc.0 for ; Fri, 21 Sep 2018 00:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BVLbSgd1wb/HwG+kDXFY/KlS+ziWt1RndHQUeQC7kyc=; b=a7QRAMB9IE3DmEB5wR9u0Mt99su5XgEX/eTSBxVzD+M+bK06knYXrB2nIVT2TrxduA cUZpYJT/MtPZGgRFdqhS3VLRfcRcvCIu8rOeBVci9f34nd0gNHLtOhCv0hvmNRxim+Zs N1F0OitgHNVVuJXUKYn41+enR47CZXFOfhNSjl+WQCYpUcfM2G3PjZg8P3cKNxx0N0nH cUVKQ7HE1bHexVouHgE7NLJHxco3s/lw1oBFde6xCYO9/sx9sefjGHBUwhSpHRid3KpO XiNuNrgJvpBL2FO/qX52yNNrM76OxCcgHsUwLRQygt9FnT5HABpcyNgjomN7GnCg7VR/ x5aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BVLbSgd1wb/HwG+kDXFY/KlS+ziWt1RndHQUeQC7kyc=; b=c/qYU2GRri7+ehftu9SOYoKYqPx3a2rLHT9pqartkQDgX5sfxKo79vq3nUjApgTs/h KYEuekO9SRaET+xejvs1bpkp7GxIjgylTBvhfQ8rsp6qnepv2GFcSyzR1ZSc6zIIxDO3 uIO/ueTOjgffdn3PmQCI2e2UgRphPxoL+QvH8k1/NAW1U4mzpp4ILUkUTmy73/7K23jc Nv1F6j6ZJKaDAicNTj2E6mFublT0kaygJdVig7I2/B/kE8UyCvPj6E+8KGI8/g0iRFZ8 fHa/zoKSAbsHK1hizvMf86pFbyj/41dxR4rHmmGcWP66tWjxA4COH4fwkhvWO42kRWiW 8HVA== X-Gm-Message-State: ABuFfojYkiaOyT+iF2tLZa8WsXIoB9rsqKN8PMMDHoqQkJyhHBP9Xr51 6LAcgVeNSoraVKYENdD9utMV6Q== X-Google-Smtp-Source: ANB0Vdb9HGryc4tNeEoea1LbGzQw/ODvtG/TZj55AVd1yReHsffG/W5gOhQeQ/w4gT8U+wTGGaLr3A== X-Received: by 2002:a1c:e00a:: with SMTP id x10-v6mr5954422wmg.58.1537514996394; Fri, 21 Sep 2018 00:29:56 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id d18-v6sm2841597wmb.33.2018.09.21.00.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 00:29:55 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v5 22/22] nvmem: use octal permissions instead of constants Date: Fri, 21 Sep 2018 09:29:21 +0200 Message-Id: <20180921072921.19387-23-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180921072921.19387-1-brgl@bgdev.pl> References: <20180921072921.19387-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_003002_654143_4BBCAAAB X-CRM114-Status: GOOD ( 14.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Checkpatch emits a warning when using symbolic permissions. Use octal permissions instead. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index e44a1860a2b3..ad1227df1984 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -154,7 +154,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj, static struct bin_attribute bin_attr_rw_nvmem = { .attr = { .name = "nvmem", - .mode = S_IWUSR | S_IRUGO, + .mode = 0644, }, .read = bin_attr_nvmem_read, .write = bin_attr_nvmem_write, @@ -178,7 +178,7 @@ static const struct attribute_group *nvmem_rw_dev_groups[] = { static struct bin_attribute bin_attr_ro_nvmem = { .attr = { .name = "nvmem", - .mode = S_IRUGO, + .mode = 0444, }, .read = bin_attr_nvmem_read, }; @@ -201,7 +201,7 @@ static const struct attribute_group *nvmem_ro_dev_groups[] = { static struct bin_attribute bin_attr_rw_root_nvmem = { .attr = { .name = "nvmem", - .mode = S_IWUSR | S_IRUSR, + .mode = 0600, }, .read = bin_attr_nvmem_read, .write = bin_attr_nvmem_write, @@ -225,7 +225,7 @@ static const struct attribute_group *nvmem_rw_root_dev_groups[] = { static struct bin_attribute bin_attr_ro_root_nvmem = { .attr = { .name = "nvmem", - .mode = S_IRUSR, + .mode = 0400, }, .read = bin_attr_nvmem_read, };