block: Fix some inconsistencies in block_{read, write} implementors
cover block: Fix some inconsistencies in block_{read, write} implementors
Hey all,
I ran into this problem while testing Pavel Herrmann's patch to move externs to <sata.h>. To fix these problems I've taken over the patch. Pavel's patch makes all of the sata drivers include <sata.h>, and this exposed a number of build problems due to type mis-match. Examining these mis-matches leads to this series. Both <ide.h> and <sata.h> set prototypes for block_dev_desc_t->block_{read,write} implementors that did not match the prototype. First we fix these implemenators (and in the case of ata_piix.[ch] fix a large number of checkpatch issues. Then we fix the prototypes in the headers.
--
Tom
Pavel Herrmann (1):
sata.h: Make all sata/ata drivers include <sata.h>
Tom Rini (8):
ata_piix: Fix checkpatch issues
ata_piix: sata_write must take a const void argument.
dwc_ahsata: Make sata_write() comply with <part.h>
fsl_sata: Make sata_{read,write}() comply with <part.h>
pata_bfin: Make sata_{read,write}() comply with <part.h>
sata_dwc: Make sata_write() use const void, per <part.h>
sil_sata: Make sata_write() comply with <part.h> ide.h: Make ide_(read|write) match block_dev_desc_t
block_(read|write)
drivers/block/ata_piix.c | 455 ++++++++++++++++++++---------------------- drivers/block/ata_piix.h | 46 ++--- drivers/block/dwc_ahsata.c | 9 +- drivers/block/dwc_ahsata.h | 2 - drivers/block/fsl_sata.c | 13 +- drivers/block/pata_bfin.c | 5 +- drivers/block/pata_bfin.h | 2 - drivers/block/sata_dwc.c | 5 +- drivers/block/sata_sil.c | 7 +- drivers/block/sata_sil.h | 2 - drivers/block/sata_sil3114.c | 2 +- include/ide.h | 4 +- include/sata.h | 7 +- 13 files changed, 260 insertions(+), 299 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/9 ata_piix: Fix checkpatch issues
While in here also:
- Switch to debug from custom PRINTF for debugging.
- Use mdelay rather than custom msleep.
--- drivers/block/ata_piix.c | 451 ++++++++++++++++++++++------------------------ drivers/block/ata_piix.h | 48 ++--- 2 files changed, 232 insertions(+), 267 deletions(-)
drivers/block/ata_piix.c +212 -239
@@ -38,13 +38,13 @@extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ];extern int sata_curr_device; -#define DEBUG_SATA 0/*For debug prints set DEBUG_SATA to 1 */ +#define DEBUG_SATA 0/* For debug prints set DEBUG_SATA to 1 */ #define SATA_DECL -#define DRV_DECL /*For file specific declarations */ +#define DRV_DECL /* For file specific declarations */ #include "ata_piix.h" -/*Macros realted to PCI*/ +/* Macros realted to PCI */ #define PCI_SATA_BUS 0x00#define PCI_SATA_DEV 0x1f#define PCI_SATA_FUNC 0x02
@@ -63,35 +63,36 @@ extern int sata_curr_device;#define PORT_ENABLED (1<<4)u32 bdf; -u32 iobase1 =0 ;/*Primary cmd block */ -u32 iobase2 =0 ;/*Primary ctl block */ -u32 iobase3 =0 ;/*Sec cmd block */ -u32 iobase4 =0 ;/*sec ctl block */ -u32 iobase5 =0 ;/*BMDMA*/ -int -pci_sata_init (void ) +u32 iobase1;/* Primary cmd block */ +u32 iobase2;/* Primary ctl block */ +u32 iobase3;/* Sec cmd block */ +u32 iobase4;/* sec ctl block */ +u32 iobase5;/* BMDMA*/ + +int pci_sata_init (void ) {u32 bus =PCI_SATA_BUS ;u32 dev =PCI_SATA_DEV ;u32 fun =PCI_SATA_FUNC ;u16 cmd =0 ;u8 lat =0 , pcibios_max_latency =0xff ; -u8 pmr;/*Port mapping reg */ -u8 pi;/*Prgming Interface reg */ +u8 pmr;/* Port mapping reg */ +u8 pi;/* Prgming Interface reg */ - bdf =PCI_BDF (bus, dev, fun); -pci_read_config_dword (bdf,PCI_SATA_BASE1 , &iobase1); -pci_read_config_dword (bdf,PCI_SATA_BASE2 , &iobase2); -pci_read_config_dword (bdf,PCI_SATA_BASE3 , &iobase3); -pci_read_config_dword (bdf,PCI_SATA_BASE4 , &iobase4); -pci_read_config_dword (bdf,PCI_SATA_BASE5 , &iobase5); + bdf =PCI_BDF (bus, dev, fun); +pci_read_config_dword (bdf,PCI_SATA_BASE1 , &iobase1); +pci_read_config_dword (bdf,PCI_SATA_BASE2 , &iobase2); +pci_read_config_dword (bdf,PCI_SATA_BASE3 , &iobase3); +pci_read_config_dword (bdf,PCI_SATA_BASE4 , &iobase4); +pci_read_config_dword (bdf,PCI_SATA_BASE5 , &iobase5);if ((iobase1 ==0xFFFFFFFF ) || (iobase2 ==0xFFFFFFFF ) || (iobase3 ==0xFFFFFFFF ) || (iobase4 ==0xFFFFFFFF ) || (iobase5 ==0xFFFFFFFF )) { -printf ("error no base addr for SATA controller\n" ); +/* ERROR */ +printf ("error no base addr for SATA controller\n" );return 1 ; -/*ERROR*/ } + } iobase1 &=0xFFFFFFFE ; iobase2 &=0xFFFFFFFE ;
@@ -99,44 +100,42 @@ pci_sata_init (void) iobase4 &=0xFFFFFFFE ; iobase5 &=0xFFFFFFFE ; -/*check for mode */ -pci_read_config_byte (bdf,PCI_PMR , &pmr); +/* check for mode */ +pci_read_config_byte (bdf,PCI_PMR , &pmr);if (pmr >1 ) { -printf ("combined mode not supported\n" ); +puts ("combined mode not supported\n" );return 1 ; } -pci_read_config_byte (bdf,PCI_PI , &pi); +pci_read_config_byte (bdf,PCI_PI , &pi);if ((pi &0x05 ) !=0x05 ) { -printf ("Sata is in Legacy mode\n" ); +puts ("Sata is in Legacy mode\n" );return 1 ; - }else { -printf ("sata is in Native mode\n" ); - } + }else +puts ("sata is in Native mode\n" ); -/*MASTER CFG AND IO CFG */ -pci_read_config_word (bdf,PCI_COMMAND , &cmd); +/* MASTER CFG AND IO CFG */ +pci_read_config_word (bdf,PCI_COMMAND , &cmd); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_IO ; -pci_write_config_word (bdf,PCI_COMMAND , cmd); -pci_read_config_byte (dev,PCI_LATENCY_TIMER , &lat); +pci_write_config_word (bdf,PCI_COMMAND , cmd); +pci_read_config_byte (dev,PCI_LATENCY_TIMER , &lat);if (lat <16 ) lat = (64 <= pcibios_max_latency) ?64 : pcibios_max_latency;else if (lat > pcibios_max_latency) lat = pcibios_max_latency; -pci_write_config_byte (dev,PCI_LATENCY_TIMER , lat); +pci_write_config_byte (dev,PCI_LATENCY_TIMER , lat);return 0 ; } -int -sata_bus_probe (int port_no) +int sata_bus_probe (int port_no) {int orig_mask, mask;u16 pcs; mask = (PORT_PRESENT << port_no); -pci_read_config_word (bdf,PCI_PCS , &pcs); +pci_read_config_word (bdf,PCI_PCS , &pcs); orig_mask = (int ) pcs &0xff ;if ((orig_mask & mask) != mask)return 0 ;
@@ -144,10 +143,9 @@ sata_bus_probe (int port_no)return 1 ; } -int -init_sata (int dev) +int init_sata (int dev) { -static int done =0 ; +static int done;u8 i, rv =0 ;if (!done)
@@ -155,9 +153,9 @@ init_sata (int dev)else return 0 ; - rv =pci_sata_init (); + rv =pci_sata_init ();if (rv ==1 ) { -printf ("pci initialization failed\n" ); +puts ("pci initialization failed\n" );return 1 ; }
@@ -174,19 +172,18 @@ init_sata (int dev) port[1 ].ioaddr.bmdma_addr = iobase5 +0x8 ;for (i =0 ; i <CONFIG_SYS_SATA_MAXBUS ; i++) -sata_port (&port[i].ioaddr); +sata_port (&port[i].ioaddr);for (i =0 ; i <CONFIG_SYS_SATA_MAXBUS ; i++) { -if (!(sata_bus_probe (i))) { +if (!(sata_bus_probe (i))) { port[i].port_state =0 ; -printf ("SATA#%d port is not present \n" , i); +printf ("SATA#%d port is not present\n" , i); }else { -printf ("SATA#%d port is present\n" , i); -if (sata_bus_softreset (i)) { +printf ("SATA#%d port is present\n" , i); +if (sata_bus_softreset (i)) port[i].port_state =0 ; - }else { +else port[i].port_state =1 ; - } } }
@@ -196,47 +193,43 @@ init_sata (int dev)if (port[i].port_state ==0 )continue ;for (j =0 ; j <CONFIG_SYS_SATA_DEVS_PER_BUS ; j++) { -sata_identify (i, j); -set_Feature_cmd (i, j); +sata_identify (i, j); +set_Feature_cmd (i, j); devno = i *CONFIG_SYS_SATA_DEVS_PER_BUS + j;if ((sata_dev_desc[devno].lba >0 ) && (sata_dev_desc[devno].blksz >0 )) { -dev_print (&sata_dev_desc[devno]); +dev_print (&sata_dev_desc[devno]);/* initialize partition type */ -init_part (&sata_dev_desc[devno]); +init_part (&sata_dev_desc[devno]); } } }return 0 ; } -static u8 __inline__ -sata_inb (unsigned long ioaddr) +static inline u8 sata_inb (unsigned long ioaddr) { -return inb (ioaddr); +return inb (ioaddr); } -static void __inline__ -sata_outb (unsigned char val,unsigned long ioaddr) +static inline void sata_outb (unsigned char val,unsigned long ioaddr) { -outb (val, ioaddr); +outb (val, ioaddr); } -static void -output_data (struct sata_ioports *ioaddr,ulong * sect_buf,int words) +static void output_data (struct sata_ioports *ioaddr,ulong * sect_buf, +int words) { -outsw (ioaddr->data_addr, sect_buf, words <<1 ); +outsw (ioaddr->data_addr, sect_buf, words <<1 ); } -static int -input_data (struct sata_ioports *ioaddr,ulong * sect_buf,int words) +static int input_data (struct sata_ioports *ioaddr,ulong * sect_buf,int words) { -insw (ioaddr->data_addr, sect_buf, words <<1 ); +insw (ioaddr->data_addr, sect_buf, words <<1 );return 0 ; } -static void -sata_cpy (unsigned char *dst,unsigned char *src,unsigned int len) +static void sata_cpy (unsigned char *dst,unsigned char *src,unsigned int len) {unsigned char *end, *last;
@@ -257,41 +250,41 @@ sata_cpy (unsigned char *dst, unsigned char *src, unsigned int len)if (*src++ !=' ' ) last = dst; } - OUT: +OUT: *last ='\0' ; } -int -sata_bus_softreset (int num) +int sata_bus_softreset (int num) {u8 dev =0 , status =0 , i; port[num].dev_mask =0 ;for (i =0 ; i <CONFIG_SYS_SATA_DEVS_PER_BUS ; i++) { -if (!(sata_devchk (&port[num].ioaddr, i))) { -PRINTF ("dev_chk failed for dev#%d\n" , i); +if (!(sata_devchk (&port[num].ioaddr, i))) { +debug ("dev_chk failed for dev#%d\n" , i); }else { port[num].dev_mask |= (1 << i); -PRINTF ("dev_chk passed for dev#%d\n" , i); +debug ("dev_chk passed for dev#%d\n" , i); } }if (!(port[num].dev_mask)) { -printf ("no devices on port%d\n" , num); +printf ("no devices on port%d\n" , num);return 1 ; } -dev_select (&port[num].ioaddr, dev); +dev_select (&port[num].ioaddr, dev); - port[num].ctl_reg =0x08 ;/*Default value of control reg */ -sata_outb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); -udelay (10 ); -sata_outb (port[num].ctl_reg |ATA_SRST , port[num].ioaddr.ctl_addr); -udelay (10 ); -sata_outb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); + port[num].ctl_reg =0x08 ;/* Default value of control reg */ +sata_outb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); +udelay (10 ); +sata_outb (port[num].ctl_reg |ATA_SRST , port[num].ioaddr.ctl_addr); +udelay (10 ); +sata_outb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); -/* spec mandates ">= 2ms" before checking status. +/* +* spec mandates ">= 2ms" before checking status. * We wait 150ms, because that was the magic delay used for * ATAPI devices in Hale Landis's ATADRVR, for the period of time * between when the ATA command register is written, and then
@@ -299,38 +292,37 @@ sata_bus_softreset (int num)* checking status is fine, post SRST, we perform this magic * delay here as well. */ -msleep (150 ); - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,300 ); +mdelay (150 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,300 );while ((status &ATA_BUSY )) { -msleep (100 ); - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,3 ); +mdelay (100 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,3 ); }if (status &ATA_BUSY ) -printf ("ata%u is slow to respond,plz be patient\n" , num); +printf ("ata%u is slow to respond,plz be patient\n" , num);while ((status &ATA_BUSY )) { -msleep (100 ); - status =sata_chk_status (&port[num].ioaddr); +mdelay (100 ); + status =sata_chk_status (&port[num].ioaddr); }if (status &ATA_BUSY ) { -printf ("ata%u failed to respond : " , num); -printf ("bus reset failed\n" ); +printf ("ata%u failed to respond : bus reset failed\n" , num);return 1 ; }return 0 ; } -void -sata_identify (int num,int dev) +void sata_identify (int num,int dev) { -u8 cmd =0 , status =0 , devno = num *CONFIG_SYS_SATA_DEVS_PER_BUS + dev; +u8 cmd =0 , status =0 ; +u8 devno = num *CONFIG_SYS_SATA_DEVS_PER_BUS + dev;u16 iobuf[ATA_SECT_SIZE ];u64 n_sectors =0 ;u8 mask =0 ; -memset (iobuf,0 ,sizeof (iobuf)); +memset (iobuf,0 ,sizeof (iobuf));hd_driveid_t *iop = (hd_driveid_t *) iobuf;if (dev ==0 )
@@ -339,70 +331,67 @@ sata_identify (int num, int dev) mask =0x02 ;if (!(port[num].dev_mask & mask)) { -printf ("dev%d is not present on port#%d\n" , dev, num); +printf ("dev%d is not present on port#%d\n" , dev, num);return ; } -printf ("port=%d dev=%d\n" , num, dev); +printf ("port=%d dev=%d\n" , num, dev); -dev_select (&port[num].ioaddr, dev); +dev_select (&port[num].ioaddr, dev); status =0 ; - cmd =ATA_CMD_IDENT ;/*Device Identify Command */ -sata_outb (cmd, port[num].ioaddr.command_addr); -sata_inb (port[num].ioaddr.altstatus_addr); -udelay (10 ); + cmd =ATA_CMD_IDENT ;/* Device Identify Command */ +sata_outb (cmd, port[num].ioaddr.command_addr); +sata_inb (port[num].ioaddr.altstatus_addr); +udelay (10 ); - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,1000 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,1000 );if (status &ATA_ERR ) { -printf ("\ndevice not responding\n" ); +puts ("\ndevice not responding\n" ); port[num].dev_mask &= ~mask;return ; } -input_data (&port[num].ioaddr, (ulong *) iobuf,ATA_SECTORWORDS ); +input_data (&port[num].ioaddr, (ulong *) iobuf,ATA_SECTORWORDS ); -PRINTF ("\nata%u: dev %u cfg 49:%04x 82:%04x 83:%04x 84:%04x85:%04x" +debug ("\nata%u: dev %u cfg 49:%04x 82:%04x 83:%04x 84:%04x85:%04x" "86:%04x" "87:%04x 88:%04x\n" , num, dev, iobuf[49 ], iobuf[82 ], iobuf[83 ], iobuf[84 ], iobuf[85 ], iobuf[86 ], iobuf[87 ], iobuf[88 ]);/* we require LBA and DMA support (bits 8 & 9 of word 49) */ -if (!ata_id_has_dma (iobuf) || !ata_id_has_lba (iobuf)) { -PRINTF ("ata%u: no dma/lba\n" , num); - } -ata_dump_id (iobuf); +if (!ata_id_has_dma (iobuf) || !ata_id_has_lba (iobuf)) +debug ("ata%u: no dma/lba\n" , num); +ata_dump_id (iobuf); -if (ata_id_has_lba48 (iobuf)) { - n_sectors =ata_id_u64 (iobuf,100 ); - }else { - n_sectors =ata_id_u32 (iobuf,60 ); - } -PRINTF ("no. of sectors %u\n" ,ata_id_u64 (iobuf,100 )); -PRINTF ("no. of sectors %u\n" ,ata_id_u32 (iobuf,60 )); +if (ata_id_has_lba48 (iobuf)) + n_sectors =ata_id_u64 (iobuf,100 ); +else + n_sectors =ata_id_u32 (iobuf,60 ); +debug ("no. of sectors %u\n" ,ata_id_u64 (iobuf,100 )); +debug ("no. of sectors %u\n" ,ata_id_u32 (iobuf,60 ));if (n_sectors ==0 ) { port[num].dev_mask &= ~mask;return ; } -sata_cpy ((unsigned char *)sata_dev_desc[devno].revision, iop->fw_rev, -sizeof (sata_dev_desc[devno].revision)); -sata_cpy ((unsigned char *)sata_dev_desc[devno].vendor, iop->model, -sizeof (sata_dev_desc[devno].vendor)); -sata_cpy ((unsigned char *)sata_dev_desc[devno].product, iop->serial_no, -sizeof (sata_dev_desc[devno].product)); -strswab (sata_dev_desc[devno].revision); -strswab (sata_dev_desc[devno].vendor); +sata_cpy ((unsigned char *)sata_dev_desc[devno].revision, iop->fw_rev, +sizeof (sata_dev_desc[devno].revision)); +sata_cpy ((unsigned char *)sata_dev_desc[devno].vendor, iop->model, +sizeof (sata_dev_desc[devno].vendor)); +sata_cpy ((unsigned char *)sata_dev_desc[devno].product, iop->serial_no, +sizeof (sata_dev_desc[devno].product)); +strswab (sata_dev_desc[devno].revision); +strswab (sata_dev_desc[devno].vendor); -if ((iop->config &0x0080 ) ==0x0080 ) { +if ((iop->config &0x0080 ) ==0x0080 ) sata_dev_desc[devno].removable =1 ; - }else { +else sata_dev_desc[devno].removable =0 ; - } sata_dev_desc[devno].lba = iop->lba_capacity; -PRINTF ("lba=0x%x" , sata_dev_desc[devno].lba); +debug ("lba=0x%x" , sata_dev_desc[devno].lba);#ifdef CONFIG_LBA48 if (iop->command_set_2 &0x0400 ) {
@@ -422,8 +411,7 @@ sata_identify (int num, int dev) sata_dev_desc[devno].lun =0 ;/* just to fill something in... */ } -void -set_Feature_cmd (int num,int dev) +void set_Feature_cmd (int num,int dev) {u8 mask =0x00 , status =0 ;
@@ -433,33 +421,32 @@ set_Feature_cmd (int num, int dev) mask =0x02 ;if (!(port[num].dev_mask & mask)) { -PRINTF ("dev%d is not present on port#%d\n" , dev, num); +debug ("dev%d is not present on port#%d\n" , dev, num);return ; } -dev_select (&port[num].ioaddr, dev); +dev_select (&port[num].ioaddr, dev); -sata_outb (SETFEATURES_XFER , port[num].ioaddr.feature_addr); -sata_outb (XFER_PIO_4 , port[num].ioaddr.nsect_addr); -sata_outb (0 , port[num].ioaddr.lbal_addr); -sata_outb (0 , port[num].ioaddr.lbam_addr); -sata_outb (0 , port[num].ioaddr.lbah_addr); +sata_outb (SETFEATURES_XFER , port[num].ioaddr.feature_addr); +sata_outb (XFER_PIO_4 , port[num].ioaddr.nsect_addr); +sata_outb (0 , port[num].ioaddr.lbal_addr); +sata_outb (0 , port[num].ioaddr.lbam_addr); +sata_outb (0 , port[num].ioaddr.lbah_addr); -sata_outb (ATA_DEVICE_OBS , port[num].ioaddr.device_addr); -sata_outb (ATA_CMD_SETF , port[num].ioaddr.command_addr); +sata_outb (ATA_DEVICE_OBS , port[num].ioaddr.device_addr); +sata_outb (ATA_CMD_SETF , port[num].ioaddr.command_addr); -udelay (50 ); -msleep (150 ); +udelay (50 ); +mdelay (150 ); - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,5000 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,5000 );if ((status & (ATA_STAT_BUSY |ATA_STAT_ERR ))) { -printf ("Error : status 0x%02x\n" , status); +printf ("Error : status 0x%02x\n" , status); port[num].dev_mask &= ~mask; } } -void -sata_port (struct sata_ioports *ioport) +void sata_port (struct sata_ioports *ioport) { ioport->data_addr = ioport->cmd_addr +ATA_REG_DATA ; ioport->error_addr = ioport->cmd_addr +ATA_REG_ERR ;
@@ -473,24 +460,23 @@ sata_port (struct sata_ioports *ioport) ioport->command_addr = ioport->cmd_addr +ATA_REG_CMD ; } -int -sata_devchk (struct sata_ioports *ioaddr,int dev) +int sata_devchk (struct sata_ioports *ioaddr,int dev) {u8 nsect, lbal; -dev_select (ioaddr, dev); +dev_select (ioaddr, dev); -sata_outb (0x55 , ioaddr->nsect_addr); -sata_outb (0xaa , ioaddr->lbal_addr); +sata_outb (0x55 , ioaddr->nsect_addr); +sata_outb (0xaa , ioaddr->lbal_addr); -sata_outb (0xaa , ioaddr->nsect_addr); -sata_outb (0x55 , ioaddr->lbal_addr); +sata_outb (0xaa , ioaddr->nsect_addr); +sata_outb (0x55 , ioaddr->lbal_addr); -sata_outb (0x55 , ioaddr->nsect_addr); -sata_outb (0xaa , ioaddr->lbal_addr); +sata_outb (0x55 , ioaddr->nsect_addr); +sata_outb (0xaa , ioaddr->lbal_addr); - nsect =sata_inb (ioaddr->nsect_addr); - lbal =sata_inb (ioaddr->lbal_addr); + nsect =sata_inb (ioaddr->nsect_addr); + lbal =sata_inb (ioaddr->lbal_addr);if ((nsect ==0x55 ) && (lbal ==0xaa ))return 1 ;/* we found a device */
@@ -498,8 +484,7 @@ sata_devchk (struct sata_ioports *ioaddr, int dev)return 0 ;/* nothing found */ } -void -dev_select (struct sata_ioports *ioaddr,int dev) +void dev_select (struct sata_ioports *ioaddr,int dev) {u8 tmp =0 ;
@@ -508,42 +493,31 @@ dev_select (struct sata_ioports *ioaddr, int dev)else tmp =ATA_DEVICE_OBS |ATA_DEV1 ; -sata_outb (tmp, ioaddr->device_addr); -sata_inb (ioaddr->altstatus_addr); -udelay (5 ); +sata_outb (tmp, ioaddr->device_addr); +sata_inb (ioaddr->altstatus_addr); +udelay (5 ); } -u8 -sata_busy_wait (struct sata_ioports *ioaddr,int bits,unsigned int max) +u8 sata_busy_wait (struct sata_ioports *ioaddr,int bits,unsigned int max) {u8 status;do { -udelay (1000 ); - status =sata_chk_status (ioaddr); +udelay (1000 ); + status =sata_chk_status (ioaddr); max--; }while ((status & bits) && (max >0 ));return status; } -u8 -sata_chk_status (struct sata_ioports * ioaddr) +u8 sata_chk_status (struct sata_ioports *ioaddr) { -return sata_inb (ioaddr->status_addr); +return sata_inb (ioaddr->status_addr); } -void -msleep (int count) -{ -int i; - -for (i =0 ; i < count; i++) -udelay (1000 ); -} -ulong -sata_read (int device,ulong blknr,lbaint_t blkcnt,void * buff) +ulong sata_read (int device,ulong blknr,lbaint_t blkcnt,void *buff) {ulong n =0 , *buffer = (ulong *)buff;u8 dev =0 , num =0 , mask =0 , status =0 ;
@@ -553,16 +527,16 @@ sata_read (int device, ulong blknr,lbaint_t blkcnt, void * buff)if (blknr &0x0000fffff0000000 ) {if (!sata_dev_desc[devno].lba48) { -printf ("Drive doesn't support 48-bit addressing\n" ); +printf ("Drive doesn't support 48-bit addressing\n" );return 0 ; }/* more than 28 bits used, use 48bit mode */ lba48 =1 ; }#endif -/*Port Number */ +/* Port Number */ num = device /CONFIG_SYS_SATA_DEVS_PER_BUS ; -/*dev on the port */ +/* dev on the port */ if (device >=CONFIG_SYS_SATA_DEVS_PER_BUS ) dev = device -CONFIG_SYS_SATA_DEVS_PER_BUS ;else
@@ -574,73 +548,73 @@ sata_read (int device, ulong blknr,lbaint_t blkcnt, void * buff) mask =0x02 ;if (!(port[num].dev_mask & mask)) { -printf ("dev%d is not present on port#%d\n" , dev, num); +printf ("dev%d is not present on port#%d\n" , dev, num);return 0 ; }/* Select device */ -dev_select (&port[num].ioaddr, dev); +dev_select (&port[num].ioaddr, dev); - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 );if (status &ATA_BUSY ) { -printf ("ata%u failed to respond\n" , port[num].port_no); +printf ("ata%u failed to respond\n" , port[num].port_no);return n; }while (blkcnt-- >0 ) { - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 );if (status &ATA_BUSY ) { -printf ("ata%u failed to respond\n" ,0 ); +printf ("ata%u failed to respond\n" ,0 );return n; }#ifdef CONFIG_LBA48 if (lba48) {/* write high bits */ -sata_outb (0 , port[num].ioaddr.nsect_addr); -sata_outb ((blknr >>24 ) &0xFF , +sata_outb (0 , port[num].ioaddr.nsect_addr); +sata_outb ((blknr >>24 ) &0xFF , port[num].ioaddr.lbal_addr); -sata_outb ((blknr >>32 ) &0xFF , +sata_outb ((blknr >>32 ) &0xFF , port[num].ioaddr.lbam_addr); -sata_outb ((blknr >>40 ) &0xFF , +sata_outb ((blknr >>40 ) &0xFF , port[num].ioaddr.lbah_addr); }#endif -sata_outb (1 , port[num].ioaddr.nsect_addr); -sata_outb (((blknr) >>0 ) &0xFF , +sata_outb (1 , port[num].ioaddr.nsect_addr); +sata_outb (((blknr) >>0 ) &0xFF , port[num].ioaddr.lbal_addr); -sata_outb ((blknr >>8 ) &0xFF , port[num].ioaddr.lbam_addr); -sata_outb ((blknr >>16 ) &0xFF , port[num].ioaddr.lbah_addr); +sata_outb ((blknr >>8 ) &0xFF , port[num].ioaddr.lbam_addr); +sata_outb ((blknr >>16 ) &0xFF , port[num].ioaddr.lbah_addr);#ifdef CONFIG_LBA48 if (lba48) { -sata_outb (ATA_LBA , port[num].ioaddr.device_addr); -sata_outb (ATA_CMD_READ_EXT , +sata_outb (ATA_LBA , port[num].ioaddr.device_addr); +sata_outb (ATA_CMD_READ_EXT , port[num].ioaddr.command_addr); } else#endif { -sata_outb (ATA_LBA | ((blknr >>24 ) &0xF ), +sata_outb (ATA_LBA | ((blknr >>24 ) &0xF ), port[num].ioaddr.device_addr); -sata_outb (ATA_CMD_READ , +sata_outb (ATA_CMD_READ , port[num].ioaddr.command_addr); } -msleep (50 ); -/*may take up to 4 sec */ - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,4000 ); +mdelay (50 ); +/* may take up to 4 sec */ + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,4000 );if ((status & (ATA_STAT_DRQ |ATA_STAT_BUSY |ATA_STAT_ERR )) !=ATA_STAT_DRQ ) {u8 err =0 ; -printf ("Error no DRQ dev %d blk %ld: sts 0x%02x\n" , +printf ("Error no DRQ dev %d blk %ld: sts 0x%02x\n" , device, (ulong ) blknr, status); - err =sata_inb (port[num].ioaddr.error_addr); -printf ("Error reg = 0x%x\n" , err); -return (n); + err =sata_inb (port[num].ioaddr.error_addr); +printf ("Error reg = 0x%x\n" , err); +return n; } -input_data (&port[num].ioaddr, buffer,ATA_SECTORWORDS ); -sata_inb (port[num].ioaddr.altstatus_addr); -udelay (50 ); +input_data (&port[num].ioaddr, buffer,ATA_SECTORWORDS ); +sata_inb (port[num].ioaddr.altstatus_addr); +udelay (50 ); ++n; ++blknr;
@@ -649,8 +623,7 @@ sata_read (int device, ulong blknr,lbaint_t blkcnt, void * buff)return n; } -ulong -sata_write (int device,ulong blknr,lbaint_t blkcnt,void * buff) +ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,void *buff) {ulong n =0 , *buffer = (ulong *)buff;unsigned char status =0 , num =0 , dev =0 , mask =0 ;
@@ -660,16 +633,16 @@ sata_write (int device, ulong blknr,lbaint_t blkcnt, void * buff)if (blknr &0x0000fffff0000000 ) {if (!sata_dev_desc[devno].lba48) { -printf ("Drive doesn't support 48-bit addressing\n" ); +printf ("Drive doesn't support 48-bit addressing\n" );return 0 ; }/* more than 28 bits used, use 48bit mode */ lba48 =1 ; }#endif -/*Port Number */ +/* Port Number */ num = device /CONFIG_SYS_SATA_DEVS_PER_BUS ; -/*dev on the Port */ +/* dev on the Port */ if (device >=CONFIG_SYS_SATA_DEVS_PER_BUS ) dev = device -CONFIG_SYS_SATA_DEVS_PER_BUS ;else
@@ -681,64 +654,64 @@ sata_write (int device, ulong blknr,lbaint_t blkcnt, void * buff) mask =0x02 ;/* Select device */ -dev_select (&port[num].ioaddr, dev); +dev_select (&port[num].ioaddr, dev); - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 );if (status &ATA_BUSY ) { -printf ("ata%u failed to respond\n" , port[num].port_no); +printf ("ata%u failed to respond\n" , port[num].port_no);return n; }while (blkcnt-- >0 ) { - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 ); + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,500 );if (status &ATA_BUSY ) { -printf ("ata%u failed to respond\n" , +printf ("ata%u failed to respond\n" , port[num].port_no);return n; }#ifdef CONFIG_LBA48 if (lba48) {/* write high bits */ -sata_outb (0 , port[num].ioaddr.nsect_addr); -sata_outb ((blknr >>24 ) &0xFF , +sata_outb (0 , port[num].ioaddr.nsect_addr); +sata_outb ((blknr >>24 ) &0xFF , port[num].ioaddr.lbal_addr); -sata_outb ((blknr >>32 ) &0xFF , +sata_outb ((blknr >>32 ) &0xFF , port[num].ioaddr.lbam_addr); -sata_outb ((blknr >>40 ) &0xFF , +sata_outb ((blknr >>40 ) &0xFF , port[num].ioaddr.lbah_addr); }#endif -sata_outb (1 , port[num].ioaddr.nsect_addr); -sata_outb ((blknr >>0 ) &0xFF , port[num].ioaddr.lbal_addr); -sata_outb ((blknr >>8 ) &0xFF , port[num].ioaddr.lbam_addr); -sata_outb ((blknr >>16 ) &0xFF , port[num].ioaddr.lbah_addr); +sata_outb (1 , port[num].ioaddr.nsect_addr); +sata_outb ((blknr >>0 ) &0xFF , port[num].ioaddr.lbal_addr); +sata_outb ((blknr >>8 ) &0xFF , port[num].ioaddr.lbam_addr); +sata_outb ((blknr >>16 ) &0xFF , port[num].ioaddr.lbah_addr);#ifdef CONFIG_LBA48 if (lba48) { -sata_outb (ATA_LBA , port[num].ioaddr.device_addr); -sata_outb (ATA_CMD_WRITE_EXT , +sata_outb (ATA_LBA , port[num].ioaddr.device_addr); +sata_outb (ATA_CMD_WRITE_EXT , port[num].ioaddr.command_addr); } else#endif { -sata_outb (ATA_LBA | ((blknr >>24 ) &0xF ), +sata_outb (ATA_LBA | ((blknr >>24 ) &0xF ), port[num].ioaddr.device_addr); -sata_outb (ATA_CMD_WRITE , +sata_outb (ATA_CMD_WRITE , port[num].ioaddr.command_addr); } -msleep (50 ); -/*may take up to 4 sec */ - status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,4000 ); +mdelay (50 ); +/* may take up to 4 sec */ + status =sata_busy_wait (&port[num].ioaddr,ATA_BUSY ,4000 );if ((status & (ATA_STAT_DRQ |ATA_STAT_BUSY |ATA_STAT_ERR )) !=ATA_STAT_DRQ ) { -printf ("Error no DRQ dev %d blk %ld: sts 0x%02x\n" , +printf ("Error no DRQ dev %d blk %ld: sts 0x%02x\n" , device, (ulong ) blknr, status); -return (n); +return n; } -output_data (&port[num].ioaddr, buffer,ATA_SECTORWORDS ); -sata_inb (port[num].ioaddr.altstatus_addr); -udelay (50 ); +output_data (&port[num].ioaddr, buffer,ATA_SECTORWORDS ); +sata_inb (port[num].ioaddr.altstatus_addr); +udelay (50 ); ++n; ++blknr;
drivers/block/ata_piix.h +20 -28
77 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 2/9 ata_piix: sata_write must take a const void argument.
In reply to Tom Rini--- drivers/block/ata_piix.c | 2 +- drivers/block/ata_piix.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/block/ata_piix.c +1 -1
@@ -623,7 +623,7 @@ ulong sata_read(int device, ulong blknr, lbaint_t blkcnt, void *buff)return n; } -ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,void *buff) +ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,const void *buff) {ulong n =0 , *buffer = (ulong *)buff;unsigned char status =0 , num =0 , dev =0 , mask =0 ;
drivers/block/ata_piix.h +1 -1
@@ -57,7 +57,7 @@ void dev_select(struct sata_ioports *ioaddr, int dev);u8 sata_busy_wait (struct sata_ioports *ioaddr,int bits,unsigned int max);u8 sata_chk_status (struct sata_ioports *ioaddr);ulong sata_read (int device,ulong blknr,lbaint_t blkcnt,void *buffer); -ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,void *buffer); +ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,const void *buffer);#endif /************DRIVER SPECIFIC DEFINITIONS AND DECLARATIONS**************/
Signature · 1 line
1.7.9.5
PATCH 3/9 dwc_ahsata: Make sata_write() comply with <part.h>
In reply to Tom Rinisata_write() takes a const void as the last argument. Fixing this means we also need to make ata_low_level_rw_lba{28,48} also take a const void.
--- drivers/block/dwc_ahsata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/dwc_ahsata.c +4 -4
@@ -794,7 +794,7 @@ static void dwc_ahsata_init_wcache(int dev, u16 *id) }u32 ata_low_level_rw_lba48 (int dev,u32 blknr,lbaint_t blkcnt, -void *buffer,int is_write) +const void *buffer,int is_write) {u32 start, blks;u8 *addr;
@@ -828,7 +828,7 @@ u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt, }u32 ata_low_level_rw_lba28 (int dev,u32 blknr,lbaint_t blkcnt, -void *buffer,int is_write) +const void *buffer,int is_write) {u32 start, blks;u8 *addr;
@@ -863,7 +863,7 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr, lbaint_t blkcnt,/* * SATA interface between low level driver and command layer */ -ulong sata_read (int dev,unsigned long blknr,lbaint_t blkcnt,void *buffer) +ulong sata_read (int dev,ulong blknr,lbaint_t blkcnt,void *buffer) {u32 rc;
@@ -876,7 +876,7 @@ ulong sata_read(int dev, unsigned long blknr, lbaint_t blkcnt, void *buffer)return rc; } -ulong sata_write (int dev,unsigned long blknr,lbaint_t blkcnt,void *buffer) +ulong sata_write (int dev,ulong blknr,lbaint_t blkcnt,const void *buffer) {u32 rc; struct ahci_probe_ent *probe_ent =
Signature · 1 line
1.7.9.5
PATCH 3/9 dwc_ahsata: Make sata_write() comply with <part.h>
Am 29/09/2012 22:51, schrieb Tom Rini:
Quoted 41 lines
sata_write()takes a const void as the last argument. Fixing this means we also need to make ata_low_level_rw_lba{28,48} also take a const void.Signed-off-by Tom Rini <[email protected]>--- drivers/block/dwc_ahsata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/block/dwc_ahsata.c +3
-3@@ -794,7 +794,7 @@ static void dwc_ahsata_init_wcache(int dev, u16 *id) }u32 ata_low_level_rw_lba48 (int dev,u32 blknr,lbaint_t blkcnt, -void *buffer,int is_write) +const void *buffer,int is_write) {u32 start, blks;u8 *addr;@@ -828,7 +828,7 @@ u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt, }u32 ata_low_level_rw_lba28 (int dev,u32 blknr,lbaint_t blkcnt, -void *buffer,int is_write) +const void *buffer,int is_write) {u32 start, blks;u8 *addr;@@ -863,7 +863,7 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr, lbaint_t blkcnt,/* * SATA interface between low level driver and command layer */ -ulong sata_read (int dev,unsigned long blknr,lbaint_t blkcnt,void *buffer) +ulong sata_read (int dev,ulong blknr,lbaint_t blkcnt,void *buffer) {u32 rc;
drivers/block/dwc_ahsata.c ulong sata_read(int dev, unsigned long blknr, lbaint_t blkcnt, void *buffer) · line 882
Quoted 8 lines
drivers/block/dwc_ahsata.c +1
-1@@ -876,7 +876,7 @@ ulong sata_read(int dev, unsigned long blknr, lbaint_t blkcnt, void *buffer)return rc; } -ulong sata_write (int dev,unsigned long blknr,lbaint_t blkcnt,void *buffer) +ulong sata_write (int dev,ulong blknr,lbaint_t blkcnt,const void *buffer) {u32 rc; struct ahci_probe_ent *probe_ent =
Regards,
Stefano
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 4/9 fsl_sata: Make sata_{read, write}() comply with <part.h>
In reply to Tom Rini- sata_write() takes a const void as the last argument. Fixing this means we also need to make ata_low_level_rw_lba{28,48} also take a const void.
- Both sata_{read,write} take lbaint_t for blkcnt and ulong for blknr
--- drivers/block/fsl_sata.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/block/fsl_sata.c +6 -4
@@ -758,7 +758,8 @@ static int fsl_sata_get_flush_ext(int dev)return sata->flush_ext; } -u32 ata_low_level_rw_lba48 (int dev,u32 blknr,u32 blkcnt,void *buffer,int is_write) +u32 ata_low_level_rw_lba48 (int dev,u32 blknr,lbaint_t blkcnt, +const void *buffer,int is_write) {u32 start, blks;u8 *addr;
@@ -792,7 +793,8 @@ u32 ata_low_level_rw_lba48(int dev, u32 blknr, u32 blkcnt, void *buffer, int is_return blkcnt; } -u32 ata_low_level_rw_lba28 (int dev,u32 blknr,u32 blkcnt,void *buffer,int is_write) +u32 ata_low_level_rw_lba28 (int dev,u32 blknr,u32 blkcnt,const void *buffer, +int is_write) {u32 start, blks;u8 *addr;
@@ -823,7 +825,7 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr, u32 blkcnt, void *buffer, int is_/* * SATA interface between low level driver and command layer */ -ulong sata_read (int dev,u32 blknr,u32 blkcnt,void *buffer) +ulong sata_read (int dev,ulong blknr,lbaint_t blkcnt,void *buffer) {u32 rc;fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
@@ -835,7 +837,7 @@ ulong sata_read(int dev, u32 blknr, u32 blkcnt, void *buffer)return rc; } -ulong sata_write (int dev,u32 blknr,u32 blkcnt,void *buffer) +ulong sata_write (int dev,ulong blknr,lbaint_t blkcnt,const void *buffer) {u32 rc;fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
Signature · 1 line
1.7.9.5
PATCH 5/9 pata_bfin: Make sata_{read, write}() comply with <part.h>
In reply to Tom RiniThese functions take lbaint_t for blkcnt.
--- drivers/block/pata_bfin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/pata_bfin.c +2 -2
@@ -1079,7 +1079,7 @@ static u8 do_one_read(struct ata_port *ap, u64 blknr, u8 blkcnt, u16 *buffer,return sr; } -ulong sata_read (int dev,ulong block,ulong blkcnt,void *buff) +ulong sata_read (int dev,ulong block,lbaint_t blkcnt,void *buff) {struct ata_port *ap = &port[dev];ulong n =0 , sread;
@@ -1121,7 +1121,7 @@ ulong sata_read(int dev, ulong block, ulong blkcnt, void *buff)return n; } -ulong sata_write (int dev,ulong block,ulong blkcnt,const void *buff) +ulong sata_write (int dev,ulong block,lbaint_t blkcnt,const void *buff) {struct ata_port *ap = &port[dev];void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
Signature · 1 line
1.7.9.5
PATCH 6/9 sata_dwc: Make sata_write() use const void, per <part.h>
In reply to Tom Rini--- drivers/block/sata_dwc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/sata_dwc.c +1 -1
@@ -1907,7 +1907,7 @@ err_out:#define SATA_MAX_WRITE_BLK 0xFFFF#endif -ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,void *buffer) +ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,const void *buffer) {ulong start,blks, buf_addr;unsigned short smallblks;
Signature · 1 line
1.7.9.5
PATCH 7/9 sil_sata: Make sata_write() comply with <part.h>
In reply to Tom Rinisata_write() takes a const void as the last argument. Fixing this means we also need to make ata_low_level_rw_lba{28,48} also take a const void.
--- drivers/block/sata_sil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/sata_sil.c +3 -3
@@ -369,7 +369,7 @@ static ulong sil_sata_rw_cmd_ext(int dev, ulong start, ulong blkcnt, }ulong sil_sata_rw_lba28 (int dev,ulong blknr,lbaint_t blkcnt, -void *buffer,int is_write) +const void *buffer,int is_write) {ulong start, blks, max_blks;u8 *addr;
@@ -397,7 +397,7 @@ ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt, }ulong sil_sata_rw_lba48 (int dev,ulong blknr,lbaint_t blkcnt, -void *buffer,int is_write) +const void *buffer,int is_write) {ulong start, blks, max_blks;u8 *addr;
@@ -502,7 +502,7 @@ ulong sata_read(int dev, ulong blknr, lbaint_t blkcnt, void *buffer)/* * SATA interface between low level driver and command layer */ -ulong sata_write (int dev,ulong blknr,lbaint_t blkcnt,void *buffer) +ulong sata_write (int dev,ulong blknr,lbaint_t blkcnt,const void *buffer) {struct sil_sata *sata = sata_dev_desc[dev].priv;ulong rc;
Signature · 1 line
1.7.9.5
PATCH 8/9 ide.h: Make ide_(read|write) match block_dev_desc_t block_(read|write)
In reply to Tom Riniblock_dev_desc_t says that block_(read|write) take lbaint_t for blkcnt not ulong
--- include/ide.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/ide.h +2 -2
@@ -51,8 +51,8 @@ typedef ulong lbaint_t;*/ void ide_init (void ); -ulong ide_read (int device,lbaint_t blknr,ulong blkcnt,void *buffer); -ulong ide_write (int device,lbaint_t blknr,ulong blkcnt,const void *buffer); +ulong ide_read (int device,ulong blknr,lbaint_t blkcnt,void *buffer); +ulong ide_write (int device,ulong blknr,lbaint_t blkcnt,const void *buffer);#if defined(CONFIG_OF_IDE_FIXUP )int ide_device_present (int dev);
Signature · 1 line
1.7.9.5
PATCH 9/9 sata.h: Make all sata/ata drivers include <sata.h>
In reply to Tom RiniFrom: Pavel Herrmann <[email protected]>
- block_dev_desc_t says that block_(read|write) take lbaint_t for blkcnt not ulong.
- We also move the extern of sata_dev_desc into <sata.h>
- Remove now duplicate declarations from driver-specific headers.
--- drivers/block/ata_piix.c | 4 +--- drivers/block/ata_piix.h | 2 -- drivers/block/dwc_ahsata.c | 1 + drivers/block/dwc_ahsata.h | 2 -- drivers/block/fsl_sata.c | 3 +-- drivers/block/pata_bfin.c | 1 + drivers/block/pata_bfin.h | 2 -- drivers/block/sata_dwc.c | 3 +-- drivers/block/sata_sil.c | 1 + drivers/block/sata_sil.h | 2 -- drivers/block/sata_sil3114.c | 2 +- include/sata.h | 7 +++++-- 12 files changed, 12 insertions(+), 18 deletions(-)
drivers/block/ata_piix.c +1 -3
@@ -34,9 +34,7 @@#include <part.h> #include <ide.h> #include <ata.h> - -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ]; -extern int sata_curr_device; +#include <sata.h> #define DEBUG_SATA 0/* For debug prints set DEBUG_SATA to 1 */
drivers/block/ata_piix.h +0 -2
@@ -56,8 +56,6 @@ int sata_devchk(struct sata_ioports *ioaddr, int dev);void dev_select (struct sata_ioports *ioaddr,int dev);u8 sata_busy_wait (struct sata_ioports *ioaddr,int bits,unsigned int max);u8 sata_chk_status (struct sata_ioports *ioaddr); -ulong sata_read (int device,ulong blknr,lbaint_t blkcnt,void *buffer); -ulong sata_write (int device,ulong blknr,lbaint_t blkcnt,const void *buffer);#endif /************DRIVER SPECIFIC DEFINITIONS AND DECLARATIONS**************/
drivers/block/dwc_ahsata.c +1 -0
@@ -24,6 +24,7 @@#include <libata.h> #include <ahci.h> #include <fis.h> +#include <sata.h> #include <common.h> #include <malloc.h>
drivers/block/dwc_ahsata.h +0 -2
@@ -330,6 +330,4 @@#define READ_CMD 0#define WRITE_CMD 1 -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ]; -#endif /* __FSL_SATA_H__ */
drivers/block/fsl_sata.c +1 -2
@@ -26,10 +26,9 @@#include <malloc.h> #include <libata.h> #include <fis.h> +#include <sata.h> #include "fsl_sata.h" -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ]; -#ifndef CONFIG_SYS_SATA1_FLAGS #define CONFIG_SYS_SATA1_FLAGS FLAGS_DMA#endif
drivers/block/pata_bfin.c +1 -0
@@ -17,6 +17,7 @@#include <asm/portmux.h> #include <asm/mach-common/bits/pata.h> #include <ata.h> +#include <sata.h> #include <libata.h> #include "pata_bfin.h"
drivers/block/pata_bfin.h +0 -2
@@ -41,8 +41,6 @@ struct ata_port {unsigned char dev_mask; }; -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ]; -#define DRV_NAME "pata-bfin"#define DRV_VERSION "0.9"#define __iomem
drivers/block/sata_dwc.c +1 -2
@@ -35,6 +35,7 @@#include <asm/io.h> #include <malloc.h> #include <ata.h> +#include <sata.h> #include <linux/ctype.h> #include "sata_dwc.h"
@@ -268,8 +269,6 @@ static int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, unsigned int flags, u16 *id);static int check_sata_dev_state (void ); -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ]; -static const struct ata_port_info sata_dwc_port_info[] = { { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
drivers/block/sata_sil.c +1 -0
@@ -25,6 +25,7 @@#include <malloc.h> #include <asm/io.h> #include <fis.h> +#include <sata.h> #include <libata.h> #include "sata_sil.h"
drivers/block/sata_sil.h +0 -2
@@ -24,8 +24,6 @@#define READ_CMD 0#define WRITE_CMD 1 -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ]; -/* * SATA device driver struct for each dev */
drivers/block/sata_sil3114.c +1 -1
@@ -28,6 +28,7 @@#include <asm/byteorder.h> #include <asm/io.h> #include <ide.h> +#include <sata.h> #include <libata.h> #include "sata_sil3114.h"
@@ -48,7 +49,6 @@ static u8 sata_chk_status (struct sata_ioports *ioaddr, u8 usealtstatus);static void msleep (int count);static u32 iobase[6 ] = {0 ,0 ,0 ,0 ,0 ,0 };/* PCI BAR registers for device */ -extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE ];static struct sata_port port[CONFIG_SYS_SATA_MAX_DEVICE ];
include/sata.h +5 -2
@@ -1,12 +1,15 @@#ifndef __SATA_H__#define __SATA_H__ +#include <part.h> int init_sata (int dev);int scan_sata (int dev); -ulong sata_read (int dev,ulong blknr,ulong blkcnt,void *buffer); -ulong sata_write (int dev,ulong blknr,ulong blkcnt,const void *buffer); +ulong sata_read (int dev,ulong blknr,lbaint_t blkcnt,void *buffer); +ulong sata_write (int dev,ulong blknr,lbaint_t blkcnt,const void *buffer);int sata_initialize (void );int __sata_initialize (void ); +extern block_dev_desc_t sata_dev_desc[]; +#endif
Signature · 1 line
1.7.9.5
cover block: Fix some inconsistencies in block_{read, write} implementors
In reply to Tom RiniQuoted 11 lines · Tom Rini
Hey all,
I ran into this problem while testing Pavel Herrmann's patch to move externs to <
sata.h>. To fix these problems I've taken over the patch. Pavel's patch makes all of the sata drivers include <sata.h>, and this exposed a number of build problems due to type mis-match. Examining these mis-matches leads to this series. Both <ide.h> and <sata.h> set prototypes for block_dev_desc_t->block_{read,write} implementors that did not match the prototype. First we fix these implemenators (and in the case of ata_piix.[ch] fix a large number of checkpatch issues. Then we fix the prototypes in the headers.
I've applied this to u-boot/next.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121009/eca7afeb/attachment.pgp>