[V4,4/4] nvmem: layouts: add fixed cells layout

Message ID 20230317132620.31142-5-zajec5@gmail.com
State New
Headers
Series nvmem: add fixed cells layout |

Commit Message

Rafał Miłecki March 17, 2023, 1:26 p.m. UTC
  From: Rafał Miłecki <rafal@milecki.pl>

This adds a driver for the "fixed-layout" NVMEM layout binding. It
allows defining NVMEM cells in a layout DT node named "nvmem-layout".

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/nvmem/layouts/Kconfig  |  8 +++++++
 drivers/nvmem/layouts/Makefile |  1 +
 drivers/nvmem/layouts/fixed.c  | 41 ++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/nvmem/layouts/fixed.c
  

Comments

kernel test robot March 17, 2023, 3:54 p.m. UTC | #1
Hi Rafał,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20230317]
[cannot apply to robh/for-next krzk-dt/for-next char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.3-rc2 v6.3-rc1 v6.2 v6.3-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rafa-Mi-ecki/dt-bindings-nvmem-layouts-add-fixed-layout/20230317-212948
patch link:    https://lore.kernel.org/r/20230317132620.31142-5-zajec5%40gmail.com
patch subject: [PATCH V4 4/4] nvmem: layouts: add fixed cells layout
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230317/202303172348.sb4rePWl-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/7ffae9ad6cdb83ae60e3eacf96ab779e0b69a65b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Rafa-Mi-ecki/dt-bindings-nvmem-layouts-add-fixed-layout/20230317-212948
        git checkout 7ffae9ad6cdb83ae60e3eacf96ab779e0b69a65b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash drivers/nvmem/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303172348.sb4rePWl-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/nvmem/layouts/fixed.c:37:1: warning: data definition has no type or storage class
      37 | module_nvmem_layout_driver(fixed_nvmem_layout);
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvmem/layouts/fixed.c:37:1: error: type defaults to 'int' in declaration of 'module_nvmem_layout_driver' [-Werror=implicit-int]
>> drivers/nvmem/layouts/fixed.c:37:1: warning: parameter names (without types) in function declaration
   cc1: some warnings being treated as errors


vim +37 drivers/nvmem/layouts/fixed.c

    36	
  > 37	module_nvmem_layout_driver(fixed_nvmem_layout);
    38
  
Rafał Miłecki March 17, 2023, 4:04 p.m. UTC | #2
On 17.03.2023 16:54, kernel test robot wrote:
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on next-20230317]
> [cannot apply to robh/for-next krzk-dt/for-next char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.3-rc2 v6.3-rc1 v6.2 v6.3-rc2]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Rafa-Mi-ecki/dt-bindings-nvmem-layouts-add-fixed-layout/20230317-212948
> patch link:    https://lore.kernel.org/r/20230317132620.31142-5-zajec5%40gmail.com
> patch subject: [PATCH V4 4/4] nvmem: layouts: add fixed cells layout
> config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230317/202303172348.sb4rePWl-lkp@intel.com/config)
> compiler: sparc64-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # https://github.com/intel-lab-lkp/linux/commit/7ffae9ad6cdb83ae60e3eacf96ab779e0b69a65b
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Rafa-Mi-ecki/dt-bindings-nvmem-layouts-add-fixed-layout/20230317-212948
>          git checkout 7ffae9ad6cdb83ae60e3eacf96ab779e0b69a65b
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash drivers/nvmem/
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Link: https://lore.kernel.org/oe-kbuild-all/202303172348.sb4rePWl-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>>> drivers/nvmem/layouts/fixed.c:37:1: warning: data definition has no type or storage class
>        37 | module_nvmem_layout_driver(fixed_nvmem_layout);
>           | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/nvmem/layouts/fixed.c:37:1: error: type defaults to 'int' in declaration of 'module_nvmem_layout_driver' [-Werror=implicit-int]
>>> drivers/nvmem/layouts/fixed.c:37:1: warning: parameter names (without types) in function declaration
>     cc1: some warnings being treated as errors

I reported that to Miquel already, he's going to improve his patch:
https://lore.kernel.org/lkml/20230316173741.4f572068@xps-13/


> vim +37 drivers/nvmem/layouts/fixed.c
> 
>      36	
>    > 37	module_nvmem_layout_driver(fixed_nvmem_layout);
>      38	
>
  

Patch

diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig
index 7ff1ee1c1f05..2ebbde7b15b2 100644
--- a/drivers/nvmem/layouts/Kconfig
+++ b/drivers/nvmem/layouts/Kconfig
@@ -2,6 +2,14 @@ 
 
 menu "Layout Types"
 
+config NVMEM_LAYOUT_FIXED
+	tristate "Fixed cells layout support"
+	help
+	  Say Y here if you want to support layout with fixed cells (hardcoded
+	  offsets and sizes).
+
+	  If unsure, say N.
+
 config NVMEM_LAYOUT_SL28_VPD
 	tristate "Kontron sl28 VPD layout support"
 	select CRC8
diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile
index 2974bd7d33ed..449dd893f968 100644
--- a/drivers/nvmem/layouts/Makefile
+++ b/drivers/nvmem/layouts/Makefile
@@ -3,5 +3,6 @@ 
 # Makefile for nvmem layouts.
 #
 
+obj-$(CONFIG_NVMEM_LAYOUT_FIXED) += fixed.o
 obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o
 obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o
diff --git a/drivers/nvmem/layouts/fixed.c b/drivers/nvmem/layouts/fixed.c
new file mode 100644
index 000000000000..b8d2f141d272
--- /dev/null
+++ b/drivers/nvmem/layouts/fixed.c
@@ -0,0 +1,41 @@ 
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of.h>
+
+static int fixed_add_cells(struct device *dev, struct nvmem_device *nvmem,
+			   struct nvmem_layout *layout)
+{
+	struct device_node *layout_np;
+	int err;
+
+	layout_np = of_nvmem_layout_get_container(nvmem);
+	if (!layout_np)
+		return -ENOENT;
+
+	err = nvmem_add_cells_from_of(nvmem, layout_np);
+
+	of_node_put(layout_np);
+
+	return err;
+}
+
+static const struct of_device_id fixed_of_match_table[] = {
+	{ .compatible = "fixed-layout" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, fixed_of_match_table);
+
+struct nvmem_layout fixed_nvmem_layout = {
+	.name = "fixed-layout",
+	.of_match_table = fixed_of_match_table,
+	.add_cells = fixed_add_cells,
+};
+
+module_nvmem_layout_driver(fixed_nvmem_layout);
+
+MODULE_AUTHOR("Rafał Miłecki");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(of, fixed_of_match_table);