aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_via.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-07-16 01:29:40 -0400
committerJeff Garzik <jeff@garzik.org>2007-07-20 08:02:11 -0400
commitda3dbb17a0e9a9ec7f5aed95f1fddadb790edc9d (patch)
tree289239e1eb60168321e905c545aa2e2f3a2b5475 /drivers/ata/sata_via.c
parent5335b729064e03319cd2d5219770451dbb1d7f67 (diff)
libata: make ->scr_read/write callbacks return error code
Convert ->scr_read/write callbacks to return error code to better indicate failure. This will help handling of SCR_NOTIFICATION. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_via.c')
-rw-r--r--drivers/ata/sata_via.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index c4124475f754..86b7bfc17324 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -72,8 +72,8 @@ enum {
72}; 72};
73 73
74static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 74static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg); 75static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 76static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
77static void svia_noop_freeze(struct ata_port *ap); 77static void svia_noop_freeze(struct ata_port *ap);
78static void vt6420_error_handler(struct ata_port *ap); 78static void vt6420_error_handler(struct ata_port *ap);
79static int vt6421_pata_cable_detect(struct ata_port *ap); 79static int vt6421_pata_cable_detect(struct ata_port *ap);
@@ -249,18 +249,20 @@ MODULE_LICENSE("GPL");
249MODULE_DEVICE_TABLE(pci, svia_pci_tbl); 249MODULE_DEVICE_TABLE(pci, svia_pci_tbl);
250MODULE_VERSION(DRV_VERSION); 250MODULE_VERSION(DRV_VERSION);
251 251
252static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg) 252static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
253{ 253{
254 if (sc_reg > SCR_CONTROL) 254 if (sc_reg > SCR_CONTROL)
255 return 0xffffffffU; 255 return -EINVAL;
256 return ioread32(ap->ioaddr.scr_addr + (4 * sc_reg)); 256 *val = ioread32(ap->ioaddr.scr_addr + (4 * sc_reg));
257 return 0;
257} 258}
258 259
259static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 260static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
260{ 261{
261 if (sc_reg > SCR_CONTROL) 262 if (sc_reg > SCR_CONTROL)
262 return; 263 return -EINVAL;
263 iowrite32(val, ap->ioaddr.scr_addr + (4 * sc_reg)); 264 iowrite32(val, ap->ioaddr.scr_addr + (4 * sc_reg));
265 return 0;
264} 266}
265 267
266static void svia_noop_freeze(struct ata_port *ap) 268static void svia_noop_freeze(struct ata_port *ap)
@@ -305,18 +307,19 @@ static int vt6420_prereset(struct ata_port *ap, unsigned long deadline)
305 307
306 /* Resume phy. This is the old SATA resume sequence */ 308 /* Resume phy. This is the old SATA resume sequence */
307 svia_scr_write(ap, SCR_CONTROL, 0x300); 309 svia_scr_write(ap, SCR_CONTROL, 0x300);
308 svia_scr_read(ap, SCR_CONTROL); /* flush */ 310 svia_scr_read(ap, SCR_CONTROL, &scontrol); /* flush */
309 311
310 /* wait for phy to become ready, if necessary */ 312 /* wait for phy to become ready, if necessary */
311 do { 313 do {
312 msleep(200); 314 msleep(200);
313 if ((svia_scr_read(ap, SCR_STATUS) & 0xf) != 1) 315 svia_scr_read(ap, SCR_STATUS, &sstatus);
316 if ((sstatus & 0xf) != 1)
314 break; 317 break;
315 } while (time_before(jiffies, timeout)); 318 } while (time_before(jiffies, timeout));
316 319
317 /* open code sata_print_link_status() */ 320 /* open code sata_print_link_status() */
318 sstatus = svia_scr_read(ap, SCR_STATUS); 321 svia_scr_read(ap, SCR_STATUS, &sstatus);
319 scontrol = svia_scr_read(ap, SCR_CONTROL); 322 svia_scr_read(ap, SCR_CONTROL, &scontrol);
320 323
321 online = (sstatus & 0xf) == 0x3; 324 online = (sstatus & 0xf) == 0x3;
322 325
@@ -325,7 +328,7 @@ static int vt6420_prereset(struct ata_port *ap, unsigned long deadline)
325 online ? "up" : "down", sstatus, scontrol); 328 online ? "up" : "down", sstatus, scontrol);
326 329
327 /* SStatus is read one more time */ 330 /* SStatus is read one more time */
328 svia_scr_read(ap, SCR_STATUS); 331 svia_scr_read(ap, SCR_STATUS, &sstatus);
329 332
330 if (!online) { 333 if (!online) {
331 /* tell EH to bail */ 334 /* tell EH to bail */