Skip to contentSkip to conversation

ata: pata_legacy: fix pdc20230_set_piomode()

PATCH Applied Sergey Shtylyov 2 participants 3 messages Oct 28, 2022 – Nov 2, 2022 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: pata_legacy: fix pdc20230_set_piomode()

Clang gives a warning when compiling pata_legacy.c with 'make W=1' about the 'rt' local variable in pdc20230_set_piomode() being set but unused. Quite obviously, there is an outb() call missing to write back the updated variable. Moreover, checking the docs by Petr Soucek revealed that bitwise AND should have been done with a negated timing mask and the master/slave timing masks were swapped while updating...

Fixes 669a5db411d8 ("[libata] Add a bunch of PATA drivers.")
---
 drivers/ata/pata_legacy.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/pata_legacy.c +3 -2
Index: libata/drivers/ata/pata_legacy.c
===================================================================
@@ -315,9 +315,10 @@ static void pdc20230_set_piomode(struct
 	outb(inb(0x1F4) & 0x07, 0x1F4);
 
 	rt = inb(0x1F3);
-	rt &= 0x07 << (3 * adev->devno);
+	rt &= ~(0x07 << (3 * !adev->devno));
 	if (pio)
-		rt |= (1 + 3 * pio) << (3 * adev->devno);
+		rt |= (1 + 3 * pio) << (3 * !adev->devno);
+	outb(rt, 0x1F3);
 
 	udelay(100);
 	outb(inb(0x1F2) | 0x01, 0x1F2);
#1 lore raw

Hello!

Quoted 7 lines · Sergey Shtylyov

Clang gives a warning when compiling pata_legacy.c with 'make W=1' about the 'rt' local variable in pdc20230_set_piomode() being set but unused. Quite obviously, there is an outb() call missing to write back the updated variable. Moreover, checking the docs by Petr Soucek revealed that bitwise AND should have been done with a negated timing mask and the master/slave timing masks were swapped while updating...

Quoted 5 lines
Fixes 669a5db411d8 ("[libata] Add a bunch of PATA drivers.")

---

Forgot to mention that the patch was done against the 'master' branch
of libata.git...

[...]

MBR, Sergey

#2 lore raw
In reply to Sergey Shtylyov
Quoted 10 lines · Sergey Shtylyov

Clang gives a warning when compiling pata_legacy.c with 'make W=1' about the 'rt' local variable in pdc20230_set_piomode() being set but unused. Quite obviously, there is an outb() call missing to write back the updated variable. Moreover, checking the docs by Petr Soucek revealed that bitwise AND should have been done with a negated timing mask and the master/slave timing masks were swapped while updating...

Fixes 669a5db411d8 ("[libata] Add a bunch of PATA drivers.")

Applied to for-6.1-fixes. Thanks !

Quoted 22 lines
---
 drivers/ata/pata_legacy.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: libata/drivers/ata/pata_legacy.c
===================================================================

drivers/ata/pata_legacy.c +3 -2
@@ -315,9 +315,10 @@ static void pdc20230_set_piomode(struct
 	outb(inb(0x1F4) & 0x07, 0x1F4);
 
 	rt = inb(0x1F3);
-	rt &= 0x07 << (3 * adev->devno);
+	rt &= ~(0x07 << (3 * !adev->devno));
 	if (pio)
-		rt |= (1 + 3 * pio) << (3 * adev->devno);
+		rt |= (1 + 3 * pio) << (3 * !adev->devno);
+	outb(rt, 0x1F3);
 
 	udelay(100);
 	outb(inb(0x1F2) | 0x01, 0x1F2);
Signature · 2 lines
Damien Le Moal
Western Digital Research