Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4958013pxb; Tue, 28 Sep 2021 07:42:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6IXN8DOegzK2pqIIGxhezYcm+PWVgpQsGaoMIoo0xZRf3E6laLBW8cM7pJSTzybNrEbg3 X-Received: by 2002:a50:d9ce:: with SMTP id x14mr8031416edj.175.1632840145072; Tue, 28 Sep 2021 07:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632840145; cv=none; d=google.com; s=arc-20160816; b=uEIRsmh7EFZjnvK0mTq18H8YXvC4Yu8OXb4sb5XWkUOsdR35E1xz6Gg7eimpJFaW46 Khm3m5bbnx/zx9WGjV7GWVMGV0SFCPjxckSS3x3TBhfUufBvPNenc2DCoKTbV4Yz8Eno BK9H2VIaGAqvMKAAICejA7915cVzPceWJvzcTbZc5wgw1G3hkhuZr8UPxsI25YmUR5OY at/bWz3BP6jkgwgNshApjIEUcw3G/BEfQr0FBqwb5PLEBuCBm41GjXjbP6LaNY7z8Bf7 iyEHkyII6cekfc8XJ+Y9TSIu4nC3tUv+xGQbiXWj0uTAzWY3+ivwTs3/EB+B1Ir3A9jm I1Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=pxJvMhOt0xNvz+afkkMlplB8Oci4FMpO0XMdkB5w8X0=; b=KoSQV6foIiM7Yf7+8MKWQ8kvxnKW4SF/Y2sD8dDbVj9ZLmKo12u19OKAArFJi2vsiI A1vrUFD5PYq56ibXQqkPk1VTXzbd3pKV+85OBw9J26kLMI0Svi1Jj4t0HG+hb7kMQqPW 43fpNSnFuREg2h3CS7OqycEtXexm9Q3xcy0hEa8mf34Dcyt+KtvdnLUqnCz2ySRc5goh ihYgODdPX5mrmjzqKCVRjyjRFs6xqDfv4HU+6KOeRuphNzuWHetQMTuZ3zQTv2ziS48j vH1oGWiKP6ShTas3qOcT2XCUlrSpvGPCDwsGkyY6qFvnCeD9SKT/c8t9N8i54YHCi3Mg sbvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGDPnEFT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si22558113edj.456.2021.09.28.07.41.59; Tue, 28 Sep 2021 07:42:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGDPnEFT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241343AbhI1Olk (ORCPT + 99 others); Tue, 28 Sep 2021 10:41:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbhI1Olj (ORCPT ); Tue, 28 Sep 2021 10:41:39 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D5FC06161C for ; Tue, 28 Sep 2021 07:40:00 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id k7so6596275wrd.13 for ; Tue, 28 Sep 2021 07:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pxJvMhOt0xNvz+afkkMlplB8Oci4FMpO0XMdkB5w8X0=; b=bGDPnEFT0YYGPPbCwa2hLR4rp2POsu8kr4eRpAgtNxcMCLoA+eEvvpr/fMYLKK+DyS JBsOWHuw5b3iQTLluqwniDe8k4TJt5NbQNP93jNgY7fxXZghBMdr4AXVlAeN6BcKLhYf 6l0eqwPwwSTufHyvWhAH/rIDXzEqX8+p63B6gH0cvzCbrkXsgBcOm69ScXqmPiAcuyk7 8SOaJ0TVny0vzT4ImFQWuR1DP4Ocz6VO7rvsiC44hSjHdbLN1PcvvUETxp/Vof+vN6dH KniP2UA3LsLm3lf2VwnTLYpThoBLVf3kzhaE9zsiqNGMzR8MjrvUcOjN/rJYUpc598B9 fC5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pxJvMhOt0xNvz+afkkMlplB8Oci4FMpO0XMdkB5w8X0=; b=1CAlaQzgpEjmk2gm2sqhNKQ2MRhXCVLe5k6ndRc2IwgfLytjUtGdKurlzEVLAKKJTF q/AIW4PhX6XQKqddNTWQPncQAI1eZmnArxCIJ/To1q/cza2wUqkDkgZDO3oeCdlmj6sy 0LWC230QtsByiSyVmrPWz1SDzGA/hgmjsvV2SvYNVVij6NImMZcI//PGG9TaXmawAoB5 icr+38hz4fmnFRZMFhB7XtyehgjPcmVKCjeMGQrKB+BAFEMN8tS4UZx8zd+v11HLKDyR aU6io415sQgmy0D2EtLxGjZ7XAIzVYnt7H8mpNtvJJWOW6n9gtzR94+VgTOXH7loSjzF IakQ== X-Gm-Message-State: AOAM532ISFIBjRj6qfbDSFCGDiGw9rZtEgu2tM5kZzMhDmC+AlAiDtie TsaKG+dfjdy+7foe6PlwaVay+w== X-Received: by 2002:adf:f64d:: with SMTP id x13mr463234wrp.360.1632839998940; Tue, 28 Sep 2021 07:39:58 -0700 (PDT) Received: from [192.168.86.34] (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.googlemail.com with ESMTPSA id s85sm3036041wme.20.2021.09.28.07.39.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 07:39:57 -0700 (PDT) Subject: Re: [PATCH v2 1/3] nvmem: core: introduce cells parser To: Vadym Kochan Cc: John Thomson , Rob Herring , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Robert Marko References: <20210608190327.22071-1-vadym.kochan@plvision.eu> <20210608190327.22071-2-vadym.kochan@plvision.eu> <43023500-dd6a-5180-057e-cecc1f1b6500@linaro.org> <20210616123356.GA9951@plvision.eu> <7e6d75ed-cebc-597f-7062-34261d184968@linaro.org> <0e471789-fe29-b747-5153-75c9b4616c7f@linaro.org> <1da03714-8f23-1004-e89a-891e4599e04a@linaro.org> <1e146349-9fef-972b-9084-577f02d5168b@linaro.org> <169d3f36-4297-32a3-3d23-824989625b26@linaro.org> <77b11bf7-3003-483f-b91e-bd93576eaae1@www.fastmail.com> <56fb5c64-4142-03ef-2ea8-fc586fd239e1@linaro.org> From: Srinivas Kandagatla Message-ID: Date: Tue, 28 Sep 2021 15:39:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/09/2021 15:11, Vadym Kochan wrote: > Srinivas Kandagatla writes: > >> On 28/09/2021 14:31, Vadym Kochan wrote: >>>>>> Can I note here that I would like to parse >>>>>> TLV data from an SPI-NOR device to NVMEM cells. >>>>>> The same general use case (getting mac-address from OEM data). >>>>>> >>>>>> Was planning to base my work on this series, as well as >>>>>> https://lore.kernel.org/all/20210908100257.17833-1-qiangqing.zhang@nxp.com/ >>>>>> (thanks for pointing that out Srinivas) >>>>>> >>>>>> Cheers, >>>>> What about at least to have just one call in core.c to make it a bit >>>>> de-coupled, like: >>>> Why do you want to decouple this? the provider driver should be very >>>> well aware of the format the data layout. >>>> >>> In my understanding nvmem device should not aware about the data layout >>> (in case it does not rely on device's specific characteristics). Same >>> cells layout (TLV, etc) might exist on other nvmem devices. >>> >> How would provider driver parse this without even knowing data layout? >> >> >>>> Its fine to an extent to adding parse_cells() callback in nvmem_config. >>>> >>> OK, in that case it will require small change in the core. >>> >>>>> core.c >>>>> >>>>> struct nvmem_device *nvmem_register(const struct nvmem_config *config) >>>>> { >>>>> ... >>>>> rval = nvmem_add_cells_from_table(nvmem); >>>>> if (rval) >>>>> goto err_remove_cells; >>>>> >>>>> + rval = nvmem_parse_cells(nvmem, of); >>>>> + if (rval) { >>>>> + /* err handling */ >>>>> + } >>>>> + >>>>> rval = nvmem_add_cells_from_of(nvmem); >>>>> if (rval) >>>>> goto err_remove_cells; >>>>> >>>>> blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); >>>>> >>>>> return nvmem; >>>>> >>>>> ... >>>>> >>>>> } >>>>> >>>>> somewhere in nvmem-parser.c: >>>> However this is totally over kill. >>>> >>>>> /* retreive parser name from of_node and call appropriate function to parse >>>>> non-fixed cells and update via of_update */ >>>> This is completely provider drivers job, nothing nvmem core should worry >>>> about. >>>> >>>> If you have concern of having code duplicated then we could make some of >>>> the common functions as library functions, But it still is within the >>>> scope of provider drivers. >>>> >>> Do I understand correctly that this parser function should be exported >>> from at24.c (in case of ONIE) and not from a separate C module ? Or >>> it just means that if there will be more users of this parsing function >>> then it might be moved to separate C module ? >> yes. >> For now am not really sure how many users are for such parsing function. >> >>>> --srini >>>> >>> BTW, what if such change will be declined by particular nvmem driver >>> maintainer ? >> You would need some changes to provider driver to be able to flag that >> there is some kind of parsing required anyway. >> > It might be some new property in device-tree which can be used also > for the other providers. But this new binding will still belong to the provider driver that you want to support parsing. --srini >