Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3919211imm; Wed, 5 Sep 2018 08:01:46 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0pQLtLvWwj12JsEf6TFClQlNHBDArHbTd8ZbLXwpAbXqNtuz1TdJkXdTPLyqxGIzD3ac9 X-Received: by 2002:a63:4860:: with SMTP id x32-v6mr32953170pgk.375.1536159706549; Wed, 05 Sep 2018 08:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536159706; cv=none; d=google.com; s=arc-20160816; b=YDQuqzmMnq0eLDF4gQ5sTi/ylkoLKL24NM7+yxpVPMV7y5tjwbH9d8KnoKvMYwL6qu 3zqCCzkCEVKalueOmDlX7QnCaWfYe5l/Y8ks5LUgUOb75W/y9Zxm20AnDgYSs9xpZsbs nQtnrhMGwcoMYyzLok3xsh9In/fSpXX2LHsjk3ax5Exl97tvgCG+1X6tpKnNPIos3O26 1iA0y/5ZL3E3o3X0iM3/FpaFF8Ngji/GMLOh+Kl6q3OkJRX1SqnqrGTOvLqJPb+BOWG6 AcRiH7Rh8ZnTHZGkz4sLG4hxSz5ahkoEBNHhCBqUgkXLWShAScLoMT+/JunhBeS11e+t n+6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=7soIAXT3GXD4SefRh7jv1wVv7NOVKc1e19knmwA3bnA=; b=K0WrTPf9qfn6N0E+qQEQk3DGFmGogt2o2FOeefkAGKV7x6qrbGzQ+4uhElAYGwCWZe PNJW08mYg0OzDiZXaNpIlzgBj7i37+t0bE+/2S0YHgKhB/M382UMbtVxJ+fzfEpXSzla 1uiKP+TFnvFddPd40l4ilbIhJkp/sMN3bnQvMX9mddt0zYI7f1qyWKuC7RWKlv4dND9O /e5sjYVj2aEvDb7o7ohoPAmi/UvVz7SGIhjuVEPl8wwcyx9FUwqX3gl3ZTAkE1dbfO/1 dIz4wV/SZ+PZu0BNnnEBSGZM62JXpRN89UAoQWRYZw1awYCYElM3ACYMKXyCi/AK88LI yFBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185-v6si2068331pgj.511.2018.09.05.08.01.29; Wed, 05 Sep 2018 08:01:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727626AbeIETad (ORCPT + 99 others); Wed, 5 Sep 2018 15:30:33 -0400 Received: from mail.bootlin.com ([62.4.15.54]:53129 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727527AbeIETac (ORCPT ); Wed, 5 Sep 2018 15:30:32 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 63C3C208B5; Wed, 5 Sep 2018 16:59:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-92-107.w90-88.abo.wanadoo.fr [90.88.33.107]) by mail.bootlin.com (Postfix) with ESMTPSA id DA8E620741; Wed, 5 Sep 2018 16:59:46 +0200 (CEST) Date: Wed, 5 Sep 2018 16:59:45 +0200 From: Boris Brezillon To: Bartosz Golaszewski Cc: Srinivas Kandagatla , Joachim Eastwood , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Andrew Lunn , Alban Bedel , Maxime Ripard , linux-doc , Linux Kernel Mailing List , Linux ARM , Bartosz Golaszewski Subject: Re: [PATCH 11/13] nvmem: add support for cell lookups from machine code Message-ID: <20180905165945.6101d62e@bbrezillon> In-Reply-To: References: <20180905095738.26406-1-brgl@bgdev.pl> <20180905095738.26406-12-brgl@bgdev.pl> <20180905155741.22b7d0ef@bbrezillon> <20180905162135.700d2145@bbrezillon> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 5 Sep 2018 16:47:57 +0200 Bartosz Golaszewski wrote: > 2018-09-05 16:21 GMT+02:00 Boris Brezillon : > > On Wed, 5 Sep 2018 16:00:36 +0200 > > Bartosz Golaszewski wrote: > > > >> 2018-09-05 15:57 GMT+02:00 Boris Brezillon : > >> > On Wed, 5 Sep 2018 11:57:36 +0200 > >> > Bartosz Golaszewski wrote: > >> > > >> >> > >> >> +struct nvmem_cell_lookup { > >> >> + const char *nvmem_name; > >> >> + const char *dev_id; > >> > > >> > Shouldn't we have a con_id here? > >> > > >> >> + const char *cell_id; > >> >> + struct list_head node; > >> >> +}; > >> > >> I wanted to stay in line with the current API - nvmem_cell_get() takes > >> as argument a string called cell_id. I wanted to reflect that here. > > > > Actually, you need both. con_id is the name you would have in your DT > > in the nvmem-cell-names property, cell_id is the name of the cell > > you'd find under the nvmem device node. > > > > Let's take an example: > > > > mydev { > > #nvmem-cell-names = "mac-address", "revision"; > > #nvmem-cells = <&cell1>, <&cell2>; > > }; > > > > mynvmemdev { > > #size-cells = <1>; > > #address-cells = <1>; > > > > cell1: foo@0 { > > reg = <0x0 0x6>; > > }; > > > > cell2: bar@6 { > > reg = <0x6 0x10>; > > }; > > }; > > > > this can be described the same way using a consumer lookup table: > > > > struct nvmem_cell_lookup_entry { > > const char *con_id; > > const char *nvmem_name; > > const char *cell_name; > > }; > > > > struct nvmem_cell_lookup_table { > > struct list_head node; > > const char *dev_id; > > unsigned int nentries; > > const struct nvmem_cell_lookup_entry *entries; > > } > > > > static const struct nvmem_cell_lookup_entry mydev_nvmem_cells[] = { > > { > > .con_id = "mac-address", > > .nvmem_name = "mynvmemdev", > > .cell_name = "foo", > > }, > > { > > .con_id = "revision", > > .nvmem_name = "mynvmemdev", > > .cell_name = "bar", > > }, > > } > > > > static const struct nvmem_cell_lookup_table mydev_nvmem_lookup = { > > .dev_id = "mydev.0", > > .nentries = ARRAY_SIZE(mydev_nvmem_cells), > > .entries = mydev_nvmem_cells, > > }; > > > > > > ... > > > > nvmem_add_cell_lookups(&mydev_nvmem_lookup); > > Ok I get it. Shouldn't we change the argument name of nvmem_cell_get() > and friends from 'name' to 'con_id' or simply 'id' similarly to what > other frameworks do to avoid such confusion? I'll let Srinivas answer that one. > > I also don't see a need for splitting the lookup into two structures > here. Something like: > > struct nvmem_cell_lookup { > const char *nvmem_name; > const char *cell_name; > const char *dev_id; > const char *con_id; > }; > > Would be perfectly fine and would allow to register all lookups for > given machine with a single call. Yep, makes sense.