diff options
author | Tejun Heo <htejun@gmail.com> | 2006-05-15 07:57:53 -0400 |
---|---|---|
committer | Tejun Heo <htejun@gmail.com> | 2006-05-15 07:57:53 -0400 |
commit | 3373efd89dead4ce7818d685729e0431448357c9 (patch) | |
tree | d7e7a1afd83e269c3c0978f924cd8c54d9be7f5a /drivers/scsi/libata-core.c | |
parent | 38d87234d6c47ca487fc6344100323d5adc6f32c (diff) |
[PATCH] libata: use dev->ap
Use dev->ap where possible and eliminate superflous @ap from functions
and structures.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 160 |
1 files changed, 75 insertions, 85 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 31b65e0da0b1..4ced962db812 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -61,13 +61,10 @@ | |||
61 | 61 | ||
62 | #include "libata.h" | 62 | #include "libata.h" |
63 | 63 | ||
64 | static unsigned int ata_dev_init_params(struct ata_port *ap, | 64 | static unsigned int ata_dev_init_params(struct ata_device *dev, |
65 | struct ata_device *dev, | 65 | u16 heads, u16 sectors); |
66 | u16 heads, | 66 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); |
67 | u16 sectors); | 67 | static void ata_dev_xfermask(struct ata_device *dev); |
68 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | ||
69 | struct ata_device *dev); | ||
70 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev); | ||
71 | 68 | ||
72 | static unsigned int ata_unique_id = 1; | 69 | static unsigned int ata_unique_id = 1; |
73 | static struct workqueue_struct *ata_wq; | 70 | static struct workqueue_struct *ata_wq; |
@@ -412,11 +409,11 @@ static const char *sata_spd_string(unsigned int spd) | |||
412 | return spd_str[spd - 1]; | 409 | return spd_str[spd - 1]; |
413 | } | 410 | } |
414 | 411 | ||
415 | void ata_dev_disable(struct ata_port *ap, struct ata_device *dev) | 412 | void ata_dev_disable(struct ata_device *dev) |
416 | { | 413 | { |
417 | if (ata_dev_enabled(dev)) { | 414 | if (ata_dev_enabled(dev)) { |
418 | printk(KERN_WARNING "ata%u: dev %u disabled\n", | 415 | printk(KERN_WARNING "ata%u: dev %u disabled\n", |
419 | ap->id, dev->devno); | 416 | dev->ap->id, dev->devno); |
420 | dev->class++; | 417 | dev->class++; |
421 | } | 418 | } |
422 | } | 419 | } |
@@ -960,7 +957,6 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
960 | 957 | ||
961 | /** | 958 | /** |
962 | * ata_exec_internal - execute libata internal command | 959 | * ata_exec_internal - execute libata internal command |
963 | * @ap: Port to which the command is sent | ||
964 | * @dev: Device to which the command is sent | 960 | * @dev: Device to which the command is sent |
965 | * @tf: Taskfile registers for the command and the result | 961 | * @tf: Taskfile registers for the command and the result |
966 | * @cdb: CDB for packet command | 962 | * @cdb: CDB for packet command |
@@ -978,10 +974,11 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
978 | * None. Should be called with kernel context, might sleep. | 974 | * None. Should be called with kernel context, might sleep. |
979 | */ | 975 | */ |
980 | 976 | ||
981 | unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | 977 | unsigned ata_exec_internal(struct ata_device *dev, |
982 | struct ata_taskfile *tf, const u8 *cdb, | 978 | struct ata_taskfile *tf, const u8 *cdb, |
983 | int dma_dir, void *buf, unsigned int buflen) | 979 | int dma_dir, void *buf, unsigned int buflen) |
984 | { | 980 | { |
981 | struct ata_port *ap = dev->ap; | ||
985 | u8 command = tf->command; | 982 | u8 command = tf->command; |
986 | struct ata_queued_cmd *qc; | 983 | struct ata_queued_cmd *qc; |
987 | DECLARE_COMPLETION(wait); | 984 | DECLARE_COMPLETION(wait); |
@@ -990,7 +987,7 @@ unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
990 | 987 | ||
991 | spin_lock_irqsave(&ap->host_set->lock, flags); | 988 | spin_lock_irqsave(&ap->host_set->lock, flags); |
992 | 989 | ||
993 | qc = ata_qc_new_init(ap, dev); | 990 | qc = ata_qc_new_init(dev); |
994 | BUG_ON(qc == NULL); | 991 | BUG_ON(qc == NULL); |
995 | 992 | ||
996 | qc->tf = *tf; | 993 | qc->tf = *tf; |
@@ -1095,7 +1092,6 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1095 | 1092 | ||
1096 | /** | 1093 | /** |
1097 | * ata_dev_read_id - Read ID data from the specified device | 1094 | * ata_dev_read_id - Read ID data from the specified device |
1098 | * @ap: port on which target device resides | ||
1099 | * @dev: target device | 1095 | * @dev: target device |
1100 | * @p_class: pointer to class of the target device (may be changed) | 1096 | * @p_class: pointer to class of the target device (may be changed) |
1101 | * @post_reset: is this read ID post-reset? | 1097 | * @post_reset: is this read ID post-reset? |
@@ -1112,9 +1108,10 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1112 | * RETURNS: | 1108 | * RETURNS: |
1113 | * 0 on success, -errno otherwise. | 1109 | * 0 on success, -errno otherwise. |
1114 | */ | 1110 | */ |
1115 | static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | 1111 | static int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, |
1116 | unsigned int *p_class, int post_reset, u16 *id) | 1112 | int post_reset, u16 *id) |
1117 | { | 1113 | { |
1114 | struct ata_port *ap = dev->ap; | ||
1118 | unsigned int class = *p_class; | 1115 | unsigned int class = *p_class; |
1119 | struct ata_taskfile tf; | 1116 | struct ata_taskfile tf; |
1120 | unsigned int err_mask = 0; | 1117 | unsigned int err_mask = 0; |
@@ -1126,7 +1123,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1126 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ | 1123 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ |
1127 | 1124 | ||
1128 | retry: | 1125 | retry: |
1129 | ata_tf_init(ap, &tf, dev->devno); | 1126 | ata_tf_init(dev, &tf); |
1130 | 1127 | ||
1131 | switch (class) { | 1128 | switch (class) { |
1132 | case ATA_DEV_ATA: | 1129 | case ATA_DEV_ATA: |
@@ -1143,7 +1140,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1143 | 1140 | ||
1144 | tf.protocol = ATA_PROT_PIO; | 1141 | tf.protocol = ATA_PROT_PIO; |
1145 | 1142 | ||
1146 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_FROM_DEVICE, | 1143 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, |
1147 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1144 | id, sizeof(id[0]) * ATA_ID_WORDS); |
1148 | if (err_mask) { | 1145 | if (err_mask) { |
1149 | rc = -EIO; | 1146 | rc = -EIO; |
@@ -1170,7 +1167,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1170 | * Some drives were very specific about that exact sequence. | 1167 | * Some drives were very specific about that exact sequence. |
1171 | */ | 1168 | */ |
1172 | if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) { | 1169 | if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) { |
1173 | err_mask = ata_dev_init_params(ap, dev, id[3], id[6]); | 1170 | err_mask = ata_dev_init_params(dev, id[3], id[6]); |
1174 | if (err_mask) { | 1171 | if (err_mask) { |
1175 | rc = -EIO; | 1172 | rc = -EIO; |
1176 | reason = "INIT_DEV_PARAMS failed"; | 1173 | reason = "INIT_DEV_PARAMS failed"; |
@@ -1195,15 +1192,13 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1195 | return rc; | 1192 | return rc; |
1196 | } | 1193 | } |
1197 | 1194 | ||
1198 | static inline u8 ata_dev_knobble(const struct ata_port *ap, | 1195 | static inline u8 ata_dev_knobble(struct ata_device *dev) |
1199 | struct ata_device *dev) | ||
1200 | { | 1196 | { |
1201 | return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); | 1197 | return ((dev->ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); |
1202 | } | 1198 | } |
1203 | 1199 | ||
1204 | /** | 1200 | /** |
1205 | * ata_dev_configure - Configure the specified ATA/ATAPI device | 1201 | * ata_dev_configure - Configure the specified ATA/ATAPI device |
1206 | * @ap: Port on which target device resides | ||
1207 | * @dev: Target device to configure | 1202 | * @dev: Target device to configure |
1208 | * @print_info: Enable device info printout | 1203 | * @print_info: Enable device info printout |
1209 | * | 1204 | * |
@@ -1216,9 +1211,9 @@ static inline u8 ata_dev_knobble(const struct ata_port *ap, | |||
1216 | * RETURNS: | 1211 | * RETURNS: |
1217 | * 0 on success, -errno otherwise | 1212 | * 0 on success, -errno otherwise |
1218 | */ | 1213 | */ |
1219 | static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | 1214 | static int ata_dev_configure(struct ata_device *dev, int print_info) |
1220 | int print_info) | ||
1221 | { | 1215 | { |
1216 | struct ata_port *ap = dev->ap; | ||
1222 | const u16 *id = dev->id; | 1217 | const u16 *id = dev->id; |
1223 | unsigned int xfer_mask; | 1218 | unsigned int xfer_mask; |
1224 | int i, rc; | 1219 | int i, rc; |
@@ -1331,7 +1326,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1331 | ap->device[i].cdb_len); | 1326 | ap->device[i].cdb_len); |
1332 | 1327 | ||
1333 | /* limit bridge transfers to udma5, 200 sectors */ | 1328 | /* limit bridge transfers to udma5, 200 sectors */ |
1334 | if (ata_dev_knobble(ap, dev)) { | 1329 | if (ata_dev_knobble(dev)) { |
1335 | if (print_info) | 1330 | if (print_info) |
1336 | printk(KERN_INFO "ata%u(%u): applying bridge limits\n", | 1331 | printk(KERN_INFO "ata%u(%u): applying bridge limits\n", |
1337 | ap->id, dev->devno); | 1332 | ap->id, dev->devno); |
@@ -1416,11 +1411,11 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1416 | if (!ata_dev_enabled(dev)) | 1411 | if (!ata_dev_enabled(dev)) |
1417 | continue; | 1412 | continue; |
1418 | 1413 | ||
1419 | rc = ata_dev_read_id(ap, dev, &dev->class, 1, dev->id); | 1414 | rc = ata_dev_read_id(dev, &dev->class, 1, dev->id); |
1420 | if (rc) | 1415 | if (rc) |
1421 | goto fail; | 1416 | goto fail; |
1422 | 1417 | ||
1423 | rc = ata_dev_configure(ap, dev, 1); | 1418 | rc = ata_dev_configure(dev, 1); |
1424 | if (rc) | 1419 | if (rc) |
1425 | goto fail; | 1420 | goto fail; |
1426 | } | 1421 | } |
@@ -1453,13 +1448,13 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1453 | default: | 1448 | default: |
1454 | tries[dev->devno]--; | 1449 | tries[dev->devno]--; |
1455 | if (down_xfermask && | 1450 | if (down_xfermask && |
1456 | ata_down_xfermask_limit(ap, dev, tries[dev->devno] == 1)) | 1451 | ata_down_xfermask_limit(dev, tries[dev->devno] == 1)) |
1457 | tries[dev->devno] = 0; | 1452 | tries[dev->devno] = 0; |
1458 | } | 1453 | } |
1459 | 1454 | ||
1460 | if (!tries[dev->devno]) { | 1455 | if (!tries[dev->devno]) { |
1461 | ata_down_xfermask_limit(ap, dev, 1); | 1456 | ata_down_xfermask_limit(dev, 1); |
1462 | ata_dev_disable(ap, dev); | 1457 | ata_dev_disable(dev); |
1463 | } | 1458 | } |
1464 | 1459 | ||
1465 | goto retry; | 1460 | goto retry; |
@@ -1586,15 +1581,15 @@ void sata_phy_reset(struct ata_port *ap) | |||
1586 | 1581 | ||
1587 | /** | 1582 | /** |
1588 | * ata_dev_pair - return other device on cable | 1583 | * ata_dev_pair - return other device on cable |
1589 | * @ap: port | ||
1590 | * @adev: device | 1584 | * @adev: device |
1591 | * | 1585 | * |
1592 | * Obtain the other device on the same cable, or if none is | 1586 | * Obtain the other device on the same cable, or if none is |
1593 | * present NULL is returned | 1587 | * present NULL is returned |
1594 | */ | 1588 | */ |
1595 | 1589 | ||
1596 | struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev) | 1590 | struct ata_device *ata_dev_pair(struct ata_device *adev) |
1597 | { | 1591 | { |
1592 | struct ata_port *ap = adev->ap; | ||
1598 | struct ata_device *pair = &ap->device[1 - adev->devno]; | 1593 | struct ata_device *pair = &ap->device[1 - adev->devno]; |
1599 | if (!ata_dev_enabled(pair)) | 1594 | if (!ata_dev_enabled(pair)) |
1600 | return NULL; | 1595 | return NULL; |
@@ -1886,7 +1881,6 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1886 | 1881 | ||
1887 | /** | 1882 | /** |
1888 | * ata_down_xfermask_limit - adjust dev xfer masks downward | 1883 | * ata_down_xfermask_limit - adjust dev xfer masks downward |
1889 | * @ap: Port associated with device @dev | ||
1890 | * @dev: Device to adjust xfer masks | 1884 | * @dev: Device to adjust xfer masks |
1891 | * @force_pio0: Force PIO0 | 1885 | * @force_pio0: Force PIO0 |
1892 | * | 1886 | * |
@@ -1900,9 +1894,9 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1900 | * RETURNS: | 1894 | * RETURNS: |
1901 | * 0 on success, negative errno on failure | 1895 | * 0 on success, negative errno on failure |
1902 | */ | 1896 | */ |
1903 | int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev, | 1897 | int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0) |
1904 | int force_pio0) | ||
1905 | { | 1898 | { |
1899 | struct ata_port *ap = dev->ap; | ||
1906 | unsigned long xfer_mask; | 1900 | unsigned long xfer_mask; |
1907 | int highbit; | 1901 | int highbit; |
1908 | 1902 | ||
@@ -1934,8 +1928,9 @@ int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev, | |||
1934 | return -EINVAL; | 1928 | return -EINVAL; |
1935 | } | 1929 | } |
1936 | 1930 | ||
1937 | static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | 1931 | static int ata_dev_set_mode(struct ata_device *dev) |
1938 | { | 1932 | { |
1933 | struct ata_port *ap = dev->ap; | ||
1939 | unsigned int err_mask; | 1934 | unsigned int err_mask; |
1940 | int rc; | 1935 | int rc; |
1941 | 1936 | ||
@@ -1943,7 +1938,7 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1943 | if (dev->xfer_shift == ATA_SHIFT_PIO) | 1938 | if (dev->xfer_shift == ATA_SHIFT_PIO) |
1944 | dev->flags |= ATA_DFLAG_PIO; | 1939 | dev->flags |= ATA_DFLAG_PIO; |
1945 | 1940 | ||
1946 | err_mask = ata_dev_set_xfermode(ap, dev); | 1941 | err_mask = ata_dev_set_xfermode(dev); |
1947 | if (err_mask) { | 1942 | if (err_mask) { |
1948 | printk(KERN_ERR | 1943 | printk(KERN_ERR |
1949 | "ata%u: failed to set xfermode (err_mask=0x%x)\n", | 1944 | "ata%u: failed to set xfermode (err_mask=0x%x)\n", |
@@ -1951,7 +1946,7 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1951 | return -EIO; | 1946 | return -EIO; |
1952 | } | 1947 | } |
1953 | 1948 | ||
1954 | rc = ata_dev_revalidate(ap, dev, 0); | 1949 | rc = ata_dev_revalidate(dev, 0); |
1955 | if (rc) | 1950 | if (rc) |
1956 | return rc; | 1951 | return rc; |
1957 | 1952 | ||
@@ -2007,7 +2002,7 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2007 | if (!ata_dev_enabled(dev)) | 2002 | if (!ata_dev_enabled(dev)) |
2008 | continue; | 2003 | continue; |
2009 | 2004 | ||
2010 | ata_dev_xfermask(ap, dev); | 2005 | ata_dev_xfermask(dev); |
2011 | 2006 | ||
2012 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); | 2007 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); |
2013 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); | 2008 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); |
@@ -2060,7 +2055,7 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2060 | if (!ata_dev_enabled(dev)) | 2055 | if (!ata_dev_enabled(dev)) |
2061 | continue; | 2056 | continue; |
2062 | 2057 | ||
2063 | rc = ata_dev_set_mode(ap, dev); | 2058 | rc = ata_dev_set_mode(dev); |
2064 | if (rc) | 2059 | if (rc) |
2065 | goto out; | 2060 | goto out; |
2066 | } | 2061 | } |
@@ -2712,7 +2707,6 @@ int ata_drive_probe_reset(struct ata_port *ap, ata_probeinit_fn_t probeinit, | |||
2712 | 2707 | ||
2713 | /** | 2708 | /** |
2714 | * ata_dev_same_device - Determine whether new ID matches configured device | 2709 | * ata_dev_same_device - Determine whether new ID matches configured device |
2715 | * @ap: port on which the device to compare against resides | ||
2716 | * @dev: device to compare against | 2710 | * @dev: device to compare against |
2717 | * @new_class: class of the new device | 2711 | * @new_class: class of the new device |
2718 | * @new_id: IDENTIFY page of the new device | 2712 | * @new_id: IDENTIFY page of the new device |
@@ -2727,9 +2721,10 @@ int ata_drive_probe_reset(struct ata_port *ap, ata_probeinit_fn_t probeinit, | |||
2727 | * RETURNS: | 2721 | * RETURNS: |
2728 | * 1 if @dev matches @new_class and @new_id, 0 otherwise. | 2722 | * 1 if @dev matches @new_class and @new_id, 0 otherwise. |
2729 | */ | 2723 | */ |
2730 | static int ata_dev_same_device(struct ata_port *ap, struct ata_device *dev, | 2724 | static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, |
2731 | unsigned int new_class, const u16 *new_id) | 2725 | const u16 *new_id) |
2732 | { | 2726 | { |
2727 | struct ata_port *ap = dev->ap; | ||
2733 | const u16 *old_id = dev->id; | 2728 | const u16 *old_id = dev->id; |
2734 | unsigned char model[2][41], serial[2][21]; | 2729 | unsigned char model[2][41], serial[2][21]; |
2735 | u64 new_n_sectors; | 2730 | u64 new_n_sectors; |
@@ -2774,7 +2769,6 @@ static int ata_dev_same_device(struct ata_port *ap, struct ata_device *dev, | |||
2774 | 2769 | ||
2775 | /** | 2770 | /** |
2776 | * ata_dev_revalidate - Revalidate ATA device | 2771 | * ata_dev_revalidate - Revalidate ATA device |
2777 | * @ap: port on which the device to revalidate resides | ||
2778 | * @dev: device to revalidate | 2772 | * @dev: device to revalidate |
2779 | * @post_reset: is this revalidation after reset? | 2773 | * @post_reset: is this revalidation after reset? |
2780 | * | 2774 | * |
@@ -2787,9 +2781,9 @@ static int ata_dev_same_device(struct ata_port *ap, struct ata_device *dev, | |||
2787 | * RETURNS: | 2781 | * RETURNS: |
2788 | * 0 on success, negative errno otherwise | 2782 | * 0 on success, negative errno otherwise |
2789 | */ | 2783 | */ |
2790 | int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 2784 | int ata_dev_revalidate(struct ata_device *dev, int post_reset) |
2791 | int post_reset) | ||
2792 | { | 2785 | { |
2786 | struct ata_port *ap = dev->ap; | ||
2793 | unsigned int class = dev->class; | 2787 | unsigned int class = dev->class; |
2794 | u16 *id = (void *)ap->sector_buf; | 2788 | u16 *id = (void *)ap->sector_buf; |
2795 | int rc; | 2789 | int rc; |
@@ -2800,12 +2794,12 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | |||
2800 | } | 2794 | } |
2801 | 2795 | ||
2802 | /* read ID data */ | 2796 | /* read ID data */ |
2803 | rc = ata_dev_read_id(ap, dev, &class, post_reset, id); | 2797 | rc = ata_dev_read_id(dev, &class, post_reset, id); |
2804 | if (rc) | 2798 | if (rc) |
2805 | goto fail; | 2799 | goto fail; |
2806 | 2800 | ||
2807 | /* is the device still there? */ | 2801 | /* is the device still there? */ |
2808 | if (!ata_dev_same_device(ap, dev, class, id)) { | 2802 | if (!ata_dev_same_device(dev, class, id)) { |
2809 | rc = -ENODEV; | 2803 | rc = -ENODEV; |
2810 | goto fail; | 2804 | goto fail; |
2811 | } | 2805 | } |
@@ -2813,7 +2807,7 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | |||
2813 | memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); | 2807 | memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); |
2814 | 2808 | ||
2815 | /* configure device according to the new ID */ | 2809 | /* configure device according to the new ID */ |
2816 | rc = ata_dev_configure(ap, dev, 0); | 2810 | rc = ata_dev_configure(dev, 0); |
2817 | if (rc == 0) | 2811 | if (rc == 0) |
2818 | return 0; | 2812 | return 0; |
2819 | 2813 | ||
@@ -2895,7 +2889,6 @@ static int ata_dma_blacklisted(const struct ata_device *dev) | |||
2895 | 2889 | ||
2896 | /** | 2890 | /** |
2897 | * ata_dev_xfermask - Compute supported xfermask of the given device | 2891 | * ata_dev_xfermask - Compute supported xfermask of the given device |
2898 | * @ap: Port on which the device to compute xfermask for resides | ||
2899 | * @dev: Device to compute xfermask for | 2892 | * @dev: Device to compute xfermask for |
2900 | * | 2893 | * |
2901 | * Compute supported xfermask of @dev and store it in | 2894 | * Compute supported xfermask of @dev and store it in |
@@ -2910,8 +2903,9 @@ static int ata_dma_blacklisted(const struct ata_device *dev) | |||
2910 | * LOCKING: | 2903 | * LOCKING: |
2911 | * None. | 2904 | * None. |
2912 | */ | 2905 | */ |
2913 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | 2906 | static void ata_dev_xfermask(struct ata_device *dev) |
2914 | { | 2907 | { |
2908 | struct ata_port *ap = dev->ap; | ||
2915 | struct ata_host_set *hs = ap->host_set; | 2909 | struct ata_host_set *hs = ap->host_set; |
2916 | unsigned long xfer_mask; | 2910 | unsigned long xfer_mask; |
2917 | int i; | 2911 | int i; |
@@ -2964,7 +2958,6 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | |||
2964 | 2958 | ||
2965 | /** | 2959 | /** |
2966 | * ata_dev_set_xfermode - Issue SET FEATURES - XFER MODE command | 2960 | * ata_dev_set_xfermode - Issue SET FEATURES - XFER MODE command |
2967 | * @ap: Port associated with device @dev | ||
2968 | * @dev: Device to which command will be sent | 2961 | * @dev: Device to which command will be sent |
2969 | * | 2962 | * |
2970 | * Issue SET FEATURES - XFER MODE command to device @dev | 2963 | * Issue SET FEATURES - XFER MODE command to device @dev |
@@ -2977,8 +2970,7 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | |||
2977 | * 0 on success, AC_ERR_* mask otherwise. | 2970 | * 0 on success, AC_ERR_* mask otherwise. |
2978 | */ | 2971 | */ |
2979 | 2972 | ||
2980 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | 2973 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev) |
2981 | struct ata_device *dev) | ||
2982 | { | 2974 | { |
2983 | struct ata_taskfile tf; | 2975 | struct ata_taskfile tf; |
2984 | unsigned int err_mask; | 2976 | unsigned int err_mask; |
@@ -2986,14 +2978,14 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | |||
2986 | /* set up set-features taskfile */ | 2978 | /* set up set-features taskfile */ |
2987 | DPRINTK("set features - xfer mode\n"); | 2979 | DPRINTK("set features - xfer mode\n"); |
2988 | 2980 | ||
2989 | ata_tf_init(ap, &tf, dev->devno); | 2981 | ata_tf_init(dev, &tf); |
2990 | tf.command = ATA_CMD_SET_FEATURES; | 2982 | tf.command = ATA_CMD_SET_FEATURES; |
2991 | tf.feature = SETFEATURES_XFER; | 2983 | tf.feature = SETFEATURES_XFER; |
2992 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2984 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
2993 | tf.protocol = ATA_PROT_NODATA; | 2985 | tf.protocol = ATA_PROT_NODATA; |
2994 | tf.nsect = dev->xfer_mode; | 2986 | tf.nsect = dev->xfer_mode; |
2995 | 2987 | ||
2996 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); | 2988 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); |
2997 | 2989 | ||
2998 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 2990 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
2999 | return err_mask; | 2991 | return err_mask; |
@@ -3001,8 +2993,9 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | |||
3001 | 2993 | ||
3002 | /** | 2994 | /** |
3003 | * ata_dev_init_params - Issue INIT DEV PARAMS command | 2995 | * ata_dev_init_params - Issue INIT DEV PARAMS command |
3004 | * @ap: Port associated with device @dev | ||
3005 | * @dev: Device to which command will be sent | 2996 | * @dev: Device to which command will be sent |
2997 | * @heads: Number of heads | ||
2998 | * @sectors: Number of sectors | ||
3006 | * | 2999 | * |
3007 | * LOCKING: | 3000 | * LOCKING: |
3008 | * Kernel thread context (may sleep) | 3001 | * Kernel thread context (may sleep) |
@@ -3010,11 +3003,8 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | |||
3010 | * RETURNS: | 3003 | * RETURNS: |
3011 | * 0 on success, AC_ERR_* mask otherwise. | 3004 | * 0 on success, AC_ERR_* mask otherwise. |
3012 | */ | 3005 | */ |
3013 | 3006 | static unsigned int ata_dev_init_params(struct ata_device *dev, | |
3014 | static unsigned int ata_dev_init_params(struct ata_port *ap, | 3007 | u16 heads, u16 sectors) |
3015 | struct ata_device *dev, | ||
3016 | u16 heads, | ||
3017 | u16 sectors) | ||
3018 | { | 3008 | { |
3019 | struct ata_taskfile tf; | 3009 | struct ata_taskfile tf; |
3020 | unsigned int err_mask; | 3010 | unsigned int err_mask; |
@@ -3026,14 +3016,14 @@ static unsigned int ata_dev_init_params(struct ata_port *ap, | |||
3026 | /* set up init dev params taskfile */ | 3016 | /* set up init dev params taskfile */ |
3027 | DPRINTK("init dev params \n"); | 3017 | DPRINTK("init dev params \n"); |
3028 | 3018 | ||
3029 | ata_tf_init(ap, &tf, dev->devno); | 3019 | ata_tf_init(dev, &tf); |
3030 | tf.command = ATA_CMD_INIT_DEV_PARAMS; | 3020 | tf.command = ATA_CMD_INIT_DEV_PARAMS; |
3031 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 3021 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
3032 | tf.protocol = ATA_PROT_NODATA; | 3022 | tf.protocol = ATA_PROT_NODATA; |
3033 | tf.nsect = sectors; | 3023 | tf.nsect = sectors; |
3034 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ | 3024 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ |
3035 | 3025 | ||
3036 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); | 3026 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); |
3037 | 3027 | ||
3038 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 3028 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
3039 | return err_mask; | 3029 | return err_mask; |
@@ -4045,16 +4035,15 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | |||
4045 | 4035 | ||
4046 | /** | 4036 | /** |
4047 | * ata_qc_new_init - Request an available ATA command, and initialize it | 4037 | * ata_qc_new_init - Request an available ATA command, and initialize it |
4048 | * @ap: Port associated with device @dev | ||
4049 | * @dev: Device from whom we request an available command structure | 4038 | * @dev: Device from whom we request an available command structure |
4050 | * | 4039 | * |
4051 | * LOCKING: | 4040 | * LOCKING: |
4052 | * None. | 4041 | * None. |
4053 | */ | 4042 | */ |
4054 | 4043 | ||
4055 | struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 4044 | struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev) |
4056 | struct ata_device *dev) | ||
4057 | { | 4045 | { |
4046 | struct ata_port *ap = dev->ap; | ||
4058 | struct ata_queued_cmd *qc; | 4047 | struct ata_queued_cmd *qc; |
4059 | 4048 | ||
4060 | qc = ata_qc_new(ap); | 4049 | qc = ata_qc_new(ap); |
@@ -4520,19 +4509,18 @@ int ata_port_offline(struct ata_port *ap) | |||
4520 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, | 4509 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, |
4521 | * without filling any other registers | 4510 | * without filling any other registers |
4522 | */ | 4511 | */ |
4523 | static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, | 4512 | static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) |
4524 | u8 cmd) | ||
4525 | { | 4513 | { |
4526 | struct ata_taskfile tf; | 4514 | struct ata_taskfile tf; |
4527 | int err; | 4515 | int err; |
4528 | 4516 | ||
4529 | ata_tf_init(ap, &tf, dev->devno); | 4517 | ata_tf_init(dev, &tf); |
4530 | 4518 | ||
4531 | tf.command = cmd; | 4519 | tf.command = cmd; |
4532 | tf.flags |= ATA_TFLAG_DEVICE; | 4520 | tf.flags |= ATA_TFLAG_DEVICE; |
4533 | tf.protocol = ATA_PROT_NODATA; | 4521 | tf.protocol = ATA_PROT_NODATA; |
4534 | 4522 | ||
4535 | err = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); | 4523 | err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); |
4536 | if (err) | 4524 | if (err) |
4537 | printk(KERN_ERR "%s: ata command failed: %d\n", | 4525 | printk(KERN_ERR "%s: ata command failed: %d\n", |
4538 | __FUNCTION__, err); | 4526 | __FUNCTION__, err); |
@@ -4540,7 +4528,7 @@ static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, | |||
4540 | return err; | 4528 | return err; |
4541 | } | 4529 | } |
4542 | 4530 | ||
4543 | static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev) | 4531 | static int ata_flush_cache(struct ata_device *dev) |
4544 | { | 4532 | { |
4545 | u8 cmd; | 4533 | u8 cmd; |
4546 | 4534 | ||
@@ -4552,22 +4540,21 @@ static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev) | |||
4552 | else | 4540 | else |
4553 | cmd = ATA_CMD_FLUSH; | 4541 | cmd = ATA_CMD_FLUSH; |
4554 | 4542 | ||
4555 | return ata_do_simple_cmd(ap, dev, cmd); | 4543 | return ata_do_simple_cmd(dev, cmd); |
4556 | } | 4544 | } |
4557 | 4545 | ||
4558 | static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev) | 4546 | static int ata_standby_drive(struct ata_device *dev) |
4559 | { | 4547 | { |
4560 | return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1); | 4548 | return ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); |
4561 | } | 4549 | } |
4562 | 4550 | ||
4563 | static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) | 4551 | static int ata_start_drive(struct ata_device *dev) |
4564 | { | 4552 | { |
4565 | return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE); | 4553 | return ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE); |
4566 | } | 4554 | } |
4567 | 4555 | ||
4568 | /** | 4556 | /** |
4569 | * ata_device_resume - wakeup a previously suspended devices | 4557 | * ata_device_resume - wakeup a previously suspended devices |
4570 | * @ap: port the device is connected to | ||
4571 | * @dev: the device to resume | 4558 | * @dev: the device to resume |
4572 | * | 4559 | * |
4573 | * Kick the drive back into action, by sending it an idle immediate | 4560 | * Kick the drive back into action, by sending it an idle immediate |
@@ -4575,39 +4562,42 @@ static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) | |||
4575 | * and host. | 4562 | * and host. |
4576 | * | 4563 | * |
4577 | */ | 4564 | */ |
4578 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | 4565 | int ata_device_resume(struct ata_device *dev) |
4579 | { | 4566 | { |
4567 | struct ata_port *ap = dev->ap; | ||
4568 | |||
4580 | if (ap->flags & ATA_FLAG_SUSPENDED) { | 4569 | if (ap->flags & ATA_FLAG_SUSPENDED) { |
4581 | struct ata_device *failed_dev; | 4570 | struct ata_device *failed_dev; |
4582 | ap->flags &= ~ATA_FLAG_SUSPENDED; | 4571 | ap->flags &= ~ATA_FLAG_SUSPENDED; |
4583 | while (ata_set_mode(ap, &failed_dev)) | 4572 | while (ata_set_mode(ap, &failed_dev)) |
4584 | ata_dev_disable(ap, failed_dev); | 4573 | ata_dev_disable(failed_dev); |
4585 | } | 4574 | } |
4586 | if (!ata_dev_enabled(dev)) | 4575 | if (!ata_dev_enabled(dev)) |
4587 | return 0; | 4576 | return 0; |
4588 | if (dev->class == ATA_DEV_ATA) | 4577 | if (dev->class == ATA_DEV_ATA) |
4589 | ata_start_drive(ap, dev); | 4578 | ata_start_drive(dev); |
4590 | 4579 | ||
4591 | return 0; | 4580 | return 0; |
4592 | } | 4581 | } |
4593 | 4582 | ||
4594 | /** | 4583 | /** |
4595 | * ata_device_suspend - prepare a device for suspend | 4584 | * ata_device_suspend - prepare a device for suspend |
4596 | * @ap: port the device is connected to | ||
4597 | * @dev: the device to suspend | 4585 | * @dev: the device to suspend |
4598 | * | 4586 | * |
4599 | * Flush the cache on the drive, if appropriate, then issue a | 4587 | * Flush the cache on the drive, if appropriate, then issue a |
4600 | * standbynow command. | 4588 | * standbynow command. |
4601 | */ | 4589 | */ |
4602 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state) | 4590 | int ata_device_suspend(struct ata_device *dev, pm_message_t state) |
4603 | { | 4591 | { |
4592 | struct ata_port *ap = dev->ap; | ||
4593 | |||
4604 | if (!ata_dev_enabled(dev)) | 4594 | if (!ata_dev_enabled(dev)) |
4605 | return 0; | 4595 | return 0; |
4606 | if (dev->class == ATA_DEV_ATA) | 4596 | if (dev->class == ATA_DEV_ATA) |
4607 | ata_flush_cache(ap, dev); | 4597 | ata_flush_cache(dev); |
4608 | 4598 | ||
4609 | if (state.event != PM_EVENT_FREEZE) | 4599 | if (state.event != PM_EVENT_FREEZE) |
4610 | ata_standby_drive(ap, dev); | 4600 | ata_standby_drive(dev); |
4611 | ap->flags |= ATA_FLAG_SUSPENDED; | 4601 | ap->flags |= ATA_FLAG_SUSPENDED; |
4612 | return 0; | 4602 | return 0; |
4613 | } | 4603 | } |