misc: cardreader: fix overwritten return value in RTS5260 driver
PATCH v2 1/1 misc: cardreader: fix overwritten return value in RTS5260 driver
From: Tian Liu <[email protected]>
In both rts5260.c and rtsx_pcr.c, a return value is assigned and then overwritten by a subsequent call, which causes the original result to be lost. This may result in silently ignoring errors from the first write.
This patch uses err |= to preserve earlier failure status.
This is an untested cleanup inspired by commit c55c7a85e02a ("um: ubd: Preserve earlier error value in ubd_user") which fixed similar error-handling logic. While this change has not been functionally tested on hardware, it is a mechanical fix and aligns with expected error-handling style.
Changes in v2:
- Use full name in Signed-off-by and From
- Add Fixes: tag
- Clarify that patch is untested, but reasoned from upstream style
- Cc: appropriate public mailing list
--- drivers/misc/cardreader/rts5260.c | 2 +- drivers/misc/cardreader/rtsx_pcr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/cardreader/rts5260.c +1 -1
@@ -269,7 +269,7 @@ static int rts5260_card_power_off(struct rtsx_pcr *pcr, int card)rts5260_card_before_power_off (pcr); err =rtsx_pci_write_register (pcr,LDO_VCC_CFG1 ,LDO_POW_SDVDD1_MASK ,LDO_POW_SDVDD1_OFF ); - err =rtsx_pci_write_register (pcr,LDO_CONFIG2 , + err |=rtsx_pci_write_register (pcr,LDO_CONFIG2 ,DV331812_POWERON ,DV331812_POWEROFF );if (pcr->option.ocp_en)rtsx_pci_disable_ocp (pcr);
drivers/misc/cardreader/rtsx_pcr.c +1 -1
@@ -1196,7 +1196,7 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)/* Gating real mcu clock */ err =rtsx_pci_write_register (pcr,RTS5261_FW_CFG1 ,RTS5261_MCU_CLOCK_GATING ,0 ); - err =rtsx_pci_write_register (pcr,RTS5261_REG_FPDCTL , + err |=rtsx_pci_write_register (pcr,RTS5261_REG_FPDCTL ,SSC_POWER_DOWN ,0 ); }else { err =rtsx_pci_write_register (pcr,FPDCTL ,SSC_POWER_DOWN ,0 );
Signature · 1 line
2.39.5 (Apple Git-154)
Greg KH
maintainerQuoted 15 lines · Tian
From: Tian Liu <[email protected]>
In both
rts5260.candrtsx_pcr.c, a return value is assigned and then overwritten by a subsequent call, which causes the original result to be lost. This may result in silently ignoring errors from the first write.This patch uses
err |=to preserve earlier failure status.This is an untested cleanup inspired by commit
c55c7a85e02a("um: ubd: Preserve earlier error value inubd_user") which fixed similar error-handling logic. While this change has not been functionally tested on hardware, it is a mechanical fix and aligns with expected error-handling style.Fixes bede03a579b3 ("misc: rtsx: Enable OCP for rts522a rts524a rts525a rts5260")Fixes c0e5f4e73a71 ("misc: rtsx: Add support for RTS5261")Signed-off-by Tian Liu <[email protected]>
Quoted 7 lines
Changes in v2:
- Use full name in Signed-off-by and From
- Add Fixes: tag
- Clarify that patch is untested, but reasoned from upstream style
- Cc: appropriate public mailing list---
The "changes..." stuff goes below the --- line.
Also, please wrap your changelog text at 72 columns.
As you have not tested this, I don't think this should be taken, do you?
Quoted 9 lines
drivers/misc/cardreader/rts5260.c | 2 +- drivers/misc/cardreader/rtsx_pcr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/misc/cardreader/rts5260.c +0
-0
drivers/misc/cardreader/rts5260.c static int rts5260_card_power_off(struct rtsx_pcr *pcr, int card) · line 273
Quoted 6 lines
drivers/misc/cardreader/rts5260.c +1
-1@@ -269,7 +269,7 @@ static int rts5260_card_power_off(struct rtsx_pcr *pcr, int card)rts5260_card_before_power_off (pcr); err =rtsx_pci_write_register (pcr,LDO_VCC_CFG1 ,LDO_POW_SDVDD1_MASK ,LDO_POW_SDVDD1_OFF ); - err =rtsx_pci_write_register (pcr,LDO_CONFIG2 , + err |=rtsx_pci_write_register (pcr,LDO_CONFIG2 ,DV331812_POWERON ,DV331812_POWEROFF );
How can this write fail? And just | all errors together really doesn't do all that much, right?
drivers/misc/cardreader/rtsx_pcr.c static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) · line 1200
Quoted 13 lines
drivers/misc/cardreader/rts5260.c +0
-0if (pcr->option.ocp_en)rtsx_pci_disable_ocp (pcr);drivers/misc/cardreader/rtsx_pcr.c +1
-1@@ -1196,7 +1196,7 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)/* Gating real mcu clock */ err =rtsx_pci_write_register (pcr,RTS5261_FW_CFG1 ,RTS5261_MCU_CLOCK_GATING ,0 ); - err =rtsx_pci_write_register (pcr,RTS5261_REG_FPDCTL , + err |=rtsx_pci_write_register (pcr,RTS5261_REG_FPDCTL ,SSC_POWER_DOWN ,0 );
Same here, it feels odd to do that.
thanks,
greg k-h