Subject: Re: [PATCH v3] char: nvram: Remove unused nvram_mutex to fix -Wunused-variable warning

From: kernel test robot <[email-masked]>
Date: Thu, 2 Apr 2026 22:04:11 +0200

Hi Venkat,

kernel test robot noticed the following build errors:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on char-misc/char-misc-next char-misc/char-misc-linus linus/master v7.0-rc6 next-20260402]
[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/Venkat-Rao-Bagalkote/char-nvram-Remove-unused-nvram_mutex-to-fix-Wunused-variable-warning/20260330-234134
base:   char-misc/char-misc-testing
patch link:    https://lore.kernel.org/r/20260330062201.2581-1-venkat88%40linux.ibm.com
patch subject: [PATCH v3] char: nvram: Remove unused nvram_mutex to fix -Wunused-variable warning
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260402/[email-masked]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260402/[email-masked]/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 <[email-masked]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email-masked]/

All errors (new ones prefixed by >>):

   drivers/char/nvram.c: In function 'nvram_misc_ioctl':
>> drivers/char/nvram.c:327:37: error: 'nvram_mutex' undeclared (first use in this function)
     327 |                         mutex_lock(&nvram_mutex);
         |                                     ^~~~~~~~~~~
   drivers/char/nvram.c:327:37: note: each undeclared identifier is reported only once for each function it appears in

vim +/nvram_mutex +327 drivers/char/nvram.c

