From patchwork Fri Sep 14 14:39:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600855 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 BC21314BD for ; Fri, 14 Sep 2018 14:41:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 994E62B88C for ; Fri, 14 Sep 2018 14:41:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF2F2B890; Fri, 14 Sep 2018 14:41:59 +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 224122B88C for ; Fri, 14 Sep 2018 14:41:59 +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=Tb6iH7dPTLPcEFvti92PTAHnTjgwdsn2llxqG0kWUqg=; b=akcAyJFrhBSeJWVJMLxcgFy0Wg xx0gHhWagDfEInEOuc58tT9s5SV/jgzPFCAU4qujif5Xqec1tJsxLKQpRnNUGpCe/4PyiXeLe0pov QMbszWkzQF++KT1JfgPCY+4Go5wy7I5rv6TmPzyywXWq4I4jmAirKzO9WdSsUtHi63zVbJjSwrGVN dMFA3TQJUcQsnuYv7faz5Sq4uJJBZkUXPvGa97HvnB/XT0vP37zZYd28935QVXlcV1rayl3ZJT70g y7/NiAPoIs00H34iGbCZiboczT2MWluoKiYuaaeJnSD1znjvyBe7RBC5stVOy+JlS7rlTGp9bjNmb 7WQg+bww==; 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 1g0pHx-0001LJ-HR; Fri, 14 Sep 2018 14:41:41 +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 1g0pGu-0000ic-Od for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:39 +0000 Received: by mail-wm1-x342.google.com with SMTP id 207-v6so2181540wme.5 for ; Fri, 14 Sep 2018 07:40:26 -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=ckie7x+arONEAftwpr6LcpA8Mb8Zyx+Fo4gw/6J/zcY=; b=aGJL8NeD2q1SDLkZHMzMrDLGer2z2Lr8CMsQJi10ftvcG5/HOr3eZcI4rSqptvSCiw uzRwbwcQJYG5O2XEEBHex09AVL2AN2jHVHOuIHf58k6BHr1YrrPkv5N2X3KIzuOhRSZh ZK/LjY7NTuzFUSc8FHjoodh5kQx8PdKz/jICQVEzN+8TChULEMmBnt+x3138twCgGgJm LYliBoBwU348C7tPOfjClxmxP9l05pjlD/1T0Vijh2BspkqWpdkckR7n2FKgMisczPtI +XJHwD4Bwa4ZGqIhtXpltpP7rhALqbTTZ68ZjgQuEJ6BapQtjxQS58kGjMaV7aS5PtnX TxcQ== 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=ckie7x+arONEAftwpr6LcpA8Mb8Zyx+Fo4gw/6J/zcY=; b=I0g7zPDmV280G/Z5q3Q9R5N1ZEjtULy3XhvRWoh8mAY9fS3LVV3j1PlP9xlbDBsAH+ C29HBMwxZYsO1lvo7UDoEGn4Yl+kycy92LahzPdAkrgXloaUM+XkCao7xkscC9Ldypq9 eX02+m5Xm72YESvmGPKu74lQJD0WPlKom/4KO+sGRiwN083LyoLevKawuyRdhZLFmaWF AphoMZBExr1h4XSfWQ35GuvRP19tytoQRHOiCgoRUipN6i8j1MY+ZPzuiE73gd7pJS1M Um4GBOUoH04UahyaJ8UH/A4r0IGUdsrax7pKHd4innPccOKVGLt2f/SEyCQQl5YgHx4n Be3w== X-Gm-Message-State: APzg51DUcPzYoWRQ1809hCPF1QqJUhEhc8KFjLmFbY+3gZkyeeCuyiqy 5IhQOhZqFx/GkQDPvAKWEjn62Q== X-Google-Smtp-Source: ANB0VdbHGUseOA6R8VB+dFCItVbCnE4pC/0+VeRKBWTr8GHBsjQa4VpVqD3eY5w62OUaS/KnM5jLTg== X-Received: by 2002:a1c:1ec5:: with SMTP id e188-v6mr2623098wme.1.1536936025117; Fri, 14 Sep 2018 07:40:25 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:24 -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 v4 01/22] nvmem: provide nvmem_dev_name() Date: Fri, 14 Sep 2018 16:39:50 +0200 Message-Id: <20180914144011.27614-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074036_803261_AA1EF238 X-CRM114-Status: GOOD ( 14.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 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 aa1657831b70..d96348ae0f37 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 14 14:39:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600857 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 071D1157B for ; Fri, 14 Sep 2018 14:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA9C52B890 for ; Fri, 14 Sep 2018 14:42:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDC122B893; Fri, 14 Sep 2018 14:42:52 +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 537FD2B890 for ; Fri, 14 Sep 2018 14:42:52 +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=vQyENN+KvgdzC5Ks8yJCyG26J6cw/tq0dVx3xMVay3s=; b=K1OMo73FhuiE81NTJetixqZrXw /85ys7/SNtKf0ufrIQ6/tJyAzrd0t3FiSdfhBoezLwGgmlG/v0/HwPgQB/r6EHQoiFfFINz4otxQ/ f2aZlXGhs/bDdPiwmpPMWXg1vQGwu45crAnzcQV/TVU4U36k3imhzKcXjEpiy8YZ/6rjG0NTpB1G0 1R7syg0pua2HM3K6WdQkoadpPdswQuQHzL1WAq1b5vlYY+SSBSuP61ONetvWWkQCIu2zdYfx9w5kD Vp8KZx8Had/rrajGu7bxF6B4RgrK2AE3vHxutMtBlhBDhBoCP3r3fB2ytaO2miKxtoaC1c7T7Nz49 KCLJd2hg==; 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 1g0pIq-0001hR-Oq; Fri, 14 Sep 2018 14:42:36 +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 1g0pGw-0000p8-4f for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:41 +0000 Received: by mail-wr1-x442.google.com with SMTP id z96-v6so10881977wrb.8 for ; Fri, 14 Sep 2018 07:40:27 -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=To/SQLBCgeq0lnY/26X7cnEpcdLcDIuj/UXMlG3uaxI=; b=tdVj5GlFefhU/37/xmsD4OR3sD01gWfqXfUwQmv5zNZwJSFt2uqRm5yb6o7rW76NCZ 1qg/VipmX9svIqIc8Z7IqPIL8gHhaME9b7uYY0Pvh42UBIAP8Sc3qRnK5Hbg1qPyLZeL WAwAWvs5lRICPJh9D2VSTKMTI2zs6T472BRFt/FkEIyNR61BNlubIZsUPFdCSb0KO+sD tfwGqz7ZM3CX+sIRvBhzVLPEwAIjTyVTSGwMMRIGOLFbmO1KTPCuNPNphdi36RxZwwxK ghXiQF8gH7UEbjkP3kFFVNwoWBt0flBCjlq+bkvY+ZJ3AuOnvVrryfHmQjjjg4r+gV57 gNow== 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=To/SQLBCgeq0lnY/26X7cnEpcdLcDIuj/UXMlG3uaxI=; b=s3n9s0Gb2CN+uax3sDDjK9fmS1nX3S0ZU2D5RYhihqzqk+elJFPCzVYZAx+HjiYo85 y2E0jY2TBUpkH9RYPfrmpajGoKfEMi60zeiya6RssKMmgTSwI+6HG66kzl6ihZ/eM5+J +PEX/cc4AkjK09YRz9OE62WIcGuvgZZg5UpEts/jxzlc6Lm4lt0ZiEavpu/wh7/4mrfg /bWLUwmV/JNF3oTFvxzufX6G0QX83OYcPuU9c67f1+nCavxME4iaxPYdIme5HswK6SOr PST9/nCmjezMvXueWH67Opoarc8Ys82mfkRTzIrYi58c9GCBOR77azwTYmw+qoYGVJbR AEjw== X-Gm-Message-State: APzg51AFIi1IzlIsgWk9lEFd8rDkgbIqrP9EjqvLz3Uze99hEpfXomlv glwEVqW184kBNnj23lm68b3Sow== X-Google-Smtp-Source: ANB0VdbD5bR5nBTiU0E1EUKOniCAUGLi2ZPGC0OFUhyuP64ZlGD5Gitk+ZwXUBvxo+rNE7I2oEW5OQ== X-Received: by 2002:adf:c684:: with SMTP id j4-v6mr9968773wrg.243.1536936026440; Fri, 14 Sep 2018 07:40:26 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:25 -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 v4 02/22] nvmem: remove the name field from struct nvmem_device Date: Fri, 14 Sep 2018 16:39:51 +0200 Message-Id: <20180914144011.27614-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074038_214691_28FEE107 X-CRM114-Status: GOOD ( 15.56 ) 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 d96348ae0f37..8987da0f7456 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 14 14:39:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600861 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 2E28C14BD for ; Fri, 14 Sep 2018 14:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DE832B890 for ; Fri, 14 Sep 2018 14:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 014AB2B893; Fri, 14 Sep 2018 14:44:33 +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 8862D2B890 for ; Fri, 14 Sep 2018 14:44:33 +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=LtK98uOl3ZAUfGBQz1/TUquKPb/3SWs4QgjGc7zHoxg=; b=oqHgraRrDeCr2wOc7IaM99lorc VY/k/OWmDTw+PCxvGK2Dum6TVXfBZNod+YGAj4vUCzY5heqVLIUMA6Pq3JpDnh0wYtlj7K5PQcUOm 2HcR7Tpidc5ZVaV2qFVe18cB0yzufJDAfKtqzJHn5iBbl8wSjGGefgceRsjXkOCMFxTLBj4tcOWWT xAmDu55JUzjLgR1VuTuVQNma9Gu3qifT2f5/6qKpxPm29NIJY2QXqXNAV+t2ofbK/pds1XAA1Goqq o11hUKPs1nps92ogUELuHVaZ5nzm33zDyYc2UE85x/2NHqMvLF2neaOMYrwLpLjwZo7Xbs5Tpp+MV S37bUYYg==; 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 1g0pKV-0002Na-62; Fri, 14 Sep 2018 14:44:19 +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 1g0pGx-0000py-DU for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:41 +0000 Received: by mail-wm1-x343.google.com with SMTP id n11-v6so2188359wmc.2 for ; Fri, 14 Sep 2018 07:40: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=j5VzygIMcTmrTIR1xvM1gLa6GSilUZBltKq95M6HHPU=; b=NuUWQ0egq5rhjpw96ov2rRI14N6D+0MsBMpOYkRNZtSP5snOGM0p0hOHaB5O6RxBMH UnChgkAplDVWzwWnmdYoiUN/Oe7vq2SPZTD7/8GHCfvrGE654PuT8T6nYE7PljvqAknR FqmA2v39WYp7tPjBST6OL7uuk0Rxk2tqjOiQ3xFbriEEfYepT/ZJJrE0h4+Ov5KX1RdE KeLnkxgAPMzY5Fwt/Dqx1EAIY/MbTMIkhutJmW3japw7DI5c+W+X7KE1Xc6pZPOPm1LH diS9rHT5V1shii+T12U/vdn2MmgQDFLMBGqGeekoYvZBWXPz59o0ERbhGGUEbdsUuuoF qhHQ== 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=j5VzygIMcTmrTIR1xvM1gLa6GSilUZBltKq95M6HHPU=; b=lGzXtDWPtduh27Mc/szKUFNtIk5q0S984tKT9amCXX9tN7zXyg6QPXshgq9OW32EF4 NE0LS0pC7d8kkRIEeSp2AuPMSycqx9hgEfG1c1uWn3iUiBz5QqxQU9Or19UVKydfzhGR EksAjGM3yQ6r8Iz2LQaNbLsU6XYOw74/g1ncAO9WrMCyu5CsUJM4I1XBfXs0BUPv/mTt ZfC5FrVKb8UFLOQsMO200nRddovJ9ETSIe8eZl0tMMuiUBqq5+Mx4lzOpE97rBIL9MtB cQIX8tLWbBT8N79f0UtJBONEdBQ4UUpI86zFXcKMFuPjOwovIra/a1jUR5BtYuD4kZ3P Bw/A== X-Gm-Message-State: APzg51DHM3uKGwOAkc8m/h+7yqcsL+PHqkMFs97X28k9pnZAzi60KeRt Fd6VyGdOGtmdUdJnqcFcSM0uUQ== X-Google-Smtp-Source: ANB0VdZlclLE5F7JZ+fJ/2PhQs9vzg3y/gJAwDStgrA06ANeyynHGGfYQpupAayEc+5lWmP4KuUM4w== X-Received: by 2002:a1c:c501:: with SMTP id v1-v6mr2681386wmf.115.1536936027782; Fri, 14 Sep 2018 07:40:27 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 03/22] nvmem: use list_for_each_entry_safe in nvmem_device_remove_all_cells() Date: Fri, 14 Sep 2018 16:39:52 +0200 Message-Id: <20180914144011.27614-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074039_493093_95F18AFD X-CRM114-Status: GOOD ( 13.60 ) 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 8987da0f7456..b69005367908 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 14 14:39:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600871 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 6803313AD for ; Fri, 14 Sep 2018 14:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 470282B8A4 for ; Fri, 14 Sep 2018 14:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A2852B8A6; Fri, 14 Sep 2018 14:47: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 BEFC82B8A1 for ; Fri, 14 Sep 2018 14:47: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=6loovYvtbR/an2ow4+5x2GwPQNLALxX6IquPAMZs5go=; b=hbcekg1ACf0fgnkkbXE/9dgDJ0 56M7uPfYh6Nl2Lsr9NBodWXimwtUNEJMNAyqWyMQhBCzuV2R4qoZ59Ux5FKG5swPfGt0FBOijsSaT tASsI6iP0Mz8Fh2Be3w+G28zoNbbiTAJlgBukuzGgTRnLpGtMrZQmO4FWNSIRMhIjlYbLoyPEIBsZ 2BeiyjP+JZrunNBmi7Aj+fzZYyI7EYa+iWtD0vgCmnRq/CWAqgzLaEjdlrZwtKU72HbCivZ5NJc/e UmzbJmVkVsj3L2IomsAzlF7YWERVbBBwaCejvi6iA8vGk4FVl/8mmR6Mv7+qSCEHFIrC8fD/pyZ4s 3kxHTrpw==; 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 1g0pNT-0005my-Qn; Fri, 14 Sep 2018 14:47:23 +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 1g0pGy-0000q6-Ol for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:43 +0000 Received: by mail-wr1-x441.google.com with SMTP id s14-v6so10879246wrw.6 for ; Fri, 14 Sep 2018 07:40: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=LlD+NifSVaE3IfYdeYyWcCIMEiVmFR39vy4y8WN8rv8=; b=kwvO6hHYoVK6Et8cqODz+uSJyw1JFE+9rpWKLTKOJIcAVd2k7gjQONwAH/NfmRbOaw 9BDngcuqhDI4WF49FltrihGy9WKTau6EXGhZ7ZAIQDrZAw5uJWWKQbeNH8RLcyxi2Zkt rdmhEe07bXSLeeR0NTNfU5ukqdz4bmf0wZUKs8lMutBV15+L0778Kv7kABmE8s8YAwAp +MtAXmf1dFcS48YThM6WcKUDHTrwuatE3Pw8VtqenpZuLRtHIgj/SFy3uXKYwYnBArC1 D+8NyRoXa/zy/dbdZZnhwNSX64TlFzJKsuWNmjuQX6oWWz2Ym4e1cEl3pyFdWcGJqo+B m1PQ== 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=LlD+NifSVaE3IfYdeYyWcCIMEiVmFR39vy4y8WN8rv8=; b=W17fYR3shbt+SMVhqIdPMnB7s5xdIvTRYjT9r1zYKmJH+df2Fza9qzqLVHTOdHPaOY 0J6iPYLgMtC4KJfbv6m3mz+vaQ5+bOCH5IDZnFuSSnLrFaSCSs9HNtcIGNfe2ZnmuSyU OwXeEB2PxXelKr/plhtWLqDOtbUgy9IOoEdryFIIPgzbxGsyE0ipkdrE8HMGpzSDzWkv oKPQ8BIdSIMNHbgXLOUnmUMn6/3N7Wa1dAgM19YKX211/DFAdMhyVt4FpZPjV2vlhrNm pGRWLe8mhPO8iG6hlkD/2MEnbueY7/TllO0zggHBXMhdTOVh1ean3W070/fn6XK+n0s9 RTFg== X-Gm-Message-State: APzg51ATxMUCeSQRaUE53G2X6NdpmUhSZZ6/xlLe6Sat33qsLo2G09o0 aX1b00m7HsSuKUlPBShXFUWHcw== X-Google-Smtp-Source: ANB0VdZQu68ZpJmiUaYe1juj2SGgRn9JjIQ/XZgmIF8uHv3fD8J57t71s404Jw9gEreKHVsXuwxVeA== X-Received: by 2002:a5d:4605:: with SMTP id t5-v6mr9322475wrq.200.1536936029060; Fri, 14 Sep 2018 07:40:29 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 04/22] nvmem: remove a stray newline Date: Fri, 14 Sep 2018 16:39:53 +0200 Message-Id: <20180914144011.27614-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074040_867291_B3DD20DD X-CRM114-Status: GOOD ( 12.37 ) 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 b69005367908..b469f700c699 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 14 14:39:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600869 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 AA73814BD for ; Fri, 14 Sep 2018 14:46:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88FBA2B89B for ; Fri, 14 Sep 2018 14:46:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BBC82B89D; Fri, 14 Sep 2018 14:46:52 +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 0D1822B89B for ; Fri, 14 Sep 2018 14:46:52 +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=PIq6UtdxwIkWVpmUyGrh7vae5i72ikV7bJNM/5BwrqU=; b=guwD4jzxymcCTWjIZ/eXhGEzcF pYV7ZLNT5JxilArO0gNk1g28YuNBoNO1XGJcuAORiVkxgaAVjn7K09TSD9f1CXLK4TsQtUJB/udSl ajiBgVkenvEMCXO92OhgkRZsK+7q5kapclR2n3/RsaEOroCXaca1mEtlpOeoAL010UGdIpc/p/j2b GqBZaJpHUKNOmvtnjYk8J4WPNQg4I6gbXAgpKqUq+/sVs+KRgNm5gwunT4gqBmWNIEXETA4VjyeZb cKu3pdu2p5s5P5SVkYe5GfBdkXyv+/X2/71KWwhYbVaH5oAzm3pvBOD+0JQxWT6GKO/3bS9ppz6IZ bugRywEw==; 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 1g0pMl-0005Vl-Sm; Fri, 14 Sep 2018 14:46: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 1g0pGy-0000qN-Oq for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:43 +0000 Received: by mail-wr1-x441.google.com with SMTP id n2-v6so10889060wrw.7 for ; Fri, 14 Sep 2018 07:40: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=5hy1cImwFLaoJYAZMstJrgaN4xDvjcz+dii9EY6OQ8c=; b=o0XNS9YSB3E+o5w9WuKdMh6H+ShF1Ispq2AgrjESnp0laXJjmFH4P+biT9tNq51vGf 1vKcEPm5C22/lPn5wyIZyOI8MoTSW6BASGR4E/rolX2DW5RS30NCEurmZ0QZ7tOb+L3o 33Q8ghK9hbaLP8ts2Rf85sF5zrv+5nnY0ZxoCQ0SMXPnS4BX9+88L9W6mPGi+Vhj1+Og WNz49MqJyZ02TctMIO6WUnyY/id50Zd1N9Syc1f6dkXLyft1U8M2jjOU5emImD0ragQH ZkiUJ8sAk9pdtbV4Wi3gosezr/8VgiUOZW+zzuGXhPBTuJJs3r6pru4gClvJyZ0Q3rXe /+SA== 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=5hy1cImwFLaoJYAZMstJrgaN4xDvjcz+dii9EY6OQ8c=; b=GsgkUhfDcSz1FHDQtD6xfDTgBGADoZPs+cTbunI0WCHJszXDNi2qRejIJnhtHOoueJ rhuaYVxp8CFHG5K8mRaS3wJiwLzIfVZ3YwveJku2RO+gHRSe07usAOYow8BtAn0ZoaLU 9BgvTkghhwsvQDXt3RDBe+dZldIaG43cnH4ZIzlI4JrU+B69f3KQOZWQKKulSQ7XfrDM 0YsCX0gKcxXH5qv3nzmDv3ZxlB0SH+AYD4BzACuzJkUu96LlaAg01mpx2yJMohDHRVt6 GZWIWuLLsFrrj9uWaqugNXiFCSvxliZlM9HKez5YyH188gMCJSukw+qJFgibgXVVab9r i5mg== X-Gm-Message-State: APzg51Dw8HpFI44MH+2UA4hQVpW7hV5gE5+ruPF/T8cosgN38iUt1CA8 m2OECRXM62zDqU/FiAZAH9VTJg== X-Google-Smtp-Source: ANB0VdZhDkcM2z7bM3oRujFanuSA4xLtl50xZNt7TIdAgbgPyQbpDPu3slIPOgPa541xQJ+mQXRZVg== X-Received: by 2002:adf:9f13:: with SMTP id l19-v6mr10382180wrf.206.1536936030348; Fri, 14 Sep 2018 07:40:30 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:29 -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 v4 05/22] nvmem: check the return value of nvmem_add_cells() Date: Fri, 14 Sep 2018 16:39:54 +0200 Message-Id: <20180914144011.27614-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074040_854527_80A2ECC2 X-CRM114-Status: GOOD ( 13.88 ) 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 b469f700c699..ffed8fa16936 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 14 14:39:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600859 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 01A4814BD for ; Fri, 14 Sep 2018 14:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D52742B826 for ; Fri, 14 Sep 2018 14:43:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C69F92B890; Fri, 14 Sep 2018 14: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 494612B826 for ; Fri, 14 Sep 2018 14:43:39 +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=JWo4b7LYDzLmm1Qo5AeqgCBh/roaIOS0AzFW2ljPXz4=; b=fMb+Cj3yIM1kJ93dE0fyUD5eZz k5Yp1A304S44BhrZ1+g+APgF96GUp+baR1bJOMzAEN1o5ZGiy402OnOmK/yZTGmVr+UF1fJL10U7V ZjcHGXZhujZb+KCf1vC1evBJmgoy876WG4ZlMAOR9hhiypv8ZDGDOQUCeKsI+PymcsDD2bVqc23ze IYRCt0EEbeoy0exjk9JFDQoGA0bQkbN7T4J4cpuTug4mBQvNRUKq1J8T9aQ1FD5fEjMJ7Zx3+wdi1 o5ldc1PlL6qPhe/kxnSBUCDzrb5/DI3mvNxlRoOBQrviS0wm/YDd5GXp9XEY7chaSv+wB2qOG034j 1udcjY8w==; 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 1g0pJb-00021H-2e; Fri, 14 Sep 2018 14:43: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 1g0pGw-0000qx-50 for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:40 +0000 Received: by mail-wr1-x442.google.com with SMTP id z96-v6so10882290wrb.8 for ; Fri, 14 Sep 2018 07:40:32 -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=ItU0oQ7oWgVAhdtVOsH1jZ2YSN2mvMhQOChLXBHLTVc=; b=x6jtNJmKVqd0wEpnwBYoZV8FBftk3EGFrPNFcDlF1XqWp/Ki77ks9xkLw4wPj1RBY8 0oPEswhGGAPv5BSYYJ67w8jl1f+eSQ/Nke/3cP2cLq2RUYUo7gKz3X26EB8OXUL1l39R R95dn0z/Zq7K8cWMU1h/IDWRl0i2k9F0da4mRjJx8Yp0tjflrAYjRZ27TOw6LIYSacZP nYh31cL/uy88pPKQB/pdkRx/OJPOKrPnUeGGxv0CZmZNc1MQE79X2e10WgfLGlL4lgGF RlDaxATYb8ETHkRvmQ9j7AxMos0OgG70z9SznH3cZsveMO7Mr+YeKSa4Z//jEZt9aOMn 4v9Q== 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=ItU0oQ7oWgVAhdtVOsH1jZ2YSN2mvMhQOChLXBHLTVc=; b=GeRVfy1NYOTEN3afdqLniwSlK2ZENesRi5YHoVCc6Nn/UvsjtMDuOvtgHwCtkuu9hM r8he8ZpFnBtZQHoZj1gFmVK+nzWmpB1lnA+ga6Y+jws19DL7pfiWfIkUHgZVox2Rbu7E huxU3D2hpbiZw6O/h0mBXEjmxdJ6PN14cMywNvE1uUAEWxc1nJlHKCl6AclVqf3x4ZXH xQhQUJlTFHTKp9I/ZSYy9VswDTJ+istl1zP5KoW4QbStCAbQ8Nyu28d6OT+3vn0s/NfQ 9vueSG/CdKnAXL41hnaRl53qW18Uleil6jSp3IJUxDe5hUUpa+1kgK6IuNgPtlQbUwy0 Bh2A== X-Gm-Message-State: APzg51DgMvhbQpg7W9o7D3lpQosQaya80zOnwdpJm81vYC+E2EpcZWNw xACoAurt1hrzYeUBvqstunaQlQ== X-Google-Smtp-Source: ANB0VdblATkKapARBX1WtsqhnW6GY0ysrGw8SesGgUpQeDdRDQTQMV4ViGuxsSz/4WGZQVyR03xqeA== X-Received: by 2002:adf:fc83:: with SMTP id g3-v6mr9627462wrr.216.1536936031633; Fri, 14 Sep 2018 07:40:31 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 06/22] nvmem: use kref Date: Fri, 14 Sep 2018 16:39:55 +0200 Message-Id: <20180914144011.27614-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074038_203181_61CBFB80 X-CRM114-Status: GOOD ( 17.22 ) 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 ffed8fa16936..552ffedce38e 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 14 14:39:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600873 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 E45E414BD for ; Fri, 14 Sep 2018 14:48:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2D1F2AF5E for ; Fri, 14 Sep 2018 14:48:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B41E42AF7F; Fri, 14 Sep 2018 14:48:14 +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 23F6B2AF5E for ; Fri, 14 Sep 2018 14:48:14 +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=qyuYUyZTV7vQkVq5Z/VwzzMHtu mMiIbxxHR37S00bgvZfvx99N1xoO96fWNivG7lHrFyM+vhJV2Zuw6SmcZJfxtmdDOcBczd17j//8p +HR2iKlf5jxOTabJArhb1zeRp2jyyj2+VepSqmwIItwV30G/uQr6gtFvBrudZ+PpqAFTZ4CpJ3zho unJhvLDao5uy6a6GFyywGCDpCrUwRvmVH98Pvls3cuaw8iB0PRs7PQd4T+1w3HBJl6jLgvnyRAC6e ISOF3bJgsw8KbQoFCaUs/qgkxfGRvF4jVdqFrCwwJuNJo0PsbgErLu8waZhXsm3t3u74JICUzO2o9 4MlggaNQ==; 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 1g0pO8-00063Z-El; Fri, 14 Sep 2018 14:48:04 +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 1g0pH2-0000rS-GR for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:46 +0000 Received: by mail-wr1-x444.google.com with SMTP id w11-v6so10880600wrc.5 for ; Fri, 14 Sep 2018 07:40: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=7pNB/YkN9hno7KdXunbmQOYsXKCGrUI9TMuetzklSpo=; b=kVueZXqzj43Ei3Z1+1lFMocjfG/ooMES8MIemzLkdHBxyGqT+VEsAkbbdYoilTq/VM xhxqidCZTA2zjXLS7a/ITVZnZAc+rnxXNjotPFDbXFyDMY6AWSje1CxxdRiSshj44BHK jRhqz/35mpC/P4YeFVwqvq//8J4u8Cms6EUdrRzo2ilGg3EM3vHCKvte5yDN1Bv9xqPB Uxrmf1IZPmMcOn6sKdYwsdB3UXDEE00yk3Wcso/mf9cNHx4c/7jpiZgt4urzrOqYkDZ3 otm10MoZyqiJWEs5D1eo3o0Oy2XfyxcJJbCqW2SgKPiob5gaP5e+c71rqqFDoIcRHkMP RmeA== 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=eff89KHU/m2jsGUrl/fkfVEc+CI/+NkEqKC78fjgJrrjoKdyj8SInaFROUvq3PL2jD b5MBmlZo5MiaOChSi18gzPtIBxqTbKln7U0CAPGUlgOsoDSRjGT010WrpPL/DsZI2cHy i4Gp3EeHfLSBLgbtdBK8MukdkvLGs+R0TLd4nXHmnitCdkas31Yj5T/3M/TP/sL+I7Mx 6DjhQWaAdkyS5vGMKY/KyfHM1PyHzM0/9EfDtFrud3KA314eDRlHTzZBjQ8tcOT9zEIZ sA76xjAYLX8MZ8JQO3dIp8Zuu0Sh5uVlnP/TVDY34gMRGoogz4xwd6xW9sry5DUArSEi T+BQ== X-Gm-Message-State: APzg51D2Vc8bCwFkC+mG+BgQUae/l2ja7WVZH7b6++eMh+C0+mJ9D6LB +6WZCwcE5vnZyxS3B3f9GqmjPTPJSu8= X-Google-Smtp-Source: ANB0VdZGHNWzAEllVRroGFkQVUm1NLL3cKkbyxRGezizukVkvSVhVANUJu6udaTUcIlVq2qbG/SbDA== X-Received: by 2002:adf:de85:: with SMTP id w5-v6mr10818141wrl.270.1536936032885; Fri, 14 Sep 2018 07:40:32 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 07/22] nvmem: sunxi_sid: return -ENOMEM if kzalloc() fails Date: Fri, 14 Sep 2018 16:39:56 +0200 Message-Id: <20180914144011.27614-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074044_573934_3FEEA202 X-CRM114-Status: GOOD ( 15.01 ) 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 14 14:39:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600867 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 A026314BD for ; Fri, 14 Sep 2018 14:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80D692B897 for ; Fri, 14 Sep 2018 14:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 749432B89C; Fri, 14 Sep 2018 14:46: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 F063E2B897 for ; Fri, 14 Sep 2018 14:46:00 +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=EthYpRvqB1F6IUARAFoMbP+an0 OI72w5QalUYk5FhvA0QQOr7/y8o5MAUPa0yQCaNUjWaILDb++iW9FFqeBcZUJUCMlvLiWGdKyfysH ZBtU8sZV8zL920G09aE2/I8zV/qZdnXuS5Jgsv/UAjBDTPuuo9Mgzqjp0GUaXf5+qfAqEgSwZkpXf cHlmR487PRfT+MhT9Y8DaMuEnt8zfLHaOF9ShPN5LG/HmlfrmFrFTYTc3834sCxZrMe88imFxYZk5 1t52iG9Irnt1Wr+ymyteH+P/XVyiP+ZIOzIEu63IpeMybpeWzMBfgcTLuFBt642OXbAOu0uks1lcc Uvb5oLrQ==; 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 1g0pM4-0005EC-Mw; Fri, 14 Sep 2018 14: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 1g0pGw-0000s2-5L for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:41 +0000 Received: by mail-wr1-x442.google.com with SMTP id e1-v6so10901500wrt.3 for ; Fri, 14 Sep 2018 07:40: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=M9taBHuR1Z2o6Tp/6FUEDxrf8r9YUt6RGonYwMvTT5A=; b=ZV8OEDNLDzAqKYFT/h1fmNr0LGgc6hSRMKH8jwYkb7++Fs28jhjP94E6Z/qM2Zy+xf ZY+PbDG+gl4pECeSwdZ4u0IqwX6ZPTCn8RveRw5f5LyNV/wIk5EzJj3GODsSGFvESZrd T6YmQ1F2Yerk5/mPuhTtILw9vZSUSDLt+qBJh6zKFzxKjWcF4BHgoPiSgi1PpixweveU QayhwBH3VH6Elvm8sQkWhsB26OCqbTwO0HquS2DBwnWre6NJn3VPbbtEm3FqJKF12I3s KnhRtKqIr62H8VU/H/a2jPmMywAMRuTkF5JC0g2fcLdcGOQnam6td3eVHnm3YHFmd0my hQeA== 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=EkpvGo/OgDU3kCsYDpQQjxDp8bbVRwEmpTNtI7ou96uU3ogTjdUgIIZHdif5ccJ935 YnzksXlXFnI8vSl9rbdY/IvIG2CCsCOCw3+q0AP9fStea26tLWrTx3QdBUCsoUfU8bvu s2Mbt/i0p/yT4JtICbY6cCfapW4r+5UdXFfAzRgbj8a2sibYvxUI484qGa/1fI8EHl9d mU4GRn2hqOELsYAbaKuWp/Sa0nAQVkzGU968RX5bQRXwkpHw75GG9OLNFQWWUIUsrIlA cfWi7anW60ygMt64fNGRqafpXBjHZlTm55FZ1kQR4F4U/fB1iaQbjgtEIbtKIZgvmaCu xt0w== X-Gm-Message-State: APzg51BMqVR0R89p4fgnaHmDulMit0+phXQFT/yVWd5X45YSuqFBhmLO PJbUqk1iFbLwQ56nNroxnw8VfDSHsoI= X-Google-Smtp-Source: ANB0VdYInIfM4MafDSF34HNDSpOlPYMYbsOmD+6s3esuwAMxaa9I90iHesl+qaV43/rVItBKNcBDMQ== X-Received: by 2002:a5d:4648:: with SMTP id j8-v6mr9722923wrs.52.1536936034233; Fri, 14 Sep 2018 07:40:34 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 08/22] nvmem: sunxi_sid: use devm_nvmem_register() Date: Fri, 14 Sep 2018 16:39:57 +0200 Message-Id: <20180914144011.27614-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074038_216407_77DB7F59 X-CRM114-Status: GOOD ( 15.42 ) 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 14 14:39:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600877 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 609A013AD for ; Fri, 14 Sep 2018 14:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DE3C2B884 for ; Fri, 14 Sep 2018 14:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3078B2B8A4; Fri, 14 Sep 2018 14:49:46 +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 C8DFA2B884 for ; Fri, 14 Sep 2018 14:49:45 +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=UqkgO3HhTR3SkW4SjbdlZlP6Fz Lmg/gBXQ8edWwN2cmw5r0yE4Ac5Gqf3vXrFBIQmWj3TXmLKBtEMl7gi5t/04xsOgeEcP7z0fbQq7/ 5oz+dS2nbiIXsr/xGtQn7R8+79rIaA93BJUPwLKO4Nz973yJP6yM2uWQ1tl/pE1VMIOzKe2Jw/izU NRbe4DEumzsP5I+1KEe/YwMQph4DE59VB+45DhFA9G1iEw2Lv30X9RGZmr+5Tb4fn49MR80ZY3q2K HTz5KEw/SCdW4oSTYkCJ9StXaSZLNnDQAYY4DsbPyktrrBQ1ATeJw8qSKLmbzarYd7My1OvDpSoZt ifxl+Z7w==; 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 1g0pPZ-0006b1-7T; Fri, 14 Sep 2018 14:49:33 +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 1g0pH5-0000s6-9z for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:48 +0000 Received: by mail-wr1-x443.google.com with SMTP id g33-v6so10913443wrd.1 for ; Fri, 14 Sep 2018 07:40:36 -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=S7jbs5pPQ2x3wKmhl12WP8g1zp9JDwpVIt1QT49EXeR5DLKo2hy3aYJPrmap8/bue3 w9ldGm6jkuCKD47VfAVUwdnRu4tw+QAo/0nYhqtnUfgsutWPjzs5RpF/M8aSSXiXeA9n 3nY/g4LSs5XIOgYrvpKap6ONXJuzGMs/aGXx42ZBOXU57gMPeEk3UL7dcFw9arEwS6r0 Uv3AncCtRfQCoKdt8aiWQZbAylcyKZqRNddTD02zT0HoxMsZGVastn6agIKjmVlKsszX tRGR5fg6X4gO1KjhVbUr9Yz9nSiWpRnI329lmZBmxE/XoCfaLvZ5wu8hnqABHuDPdi9S aN7w== 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=ikE0e4HnSaIt3g1dF+dgPQ5X0HgzP/vUgWASZk+zK/r6ighSqhcie29L/Tp0oOpz1R qfnshf2BftFpL8KHoY3TZWhQUxFv6zxkRBlTRpc1RcE/FWiB0UFh5Vj0fKnnL6dt8GN/ Mx8Utwgfl69TxmC/TLOfSXW73HCZRZn3OJIUR6CvXvm+GXOelmTPBxU7Zzlwxjv4EJL3 yrIxkls84gVTkRolQLE3DqUY2XSnjTdFebSW/qvX1dSf6RcHP+22kRKpyUI3vXAZxzre CARio7fcuo1s1laC9YCctkMEJC5vbD0P87edIx6rXpqi6ULQkA1ui8flgIS5j020EOL2 4mqg== X-Gm-Message-State: APzg51Cvl+/OlZE1PDWNtbbhrN2CZGeA2/HyNcP4+6SBnTfxUntB4uhz b5/iuHk1HLC/fSW0r9m2OYyVJg== X-Google-Smtp-Source: ANB0VdbiWxIsIrJKeRP4iH0O3gtnMPpYpzuvzvv/gKbNvuLJuiqaPtjl/n/DkJoHAUaZS7WkLor/xg== X-Received: by 2002:a1c:b709:: with SMTP id h9-v6mr2482752wmf.130.1536936035500; Fri, 14 Sep 2018 07:40:35 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 09/22] nvmem: lpc18xx_eeprom: use devm_nvmem_register() Date: Fri, 14 Sep 2018 16:39:58 +0200 Message-Id: <20180914144011.27614-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074047_404562_E6AD1A97 X-CRM114-Status: GOOD ( 14.23 ) 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 14 14:39:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10600863 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 0137E13AD for ; Fri, 14 Sep 2018 14:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5E3E2B826 for ; Fri, 14 Sep 2018 14:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C97B02B894; Fri, 14 Sep 2018 14:45:18 +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 5F8752B826 for ; Fri, 14 Sep 2018 14:45: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=V4U/VlmG5JWS3uODLSAR0HE88DftOmP2cW2rKHjWQRM=; b=Yt1iicb/LqQYGmf4QmG8AlsoBb U5+NdEE1MG679J/MRMHZe/QeHaSqc6qYz877U+2ZZkv8QseTATBpFFhdPVAWSBgsuD53723JE4KXY 8hLYvvwtFwHJjjgOa6q2YT9Xoh0xOAzagxCuxoikmEUGCHxKVLu4Kr7eGhdzYB6S6wNpgt3WgUlhH z+ViW3ueF5W1M1AEwOJrQF+WQxvwu46YfKzfneNJoDSJPwc0AUN4kVE3R4Z95ys7F5rTym2mk+h08 sJn49aXSz9i6wFHSlVD7kfIsUVQ2HRv2vXZwioncqJbZG4WO43fw47aOuT9g0BT2ARmiQoA6tOAx0 poCoAhCA==; 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 1g0pLE-0002hP-MA; Fri, 14 Sep 2018 14:45:04 +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 1g0pGx-0000sV-E7 for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:42 +0000 Received: by mail-wm1-x343.google.com with SMTP id c14-v6so2183062wmb.4 for ; Fri, 14 Sep 2018 07:40: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=enYwgS0Z/OX0ykxo6KT1YIz+qVBOPAuLng+TvhpgC2Q=; b=J0tuqWp78z/kLE8iKSFZ9qTLtR9ffUNnaPhG8bhPBRUa+c3nJcxft2O95gA8Ihugen uC23jq4mGvPuJh0uI9e7tpfFNEgQyw5Xrtgg/MhnZpx2S38tc+aVx991nB8a182v3yz3 uoC5rZp9NGqGMzU1EWu7zxLKgpLotfVIXdPk/yJVEr0iRyBJvKCsR+KUVNFXA5Nd9UtX q5sqR6oge4AoM3HjIo8YIWP642CRNNLBdKkFW+1ctOnug5huoJpjmSa1yWdU0BIBbLEy SzUR0rpnR5lKp++KfieuQyrgtvORNpNayzO5VPERvyprWFbLl6WmaD7w/iYilKsjDWEu b3fg== 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=EtQ8utpJfVuuoH/2aD98lF5wkUluA+smwlhcqeD3LE/KI/9oksURa4kVuPa5nOyNk8 AjhMVX76MeYaegdNv7a6iPxlbK45clF7PpY2HC40fOe4E+gVqAdsU2pPMN9yOvvBtHl8 AFdt24DGPOEgoD92U3u50ZNZQNH8R9HCPjX+qeRHYwpFsIn69rmboydfCEE457bam1IZ 8CrA6hHNhP/48v4ViX0xOj8zm80yQ+tHHqtMJSwkW2oOm3BXcvOnGEKQ5mYbhJqmdiM0 yxq+kwKlhQZRpo+NmKWQHvXqZKupiWsT3yR392lOxvC8pV9Gw/w7cCmq43/sdbbJbUQV Gihw== X-Gm-Message-State: APzg51CL3TCqXQsBTXL7Sr4E34Wb8qjlvBRb2kVnQ50lhv6RnCixrpvU 0DWkK1+2ZFLP/ZLca/wUjCci6g== X-Google-Smtp-Source: ANB0VdYSJoaq9YUkUfMrwDJmJ+UhshpcMNt1XhFoxdx3nGoTVcq/P5Nnu19eUdKBLyJ3Bp9dxiWEdQ== X-Received: by 2002:a1c:1745:: with SMTP id 66-v6mr2530682wmx.38.1536936036782; Fri, 14 Sep 2018 07:40:36 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 10/22] nvmem: mxs-ocotp: use devm_nvmem_register() Date: Fri, 14 Sep 2018 16:39:59 +0200 Message-Id: <20180914144011.27614-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074039_515527_0909C9E8 X-CRM114-Status: GOOD ( 14.40 ) 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 14 14:40: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: 10600893 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 10FEF14BD for ; Fri, 14 Sep 2018 14:53:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4C5E287F3 for ; Fri, 14 Sep 2018 14:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D861928817; Fri, 14 Sep 2018 14:53:06 +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 C7B2D287F3 for ; Fri, 14 Sep 2018 14:53: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=BXVivYH5p/zYOQVNuoB/Vr7WBi+QoalCeeJ8v7wk5Nk=; b=MqN2LpqR11BMjTv0PE8Ghla+tq MCY/PzC0OBnypaoL875PmQPtR8L6iFYK/EC0sSLmCxvaFsVZv0TxBygmXRo0MZGw4n9UI5m1tPY4s soMq6qaDJ045RCcW1V2LkabHiH4eAgSQwuhD5bA6Z/5TW10X6+mH+jH5+D8gdy/cCuU5kzZCV118I Y6/YnXQJrA5bXM6YNLB/VX1+2IVTJ41ypD82bndJ8wC+L/r1FmHe3Us/xqwoZtIw+HJTNq9l5Rvwl Ga85jh7+pe0YsFCWwoUBeruooRgh1Q6C4W6Ab4rbUy9NXw4MkaKRksWy03QJhVBNyqnqQ1e3cCRnZ 7HtPTvXQ==; 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 1g0pSn-0000fp-Rr; Fri, 14 Sep 2018 14:52:53 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0pHE-000128-Dl for linux-arm-kernel@bombadil.infradead.org; Fri, 14 Sep 2018 14:40:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sH6sHViOL69spwJvTSXNgwwBEle/YysBPMHNYaVwPC4=; b=cCNEQ0cMwWVvFQ+MEXdn7En81 20zskq3eeP29YNsm27OnVEsCVL70eWd2EXNqHuHQ/EOpBdeEVAC7GWcK5X+hZklLSP5G3lb/mZNt/ rHyK13Y442pbA8VAJ50885HDKbEY8IA3YU4sBphYs+Ojg1b6zO7C6ZVahdUvFNLcuhOH9+5oVxr9K k+B0cVx3afN9iLwSIRMbx8bGgwitJyFKY1AKuxr9tNTTe5QeznIrgXQH9zFrvvy4mUVVsRzaJ51VN sTP2V/5ln8EWw9dQWqZXJZ/oEwSGNyz1EQZ/wj7pIwNBIX3b35kTK4b4JozLWIxAOGB/PMRHthjuw A70SgRrZQ==; Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0pHB-0003EW-1d for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:54 +0000 Received: by mail-wm1-x344.google.com with SMTP id t25-v6so2184639wmi.3 for ; Fri, 14 Sep 2018 07:40: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=sH6sHViOL69spwJvTSXNgwwBEle/YysBPMHNYaVwPC4=; b=Koy/9eEzBccfFG9qSCX+EOZhuxMPA7hy2QzVpOung//tiU7iCFZE18fJYvadLjX0kA /qoGTEDfuoqQXsoDCRQoHYQBFZY52GGkoNEFHD6GQq1Yb6cXXlexKon4T1Qn2O094bql pkEGDJFEyXZYW640qfwuWpmTcRY1rfT4n7pFTIPq1Ulxnn+0P5DAmzqillC91rWLZP/T MPyMz6ujatZmEyFm9s6NSCk0V8NZ+U8de7XDUffgaD07C4K8My4oONF6vg/QBqeBol7k 50YL2nI0k3SzjhZElLFjuWJEz2CeYTjtBDqNq7T6K5G2mG7l7OnMov9kFjr8MgD33Tc3 jx/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=sH6sHViOL69spwJvTSXNgwwBEle/YysBPMHNYaVwPC4=; b=DT6i0cQdDvdyLPvXOaJzNIQK4uHMhJA0EvjK3CVHx57QtcQwWjdxOUf1x1naTwhPen 4N9RFt+bjyAe6KWH2YXf+4ZXkIJWRGnKoJlie06Tfl2eXgEVKjdITmtKAjvTng0AocEP deO9l+DNou6y0ZAxPaRK1HPZBJE/JDg/pcxuwdazF58UWlfzVvY+3BXChD6uj8DGKMZQ 9G//oOizN85Q605wbNY+rq0ryTcjbvTfVjn9QRX96jMWQPvVbDqTxv09IeIweQy4gs0z Cil7G3yWV6z9cgW8S9kccXtyY69j3kCQuFKrh56zSJdGzhVdxOiH5/c57bhjq6XIq+FN aMtQ== X-Gm-Message-State: APzg51CEzJoG4MG7E2uWUKuzv/FpyD8RvHPhCx7BpCwSt4ZVu9SLF11Y bI89srPhMwv41cdSXPfXxVhARQ== X-Google-Smtp-Source: ANB0VdaTRxeowG48swESmynF2i+4+p8//1nxusFMaHH5bMDpBv61xoPI4fKsn4qSlT1FiOSi5idSDw== X-Received: by 2002:a1c:b213:: with SMTP id b19-v6mr2523529wmf.141.1536936038037; Fri, 14 Sep 2018 07:40:38 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:37 -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 v4 11/22] nvmem: change the signature of nvmem_unregister() Date: Fri, 14 Sep 2018 16:40:00 +0200 Message-Id: <20180914144011.27614-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_104053_109213_87E34ABF X-CRM114-Status: GOOD ( 18.36 ) 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 552ffedce38e..c950d54bb69d 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 14 14:40: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: 10600875 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 D458D13AD for ; Fri, 14 Sep 2018 14:49:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B20362B879 for ; Fri, 14 Sep 2018 14:49:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5D892B889; Fri, 14 Sep 2018 14:49: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 F0C8C2B879 for ; Fri, 14 Sep 2018 14:49: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=vOeI0raPCSQrIDtEHD8pwyeekfggZu+TK3r4e383vlU=; b=WkX0UTOK6LNPeinrploU3ELBU5 zHj6AdJzXMgagN8FqIcxcVhui0nWGQZ0vmS/gqkiNrZHolSAKtvuYRECO0GErCFf84jh7ueGj7qMr RArepE3fcTXcKB+k61rWj5hIIl1brw+YdGe551VTcFyAsEUXsH9ywIhmuo+vr55UvUI019pFCsQw9 kghUoGmw3dAVMvDeerQ/8BtMPD6KW3Nfi3mVnxaZrOo1R/yATKvyVWuR3AgFsG40VTJbv43gj8lqM bprdoq/RCrlkVK1UGilVVFYUbZ+c4F5o9U3Ndhzg7Iw/TOOt5mOPbHNorJ+Dkb5pkNrOL2d+IU2g8 1Vp1tefA==; 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 1g0pOn-0006Jf-Un; Fri, 14 Sep 2018 14:48:46 +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 1g0pH2-0000uD-I5 for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:46 +0000 Received: by mail-wr1-x444.google.com with SMTP id n2-v6so10889540wrw.7 for ; Fri, 14 Sep 2018 07:40:40 -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=iacN5A7LU/wkiibiq8lC1h7AfXkWsMWEAz/JdUQ5Jmo=; b=A+PagJ5alGzsVmfKrww5yuuAB6Pcn4SGpA91HCgqbvU1U9nSTVpk+XzKJ7LG/8Jx+e acc/IFWZWDF2nM86ugfSp+QR6KPe/D84tX2YoNpluCYpihWTpWVI85PTvuEuN7a89A2n 6zS493ccqYefWmoyKOcpx4NJQ4D6C7hjWz26Zlw2gVzSjCY7f9ZBbsTcuHjuNYAgDxJi W+VgAdR0S8ONWFeacyPy/8ReWYFz4U7y9Ln8wTTf76pxHjhyBIiUg7CjVn6FNe8u5hEo gmtMJeOKTjK21+o/5OVkmLczbQM0SeJNLxwcOvQs6RLk3kZZS3JAE2orW+ytONqCWIOv nevw== 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=iacN5A7LU/wkiibiq8lC1h7AfXkWsMWEAz/JdUQ5Jmo=; b=me8fgiifLBwOtfTaNX14V78clRhtKBtUe51+m7NMqmMEi46vgwfl7PXl/h8RKGLt49 2lfygBwuOnhoPucWjAq25m4zKmGzRjB6yOYCC08uMSLZEHrdmoiyMAeSQTbhtx2Sfs4l bTolFvARIag6Ixq1/5GgoyeayRFgyhK037QSAnzeUlhdy15dT1bZPaFSwPjBN5da/KFd 6tOtli8cwO5Ih5++pp7RPmNwnJt9Ftv6MOD3iG/olcNu5KxZOqNh2Te1fSASZEailvqS pcvnXuWHz6hkeXJnZRGJcZO5W2iuEDddkzMQn9hVl2cJAYdIyY21gUkiONm3oRlFqHEC fxAw== X-Gm-Message-State: APzg51AOsJaKPNVNOwVUUCXxOgec9Xentg77Q6LzY3tKf6+msCswdUWa jK5/6/Kun8NpfrnbOqF9RAqUpg== X-Google-Smtp-Source: ANB0VdblS+NZxH8ZB/fLWY+GavsC2hZ/aBLIrCWzkE/zRigEXO09s2nspcwqwru6QNdqjHcIsi0dTA== X-Received: by 2002:a5d:6aca:: with SMTP id u10-v6mr10240281wrw.44.1536936039380; Fri, 14 Sep 2018 07:40:39 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 12/22] nvmem: remove the global cell list Date: Fri, 14 Sep 2018 16:40:01 +0200 Message-Id: <20180914144011.27614-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074044_657143_69E4447B X-CRM114-Status: GOOD ( 20.94 ) 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 c950d54bb69d..585688ea2152 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 14 14:40: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: 10600879 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 667A513AD for ; Fri, 14 Sep 2018 14:50:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 433A12B8C3 for ; Fri, 14 Sep 2018 14:50:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 370BB2B8D0; Fri, 14 Sep 2018 14:50:34 +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 9571B2B8DC for ; Fri, 14 Sep 2018 14:50:33 +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=hqZO7mhqoGRAVTft985Y1N6T3Z3lMTfMsoRVIAQlTc0=; b=hPfHAXINh9x9fw2k6sLmIg3RRj K11kfzM8qAGIJ6vEAVxsHoSwBnMXeiYRnJhC1LWj2HOCeo07qLWdZ2o4UJE4373Nu86fmWYgGa0eq iDslVEWBcwPonpdBf9pfZtlBn6nHX+LejedjjeRvFXI0u/+D3MODdpP1jhTFgQyGS7pCqUiZt+bFv sloyIgZSFFpZdB4duIChZi2n8YnLAueaV9KjlpPPXE3G/x6Kfocf59KFIc4FZ06yFciNsprtBbBum dh1vsVxEZDAd8NUgjmTiu2q7uMqF7GV/62rGJHOjuNkdM1dn0mmLxpHMff2N1kI6HQFwypbLO4n2Y vMQ9J3ew==; 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 1g0pQI-0007Dj-3V; Fri, 14 Sep 2018 14:50:18 +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 1g0pHA-0000vN-7D for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:55 +0000 Received: by mail-wr1-x442.google.com with SMTP id k5-v6so10871610wre.10 for ; Fri, 14 Sep 2018 07:40: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=g+5CnkSN6jG3odW9SKyytUQVE9KREzQcmfREHiH2rmo=; b=Q1yKYN+dWWsJmQHCpcPQjpSX5h4s+eo9XlLYc+yv/cJCU7usGSCr2mEjDZp1cRPKUv B9LXJPMhHsM69amXgvwou9PwBNFoExs9n4D0VIugAmXfDR3LX593GVfJVXlwFaUCGDtf CglgiUNw+wu8h0tLRUflxSIbzgYueZtk50zYKwuVisXMxhgxVNQWAfHsTC5E2so2bE9m zWxEj3xQlH3fcEglWiK76phNKdUffdr4VBwreJ4zFTonXmf9VG8gw22A5+4DqK+IntCR JN5i6TSTcKenG8wQG/L4Zq632Qw4H89IWSJuFYvmeWXyflC8n8hJcpZ1NuEZXthUOWTj c7Ig== 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=g+5CnkSN6jG3odW9SKyytUQVE9KREzQcmfREHiH2rmo=; b=BUwu7Cd0R1yyMAIvy/zUFAKvypABG7ghgTUqQTeOdE3yAJ9iM4ZOEDqqFHkRvtBC5N xKbaehvL6MSqHPPDd7J/7Zyke5EmFWXBAPq6L/2tdf6UkWJ8kSE7MKTTpo+645XAtTz1 lrGmA3m9axwwVq7ajvTsshtpyARZkxPYEn7Arr4JBqu4RS8qk+kLGmx4NO8qOjZD7ImA A7CN0dUyxJRpRh6W7f9kY3azE4fgHAe4vPy+uDOL1VU3FiJGOn0mg7ZNyrteisz21GMI 5UQE2AHWIlJso7ykCvJHOFkI4+Afvh58uYdUApdUz5kiqolfoJ99pXU1M8lQtKbmKl7Q pWsg== X-Gm-Message-State: APzg51Ara1xtvkJWWgD51OMY2K7eXMVeVZXi/LwSvR+LWST5RTKvYJ2I bZEZhVaDvzIgSoUzO24QNVT9Vw== X-Google-Smtp-Source: ANB0VdZdyaS2wzkDAhQ68VTLBgUKynp/HfJXt6Xb+5MU5E0Txi/ydlvJXNHHITif6tWIAQk8KwZiAg== X-Received: by 2002:adf:81c3:: with SMTP id 61-v6mr10248919wra.120.1536936040732; Fri, 14 Sep 2018 07:40:40 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 13/22] nvmem: add support for cell info Date: Fri, 14 Sep 2018 16:40:02 +0200 Message-Id: <20180914144011.27614-14-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074052_471383_CBD2C371 X-CRM114-Status: GOOD ( 21.06 ) 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 585688ea2152..9329857f6137 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 14 14:40: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: 10600891 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 7C16313AD for ; Fri, 14 Sep 2018 14:52:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58AA42B7A3 for ; Fri, 14 Sep 2018 14:52:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C7812B8B0; Fri, 14 Sep 2018 14:52:28 +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 274142B7A3 for ; Fri, 14 Sep 2018 14:52:26 +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=2THXIwJNaFusjdLxjCFrqgDMZo0njnoV2p4HTI2RvGE=; b=Y9HCdFxajD4YOcsrzytRRd2Xo8 ePYP5cCbnChCEEkCMNVZC7D094cfsFRx3TptInolwbLag16uM2mwc+JK1ulFtkeMPmsm4Am+zmiBq kw1KLOKEWGROjZBMgrZDYodNj/Y5uTJl08ZZ+mrtv71KwYAmd0rHaQi25hKvoPipe7BX6W8KhqRpN EtMLnVRQ5xfiON8iTnKiq7wXkdMUBxgcts59hnU8vSrrO27lcdlFM9lT2AS6BGPG7L0cUNvoyd+Qq EYtFOoP0KTIFAiCownVUQhWZUNJZulg9CkfJxYF37gTuYnsIb3lLSByKzFLYTvfvEqVuJIBXxYahU Q20Ul46g==; 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 1g0pSA-0000Lx-Gx; Fri, 14 Sep 2018 14:52:14 +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 1g0pHA-0000vp-Bx for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:57 +0000 Received: by mail-wr1-x442.google.com with SMTP id z96-v6so10882913wrb.8 for ; Fri, 14 Sep 2018 07:40:43 -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=rZWO4kI7uqrNjBVMdqrBzKtvTAgfrsLuKZ1HGrmrsw8=; b=V4Bi4OXZLyRfOpHzz/jNP4+UrnV06yEgWbrLBfjJlKSt60XtqqFi5KSKqK6UVDDrYY VaLT3f3nDnv6ZTK1+rKtR7LvDzcJc1yIxwqMGXHrUZ21nKNANgsz6GnCrUG+YTq7koyM 77iy62U1Pe8bjgfvQSWf8h7dqoLOxbtUWkUxSfmFBntJRJn5g1jO4T/Gp3hF2NYkte7+ zb2lAu+HtnaDgw2PsVkg6z3Bkrl9tJpjjZjoXBv3e5cu/6YzstcihJwR6SiRPKE4/djL NHz3ALsoH3E9Bia3jUXCYmZDxp6qIgJqZscx+78b49tarY+4ef4qcuWAusksEn1URvu9 D0TQ== 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=rZWO4kI7uqrNjBVMdqrBzKtvTAgfrsLuKZ1HGrmrsw8=; b=KD58MwIhBuAoVjT6Xdx2Ifr0ecpiRZ8CA/253vfB9w6QeZ8RPEFQRwyQRhiyQjvdRv FrxKKdroczGW1YSO0RA9ztTBAvQ+i/IRrgwxrUqMmH5bgHIgCXlvPYuthexzSN+zhbrJ uCp3C8fUS6cV6A+PbpsC+NgzdHpTVyDZYtOJS8o1eI9ssOvSTZa62NHu/O0lrKgILFPg jZWWdVZpmkiszKDaXzrvrwKNQA/BY7JYoUuy3rZ1JMMe0Fdr3PQUu3sq6+aI8hiLUt4E DZB4Mv6ejUlJPXyU85J2T+Nxm7phNxshvqIFXnAdR8uT11ZCj9rlp9uLVvOI86g1H62e bJNg== X-Gm-Message-State: APzg51DrBBEPWe2r3BEdUp29Aj/EFfLnrPC6XbWoxcjrkDnxXsfbtAFP w4YiidOjlBw0zKhTDUBlp4+zkQ== X-Google-Smtp-Source: ANB0VdYBhBO6xlWY+Xc26xG17rXudfpqtkNILzg8ug80b3wMw8wifWEBZAyh3VLHVC7h29hqqZldag== X-Received: by 2002:adf:b357:: with SMTP id k23-v6mr10180459wrd.207.1536936042049; Fri, 14 Sep 2018 07:40:42 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:41 -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 v4 14/22] nvmem: resolve cells from DT at registration time Date: Fri, 14 Sep 2018 16:40:03 +0200 Message-Id: <20180914144011.27614-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074052_498793_39119FF8 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 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 9329857f6137..13568e7ad178 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 14 14:40: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: 10600897 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 5FB9D13AD for ; Fri, 14 Sep 2018 14:54:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F2B72B8A6 for ; Fri, 14 Sep 2018 14:54:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32E3E2B8BC; Fri, 14 Sep 2018 14:54:33 +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 878E02B8A6 for ; Fri, 14 Sep 2018 14:54:32 +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=C/jqlK7y+MzizaEZJUzyfSdS1AtUJ/g8Bf+ytgjQlpg=; b=fL5+gLzhtudfnS2ZILzunbfqsK xc9v6geYZjuKGi6yXB/FXHjPE45Z0sn32vWLFx1mNi9E6SPa3z0AkVJgJLWXPoKs5HGtxplUWPPM+ ja7oddadi80FSO7BpFiIVMP9AdpV7vgay+qVJysELTmqHZJ65EIardZD+DmtF6RnigpU3oQGRsuhC qE+II1sXTkizv3M48Z24pP/ZVKXYAZ2NjpzQjWHto6bHjv+SaPjOFdeFUqVMts9lghjG2/FMKTjYb xbW9NWLiDpkkH1MzAr2TmX59f6042CFpszyBgF3dK+Bf3K8DXO9BYVYV0crlNNr7GANEu+E7DvnaW P4KsbKgg==; 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 1g0pU9-0001Bz-Pf; Fri, 14 Sep 2018 14:54:17 +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 1g0pHD-0000wT-HT for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:59 +0000 Received: by mail-wm1-x342.google.com with SMTP id q8-v6so2198356wmq.4 for ; Fri, 14 Sep 2018 07:40: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=lLKK18pFJM5d1X9iNpVJoHXKMT+hCg6oOMMo9UfD6ow=; b=JAjqHIHtRrz4ZWJJnwIrrgcFvgJIEIVzAP5Dul7SEzHHRXYNLu+jtQF/o5G91ZCKUG X1LwLBmq9SaP08ilzDQcn7OpRJYhU3tck8tHSSnlJkItbYYX2BQVm2zDzmNv40BYioXB t+mYr/zSyyfReoiBtZDDeuEa6nbGteyQsQeTl7SPNsnB6kdTm37lNhEq6VcENO5zCFyd pa4jUOP85m65VJc1bYJBI2RFHChROHryZVr903Hzfbtvlpj6NmNobDsfEhkDiTug780b 3DxKpm1bMlqLC014H3KYlKJr7J5hWsXkddUoA/A9/uNKqFrKTraI6vjFSWK9HYnRJtoM UsUQ== 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=lLKK18pFJM5d1X9iNpVJoHXKMT+hCg6oOMMo9UfD6ow=; b=YylNXU6z1C5alakmysuLD0lv66W7lyU78Ydys408Jf31uOk3JIg03yG6e9y5n+RtNR 7AwE/5M30PIrKOHG5of7E3ASuHP439C0CoywYO5g0JsE84Ufdf1OmnFGV+bYXzxAV/hC Omk2S6x3xeFl7Mvg0EIU1gJaSWvSKKwROm5vw5mncaRJYu1ClqdYOCiD6x40CAW9sCk5 ysKTkI2Nz3J3z5hfLIWNJQkJh8ya9G9UkXUcPiAUh/fY0DIz0ZkSuim4mMfL3xCWlPYW ROueTp0vdza78STfIsU4kdAKwNsjy7qFXma4nxnTZs+VktumA0U8wZXJXq7SG37LXOSX IXiQ== X-Gm-Message-State: APzg51CCa2h9xryRU+HePnepA84kNLp+N3F8CKeYIuD9yrZahxDnJ1rk iKfzGkiRfXG3POVh1UsfS+cX+A== X-Google-Smtp-Source: ANB0VdYgQ6LcnKClatknIOu7Kin5m3ubslpo1cEfDIKBL3bwqzhytaAp9VXTuETldkVYrkBL2l4/bQ== X-Received: by 2002:a1c:9692:: with SMTP id y140-v6mr2574820wmd.82.1536936043788; Fri, 14 Sep 2018 07:40:43 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 15/22] nvmem: add support for cell lookups from machine code Date: Fri, 14 Sep 2018 16:40:04 +0200 Message-Id: <20180914144011.27614-16-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074055_799071_B00449F6 X-CRM114-Status: GOOD ( 23.55 ) 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 moves 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 13568e7ad178..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 NULL; - - 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 14 14:40: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: 10600899 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 418EB14BD for ; Fri, 14 Sep 2018 14:55:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FC8C2B8B7 for ; Fri, 14 Sep 2018 14:55:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 137382B8B9; Fri, 14 Sep 2018 14:55:15 +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 7DB272B8B7 for ; Fri, 14 Sep 2018 14:55:14 +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=fVJdfpRvALTlnwpmPKYn3ZvpyM nglV9hBNorrSCxpRi9v05uRtC9HxTzA13PJL1TRRzIGFAgX1C4lkToHgKOAWmLxaN1208LD6bm7tH 7FLANa43PJEZMTmsoAf9PWDX/6XfQXuLjEmiAIZVWf930/fhWKoflmk8KGdLMtbhuSvp3dzE40/TS QJenjV1WGCz7dCD+OidSnTKluoIM8koaJpTW9n5VoaA4rx0noO7qzc/uHldgbsWFW/jxyK/6n+P56 Dc3BhhqC4UqJAY1ZEaKZWCE5dbgk+SEmcVGni5HiR/aZ+IIE1TSlk2j/MhcWuONBRkj+VbBdj9RuT C6GeBjyQ==; 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 1g0pUq-0001U0-6P; Fri, 14 Sep 2018 14:55:00 +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 1g0pHE-0000xU-Oz for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:59 +0000 Received: by mail-wr1-x444.google.com with SMTP id n2-v6so10889810wrw.7 for ; Fri, 14 Sep 2018 07:40: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=rjARCe3NpsJLpu+gwm8Y4x+0pJknacrTsP46NqsklWs=; b=ehBne27meR4PyxNCUPBVLcSfQlbZbVl7xJaoMM+y1SldpCWucVmRWNQ02YfBoKlyrQ g4wHbPqW8q+LvM8BfzrqI3DrHrsjkqmtvKGud4P2hgJnhiNuqRD8CTLPs6koOpMuh3A9 PYK8zvCn2EMKZ0vtPaVvaAtERAC4oXhjRcCeb77BWk5E7h+vGM9uO0B7fz9sy98ZN+Bp pX7dSsH8P9brxc85RCbgRPyOVmqa6x3FS6Z/io1fetyvDIJ0JS7XojWkA6vWF7t7wgIX x0P7EgfCxnyMI6z0DIKUvBeRGEZBqxdyCiukDKov1bEE1i22YOYccM5q9mHiHzVvFvMP bj7A== 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=tQhuoYsu1uZzSoBGYl1oovmaKEIue9HAYxuEeCGsN+wf7v/N5hM091dvXMFxqy8GBS R35+G/vMIK8h9/te/PIc0y/JtJAn8azvGDexmlZe+ytFhL9m2DrSO+fGc2DWUyyYbXP2 7940p9QHwDNdXwZUr8fPKnTD9+rNUd7SNXQoeh5xf6cHQn9X5x3FqLHpamBpQuDGQiOR UzzB4btKca0rtSQMHgCmedhiV5jjJMxGHPmTs6b+U+l4psyK4yS+LcgVwxVfjXkAvIQK tcPmeUf0VfPgpDaC5fpNcJKtoNZDjVOM2LQZRGEqj7vbwur56nyPM6RFOomOn/S78Hlr DAWg== X-Gm-Message-State: APzg51AQHlDc0VH/pnircfaxORI40yY3FV+0Ep/odJR6QQNpZp9YwGKA HlCBFf+lWfpLxu9oVE6frZDQqw== X-Google-Smtp-Source: ANB0VdYkLruEia5UqmkWWvf/+HeCNtupZRYryHgb8VDENNxCVWiGFO+ctoDMZJ3RE1WRgggXgFckag== X-Received: by 2002:a5d:4648:: with SMTP id j8-v6mr9723585wrs.52.1536936045075; Fri, 14 Sep 2018 07:40:45 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 16/22] Documentation: nvmem: document cell tables and lookup entries Date: Fri, 14 Sep 2018 16:40:05 +0200 Message-Id: <20180914144011.27614-17-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074057_127689_98407692 X-CRM114-Status: GOOD ( 14.22 ) 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 14 14:40: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: 10600881 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 65F3214BD for ; Fri, 14 Sep 2018 14:51:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 467DB2B8C1 for ; Fri, 14 Sep 2018 14:51:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AD7B2B91A; Fri, 14 Sep 2018 14:51:07 +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 7BE0B2B90F for ; Fri, 14 Sep 2018 14:51:06 +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=tnxmnKWvNPeHmxvHMq6o++e/pT AKQjHutodz1rWvz4t8VuvY8bjrtH5gmKbTjKsC/CJNlSV+MLw3yhS9E8Rjy+K/7l8PJsTHX5Hmzf5 2JOrk+BeHKfpZmPwQ4rv4dj4w9RSqoal/MYIGfrYfnSp5JfN4lBqid8/jwTSYz758ExnvuW2sey1c bnokc+ruGPyvWev5xn8crlqIyjp9lJkEqwA7OeZ2nAYZ81uGpigX8+rIzY9mGxQfaEe0CV2oSLvLO wORIjnVRIfehNvEKYuoPD7tpRi68Tjb73179SYkAj+7nInH0PiTB6IKKDYU8VcHNErrkFH/E6bLEO koRyeVcQ==; 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 1g0pR0-0008LO-0J; Fri, 14 Sep 2018 14:51:02 +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 1g0pHA-0000xu-Bh for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:55 +0000 Received: by mail-wr1-x442.google.com with SMTP id j26-v6so10893722wre.2 for ; Fri, 14 Sep 2018 07:40:47 -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=rFtkcoouPEiGykuZjqSBcnRdSc5Uj1i1Hvm/jxhYa7EiTDErrMnV0bknzVe08c/u9x PfdAQK3cpWPqmaAQhKUOsYx9t0CrL8KfngEwNp5WqrgsBtZtSIE5B/RjSDFXsYbqRCfS /CUsA/YWCw41r6o6qPctTthDJih0yrI9jh++kLn3+tcdbDo9wpbEfIVHFl2E9tHUD/op xDhTEFC6dNxebzXHXwBMYsZbGiV4lXGzXLFcLU9wcxu3KxE6p+b2ryDDvIOfxc8Insv9 aPczgP6kfgN9Eo0xr1/ayCqEedDpzyI8eytgVEgXP1Z9Mu+pxa3m75AUGRxXftD/uOiF A2qg== 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=GEGcDbQvxRNj3b7h0e3pnL6VxvaFM3MOF8jqqy9pCJEaP5tN+dfCtjL9gI8VncJv2W ixD4jnkObknJNrG4Mw169uFX/6LAen97lEZ9iPFP388Lj6RF29pIyt4WdX/wBpe8Hp4s WAIlxYgsC3FQbiXKm0PhZm4F8OKEKj9GgugMLPwfZWerA8LxyQeHOJus1LUmVb+9J4LE 2NciHDk2scZz4pdGLtwFep5HqAy8bCEe1HjDwZA5lGraY0IzCWlr/cgREQuNMFR8XktG 17NRX0Yh4Z1BUb0eyE537inE2igizN4SZ7sA/d3CuoKB2+wemMizInVfDKQqDRfqFQnK T6RQ== X-Gm-Message-State: APzg51DqhFt3zxQHcsDfw9osiK9fdPlacxJtqONuisBgqVq7a6YYydN4 npzPjffYqi0UExLX/lP5J57tZPwe3fw= X-Google-Smtp-Source: ANB0VdahqfCi6dDykvBf1NSmUEfDvA15ATslS+f8n5FCEYmJcFfHCyZ8tVeVxH6rDZqwPib36gq45w== X-Received: by 2002:adf:eaca:: with SMTP id o10-v6mr9244818wrn.98.1536936046386; Fri, 14 Sep 2018 07:40:46 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:45 -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 v4 17/22] nvmem: add a notifier chain Date: Fri, 14 Sep 2018 16:40:06 +0200 Message-Id: <20180914144011.27614-18-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074052_507752_9BF6E520 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 14 14:40: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: 10600901 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 7774214BD for ; Fri, 14 Sep 2018 14:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56AD42B8AF for ; Fri, 14 Sep 2018 14:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A0C22B8B9; Fri, 14 Sep 2018 14:56: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 8E9DC2B8AF for ; Fri, 14 Sep 2018 14:56:00 +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=GonMLM4TeELAAGX6DvuJNmje9b Pn2VcOvUIFeA7CalcKupziqILXzX9gGFHOGvct8f8rP/Wn0gqM4icF3hH4WLo+OMBLTfZ2wqQEE1Z GMNtqEce1dTcideNpMAtudukdK6Y6CiWS61A3w6nCqWaW8K4/KxXaxLc6ZEtIuqM4xclYU5VCHlFS LPET96zf1keKBRPerqWoOiDJLivmH3L0bQN+0KcMtSptCBMCtY7d/0xv8E9kJmfGg3BFz85D/abst /aU8H5sIumH26cmGY7pEoMmHSrjPI4Or8g/OKWkYEthxoyag7GzYTSGgBknnMdQ4h+sH7zul2Hzjx ehN13neQ==; 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 1g0pVb-0002zG-BG; Fri, 14 Sep 2018 14:55:47 +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 1g0pHE-0000yV-P0 for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:59 +0000 Received: by mail-wr1-x444.google.com with SMTP id v90-v6so10900020wrc.0 for ; Fri, 14 Sep 2018 07:40: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=ujFzkuZMMLmXfVfLF2lfmeu9c3YEpE3NecX6O1UeHlg=; b=OAompkBlzUe6jIx8tDFhyLc+feF0D6RjhKt+SaoxIJlxgpk1iyFjqtoJrUq/CWKfaV xRFWEjUczPc76/xwEWzOU2cPz9x4VL3jZjZi8fVBAIBrtaq5aWIItbfHlZyr1QgOl6e6 GzSxM/E+QUzAjr/DjI2KcRysFXWs0Y3iGVXAzCtTtD51qEbWVT6YyCnQacaupwI0EV4m dzveXvWdNCVn/Yi08U+GefqGndeEkjHqTT5dZEYDOv+wwRvD0Z74Xbeq2TNDbH8Rcrkf 3NvCgNzaxbQ0BQluKsRjX98CoOwrWrxfDlcQ3eoKRwDDU0Tr4dC4coAtTHGyUgMuaWdA VVUg== 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=oyS68Z0pDu3gZFBbK01UAf/DpAwEP0MzJScQDYgBHrnHlbe09w7p3N9fRlRaxOvDZd UHo0Vv56jCekQKWiahaDwbbeL+goChOs6ovWDxMJzSQAndGiHsnMw07OlUnbbZVSMoy9 Pn8snxyWU3TNzwshf9bsVKl2B6VkJKdFfqLg5oK27mgQdndMlcLWq0bblUWyTyjXeoY1 bSGmtuRll2TA4ZSv9O7BpnfOiB9aEw+4LYdhqOKTstwkrfs8ULy9C/LYFz07JKIznUpb PivtOg8YnApza2dG+eNFzhuOPDtHx/TD8BRrbfkNckhL61czBf6/nao1ohdKqAwWoJdU 2NQQ== X-Gm-Message-State: APzg51D677XurxF41vCPwMIeboPN3IWUkM+Bn/Bp33/ynAC3WV1EcSlG XhtynQ/yw/ZjQ/P5LaSvhk8PeA== X-Google-Smtp-Source: ANB0VdYfKVXK35963rQ3LpNlbAOqtyE1CvvdkM3Q9+pE6Hz4KU0cHlPfk8BBh5Yz3U0lQXahzwcgXw== X-Received: by 2002:adf:9b9b:: with SMTP id d27-v6mr10131493wrc.240.1536936047662; Fri, 14 Sep 2018 07:40:47 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 18/22] nvmem: use SPDX license identifiers Date: Fri, 14 Sep 2018 16:40:07 +0200 Message-Id: <20180914144011.27614-19-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074057_083464_ABC31F01 X-CRM114-Status: GOOD ( 14.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 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 14 14:40: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: 10600895 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 3373114BD for ; Fri, 14 Sep 2018 14:53:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10B582B8B9 for ; Fri, 14 Sep 2018 14:53:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03E982B8CF; Fri, 14 Sep 2018 14:53:46 +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 46D582B8B9 for ; Fri, 14 Sep 2018 14:53:45 +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=tUr/IubWUeivcdZ2U8a+OIYmiy FVSzUekAK0f2jqmxy/0K9rjgzblZ09gW6Czs/GZV6Y5akCWXWG5Q2moDPzkxC2cZqczWbFYObveeD heWjSG9oZuMKnF5HRDDS3GhSMOA1RDjQZ4XXV72vls6XYyv7nACBLVcPRp4LIr/ngEe/UHW9QIUQx MynMsLtYa2lUAZFYu8C7WBFS93C3FtAKS5BZ3AY+Q2AMhD6WTkochux4+x8uTwzxMlglV/B5GKZe1 StEyGspkpF7krLO/AAEHlU/MT1YtiKfxHwPdpqPzczby50wec7lMm1VD80auchSlCgttLugqnyCF+ W0Njw3cg==; 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 1g0pTU-0000vs-DM; Fri, 14 Sep 2018 14:53:36 +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 1g0pHD-0000zB-GD for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:40:58 +0000 Received: by mail-wm1-x342.google.com with SMTP id s12-v6so2193999wmc.0 for ; Fri, 14 Sep 2018 07:40: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=SWhvTRaZMO6GTmTkXjZ+oIHfexV3W/J/b8cNASj1ylQ=; b=RwaakG6bYlcm0lGCS8eOtLIj4Mp8WIvjUCZYaCoWIQDAQ/PObldJHzjc25om3Cq0BP p+h89nN9Uh/kmBHn74JEVrjMa6Vi8dzSuCZwopCODbUM0Qo4Xpeig1DHBLkNhXVs+qHQ Qrf797f7tJtZ7WqSt1RM1JqAM9lNO85SdHer0g2HNAYzARx80IuMOi7DerD5PHepypT9 nJFHcFUhCyCOPSgahlpAn21GX94KkxNQ0WO34IYkzTvBhNHrRt8usaCbUmC9HN3jWPyU cvFW6LEIWce8EshNQ56s46aOcR7dwPjKQ/7UIsUQcOthctwBA+ZZhDenUKaTtx5nqahm P75w== 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=iw1tO2gG9lRdVmrBgxILohhILEMmNb7wdwvoyo3EiUwGs/1CErgmaJTK3ITSle0Zl4 Y+LZs+KFDVivWHU6CCBes7mqGhnUpG7n0w+bTEte804PJPhKfNaMWUpn56rgoSvZeJHO 3nSF4aqXnGOyHOPuGzSoHDKFlSTNtSrxnYPI0VuaiILl7USSXqWviIKXUHlzoYZyt+K7 1GBb4brf1V0NMuIczfKsgWuQIoBthJeguK0Fk1qq3QP+iBBZSqxvZBaocs8paxOTK3Qd OanpC7wyxPZA/xkXwNbZZI9ZyH8AuNqdWC+Seo1Z098zmS5qryhH0eQ12EO/7oILUEdM Ue3g== X-Gm-Message-State: APzg51AGoc/1MjWcvSs4rrRUHB7X43NP6O+bGKHDFmUmShHpTxKN5Vw/ xEUhDKtLv1kwWfIXRzZigPB4jg== X-Google-Smtp-Source: ANB0Vdal0s7pvC2zmwT7gSqdyG8wHbOks9EXb9Vd1c7qhj6dANybj0gDiDT9zmAkh+lZdD+kUCcMNQ== X-Received: by 2002:a1c:1745:: with SMTP id 66-v6mr2531364wmx.38.1536936049073; Fri, 14 Sep 2018 07:40:49 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:48 -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 v4 19/22] nvmem: make the naming of arguments in nvmem_cell_get() consistent Date: Fri, 14 Sep 2018 16:40:08 +0200 Message-Id: <20180914144011.27614-20-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074055_825068_B02CF82F X-CRM114-Status: GOOD ( 18.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 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 14 14:40: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: 10600905 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 6B4EE15A7 for ; Fri, 14 Sep 2018 14:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AFD92B8BA for ; Fri, 14 Sep 2018 14:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E5D72B8C1; Fri, 14 Sep 2018 14:57:23 +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 B13DF2B8BA for ; Fri, 14 Sep 2018 14:57:22 +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=CeXmDfOZAotaKbb3IUfsVc/9gL MsC3uqA3/o4qJ9t263MpRCzYh6rgRmFe24dXwf/CXgaWIEEF922Zn9SjYpNmF4msxcbfe4CTGiCsF /gbeyFBZhk2fA4yNUxy8MsmEkxuLve0NoL8saFr29OpOKSeLYepvwnhI/rjafO8up/INs/B4w6I46 IOiJMtu6uHDjYbOlZMn4+eUamTUhn6AaNltB/RsVT/6/5lcb+Bkrk0V9fzTH1DZSIhBW2bjcKu9Hm l4Uzi3VsWnNPsAavk8pjyEDwcMc67SkY/tpA3/yef949TiB27P6/rkIrg9zrNdUhPG2+Mjmw5+gD/ f0WHwRyA==; 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 1g0pWw-0003W4-0t; Fri, 14 Sep 2018 14:57:10 +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 1g0pHK-0000zr-42 for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:41:04 +0000 Received: by mail-wr1-x441.google.com with SMTP id n2-v6so10890074wrw.7 for ; Fri, 14 Sep 2018 07:40:51 -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=iVPEx3YTxvbx2eRoKfJXvUhCsfC1Q5koeN87QHyS+Hx2YfhBM/EmbMWFyAqLwZev1k BLIMPnfndIqG+dlKsj0fXUdwe0hoMnPksa1E7i1OMWvNKUG9T7cHY0MIcWT5pD7/QXg6 adCUxMA2XSxvJB5QTQ9d6IvgDfT9qemUmsl4D5DRI4gI2fu+EmVpMSo2Ex0nFKuS5HDc Uxir5PhMw7UWBXXkKzmtV9cq1CpdKwimBOcvScDCU4C1pi1xxb829TU5MUH20IpAZ60c p9+N+gV7SfcoNrhq7gK7SnMJdfvcDtYESPDvGzLWG+F4qW2bXJZK/43PPfYT1TxKAlxC XFqw== 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=NU1/nhrut/EQX/m4LUia8TnF0R/n4PAoWrDPjpWK0TrLnC3ndi02rdIBrbGqZRPl4c 9ZubDHdBCqBWqhqQTHnXWQPACMMABjpp8yIo+TruiZC/K7kuMErl1tT0P3wtdxd77HgO Nhq2w0x6IHhUG2j8bUOBgXf8Xk5lWxd8tlxFy9PrvFKpzOPdp7L5wMWhFcn4MJVBdCf8 P/8i+RYPz6UsSAYxHKK2lopj8oJfMyNiDL+UQOwqmaCpsyakdjWjGce0YXC9UqWbBT8/ BWyzZRqE3d8W4YuWTPvluCqnDV8GFQ0cAi0ZHvoYt5AxT6wGQVwn+F/DuRkcCbSvFUpb 1NwA== X-Gm-Message-State: APzg51CSEDA3G6Lq27d5xe4hxqYqmbQGvXDTqDymwLBpE2HVVayG+1WQ +yZyrLeqpE/pxFFTBQFnibjKow== X-Google-Smtp-Source: ANB0VdaBgQ1b0c71m+FKGhizDR8S2sBgA3jAyATT01Q4eT07YuaGKpVh1P6s+5fs+eBLxUhX6GGYNw== X-Received: by 2002:adf:fe06:: with SMTP id n6-v6mr10308354wrr.171.1536936050423; Fri, 14 Sep 2018 07:40:50 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 20/22] nvmem: use EOPNOTSUPP instead of ENOSYS Date: Fri, 14 Sep 2018 16:40:09 +0200 Message-Id: <20180914144011.27614-21-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074102_300828_83564547 X-CRM114-Status: GOOD ( 14.48 ) 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 14 14:40: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: 10600903 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 E047915A7 for ; Fri, 14 Sep 2018 14:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEEA12B8AC for ; Fri, 14 Sep 2018 14:56:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1D182B8C1; Fri, 14 Sep 2018 14:56:34 +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 272DF2B8AC for ; Fri, 14 Sep 2018 14:56: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=zphstlY7zima8OgHmmnlQzj5QkpahY6ra+B8zhbKgPA=; b=YAqDESbsJzRzviTorBUeKSPBhx K+QKGY8UNQdNJv6apfBQ5QFvCAOAfpLgBfaXMG8s9PpUsQkyePPlLPB/2izd1ATmXF5/PB4eEotAx pOsZBv7a8ufv4GvuY33DTAf54ROXk1wwdaW2LrlMS8fGFk7wegiJH8iWVyO5MrDuMXfo1NcVcQLhN MTjL+/NYX5LM1aTWcnwZirikgqowBUm58rXaew5Rsa3Uz2WJ86ss0eNnL+Hv7vyvyIX9sMdVN1LzI dr9CSF7ODI+BxdKGrSpSeWooHAUOOyIePNIU+udq4M0MtIhyosfiKoSQUmXHdg9ceABpBHIpvOnQ/ rCAsvDaA==; 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 1g0pWG-0003GW-BE; Fri, 14 Sep 2018 14:56:28 +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 1g0pHL-00010Q-Hf for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:41:04 +0000 Received: by mail-wm1-x343.google.com with SMTP id s12-v6so2194142wmc.0 for ; Fri, 14 Sep 2018 07:40: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=bgOE1ULQMMWfipJCdPWyqE18ogCrSsaTmNT0nDozskM=; b=12rmIQnLSxRah0jIWPCrqBXtImBz27dSY2L4zYm5ugr4x5upENwWdL3Gelv24P5g31 l36nGiI5drvS+i/I/dduUf6TodQGCHEkulXpgAM8xZIamMa/ONYbD3pD3kzBqPU2Koen N5HhIDUYZ4A7/IUSbUlhS83mYNQrwPmMmVjmaIByUUkLVfChMxXrWqzakwsY/HEjbCTS MtJMO7iLTcJVqMirmk0014rQkuIZy45jqsePfXVQSrNeS3zKikAn5GB2GgcNmoQWcTBN Tr41hMP6cv3Gv8szV8e5ThnoqS56de9gzuEtuKoMpeKudvpHLrs5baJYi+kFp3y8XFt6 6yGQ== 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=o+vc7nNFMPZfjq+VzV0hIUEGIxF7vH0PAp/CuhYuFtwrX2wUBaoJD4V/EXAXQQFtAP fETdCgqUVJQ8GiPC4RgGGnabwPY8sAWzliChgx2c0QRRwQcZ5dima/grbKCGO/Bcxec2 p5TvhCZ7HUjEZpTIEmJTwv0L5BkMFoYDqGHFWkUBr6UxhqsldSXqGPCz/p2Zo3YlfIRO wOVYxGG/K2I7XN9+OxE1U9ys+D6UBSVHDM2PByP6+KB75KiHrKeyKnUs50PANtlWFMk/ PtbTr9cgFEBWJdcRzk6z+yTEScavMfZU/Qamvo/2et3vhITjCOp1yb6iob8gjBQypKnn ipng== X-Gm-Message-State: APzg51Bo6StxnvJcl2lsXE4VBZj1fDJ6eqcfu2TZfLg4zGxotaWx5GpH wSrB+kjPP7Nn0QPs4ej1W0gsXw== X-Google-Smtp-Source: ANB0Vdbyoboif8kkoL6w59OXgc7YVNKwxX/pjoAcaVxxVv0ojGqrw1afeisPi8dn/KHkkG7fKUzQOQ== X-Received: by 2002:a1c:c5cc:: with SMTP id v195-v6mr2662105wmf.29.1536936051682; Fri, 14 Sep 2018 07:40:51 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40: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 v4 21/22] nvmem: fix commenting style Date: Fri, 14 Sep 2018 16:40:10 +0200 Message-Id: <20180914144011.27614-22-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074103_647395_4B3F1D42 X-CRM114-Status: GOOD ( 13.35 ) 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 14 14:40: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: 10600907 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 75DA014BD for ; Fri, 14 Sep 2018 14:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B3E62AF17 for ; Fri, 14 Sep 2018 14:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AE442AF14; Fri, 14 Sep 2018 14:58:06 +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 273042AF14 for ; Fri, 14 Sep 2018 14:58:06 +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=Au4NfWd2DqIbQcI2/myWSTjI9C fHvlhUuuS/3yvzsTbddVEGmgWl/MEATd3FK3iXmzHZtiUAz7wICWBDrbG5qzck6ud9S3av/C5v1TR an23GrIPwdr6j5bXDZ11FLwZi5yrC914THOed9lt8ZHPN00KTAiscc815/ZH9QbOI7T0Wi7X+ikzb cl9CCMIrMxJINxPeHAJMK1YnZbsXTMkUYjLor6vIxstrvoIvxeaNsoPh3kcwgSKfj9ibKaZ4lkk0V 6nLWlrHp9qwpg5fi5WqnnbxZtVfKPuTmYEk/H30GSc0oyJ7+P1DzdO5JTXOFLqOtq8iKQOrjMBaWc 8zCykQnw==; 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 1g0pXe-0003xW-Ew; Fri, 14 Sep 2018 14:57:54 +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 1g0pHL-00011k-Hg for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 14:41:05 +0000 Received: by mail-wm1-x343.google.com with SMTP id 207-v6so2183271wme.5 for ; Fri, 14 Sep 2018 07:40:54 -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=isCJL/Wkrqg/c5ZnUFCwrlHeC9e63kQRNS6yYITqXuUTzi9QUeW6m+HdSMO9dQBR+s TxAAc9+P9B+aCEivV821qkKzwY3LqqcpZRYDaz36fhZD4dUvils+SpeAbinPeITPpxdJ sS298vBLKyU1GEdjBAr1twcJsgbnzTvE4HrHAKX6mbZL/pOSv/tgjZQ1xh86H7/e0Q7Z J9+BTfK7432MpILwQKzOoJnSODVAZtSrzDwSkGKnJIpT7LJlS68PAGRsZo6Y/w0qk2kF On2Kexn7IIt0YbK8WzL9AjLxEuCelCqvtFel898oddUyfNCa03lWO90I912KwtLgPa77 AvZw== 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=dar9SG2ml0lqZjDNH8GM4ZAkyNhNSbvu3O/Km0Uswv6hsNSaDIwwPUbDW3EtnIVXbq crw8J7y/kSztzvbUblGatFA2wicbTxZJAhsuTA/O7tkk0BBhWVPywgGeBOb1Z3AVnkvC Lf1Hi1Rmey1E0h2L17WN9LQDNN2c0nRRBB2k3rkNqdg3NjW4fP1TaQ1BeqmDyRJhazR/ AUL2JWAkL8CQ6Mg1qF+cM/LS2YP53dAhEW/0bMoHfDk9JZ+vGEezidGv5Im+O3ojUb/H TqoJuhlCWMcjsuXC95gOWrSLENEudP5/N7OdaFdrvgBC5HhoZvBKvWyZ/Y8YChXNGy/I akEQ== X-Gm-Message-State: APzg51BFrGMIyc09480QDv15KMA9DbJCnO6HKs3iOaVRWVTTChRftN4T VfgmUUAH9krnSIS8s/p3XM2tuw== X-Google-Smtp-Source: ANB0VdZVGm4cyztOffbnujLBEDL5C92pYxxkPPUE6lJlaTWeO+l+BV1X/QAp3WYc0wZ4Abd5iZ/s0A== X-Received: by 2002:a7b:c10c:: with SMTP id w12-v6mr2655589wmi.132.1536936052981; Fri, 14 Sep 2018 07:40:52 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v46-v6sm10313526wrc.63.2018.09.14.07.40.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:40:52 -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 v4 22/22] nvmem: use octal permissions instead of constants Date: Fri, 14 Sep 2018 16:40:11 +0200 Message-Id: <20180914144011.27614-23-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914144011.27614-1-brgl@bgdev.pl> References: <20180914144011.27614-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_074103_648593_9A2AD149 X-CRM114-Status: GOOD ( 14.08 ) 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, };