Skip to content

Commit e896c04

Browse files
nathanchancebroonie
authored andcommitted
spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op()
After commit e6204f3 ("spi: amd: Drop redundant check"), clang warns (or errors with CONFIG_WERROR=y): drivers/spi/spi-amd.c:695:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized] 695 | return ret; | ^~~ drivers/spi/spi-amd.c:673:9: note: initialize the variable 'ret' to silence this warning 673 | int ret; | ^ | = 0 1 error generated. ret is no longer set on anything other than the default switch path. Replace ret with a direct return of 0 at the end of the function and -EOPNOTSUPP in the default case to resolve the warning. Fixes: e6204f3 ("spi: amd: Drop redundant check") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202501112315.ugYQ7Ce7-lkp@intel.com/ Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://patch.msgid.link/20250111-spi-amd-fix-uninitialized-ret-v1-1-c66ab9f6a23d@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 226d6cb commit e896c04

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/spi/spi-amd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,
670670
const struct spi_mem_op *op)
671671
{
672672
struct amd_spi *amd_spi;
673-
int ret;
674673

675674
amd_spi = spi_controller_get_devdata(mem->spi->controller);
676675

@@ -689,10 +688,10 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,
689688
amd_spi_mem_data_out(amd_spi, op);
690689
break;
691690
default:
692-
ret = -EOPNOTSUPP;
691+
return -EOPNOTSUPP;
693692
}
694693

695-
return ret;
694+
return 0;
696695
}
697696

698697
static const struct spi_controller_mem_ops amd_spi_mem_ops = {

0 commit comments

Comments
 (0)