extract duplicated constants out of PIIX like drivers
PATCH 1/1 extract duplicated constants out of PIIX like drivers
Each PIIX driver has two copies of a tiny 10 byte table. Jeff asked that it was moved to a common place in each driver. Personally I think it looked a lot better before but as Jeff is maintainer it's his call.
drivers/ata/ata_piix.c +21 -25
@@ -440,6 +440,21 @@ [ich8_sata_ahci] = &ich8_map_db, }; +/* +* See Intel Document 298600-004 for the timing programing rules +* for ICH controllers. +*/ + +static const u8 intel_timings[][2 ] = { +/* ISP RTC */ + {0 ,0 }, + {0 ,0 }, + {1 ,0 }, + {2 ,1 }, + {2 ,3 } +}; + +static struct ata_port_info piix_port_info[] = {/* piix_pata_33: 0: PIIX3 or 4 at 33MHz */ {
@@ -702,18 +717,6 @@u8 udma_enable;int control =0 ; -/* -* See Intel Document 298600-004 for the timing programing rules -* for ICH controllers. -*/ - -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; -if (pio >=2 ) control |=1 ;/* TIME1 enable */ if (ata_pio_need_iordy (adev))
@@ -732,15 +735,15 @@pci_read_config_byte (dev, slave_port, &slave_data); slave_data &= (ap->port_no ?0x0f :0xf0 );/* Load the timing nibble for this slave */ - slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << (ap->port_no ?4 :0 ); + slave_data |= ((intel_timings[pio][0 ] <<2 ) | intel_timings[pio][1 ]) << (ap->port_no ?4 :0 ); }else {/* Master keeps the bits in a different format */ master_data &=0xccf8 ;/* Enable PPE, IE and TIME as appropriate */ master_data |= control; master_data |= - (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); + (intel_timings[pio][0 ] <<12 ) | + (intel_timings[pio][1 ] <<8 ); }pci_write_config_word (dev, master_port, master_data);if (is_slave)
@@ -778,13 +781,6 @@int devid = adev->devno +2 * ap->port_no;u8 udma_enable; -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; -pci_read_config_word (dev, master_port, &master_data);pci_read_config_byte (dev,0x48 , &udma_enable);
@@ -855,15 +851,15 @@pci_read_config_byte (dev,0x44 , &slave_data); slave_data &= (0x0F +0xE1 * ap->port_no);/* Load the matching timing */ - slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << (ap->port_no ?4 :0 ); + slave_data |= ((intel_timings[pio][0 ] <<2 ) | intel_timings[pio][1 ]) << (ap->port_no ?4 :0 );pci_write_config_byte (dev,0x44 , slave_data); }else {/* Master */ master_data &=0xCCF4 ;/* Mask out IORDY|TIME1|DMAONLY and master timing bits */ master_data |= control; master_data |= - (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); + (intel_timings[pio][0 ] <<12 ) | + (intel_timings[pio][1 ] <<8 ); } udma_enable &= ~(1 << devid);pci_write_config_word (dev, master_port, master_data);
drivers/ata/pata_efar.c +16 -20
@@ -24,6 +24,16 @@#define DRV_NAME "pata_efar"#define DRV_VERSION "0.4.3" +static const u8 efar_timings[][2 ] = { +/* ISP RTC */ + {0 ,0 }, + {0 ,0 }, + {1 ,0 }, + {2 ,1 }, + {2 ,3 }, +}; + +/** * efar_pre_reset - check for 40/80 pin * @ap: Port
@@ -90,13 +100,6 @@* for PIIX/ICH. The EFAR is a clone so very similar */ -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; -if (pio >2 ) control |=1 ;/* TIME1 enable */ if (ata_pio_need_iordy (adev))/* PIO 3/4 require IORDY */
@@ -112,8 +115,8 @@if (adev->devno ==0 ) { idetm_data &=0xCCF0 ; idetm_data |= control; - idetm_data |= (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); + idetm_data |= (efar_timings[pio][0 ] <<12 ) | + (efar_timings[pio][1 ] <<8 ); }else {int shift =4 * ap->port_no;u8 slave_data;
@@ -124,7 +127,7 @@/* Slave timing in seperate register */ pci_read_config_byte (dev,0x44 , &slave_data); slave_data &=0x0F << shift; - slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << shift; + slave_data |= ((efar_timings[pio][0 ] <<2 ) | efar_timings[pio][1 ]) << shift;pci_write_config_byte (dev,0x44 , slave_data); }
@@ -152,13 +155,6 @@int devid = adev->devno +2 * ap->port_no;u8 udma_enable; -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; -pci_read_config_word (dev, master_port, &master_data);pci_read_config_byte (dev,0x48 , &udma_enable);
@@ -202,15 +198,15 @@pci_read_config_byte (dev,0x44 , &slave_data); slave_data &= (0x0F +0xE1 * ap->port_no);/* Load the matching timing */ - slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << (ap->port_no ?4 :0 ); + slave_data |= ((efar_timings[pio][0 ] <<2 ) | efar_timings[pio][1 ]) << (ap->port_no ?4 :0 );pci_write_config_byte (dev,0x44 , slave_data); }else {/* Master */ master_data &=0xCCF4 ;/* Mask out IORDY|TIME1|DMAONLY and master timing bits */ master_data |= control; master_data |= - (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); + (efar_timings[pio][0 ] <<12 ) | + (efar_timings[pio][1 ] <<8 ); } udma_enable &= ~(1 << devid);pci_write_config_word (dev, master_port, master_data);
drivers/ata/pata_it8213.c +23 -20
91 lines not on this page · raw message
Quoted 5 lines · Alan
Each PIIX driver has two copies of a tiny 10 byte table. Jeff asked that it was moved to a common place in each driver. Personally I think it looked a lot better before but as Jeff is maintainer it's his call.
Signed-off-by Alan Cox <[email protected]>
Did I really ask for this? ;-)
Looking at the patch, I think prefer the unpatched code, and would prefer to drop this patch if that's ok?
Jeff
Quoted 8 lines · On Mon, 08 Jan 2007 11:16:52 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 5 lines · Alan
Each PIIX driver has two copies of a tiny 10 byte table. Jeff asked that it was moved to a common place in each driver. Personally I think it looked a lot better before but as Jeff is maintainer it's his call.
Signed-off-by Alan Cox <[email protected]>Did I really ask for this? ;-)
You did and I can prove it as I have the email ;)
Quoted 2 lines
Looking at the patch, I think prefer the unpatched code, and would prefer to drop this patch if that's ok?
Definitely fine by me. Will flush from my tree
Alan