From patchwork Wed Jan 3 20:00:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10142955 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 56687601A1 for ; Wed, 3 Jan 2018 20:04:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 494CA29200 for ; Wed, 3 Jan 2018 20:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D08E29279; Wed, 3 Jan 2018 20:04:25 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 A2FFB29200 for ; Wed, 3 Jan 2018 20:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=JQ+NTyzOJYVzU4Qay2hnPnwl++LLBNiHoRiv0W/JNSs=; b=X1jvcyjXn/csL6IsrZbOf/6tLD WnEgE16NUTzM9o+IwYNpapcUlfeHx+ed6CrO0Es4g3vcvPEDbMxXFn/5uDr4InWyZBIkByMI23uz2 GQAAUyBakZHdZAoeBzZTIAx7DScx7+JDy6XbkOPFcQXC52BGx83d+MeGuf7BWMNMxFfG4TO03G2VQ Y9cxsVoJw1KlS5qQNHVSs0T6jgS15x3sBstIWgd1y7WMKGUyAMQu1GN30gDH4dN+6pBePVzQ3D+gr Vwz/RFx4GrGkbrEfejMdcVKtLg8ao1F91VmJ2ViVkiJ++n/DcGxNhWP778F4VxMX7waHqEI6Td0xs AYDslrQw==; 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 1eWpGu-0006Fi-HY; Wed, 03 Jan 2018 20:04:20 +0000 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWpEC-0004Yw-1U; Wed, 03 Jan 2018 20:01:45 +0000 Received: by mail-pl0-x242.google.com with SMTP id s10so1867491plj.5; Wed, 03 Jan 2018 12:01:21 -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=f1ftXiBqmaCTxJpHt2HykRIlYcDTg6jVqwcFLZICXMA=; b=TVwWR1vBWZ7AjEzXlSHHKIPE3Ul24291vnp/8XkrEYjYvSj1htxKcsqatm5CIiRnR7 wOY3p+pDN1KUmq+h/Jp2fVj5LXA+gCjE7Bf4AV+aFWbPHqcc3T8aQGCwbPgib9w4QniO Dw2Lg/SPvoEGOI1Gxfa7IwlWwb4hRIRGDqk3mX9xS+bkc2ja7RsY11mqdMpAmaeiYVtF Zj5ytwMn4grq4ixv1WSs8NfN8ub2CQMaX8h6dzaJ1lqAwBX6i8sva0B2gOqE5gODGyD2 NWd+syAm/jbzYTUmxshceH6VFie07/E7zw5IWQgKIXPGYUw5lFz1rJfCnx+wwORx7YK9 94bg== 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=f1ftXiBqmaCTxJpHt2HykRIlYcDTg6jVqwcFLZICXMA=; b=BOMuuNvwQBv6sghVo+CApODZYNGyBJKjhS7LbnbejE0VFlfFUA06x1KNeSWliNUcQl l8lsygHVeQjgK6ETsu9XKFrggOSXwtvmS2YLK1WOk/8yog5tRvxPwKgGQV+5T6ZmanQ/ v/ZppqxXUAVqiVhGsOqaZYFTTxZej/sovtDbEg61yKpqpXEJUSJLvgEKKf4ZHcGh4Jnr 9Gv/gH5YxBBMPU3XuVcN/XGSMJDJzjYCkxwH6l7J7J+SBwhwb+funfVWd9uU1EnWOM/m vdVEFR2tySL+kyVXFYMe1BJYQzzaZthzUJ8zHgNqNYClUWs+DTqfPz4nv/JsjGcX+sVU Y+qA== X-Gm-Message-State: AKGB3mLeXi9J74nEIMeyOUiO79exIvETDjX22HakPckRIU+ojs6su3ty Uuzatktlbw4+YwiVvfdr9kI= X-Google-Smtp-Source: ACJfBotTC5BvfFhtzy4KM4TnOxpPpvW2ZKIrkDd7Ur6HYnafmUSosMH9HeL+V0kvfljAQin2mX6VZw== X-Received: by 10.84.168.227 with SMTP id f90mr2336785plb.320.1515009681425; Wed, 03 Jan 2018 12:01:21 -0800 (PST) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id b9sm4542209pfl.108.2018.01.03.12.01.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2018 12:01:20 -0800 (PST) From: Andrey Smirnov To: Srinivas Kandagatla Subject: [PATCH v3 02/22] nvmem: core: Allow specifying device name verbatim Date: Wed, 3 Jan 2018 12:00:54 -0800 Message-Id: <20180103200114.23922-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180103200114.23922-1-andrew.smirnov@gmail.com> References: <20180103200114.23922-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180103_120132_231114_D308D5ED X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. 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: 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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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 5a5cefd12153..57cbeacfbeb2 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -475,9 +475,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->reg_write = config->reg_write; np = config->dev->of_node; nvmem->dev.of_node = np; - 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 = of_property_read_bool(np, "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;