* [PATCH] power: supply: twl4030-charger: remove unused cur_reg variable
@ 2023-04-01 11:34 Tom Rix
2023-04-01 20:30 ` Sebastian Reichel
0 siblings, 1 reply; 3+ messages in thread
From: Tom Rix @ 2023-04-01 11:34 UTC (permalink / raw)
To: sre, nathan, ndesaulniers; +Cc: linux-pm, linux-kernel, llvm, Tom Rix
clang with W=1 reports
drivers/power/supply/twl4030_charger.c:242:16: error: variable
'cur_reg' set but not used [-Werror,-Wunused-but-set-variable]
unsigned reg, cur_reg;
^
This variable is not used so remove it.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/power/supply/twl4030_charger.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
index 7adfd69fe649..5fa5b2311330 100644
--- a/drivers/power/supply/twl4030_charger.c
+++ b/drivers/power/supply/twl4030_charger.c
@@ -239,7 +239,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
{
int status;
int cur;
- unsigned reg, cur_reg;
+ unsigned reg;
u8 bcictl1, oldreg, fullreg;
bool cgain = false;
u8 boot_bci;
@@ -357,11 +357,9 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
status = twl4030_bci_read(TWL4030_BCIIREF1, &oldreg);
if (status < 0)
return status;
- cur_reg = oldreg;
status = twl4030_bci_read(TWL4030_BCIIREF2, &oldreg);
if (status < 0)
return status;
- cur_reg |= oldreg << 8;
if (reg != oldreg) {
/* disable write protection for one write access for
* BCIIREF */
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: twl4030-charger: remove unused cur_reg variable
2023-04-01 11:34 [PATCH] power: supply: twl4030-charger: remove unused cur_reg variable Tom Rix
@ 2023-04-01 20:30 ` Sebastian Reichel
2023-04-01 21:39 ` Andreas Kemnade
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Reichel @ 2023-04-01 20:30 UTC (permalink / raw)
To: Tom Rix
Cc: nathan, ndesaulniers, linux-pm, linux-kernel, llvm,
Andreas Kemnade, H. Nikolaus Schaller
[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]
Hi,
On Sat, Apr 01, 2023 at 07:34:32AM -0400, Tom Rix wrote:
> clang with W=1 reports
> drivers/power/supply/twl4030_charger.c:242:16: error: variable
> 'cur_reg' set but not used [-Werror,-Wunused-but-set-variable]
> unsigned reg, cur_reg;
> ^
> This variable is not used so remove it.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/power/supply/twl4030_charger.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
> index 7adfd69fe649..5fa5b2311330 100644
> --- a/drivers/power/supply/twl4030_charger.c
> +++ b/drivers/power/supply/twl4030_charger.c
> @@ -239,7 +239,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
> {
> int status;
> int cur;
> - unsigned reg, cur_reg;
> + unsigned reg;
> u8 bcictl1, oldreg, fullreg;
> bool cgain = false;
> u8 boot_bci;
> @@ -357,11 +357,9 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
> status = twl4030_bci_read(TWL4030_BCIIREF1, &oldreg);
> if (status < 0)
> return status;
> - cur_reg = oldreg;
> status = twl4030_bci_read(TWL4030_BCIIREF2, &oldreg);
> if (status < 0)
> return status;
> - cur_reg |= oldreg << 8;
> if (reg != oldreg) {
I think the correct fix would be checking for (reg != cur_reg) here.
-- Sebastian
> /* disable write protection for one write access for
> * BCIIREF */
> --
> 2.27.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: twl4030-charger: remove unused cur_reg variable
2023-04-01 20:30 ` Sebastian Reichel
@ 2023-04-01 21:39 ` Andreas Kemnade
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Kemnade @ 2023-04-01 21:39 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Tom Rix, nathan, ndesaulniers, linux-pm, linux-kernel, llvm,
H. Nikolaus Schaller
On Sat, 1 Apr 2023 22:30:26 +0200
Sebastian Reichel <sebastian.reichel@collabora.com> wrote:
> Hi,
>
> On Sat, Apr 01, 2023 at 07:34:32AM -0400, Tom Rix wrote:
> > clang with W=1 reports
> > drivers/power/supply/twl4030_charger.c:242:16: error: variable
> > 'cur_reg' set but not used [-Werror,-Wunused-but-set-variable]
> > unsigned reg, cur_reg;
> > ^
> > This variable is not used so remove it.
> >
> > Signed-off-by: Tom Rix <trix@redhat.com>
> > ---
> > drivers/power/supply/twl4030_charger.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
> > index 7adfd69fe649..5fa5b2311330 100644
> > --- a/drivers/power/supply/twl4030_charger.c
> > +++ b/drivers/power/supply/twl4030_charger.c
> > @@ -239,7 +239,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
> > {
> > int status;
> > int cur;
> > - unsigned reg, cur_reg;
> > + unsigned reg;
> > u8 bcictl1, oldreg, fullreg;
> > bool cgain = false;
> > u8 boot_bci;
> > @@ -357,11 +357,9 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
> > status = twl4030_bci_read(TWL4030_BCIIREF1, &oldreg);
> > if (status < 0)
> > return status;
> > - cur_reg = oldreg;
> > status = twl4030_bci_read(TWL4030_BCIIREF2, &oldreg);
> > if (status < 0)
> > return status;
> > - cur_reg |= oldreg << 8;
> > if (reg != oldreg) {
>
> I think the correct fix would be checking for (reg != cur_reg) here.
>
yes, makes more sense.
Regards,
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-01 21:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-01 11:34 [PATCH] power: supply: twl4030-charger: remove unused cur_reg variable Tom Rix
2023-04-01 20:30 ` Sebastian Reichel
2023-04-01 21:39 ` Andreas Kemnade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).