aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/aic94xx/aic94xx_dev.c24
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_tmf.c2
-rw-r--r--drivers/scsi/isci/remote_device.c4
-rw-r--r--drivers/scsi/isci/remote_device.h2
-rw-r--r--drivers/scsi/isci/request.c6
-rw-r--r--drivers/scsi/isci/task.c2
-rw-r--r--drivers/scsi/libsas/sas_ata.c18
-rw-r--r--drivers/scsi/libsas/sas_discover.c34
-rw-r--r--drivers/scsi/libsas/sas_expander.c110
-rw-r--r--drivers/scsi/libsas/sas_internal.h10
-rw-r--r--drivers/scsi/libsas/sas_port.c2
-rw-r--r--drivers/scsi/mvsas/mv_init.c2
-rw-r--r--drivers/scsi/mvsas/mv_sas.c16
-rw-r--r--drivers/scsi/mvsas/mv_sas.h4
-rw-r--r--drivers/scsi/pm8001/pm8001_hwi.c18
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c2
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.c14
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.h4
-rw-r--r--drivers/scsi/pm8001/pm80xx_hwi.c12
-rw-r--r--include/scsi/libsas.h4
-rw-r--r--include/scsi/sas.h22
-rw-r--r--include/scsi/sas_ata.h4
-rw-r--r--include/scsi/scsi_transport_sas.h7
24 files changed, 160 insertions, 165 deletions
diff --git a/drivers/scsi/aic94xx/aic94xx_dev.c b/drivers/scsi/aic94xx/aic94xx_dev.c
index 64136c56e706..33072388ea16 100644
--- a/drivers/scsi/aic94xx/aic94xx_dev.c
+++ b/drivers/scsi/aic94xx/aic94xx_dev.c
@@ -84,7 +84,7 @@ static void asd_set_ddb_type(struct domain_device *dev)
84 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; 84 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha;
85 int ddb = (int) (unsigned long) dev->lldd_dev; 85 int ddb = (int) (unsigned long) dev->lldd_dev;
86 86
87 if (dev->dev_type == SATA_PM_PORT) 87 if (dev->dev_type == SAS_SATA_PM_PORT)
88 asd_ddbsite_write_byte(asd_ha,ddb, DDB_TYPE, DDB_TYPE_PM_PORT); 88 asd_ddbsite_write_byte(asd_ha,ddb, DDB_TYPE, DDB_TYPE_PM_PORT);
89 else if (dev->tproto) 89 else if (dev->tproto)
90 asd_ddbsite_write_byte(asd_ha,ddb, DDB_TYPE, DDB_TYPE_TARGET); 90 asd_ddbsite_write_byte(asd_ha,ddb, DDB_TYPE, DDB_TYPE_TARGET);
@@ -116,7 +116,7 @@ void asd_set_dmamode(struct domain_device *dev)
116 int ddb = (int) (unsigned long) dev->lldd_dev; 116 int ddb = (int) (unsigned long) dev->lldd_dev;
117 u32 qdepth = 0; 117 u32 qdepth = 0;
118 118
119 if (dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM_PORT) { 119 if (dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM_PORT) {
120 if (ata_id_has_ncq(ata_dev->id)) 120 if (ata_id_has_ncq(ata_dev->id))
121 qdepth = ata_id_queue_depth(ata_dev->id); 121 qdepth = ata_id_queue_depth(ata_dev->id);
122 asd_ddbsite_write_dword(asd_ha, ddb, SATA_TAG_ALLOC_MASK, 122 asd_ddbsite_write_dword(asd_ha, ddb, SATA_TAG_ALLOC_MASK,
@@ -140,8 +140,8 @@ static int asd_init_sata(struct domain_device *dev)
140 int ddb = (int) (unsigned long) dev->lldd_dev; 140 int ddb = (int) (unsigned long) dev->lldd_dev;
141 141
142 asd_ddbsite_write_word(asd_ha, ddb, ATA_CMD_SCBPTR, 0xFFFF); 142 asd_ddbsite_write_word(asd_ha, ddb, ATA_CMD_SCBPTR, 0xFFFF);
143 if (dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM || 143 if (dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM ||
144 dev->dev_type == SATA_PM_PORT) { 144 dev->dev_type == SAS_SATA_PM_PORT) {
145 struct dev_to_host_fis *fis = (struct dev_to_host_fis *) 145 struct dev_to_host_fis *fis = (struct dev_to_host_fis *)
146 dev->frame_rcvd; 146 dev->frame_rcvd;
147 asd_ddbsite_write_byte(asd_ha, ddb, SATA_STATUS, fis->status); 147 asd_ddbsite_write_byte(asd_ha, ddb, SATA_STATUS, fis->status);
@@ -174,7 +174,7 @@ static int asd_init_target_ddb(struct domain_device *dev)
174 asd_ddbsite_write_byte(asd_ha, ddb, CONN_MASK, dev->port->phy_mask); 174 asd_ddbsite_write_byte(asd_ha, ddb, CONN_MASK, dev->port->phy_mask);
175 if (dev->port->oob_mode != SATA_OOB_MODE) { 175 if (dev->port->oob_mode != SATA_OOB_MODE) {
176 flags |= OPEN_REQUIRED; 176 flags |= OPEN_REQUIRED;
177 if ((dev->dev_type == SATA_DEV) || 177 if ((dev->dev_type == SAS_SATA_DEV) ||
178 (dev->tproto & SAS_PROTOCOL_STP)) { 178 (dev->tproto & SAS_PROTOCOL_STP)) {
179 struct smp_resp *rps_resp = &dev->sata_dev.rps_resp; 179 struct smp_resp *rps_resp = &dev->sata_dev.rps_resp;
180 if (rps_resp->frame_type == SMP_RESPONSE && 180 if (rps_resp->frame_type == SMP_RESPONSE &&
@@ -188,8 +188,8 @@ static int asd_init_target_ddb(struct domain_device *dev)
188 } else { 188 } else {
189 flags |= CONCURRENT_CONN_SUPP; 189 flags |= CONCURRENT_CONN_SUPP;
190 if (!dev->parent && 190 if (!dev->parent &&
191 (dev->dev_type == EDGE_DEV || 191 (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
192 dev->dev_type == FANOUT_DEV)) 192 dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE))
193 asd_ddbsite_write_byte(asd_ha, ddb, MAX_CCONN, 193 asd_ddbsite_write_byte(asd_ha, ddb, MAX_CCONN,
194 4); 194 4);
195 else 195 else
@@ -198,7 +198,7 @@ static int asd_init_target_ddb(struct domain_device *dev)
198 asd_ddbsite_write_byte(asd_ha, ddb, NUM_CTX, 1); 198 asd_ddbsite_write_byte(asd_ha, ddb, NUM_CTX, 1);
199 } 199 }
200 } 200 }
201 if (dev->dev_type == SATA_PM) 201 if (dev->dev_type == SAS_SATA_PM)
202 flags |= SATA_MULTIPORT; 202 flags |= SATA_MULTIPORT;
203 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS, flags); 203 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS, flags);
204 204
@@ -211,7 +211,7 @@ static int asd_init_target_ddb(struct domain_device *dev)
211 asd_ddbsite_write_word(asd_ha, ddb, SEND_QUEUE_TAIL, 0xFFFF); 211 asd_ddbsite_write_word(asd_ha, ddb, SEND_QUEUE_TAIL, 0xFFFF);
212 asd_ddbsite_write_word(asd_ha, ddb, SISTER_DDB, 0xFFFF); 212 asd_ddbsite_write_word(asd_ha, ddb, SISTER_DDB, 0xFFFF);
213 213
214 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { 214 if (dev->dev_type == SAS_SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
215 i = asd_init_sata(dev); 215 i = asd_init_sata(dev);
216 if (i < 0) { 216 if (i < 0) {
217 asd_free_ddb(asd_ha, ddb); 217 asd_free_ddb(asd_ha, ddb);
@@ -219,7 +219,7 @@ static int asd_init_target_ddb(struct domain_device *dev)
219 } 219 }
220 } 220 }
221 221
222 if (dev->dev_type == SAS_END_DEV) { 222 if (dev->dev_type == SAS_END_DEVICE) {
223 struct sas_end_device *rdev = rphy_to_end_device(dev->rphy); 223 struct sas_end_device *rdev = rphy_to_end_device(dev->rphy);
224 if (rdev->I_T_nexus_loss_timeout > 0) 224 if (rdev->I_T_nexus_loss_timeout > 0)
225 asd_ddbsite_write_word(asd_ha, ddb, ITNL_TIMEOUT, 225 asd_ddbsite_write_word(asd_ha, ddb, ITNL_TIMEOUT,
@@ -328,10 +328,10 @@ int asd_dev_found(struct domain_device *dev)
328 328
329 spin_lock_irqsave(&asd_ha->hw_prof.ddb_lock, flags); 329 spin_lock_irqsave(&asd_ha->hw_prof.ddb_lock, flags);
330 switch (dev->dev_type) { 330 switch (dev->dev_type) {
331 case SATA_PM: 331 case SAS_SATA_PM:
332 res = asd_init_sata_pm_ddb(dev); 332 res = asd_init_sata_pm_ddb(dev);
333 break; 333 break;
334 case SATA_PM_PORT: 334 case SAS_SATA_PM_PORT:
335 res = asd_init_sata_pm_port_ddb(dev); 335 res = asd_init_sata_pm_port_ddb(dev);
336 break; 336 break;
337 default: 337 default:
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 81b736c76fff..4df867e07b20 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -74,7 +74,7 @@ static void asd_init_phy_identify(struct asd_phy *phy)
74 74
75 memset(phy->identify_frame, 0, sizeof(*phy->identify_frame)); 75 memset(phy->identify_frame, 0, sizeof(*phy->identify_frame));
76 76
77 phy->identify_frame->dev_type = SAS_END_DEV; 77 phy->identify_frame->dev_type = SAS_END_DEVICE;
78 if (phy->sas_phy.role & PHY_ROLE_INITIATOR) 78 if (phy->sas_phy.role & PHY_ROLE_INITIATOR)
79 phy->identify_frame->initiator_bits = phy->sas_phy.iproto; 79 phy->identify_frame->initiator_bits = phy->sas_phy.iproto;
80 if (phy->sas_phy.role & PHY_ROLE_TARGET) 80 if (phy->sas_phy.role & PHY_ROLE_TARGET)
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
index cf9040933da6..d4c35df3d4ae 100644
--- a/drivers/scsi/aic94xx/aic94xx_tmf.c
+++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
@@ -184,7 +184,7 @@ int asd_I_T_nexus_reset(struct domain_device *dev)
184 struct sas_phy *phy = sas_get_local_phy(dev); 184 struct sas_phy *phy = sas_get_local_phy(dev);
185 /* Standard mandates link reset for ATA (type 0) and 185 /* Standard mandates link reset for ATA (type 0) and
186 * hard reset for SSP (type 1) */ 186 * hard reset for SSP (type 1) */
187 int reset_type = (dev->dev_type == SATA_DEV || 187 int reset_type = (dev->dev_type == SAS_SATA_DEV ||
188 (dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1; 188 (dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
189 189
190 asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE); 190 asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE);
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index c3aa6c5457b9..96a26f454673 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -1085,7 +1085,7 @@ static void sci_remote_device_ready_state_enter(struct sci_base_state_machine *s
1085 struct isci_host *ihost = idev->owning_port->owning_controller; 1085 struct isci_host *ihost = idev->owning_port->owning_controller;
1086 struct domain_device *dev = idev->domain_dev; 1086 struct domain_device *dev = idev->domain_dev;
1087 1087
1088 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { 1088 if (dev->dev_type == SAS_SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) {
1089 sci_change_state(&idev->sm, SCI_STP_DEV_IDLE); 1089 sci_change_state(&idev->sm, SCI_STP_DEV_IDLE);
1090 } else if (dev_is_expander(dev)) { 1090 } else if (dev_is_expander(dev)) {
1091 sci_change_state(&idev->sm, SCI_SMP_DEV_IDLE); 1091 sci_change_state(&idev->sm, SCI_SMP_DEV_IDLE);
@@ -1098,7 +1098,7 @@ static void sci_remote_device_ready_state_exit(struct sci_base_state_machine *sm
1098 struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); 1098 struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
1099 struct domain_device *dev = idev->domain_dev; 1099 struct domain_device *dev = idev->domain_dev;
1100 1100
1101 if (dev->dev_type == SAS_END_DEV) { 1101 if (dev->dev_type == SAS_END_DEVICE) {
1102 struct isci_host *ihost = idev->owning_port->owning_controller; 1102 struct isci_host *ihost = idev->owning_port->owning_controller;
1103 1103
1104 isci_remote_device_not_ready(ihost, idev, 1104 isci_remote_device_not_ready(ihost, idev,
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h
index 7674caae1d88..47a013fffae7 100644
--- a/drivers/scsi/isci/remote_device.h
+++ b/drivers/scsi/isci/remote_device.h
@@ -297,7 +297,7 @@ static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_conte
297 297
298static inline bool dev_is_expander(struct domain_device *dev) 298static inline bool dev_is_expander(struct domain_device *dev)
299{ 299{
300 return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV; 300 return dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE;
301} 301}
302 302
303static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev) 303static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev)
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 9594ab62702b..e3e3bcbd5a9f 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2978,7 +2978,7 @@ static void sci_request_started_state_enter(struct sci_base_state_machine *sm)
2978 /* all unaccelerated request types (non ssp or ncq) handled with 2978 /* all unaccelerated request types (non ssp or ncq) handled with
2979 * substates 2979 * substates
2980 */ 2980 */
2981 if (!task && dev->dev_type == SAS_END_DEV) { 2981 if (!task && dev->dev_type == SAS_END_DEVICE) {
2982 state = SCI_REQ_TASK_WAIT_TC_COMP; 2982 state = SCI_REQ_TASK_WAIT_TC_COMP;
2983 } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { 2983 } else if (task && task->task_proto == SAS_PROTOCOL_SMP) {
2984 state = SCI_REQ_SMP_WAIT_RESP; 2984 state = SCI_REQ_SMP_WAIT_RESP;
@@ -3101,7 +3101,7 @@ sci_io_request_construct(struct isci_host *ihost,
3101 if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) 3101 if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
3102 return SCI_FAILURE_INVALID_REMOTE_DEVICE; 3102 return SCI_FAILURE_INVALID_REMOTE_DEVICE;
3103 3103
3104 if (dev->dev_type == SAS_END_DEV) 3104 if (dev->dev_type == SAS_END_DEVICE)
3105 /* pass */; 3105 /* pass */;
3106 else if (dev_is_sata(dev)) 3106 else if (dev_is_sata(dev))
3107 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); 3107 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd));
@@ -3125,7 +3125,7 @@ enum sci_status sci_task_request_construct(struct isci_host *ihost,
3125 /* Build the common part of the request */ 3125 /* Build the common part of the request */
3126 sci_general_request_construct(ihost, idev, ireq); 3126 sci_general_request_construct(ihost, idev, ireq);
3127 3127
3128 if (dev->dev_type == SAS_END_DEV || dev_is_sata(dev)) { 3128 if (dev->dev_type == SAS_END_DEVICE || dev_is_sata(dev)) {
3129 set_bit(IREQ_TMF, &ireq->flags); 3129 set_bit(IREQ_TMF, &ireq->flags);
3130 memset(ireq->tc, 0, sizeof(struct scu_task_context)); 3130 memset(ireq->tc, 0, sizeof(struct scu_task_context));
3131 3131
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index b6f19a1db780..9bb020ac089c 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -250,7 +250,7 @@ static struct isci_request *isci_task_request_build(struct isci_host *ihost,
250 } 250 }
251 251
252 /* XXX convert to get this from task->tproto like other drivers */ 252 /* XXX convert to get this from task->tproto like other drivers */
253 if (dev->dev_type == SAS_END_DEV) { 253 if (dev->dev_type == SAS_END_DEVICE) {
254 isci_tmf->proto = SAS_PROTOCOL_SSP; 254 isci_tmf->proto = SAS_PROTOCOL_SSP;
255 status = sci_task_request_construct_ssp(ireq); 255 status = sci_task_request_construct_ssp(ireq);
256 if (status != SCI_SUCCESS) 256 if (status != SCI_SUCCESS)
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index bdb81cda8401..161c98efade9 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -285,14 +285,14 @@ int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
285 if (phy->attached_tproto & SAS_PROTOCOL_STP) 285 if (phy->attached_tproto & SAS_PROTOCOL_STP)
286 dev->tproto = phy->attached_tproto; 286 dev->tproto = phy->attached_tproto;
287 if (phy->attached_sata_dev) 287 if (phy->attached_sata_dev)
288 dev->tproto |= SATA_DEV; 288 dev->tproto |= SAS_SATA_DEV;
289 289
290 if (phy->attached_dev_type == SATA_PENDING) 290 if (phy->attached_dev_type == SAS_SATA_PENDING)
291 dev->dev_type = SATA_PENDING; 291 dev->dev_type = SAS_SATA_PENDING;
292 else { 292 else {
293 int res; 293 int res;
294 294
295 dev->dev_type = SATA_DEV; 295 dev->dev_type = SAS_SATA_DEV;
296 res = sas_get_report_phy_sata(dev->parent, phy->phy_id, 296 res = sas_get_report_phy_sata(dev->parent, phy->phy_id,
297 &dev->sata_dev.rps_resp); 297 &dev->sata_dev.rps_resp);
298 if (res) { 298 if (res) {
@@ -314,7 +314,7 @@ static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy)
314 int res; 314 int res;
315 315
316 /* we weren't pending, so successfully end the reset sequence now */ 316 /* we weren't pending, so successfully end the reset sequence now */
317 if (dev->dev_type != SATA_PENDING) 317 if (dev->dev_type != SAS_SATA_PENDING)
318 return 1; 318 return 1;
319 319
320 /* hmmm, if this succeeds do we need to repost the domain_device to the 320 /* hmmm, if this succeeds do we need to repost the domain_device to the
@@ -348,9 +348,9 @@ static int smp_ata_check_ready(struct ata_link *link)
348 return 0; 348 return 0;
349 349
350 switch (ex_phy->attached_dev_type) { 350 switch (ex_phy->attached_dev_type) {
351 case SATA_PENDING: 351 case SAS_SATA_PENDING:
352 return 0; 352 return 0;
353 case SAS_END_DEV: 353 case SAS_END_DEVICE:
354 if (ex_phy->attached_sata_dev) 354 if (ex_phy->attached_sata_dev)
355 return sas_ata_clear_pending(dev, ex_phy); 355 return sas_ata_clear_pending(dev, ex_phy);
356 default: 356 default:
@@ -631,7 +631,7 @@ static void sas_get_ata_command_set(struct domain_device *dev)
631 struct dev_to_host_fis *fis = 631 struct dev_to_host_fis *fis =
632 (struct dev_to_host_fis *) dev->frame_rcvd; 632 (struct dev_to_host_fis *) dev->frame_rcvd;
633 633
634 if (dev->dev_type == SATA_PENDING) 634 if (dev->dev_type == SAS_SATA_PENDING)
635 return; 635 return;
636 636
637 if ((fis->sector_count == 1 && /* ATA */ 637 if ((fis->sector_count == 1 && /* ATA */
@@ -797,7 +797,7 @@ int sas_discover_sata(struct domain_device *dev)
797{ 797{
798 int res; 798 int res;
799 799
800 if (dev->dev_type == SATA_PM) 800 if (dev->dev_type == SAS_SATA_PM)
801 return -ENODEV; 801 return -ENODEV;
802 802
803 sas_get_ata_command_set(dev); 803 sas_get_ata_command_set(dev);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index a0c3003e0c7d..62b58d38ce2e 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -39,11 +39,11 @@
39void sas_init_dev(struct domain_device *dev) 39void sas_init_dev(struct domain_device *dev)
40{ 40{
41 switch (dev->dev_type) { 41 switch (dev->dev_type) {
42 case SAS_END_DEV: 42 case SAS_END_DEVICE:
43 INIT_LIST_HEAD(&dev->ssp_dev.eh_list_node); 43 INIT_LIST_HEAD(&dev->ssp_dev.eh_list_node);
44 break; 44 break;
45 case EDGE_DEV: 45 case SAS_EDGE_EXPANDER_DEVICE:
46 case FANOUT_DEV: 46 case SAS_FANOUT_EXPANDER_DEVICE:
47 INIT_LIST_HEAD(&dev->ex_dev.children); 47 INIT_LIST_HEAD(&dev->ex_dev.children);
48 mutex_init(&dev->ex_dev.cmd_mutex); 48 mutex_init(&dev->ex_dev.cmd_mutex);
49 break; 49 break;
@@ -93,9 +93,9 @@ static int sas_get_port_device(struct asd_sas_port *port)
93 if (fis->interrupt_reason == 1 && fis->lbal == 1 && 93 if (fis->interrupt_reason == 1 && fis->lbal == 1 &&
94 fis->byte_count_low==0x69 && fis->byte_count_high == 0x96 94 fis->byte_count_low==0x69 && fis->byte_count_high == 0x96
95 && (fis->device & ~0x10) == 0) 95 && (fis->device & ~0x10) == 0)
96 dev->dev_type = SATA_PM; 96 dev->dev_type = SAS_SATA_PM;
97 else 97 else
98 dev->dev_type = SATA_DEV; 98 dev->dev_type = SAS_SATA_DEV;
99 dev->tproto = SAS_PROTOCOL_SATA; 99 dev->tproto = SAS_PROTOCOL_SATA;
100 } else { 100 } else {
101 struct sas_identify_frame *id = 101 struct sas_identify_frame *id =
@@ -109,21 +109,21 @@ static int sas_get_port_device(struct asd_sas_port *port)
109 109
110 dev->port = port; 110 dev->port = port;
111 switch (dev->dev_type) { 111 switch (dev->dev_type) {
112 case SATA_DEV: 112 case SAS_SATA_DEV:
113 rc = sas_ata_init(dev); 113 rc = sas_ata_init(dev);
114 if (rc) { 114 if (rc) {
115 rphy = NULL; 115 rphy = NULL;
116 break; 116 break;
117 } 117 }
118 /* fall through */ 118 /* fall through */
119 case SAS_END_DEV: 119 case SAS_END_DEVICE:
120 rphy = sas_end_device_alloc(port->port); 120 rphy = sas_end_device_alloc(port->port);
121 break; 121 break;
122 case EDGE_DEV: 122 case SAS_EDGE_EXPANDER_DEVICE:
123 rphy = sas_expander_alloc(port->port, 123 rphy = sas_expander_alloc(port->port,
124 SAS_EDGE_EXPANDER_DEVICE); 124 SAS_EDGE_EXPANDER_DEVICE);
125 break; 125 break;
126 case FANOUT_DEV: 126 case SAS_FANOUT_EXPANDER_DEVICE:
127 rphy = sas_expander_alloc(port->port, 127 rphy = sas_expander_alloc(port->port,
128 SAS_FANOUT_EXPANDER_DEVICE); 128 SAS_FANOUT_EXPANDER_DEVICE);
129 break; 129 break;
@@ -156,7 +156,7 @@ static int sas_get_port_device(struct asd_sas_port *port)
156 dev->rphy = rphy; 156 dev->rphy = rphy;
157 get_device(&dev->rphy->dev); 157 get_device(&dev->rphy->dev);
158 158
159 if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEV) 159 if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEVICE)
160 list_add_tail(&dev->disco_list_node, &port->disco_list); 160 list_add_tail(&dev->disco_list_node, &port->disco_list);
161 else { 161 else {
162 spin_lock_irq(&port->dev_list_lock); 162 spin_lock_irq(&port->dev_list_lock);
@@ -315,7 +315,7 @@ void sas_free_device(struct kref *kref)
315 dev->phy = NULL; 315 dev->phy = NULL;
316 316
317 /* remove the phys and ports, everything else should be gone */ 317 /* remove the phys and ports, everything else should be gone */
318 if (dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV) 318 if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
319 kfree(dev->ex_dev.ex_phy); 319 kfree(dev->ex_dev.ex_phy);
320 320
321 if (dev_is_sata(dev) && dev->sata_dev.ap) { 321 if (dev_is_sata(dev) && dev->sata_dev.ap) {
@@ -343,7 +343,7 @@ static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_d
343 spin_unlock_irq(&port->dev_list_lock); 343 spin_unlock_irq(&port->dev_list_lock);
344 344
345 spin_lock_irq(&ha->lock); 345 spin_lock_irq(&ha->lock);
346 if (dev->dev_type == SAS_END_DEV && 346 if (dev->dev_type == SAS_END_DEVICE &&
347 !list_empty(&dev->ssp_dev.eh_list_node)) { 347 !list_empty(&dev->ssp_dev.eh_list_node)) {
348 list_del_init(&dev->ssp_dev.eh_list_node); 348 list_del_init(&dev->ssp_dev.eh_list_node);
349 ha->eh_active--; 349 ha->eh_active--;
@@ -457,15 +457,15 @@ static void sas_discover_domain(struct work_struct *work)
457 task_pid_nr(current)); 457 task_pid_nr(current));
458 458
459 switch (dev->dev_type) { 459 switch (dev->dev_type) {
460 case SAS_END_DEV: 460 case SAS_END_DEVICE:
461 error = sas_discover_end_dev(dev); 461 error = sas_discover_end_dev(dev);
462 break; 462 break;
463 case EDGE_DEV: 463 case SAS_EDGE_EXPANDER_DEVICE:
464 case FANOUT_DEV: 464 case SAS_FANOUT_EXPANDER_DEVICE:
465 error = sas_discover_root_expander(dev); 465 error = sas_discover_root_expander(dev);
466 break; 466 break;
467 case SATA_DEV: 467 case SAS_SATA_DEV:
468 case SATA_PM: 468 case SAS_SATA_PM:
469#ifdef CONFIG_SCSI_SAS_ATA 469#ifdef CONFIG_SCSI_SAS_ATA
470 error = sas_discover_sata(dev); 470 error = sas_discover_sata(dev);
471 break; 471 break;
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 55cbd0180159..74cc4a02092e 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -183,21 +183,21 @@ static char sas_route_char(struct domain_device *dev, struct ex_phy *phy)
183 } 183 }
184} 184}
185 185
186static enum sas_dev_type to_dev_type(struct discover_resp *dr) 186static enum sas_device_type to_dev_type(struct discover_resp *dr)
187{ 187{
188 /* This is detecting a failure to transmit initial dev to host 188 /* This is detecting a failure to transmit initial dev to host
189 * FIS as described in section J.5 of sas-2 r16 189 * FIS as described in section J.5 of sas-2 r16
190 */ 190 */
191 if (dr->attached_dev_type == NO_DEVICE && dr->attached_sata_dev && 191 if (dr->attached_dev_type == SAS_PHY_UNUSED && dr->attached_sata_dev &&
192 dr->linkrate >= SAS_LINK_RATE_1_5_GBPS) 192 dr->linkrate >= SAS_LINK_RATE_1_5_GBPS)
193 return SATA_PENDING; 193 return SAS_SATA_PENDING;
194 else 194 else
195 return dr->attached_dev_type; 195 return dr->attached_dev_type;
196} 196}
197 197
198static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) 198static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
199{ 199{
200 enum sas_dev_type dev_type; 200 enum sas_device_type dev_type;
201 enum sas_linkrate linkrate; 201 enum sas_linkrate linkrate;
202 u8 sas_addr[SAS_ADDR_SIZE]; 202 u8 sas_addr[SAS_ADDR_SIZE];
203 struct smp_resp *resp = rsp; 203 struct smp_resp *resp = rsp;
@@ -238,7 +238,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
238 /* Handle vacant phy - rest of dr data is not valid so skip it */ 238 /* Handle vacant phy - rest of dr data is not valid so skip it */
239 if (phy->phy_state == PHY_VACANT) { 239 if (phy->phy_state == PHY_VACANT) {
240 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 240 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
241 phy->attached_dev_type = NO_DEVICE; 241 phy->attached_dev_type = SAS_PHY_UNUSED;
242 if (!test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)) { 242 if (!test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)) {
243 phy->phy_id = phy_id; 243 phy->phy_id = phy_id;
244 goto skip; 244 goto skip;
@@ -259,7 +259,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
259 /* help some expanders that fail to zero sas_address in the 'no 259 /* help some expanders that fail to zero sas_address in the 'no
260 * device' case 260 * device' case
261 */ 261 */
262 if (phy->attached_dev_type == NO_DEVICE || 262 if (phy->attached_dev_type == SAS_PHY_UNUSED ||
263 phy->linkrate < SAS_LINK_RATE_1_5_GBPS) 263 phy->linkrate < SAS_LINK_RATE_1_5_GBPS)
264 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 264 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
265 else 265 else
@@ -292,13 +292,13 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
292 292
293 out: 293 out:
294 switch (phy->attached_dev_type) { 294 switch (phy->attached_dev_type) {
295 case SATA_PENDING: 295 case SAS_SATA_PENDING:
296 type = "stp pending"; 296 type = "stp pending";
297 break; 297 break;
298 case NO_DEVICE: 298 case SAS_PHY_UNUSED:
299 type = "no device"; 299 type = "no device";
300 break; 300 break;
301 case SAS_END_DEV: 301 case SAS_END_DEVICE:
302 if (phy->attached_iproto) { 302 if (phy->attached_iproto) {
303 if (phy->attached_tproto) 303 if (phy->attached_tproto)
304 type = "host+target"; 304 type = "host+target";
@@ -311,8 +311,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
311 type = "ssp"; 311 type = "ssp";
312 } 312 }
313 break; 313 break;
314 case EDGE_DEV: 314 case SAS_EDGE_EXPANDER_DEVICE:
315 case FANOUT_DEV: 315 case SAS_FANOUT_EXPANDER_DEVICE:
316 type = "smp"; 316 type = "smp";
317 break; 317 break;
318 default: 318 default:
@@ -833,7 +833,7 @@ static struct domain_device *sas_ex_discover_end_dev(
833 } else 833 } else
834#endif 834#endif
835 if (phy->attached_tproto & SAS_PROTOCOL_SSP) { 835 if (phy->attached_tproto & SAS_PROTOCOL_SSP) {
836 child->dev_type = SAS_END_DEV; 836 child->dev_type = SAS_END_DEVICE;
837 rphy = sas_end_device_alloc(phy->port); 837 rphy = sas_end_device_alloc(phy->port);
838 /* FIXME: error handling */ 838 /* FIXME: error handling */
839 if (unlikely(!rphy)) 839 if (unlikely(!rphy))
@@ -932,11 +932,11 @@ static struct domain_device *sas_ex_discover_expander(
932 932
933 933
934 switch (phy->attached_dev_type) { 934 switch (phy->attached_dev_type) {
935 case EDGE_DEV: 935 case SAS_EDGE_EXPANDER_DEVICE:
936 rphy = sas_expander_alloc(phy->port, 936 rphy = sas_expander_alloc(phy->port,
937 SAS_EDGE_EXPANDER_DEVICE); 937 SAS_EDGE_EXPANDER_DEVICE);
938 break; 938 break;
939 case FANOUT_DEV: 939 case SAS_FANOUT_EXPANDER_DEVICE:
940 rphy = sas_expander_alloc(phy->port, 940 rphy = sas_expander_alloc(phy->port,
941 SAS_FANOUT_EXPANDER_DEVICE); 941 SAS_FANOUT_EXPANDER_DEVICE);
942 break; 942 break;
@@ -1013,7 +1013,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
1013 if (sas_dev_present_in_domain(dev->port, ex_phy->attached_sas_addr)) 1013 if (sas_dev_present_in_domain(dev->port, ex_phy->attached_sas_addr))
1014 sas_ex_disable_port(dev, ex_phy->attached_sas_addr); 1014 sas_ex_disable_port(dev, ex_phy->attached_sas_addr);
1015 1015
1016 if (ex_phy->attached_dev_type == NO_DEVICE) { 1016 if (ex_phy->attached_dev_type == SAS_PHY_UNUSED) {
1017 if (ex_phy->routing_attr == DIRECT_ROUTING) { 1017 if (ex_phy->routing_attr == DIRECT_ROUTING) {
1018 memset(ex_phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 1018 memset(ex_phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
1019 sas_configure_routing(dev, ex_phy->attached_sas_addr); 1019 sas_configure_routing(dev, ex_phy->attached_sas_addr);
@@ -1022,10 +1022,10 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
1022 } else if (ex_phy->linkrate == SAS_LINK_RATE_UNKNOWN) 1022 } else if (ex_phy->linkrate == SAS_LINK_RATE_UNKNOWN)
1023 return 0; 1023 return 0;
1024 1024
1025 if (ex_phy->attached_dev_type != SAS_END_DEV && 1025 if (ex_phy->attached_dev_type != SAS_END_DEVICE &&
1026 ex_phy->attached_dev_type != FANOUT_DEV && 1026 ex_phy->attached_dev_type != SAS_FANOUT_EXPANDER_DEVICE &&
1027 ex_phy->attached_dev_type != EDGE_DEV && 1027 ex_phy->attached_dev_type != SAS_EDGE_EXPANDER_DEVICE &&
1028 ex_phy->attached_dev_type != SATA_PENDING) { 1028 ex_phy->attached_dev_type != SAS_SATA_PENDING) {
1029 SAS_DPRINTK("unknown device type(0x%x) attached to ex %016llx " 1029 SAS_DPRINTK("unknown device type(0x%x) attached to ex %016llx "
1030 "phy 0x%x\n", ex_phy->attached_dev_type, 1030 "phy 0x%x\n", ex_phy->attached_dev_type,
1031 SAS_ADDR(dev->sas_addr), 1031 SAS_ADDR(dev->sas_addr),
@@ -1049,11 +1049,11 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
1049 } 1049 }
1050 1050
1051 switch (ex_phy->attached_dev_type) { 1051 switch (ex_phy->attached_dev_type) {
1052 case SAS_END_DEV: 1052 case SAS_END_DEVICE:
1053 case SATA_PENDING: 1053 case SAS_SATA_PENDING:
1054 child = sas_ex_discover_end_dev(dev, phy_id); 1054 child = sas_ex_discover_end_dev(dev, phy_id);
1055 break; 1055 break;
1056 case FANOUT_DEV: 1056 case SAS_FANOUT_EXPANDER_DEVICE:
1057 if (SAS_ADDR(dev->port->disc.fanout_sas_addr)) { 1057 if (SAS_ADDR(dev->port->disc.fanout_sas_addr)) {
1058 SAS_DPRINTK("second fanout expander %016llx phy 0x%x " 1058 SAS_DPRINTK("second fanout expander %016llx phy 0x%x "
1059 "attached to ex %016llx phy 0x%x\n", 1059 "attached to ex %016llx phy 0x%x\n",
@@ -1067,7 +1067,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
1067 memcpy(dev->port->disc.fanout_sas_addr, 1067 memcpy(dev->port->disc.fanout_sas_addr,
1068 ex_phy->attached_sas_addr, SAS_ADDR_SIZE); 1068 ex_phy->attached_sas_addr, SAS_ADDR_SIZE);
1069 /* fallthrough */ 1069 /* fallthrough */
1070 case EDGE_DEV: 1070 case SAS_EDGE_EXPANDER_DEVICE:
1071 child = sas_ex_discover_expander(dev, phy_id); 1071 child = sas_ex_discover_expander(dev, phy_id);
1072 break; 1072 break;
1073 default: 1073 default:
@@ -1111,8 +1111,8 @@ static int sas_find_sub_addr(struct domain_device *dev, u8 *sub_addr)
1111 phy->phy_state == PHY_NOT_PRESENT) 1111 phy->phy_state == PHY_NOT_PRESENT)
1112 continue; 1112 continue;
1113 1113
1114 if ((phy->attached_dev_type == EDGE_DEV || 1114 if ((phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE ||
1115 phy->attached_dev_type == FANOUT_DEV) && 1115 phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE) &&
1116 phy->routing_attr == SUBTRACTIVE_ROUTING) { 1116 phy->routing_attr == SUBTRACTIVE_ROUTING) {
1117 1117
1118 memcpy(sub_addr, phy->attached_sas_addr,SAS_ADDR_SIZE); 1118 memcpy(sub_addr, phy->attached_sas_addr,SAS_ADDR_SIZE);
@@ -1130,8 +1130,8 @@ static int sas_check_level_subtractive_boundary(struct domain_device *dev)
1130 u8 sub_addr[8] = {0, }; 1130 u8 sub_addr[8] = {0, };
1131 1131
1132 list_for_each_entry(child, &ex->children, siblings) { 1132 list_for_each_entry(child, &ex->children, siblings) {
1133 if (child->dev_type != EDGE_DEV && 1133 if (child->dev_type != SAS_EDGE_EXPANDER_DEVICE &&
1134 child->dev_type != FANOUT_DEV) 1134 child->dev_type != SAS_FANOUT_EXPANDER_DEVICE)
1135 continue; 1135 continue;
1136 if (sub_addr[0] == 0) { 1136 if (sub_addr[0] == 0) {
1137 sas_find_sub_addr(child, sub_addr); 1137 sas_find_sub_addr(child, sub_addr);
@@ -1208,7 +1208,7 @@ static int sas_check_ex_subtractive_boundary(struct domain_device *dev)
1208 int i; 1208 int i;
1209 u8 *sub_sas_addr = NULL; 1209 u8 *sub_sas_addr = NULL;
1210 1210
1211 if (dev->dev_type != EDGE_DEV) 1211 if (dev->dev_type != SAS_EDGE_EXPANDER_DEVICE)
1212 return 0; 1212 return 0;
1213 1213
1214 for (i = 0; i < ex->num_phys; i++) { 1214 for (i = 0; i < ex->num_phys; i++) {
@@ -1218,8 +1218,8 @@ static int sas_check_ex_subtractive_boundary(struct domain_device *dev)
1218 phy->phy_state == PHY_NOT_PRESENT) 1218 phy->phy_state == PHY_NOT_PRESENT)
1219 continue; 1219 continue;
1220 1220
1221 if ((phy->attached_dev_type == FANOUT_DEV || 1221 if ((phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE ||
1222 phy->attached_dev_type == EDGE_DEV) && 1222 phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE) &&
1223 phy->routing_attr == SUBTRACTIVE_ROUTING) { 1223 phy->routing_attr == SUBTRACTIVE_ROUTING) {
1224 1224
1225 if (!sub_sas_addr) 1225 if (!sub_sas_addr)
@@ -1245,8 +1245,8 @@ static void sas_print_parent_topology_bug(struct domain_device *child,
1245 struct ex_phy *child_phy) 1245 struct ex_phy *child_phy)
1246{ 1246{
1247 static const char *ex_type[] = { 1247 static const char *ex_type[] = {
1248 [EDGE_DEV] = "edge", 1248 [SAS_EDGE_EXPANDER_DEVICE] = "edge",
1249 [FANOUT_DEV] = "fanout", 1249 [SAS_FANOUT_EXPANDER_DEVICE] = "fanout",
1250 }; 1250 };
1251 struct domain_device *parent = child->parent; 1251 struct domain_device *parent = child->parent;
1252 1252
@@ -1321,8 +1321,8 @@ static int sas_check_parent_topology(struct domain_device *child)
1321 if (!child->parent) 1321 if (!child->parent)
1322 return 0; 1322 return 0;
1323 1323
1324 if (child->parent->dev_type != EDGE_DEV && 1324 if (child->parent->dev_type != SAS_EDGE_EXPANDER_DEVICE &&
1325 child->parent->dev_type != FANOUT_DEV) 1325 child->parent->dev_type != SAS_FANOUT_EXPANDER_DEVICE)
1326 return 0; 1326 return 0;
1327 1327
1328 parent_ex = &child->parent->ex_dev; 1328 parent_ex = &child->parent->ex_dev;
@@ -1341,8 +1341,8 @@ static int sas_check_parent_topology(struct domain_device *child)
1341 child_phy = &child_ex->ex_phy[parent_phy->attached_phy_id]; 1341 child_phy = &child_ex->ex_phy[parent_phy->attached_phy_id];
1342 1342
1343 switch (child->parent->dev_type) { 1343 switch (child->parent->dev_type) {
1344 case EDGE_DEV: 1344 case SAS_EDGE_EXPANDER_DEVICE:
1345 if (child->dev_type == FANOUT_DEV) { 1345 if (child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) {
1346 if (parent_phy->routing_attr != SUBTRACTIVE_ROUTING || 1346 if (parent_phy->routing_attr != SUBTRACTIVE_ROUTING ||
1347 child_phy->routing_attr != TABLE_ROUTING) { 1347 child_phy->routing_attr != TABLE_ROUTING) {
1348 sas_print_parent_topology_bug(child, parent_phy, child_phy); 1348 sas_print_parent_topology_bug(child, parent_phy, child_phy);
@@ -1366,7 +1366,7 @@ static int sas_check_parent_topology(struct domain_device *child)
1366 } 1366 }
1367 } 1367 }
1368 break; 1368 break;
1369 case FANOUT_DEV: 1369 case SAS_FANOUT_EXPANDER_DEVICE:
1370 if (parent_phy->routing_attr != TABLE_ROUTING || 1370 if (parent_phy->routing_attr != TABLE_ROUTING ||
1371 child_phy->routing_attr != SUBTRACTIVE_ROUTING) { 1371 child_phy->routing_attr != SUBTRACTIVE_ROUTING) {
1372 sas_print_parent_topology_bug(child, parent_phy, child_phy); 1372 sas_print_parent_topology_bug(child, parent_phy, child_phy);
@@ -1619,8 +1619,8 @@ static int sas_ex_level_discovery(struct asd_sas_port *port, const int level)
1619 struct domain_device *dev; 1619 struct domain_device *dev;
1620 1620
1621 list_for_each_entry(dev, &port->dev_list, dev_list_node) { 1621 list_for_each_entry(dev, &port->dev_list, dev_list_node) {
1622 if (dev->dev_type == EDGE_DEV || 1622 if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
1623 dev->dev_type == FANOUT_DEV) { 1623 dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) {
1624 struct sas_expander_device *ex = 1624 struct sas_expander_device *ex =
1625 rphy_to_expander_device(dev->rphy); 1625 rphy_to_expander_device(dev->rphy);
1626 1626
@@ -1720,7 +1720,7 @@ static int sas_get_phy_change_count(struct domain_device *dev,
1720} 1720}
1721 1721
1722static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, 1722static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
1723 u8 *sas_addr, enum sas_dev_type *type) 1723 u8 *sas_addr, enum sas_device_type *type)
1724{ 1724{
1725 int res; 1725 int res;
1726 struct smp_resp *disc_resp; 1726 struct smp_resp *disc_resp;
@@ -1849,7 +1849,7 @@ static int sas_find_bcast_dev(struct domain_device *dev,
1849 SAS_DPRINTK("Expander phys DID NOT change\n"); 1849 SAS_DPRINTK("Expander phys DID NOT change\n");
1850 } 1850 }
1851 list_for_each_entry(ch, &ex->children, siblings) { 1851 list_for_each_entry(ch, &ex->children, siblings) {
1852 if (ch->dev_type == EDGE_DEV || ch->dev_type == FANOUT_DEV) { 1852 if (ch->dev_type == SAS_EDGE_EXPANDER_DEVICE || ch->dev_type == SAS_FANOUT_EXPANDER_DEVICE) {
1853 res = sas_find_bcast_dev(ch, src_dev); 1853 res = sas_find_bcast_dev(ch, src_dev);
1854 if (*src_dev) 1854 if (*src_dev)
1855 return res; 1855 return res;
@@ -1866,8 +1866,8 @@ static void sas_unregister_ex_tree(struct asd_sas_port *port, struct domain_devi
1866 1866
1867 list_for_each_entry_safe(child, n, &ex->children, siblings) { 1867 list_for_each_entry_safe(child, n, &ex->children, siblings) {
1868 set_bit(SAS_DEV_GONE, &child->state); 1868 set_bit(SAS_DEV_GONE, &child->state);
1869 if (child->dev_type == EDGE_DEV || 1869 if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
1870 child->dev_type == FANOUT_DEV) 1870 child->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
1871 sas_unregister_ex_tree(port, child); 1871 sas_unregister_ex_tree(port, child);
1872 else 1872 else
1873 sas_unregister_dev(port, child); 1873 sas_unregister_dev(port, child);
@@ -1887,8 +1887,8 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,
1887 if (SAS_ADDR(child->sas_addr) == 1887 if (SAS_ADDR(child->sas_addr) ==
1888 SAS_ADDR(phy->attached_sas_addr)) { 1888 SAS_ADDR(phy->attached_sas_addr)) {
1889 set_bit(SAS_DEV_GONE, &child->state); 1889 set_bit(SAS_DEV_GONE, &child->state);
1890 if (child->dev_type == EDGE_DEV || 1890 if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
1891 child->dev_type == FANOUT_DEV) 1891 child->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
1892 sas_unregister_ex_tree(parent->port, child); 1892 sas_unregister_ex_tree(parent->port, child);
1893 else 1893 else
1894 sas_unregister_dev(parent->port, child); 1894 sas_unregister_dev(parent->port, child);
@@ -1916,8 +1916,8 @@ static int sas_discover_bfs_by_root_level(struct domain_device *root,
1916 int res = 0; 1916 int res = 0;
1917 1917
1918 list_for_each_entry(child, &ex_root->children, siblings) { 1918 list_for_each_entry(child, &ex_root->children, siblings) {
1919 if (child->dev_type == EDGE_DEV || 1919 if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
1920 child->dev_type == FANOUT_DEV) { 1920 child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) {
1921 struct sas_expander_device *ex = 1921 struct sas_expander_device *ex =
1922 rphy_to_expander_device(child->rphy); 1922 rphy_to_expander_device(child->rphy);
1923 1923
@@ -1970,8 +1970,8 @@ static int sas_discover_new(struct domain_device *dev, int phy_id)
1970 list_for_each_entry(child, &dev->ex_dev.children, siblings) { 1970 list_for_each_entry(child, &dev->ex_dev.children, siblings) {
1971 if (SAS_ADDR(child->sas_addr) == 1971 if (SAS_ADDR(child->sas_addr) ==
1972 SAS_ADDR(ex_phy->attached_sas_addr)) { 1972 SAS_ADDR(ex_phy->attached_sas_addr)) {
1973 if (child->dev_type == EDGE_DEV || 1973 if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
1974 child->dev_type == FANOUT_DEV) 1974 child->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
1975 res = sas_discover_bfs_by_root(child); 1975 res = sas_discover_bfs_by_root(child);
1976 break; 1976 break;
1977 } 1977 }
@@ -1979,16 +1979,16 @@ static int sas_discover_new(struct domain_device *dev, int phy_id)
1979 return res; 1979 return res;
1980} 1980}
1981 1981
1982static bool dev_type_flutter(enum sas_dev_type new, enum sas_dev_type old) 1982static bool dev_type_flutter(enum sas_device_type new, enum sas_device_type old)
1983{ 1983{
1984 if (old == new) 1984 if (old == new)
1985 return true; 1985 return true;
1986 1986
1987 /* treat device directed resets as flutter, if we went 1987 /* treat device directed resets as flutter, if we went
1988 * SAS_END_DEV to SATA_PENDING the link needs recovery 1988 * SAS_END_DEVICE to SAS_SATA_PENDING the link needs recovery
1989 */ 1989 */
1990 if ((old == SATA_PENDING && new == SAS_END_DEV) || 1990 if ((old == SAS_SATA_PENDING && new == SAS_END_DEVICE) ||
1991 (old == SAS_END_DEV && new == SATA_PENDING)) 1991 (old == SAS_END_DEVICE && new == SAS_SATA_PENDING))
1992 return true; 1992 return true;
1993 1993
1994 return false; 1994 return false;
@@ -1998,7 +1998,7 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
1998{ 1998{
1999 struct expander_device *ex = &dev->ex_dev; 1999 struct expander_device *ex = &dev->ex_dev;
2000 struct ex_phy *phy = &ex->ex_phy[phy_id]; 2000 struct ex_phy *phy = &ex->ex_phy[phy_id];
2001 enum sas_dev_type type = NO_DEVICE; 2001 enum sas_device_type type = SAS_PHY_UNUSED;
2002 u8 sas_addr[8]; 2002 u8 sas_addr[8];
2003 int res; 2003 int res;
2004 2004
@@ -2032,7 +2032,7 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
2032 2032
2033 sas_ex_phy_discover(dev, phy_id); 2033 sas_ex_phy_discover(dev, phy_id);
2034 2034
2035 if (ata_dev && phy->attached_dev_type == SATA_PENDING) 2035 if (ata_dev && phy->attached_dev_type == SAS_SATA_PENDING)
2036 action = ", needs recovery"; 2036 action = ", needs recovery";
2037 SAS_DPRINTK("ex %016llx phy 0x%x broadcast flutter%s\n", 2037 SAS_DPRINTK("ex %016llx phy 0x%x broadcast flutter%s\n",
2038 SAS_ADDR(dev->sas_addr), phy_id, action); 2038 SAS_ADDR(dev->sas_addr), phy_id, action);
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 1de67964e5a1..7e7ba83f0a21 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -131,16 +131,16 @@ static inline void sas_fill_in_rphy(struct domain_device *dev,
131 rphy->identify.initiator_port_protocols = dev->iproto; 131 rphy->identify.initiator_port_protocols = dev->iproto;
132 rphy->identify.target_port_protocols = dev->tproto; 132 rphy->identify.target_port_protocols = dev->tproto;
133 switch (dev->dev_type) { 133 switch (dev->dev_type) {
134 case SATA_DEV: 134 case SAS_SATA_DEV:
135 /* FIXME: need sata device type */ 135 /* FIXME: need sata device type */
136 case SAS_END_DEV: 136 case SAS_END_DEVICE:
137 case SATA_PENDING: 137 case SAS_SATA_PENDING:
138 rphy->identify.device_type = SAS_END_DEVICE; 138 rphy->identify.device_type = SAS_END_DEVICE;
139 break; 139 break;
140 case EDGE_DEV: 140 case SAS_EDGE_EXPANDER_DEVICE:
141 rphy->identify.device_type = SAS_EDGE_EXPANDER_DEVICE; 141 rphy->identify.device_type = SAS_EDGE_EXPANDER_DEVICE;
142 break; 142 break;
143 case FANOUT_DEV: 143 case SAS_FANOUT_EXPANDER_DEVICE:
144 rphy->identify.device_type = SAS_FANOUT_EXPANDER_DEVICE; 144 rphy->identify.device_type = SAS_FANOUT_EXPANDER_DEVICE;
145 break; 145 break;
146 default: 146 default:
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 1398b714c018..d3c5297c6c89 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -69,7 +69,7 @@ static void sas_resume_port(struct asd_sas_phy *phy)
69 continue; 69 continue;
70 } 70 }
71 71
72 if (dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV) { 72 if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) {
73 dev->ex_dev.ex_change_count = -1; 73 dev->ex_dev.ex_change_count = -1;
74 for (i = 0; i < dev->ex_dev.num_phys; i++) { 74 for (i = 0; i < dev->ex_dev.num_phys; i++) {
75 struct ex_phy *phy = &dev->ex_dev.ex_phy[i]; 75 struct ex_phy *phy = &dev->ex_dev.ex_phy[i];
diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 74550922ad55..7b7381d7671f 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -254,7 +254,7 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
254 } 254 }
255 for (i = 0; i < MVS_MAX_DEVICES; i++) { 255 for (i = 0; i < MVS_MAX_DEVICES; i++) {
256 mvi->devices[i].taskfileset = MVS_ID_NOT_MAPPED; 256 mvi->devices[i].taskfileset = MVS_ID_NOT_MAPPED;
257 mvi->devices[i].dev_type = NO_DEVICE; 257 mvi->devices[i].dev_type = SAS_PHY_UNUSED;
258 mvi->devices[i].device_id = i; 258 mvi->devices[i].device_id = i;
259 mvi->devices[i].dev_status = MVS_DEV_NORMAL; 259 mvi->devices[i].dev_status = MVS_DEV_NORMAL;
260 init_timer(&mvi->devices[i].timer); 260 init_timer(&mvi->devices[i].timer);
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 532110f4562a..c9e244984e30 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -706,7 +706,7 @@ static int mvs_task_prep_ssp(struct mvs_info *mvi,
706 return 0; 706 return 0;
707} 707}
708 708
709#define DEV_IS_GONE(mvi_dev) ((!mvi_dev || (mvi_dev->dev_type == NO_DEVICE))) 709#define DEV_IS_GONE(mvi_dev) ((!mvi_dev || (mvi_dev->dev_type == SAS_PHY_UNUSED)))
710static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf, 710static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf,
711 struct mvs_tmf_task *tmf, int *pass) 711 struct mvs_tmf_task *tmf, int *pass)
712{ 712{
@@ -726,7 +726,7 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf
726 * libsas will use dev->port, should 726 * libsas will use dev->port, should
727 * not call task_done for sata 727 * not call task_done for sata
728 */ 728 */
729 if (dev->dev_type != SATA_DEV) 729 if (dev->dev_type != SAS_SATA_DEV)
730 task->task_done(task); 730 task->task_done(task);
731 return rc; 731 return rc;
732 } 732 }
@@ -1159,10 +1159,10 @@ void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st)
1159 phy->identify.device_type = 1159 phy->identify.device_type =
1160 phy->att_dev_info & PORT_DEV_TYPE_MASK; 1160 phy->att_dev_info & PORT_DEV_TYPE_MASK;
1161 1161
1162 if (phy->identify.device_type == SAS_END_DEV) 1162 if (phy->identify.device_type == SAS_END_DEVICE)
1163 phy->identify.target_port_protocols = 1163 phy->identify.target_port_protocols =
1164 SAS_PROTOCOL_SSP; 1164 SAS_PROTOCOL_SSP;
1165 else if (phy->identify.device_type != NO_DEVICE) 1165 else if (phy->identify.device_type != SAS_PHY_UNUSED)
1166 phy->identify.target_port_protocols = 1166 phy->identify.target_port_protocols =
1167 SAS_PROTOCOL_SMP; 1167 SAS_PROTOCOL_SMP;
1168 if (oob_done) 1168 if (oob_done)
@@ -1260,7 +1260,7 @@ struct mvs_device *mvs_alloc_dev(struct mvs_info *mvi)
1260{ 1260{
1261 u32 dev; 1261 u32 dev;
1262 for (dev = 0; dev < MVS_MAX_DEVICES; dev++) { 1262 for (dev = 0; dev < MVS_MAX_DEVICES; dev++) {
1263 if (mvi->devices[dev].dev_type == NO_DEVICE) { 1263 if (mvi->devices[dev].dev_type == SAS_PHY_UNUSED) {
1264 mvi->devices[dev].device_id = dev; 1264 mvi->devices[dev].device_id = dev;
1265 return &mvi->devices[dev]; 1265 return &mvi->devices[dev];
1266 } 1266 }
@@ -1278,7 +1278,7 @@ void mvs_free_dev(struct mvs_device *mvi_dev)
1278 u32 id = mvi_dev->device_id; 1278 u32 id = mvi_dev->device_id;
1279 memset(mvi_dev, 0, sizeof(*mvi_dev)); 1279 memset(mvi_dev, 0, sizeof(*mvi_dev));
1280 mvi_dev->device_id = id; 1280 mvi_dev->device_id = id;
1281 mvi_dev->dev_type = NO_DEVICE; 1281 mvi_dev->dev_type = SAS_PHY_UNUSED;
1282 mvi_dev->dev_status = MVS_DEV_NORMAL; 1282 mvi_dev->dev_status = MVS_DEV_NORMAL;
1283 mvi_dev->taskfileset = MVS_ID_NOT_MAPPED; 1283 mvi_dev->taskfileset = MVS_ID_NOT_MAPPED;
1284} 1284}
@@ -1480,7 +1480,7 @@ static int mvs_debug_I_T_nexus_reset(struct domain_device *dev)
1480{ 1480{
1481 int rc; 1481 int rc;
1482 struct sas_phy *phy = sas_get_local_phy(dev); 1482 struct sas_phy *phy = sas_get_local_phy(dev);
1483 int reset_type = (dev->dev_type == SATA_DEV || 1483 int reset_type = (dev->dev_type == SAS_SATA_DEV ||
1484 (dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1; 1484 (dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
1485 rc = sas_phy_reset(phy, reset_type); 1485 rc = sas_phy_reset(phy, reset_type);
1486 sas_put_local_phy(phy); 1486 sas_put_local_phy(phy);
@@ -1629,7 +1629,7 @@ int mvs_abort_task(struct sas_task *task)
1629 1629
1630 } else if (task->task_proto & SAS_PROTOCOL_SATA || 1630 } else if (task->task_proto & SAS_PROTOCOL_SATA ||
1631 task->task_proto & SAS_PROTOCOL_STP) { 1631 task->task_proto & SAS_PROTOCOL_STP) {
1632 if (SATA_DEV == dev->dev_type) { 1632 if (SAS_SATA_DEV == dev->dev_type) {
1633 struct mvs_slot_info *slot = task->lldd_task; 1633 struct mvs_slot_info *slot = task->lldd_task;
1634 u32 slot_idx = (u32)(slot - mvi->slot_info); 1634 u32 slot_idx = (u32)(slot - mvi->slot_info);
1635 mv_dprintk("mvs_abort_task() mvi=%p task=%p " 1635 mv_dprintk("mvs_abort_task() mvi=%p task=%p "
diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
index 9f3cc13a5ce7..60e2fb7f2dca 100644
--- a/drivers/scsi/mvsas/mv_sas.h
+++ b/drivers/scsi/mvsas/mv_sas.h
@@ -67,7 +67,7 @@ extern const struct mvs_dispatch mvs_94xx_dispatch;
67extern struct kmem_cache *mvs_task_list_cache; 67extern struct kmem_cache *mvs_task_list_cache;
68 68
69#define DEV_IS_EXPANDER(type) \ 69#define DEV_IS_EXPANDER(type) \
70 ((type == EDGE_DEV) || (type == FANOUT_DEV)) 70 ((type == SAS_EDGE_EXPANDER_DEVICE) || (type == SAS_FANOUT_EXPANDER_DEVICE))
71 71
72#define bit(n) ((u64)1 << n) 72#define bit(n) ((u64)1 << n)
73 73
@@ -241,7 +241,7 @@ struct mvs_phy {
241 241
242struct mvs_device { 242struct mvs_device {
243 struct list_head dev_entry; 243 struct list_head dev_entry;
244 enum sas_dev_type dev_type; 244 enum sas_device_type dev_type;
245 struct mvs_info *mvi_info; 245 struct mvs_info *mvi_info;
246 struct domain_device *sas_device; 246 struct domain_device *sas_device;
247 struct timer_list timer; 247 struct timer_list timer;
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 95d04cc78c0b..69dd49c05f1e 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -1505,7 +1505,7 @@ void pm8001_work_fn(struct work_struct *work)
1505 pm8001_dev = pw->data; /* Most stash device structure */ 1505 pm8001_dev = pw->data; /* Most stash device structure */
1506 if ((pm8001_dev == NULL) 1506 if ((pm8001_dev == NULL)
1507 || ((pw->handler != IO_XFER_ERROR_BREAK) 1507 || ((pw->handler != IO_XFER_ERROR_BREAK)
1508 && (pm8001_dev->dev_type == NO_DEVICE))) { 1508 && (pm8001_dev->dev_type == SAS_PHY_UNUSED))) {
1509 kfree(pw); 1509 kfree(pw);
1510 return; 1510 return;
1511 } 1511 }
@@ -3443,7 +3443,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)
3443 sizeof(struct dev_to_host_fis)); 3443 sizeof(struct dev_to_host_fis));
3444 phy->frame_rcvd_size = sizeof(struct dev_to_host_fis); 3444 phy->frame_rcvd_size = sizeof(struct dev_to_host_fis);
3445 phy->identify.target_port_protocols = SAS_PROTOCOL_SATA; 3445 phy->identify.target_port_protocols = SAS_PROTOCOL_SATA;
3446 phy->identify.device_type = SATA_DEV; 3446 phy->identify.device_type = SAS_SATA_DEV;
3447 pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 3447 pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr);
3448 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 3448 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
3449 pm8001_bytes_dmaed(pm8001_ha, phy_id); 3449 pm8001_bytes_dmaed(pm8001_ha, phy_id);
@@ -4465,7 +4465,7 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
4465 payload.ase_sh_lm_slr_phyid = cpu_to_le32(SPINHOLD_DISABLE | 4465 payload.ase_sh_lm_slr_phyid = cpu_to_le32(SPINHOLD_DISABLE |
4466 LINKMODE_AUTO | LINKRATE_15 | 4466 LINKMODE_AUTO | LINKRATE_15 |
4467 LINKRATE_30 | LINKRATE_60 | phy_id); 4467 LINKRATE_30 | LINKRATE_60 | phy_id);
4468 payload.sas_identify.dev_type = SAS_END_DEV; 4468 payload.sas_identify.dev_type = SAS_END_DEVICE;
4469 payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL; 4469 payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL;
4470 memcpy(payload.sas_identify.sas_addr, 4470 memcpy(payload.sas_identify.sas_addr,
4471 pm8001_ha->sas_addr, SAS_ADDR_SIZE); 4471 pm8001_ha->sas_addr, SAS_ADDR_SIZE);
@@ -4527,11 +4527,11 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
4527 if (flag == 1) 4527 if (flag == 1)
4528 stp_sspsmp_sata = 0x02; /*direct attached sata */ 4528 stp_sspsmp_sata = 0x02; /*direct attached sata */
4529 else { 4529 else {
4530 if (pm8001_dev->dev_type == SATA_DEV) 4530 if (pm8001_dev->dev_type == SAS_SATA_DEV)
4531 stp_sspsmp_sata = 0x00; /* stp*/ 4531 stp_sspsmp_sata = 0x00; /* stp*/
4532 else if (pm8001_dev->dev_type == SAS_END_DEV || 4532 else if (pm8001_dev->dev_type == SAS_END_DEVICE ||
4533 pm8001_dev->dev_type == EDGE_DEV || 4533 pm8001_dev->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
4534 pm8001_dev->dev_type == FANOUT_DEV) 4534 pm8001_dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
4535 stp_sspsmp_sata = 0x01; /*ssp or smp*/ 4535 stp_sspsmp_sata = 0x01; /*ssp or smp*/
4536 } 4536 }
4537 if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) 4537 if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type))
@@ -4662,9 +4662,9 @@ int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,
4662 PM8001_EH_DBG(pm8001_ha, 4662 PM8001_EH_DBG(pm8001_ha,
4663 pm8001_printk("cmd_tag = %x, abort task tag = 0x%x", 4663 pm8001_printk("cmd_tag = %x, abort task tag = 0x%x",
4664 cmd_tag, task_tag)); 4664 cmd_tag, task_tag));
4665 if (pm8001_dev->dev_type == SAS_END_DEV) 4665 if (pm8001_dev->dev_type == SAS_END_DEVICE)
4666 opc = OPC_INB_SSP_ABORT; 4666 opc = OPC_INB_SSP_ABORT;
4667 else if (pm8001_dev->dev_type == SATA_DEV) 4667 else if (pm8001_dev->dev_type == SAS_SATA_DEV)
4668 opc = OPC_INB_SATA_ABORT; 4668 opc = OPC_INB_SATA_ABORT;
4669 else 4669 else
4670 opc = OPC_INB_SMP_ABORT;/* SMP */ 4670 opc = OPC_INB_SMP_ABORT;/* SMP */
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 1c718520036a..e4b9bc7f5410 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -361,7 +361,7 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
361 361
362 pm8001_ha->devices = pm8001_ha->memoryMap.region[DEV_MEM].virt_ptr; 362 pm8001_ha->devices = pm8001_ha->memoryMap.region[DEV_MEM].virt_ptr;
363 for (i = 0; i < PM8001_MAX_DEVICES; i++) { 363 for (i = 0; i < PM8001_MAX_DEVICES; i++) {
364 pm8001_ha->devices[i].dev_type = NO_DEVICE; 364 pm8001_ha->devices[i].dev_type = SAS_PHY_UNUSED;
365 pm8001_ha->devices[i].id = i; 365 pm8001_ha->devices[i].id = i;
366 pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES; 366 pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES;
367 pm8001_ha->devices[i].running_req = 0; 367 pm8001_ha->devices[i].running_req = 0;
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 9af95853f840..a85d73de7c80 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -357,7 +357,7 @@ static int sas_find_local_port_id(struct domain_device *dev)
357 * @tmf: the task management IU 357 * @tmf: the task management IU
358 */ 358 */
359#define DEV_IS_GONE(pm8001_dev) \ 359#define DEV_IS_GONE(pm8001_dev) \
360 ((!pm8001_dev || (pm8001_dev->dev_type == NO_DEVICE))) 360 ((!pm8001_dev || (pm8001_dev->dev_type == SAS_PHY_UNUSED)))
361static int pm8001_task_exec(struct sas_task *task, const int num, 361static int pm8001_task_exec(struct sas_task *task, const int num,
362 gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf) 362 gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf)
363{ 363{
@@ -375,7 +375,7 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
375 struct task_status_struct *tsm = &t->task_status; 375 struct task_status_struct *tsm = &t->task_status;
376 tsm->resp = SAS_TASK_UNDELIVERED; 376 tsm->resp = SAS_TASK_UNDELIVERED;
377 tsm->stat = SAS_PHY_DOWN; 377 tsm->stat = SAS_PHY_DOWN;
378 if (dev->dev_type != SATA_DEV) 378 if (dev->dev_type != SAS_SATA_DEV)
379 t->task_done(t); 379 t->task_done(t);
380 return 0; 380 return 0;
381 } 381 }
@@ -553,7 +553,7 @@ struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
553{ 553{
554 u32 dev; 554 u32 dev;
555 for (dev = 0; dev < PM8001_MAX_DEVICES; dev++) { 555 for (dev = 0; dev < PM8001_MAX_DEVICES; dev++) {
556 if (pm8001_ha->devices[dev].dev_type == NO_DEVICE) { 556 if (pm8001_ha->devices[dev].dev_type == SAS_PHY_UNUSED) {
557 pm8001_ha->devices[dev].id = dev; 557 pm8001_ha->devices[dev].id = dev;
558 return &pm8001_ha->devices[dev]; 558 return &pm8001_ha->devices[dev];
559 } 559 }
@@ -589,7 +589,7 @@ static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
589 u32 id = pm8001_dev->id; 589 u32 id = pm8001_dev->id;
590 memset(pm8001_dev, 0, sizeof(*pm8001_dev)); 590 memset(pm8001_dev, 0, sizeof(*pm8001_dev));
591 pm8001_dev->id = id; 591 pm8001_dev->id = id;
592 pm8001_dev->dev_type = NO_DEVICE; 592 pm8001_dev->dev_type = SAS_PHY_UNUSED;
593 pm8001_dev->device_id = PM8001_MAX_DEVICES; 593 pm8001_dev->device_id = PM8001_MAX_DEVICES;
594 pm8001_dev->sas_device = NULL; 594 pm8001_dev->sas_device = NULL;
595} 595}
@@ -647,7 +647,7 @@ static int pm8001_dev_found_notify(struct domain_device *dev)
647 res = -1; 647 res = -1;
648 } 648 }
649 } else { 649 } else {
650 if (dev->dev_type == SATA_DEV) { 650 if (dev->dev_type == SAS_SATA_DEV) {
651 pm8001_device->attached_phy = 651 pm8001_device->attached_phy =
652 dev->rphy->identify.phy_identifier; 652 dev->rphy->identify.phy_identifier;
653 flag = 1; /* directly sata*/ 653 flag = 1; /* directly sata*/
@@ -657,7 +657,7 @@ static int pm8001_dev_found_notify(struct domain_device *dev)
657 PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag); 657 PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag);
658 spin_unlock_irqrestore(&pm8001_ha->lock, flags); 658 spin_unlock_irqrestore(&pm8001_ha->lock, flags);
659 wait_for_completion(&completion); 659 wait_for_completion(&completion);
660 if (dev->dev_type == SAS_END_DEV) 660 if (dev->dev_type == SAS_END_DEVICE)
661 msleep(50); 661 msleep(50);
662 pm8001_ha->flags = PM8001F_RUN_TIME; 662 pm8001_ha->flags = PM8001F_RUN_TIME;
663 return 0; 663 return 0;
@@ -927,7 +927,7 @@ void pm8001_open_reject_retry(
927 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[i]; 927 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[i];
928 928
929 pm8001_dev = ccb->device; 929 pm8001_dev = ccb->device;
930 if (!pm8001_dev || (pm8001_dev->dev_type == NO_DEVICE)) 930 if (!pm8001_dev || (pm8001_dev->dev_type == SAS_PHY_UNUSED))
931 continue; 931 continue;
932 if (!device_to_close) { 932 if (!device_to_close) {
933 uintptr_t d = (uintptr_t)pm8001_dev 933 uintptr_t d = (uintptr_t)pm8001_dev
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 72d46ea398dc..570819464d90 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -103,7 +103,7 @@ do { \
103#define PM8001_READ_VPD 103#define PM8001_READ_VPD
104 104
105 105
106#define DEV_IS_EXPANDER(type) ((type == EDGE_DEV) || (type == FANOUT_DEV)) 106#define DEV_IS_EXPANDER(type) ((type == SAS_EDGE_EXPANDER_DEVICE) || (type == SAS_FANOUT_EXPANDER_DEVICE))
107 107
108#define PM8001_NAME_LENGTH 32/* generic length of strings */ 108#define PM8001_NAME_LENGTH 32/* generic length of strings */
109extern struct list_head hba_list; 109extern struct list_head hba_list;
@@ -206,7 +206,7 @@ struct pm8001_phy {
206}; 206};
207 207
208struct pm8001_device { 208struct pm8001_device {
209 enum sas_dev_type dev_type; 209 enum sas_device_type dev_type;
210 struct domain_device *sas_device; 210 struct domain_device *sas_device;
211 u32 attached_phy; 211 u32 attached_phy;
212 u32 id; 212 u32 id;
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 670998a8ca79..302514d8157b 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -2684,7 +2684,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)
2684 sizeof(struct dev_to_host_fis)); 2684 sizeof(struct dev_to_host_fis));
2685 phy->frame_rcvd_size = sizeof(struct dev_to_host_fis); 2685 phy->frame_rcvd_size = sizeof(struct dev_to_host_fis);
2686 phy->identify.target_port_protocols = SAS_PROTOCOL_SATA; 2686 phy->identify.target_port_protocols = SAS_PROTOCOL_SATA;
2687 phy->identify.device_type = SATA_DEV; 2687 phy->identify.device_type = SAS_SATA_DEV;
2688 pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 2688 pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr);
2689 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 2689 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
2690 pm8001_bytes_dmaed(pm8001_ha, phy_id); 2690 pm8001_bytes_dmaed(pm8001_ha, phy_id);
@@ -3952,7 +3952,7 @@ pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
3952 Have to add "SAS PHY Analog Setup SPASTI 1 Byte" Based on need 3952 Have to add "SAS PHY Analog Setup SPASTI 1 Byte" Based on need
3953 **/ 3953 **/
3954 3954
3955 payload.sas_identify.dev_type = SAS_END_DEV; 3955 payload.sas_identify.dev_type = SAS_END_DEVICE;
3956 payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL; 3956 payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL;
3957 memcpy(payload.sas_identify.sas_addr, 3957 memcpy(payload.sas_identify.sas_addr,
3958 pm8001_ha->sas_addr, SAS_ADDR_SIZE); 3958 pm8001_ha->sas_addr, SAS_ADDR_SIZE);
@@ -4015,11 +4015,11 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
4015 if (flag == 1) { 4015 if (flag == 1) {
4016 stp_sspsmp_sata = 0x02; /*direct attached sata */ 4016 stp_sspsmp_sata = 0x02; /*direct attached sata */
4017 } else { 4017 } else {
4018 if (pm8001_dev->dev_type == SATA_DEV) 4018 if (pm8001_dev->dev_type == SAS_SATA_DEV)
4019 stp_sspsmp_sata = 0x00; /* stp*/ 4019 stp_sspsmp_sata = 0x00; /* stp*/
4020 else if (pm8001_dev->dev_type == SAS_END_DEV || 4020 else if (pm8001_dev->dev_type == SAS_END_DEVICE ||
4021 pm8001_dev->dev_type == EDGE_DEV || 4021 pm8001_dev->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
4022 pm8001_dev->dev_type == FANOUT_DEV) 4022 pm8001_dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE)
4023 stp_sspsmp_sata = 0x01; /*ssp or smp*/ 4023 stp_sspsmp_sata = 0x01; /*ssp or smp*/
4024 } 4024 }
4025 if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) 4025 if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type))
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index ef937b56f9b5..e2c1e66d58ae 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -118,7 +118,7 @@ struct ex_phy {
118 118
119 enum ex_phy_state phy_state; 119 enum ex_phy_state phy_state;
120 120
121 enum sas_dev_type attached_dev_type; 121 enum sas_device_type attached_dev_type;
122 enum sas_linkrate linkrate; 122 enum sas_linkrate linkrate;
123 123
124 u8 attached_sata_host:1; 124 u8 attached_sata_host:1;
@@ -195,7 +195,7 @@ enum {
195 195
196struct domain_device { 196struct domain_device {
197 spinlock_t done_lock; 197 spinlock_t done_lock;
198 enum sas_dev_type dev_type; 198 enum sas_device_type dev_type;
199 199
200 enum sas_linkrate linkrate; 200 enum sas_linkrate linkrate;
201 enum sas_linkrate min_linkrate; 201 enum sas_linkrate min_linkrate;
diff --git a/include/scsi/sas.h b/include/scsi/sas.h
index be3eb0bf1ac0..0d2607d12387 100644
--- a/include/scsi/sas.h
+++ b/include/scsi/sas.h
@@ -90,16 +90,18 @@ enum sas_oob_mode {
90}; 90};
91 91
92/* See sas_discover.c if you plan on changing these */ 92/* See sas_discover.c if you plan on changing these */
93enum sas_dev_type { 93enum sas_device_type {
94 NO_DEVICE = 0, /* protocol */ 94 /* these are SAS protocol defined (attached device type field) */
95 SAS_END_DEV = 1, /* protocol */ 95 SAS_PHY_UNUSED = 0,
96 EDGE_DEV = 2, /* protocol */ 96 SAS_END_DEVICE = 1,
97 FANOUT_DEV = 3, /* protocol */ 97 SAS_EDGE_EXPANDER_DEVICE = 2,
98 SAS_HA = 4, 98 SAS_FANOUT_EXPANDER_DEVICE = 3,
99 SATA_DEV = 5, 99 /* these are internal to libsas */
100 SATA_PM = 7, 100 SAS_HA = 4,
101 SATA_PM_PORT= 8, 101 SAS_SATA_DEV = 5,
102 SATA_PENDING = 9, 102 SAS_SATA_PM = 7,
103 SAS_SATA_PM_PORT = 8,
104 SAS_SATA_PENDING = 9,
103}; 105};
104 106
105enum sas_protocol { 107enum sas_protocol {
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h
index ff71a5654684..00f41aeeecf5 100644
--- a/include/scsi/sas_ata.h
+++ b/include/scsi/sas_ata.h
@@ -32,8 +32,8 @@
32 32
33static inline int dev_is_sata(struct domain_device *dev) 33static inline int dev_is_sata(struct domain_device *dev)
34{ 34{
35 return dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM || 35 return dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM ||
36 dev->dev_type == SATA_PM_PORT || dev->dev_type == SATA_PENDING; 36 dev->dev_type == SAS_SATA_PM_PORT || dev->dev_type == SAS_SATA_PENDING;
37} 37}
38 38
39int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy); 39int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy);
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 9b8e08879cfc..0bd71e2702e3 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -10,13 +10,6 @@ struct scsi_transport_template;
10struct sas_rphy; 10struct sas_rphy;
11struct request; 11struct request;
12 12
13enum sas_device_type {
14 SAS_PHY_UNUSED = 0,
15 SAS_END_DEVICE = 1,
16 SAS_EDGE_EXPANDER_DEVICE = 2,
17 SAS_FANOUT_EXPANDER_DEVICE = 3,
18};
19
20static inline int sas_protocol_ata(enum sas_protocol proto) 13static inline int sas_protocol_ata(enum sas_protocol proto)
21{ 14{
22 return ((proto & SAS_PROTOCOL_SATA) || 15 return ((proto & SAS_PROTOCOL_SATA) ||