From patchwork Fri Sep 7 10:07:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591989 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 CB3266CB for ; Fri, 7 Sep 2018 10:15:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3DF82ADFF for ; Fri, 7 Sep 2018 10:15:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A712F2AE09; Fri, 7 Sep 2018 10:15:31 +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 D1E7B2ADFF for ; Fri, 7 Sep 2018 10:15:30 +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=U3wXrDYqk/SSZGpO8IuYnLFDtT1dbZLIRyQC7hQaCdM=; b=ADa5xuXdatKWNZQC8EVehQlqYd f/mZoiH5/8Ykuk8qj7KLTvt/g/s2ZPh1BKmtcifBsi01cXuCSYOlIFoHUIMLYTlApkbhJgqSuQXip wLnAJHUd6hUHJMy3HPfeZtBwQHDqlgl8vhfwviQNFoGhddjBlop+JB2KbrJ2HtdlDsh9L1w5oGUQ/ oxadUAizY4VQAkH5aOXvGux6hYvCeBCw/Yr9axJidacKwU1gOR7SvpXhvK8XBsN7+CvQe8YB79LNV y1lWt1+xNAwJQo9g9AmQP1XHf/AHxvnZl7QmcrOdCe8K2trUyhK2rtuQjZFbdP3MqQg4AfcEZu972 mdVJarXw==; 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 1fyDnJ-0003Qx-BT; Fri, 07 Sep 2018 10:15:17 +0000 Received: from mail-wm0-f68.google.com ([74.125.82.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjg-0008Rb-59 for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:38 +0000 Received: by mail-wm0-f68.google.com with SMTP id 207-v6so13971694wme.5 for ; Fri, 07 Sep 2018 03:09:21 -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=UKv5jlrCAyaYTLT/BZL/veEIJ+piaHWDiSNiFe36RjY=; b=pPF/ueKgtFq9mKb3FaV7AAJ/RX0nSF64gZ5UNzEiTnsOUJHDrG9EByrW1ym3hSlqxJ kA4HopQRE16LJRsda7eXq4JKZkeHtEwOjjoidFff627a5CLvwzabFmUouMufQnszsw2P JVL/KBHK0I5Ll1ARWcFuXQmTdghTsBduW7XfnnYrP/gr8nTuROzcLr1rFuMtC5OfQg3g dmlA2kuH43nDws0/9pa9ZnyIEXDt49CmGtjutMU6yaN9MX8KcAGzbJvrn6V7hQYaDjVb 1Ss04RRgfLkNiQdVTFwJI/6LvU5N2usEGYkKy9HO0lZC1g+6JtiBP1dd5aQifdoA7yBX 2ORw== 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=UKv5jlrCAyaYTLT/BZL/veEIJ+piaHWDiSNiFe36RjY=; b=HeHbv/K3xCpiiabhAUpejedOh1yQOp0asdbWBPmVlDUOdlNwTPEaJP+eOzAfndLixY T7yhQ3QpNRrYBtLxYZpa9kCHgCucZelDZLkzEzzJf2Lq+jCiewSyRMA0XA2hy3bZxvH/ gT5Q6lNQLAG70e1b4TP50k5u4VGeAXUdgPv150by3qKe9rUoMdQYATKEywd1O8b4ffML S/gfa7jgt+7L8QUtEXlbG4nhW6q5y/e3JI4QCZtaIQsKUVrGDgo0n+nnHO5tcJN/I0L2 Zew01NhGlFQJBz79fUHUwA272RNCdIWcZ43LYxXnOce2ll3YkXXMFaRnEe38ZvsJN/q0 ChbQ== X-Gm-Message-State: APzg51B7DjamdPjVOxEH+kONST61d0bxX8yD5dkI13KKiwqJqsZ3SgjP giiQP8qpBogxJ4ymq5pMd5+c8AnDAzw= X-Google-Smtp-Source: ANB0VdYj2O2qoO8Rp1wd+pft9Qu0VQP48i8MbQM1ELPF7qM2HYUTuDS1wrvTV4ec3sIu38mVVLQnfQ== X-Received: by 2002:a1c:a60e:: with SMTP id p14-v6mr5088588wme.64.1536314900049; Fri, 07 Sep 2018 03:08:20 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08:19 -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 v2 01/16] nvmem: remove unused APIs Date: Fri, 7 Sep 2018 12:07:35 +0200 Message-Id: <20180907100750.14564-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031132_237728_22C2C0CF X-CRM114-Status: GOOD ( 21.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Remove all APIs dealing with nvmem_cell_info. There are no users and this part of the subsystem will be reworked. This patch temprarily disables support for non-DT users. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 212 ++------------------------------- include/linux/nvmem-consumer.h | 26 ---- include/linux/nvmem-provider.h | 13 -- 3 files changed, 12 insertions(+), 239 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index aa1657831b70..bb475c2688f9 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -282,23 +282,6 @@ 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); @@ -326,82 +309,6 @@ static void nvmem_cell_add(struct nvmem_cell *cell) mutex_unlock(&nvmem_cells_mutex); } -static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem, - const struct nvmem_cell_info *info, - struct nvmem_cell *cell) -{ - cell->nvmem = nvmem; - cell->offset = info->offset; - cell->bytes = info->bytes; - cell->name = info->name; - - cell->bit_offset = info->bit_offset; - cell->nbits = info->nbits; - - 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); - return -EINVAL; - } - - return 0; -} - -/** - * nvmem_add_cells() - Add cell information to an nvmem device - * - * @nvmem: nvmem device to add cells to. - * @info: nvmem cell info to add to the device - * @ncells: number of cells in info - * - * Return: 0 or negative error code on failure. - */ -int nvmem_add_cells(struct nvmem_device *nvmem, - const struct nvmem_cell_info *info, - int ncells) -{ - struct nvmem_cell **cells; - int i, rval; - - cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL); - if (!cells) - return -ENOMEM; - - for (i = 0; i < ncells; i++) { - cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL); - if (!cells[i]) { - rval = -ENOMEM; - goto err; - } - - rval = nvmem_cell_info_to_nvmem_cell(nvmem, &info[i], cells[i]); - if (rval) { - kfree(cells[i]); - goto err; - } - - nvmem_cell_add(cells[i]); - } - - /* remove tmp array */ - kfree(cells); - - return 0; -err: - while (i--) - nvmem_cell_drop(cells[i]); - - kfree(cells); - - return rval; -} -EXPORT_SYMBOL_GPL(nvmem_add_cells); - /* * nvmem_setup_compat() - Create an additional binary entry in * drivers sys directory, to be backwards compatible with the older @@ -516,9 +423,6 @@ 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); - return nvmem; err_device_del: @@ -618,32 +522,19 @@ 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) +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 (!np) + return ERR_PTR(-EINVAL); - if (cell) { - nvmem = cell->nvmem; - *cellp = cell; - } + mutex_lock(&nvmem_mutex); - if (!nvmem) { - mutex_unlock(&nvmem_mutex); - return ERR_PTR(-ENOENT); - } + nvmem = of_nvmem_find(np); + if (!nvmem) { + mutex_unlock(&nvmem_mutex); + return ERR_PTR(-EPROBE_DEFER); } nvmem->users++; @@ -706,7 +597,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); } EXPORT_SYMBOL_GPL(of_nvmem_device_get); #endif @@ -810,18 +701,6 @@ 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) -{ - struct nvmem_cell *cell = NULL; - struct nvmem_device *nvmem; - - nvmem = __nvmem_device_get(NULL, &cell, cell_id); - if (IS_ERR(nvmem)) - return ERR_CAST(nvmem); - - return cell; -} - #if IS_ENABLED(CONFIG_OF) /** * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id @@ -857,7 +736,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); of_node_put(nvmem_np); if (IS_ERR(nvmem)) return ERR_CAST(nvmem); @@ -926,19 +805,10 @@ EXPORT_SYMBOL_GPL(of_nvmem_cell_get); */ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id) { - struct nvmem_cell *cell; - - if (dev->of_node) { /* try dt first */ - cell = of_nvmem_cell_get(dev->of_node, cell_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) + if (!dev->of_node) return ERR_PTR(-EINVAL); - return nvmem_cell_get_from_list(cell_id); + return of_nvmem_cell_get(dev->of_node, cell_id); } EXPORT_SYMBOL_GPL(nvmem_cell_get); @@ -1227,64 +1097,6 @@ int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val) } EXPORT_SYMBOL_GPL(nvmem_cell_read_u32); -/** - * nvmem_device_cell_read() - Read a given nvmem device and cell - * - * @nvmem: nvmem device to read from. - * @info: nvmem cell info to be read. - * @buf: buffer pointer which will be populated on successful read. - * - * Return: length of successful bytes read on success and negative - * error code on error. - */ -ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, - struct nvmem_cell_info *info, void *buf) -{ - struct nvmem_cell cell; - int rc; - ssize_t len; - - if (!nvmem) - return -EINVAL; - - rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell); - if (rc) - return rc; - - rc = __nvmem_cell_read(nvmem, &cell, buf, &len); - if (rc) - return rc; - - return len; -} -EXPORT_SYMBOL_GPL(nvmem_device_cell_read); - -/** - * nvmem_device_cell_write() - Write cell to a given nvmem device - * - * @nvmem: nvmem device to be written to. - * @info: nvmem cell info to be written. - * @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) -{ - struct nvmem_cell cell; - int rc; - - if (!nvmem) - return -EINVAL; - - rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell); - if (rc) - return rc; - - return nvmem_cell_write(&cell, buf, cell.bytes); -} -EXPORT_SYMBOL_GPL(nvmem_device_cell_write); - /** * nvmem_device_read() - Read from a given nvmem device * diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 4e85447f7860..7e9fb5a19d91 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -21,14 +21,6 @@ struct device_node; struct nvmem_cell; struct nvmem_device; -struct nvmem_cell_info { - const char *name; - unsigned int offset; - unsigned int bytes; - unsigned int bit_offset; - unsigned int nbits; -}; - #if IS_ENABLED(CONFIG_NVMEM) /* Cell based interface */ @@ -50,10 +42,6 @@ int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf); int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf); -ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, - struct nvmem_cell_info *info, void *buf); -int nvmem_device_cell_write(struct nvmem_device *nvmem, - struct nvmem_cell_info *info, void *buf); #else @@ -116,20 +104,6 @@ static inline void devm_nvmem_device_put(struct device *dev, { } -static inline ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, - struct nvmem_cell_info *info, - void *buf) -{ - return -ENOSYS; -} - -static inline int nvmem_device_cell_write(struct nvmem_device *nvmem, - struct nvmem_cell_info *info, - void *buf) -{ - return -ENOSYS; -} - static inline int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf) diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 24def6ad09bb..cc8556e3c825 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -16,7 +16,6 @@ #include struct nvmem_device; -struct nvmem_cell_info; typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset, void *val, size_t bytes); typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset, @@ -52,8 +51,6 @@ struct nvmem_config { const char *name; int id; struct module *owner; - const struct nvmem_cell_info *cells; - int ncells; bool read_only; bool root_only; nvmem_reg_read_t reg_read; @@ -77,9 +74,6 @@ 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); #else static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) @@ -105,12 +99,5 @@ 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; -} - #endif /* CONFIG_NVMEM */ #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */ From patchwork Fri Sep 7 10:07:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591993 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 B4C3E13BB for ; Fri, 7 Sep 2018 10:16:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E76C2ADFF for ; Fri, 7 Sep 2018 10:16:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90ED72AE09; Fri, 7 Sep 2018 10:16:56 +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 0BFE32ADFF for ; Fri, 7 Sep 2018 10:16:56 +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=KaJlZ5xxA6Ebbk88EoPOirRmJaZ+DHyZmlfK/My+Sg8=; b=hkizjqnWi4onx7+AUJN6idC2Qo P6U3MvqBxxJ/Vg0wTJdh1iu4wCKrHzXX5useyY8gYXlRVnKEU9Ji9gs4iYfGbwlJcvaH/kB+XNlRj 6jxolikqPWe0fSm4/Bqvfr6HgZ6TmQTBFu6XrCKxEDFQQ1ULNZlqzBxuEZbpBDp179YMMCJrPMA+g I2twbPK4Q/mRwDuJD9cVDgC7Oz+03ldwdCP0UvfCPohMiATmsgcR5/IvCiCYDYNKYV564q1/sK7Lq YIBe3SevSPKdZBU8bqNh0CtvwmI2QpTu/9UptaQEfwdhI00jTmdTJYnrzfCm3XtOo+xwBOZBAVEdu 5zmayWKg==; 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 1fyDog-00055o-Uj; Fri, 07 Sep 2018 10:16:42 +0000 Received: from mail-wr1-f65.google.com ([209.85.221.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjh-0008Rk-46 for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:39 +0000 Received: by mail-wr1-f65.google.com with SMTP id s14-v6so5399276wrw.6 for ; Fri, 07 Sep 2018 03:09:22 -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=OkoqiLjbJSODXJoiTP2mWCeOVuHWiRrCaV2oGASjKkw=; b=Ql67q/cvaDNfqNAJLZ2meBMvoRpSakM4XzL+fx23NO9k4x8rlyCD9s3n5YGDwet4/2 iwdk4tqwtt4FCURfcLMyJFJwG6Q6kvQ+uOtEiaLai1wldC8Ulu6OmBujeN93eoKQ1z+B K/jBklhrhuywVD6BztEtZjiZOWTwXjp/RfJhrtWWbgmLZ504+93EKiyBW990DdHipuKA ZpJy0tvsvkVk4IX+7MpqkklIA7YmQ5JPfmtiZfNnkbubr9fH1w+vUe7jx/oFy/MyK1o0 eGZH0fXT1HoXSZ1HPwlUbQ/m6r9xvIq0/g1yjo72/4J1Qc5l95XljX1MV5npITdl2Gz6 yp2A== 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=OkoqiLjbJSODXJoiTP2mWCeOVuHWiRrCaV2oGASjKkw=; b=Ezi6B7GssKFU81NOA3vvj2h5AA/k8vq7SSGwNoQVaYteAxdrb1Urpko8EE7AKnPbjp gzpi9/6aHF5W/CMYtWTnRapRucsbG6b8vNCOdhKtLzwfxZLjaZsVRQh+TE35CFZMvbdX 1CLSkIrMs3BzxeX6KpB5kxD0tIPZKuIc4bYKtMVtE0RwlGg6kmI1AgNGXFP7YBfsPzRp e6MHNtZ+mp3AZ7OnBUSiJ3+rYUtiheBW1YCGvIBUkGg+TiXqfdPFBtBNIhUvJj1cZFVc 1TGhqvEy2Q4I5SbU56BnVzCwdhD5cab4fHjOcTpH7zUK4QnI5dwlIR5eHg+0BMkXrF9p eSDQ== X-Gm-Message-State: APzg51ABUgGk3UvcHoeAc79OKvzNSOaskCq54eVC10HcCxbNTJ4eG0hK uP4rSvUHSuwqQxX5Pt0ZmyNqIQ== X-Google-Smtp-Source: ANB0VdYrylm9/VwbLuJauYWuDUOk7RPP+KGu7xOSGEhxwmNnT4Jsl1L7HVUtvaGQhQLzXZcMdumofw== X-Received: by 2002:a5d:4a44:: with SMTP id v4-v6mr5551176wrs.278.1536314901286; Fri, 07 Sep 2018 03:08:21 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08:20 -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 v2 02/16] nvmem: remove the global cell list Date: Fri, 7 Sep 2018 12:07:36 +0200 Message-Id: <20180907100750.14564-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031133_159604_855A0193 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 Make each nvmem device the owner of its nvmem cells. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index bb475c2688f9..86af62e2df47 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 @@ -284,29 +282,25 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np) 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); } -static void nvmem_device_remove_all_cells(const struct nvmem_device *nvmem) +static void nvmem_device_remove_all_cells(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); - 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); } /* @@ -423,6 +417,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) goto err_device_del; } + INIT_LIST_HEAD(&nvmem->cells); + return nvmem; err_device_del: From patchwork Fri Sep 7 10:07:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591985 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 B9F38112B for ; Fri, 7 Sep 2018 10:13:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A25AA2ADED for ; Fri, 7 Sep 2018 10:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 960082AE02; Fri, 7 Sep 2018 10:13:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 060EF2ADED for ; Fri, 7 Sep 2018 10:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wXNAptUTUhxvWoli/TUe56bkydy3vxOEDj+DrGYKJ+I=; b=EZdi4cupfWJy91J5yaWC/NUFwH ja7PsEaJYLe6bn7WG6zvUghwCEkj4dOHX/uScMdlIHANQUeyUR+AfW1qBfw1xNzfX9TyNax+1Vmes N+KZIBttt568XNkufBjF/5qGy3ly1O529e/Ol+XTw4wzs0FFQCuagrmnX4O9nNWUNobOb/plfKlMo JVkfSVIPXtClMM48tttcifkPKdmsV/4dm0YqDF7cFW/ZciV7EMvUcwBA0maE1VIdwuFUI6mTiZVHC BOQ1u1AZjT4D0pWyNEg5eAqkBR7Fi6k9dIqwaU4effEffbGSGM3Jyhvhrvy52heuUytp1Xlfs78no gqSTFRfg==; 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 1fyDlk-0002Va-KF; Fri, 07 Sep 2018 10:13:40 +0000 Received: from mail-wm0-f68.google.com ([74.125.82.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjg-0008Rl-4w for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:37 +0000 Received: by mail-wm0-f68.google.com with SMTP id f21-v6so14161885wmc.5 for ; Fri, 07 Sep 2018 03:09:23 -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=QNr1Tad048IXHrlgjJJINGlU6RT88CBalusVA7tzIww=; b=q3di/OyP3e0iEgHzrcPelNzofxqAHF64UVZUOTbHtf66zcgxeHt6qPKw4TvZgpHKaX B9FmyOPR9YAYzWENUgVX7InfVV/gf2FIjlfT/Z/M5knDhjCNkpv5yDcQLTVJ5VwyUc4Y SFxyKi5Yvfisw/v0eAvMbNM5tuMinzWKON8sFYENlC6M8U+4LM8nJ6oLfllVZ1Ea0mVX u5X4wg6rwGpXFKOT+f76+GNeFePJKB6tKzOJ8vPOPlzFkNAO4Ncq8AskHwuhlQ4DlAPW DGIaIUP+TOhBdRzSe0aKCRrNggqdQPT9H73vw/LeenBiQ0SpP9ajsoCwpcoa2I0BEsX1 Moqg== 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=QNr1Tad048IXHrlgjJJINGlU6RT88CBalusVA7tzIww=; b=FK0SBW55eJVZz/Ho9SZ2d+HPQ2HrHTBZ8KE8/UFO4Q4KctG2zrA7IVav+LmW0XaVRG tgGpMd8aEb4nVuzbzd8NTp2iVC7SMYHwJRZ+raPyDUr9SPy9YD7Bop1nwML4jWY44/0Y MNon231RfNTMJlUrZH/UtI62NKcqL8UkWsoDNGWOK6zyO+X/iTPQ9u9g+OAxNOMPQcRL Sf0dlHhEQPac5l+zOv0WTkwEAlQmL+z3bwbHsxOyxZjQs66fa+SLB39Yb/pQU6oN5RU2 G9DTDbEHDs0SCwCSvsjxpAKvpKctpjsJI9zMNB5gqRBeyI/qPVEWTn0tadRSP67PM9Zh pcxw== X-Gm-Message-State: APzg51DzmkerKTxDc/59LsKNeAXZQCf8WPzniXexTFnIZTO6TWK0Hgh3 osTVCg8j/3BI4st7Jw7VO4Nzdg== X-Google-Smtp-Source: ANB0VdZkH3hMOA7kBU2bjC2b3M9Qib0lp/rGnc6F/8ncnyYlpvcm6uWC+lplZc0PmhJaxayuitEy9g== X-Received: by 2002:a1c:9f41:: with SMTP id i62-v6mr4368466wme.87.1536314902557; Fri, 07 Sep 2018 03:08:22 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08:21 -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 v2 03/16] nvmem: use kref Date: Fri, 7 Sep 2018 12:07:37 +0200 Message-Id: <20180907100750.14564-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031132_234681_0D834369 X-CRM114-Status: GOOD ( 17.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 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 | 45 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 86af62e2df47..2335b72d4b3e 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -32,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; @@ -368,6 +368,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) @@ -430,6 +432,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 * @@ -439,19 +455,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; } @@ -517,7 +521,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_device *nvmem = NULL; @@ -533,30 +536,24 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np) return ERR_PTR(-EPROBE_DEFER); } - nvmem->users++; mutex_unlock(&nvmem_mutex); if (!try_module_get(nvmem->owner)) { dev_err(&nvmem->dev, "could not increase module refcount for cell %s\n", nvmem->name); - - 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 7 10:07:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591987 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 519DC112B for ; Fri, 7 Sep 2018 10:14:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B52B2ADED for ; Fri, 7 Sep 2018 10:14:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EF0B2ADFF; Fri, 7 Sep 2018 10:14:41 +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 783762ADED for ; Fri, 7 Sep 2018 10:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=G/OgudrqnlaJKDPcEsO1ngPAck7SlmjDTUB/eooLbTU=; b=sInVEDyix44wR9bDv5iSlWigc4 Se2rjRoVGqVBceF1RsPFF+KPUPciQiHI3/EI68dwMnaHlMMkgcxOtyPKBS25xTJnEzy2mqfkwGOI6 Jo/cwbGMA8UnSLYed7hTEBKxEJirMCnUiSOH722JjNKNUlpLQdFJ+49/0PFjPJRH4MuJ4FJtHvzZF wzDWMc6VrUEzdWvpCikxf3e+D213J1vL7C0a0VV9HOrR+gz9Tfphmbj5e9gkFkC/0ORdX+/mmJz6+ o/dtEbrSwJDOoK+VYyFY33q9TE0mUnchXdPjWfBpLXsu+fVMPAWCKeQZ9UsZw+v8P8nCUTPwMK1Vp 47owi+5A==; 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 1fyDma-0002q5-JX; Fri, 07 Sep 2018 10:14:32 +0000 Received: from mail-wr1-f67.google.com ([209.85.221.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjj-0008Rn-NQ for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:38 +0000 Received: by mail-wr1-f67.google.com with SMTP id 20-v6so14334266wrb.12 for ; Fri, 07 Sep 2018 03:09:25 -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=pStjsn6kmYK+/TObJHiv70QDQbm1gSNXEr7yllZ1+4tL4q7jO8zy8f8+x41lSJnsZL dtePAJtd1L1Um5CXMGKhQ7qt/ATjQPr+KHSz7dsoMo7cs89bklGfi7lrBi3uNTLlmQRk WukSi6u2bqvZMhSy3t+MQ/sO8rgjZJIHjBKEvFuJn+KeI6k8B8GfKb9DKy0CtYujFju6 ifbuZEgUyGjLC7TSAiKI/JMGEekuPzMJLM+TQgBQqbZvOWJkDwybZNsKQ3pQI+xEO3bI Q9IyCgpLblryTuygIqlgJJVeVv3LfVlAjxp3nMY34BFXefS5ijfafeuf0M6INj9D1Pte MzkQ== 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=UGBPYSFkls8FeMXHoIWvnAE0FIAsKFxV/u6OMmMc7Y9/BcJyWYFSJgf4XqLxSKVOam +hKRig96UuEf+fyO8odesfjE6SZhrHYLxY1XPouxcEmuiWLXDMpIpsTIeMf+WOiERGMD 8OwoEUGj+zHCxO1whM6/fzSZhU//qo311ggWZk8Y2KsMyAyznSbOBS0OVQMjjkpEdI9m pNpOvqaw3SfJ1DCrgfL8gA3YJ994/ZduKiEj/SALEiwnGQ5DFdcXQbYkaXEhVMxV5suZ WLHozurKBHNfNvlAtcXgwW+purMsOWzwDy9iZIcpywc3wWP8sapAuO1eWG2ZFIND2e4h lM+Q== X-Gm-Message-State: APzg51BUBjtx5PI+tkRCKCMTg6+Kixq9xWH8S1O/FNhByxkdCxhX/wYj CYN0dJ1oCfyYD+7OHQKPpbdOsg== X-Google-Smtp-Source: ANB0VdZirVJ1u2qyK6wuLab9le89WJXC9zyf3+G3pIOciQldk+8VJ9d2GdCkjBv5ltzgbCQDCNmvLg== X-Received: by 2002:adf:aa9c:: with SMTP id h28-v6mr5700208wrc.149.1536314903810; Fri, 07 Sep 2018 03:08:23 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08:23 -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 v2 04/16] nvmem: lpc18xx_eeprom: use devm_nvmem_register() Date: Fri, 7 Sep 2018 12:07:38 +0200 Message-Id: <20180907100750.14564-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031135_794078_1AE560AD X-CRM114-Status: GOOD ( 14.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 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 7 10:07:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591981 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 78374112B for ; Fri, 7 Sep 2018 10:12:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60F4A2ADED for ; Fri, 7 Sep 2018 10:12:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 554472ADFF; Fri, 7 Sep 2018 10:12:35 +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 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 DC2912ADED for ; Fri, 7 Sep 2018 10:12:25 +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=k0zCU1Dtxok9bQ+qyYHXkh9wkIMHHtEWwu2W7UNkyG8=; b=bOMQ/V+AYB4DVCIZeBeK/LeKFH BZdXYpPNpqqSiDRq4e1+Fzix5/jkvgTmWLlr3IYKgtv0Ad9GoXuRShuBizrvCRCq+lZAbd3Jai+xi 8QLSzWMimS4wEtxr/lYYTvW9jKekSeNzvEJN+X6ayx4fnJJlV4gh4eSNKsS/nqTwUwKD7errFAmJV me+6oM5ORv+b5B2dnX1f4EWLcHystBT2/nE+oLFk9NTKZ+hXmjsE2VSAHGSrmhBv0ILgmuXJZKZ0+ LSi/ui4afeAjR6tfHzAODdcSaWMeSbGb2nLVevBZ47eAgCWBxxqWB+G6dahznhStZA7GW5KY+3x1h D0lqhoDA==; 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 1fyDkO-0001uu-5l; Fri, 07 Sep 2018 10:12:16 +0000 Received: from mail-wm0-f68.google.com ([74.125.82.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjg-0008Ro-4j for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:36 +0000 Received: by mail-wm0-f68.google.com with SMTP id q8-v6so14099397wmq.4 for ; Fri, 07 Sep 2018 03:09: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=874CbkmyKCyBfTs9WgjHeXXK4p9vYZrCF79UGreNijg=; b=JtGi0E8EtyYudsIFL9qZFkG0FIwpMOaj9jFQI1/hi3wcuWuUVInGn/oVbgZUnC7r+/ ESIx8/2m8bMPfnhf3wfWY4zmhcIytQZMz5Btk9LDDq+fi+OSPsUad73nwbz49USeA0LS b4W85gi6o39gPDZGyXE4lmPycrCUtA/umJTTCXGTUJHcgCmByZ5EcEkPG7j25eIDAwie glIN3eQtm369yj3+FrAucFWz2OF4dFF0q7AoTbnklQD9gT0NsR2cQihAaV9WjAAppBnw c3I7nUdHo/dkCeBh/5Bl8R/Iv/3NoMV+/QtvU/fQ4xWQdfyHmf7xvkMHknvLHgJTpywG dZ+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=874CbkmyKCyBfTs9WgjHeXXK4p9vYZrCF79UGreNijg=; b=WCwtIVEPPVfkHSa3S/KPmRzklIFZL2pjOIVX1T7FfnER9XHPkHeGWnG5c524vi1axl RlawtCQ/ToAORYlcg1si6D8egMo9rN1yPHiqabC1eVqhf2CRUDQwMyr3famSryXageKf pJrbxFsxWI1cxlMV4Ej9eacZA4JskaDUJVx1ipT2+RAAtwvBWh4r2O5+pP/vENBna1VQ D1N9MVe06koX/tNJRZNxmOp3DmDTS8N3cfmO82S8WflEksWHJNOq7Ulhqd0ciQm7fqn1 1HcOBD7kdRj+BMLJbW7MgD23fg3BpBDHo3+FhOgIHqxnJ88wQQtFQHupqYj2zJkJgEOZ Od7A== X-Gm-Message-State: APzg51DvHIfU9OXosIi0D5THEr1YqdwihM6w8Cs6DDdU9mQGE108319X ZxXBHpA9hIlQLmxAEhwn7ELmeA== X-Google-Smtp-Source: ANB0Vda6VBe5FobB98uJtZPvt++yeqLqlDh6ifRlvqAGdkP0nvvIpNhCJwPav5nsLR05kFpP5HoT8A== X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr4519638wmh.108.1536314905081; Fri, 07 Sep 2018 03:08:25 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 05/16] nvmem: sunxi_sid: use devm_nvmem_register() Date: Fri, 7 Sep 2018 12:07:39 +0200 Message-Id: <20180907100750.14564-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031132_227089_6CA8FCA6 X-CRM114-Status: GOOD ( 15.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 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 d020f89248fd..0296c23db322 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 = -EINVAL; - goto err_unreg_nvmem; - } + if (!randomness) + return PTR_ERR(-EINVAL); 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 7 10:07:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591983 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 75D7A13BB for ; Fri, 7 Sep 2018 10:13:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E7E12858D for ; Fri, 7 Sep 2018 10:13:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51D28285A2; Fri, 7 Sep 2018 10:13: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 EB6422858D for ; Fri, 7 Sep 2018 10:13:13 +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=GzQ5LBCeu381R5qos5IUlEcse0 S+PqOgjNJH7G3qODuy+8AmMH3AdTE+OlzwhafPFN0D474/c3HFeWdn+VLyAqqfoGxDffGzotx3BN/ w5SKnfcTXWTrblxMFseZbGBpcQxmJP2VpACL1Co8yvK+Va4JEAMxzuPhXkDPDjYn76Houtsjuy18+ D3T0N6sjLvMe8inINXNwpwtTjSds1MMsA8Clgicj+JxlYrF4sIwVPU8ZuDJlt2m3EUfkaGdAwnxCk wJnDl6OWYt97YpsDGCU6uviP/is2VMT/UPV0M9FtNb6g5GfBHdWbzR3Wu8g5bDc1F7l2FR8UF9dYe fU/PJhzA==; 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 1fyDl5-0002Ec-9O; Fri, 07 Sep 2018 10:12:59 +0000 Received: from mail-wm0-f68.google.com ([74.125.82.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjg-0008Rs-4p for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:37 +0000 Received: by mail-wm0-f68.google.com with SMTP id t25-v6so14025242wmi.3 for ; Fri, 07 Sep 2018 03:09: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=enYwgS0Z/OX0ykxo6KT1YIz+qVBOPAuLng+TvhpgC2Q=; b=EWZcTVhMhsDVDaTyLtMOAhQI2Mel8wWobR2y7nQ1kVN7wRHx4cAlWPLu80Yy532IG5 Xp7pS3EH1WyMLwF0QDCy6h5dnfvaOmJ07pQy0yPBJqAvo8062+sLO2/mDOjMzmrgSxtF +p+3Xuvjq7ynmtNzy1RTf/IlQWvP7aiTXTR5VUp5oUCdPTDidjOE75dtLYBGuDmwRDRo VZzVfyzzWFfSFCwwI2KaW6t9WE6LgOb8LoZI3KzMUjqc3PgYTtmrWazIZDjmCO0elnow CnBM66A5OckVul4MCg1f8rbapv5hlMFQB5/q7/Ku6C/aAFkPx7LuBYuqLpfjE7y2jCPg Pggg== 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=oUboMNhVmxsTnPV0UvcX7cgJtfQtdlvn6sCvNxvtP99uGCJUihfnNeR2k3sAIosr+n V26B3vywYjGPjOMZQPkdVMCA/BcTTBoAUEpp9PPBlPDYPm1Xt3syzwN0Wf86zSgtN6XL oQk2OlMpWU9bvUhgk9fRAxtTx1DwbdHTfdr0lWRfhFZl+CYBh6TQr+CVhVGbTskw8St9 g1jTPgoPuO4yp82+D+mNWwvIPKW/uYeGBr1i23FKrw6bv04g3MbkHDarKav7GN1YLPN+ DwKXVG32ac0hqKVvjNLP+sAwPbCbPsk3bIYzXZu0XPjdjs1w5k9S3iS+AAPqRSLM0XU4 zZcA== X-Gm-Message-State: APzg51AHk1eReWS5H33WaBZtPcwSPQrze8l3mDI9mb2/mSv5NT7eUWf4 YBHnnsDo+l/2MnSNeMs+EskzeA== X-Google-Smtp-Source: ANB0VdbYcfsCltzcsIaefcMp5kEoWkpJ+Cp5Y8fpSIMkBNxg+EiRcURTXVQcMphNwB6F7rsX4qgOig== X-Received: by 2002:a1c:780c:: with SMTP id t12-v6mr4639093wmc.133.1536314906317; Fri, 07 Sep 2018 03:08:26 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 06/16] nvmem: mxs-ocotp: use devm_nvmem_register() Date: Fri, 7 Sep 2018 12:07:40 +0200 Message-Id: <20180907100750.14564-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031132_236607_F6593DB2 X-CRM114-Status: GOOD ( 14.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 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 7 10:07:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591997 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 7000314BD for ; Fri, 7 Sep 2018 10:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BCEB2AE03 for ; Fri, 7 Sep 2018 10:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F83F2ADFF; Fri, 7 Sep 2018 10:17:37 +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 E5DDC2AE03 for ; Fri, 7 Sep 2018 10:17:36 +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=nw4eYP5mSH9RGZsILdSJC81KZJbSxlrp89Inn1yK0bo=; b=lDR4Yo8yjUYOOgHGumsntgxyae Y35pYT641ZDlmWIQT5IbLVJQTyAN9xzekQjS5Q8mZQP2BpveTFZva7CcKIoqwd8jXhtcII92Owlr9 sbxDj+cZAKy7t+HDfJDw9EaFsugC5BiaFP2/OiL2Tr2d+gqe5FzQ/E/N6LSZBOtCcPHkWMsGKPY6r c2ToVL2XPO7pWAwTQcQ4b/a48VPCLyzx7TSxdTBttVXX/nv7TH0vg2N/M6U1VygxmMoDylnk0Yz7z HnIGrJUX24efGq0qtJrotYHhCGB9mOHRcdNkgFS3KqQuUBX8KW/UaM2/pNiX8qJdiVbHPtkYNMXXm qNVHGLxA==; 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 1fyDpI-0005Lb-Pr; Fri, 07 Sep 2018 10:17:20 +0000 Received: from mail-wr1-f68.google.com ([209.85.221.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjn-0008UE-IU for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:41 +0000 Received: by mail-wr1-f68.google.com with SMTP id u12-v6so14343542wrr.4 for ; Fri, 07 Sep 2018 03:09:28 -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=KfLprIfJuLGiikb3NQ4jaXuB3vUOmbbQ5NtX8GENxrY=; b=dO4KNvUqz2aIxCjLfjhvE77hHxkUffpT/Vay5uCjP+ZFbvi/dvLUPdKTf9UWESwTfZ 4/jbKTykpco+qBPXvr/0uGIwk4404XTFWhM5Y//VXplxG2QGA661QC8spnd/EhEFXu8E m7PbrqktMofdmCw7G2N7HSRpWoI9w37HUimtR5Cvxcml6TNmhL2H9rsSG6qhcA6Om+ra +lnHuhqohMvYegZS4UuZMFSF9BhxFwr0o3qWgNVZ+rS9jO4CktTxULJ03Wgb8NytupTI Xz8V/IrDju3TRKZ11YYikItkH/JnwGMcQ494vA7zeL5GrHOVno/HSuS1mUV6/hTsPG3d cw2g== 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=KfLprIfJuLGiikb3NQ4jaXuB3vUOmbbQ5NtX8GENxrY=; b=J3UOd2zuMToAiHy+CJ7t9aW86M99N2ABLGFwlW2oncngNC7QNW4b8u9EUzLyTBaXbn Kg3b8m0sXqETNIpEidqro+RuEMYq0aypJToDpp0rKcUGkYtCavpJJ2E36WzHS8/8sNmq NUVybPBk/yIhIuC2bzTLCWVCFp3dISLLVp2CHTT77uo1hZtbBNy+iJEH8CegszirT5K5 vCyYiha6be7iPUcN1OGL3ymB0mKWXWM+PLtG3jdmVcneZ7vVxINv5q1E/g7MFxe8OwPR JQu1NGISiZ0F1l9xA6OyNN0h2AFFLweZaHmaAQtHPFklcHKRkwrWZlvUS0pSUKHXYUV8 yV/w== X-Gm-Message-State: APzg51Cazpv9Lrf5qU6zm2pPNS1uUOBZig+nXuvS01Z3luzq63oJZT09 ++8ylPjifTnheOC15KPyxkQF4Q== X-Google-Smtp-Source: ANB0VdafhIuGK3oNDNnpMZYcVQAMSylAY/tTUn7PGNQnolzR5ctIKa4tIqeUtaLOTPHujjcOX8+qbw== X-Received: by 2002:adf:c751:: with SMTP id b17-v6mr5739892wrh.134.1536314907593; Fri, 07 Sep 2018 03:08:27 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 07/16] nvmem: change the signature of nvmem_unregister() Date: Fri, 7 Sep 2018 12:07:41 +0200 Message-Id: <20180907100750.14564-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031139_681698_2C67D7EF X-CRM114-Status: GOOD ( 15.78 ) 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 no longer fail and there are no more users that check it return value. Change it to 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 2335b72d4b3e..89b91f73d08a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -450,20 +450,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 cc8556e3c825..d14a577a002d 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -67,7 +67,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); @@ -81,10 +81,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) @@ -95,7 +92,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 ERR_PTR(-ENOSYS); } From patchwork Fri Sep 7 10:07:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10592001 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 7C6D16CB for ; Fri, 7 Sep 2018 10:19:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6836A2AA0C for ; Fri, 7 Sep 2018 10:19:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C1982AA2F; Fri, 7 Sep 2018 10:19:38 +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 A6BD62AA0C for ; Fri, 7 Sep 2018 10:19:37 +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=wGGSTv6moiwiPJat/Xhv4zlRhs28lk8C88BEmLie6lM=; b=ltxvdUKOBoaNxz/lcL50sncAN6 vFLPDzcUpGMa2dtkKbM0AyetPJK1MeFyni4Py5hZAjGXuqGpuQp8ZvKLMyphueUcoL+ABNFkvPEmG YF/ulcF+cPZPZqV5z0ofFa6NmN2mG6whWQeqMqqCIVFtn/QTwBD698RUiT4eJZBm9GF3KxTC8QRFJ jpk6WOgWjikfpXFazqGxjDo3z/NUnfLovSIrDUqlhMzWSyGdM44QWYJE2aOAPfD283NYxOUvN6vem OSM2gZrmYleBaKW3YYIOjJZo3fq1dQ6P6+WC811kQWtru5E5zgTbyfSGeCBwxda+NnjXrCUgJslnG W36AJtSg==; 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 1fyDrH-000683-4c; Fri, 07 Sep 2018 10:19:23 +0000 Received: from mail-wm0-f65.google.com ([74.125.82.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjo-000077-Tj for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:43 +0000 Received: by mail-wm0-f65.google.com with SMTP id n11-v6so14024433wmc.2 for ; Fri, 07 Sep 2018 03:09: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=KZATZdgnPAoTpW/g3YD69XZQ2uG+BR5UrHmRyj2MT+4=; b=pcULNN92xTe/qjAuzPWSQQbdM1Ite5wqjDFVT8DvggEMW1fn5rpUwcZU/6rRh7mov0 fZdJHqHzazXw2lc4PNtyp09Sxh5O9+skXkL6+MbIbfTXsVtVxlRWkZHjsylt5emgansP zNwTjh0hUZqCZYofmDXMwFLCPs74wZ77Tn1eN8tnyg029pLHni2TC7xetFj7c8lBVyqW eziiBZaHyP/bbqL9zD58e9/GUwea0KZXxPJI2Yxl9DoD/TAWVdYJTWhH31YuaaDygeR+ 0LHlOQLrhwoN7CDAkzRBHepsMk3Lrs925N8KBejlMIKanDPIaQrARDlXvOnAH4y/OYwD 3CAA== 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=KZATZdgnPAoTpW/g3YD69XZQ2uG+BR5UrHmRyj2MT+4=; b=prdSBf2P0TdkcZg/q43rusv9MAR/Eq2rQmHDaGUN/O/i0SIo8pWw5NcHj2GTlomHG2 lsWZ8yYipqnEq+1arJS8C7/RS2PD9UJfyttd1+TfJIcN2o3PTpLsn+3Gubrmtsd9xbC4 PwUecLwUVaX3gIoRpnv6xGrNJ4c3xgXTlaPyIxmEV0ri10RjhxhwpoIF3wzVZ3pS9wrm GiRUKyQ549i3gSRia6o2A9tZhOO7UDm57N8XMl+Uhb4udVogkl3GigixPNbpQOzP+hz8 QFb4IXL4Yr77VQfcTHoBBvKPJUE/wRPURSPQoIRyhRV0jRU9DDQHxRIlXDkLsgG/G7xQ wCTg== X-Gm-Message-State: APzg51Dcd2SpAUAZB9i6+ceJnKObgxaU1pnT8d4FJoOwHqS9TxOSidbF zwQAbKoFblej/a3dKgD6n5+nJg== X-Google-Smtp-Source: ANB0VdYDxez+BzZjBjYhAMN3BqNHP9OvUbVqViJZLEwThk2xzFJBpV/sXcwLqu0I5j8KzOgKNlQ1bA== X-Received: by 2002:a1c:b286:: with SMTP id b128-v6mr4301857wmf.121.1536314908917; Fri, 07 Sep 2018 03:08:28 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 08/16] nvmem: provide nvmem_dev_name() Date: Fri, 7 Sep 2018 12:07:42 +0200 Message-Id: <20180907100750.14564-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031140_990881_1351F475 X-CRM114-Status: GOOD ( 14.74 ) 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 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 89b91f73d08a..364ee16e7d6a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1144,6 +1144,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 7e9fb5a19d91..1313da6731ff 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -43,6 +43,8 @@ int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, size_t bytes, void *buf); +const char *nvmem_dev_name(struct nvmem_device *nvmem); + #else static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, @@ -117,6 +119,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 7 10:07:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10592003 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 1A42D6CB for ; Fri, 7 Sep 2018 10:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06B932AA38 for ; Fri, 7 Sep 2018 10:20:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE5B42AA41; Fri, 7 Sep 2018 10:20:26 +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 5883F2AA38 for ; Fri, 7 Sep 2018 10:20: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=6pfSI1mt98C57dbkXbiJ1VrmtojV2lezIzbzZz5okVo=; b=I1YdrXhCNB7D/2w3SBe+HtWFCS 9MZik7g2LRVJbuQYfgAhKbsN4M2g5w0P+RnJTy56qCJfxf72W18due2Dz9Eoazi3MNRuN5n/UUo4u 2oLEJlCEPrY9asVtNwNFwe2qcaLeuddGUdcoLAmaLXsPSv79NxxkRH3Qld5UF6b8xGPHdtWQqcrAt HbUXwf+lyxP7BzZ5UzkfwS21JUXvMdig5sCvr0ALfkIFHPRWzWIsrNkuaE2xBvKZM4zHf2IgKwMzD BSqz1uKnPR2iGPtiNNXROGZyxWrwe7hLJARUmkrM2KylnET8YEvHZCJF4cMCwqP+DdxAFOo6+kMb/ bhuCFF/A==; 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 1fyDps-0005a4-Kp; Fri, 07 Sep 2018 10:17:56 +0000 Received: from mail-wr1-f68.google.com ([209.85.221.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjn-0000B6-Ir for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:41 +0000 Received: by mail-wr1-f68.google.com with SMTP id s14-v6so5399828wrw.6 for ; Fri, 07 Sep 2018 03:09: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=I1VBG0PAwehY35jashnN3ubpOSw/AOLijfoN6Rb7R00=; b=G8hacTtyH0EPG+ekgqJrNF0glLu6/vPrPUoWVfQIZ+3QElZlOQhUVPijOPeOJjRSlj mryexc7U/A402JGKKl0OaMjEp8yYsksr9a5VrO1Bv6EUHEHF3agQgUm7SRJgDsDn3b/U S55kNmT0krv+0WK/kZpfq+lV59qz39puQPISozz/gTV4QJRitZvow5wHXqXtXhq/yKUx C5bsOLBFe2gtAk1YzaNfYn//nAhTwa4yH5dnOc6i/uW/HbR9xUbSxGYuiCoEhbflTO18 MM8KKoF0hP3TQUvlyrFIcvet9jtTcB+iUYdTxR7NboZ3Hdqw1qMf1NREnLkHp6Rzt6gt 6CaQ== 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=I1VBG0PAwehY35jashnN3ubpOSw/AOLijfoN6Rb7R00=; b=J1w+afVoAqioHHikA+sCJqMoWVIaJoCmE1VpALfmYltuZckCHjDzaJOcQnyJdWjs8n 7egqPajNFvdiwcvDFdwaR8iREX9qkykY6IGy08K0fYaUBL0bodFSgKmUff6jmd/A4dyA TMI//gnCHO9ZVZBaPo46IN8jP4EkPauTVkz7ysE4Mpx+w6xmAiv9o9YqHom8yeWwdNjz uB3Qjfx0SyBhIs7wuT9xWcIbcEGp0Az4YTd720C7Ai51KoBPX6+bdiCLXvTLIHl8ZUpK 2jwxWSIArrmLFkb165lhRV/gMRUKFJ/2N7nQzZACevox6CFx+W47QcMClpNLtLsShXqF oLYQ== X-Gm-Message-State: APzg51B6Zz4Qo2b2997U+4R8h7w6UHwpBGpqQ/xEzIS+Km4ICXNWkLAu +dcZEYQtRJrpYV8dn/d/JD9/MQ== X-Google-Smtp-Source: ANB0VdbtKtyY6wAzPCg/dUJiyphNjLbW4pTCoYbvr+dBKK484w8Mvp7op/8MXmYLj17eU5BIEppcaA== X-Received: by 2002:adf:f648:: with SMTP id x8-v6mr5742256wrp.144.1536314910161; Fri, 07 Sep 2018 03:08:30 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 09/16] nvmem: remove the name field from struct nvmem_device Date: Fri, 7 Sep 2018 12:07:43 +0200 Message-Id: <20180907100750.14564-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031139_660639_F1336E86 X-CRM114-Status: GOOD ( 15.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 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 364ee16e7d6a..e456aaa6184a 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; @@ -537,7 +536,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)); return ERR_PTR(-EINVAL); } From patchwork Fri Sep 7 10:07:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10592005 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 7FFBE13AC for ; Fri, 7 Sep 2018 10:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2142AA3A for ; Fri, 7 Sep 2018 10:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 604422AA46; Fri, 7 Sep 2018 10:20:31 +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 AE0DA2AA3A for ; Fri, 7 Sep 2018 10:20:30 +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=8hpceEtdjAfB2LSstTYfpBpPtw/lgxlyrDO9CAbuhHg=; b=FPvsUHn0QmZcbvJeMBcfc8XZ4M kwZaO9+tDWXC3m16kNfqlrWesDi7ZWP/rV17u1lRIQz/DFu524jxB5vLMlvfNrkCnUFxBwntngyFy gPTrcmqvLYSzeDt4v9HEOQgjmkEb3YtVIfEMjtEwVvg3sS/gSh7OjJHc8+qrBIiRvUwfZ6tkkiVmI SaWLG22dy2MidIiYzPGL1JKqSIB0P9Di5M//03U/Ojw4La/eTAJ2CSj3fEuf1X1Y6R6ZnEDWjZMcn W/XHbnTJAN9XHwUPrx0UNgly2W5bTV1emMXnmR/kOz5T73oNSfAXiSsDj4hini3+2/dI7RmfZGWjo qWLfhhXQ==; 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 1fyDs8-0006hD-VM; Fri, 07 Sep 2018 10:20:17 +0000 Received: from mail-wm0-f66.google.com ([74.125.82.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjt-0000BH-Js for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:47 +0000 Received: by mail-wm0-f66.google.com with SMTP id 207-v6so13972286wme.5 for ; Fri, 07 Sep 2018 03:09: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=J1XTyB4mx+/CzlqafJmwB/GS7AoL7xfVrlZaU0QgY8A=; b=GrZI/lVtMW02eiYUBbfrGywbxzO8c4MM1aHazk7T6gSADUS3HfbfE/r3QB8/Lw3Q+T 3yVl73YfRU5VOashRo9bLWu3c0hOY4VW1D1IZQ+gNCa34H2mqxSo5UXKeXAKSDrk9c7m dhNkrnfH/5I4YnTtqCxjtsotaRkc6/9T94tq3UGvKEWAKC81CuYol/4PzcjHkjXdq2ds gN+CIlNql+wA2ZcQU+qSMn6INLZv+kF0e/X+wo6F0H3ACDG/rWhy83RzuuM8uqrIhPpi ibtKqaV6r8bzjtiFEGZ2u/dexd53Oy6+D8QKSnqSS/TMqPEqmef41P5+uxWPCqxbkzY9 9pIg== 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=J1XTyB4mx+/CzlqafJmwB/GS7AoL7xfVrlZaU0QgY8A=; b=TsiwOMD72YRV6yr2MkkFv5X3pARPncmZJu1vPremp3PZ5A5pj+u1z8huPui+XMtkXh AigynqDyrren28e7u39RUkeEOonEJHbO5uzB+ryK5YDSGHFMWauUtRJNPLhXS2JzHyN8 9bNNLqfb4Nnh/wK8PYNVKjtg6641+E1UoSfpAS/kk3cm/hI0Xm2WtQXszSs6GNmb9sLi VNNvO9bt0qBUAj9GA4MxM16XM9stFfYEIZc10xCaKg6Ugna9ipmgl+WyftLdAUpLMtji A1tSn0iT8eAvzI0YVq5J0+Bk2pa0azEPXxohQY9TJfyxCshbW598BqX5RxPzDkqgTxxt ynlw== X-Gm-Message-State: APzg51By6Q56kOteKzAPeXh6Btg70SOfgrsUIaLmBOpC0mIAvLoXAo/u KSeMyQKBD9UbtNEW1BrUi5UiWw== X-Google-Smtp-Source: ANB0VdbtkBV1ML2Rf2ViBQMMF/MNN2SlVbE8BidphRJt9UAiGftA9I9Wd6/RYYdOhgAETyZT/CkWmg== X-Received: by 2002:a1c:c64c:: with SMTP id w73-v6mr4316925wmf.98.1536314911633; Fri, 07 Sep 2018 03:08:31 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08:30 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v2 10/16] nvmem: add a notifier chain Date: Fri, 7 Sep 2018 12:07:44 +0200 Message-Id: <20180907100750.14564-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031145_715687_4BEC930C X-CRM114-Status: GOOD ( 15.90 ) 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 two events (add and remove) so that users can get notified about the addition of nvmem devices 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 | 19 ++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index e456aaa6184a..17307015905a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -58,6 +58,8 @@ struct nvmem_cell { static DEFINE_MUTEX(nvmem_mutex); static DEFINE_IDA(nvmem_ida); +static BLOCKING_NOTIFIER_HEAD(nvmem_notifier); + #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key eeprom_lock_key; #endif @@ -339,6 +341,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); + /** * nvmem_register() - Register a nvmem device for given nvmem_config. * Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem @@ -420,8 +448,15 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) INIT_LIST_HEAD(&nvmem->cells); + rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); + 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: @@ -436,6 +471,7 @@ static void nvmem_device_release(struct kref *kref) struct nvmem_device *nvmem; 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 1313da6731ff..be583c4eb2d0 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; @@ -21,6 +22,11 @@ struct device_node; struct nvmem_cell; struct nvmem_device; +enum { + NVMEM_ADD = 1, + NVMEM_REMOVE, +}; + #if IS_ENABLED(CONFIG_NVMEM) /* Cell based interface */ @@ -45,6 +51,9 @@ int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, const char *nvmem_dev_name(struct nvmem_device *nvmem); +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, @@ -125,6 +134,16 @@ static inline const char *nvmem_dev_name(struct nvmem_device *nvmem) return NULL; } +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 7 10:07:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591991 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 A000613BB for ; Fri, 7 Sep 2018 10:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 841722AE09 for ; Fri, 7 Sep 2018 10:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 782702AE15; Fri, 7 Sep 2018 10:16:12 +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 C60822AE09 for ; Fri, 7 Sep 2018 10:16:11 +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=ocnRbA2bf/cZl5e9qUZNp7eU2Dsk1kGIbD5XBPtpmPc=; b=IsIgPvEPp3PSXfQbC/ZRfeIJXM ZFZX0Zh9A6gZ2tbh3mv1t+HNLpy0MM48mK4IGu1R8prF3gc3fzT2sKq/MguX6DwGrvWKhPZ516R0N 9EtN21rwMX2DWXsIr+oELHdZZV8WeVQh6GAnwR3BMPqNR3EVk2p6sqiaQLisd/WSh6FhannQ74VbF xYhrsDl5cdlsTYkG+mtttd1Fs9Btbbl/oVfRorls93W0WVfYOqYYz8q0zg86DkhqSd4ymGhwiOGnv k1t3Q4ynkTHY2JomqTS0E6e+ko7Nd9koJdlry66KK5PZfmh/onScxvlCatHoya9+AqN+hIryssH+S V0DnUaEg==; 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 1fyDo1-0004p3-NO; Fri, 07 Sep 2018 10:16:01 +0000 Received: from mail-wr1-f67.google.com ([209.85.221.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjj-0000BI-NH for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:39 +0000 Received: by mail-wr1-f67.google.com with SMTP id g33-v6so14405614wrd.1 for ; Fri, 07 Sep 2018 03:09: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=fMftZWrQBIalsIbPmpTJQIjNIX58zZmJ2I3AfPo/uy8=; b=SmNtxcXTOTANQljQeEYoLp42+q6RXRsPUEJfHcGnDHGNigvCVXBd3duo0+NDmyhwp4 gLCuWEL5IftpCPN2d8ZwGqX74q3vO6x3pYy2XZTYaRpmNiomnZj26YuX/QVqWTT0f8Tx xw70jhn0kWLlPs8TsO1GAz2iavMit0+xo6M8A2WQazOuD9Pc0nZT3Kehir1ccWwNG6uF nNJBTYWBOxo183RDBIEy212MRQiZmKmPYMhoH7RVETL4luSPej0o0nRyQGvAq2E9zlLn j7nJdJ+YPoU2+qPV+KArP4mLaa4ubYibco+3joRiNOAf9Cy1giUyGXP2SeOQj6CfdMeF pDbQ== 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=fMftZWrQBIalsIbPmpTJQIjNIX58zZmJ2I3AfPo/uy8=; b=rH2QinPxUXYoyhwerkQByrpJDH3X+ynZP/Xso2XfMpnz8uLbTSJlO0tpC1H6+SMP8h AQS64Mo1BQbikII8KaD+SYGIBhdo3A0oOGzjk5oHmiMEDtdQZ0oBSfA/a71LEmbXwXmx rFljhLbJUwPhIqzL1vS8zkKzvUn0b/4hFR62mkScMTSpeCCxQFb2130QCGXt8O4VQPP1 NzX5gBRjT/sEAIriLXEMi9yoK6doIrRPWh2TFKlBSrnw+3i5UPivxCm4KFoRPJhdeZNq iE040X8Qgn4meulXiQSVszZfKDR8ijshI/UX743qpFhesA9hwr2sYg1x70xTnR2BnwyF E7vA== X-Gm-Message-State: APzg51BH/jCjtt6rR8c5eFWcKBUL9ujer6f7K/DWFdSMjuR5aqg2AbSO 5y6T8bChVZIU3r/bBCEfIjtjGg== X-Google-Smtp-Source: ANB0VdYUTztgWVqEI3eQC1b4//EZOz2VMY1Pvq1XFFCWEebwAvvpSqZX3+K9GYXlbo7cXxHZxhsTng== X-Received: by 2002:adf:ad47:: with SMTP id p65-v6mr5623696wrc.222.1536314912929; Fri, 07 Sep 2018 03:08:32 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 11/16] nvmem: add support for cell info Date: Fri, 7 Sep 2018 12:07:45 +0200 Message-Id: <20180907100750.14564-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031135_799621_63967C28 X-CRM114-Status: GOOD ( 23.43 ) 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 --- MAINTAINERS | 1 + drivers/nvmem/core.c | 97 ++++++++++++++++++++++++++++++++++- include/linux/nvmem-machine.h | 41 +++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 include/linux/nvmem-machine.h diff --git a/MAINTAINERS b/MAINTAINERS index 9ad052aeac39..a520924bf0a9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10391,6 +10391,7 @@ F: drivers/nvmem/ F: Documentation/devicetree/bindings/nvmem/ F: Documentation/ABI/stable/sysfs-bus-nvmem F: include/linux/nvmem-consumer.h +F: include/linux/nvmem-machine.h F: include/linux/nvmem-provider.h NXP SGTL5000 DRIVER diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 17307015905a..854baa0559a1 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -58,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); + static BLOCKING_NOTIFIER_HEAD(nvmem_notifier); #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -341,6 +345,66 @@ static int nvmem_setup_compat(struct nvmem_device *nvmem, return 0; } +static struct nvmem_cell * +nvmem_cell_from_cell_info(struct nvmem_device *nvmem, + struct nvmem_cell_info *info) +{ + struct nvmem_cell *cell; + + cell = kzalloc(sizeof(*cell), GFP_KERNEL); + if (!cell) + return ERR_PTR(-ENOMEM); + + cell->nvmem = nvmem; + cell->offset = info->offset; + cell->bytes = info->bytes; + cell->name = info->name; + cell->bit_offset = info->bit_offset; + cell->nbits = info->nbits; + + 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); + kfree(cell); + return ERR_PTR(-EINVAL); + } + + return cell; +} + +static int nvmem_add_cells_from_list(struct nvmem_device *nvmem) +{ + struct nvmem_cell_table *table; + struct nvmem_cell_info *info; + 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 = nvmem_cell_from_cell_info(nvmem, info); + if (IS_ERR(cell)) { + rval = PTR_ERR(cell); + goto out; + } + + nvmem_cell_add(cell); + } + } + } + +out: + mutex_unlock(&nvmem_cell_mutex); + return rval; +} + /** * nvmem_register_notifier() - Register a notifier block for nvmem events. * @@ -447,13 +511,18 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) } INIT_LIST_HEAD(&nvmem->cells); + rval = nvmem_add_cells_from_list(nvmem); + if (rval) + goto err_teardown_compat; rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); if (rval) - goto err_teardown_compat; + 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); @@ -1179,6 +1248,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-machine.h b/include/linux/nvmem-machine.h new file mode 100644 index 000000000000..1e199dfaacab --- /dev/null +++ b/include/linux/nvmem-machine.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * nvmem framework machine code bindings + * + * Copyright (C) 2018 Bartosz Golaszewski + */ + +#ifndef _LINUX_NVMEM_MACHINE_H +#define _LINUX_NVMEM_MACHINE_H + +#include +#include + +struct nvmem_cell_info { + const char *name; + unsigned int offset; + unsigned int bytes; + unsigned int bit_offset; + unsigned int nbits; +}; + +struct nvmem_cell_table { + const char *nvmem_name; + struct nvmem_cell_info *cells; + size_t ncells; + struct list_head node; +}; + +#if IS_ENABLED(CONFIG_NVMEM) + +void nvmem_add_cell_table(struct nvmem_cell_table *table); +void nvmem_del_cell_table(struct nvmem_cell_table *table); + +#else /* CONFIG_NVMEM */ + +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_MACHINE_H */ From patchwork Fri Sep 7 10:07:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10592007 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 738F16CB for ; Fri, 7 Sep 2018 10:21:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D9D02AA5E for ; Fri, 7 Sep 2018 10:21:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DB9B2AA90; Fri, 7 Sep 2018 10:21:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BDEB82AA5E for ; Fri, 7 Sep 2018 10:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fQ295QCBX+6rljzj2Rnt1f31kL89KgYLBPFYxGK5co0=; b=robqna4Ibjd0wCacgtz3raoJ+i VmJKp4Q1KBpA4HWv0ZVaxeU9NNLJWUhca4PUnzzFHfLRsUaUwjfN7KIeunnAKDJ8uvRgA9H3YZ7vi KerUS7AL6SIdbtspBLMneN41CJGHNfLkzzesZnjYMYrvVL+4p1rRAPzw8Ee46BQOq0IlQwFQNnSNH u9gltWneZlFMWy3KQJG0S/qIu2k8YR26vRt7oZwf61btYmpj+T5bxDjXYqKFI+kOpsQyOMgAo9mCG dsq7cQBMLzTJQtB7b1/oVkS8mZAmQQij/4+amW5GqiR/fTrumlOQvQ9jYki+m5JajM1TUshveL1h8 n9zV1QWw==; 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 1fyDsx-0007yC-DV; Fri, 07 Sep 2018 10:21:07 +0000 Received: from mail-wr1-f53.google.com ([209.85.221.53]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDju-0000BJ-CR for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:48 +0000 Received: by mail-wr1-f53.google.com with SMTP id k5-v6so14352134wre.10 for ; Fri, 07 Sep 2018 03:09: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=WJJykhItDGy0gN6YBeA8zfc/w+bKn7To1re4h0kJVQI=; b=MhrXBWXgs1CaGc5cB96OOnrxs03265maIPjtvlvoJEsWrwblwm6mWcu0miwjXp+5v0 PNqj7aky/3Ff9q9Ig4V4o3aSgkCVhOtGXuwXBaQhg+xHY3xFDcgyanPyULEPWKasU35q dOKMzqzaTCV1xuUvxqvHqUpxAq2ZHwUWgjVFlPm0z3t7NWSEULkUL7IZLWADMjbxsZFF 7sZh0tzX3Ml62ffZ+Uw2SsyJXJslJ15V7zrCAJn+6TFDuwCqERPgislq3hYE0mpdyEPL XcqHsXevWqyoHjoxT7DCkXgUKFZS75GSMvEgPERldlA+N3zXgUNhax4E9/ANUGy7kmcT 867w== 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=WJJykhItDGy0gN6YBeA8zfc/w+bKn7To1re4h0kJVQI=; b=Cg2ISnn4xEuDIDBQ/kTopwlYZOLV475yIl3XbXjdzITuftzhLDgPYc3RHKQSiMNyJH NV6Xo9U38jNaTjMUmcbvZOR/2Cdvrhi4fFiqLdYj6kUnE1mv93fhTmdsjf8SglzBet5T LPceKazqIrGMQ2RN1ogF4m0EreXQ3XWhgTf15B3WMO6+32OCSC0tAb64zBhJxwFkU0Cb CsW83KENoElufZ8nknjsxmOcjXfTgC5+lGCt2Kvg7NLF6+yZJg7cN9UzgCDyI/KTA1oG ExGm65q1RUwDraWMsVzwqPtbKdz7YFKsotwarLrJ0Tg7gFMRHn4OjBKNHPCpLT/zj4xi ZDLw== X-Gm-Message-State: APzg51BijIy+q9L4bAb7ucOaak75M6lfGhqNHgULvCoKMuXo4ihNGRPD u2lFOlGQPadVi8c3krIsqtXSDg== X-Google-Smtp-Source: ANB0VdZ0G7621X7Yx3EiJJQzwsm9t1y5FWeMMkEEZ6HbLLq8PvTLYkuXn1h+I06gOJZQ1+rylcQQ8Q== X-Received: by 2002:a5d:68c9:: with SMTP id p9-v6mr5468611wrw.108.1536314914198; Fri, 07 Sep 2018 03:08:34 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 12/16] nvmem: resolve cells from DT at registration time Date: Fri, 7 Sep 2018 12:07:46 +0200 Message-Id: <20180907100750.14564-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031146_441854_D9FFD52C X-CRM114-Status: GOOD ( 18.80 ) 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 users 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 | 122 ++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 48 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 854baa0559a1..da7a9d5beb33 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -405,6 +405,73 @@ static int nvmem_add_cells_from_list(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_notifier() - Register a notifier block for nvmem events. * @@ -514,6 +581,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) rval = nvmem_add_cells_from_list(nvmem); if (rval) goto err_teardown_compat; + rval = nvmem_add_cells_from_of(nvmem); + if (rval) + goto err_remove_cells; rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); if (rval) @@ -811,10 +881,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 */ @@ -834,54 +902,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 @@ -978,7 +1005,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 7 10:07:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10591999 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 6BF4013AC for ; Fri, 7 Sep 2018 10:19:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57B0D2A9B9 for ; Fri, 7 Sep 2018 10:19:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AC742A9D7; Fri, 7 Sep 2018 10:19: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 92AA32A9B9 for ; Fri, 7 Sep 2018 10:19: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=uBjPgjuY25P2B/5nBkqV46JqyYswOTWkSnferJPCFr8=; b=pD22aik+EZGrC5Bz0x8rntTJgN 0zaizkV8Vh7Z0RidrnouKX5vzgRNel9hLqL991Q84H+dFSjd9m0C/TqfD2y8tHjwfzEoqWA3hr1X+ vKEa8lnsHkgo1Aj11saIpTK3TZQB7SK6ELHPwjjflebLqw0qO96OGb+jbM20g/TV5MvcAKVnbPYqL IQJKwgFHgP6Mdz4T7SRSdRraFQYIuTyZ03mPaCigGUM7PsoIFPWKwVpCMKPOdtrLIiReMXCKWcSXR zxxkp4T3HconnP+BAJeVyU1WcdGWkPY5GoaKX94rUp1RN2Tmn6SnVGyef7P6DOCWJLavCrHAnN8N3 HSPZnXuA==; 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 1fyDqc-0005ry-EB; Fri, 07 Sep 2018 10:18:42 +0000 Received: from mail-wr1-f68.google.com ([209.85.221.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDjn-0000BO-J5 for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:11:44 +0000 Received: by mail-wr1-f68.google.com with SMTP id z96-v6so14361525wrb.8 for ; Fri, 07 Sep 2018 03:09: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=O6kW/MWMreMdqngfmMkd7IkhX/posN3NlXBEDLsqaVk=; b=B2LeJ69LnpVEnygPtrvKbCTfC3GKdCl3LpnW/Opnqk9O6dGsko4UrPLNyOeLwJC/tB uy7s5P4gJnDKT+yYQ7lIa+wqYl2P48aLuDjmegkx2UNLXWpmuPolU3Fs7TeZh8hFBvyr z6bFP0uKAc7MubH3xzLjb+ZZea6jgPuQQiC+cWfd+yiWrUA00PPRZWalQi8yfv5cfxgU udparDXdn0LP7S+jrSSefg5gFrc3w0NWdIcMUHXza9/O+TGoMUpZr3bZDemXUiUt6fa5 d6164NMy9tATVxf8Ikoeg+AnbsLA/tSaQlVEN0QzxYq5Ydn19/NQK2JXUpJtPDFtediv bYTw== 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=O6kW/MWMreMdqngfmMkd7IkhX/posN3NlXBEDLsqaVk=; b=b6WNKreZD2gu6TBeq+0EnyxlC6TRSLeTetXvWRiq1bxnMRkazTU4s1BkzSikl0OT/Z CE/W+Ld9XKrp36zjib73h+bfGzGKo/9JizxvwWK7P3FtSSb7xZTInF4mY5FVBb5P2cGD hzLGnx3KrvjOnVOoTbA94KMt7bY/1glDRbzZO0NwdsHlguSXndMsBwBUslDfrWp8ccmH x/c/DCUbKNXS7akj06Wtp/tjRgaGNB8/5eIpLbYEBxhW07fLFj0ok34YGVx0I9sIV0c2 sN1E6hq40ycEMNft13/df+aw0sYKWDHlq7Cb8Buzs3JCico9TQ0E060W5ovSm8tWFdYb wGbg== X-Gm-Message-State: APzg51AQaD0ooSf0uAcievrlgipLvBi3HJHH5vPUyyMmzWc8qBJ06Lgv ZMlzVtzMhHe6tOBVefLX2QOgmA== X-Google-Smtp-Source: ANB0VdabosKZ0ZjzOPCNJjpWuJUjKC2RXOe8YGBWVe8H5ORsjjLitO9xqRtxg2Ml0RuKu28UZcyKHg== X-Received: by 2002:adf:ae5a:: with SMTP id u26-v6mr5780676wrd.246.1536314915443; Fri, 07 Sep 2018 03:08:35 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08:34 -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 v2 13/16] nvmem: add support for cell lookups from machine code Date: Fri, 7 Sep 2018 12:07:47 +0200 Message-Id: <20180907100750.14564-14-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_031139_668105_1B0D7F23 X-CRM114-Status: GOOD ( 20.02 ) 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. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 143 +++++++++++++++++++++++++++------- include/linux/nvmem-machine.h | 16 ++++ 2 files changed, 132 insertions(+), 27 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index da7a9d5beb33..9e2f9c993a07 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); + static BLOCKING_NOTIFIER_HEAD(nvmem_notifier); #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -285,6 +288,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); @@ -421,6 +436,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; @@ -691,22 +721,16 @@ 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) +static struct nvmem_device * +__nvmem_device_get(struct device_node *np, const char *name) { struct nvmem_device *nvmem = NULL; - if (!np) - return ERR_PTR(-EINVAL); - mutex_lock(&nvmem_mutex); - - nvmem = of_nvmem_find(np); - if (!nvmem) { - mutex_unlock(&nvmem_mutex); - return ERR_PTR(-EPROBE_DEFER); - } - + nvmem = np ? of_nvmem_find(np) : nvmem_find(name); mutex_unlock(&nvmem_mutex); + if (!nvmem) + return ERR_PTR(-EPROBE_DEFER); if (!try_module_get(nvmem->owner)) { dev_err(&nvmem->dev, @@ -726,18 +750,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 @@ -760,7 +772,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); + return __nvmem_device_get(nvmem_np, NULL); } EXPORT_SYMBOL_GPL(of_nvmem_device_get); #endif @@ -897,7 +909,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); + nvmem = __nvmem_device_get(nvmem_np, NULL); of_node_put(nvmem_np); if (IS_ERR(nvmem)) return ERR_CAST(nvmem); @@ -913,6 +925,44 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, EXPORT_SYMBOL_GPL(of_nvmem_cell_get); #endif +static struct nvmem_cell * +nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) +{ + struct nvmem_cell *cell = ERR_PTR(-ENOENT); + struct nvmem_cell_lookup *lookup; + struct nvmem_device *nvmem; + const char *dev_id; + + 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) + goto out; + } + } + +out: + mutex_unlock(&nvmem_lookup_mutex); + return cell; +} + /** * nvmem_cell_get() - Get nvmem cell of device form a given cell name * @@ -925,10 +975,14 @@ EXPORT_SYMBOL_GPL(of_nvmem_cell_get); */ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id) { - if (!dev->of_node) + if (dev->of_node) + return of_nvmem_cell_get(dev->of_node, cell_id); + + /* Only allow empty cell_id for DT systems. */ + if (!cell_id) return ERR_PTR(-EINVAL); - return of_nvmem_cell_get(dev->of_node, cell_id); + return nvmem_cell_get_from_lookup(dev, cell_id); } EXPORT_SYMBOL_GPL(nvmem_cell_get); @@ -1300,6 +1354,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-machine.h b/include/linux/nvmem-machine.h index 1e199dfaacab..7859c08934d5 100644 --- a/include/linux/nvmem-machine.h +++ b/include/linux/nvmem-machine.h @@ -26,16 +26,32 @@ struct nvmem_cell_table { struct list_head node; }; +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) void nvmem_add_cell_table(struct nvmem_cell_table *table); void nvmem_del_cell_table(struct nvmem_cell_table *table); +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 /* CONFIG_NVMEM */ static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {} static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {} +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 */ #endif /* ifndef _LINUX_NVMEM_MACHINE_H */ From patchwork Fri Sep 7 10:07:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10592033 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 14E0514E0 for ; Fri, 7 Sep 2018 10:32:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02C012AE03 for ; Fri, 7 Sep 2018 10:32:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9C932AE24; Fri, 7 Sep 2018 10:31: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 858CA2AE03 for ; Fri, 7 Sep 2018 10:31: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=6rqIHAVz8dCEdzoedI9vEAJiPyDTyvIHPrjWfOPP8HY=; b=cPElrNYNLNl8xQdDhqyjSEzfJD HjAiGZUH2emhlgDwyAlyM7w/AhBirtNirNhY/AtGhy6gtRhV1TW7hN/Ds66mblRvVXpFPMnqhPwbL cOdISM/n0kQQKRVXvhEUcmJmG/60pgvVWyXdGRS/ab67pcxqyFawq6SRSMxDKWWc4JnHgNG6POQFF 59MHm3kq3r+vi6y7n1rzm29yIWW+Jl0Y6s0J43CBFSLUa55Si6R/pQSnlZwOgozlMMDJYaqGk1uRR rB2KSQsDwhHIY6YoUAWDuzkpzE1BTZhQGnkWu8yWvb8EGoM0fc+ENp4Ht2JWqaHG5y6fUkBDoB+h2 X+ftPHMA==; 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 1fyE3H-00050s-Rs; Fri, 07 Sep 2018 10:31:47 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyE2W-0004Pm-VB for linux-arm-kernel@bombadil.infradead.org; Fri, 07 Sep 2018 10:31:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=rjARCe3NpsJLpu+gwm8Y4x+0pJknacrTsP46NqsklWs=; b=SNb9S/KZwdNNYFYwBbzr7FWcp zo7yZ+wTv7RYAfERvfH2fsUmKPVQullxbjFZjW+0Nk47XujySRw01ZKxmDQwE5SSPMDU+mGc6m+IQ QDsHW196fTIQ1oR5SZFlwqXAtNiakyl70JWrp+SpfTPJP9ZmR6bigo845Enqnh14z2/8xIh8uDuqD b0CdeRskFNsDfanU6+BgpR77hoz3um0S5Qyq85Az5n5HzrIiOhgCpqMoSgmCDMjsNDgWAvQbB0XBy NxGNB+nRHXtuEONC2O20h+biT891bRyOSggFew/oycB8QZ/AxHK81UjrzQmmnZdtwti86jnaAFZ10 o8g4dFEXQ==; Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDi1-0005wi-8T for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:09:50 +0000 Received: by mail-wm0-x242.google.com with SMTP id r1-v6so16528673wmh.0 for ; Fri, 07 Sep 2018 03:09: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=rjARCe3NpsJLpu+gwm8Y4x+0pJknacrTsP46NqsklWs=; b=JGD+vdczikrboApyovvWow0pnAnzkJz0ImUB1OKO7J6WzuO1DV32poJqARyVCHAT4W 9oJqnM42O2El0bVSTuFljdRfZZIjvgQmi+/hWuOUHYNv3wru2eluY4AmvJf6Jk1jdoTO m5Al/MYjbFknubjNUyjfSiW8IcaR5CKY1lWcAtc7UVUHVYFKUPR2A7zqJ3JKDHVB/pQZ i1+Cj4KCQLvusrX6PWxX/2YjqTAZilzQHWTmysLBMTnUDvBZdXOw+/NfjgRwEBoMFIUr T0KZAFPvSYxLE8hOYpryEJgbAWSG57sqr2etvyjPsj+lg+QngzHPPeV0q28GKHgJuBjw 8uWw== 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=nOIHIN3Yaqb7Y4IFxc3x/sGk0Dg4uhNAdBHozFArd5ln8nr0eJeRbagbqC/3rGnBJT xO+/I7xa14JI+C8G2+/ZDqQ0kxbWWPpHjBnUbZY0P3lwVmjjEaGZA+yDfw4x+RN21C8u YduK3qQzNqWERwV7qvdRZX7r5qpr0ZZb8BJjpUAieLN0RRZdC7fIk7Lpwu3LLVccwzfy e9S6xNz+E1WxY0T3IXi2WKERDlZGxYcjB73cHeWxnjV6GyXGQ8zry99rKvPzBmBVargo 6ZT9MIUYtcDjg62hJRM6bS2w6xiie5KkLeQDSffheyz01h2AD9GmKZsJQXSHib0RiZ0M 67IA== X-Gm-Message-State: APzg51AwC1Pq/BbWb3JuiyH6Pmc/0fkOJEKRs5mm/frTCXxI2RAewlbj 19dj9QECmFpTplTTSzInaSG2MQ== X-Google-Smtp-Source: ANB0VdaeWAYzfcGsVF/mkA53G39QTZNQ9p4L/aP28vkS4LM/gh08yPlu9mL8Ht3+wc7ew+p2LpA12g== X-Received: by 2002:a1c:7f93:: with SMTP id a141-v6mr4825953wmd.45.1536314916701; Fri, 07 Sep 2018 03:08:36 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 14/16] Documentation: nvmem: document cell tables and lookup entries Date: Fri, 7 Sep 2018 12:07:48 +0200 Message-Id: <20180907100750.14564-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_110949_292130_AE5D19AB X-CRM114-Status: GOOD ( 16.57 ) 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 7 10:07:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10592031 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 DB3FF112B for ; Fri, 7 Sep 2018 10:31:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C737D2AE71 for ; Fri, 7 Sep 2018 10:31:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAFBE2AE38; Fri, 7 Sep 2018 10:31:16 +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 8F95F2AD8E for ; Fri, 7 Sep 2018 10:31:15 +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=ytxN2W6FYCjOIoao7TsKEBObCbLuOpEpQM5tRORZGEg=; b=T/ogAOIMJL57WycAKlXaoTH7xh UDb/lBkeg5Yl3s4i4KJVnYUnZ6tkG7cJLz5F2gNT8jQuj70NLDxKgicJDzvvuFUZdOiKmK6K+H/97 9OKmSsi9zg6XUxfKuxoPgQehk9NVm3cOG6QDl0NMlH4xu8Pey7EmHVX5DogdbUFn5KdCpHYZF33zw L3TD0ocUHZRG03EoXV1UyxHNTclXNkMBH4N85GGpLH6fEWLhRiEvZfW8Yyn59gkhpDAfTLS1mtvhb dQjJ2GSpoBLWMJfoQSSH55yJWg3czDVdWfxOfMJsOQGgNE6aNb3b14/1Fv710t8qaWqMk2v2ovt/p Ho/lIIYg==; 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 1fyE2Y-0004d3-Kj; Fri, 07 Sep 2018 10:31:02 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyE2W-0004Pn-IK for linux-arm-kernel@bombadil.infradead.org; Fri, 07 Sep 2018 10:31:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=XBcxKh4doOX0pFb3D6b9lBHWHCCUYHWbQQl51CV8SWo=; b=uxOvOxnlfjCWOUY4ZQi4celho +HQ/iOwSjjA4K4rKDri1rWhmoP9qoNZTGEXxo0EuwPmORFWrpiuptfDOZHCFz0+Yw9NoOzirsx/kW PDfKu21PDaaYrtgUKkSvbfDYap62+YE1G4FvHseA+DfC3Xdxq+XgoLJN/74B2E7E6Brq5LAOioTO2 D1zC6tbFw6vayCdV88sI0uDu05/OZxgY4YYVtLde3wPl9urrjmmvwxbsco6njdNZ5SYqKI/7Ol4kX qPpC34mCP1iOyM7Q2dbdmFjr8F1a/UV288z4BiiMMgZi/BkKARyJ8FqW01VAyKQ7g7ToQUVb7TqFx XHjBWX91Q==; Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDi2-0005wk-Eh for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:09:52 +0000 Received: by mail-wr1-x444.google.com with SMTP id v16-v6so14343636wro.11 for ; Fri, 07 Sep 2018 03:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XBcxKh4doOX0pFb3D6b9lBHWHCCUYHWbQQl51CV8SWo=; b=oMjIXzI+g3jX1w8LqEXDQYipq1KEZV1+UkCQpXs3M7JyKWb4FYAQCtvH7U5V5gNgLZ 5Xstco+zLKBqiRuj7W/2TluKUNat/DvRp+pjNzwqLd+ZNeTbW+4JzBPl4bSiExjNCggj XpUYA5PAdz/CdxvpPvIvscDwpUkhLD/RRALRBC94Iy/1dlW6urIzFlEB0gwn59tMZ/5f ZZkkDME3kfRx4XCn1UGA33NgaZUWaFMhGUNhS6toiYvh9sXIKBEBAqzP/YgVSE6MDrtT +O6y1R3stoO69makJNcD7kh7BWFa+04AWe03RBy+H/PYVwyJKdhjKKxPkWjHg/E4VAIp UPlQ== 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=XBcxKh4doOX0pFb3D6b9lBHWHCCUYHWbQQl51CV8SWo=; b=gKBKzzdFU4fu48m/Ou4iYoSP4NDB0+GvGoObxjfvheegDuMeZHyptEvd+SlYxKKTe/ eLEy/18QN4WmY8QfG8OZvdSNnoI9+mnDGWcTe0GY40aEoDcfjewmwtrm30QXlkF2uUVo /YfQk9RyV7WjMVes8Wx8QHICsqtqjVFqmkQCDIUbyOZS10CpbTuxRaZpKEAQTSYTJBhm QNkKZbu5YgUTQ7AunvyGaLJ1Rk918doxuh9s6aELA50kTWdyHuVABx/wHyAjql3oXnUY 17Yhst72qPymt1S9efhCFtg5p0t41SBeEoCnUYUDi6by58osy7VxiBQtEe4GBiO8qRug 23SQ== X-Gm-Message-State: APzg51BOx42iu75C6OvOx7ewgFn/avhgH8wt1XHVoY9OlgCO53fKPJFT JFYBxXcxQZhLMCegKPkNTUYfXw== X-Google-Smtp-Source: ANB0Vdat07yXQ0BsQoo1LJ2JL8Qc2rVBPfxQ++3IBocgv/4ZMGTvtCrmgxiiAtcWkBo98P3+l59n1g== X-Received: by 2002:adf:b726:: with SMTP id l38-v6mr5155295wre.115.1536314917962; Fri, 07 Sep 2018 03:08:37 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 15/16] nvmem: use SPDX license identifiers Date: Fri, 7 Sep 2018 12:07:49 +0200 Message-Id: <20180907100750.14564-16-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_110950_480063_71FC6CF5 X-CRM114-Status: GOOD ( 16.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 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 9e2f9c993a07..320b3cc975a0 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 be583c4eb2d0..4c146379b9ba 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 d14a577a002d..171fb6caa578 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 7 10:07: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: 10592035 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 926E2112B for ; Fri, 7 Sep 2018 10:34:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F21F2AD94 for ; Fri, 7 Sep 2018 10:34:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 710712AE15; Fri, 7 Sep 2018 10:34:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B76BB2AD94 for ; Fri, 7 Sep 2018 10:34: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=sZsvc/sLokSsLli9ZXR6AifEGVfQQr++uvYPDH+OzxA=; b=TZmWHIvjOsAGbG0/UTwrNW5fkS lNHa41UoHguZpZ1OOtAbR7bDna5KashydQSImljgogFg8sJHBaNzolhAEwl2GFCjl4URH8RnJtH9X ryMehh9TvCzFW4+TWODr3Kkqo2eoEtT41+5mCJUTpYzxROOKDcmeUDJAdjLCd/IYdxrMZ6AeZ9QRb KOpFHXTO1zx6Yw1rxkbN19mpkAuJiJXiVQUARRfVGCkkP228WGwHzgpJgFdRNJj9ZdR7gAv3ZNvQz 1EyjpycBjhXXPTVFKZOedBpvxaTz1trkXx+3ymG2gwqIqrEWjgXbeDBmPZd9Y1IA+hHcDNZcmncrk 3+8h9/nQ==; 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 1fyE61-0005jn-9P; Fri, 07 Sep 2018 10:34:37 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyE5z-0005jW-Uf for linux-arm-kernel@bombadil.infradead.org; Fri, 07 Sep 2018 10:34:36 +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=XDlS7q6y/Wy9nWc7nbll/DVBj4MgMyVUhgPfDRtNSjo=; b=2p58axN/ULIkBrJ58HjJaXoS+ OYSEoPufzW/cPQKzQtFvUQmvDFMS+JwMiYCoN3z8hoQ5bovxemmESs8Cp+d9W3AbpHa0XtNirtf+Z 7dGcSkO/bg3zprdzoNxQ4n9EwC700i2STMeYnzumHa6bZiI5GUXbV3QUFg9ZGJ7uGlKidjSIHwUe9 1jRceHXJNcbMj350c8GSxIRLnefml2wZz6Iqq+DEe1zE4exWEr3ebdxRvzKThG/q+/UX3EfI5NnQP UH6sGW5kZiMMVojtzPIhY+qkQck1mX+0tm4Iay4fnBsZ98h6YGuP7tAcnjkvauWCvl6fUvZYkYfHI FU14JknEA==; Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyDi6-0000bJ-TH for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 10:09:57 +0000 Received: by mail-wm0-x243.google.com with SMTP id s12-v6so14205018wmc.0 for ; Fri, 07 Sep 2018 03:09: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=XDlS7q6y/Wy9nWc7nbll/DVBj4MgMyVUhgPfDRtNSjo=; b=Z4SAuD3x3tEQXKzMfDOpaftPGNjhzCYi5BaFpqPhhHOW3f5RUnF6gn7xB7N+2Ve+ya rQf3Q5h2m1pDjT/RATBOO5DEGo5QoxKGB3lyXZwYHfDWjYIRNLjP1PWQwvu6xya/XJ3Z AqBxA/g1pVWpvODIIEs4+IG0KyoNL1zUUVVhfFcyktX5+21FYr+eViKKOfMgop8zu0UJ dd+UDvfp4q9r5WlPZrMqB43Mg9B6jqia4NjlWKkd3GIOUWyTcucPicR2k1jX4aGhwSlX 9wrdUaMjxLvrsBj5ZOaVA0VwWopXMXXzqwkPlHHp1q8XQetTd3wMDHKqTs0JNpuMc6G/ TblA== 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=XDlS7q6y/Wy9nWc7nbll/DVBj4MgMyVUhgPfDRtNSjo=; b=S2mtAULshAlcgh2lwbS71FE+SmDLgINw6dBhrst3tHO2BfdiuuIAi3H9jeEb2PeoZY xytekGkJCkAnQ4TMZwTTaqnOuCvbSe7ClMOOFmWdhhYudn+V/fM8Cj94KLBSumoQEt2B CvZLJX2TtboV50yeqiWitbi+u3QwgMtj0OIcMvFzsxBTzxBwFrG34Em7MjFQ2bRAS/+M 7++Y7EP5rXONcW66fZjmyce5cTUvPb4BsZsYiU8hyhrHvVQ/RrZ31PZpvP4Bnknfn4wn U3wjb4Z2REhcWimOCzApMSGsaf8HCJtW13PmXm+UrRu9Fer+4Yf/l2pUwJxbtcxihscz 58tQ== X-Gm-Message-State: APzg51Creppw7e6uiNYrYNfRZr5oNWe/ETMm/3gsMdPlH5GRKUMfKqpN CmuBx/LA7guAQl+chSKr2OVHew== X-Google-Smtp-Source: ANB0VdZlVGl7ISwf8sv1ihjauPAij7GLIdF/FxZ8mhR0+hZuO5NDSDDPaz5enFXHugngShCmwah/wA== X-Received: by 2002:a1c:a60e:: with SMTP id p14-v6mr5089493wme.64.1536314919195; Fri, 07 Sep 2018 03:08:39 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-83-232.w90-86.abo.wanadoo.fr. [90.86.25.232]) by smtp.gmail.com with ESMTPSA id 72-v6sm6631619wrb.48.2018.09.07.03.08.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 03:08: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 v2 16/16] nvmem: make the naming of arguments in nvmem_cell_get() consistent Date: Fri, 7 Sep 2018 12:07:50 +0200 Message-Id: <20180907100750.14564-17-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907100750.14564-1-brgl@bgdev.pl> References: <20180907100750.14564-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_060954_961831_0EEEB432 X-CRM114-Status: GOOD ( 20.73 ) 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 320b3cc975a0..efcc41ba487d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -873,16 +873,15 @@ EXPORT_SYMBOL_GPL(devm_nvmem_device_get); * 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; @@ -890,8 +889,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) @@ -959,22 +958,24 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) * 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) { if (dev->of_node) - return of_nvmem_cell_get(dev->of_node, cell_id); + return of_nvmem_cell_get(dev->of_node, id); - /* Only allow empty cell_id for DT systems. */ - if (!cell_id) + /* Only allow empty cell id for DT systems. */ + 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 4c146379b9ba..31ff907c7fe7 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -27,8 +27,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); @@ -54,13 +54,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); } @@ -145,12 +145,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); }