aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-07 09:47:22 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:25 -0400
commit071f44b1d2c051641b62a3571223314737ccbe59 (patch)
treea07794c8109e5d82a78223ae0159eadbf862c463 /include/linux/libata.h
parent48515f6c006c2a9d7b624ee8ad068018c2d3fe0e (diff)
libata: implement PMP helpers
Implement helpers to test whether PMP is supported, attached and determine pmp number to use when issuing SRST to a link. While at it, move ata_is_host_link() so that it's together with the two new PMP helpers. This change simplifies LLDs and helps making PMP support optional. Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h38
1 files changed, 29 insertions, 9 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index eb86d6f39635..1908bf484743 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1090,13 +1090,38 @@ extern const struct ata_port_operations sata_port_ops;
1090 .change_queue_depth = ata_scsi_change_queue_depth 1090 .change_queue_depth = ata_scsi_change_queue_depth
1091 1091
1092/* 1092/*
1093 * PMP helpers
1094 */
1095static inline bool sata_pmp_supported(struct ata_port *ap)
1096{
1097 return ap->flags & ATA_FLAG_PMP;
1098}
1099
1100static inline bool sata_pmp_attached(struct ata_port *ap)
1101{
1102 return ap->nr_pmp_links != 0;
1103}
1104
1105static inline int ata_is_host_link(const struct ata_link *link)
1106{
1107 return link == &link->ap->link;
1108}
1109
1110static inline int sata_srst_pmp(struct ata_link *link)
1111{
1112 if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
1113 return SATA_PMP_CTRL_PORT;
1114 return link->pmp;
1115}
1116
1117/*
1093 * printk helpers 1118 * printk helpers
1094 */ 1119 */
1095#define ata_port_printk(ap, lv, fmt, args...) \ 1120#define ata_port_printk(ap, lv, fmt, args...) \
1096 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1121 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1097 1122
1098#define ata_link_printk(link, lv, fmt, args...) do { \ 1123#define ata_link_printk(link, lv, fmt, args...) do { \
1099 if ((link)->ap->nr_pmp_links) \ 1124 if (sata_pmp_attached((link)->ap)) \
1100 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1125 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1101 (link)->pmp , ##args); \ 1126 (link)->pmp , ##args); \
1102 else \ 1127 else \
@@ -1182,11 +1207,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1182/* 1207/*
1183 * link helpers 1208 * link helpers
1184 */ 1209 */
1185static inline int ata_is_host_link(const struct ata_link *link)
1186{
1187 return link == &link->ap->link;
1188}
1189
1190static inline int ata_link_max_devices(const struct ata_link *link) 1210static inline int ata_link_max_devices(const struct ata_link *link)
1191{ 1211{
1192 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS) 1212 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
@@ -1201,7 +1221,7 @@ static inline int ata_link_active(struct ata_link *link)
1201 1221
1202static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1222static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
1203{ 1223{
1204 if (ap->nr_pmp_links) 1224 if (sata_pmp_attached(ap))
1205 return ap->pmp_link; 1225 return ap->pmp_link;
1206 return &ap->link; 1226 return &ap->link;
1207} 1227}
@@ -1210,8 +1230,8 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1210{ 1230{
1211 struct ata_port *ap = link->ap; 1231 struct ata_port *ap = link->ap;
1212 1232
1213 if (link == &ap->link) { 1233 if (ata_is_host_link(link)) {
1214 if (!ap->nr_pmp_links) 1234 if (!sata_pmp_attached(ap))
1215 return NULL; 1235 return NULL;
1216 return ap->pmp_link; 1236 return ap->pmp_link;
1217 } 1237 }