^1da177e4c3f41 Linus Torvalds      2005-04-16  278  
cb8d8006d43f22 Finn Thain          2019-01-15  279  static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
55929332c92e5d Arnd Bergmann       2010-04-27  280  			     unsigned long arg)
^1da177e4c3f41 Linus Torvalds      2005-04-16  281  {
2d58636e0af724 Finn Thain          2019-01-15  282  	long ret = -ENOTTY;
^1da177e4c3f41 Linus Torvalds      2005-04-16  283  
^1da177e4c3f41 Linus Torvalds      2005-04-16  284  	switch (cmd) {
95ac14b8a32817 Finn Thain          2019-01-15  285  #ifdef CONFIG_PPC
95ac14b8a32817 Finn Thain          2019-01-15  286  	case OBSOLETE_PMAC_NVRAM_GET_OFFSET:
95ac14b8a32817 Finn Thain          2019-01-15  287  		pr_warn("nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n");
df561f6688fef7 Gustavo A. R. Silva 2020-08-23  288  		fallthrough;
95ac14b8a32817 Finn Thain          2019-01-15  289  	case IOC_NVRAM_GET_OFFSET:
95ac14b8a32817 Finn Thain          2019-01-15  290  		ret = -EINVAL;
95ac14b8a32817 Finn Thain          2019-01-15  291  #ifdef CONFIG_PPC_PMAC
95ac14b8a32817 Finn Thain          2019-01-15  292  		if (machine_is(powermac)) {
95ac14b8a32817 Finn Thain          2019-01-15  293  			int part, offset;
95ac14b8a32817 Finn Thain          2019-01-15  294  
95ac14b8a32817 Finn Thain          2019-01-15  295  			if (copy_from_user(&part, (void __user *)arg,
95ac14b8a32817 Finn Thain          2019-01-15  296  					   sizeof(part)) != 0)
95ac14b8a32817 Finn Thain          2019-01-15  297  				return -EFAULT;
95ac14b8a32817 Finn Thain          2019-01-15  298  			if (part < pmac_nvram_OF || part > pmac_nvram_NR)
95ac14b8a32817 Finn Thain          2019-01-15  299  				return -EINVAL;
95ac14b8a32817 Finn Thain          2019-01-15  300  			offset = pmac_get_partition(part);
20e07af71f34d9 Finn Thain          2019-01-15  301  			if (offset < 0)
20e07af71f34d9 Finn Thain          2019-01-15  302  				return -EINVAL;
95ac14b8a32817 Finn Thain          2019-01-15  303  			if (copy_to_user((void __user *)arg,
95ac14b8a32817 Finn Thain          2019-01-15  304  					 &offset, sizeof(offset)) != 0)
95ac14b8a32817 Finn Thain          2019-01-15  305  				return -EFAULT;
95ac14b8a32817 Finn Thain          2019-01-15  306  			ret = 0;
95ac14b8a32817 Finn Thain          2019-01-15  307  		}
95ac14b8a32817 Finn Thain          2019-01-15  308  #endif
95ac14b8a32817 Finn Thain          2019-01-15  309  		break;
20e07af71f34d9 Finn Thain          2019-01-15  310  #ifdef CONFIG_PPC32
95ac14b8a32817 Finn Thain          2019-01-15  311  	case IOC_NVRAM_SYNC:
95ac14b8a32817 Finn Thain          2019-01-15  312  		if (ppc_md.nvram_sync != NULL) {
95ac14b8a32817 Finn Thain          2019-01-15  313  			mutex_lock(&nvram_mutex);
95ac14b8a32817 Finn Thain          2019-01-15  314  			ppc_md.nvram_sync();
95ac14b8a32817 Finn Thain          2019-01-15  315  			mutex_unlock(&nvram_mutex);
95ac14b8a32817 Finn Thain          2019-01-15  316  		}
95ac14b8a32817 Finn Thain          2019-01-15  317  		ret = 0;
95ac14b8a32817 Finn Thain          2019-01-15  318  		break;
20e07af71f34d9 Finn Thain          2019-01-15  319  #endif
95ac14b8a32817 Finn Thain          2019-01-15  320  #elif defined(CONFIG_X86) || defined(CONFIG_M68K)
^1da177e4c3f41 Linus Torvalds      2005-04-16  321  	case NVRAM_INIT:
^1da177e4c3f41 Linus Torvalds      2005-04-16  322  		/* initialize NVRAM contents and checksum */
^1da177e4c3f41 Linus Torvalds      2005-04-16  323  		if (!capable(CAP_SYS_ADMIN))
^1da177e4c3f41 Linus Torvalds      2005-04-16  324  			return -EACCES;
^1da177e4c3f41 Linus Torvalds      2005-04-16  325  
2d58636e0af724 Finn Thain          2019-01-15  326  		if (arch_nvram_ops.initialize != NULL) {
613655fa39ff69 Arnd Bergmann       2010-06-02 @327  			mutex_lock(&nvram_mutex);
2d58636e0af724 Finn Thain          2019-01-15  328  			ret = arch_nvram_ops.initialize();
613655fa39ff69 Arnd Bergmann       2010-06-02  329  			mutex_unlock(&nvram_mutex);
2d58636e0af724 Finn Thain          2019-01-15  330  		}
2d58636e0af724 Finn Thain          2019-01-15  331  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  332  	case NVRAM_SETCKS:
^1da177e4c3f41 Linus Torvalds      2005-04-16  333  		/* just set checksum, contents unchanged (maybe useful after
^1da177e4c3f41 Linus Torvalds      2005-04-16  334  		 * checksum garbaged somehow...) */
^1da177e4c3f41 Linus Torvalds      2005-04-16  335  		if (!capable(CAP_SYS_ADMIN))
^1da177e4c3f41 Linus Torvalds      2005-04-16  336  			return -EACCES;
^1da177e4c3f41 Linus Torvalds      2005-04-16  337  
2d58636e0af724 Finn Thain          2019-01-15  338  		if (arch_nvram_ops.set_checksum != NULL) {
613655fa39ff69 Arnd Bergmann       2010-06-02  339  			mutex_lock(&nvram_mutex);
2d58636e0af724 Finn Thain          2019-01-15  340  			ret = arch_nvram_ops.set_checksum();
613655fa39ff69 Arnd Bergmann       2010-06-02  341  			mutex_unlock(&nvram_mutex);
^1da177e4c3f41 Linus Torvalds      2005-04-16  342  		}
2d58636e0af724 Finn Thain          2019-01-15  343  		break;
95ac14b8a32817 Finn Thain          2019-01-15  344  #endif /* CONFIG_X86 || CONFIG_M68K */
2d58636e0af724 Finn Thain          2019-01-15  345  	}
2d58636e0af724 Finn Thain          2019-01-15  346  	return ret;
^1da177e4c3f41 Linus Torvalds      2005-04-16  347  }
^1da177e4c3f41 Linus Torvalds      2005-04-16  348  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki