From patchwork Thu Mar 8 19:11:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10268735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A038860594 for ; Thu, 8 Mar 2018 19:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9014F20499 for ; Thu, 8 Mar 2018 19:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 849A728399; Thu, 8 Mar 2018 19:12:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable 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 B6DF428396 for ; Thu, 8 Mar 2018 19:12:42 +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=/Sn6gJj+EQi6VHJbHtOma0y4iNecOxA0oKQgew9tFXg=; b=mVlXsNUc4g3f9P0BNPa6F+A+7B ZNdLuKIgYNecOsHsJlOul6GUuBYOo7ePHASVsB4fQbIYSTMUY8YlP+SDwvAbQZJPBcR28lTizXZuL 2qnYr3ekuB+3ETeSOrIdzN8zWXHVYesEy+5/ViJq9oEL7DtLMrKITPHxqpiF7HjmQDlRj3PRrgaln Ze6BrPbEQIto0SaX1Qpoh2a+Nf460VpAOs7GECUlrsgx3UHK1cgKhe/Tv7CzS/Amj+dL9aSrbn60z WZcpFrEIPQXkMBOJVAlghZu7inxtUnpnE57+bfN8AZjlWSjRKAUktD+qtiSknAcD7dESWVFWrjMOz QirpRxlA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eu0xu-0001ur-D0; Thu, 08 Mar 2018 19:12:34 +0000 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eu0xq-0001t0-HO; Thu, 08 Mar 2018 19:12:32 +0000 Received: by mail-pl0-x241.google.com with SMTP id s13-v6so3838089plq.6; Thu, 08 Mar 2018 11:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eEsFiTx09k2Meo0CL7+y5ZBHMgs+PN31lPGuYYs6qmk=; b=NpKbWQRYj7xCDBcMxp44zZ0t/u5K0lFMnykkTMXxCVox70lgnO+GW+7gpj6yn/5BfB FwyBGEnq3rufKCAjr2mYmzYFO4t4QvelYJGaC3rXEdM+oFo+hx/CLSgWn9zgyVZCZBEg IKZkepGs8FN/0w0POMEiToKNVB0n49mzGkOBuT6Di1Y9nZ6pZfhssRf+42yCjgv8ZrX+ IHfTbDb49qQgfp7TGLhfaoFo/aSFaxQ+v/7fOuFZ8pMstyTemeUKPhgqvBKpj8syTInX OtSzQBqA5GY/Jv8P9GbARLEexzfxCeejnvc8OUlm8VNsvbEtU8btJ/RPBTp6kp9I+Ine TmdQ== 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=eEsFiTx09k2Meo0CL7+y5ZBHMgs+PN31lPGuYYs6qmk=; b=Ak3bkQ0mBA0C6Vwrok1mvVOmcL/kpHUBGOi4jotivR5Y9MdzKjnYDifRJf+MBNVgLQ PdyD7TB46LtRZ0OoC7cJnFfIBT1Tt6T+opKSLUm1Urw82d3iBc9XGIJrmdVPlcNRuGBp STGnGvOxaM1dvOSeaRpDtRZv5ZO7IuD4KMKGDGVUEGiNov/DIMQF7qTPeglPtvp4CgtC PKk4Eomlcgn0Qdx5jIF1HA0FjaM6GbvtK6x5uNmV9KGQWgP4pbgg78bYYSM+Kxg62tDV LJHA0ywyEBoY1JdpLi9ohtIYFU1jLLpbRufUTlqUSJJKGYxewyGYNmnLYugp8QWmJjRg IhUg== X-Gm-Message-State: APf1xPCpDeXqjkbPN9FLjCQjYy39lGLojnDquklZEXnLyJLDG4pGhwRh GSEA2kWml4xhIfO5g4k/qyA= X-Google-Smtp-Source: AG47ELtBaOeVzP5MifJurjzcGfmk+GPPLFGfCzDzqeyrJMS2fz5Evmwn7MPUuKPNwr2K3iN2UdkdnQ== X-Received: by 2002:a17:902:b704:: with SMTP id d4-v6mr25457902pls.406.1520536342190; Thu, 08 Mar 2018 11:12:22 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id j64sm47201768pfe.68.2018.03.08.11.12.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 11:12:21 -0800 (PST) From: Andrey Smirnov To: Srinivas Kandagatla Subject: [PATCH v5 02/21] nvmem: core: Allow specifying device name verbatim Date: Thu, 8 Mar 2018 11:11:46 -0800 Message-Id: <20180308191205.26943-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180308191205.26943-1-andrew.smirnov@gmail.com> References: <20180308191205.26943-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180308_111230_645959_2B03D4F1 X-CRM114-Status: GOOD ( 12.88 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , linux-rockchip@lists.infradead.org, Andrey Smirnov , Kevin Hilman , linux-kernel@vger.kernel.org, Masahiro Yamada , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Matthias Brugger , linux-amlogic@lists.infradead.org, Carlo Caione , cphealy@gmail.com MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add code to allow avoid having nvmem core append a numeric suffix to the end of the name by passing config->id of -1. Cc: Srinivas Kandagatla Cc: Heiko Stuebner Cc: Masahiro Yamada Cc: Carlo Caione Cc: Kevin Hilman Cc: Matthias Brugger Cc: cphealy@gmail.com Cc: linux-kernel@vger.kernel.org Cc: linux-mediatek@lists.infradead.org Cc: linux-rockchip@lists.infradead.org Cc: linux-amlogic@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Andrey Smirnov --- drivers/nvmem/core.c | 11 ++++++++--- include/linux/nvmem-provider.h | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 35a3dbeea324..99e04cfcc723 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -473,9 +473,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->reg_read = config->reg_read; nvmem->reg_write = config->reg_write; nvmem->dev.of_node = config->dev->of_node; - dev_set_name(&nvmem->dev, "%s%d", - config->name ? : "nvmem", - config->name ? config->id : nvmem->id); + + if (config->id == -1 && config->name) { + dev_set_name(&nvmem->dev, "%s", config->name); + } else { + dev_set_name(&nvmem->dev, "%s%d", + config->name ? : "nvmem", + config->name ? config->id : nvmem->id); + } nvmem->read_only = device_property_present(config->dev, "read-only") | config->read_only; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index a39f76ff2ccd..b00567a07496 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -43,6 +43,9 @@ typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset, * Note: A default "nvmem" name will be assigned to the device if * no name is specified in its configuration. In such case "" is * generated with ida_simple_get() and provided id field is ignored. + * + * Note: Specifying name and setting id to -1 implies a unique device + * whose name is provided as-is (kept unaltered). */ struct nvmem_config { struct device *dev;