diff mbox series

[3/3] power: reset: nvmem-reboot-mode: fix write for small cells

Message ID 20241017160904.2803663-3-jberring@redhat.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series [1/3] nvmem: core: improve range check for nvmem_cell_write() | expand

Commit Message

Jennifer Berringer Oct. 17, 2024, 4:09 p.m. UTC
Some devices, such as Qualcomm sa8775p, have an nvmem reboot mode cell
that is smaller than 32 bits, which resulted in
nvmem_reboot_mode_write() failing. Using nvmem_cell_write_variable_u32()
fixes this by writing only the least-significant byte of the magic value
when the size specified in device tree is only one byte.

Signed-off-by: Jennifer Berringer <jberring@redhat.com>
---
 drivers/power/reset/nvmem-reboot-mode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

kernel test robot Oct. 19, 2024, 12:26 a.m. UTC | #1
Hi Jennifer,

kernel test robot noticed the following build errors:

[auto build test ERROR on 98f7e32f20d28ec452afb208f9cffc08448a2652]

url:    https://github.com/intel-lab-lkp/linux/commits/Jennifer-Berringer/nvmem-core-add-nvmem_cell_write_variable_u32/20241018-001140
base:   98f7e32f20d28ec452afb208f9cffc08448a2652
patch link:    https://lore.kernel.org/r/20241017160904.2803663-3-jberring%40redhat.com
patch subject: [PATCH 3/3] power: reset: nvmem-reboot-mode: fix write for small cells
config: i386-randconfig-015-20241019 (https://download.01.org/0day-ci/archive/20241019/202410190829.e98plEvU-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241019/202410190829.e98plEvU-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410190829.e98plEvU-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/power/reset/nvmem-reboot-mode.c: In function 'nvmem_reboot_mode_write':
>> drivers/power/reset/nvmem-reboot-mode.c:27:15: error: implicit declaration of function 'nvmem_cell_write_variable_u32'; did you mean 'nvmem_cell_read_variable_le_u32'? [-Werror=implicit-function-declaration]
      27 |         ret = nvmem_cell_write_variable_u32(nvmem_rbm->cell, magic);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               nvmem_cell_read_variable_le_u32
   cc1: some warnings being treated as errors


vim +27 drivers/power/reset/nvmem-reboot-mode.c

    18	
    19	static int nvmem_reboot_mode_write(struct reboot_mode_driver *reboot,
    20					    unsigned int magic)
    21	{
    22		int ret;
    23		struct nvmem_reboot_mode *nvmem_rbm;
    24	
    25		nvmem_rbm = container_of(reboot, struct nvmem_reboot_mode, reboot);
    26	
  > 27		ret = nvmem_cell_write_variable_u32(nvmem_rbm->cell, magic);
    28		if (ret < 0)
    29			dev_err(reboot->dev, "update reboot mode bits failed\n");
    30	
    31		return ret;
    32	}
    33
diff mbox series

Patch

diff --git a/drivers/power/reset/nvmem-reboot-mode.c b/drivers/power/reset/nvmem-reboot-mode.c
index 41530b70cfc4..b52eb879d1c1 100644
--- a/drivers/power/reset/nvmem-reboot-mode.c
+++ b/drivers/power/reset/nvmem-reboot-mode.c
@@ -24,7 +24,7 @@  static int nvmem_reboot_mode_write(struct reboot_mode_driver *reboot,
 
 	nvmem_rbm = container_of(reboot, struct nvmem_reboot_mode, reboot);
 
-	ret = nvmem_cell_write(nvmem_rbm->cell, &magic, sizeof(magic));
+	ret = nvmem_cell_write_variable_u32(nvmem_rbm->cell, magic);
 	if (ret < 0)
 		dev_err(reboot->dev, "update reboot mode bits failed\n");