ata: remove FIT() macro
PATCH 3/10 ata: remove FIT() macro
Use the kernel-provided clamp_val() macro.
FIT was always applied to a member of struct ata_timing (unsigned short) and two constants. clamp_val will not cast to short anymore.
Signed-off-by Harvey Harrison <[email protected]>
--- drivers/ata/pata_ali.c | 10 ++++---- drivers/ata/pata_amd.c | 14 ++++++------ drivers/ata/pata_cypress.c | 8 +++--- drivers/ata/pata_legacy.c | 50 ++++++++++++++++++++++---------------------- drivers/ata/pata_ns87410.c | 6 ++-- drivers/ata/pata_ns87415.c | 4 +- drivers/ata/pata_qdi.c | 16 +++++++------- drivers/ata/pata_via.c | 14 ++++++------ drivers/ata/pata_winbond.c | 6 ++-- include/linux/libata.h | 2 - 10 files changed, 64 insertions(+), 66 deletions(-)
drivers/ata/pata_ali.c +5 -5
@@ -173,11 +173,11 @@ static void ali_program_modes(struct ata_port *ap, struct ata_device *adev, struu8 udma;if (t !=NULL ) { - t->setup =FIT (t->setup,1 ,8 ) &7 ; - t->act8b =FIT (t->act8b,1 ,8 ) &7 ; - t->rec8b =FIT (t->rec8b,1 ,16 ) &15 ; - t->active =FIT (t->active,1 ,8 ) &7 ; - t->recover =FIT (t->recover,1 ,16 ) &15 ; + t->setup =clamp_val (t->setup,1 ,8 ) &7 ; + t->act8b =clamp_val (t->act8b,1 ,8 ) &7 ; + t->rec8b =clamp_val (t->rec8b,1 ,16 ) &15 ; + t->active =clamp_val (t->active,1 ,8 ) &7 ; + t->recover =clamp_val (t->recover,1 ,16 ) &15 ;pci_write_config_byte (pdev, cas, t->setup);pci_write_config_byte (pdev, cbt, (t->act8b <<4 ) | t->rec8b);
drivers/ata/pata_amd.c +7 -7
@@ -82,32 +82,32 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse/* Configure the address set up timing */ pci_read_config_byte (pdev, offset +0x0C , &t); - t = (t & ~(3 << ((3 - dn) <<1 ))) | ((FIT (at.setup,1 ,4 ) -1 ) << ((3 - dn) <<1 )); + t = (t & ~(3 << ((3 - dn) <<1 ))) | ((clamp_val (at.setup,1 ,4 ) -1 ) << ((3 - dn) <<1 ));pci_write_config_byte (pdev, offset +0x0C , t);/* Configure the 8bit I/O timing */ pci_write_config_byte (pdev, offset +0x0E + (1 - (dn >>1 )), - ((FIT (at.act8b,1 ,16 ) -1 ) <<4 ) | (FIT (at.rec8b,1 ,16 ) -1 )); + ((clamp_val (at.act8b,1 ,16 ) -1 ) <<4 ) | (clamp_val (at.rec8b,1 ,16 ) -1 ));/* Drive timing */ pci_write_config_byte (pdev, offset +0x08 + (3 - dn), - ((FIT (at.active,1 ,16 ) -1 ) <<4 ) | (FIT (at.recover,1 ,16 ) -1 )); + ((clamp_val (at.active,1 ,16 ) -1 ) <<4 ) | (clamp_val (at.recover,1 ,16 ) -1 ));switch (clock) {case 1 : - t = at.udma ? (0xc0 | (FIT (at.udma,2 ,5 ) -2 )) :0x03 ; + t = at.udma ? (0xc0 | (clamp_val (at.udma,2 ,5 ) -2 )) :0x03 ;break ;case 2 : - t = at.udma ? (0xc0 | amd_cyc2udma[FIT (at.udma,2 ,10 )]) :0x03 ; + t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val (at.udma,2 ,10 )]) :0x03 ;break ;case 3 : - t = at.udma ? (0xc0 | amd_cyc2udma[FIT (at.udma,1 ,10 )]) :0x03 ; + t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val (at.udma,1 ,10 )]) :0x03 ;break ;case 4 : - t = at.udma ? (0xc0 | amd_cyc2udma[FIT (at.udma,1 ,15 )]) :0x03 ; + t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val (at.udma,1 ,15 )]) :0x03 ;break ;default :
drivers/ata/pata_cypress.c +4 -4
@@ -62,14 +62,14 @@ static void cy82c693_set_piomode(struct ata_port *ap, struct ata_device *adev)return ; } - time_16 =FIT (t.recover,0 ,15 ) | (FIT (t.active,0 ,15 ) <<4 ); - time_8 =FIT (t.act8b,0 ,15 ) | (FIT (t.rec8b,0 ,15 ) <<4 ); + time_16 =clamp_val (t.recover,0 ,15 ) | (clamp_val (t.active,0 ,15 ) <<4 ); + time_8 =clamp_val (t.act8b,0 ,15 ) | (clamp_val (t.rec8b,0 ,15 ) <<4 );if (adev->devno ==0 ) {pci_read_config_dword (pdev,CY82_IDE_ADDRSETUP , &addr); addr &= ~0x0F ;/* Mask bits */ - addr |=FIT (t.setup,0 ,15 ); + addr |=clamp_val (t.setup,0 ,15 );pci_write_config_dword (pdev,CY82_IDE_ADDRSETUP , addr);pci_write_config_byte (pdev,CY82_IDE_MASTER_IOR , time_16);
@@ -79,7 +79,7 @@ static void cy82c693_set_piomode(struct ata_port *ap, struct ata_device *adev)pci_read_config_dword (pdev,CY82_IDE_ADDRSETUP , &addr); addr &= ~0xF0 ;/* Mask bits */ - addr |= (FIT (t.setup,0 ,15 ) <<4 ); + addr |= (clamp_val (t.setup,0 ,15 ) <<4 );pci_write_config_dword (pdev,CY82_IDE_ADDRSETUP , addr);pci_write_config_byte (pdev,CY82_IDE_SLAVE_IOR , time_16);
drivers/ata/pata_legacy.c +25 -25
107 lines not on this page · raw message
drivers/ata/pata_ns87410.c +3 -3
@@ -105,9 +105,9 @@ static void ns87410_set_piomode(struct ata_port *ap, struct ata_device *adev)return ; } - at.active =FIT (at.active,2 ,16 ) -2 ; - at.setup =FIT (at.setup,1 ,4 ) -1 ; - at.recover =FIT (at.recover,1 ,12 ) -1 ; + at.active =clamp_val (at.active,2 ,16 ) -2 ; + at.setup =clamp_val (at.setup,1 ,4 ) -1 ; + at.recover =clamp_val (at.recover,1 ,12 ) -1 ; idetcr = (at.setup <<6 ) | (recoverbits[at.recover] <<3 ) | activebits[at.active];
drivers/ata/pata_ns87415.c +2 -2
@@ -66,8 +66,8 @@ static void ns87415_set_mode(struct ata_port *ap, struct ata_device *adev, u8 moata_timing_compute (adev, adev->pio_mode, &t,T ,0 ); - clocking =17 -FIT (t.active,2 ,17 ); - clocking |= (16 -FIT (t.recover,1 ,16 )) <<4 ; + clocking =17 -clamp_val (t.active,2 ,17 ); + clocking |= (16 -clamp_val (t.recover,1 ,16 )) <<4 ;/* Use the same timing for read and write bytes */ clocking |= (clocking <<8 );pci_write_config_word (dev, timing, clocking);
drivers/ata/pata_qdi.c +8 -8
@@ -60,11 +60,11 @@ static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)ata_timing_compute (adev, adev->pio_mode, &t,30303 ,1000 );if (qdi->fast) { - active =8 -FIT (t.active,1 ,8 ); - recovery =18 -FIT (t.recover,3 ,18 ); + active =8 -clamp_val (t.active,1 ,8 ); + recovery =18 -clamp_val (t.recover,3 ,18 ); }else { - active =9 -FIT (t.active,2 ,9 ); - recovery =15 -FIT (t.recover,0 ,15 ); + active =9 -clamp_val (t.active,2 ,9 ); + recovery =15 -clamp_val (t.recover,0 ,15 ); } timing = (recovery <<4 ) | active |0x08 ;
@@ -84,11 +84,11 @@ static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)ata_timing_compute (adev, adev->pio_mode, &t,30303 ,1000 );if (qdi->fast) { - active =8 -FIT (t.active,1 ,8 ); - recovery =18 -FIT (t.recover,3 ,18 ); + active =8 -clamp_val (t.active,1 ,8 ); + recovery =18 -clamp_val (t.recover,3 ,18 ); }else { - active =9 -FIT (t.active,2 ,9 ); - recovery =15 -FIT (t.recover,0 ,15 ); + active =9 -clamp_val (t.active,2 ,9 ); + recovery =15 -clamp_val (t.recover,0 ,15 ); } timing = (recovery <<4 ) | active |0x08 ;
drivers/ata/pata_via.c +7 -7
@@ -271,15 +271,15 @@ static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mopci_read_config_byte (pdev,0x4C , &setup); setup &= ~(3 << shift); - setup |=FIT (t.setup,1 ,4 ) << shift;/* 1,4 or 1,4 - 1 FIXME */ + setup |=clamp_val (t.setup,1 ,4 ) << shift;/* 1,4 or 1,4 - 1 FIXME */ pci_write_config_byte (pdev,0x4C , setup); }/* Load the PIO mode bits */ pci_write_config_byte (pdev,0x4F - ap->port_no, - ((FIT (t.act8b,1 ,16 ) -1 ) <<4 ) | (FIT (t.rec8b,1 ,16 ) -1 )); + ((clamp_val (t.act8b,1 ,16 ) -1 ) <<4 ) | (clamp_val (t.rec8b,1 ,16 ) -1 ));pci_write_config_byte (pdev,0x48 + offset, - ((FIT (t.active,1 ,16 ) -1 ) <<4 ) | (FIT (t.recover,1 ,16 ) -1 )); + ((clamp_val (t.active,1 ,16 ) -1 ) <<4 ) | (clamp_val (t.recover,1 ,16 ) -1 ));/* Load the UDMA bits according to type */ switch (udma_type) {
@@ -287,16 +287,16 @@ static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mo/* BUG() ? */ /* fall through */ case 33 : - ut = t.udma ? (0xe0 | (FIT (t.udma,2 ,5 ) -2 )) :0x03 ; + ut = t.udma ? (0xe0 | (clamp_val (t.udma,2 ,5 ) -2 )) :0x03 ;break ;case 66 : - ut = t.udma ? (0xe8 | (FIT (t.udma,2 ,9 ) -2 )) :0x0f ; + ut = t.udma ? (0xe8 | (clamp_val (t.udma,2 ,9 ) -2 )) :0x0f ;break ;case 100 : - ut = t.udma ? (0xe0 | (FIT (t.udma,2 ,9 ) -2 )) :0x07 ; + ut = t.udma ? (0xe0 | (clamp_val (t.udma,2 ,9 ) -2 )) :0x07 ;break ;case 133 : - ut = t.udma ? (0xe0 | (FIT (t.udma,2 ,9 ) -2 )) :0x07 ; + ut = t.udma ? (0xe0 | (clamp_val (t.udma,2 ,9 ) -2 )) :0x07 ;break ; }
drivers/ata/pata_winbond.c +3 -3
@@ -75,8 +75,8 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)else ata_timing_compute (adev, adev->pio_mode, &t,30303 ,1000 ); - active = (FIT (t.active,3 ,17 ) -1 ) &0x0F ; - recovery = (FIT (t.recover,1 ,15 ) +1 ) &0x0F ; + active = (clamp_val (t.active,3 ,17 ) -1 ) &0x0F ; + recovery = (clamp_val (t.recover,1 ,15 ) +1 ) &0x0F ; timing = (active <<4 ) | recovery;winbond_writecfg (winbond->config, timing, reg);
@@ -87,7 +87,7 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) reg |=0x08 ;/* FIFO off */ if (!ata_pio_need_iordy (adev)) reg |=0x02 ;/* IORDY off */ - reg |= (FIT (t.setup,0 ,3 ) <<6 ); + reg |= (clamp_val (t.setup,0 ,3 ) <<6 );winbond_writecfg (winbond->config, timing +1 , reg); }
include/linux/libata.h +0 -2
@@ -755,8 +755,6 @@ struct ata_timing {unsigned short udma;/* t2CYCTYP/2 */ }; -#define FIT (v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin) -extern const unsigned long sata_deb_timing_normal[];extern const unsigned long sata_deb_timing_hotplug[];extern const unsigned long sata_deb_timing_long[];
Signature · 1 line
1.5.4.4.653.g7cf1e