From patchwork Wed Feb 28 14:40: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: 10247699 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 17C0660362 for ; Wed, 28 Feb 2018 14:44:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072D0201A4 for ; Wed, 28 Feb 2018 14:44:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F00552881D; Wed, 28 Feb 2018 14:44:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 85067285A8 for ; Wed, 28 Feb 2018 14:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=J80NSU/0bpOIMBhev9L4EUtu25aUtyYxtw4Z+SIS+zs=; b=RWBNBOi/v0yi0GFOccYIq9mWXC qfFvtcUpjWDop9iAuEROrheC6roEC/Tkhdd5vwoWy5G9Jqi1AG9iLAtzmRuTdUBIA8Nghzp5Ox8wL 9bpTa+ZckjOG1knd+tjHp/fdTJExJkFVl3xjkymWaqRugO3vmckH7MdqJ+RO8qz9Vqi3+2oGOI1sB wqReKdOIujFsOTQWZo2nR11DlIB40pphfp/zNIlMYVg0gPpIMMOTIpt36sF6T5RpRxlqVgHKmHc05 yyDPAF/Ipx5Gw4It1LqeC0fGZomI07hSlyuvajZzUA5RzHZEutksYh2yWP4C8eI3MUIIOQbRcSpzL fTMZ7TLg==; 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 1er2xZ-0001u1-Ey; Wed, 28 Feb 2018 14:43:57 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1er2vL-0008QU-Nm; Wed, 28 Feb 2018 14:41:44 +0000 Received: by mail-pf0-x243.google.com with SMTP id u5so1065750pfh.6; Wed, 28 Feb 2018 06:41:29 -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=d/Iq03lJ/5y+3VCJYpLqQAcl5o6uCPPkXgfA6/WPNZ0=; b=ZRoHDX12P970pZZeOUHb9CWfGxYxX7UOhrV/1zfMwNA6WDZScqCEXATjRXHGHkJjRj 1uO5KZf1pqc7XIcDsDBlfTiKTXsjrvXpy0pNzY+x7yHrmwMgZJpmVf8Zj5pHrpUsbt5W VzMaZLPW5Vx997yl0s3HS+7RkgU9CiqI2LiAWxO+LdxGuEaE7KSdswGQQRGvRK2LDDs0 RO/iwtdeUoyBzxKNM60yCpoj6OfrlHhH6I308BsTfo6YUrgeoR4Sfx2FAGmrBXuEksKM JrlOniAh7qgvNcisT0cIm6qKTU3XNqTZQ6tg5JpWMydo6r6PjPqrfNNABrR1PAe9rjVv 5xjw== 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=d/Iq03lJ/5y+3VCJYpLqQAcl5o6uCPPkXgfA6/WPNZ0=; b=OJAkQioiOSVBuIDXLFxn+8A9W57XhWA0mw4tbZN7jMR/0K4GbKsohrTNGksjgSghQw vIilT1XIVt++AnELt4hWiEu2JuQu8po05CdcicUHoUaIfbM7hunRsveE4akaA7azCJLF gT+8mbaeCipVN0F4yXm/9JkKzdrnQtp59QLgP7jqWRxwQhjHE6U+njrbV8kYv/iJL5Ho jHpOxRHJjYoAZGV37z1CRpqI8azBjCrpADveKTktCIFDrS64BhCYNlVVbe2s8T1MkREW mU7mXZ3irGBzStLAoIv6EyiUcxERy8UMQ5cnrK1WJzUqSW2nl0QILhLK5/Es87cnVUP5 85sg== X-Gm-Message-State: APf1xPC1To4FCQsIMlohD/C4q2w/5YrwZx+8XqK/svIz5hslShei2oKg lIzu4AIzdWhjweXUNpEwu3M= X-Google-Smtp-Source: AH8x224LqJPB37WS8tvevvtk1Jzvh7SDZ3y9gTiWBXcQj80tDIZD+/HSzJeHyiJw7EK8oy/zw0ZcWg== X-Received: by 10.101.102.2 with SMTP id w2mr14494789pgv.326.1519828888585; Wed, 28 Feb 2018 06:41:28 -0800 (PST) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id h9sm3674312pgr.78.2018.02.28.06.41.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2018 06:41:27 -0800 (PST) From: Andrey Smirnov To: Srinivas Kandagatla Subject: [PATCH v4 02/22] nvmem: core: Allow specifying device name verbatim Date: Wed, 28 Feb 2018 06:40:46 -0800 Message-Id: <20180228144106.16363-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180228144106.16363-1-andrew.smirnov@gmail.com> References: <20180228144106.16363-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180228_064139_851836_19105921 X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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 27e599222ec1..4889a6c62a81 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;