From b3f649bbe6ea6be0a399ae4ed1a01bedf4b2b3f9 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Sun, 24 Nov 2024 21:02:05 +0800 Subject: [PATCH 1/6] pwm: phytium: initialize variable 'dbcly' before use Fix follow error with clang-19: drivers/pwm/pwm-phytium.c:233:2: error: variable 'dbcly' is uninitialized when used here [-Werror,-Wuninitialized] 233 | dbcly &= 0x0; | ^~~~~ drivers/pwm/pwm-phytium.c:226:11: note: initialize the variable 'dbcly' to silence this warning 226 | u64 dbcly, cycles, upcycles, dwcycles; | ^ | = 0 1 error generated. Signed-off-by: WangYuli --- drivers/pwm/pwm-phytium.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-phytium.c b/drivers/pwm/pwm-phytium.c index cd64e48b1f135..c9950009b931f 100644 --- a/drivers/pwm/pwm-phytium.c +++ b/drivers/pwm/pwm-phytium.c @@ -223,7 +223,8 @@ static int pwm_phytium_set_dbcly(struct pwm_chip *chip, unsigned int updbcly, un { struct phytium_pwm_chip *our_chip = to_phytium_pwm_chip(chip); u32 reg; - u64 dbcly, cycles, upcycles, dwcycles; + u64 cycles, upcycles, dwcycles; + u64 dbcly = 0; reg = readl(our_chip->base + REG_TPERIOD); if (has_acpi_companion(chip->dev)) From cadd3193208e9c2cc4bb6e16483db876d6a24a5f Mon Sep 17 00:00:00 2001 From: WangYuli Date: Sun, 24 Nov 2024 21:38:16 +0800 Subject: [PATCH 2/6] sound: soc: phytium: Avoid unneeded-internal-declaration warning by clang Fix follow errors with clang-19: sound/soc/phytium/phytium_i2s.c:979:18: error: variable 'bus_widths' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] 979 | static const u32 bus_widths[COMP_MAX_DATA_WIDTH] = { | ^~~~~~~~~~ sound/soc/phytium/phytium_i2s.c:987:18: error: variable 'formats' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] 987 | static const u32 formats[COMP_MAX_WORDSIZE] = { | ^~~~~~~ 2 errors generated. Signed-off-by: WangYuli --- sound/soc/phytium/phytium_i2s.c | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sound/soc/phytium/phytium_i2s.c b/sound/soc/phytium/phytium_i2s.c index d3966b705beb6..ea6dd0ac988ce 100644 --- a/sound/soc/phytium/phytium_i2s.c +++ b/sound/soc/phytium/phytium_i2s.c @@ -975,26 +975,6 @@ static const u32 fifo_width[COMP_MAX_WORDSIZE] = { 12, 16, 20, 24, 32, 0, 0, 0 }; -/* Width of (DMA) bus */ -static const u32 bus_widths[COMP_MAX_DATA_WIDTH] = { - DMA_SLAVE_BUSWIDTH_1_BYTE, - DMA_SLAVE_BUSWIDTH_2_BYTES, - DMA_SLAVE_BUSWIDTH_4_BYTES, - DMA_SLAVE_BUSWIDTH_UNDEFINED -}; - -/* PCM format to support channel resolution */ -static const u32 formats[COMP_MAX_WORDSIZE] = { - SNDRV_PCM_FMTBIT_S16_LE, - SNDRV_PCM_FMTBIT_S16_LE, - SNDRV_PCM_FMTBIT_S24_LE, - SNDRV_PCM_FMTBIT_S24_LE, - SNDRV_PCM_FMTBIT_S32_LE, - 0, - 0, - 0 -}; - static int phytium_configure_dai(struct i2s_phytium *dev) { u32 comp1 = i2s_read_reg(dev->regs, dev->i2s_reg_comp1); @@ -1002,6 +982,18 @@ static int phytium_configure_dai(struct i2s_phytium *dev) u32 fifo_depth = 1 << (1 + COMP1_FIFO_DEPTH_GLOBAL(comp1)); u32 idx; + /* PCM format to support channel resolution */ + static const u32 formats[COMP_MAX_WORDSIZE] = { + SNDRV_PCM_FMTBIT_S16_LE, + SNDRV_PCM_FMTBIT_S16_LE, + SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S32_LE, + 0, + 0, + 0 + }; + if (COMP1_TX_ENABLED(comp1)) { dev_dbg(dev->dev, " phytium: play supported\n"); idx = COMP1_TX_WORDSIZE_0(comp1); @@ -1038,6 +1030,14 @@ static int phytium_configure_dai_by_dt(struct i2s_phytium *dev) u32 idx2; int ret; + /* Width of (DMA) bus */ + static const u32 bus_widths[COMP_MAX_DATA_WIDTH] = { + DMA_SLAVE_BUSWIDTH_1_BYTE, + DMA_SLAVE_BUSWIDTH_2_BYTES, + DMA_SLAVE_BUSWIDTH_4_BYTES, + DMA_SLAVE_BUSWIDTH_UNDEFINED + }; + if (WARN_ON(idx >= ARRAY_SIZE(bus_widths))) return -EINVAL; From 07129445b537527b3eeb0f16c62163a3ad4c966d Mon Sep 17 00:00:00 2001 From: WangYuli Date: Sun, 24 Nov 2024 22:10:43 +0800 Subject: [PATCH 3/6] i3c: phytium: initialize variable 'ret' when !master->prescl0 Fix follow error with clang-19: drivers/i3c/master/i3c-master-phytium.c:1710:7: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] 1710 | if (!master->prescl0) | ^~~~~~~~~~~~~~~~ drivers/i3c/master/i3c-master-phytium.c:1788:9: note: uninitialized use occurs here 1788 | return ret; | ^~~ drivers/i3c/master/i3c-master-phytium.c:1710:3: note: remove the 'if' if its condition is always false 1710 | if (!master->prescl0) | ^~~~~~~~~~~~~~~~~~~~~ 1711 | goto err_disable_sysclk; | ~~~~~~~~~~~~~~~~~~~~~~~ drivers/i3c/master/i3c-master-phytium.c:1669:9: note: initialize the variable 'ret' to silence this warning 1669 | int ret, irq; | ^ | = 0 1 error generated. Signed-off-by: WangYuli --- drivers/i3c/master/i3c-master-phytium.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master/i3c-master-phytium.c b/drivers/i3c/master/i3c-master-phytium.c index 50f3f6c989951..f6b92a21c43b5 100644 --- a/drivers/i3c/master/i3c-master-phytium.c +++ b/drivers/i3c/master/i3c-master-phytium.c @@ -1666,7 +1666,8 @@ static int phytium_i3c_master_probe(struct platform_device *pdev) { struct phytium_i3c_master *master; struct resource *res; - int ret, irq; + int ret = -EINVAL; + int irq; u32 val; master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL); From 036701f58aa81d3513c764134811e39d64632706 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Thu, 28 Nov 2024 11:00:54 +0800 Subject: [PATCH 4/6] usb: phytium: Fix wrong assign logic in hostErrorIrq We'll apply a bitwise AND to the controller's rxerrirq and rxerrien to isolate interrupts that are both triggered and enabled. This filtering ensures that we only process relevant interrupts. Self bitwise AND operations are meaningless. Fix follow error with clang-19: drivers/usb/phytium/host.c:451:11: error: explicitly assigning value of variable of type 'uint16_t' (aka 'unsigned short') to itself [-Werror,-Wself-assign] 451 | rxerrirq &= rxerrirq; | ~~~~~~~~ ^ ~~~~~~~~ 1 error generated. Signed-off-by: WangYuli --- drivers/usb/phytium/host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phytium/host.c b/drivers/usb/phytium/host.c index 35a104d0c5739..8a327b09f15ae 100644 --- a/drivers/usb/phytium/host.c +++ b/drivers/usb/phytium/host.c @@ -448,7 +448,7 @@ static void hostErrorIrq(struct HOST_CTRL *priv) rxerrirq = phytium_read16(&priv->regs->rxerrirq); rxerrien = phytium_read16(&priv->regs->rxerrien); - rxerrirq &= rxerrirq; + rxerrirq &= rxerrien; if (!txerrirq && !rxerrirq) return; From 1f92db539e63f0aeb0540af1f5d635da6fe0ec08 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Thu, 28 Nov 2024 11:12:00 +0800 Subject: [PATCH 5/6] eth: phytmac: phytmac_ioctl: Return -EOPNOTSUPP by default Fix follow error with clang-19: drivers/net/ethernet/phytium/phytmac_main.c:1818:2: error: variable 'ret' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] 1818 | default: | ^~~~~~~ drivers/net/ethernet/phytium/phytmac_main.c:1822:9: note: uninitialized use occurs here 1822 | return ret; | ^~~ drivers/net/ethernet/phytium/phytmac_main.c:1799:9: note: initialize the variable 'ret' to silence this warning 1799 | int ret; | ^ | = 0 1 error generated. Signed-off-by: WangYuli --- drivers/net/ethernet/phytium/phytmac_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/phytium/phytmac_main.c b/drivers/net/ethernet/phytium/phytmac_main.c index c172103a97362..39958c1f23acf 100644 --- a/drivers/net/ethernet/phytium/phytmac_main.c +++ b/drivers/net/ethernet/phytium/phytmac_main.c @@ -1816,6 +1816,7 @@ static int phytmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) break; #endif default: + ret = -EOPNOTSUPP; break; } From bf65ad1adf33ae8bfff696fa609ef5c48bb9e443 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Thu, 28 Nov 2024 11:28:51 +0800 Subject: [PATCH 6/6] eth: phytmac: phytmac_plat_probe: initialize variable 'ret' when !pdata->msg_regs Fix follow error with clang-19: drivers/net/ethernet/phytium/phytmac_platform.c:130:8: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] 130 | if (!pdata->msg_regs) { | ^~~~~~~~~~~~~~~~ drivers/net/ethernet/phytium/phytmac_platform.c:202:9: note: uninitialized use occurs here 202 | return ret; | ^~~ drivers/net/ethernet/phytium/phytmac_platform.c:130:4: note: remove the 'if' if its condition is always false 130 | if (!pdata->msg_regs) { | ^~~~~~~~~~~~~~~~~~~~~~~ 131 | dev_err(&pdev->dev, "msg_regs ioremap failed, i=%d\n", i); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 132 | goto err_mem; | ~~~~~~~~~~~~~ 133 | } | ~ drivers/net/ethernet/phytium/phytmac_platform.c:81:9: note: initialize the variable 'ret' to silence this warning 81 | int ret, i; | ^ | = 0 1 error generated. Signed-off-by: WangYuli --- drivers/net/ethernet/phytium/phytmac_platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/phytium/phytmac_platform.c b/drivers/net/ethernet/phytium/phytmac_platform.c index 305ff5866e2fe..d98128458b464 100644 --- a/drivers/net/ethernet/phytium/phytmac_platform.c +++ b/drivers/net/ethernet/phytium/phytmac_platform.c @@ -129,6 +129,7 @@ static int phytmac_plat_probe(struct platform_device *pdev) pdata->msg_regs = ioremap_wt(regs->start, MEMORY_SIZE); if (!pdata->msg_regs) { dev_err(&pdev->dev, "msg_regs ioremap failed, i=%d\n", i); + ret = PTR_ERR(pdata->mac_regs); goto err_mem; } }