Skip to content

Commit aa9f832

Browse files
James BottomleyJames Bottomley
authored andcommitted
[SCSI] sas: unify the pointlessly separated enums sas_dev_type and sas_device_type
These enums have been separate since the dawn of SAS, mainly because the latter is a procotol only enum and the former includes additional state for libsas. The dichotomy causes endless confusion about which one you should use where and leads to pointless warnings like this: drivers/scsi/mvsas/mv_sas.c: In function 'mvs_update_phyinfo': drivers/scsi/mvsas/mv_sas.c:1162:34: warning: comparison between 'enum sas_device_type' and 'enum sas_dev_type' [-Wenum-compare] Fix by eliminating one of them. The one kept is effectively the sas.h one, but call it sas_device_type and make sure the enums are all properly namespaced with the SAS_ prefix. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent a6cb3d0 commit aa9f832

24 files changed

+160
-165
lines changed

drivers/scsi/aic94xx/aic94xx_dev.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void asd_set_ddb_type(struct domain_device *dev)
8484
struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha;
8585
int ddb = (int) (unsigned long) dev->lldd_dev;
8686

87-
if (dev->dev_type == SATA_PM_PORT)
87+
if (dev->dev_type == SAS_SATA_PM_PORT)
8888
asd_ddbsite_write_byte(asd_ha,ddb, DDB_TYPE, DDB_TYPE_PM_PORT);
8989
else if (dev->tproto)
9090
asd_ddbsite_write_byte(asd_ha,ddb, DDB_TYPE, DDB_TYPE_TARGET);
@@ -116,7 +116,7 @@ void asd_set_dmamode(struct domain_device *dev)
116116
int ddb = (int) (unsigned long) dev->lldd_dev;
117117
u32 qdepth = 0;
118118

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) {
120120
if (ata_id_has_ncq(ata_dev->id))
121121
qdepth = ata_id_queue_depth(ata_dev->id);
122122
asd_ddbsite_write_dword(asd_ha, ddb, SATA_TAG_ALLOC_MASK,
@@ -140,8 +140,8 @@ static int asd_init_sata(struct domain_device *dev)
140140
int ddb = (int) (unsigned long) dev->lldd_dev;
141141

142142
asd_ddbsite_write_word(asd_ha, ddb, ATA_CMD_SCBPTR, 0xFFFF);
143-
if (dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM ||
144-
dev->dev_type == SATA_PM_PORT) {
143+
if (dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM ||
144+
dev->dev_type == SAS_SATA_PM_PORT) {
145145
struct dev_to_host_fis *fis = (struct dev_to_host_fis *)
146146
dev->frame_rcvd;
147147
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)
174174
asd_ddbsite_write_byte(asd_ha, ddb, CONN_MASK, dev->port->phy_mask);
175175
if (dev->port->oob_mode != SATA_OOB_MODE) {
176176
flags |= OPEN_REQUIRED;
177-
if ((dev->dev_type == SATA_DEV) ||
177+
if ((dev->dev_type == SAS_SATA_DEV) ||
178178
(dev->tproto & SAS_PROTOCOL_STP)) {
179179
struct smp_resp *rps_resp = &dev->sata_dev.rps_resp;
180180
if (rps_resp->frame_type == SMP_RESPONSE &&
@@ -188,8 +188,8 @@ static int asd_init_target_ddb(struct domain_device *dev)
188188
} else {
189189
flags |= CONCURRENT_CONN_SUPP;
190190
if (!dev->parent &&
191-
(dev->dev_type == EDGE_DEV ||
192-
dev->dev_type == FANOUT_DEV))
191+
(dev->dev_type == SAS_EDGE_EXPANDER_DEVICE ||
192+
dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE))
193193
asd_ddbsite_write_byte(asd_ha, ddb, MAX_CCONN,
194194
4);
195195
else
@@ -198,7 +198,7 @@ static int asd_init_target_ddb(struct domain_device *dev)
198198
asd_ddbsite_write_byte(asd_ha, ddb, NUM_CTX, 1);
199199
}
200200
}
201-
if (dev->dev_type == SATA_PM)
201+
if (dev->dev_type == SAS_SATA_PM)
202202
flags |= SATA_MULTIPORT;
203203
asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS, flags);
204204

@@ -211,15 +211,15 @@ static int asd_init_target_ddb(struct domain_device *dev)
211211
asd_ddbsite_write_word(asd_ha, ddb, SEND_QUEUE_TAIL, 0xFFFF);
212212
asd_ddbsite_write_word(asd_ha, ddb, SISTER_DDB, 0xFFFF);
213213

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)) {
215215
i = asd_init_sata(dev);
216216
if (i < 0) {
217217
asd_free_ddb(asd_ha, ddb);
218218
return i;
219219
}
220220
}
221221

222-
if (dev->dev_type == SAS_END_DEV) {
222+
if (dev->dev_type == SAS_END_DEVICE) {
223223
struct sas_end_device *rdev = rphy_to_end_device(dev->rphy);
224224
if (rdev->I_T_nexus_loss_timeout > 0)
225225
asd_ddbsite_write_word(asd_ha, ddb, ITNL_TIMEOUT,
@@ -328,10 +328,10 @@ int asd_dev_found(struct domain_device *dev)
328328

329329
spin_lock_irqsave(&asd_ha->hw_prof.ddb_lock, flags);
330330
switch (dev->dev_type) {
331-
case SATA_PM:
331+
case SAS_SATA_PM:
332332
res = asd_init_sata_pm_ddb(dev);
333333
break;
334-
case SATA_PM_PORT:
334+
case SAS_SATA_PM_PORT:
335335
res = asd_init_sata_pm_port_ddb(dev);
336336
break;
337337
default:

drivers/scsi/aic94xx/aic94xx_hwi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void asd_init_phy_identify(struct asd_phy *phy)
7474

7575
memset(phy->identify_frame, 0, sizeof(*phy->identify_frame));
7676

77-
phy->identify_frame->dev_type = SAS_END_DEV;
77+
phy->identify_frame->dev_type = SAS_END_DEVICE;
7878
if (phy->sas_phy.role & PHY_ROLE_INITIATOR)
7979
phy->identify_frame->initiator_bits = phy->sas_phy.iproto;
8080
if (phy->sas_phy.role & PHY_ROLE_TARGET)

drivers/scsi/aic94xx/aic94xx_tmf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int asd_I_T_nexus_reset(struct domain_device *dev)
184184
struct sas_phy *phy = sas_get_local_phy(dev);
185185
/* Standard mandates link reset for ATA (type 0) and
186186
* 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 ||
188188
(dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
189189

190190
asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE);

drivers/scsi/isci/remote_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ static void sci_remote_device_ready_state_enter(struct sci_base_state_machine *s
10851085
struct isci_host *ihost = idev->owning_port->owning_controller;
10861086
struct domain_device *dev = idev->domain_dev;
10871087

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)) {
10891089
sci_change_state(&idev->sm, SCI_STP_DEV_IDLE);
10901090
} else if (dev_is_expander(dev)) {
10911091
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
10981098
struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm);
10991099
struct domain_device *dev = idev->domain_dev;
11001100

1101-
if (dev->dev_type == SAS_END_DEV) {
1101+
if (dev->dev_type == SAS_END_DEVICE) {
11021102
struct isci_host *ihost = idev->owning_port->owning_controller;
11031103

11041104
isci_remote_device_not_ready(ihost, idev,

drivers/scsi/isci/remote_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_conte
297297

298298
static inline bool dev_is_expander(struct domain_device *dev)
299299
{
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;
301301
}
302302

303303
static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev)

drivers/scsi/isci/request.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,7 @@ static void sci_request_started_state_enter(struct sci_base_state_machine *sm)
29782978
/* all unaccelerated request types (non ssp or ncq) handled with
29792979
* substates
29802980
*/
2981-
if (!task && dev->dev_type == SAS_END_DEV) {
2981+
if (!task && dev->dev_type == SAS_END_DEVICE) {
29822982
state = SCI_REQ_TASK_WAIT_TC_COMP;
29832983
} else if (task && task->task_proto == SAS_PROTOCOL_SMP) {
29842984
state = SCI_REQ_SMP_WAIT_RESP;
@@ -3101,7 +3101,7 @@ sci_io_request_construct(struct isci_host *ihost,
31013101
if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
31023102
return SCI_FAILURE_INVALID_REMOTE_DEVICE;
31033103

3104-
if (dev->dev_type == SAS_END_DEV)
3104+
if (dev->dev_type == SAS_END_DEVICE)
31053105
/* pass */;
31063106
else if (dev_is_sata(dev))
31073107
memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd));
@@ -3125,7 +3125,7 @@ enum sci_status sci_task_request_construct(struct isci_host *ihost,
31253125
/* Build the common part of the request */
31263126
sci_general_request_construct(ihost, idev, ireq);
31273127

3128-
if (dev->dev_type == SAS_END_DEV || dev_is_sata(dev)) {
3128+
if (dev->dev_type == SAS_END_DEVICE || dev_is_sata(dev)) {
31293129
set_bit(IREQ_TMF, &ireq->flags);
31303130
memset(ireq->tc, 0, sizeof(struct scu_task_context));
31313131

drivers/scsi/isci/task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static struct isci_request *isci_task_request_build(struct isci_host *ihost,
250250
}
251251

252252
/* 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) {
254254
isci_tmf->proto = SAS_PROTOCOL_SSP;
255255
status = sci_task_request_construct_ssp(ireq);
256256
if (status != SCI_SUCCESS)

drivers/scsi/libsas/sas_ata.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
285285
if (phy->attached_tproto & SAS_PROTOCOL_STP)
286286
dev->tproto = phy->attached_tproto;
287287
if (phy->attached_sata_dev)
288-
dev->tproto |= SATA_DEV;
288+
dev->tproto |= SAS_SATA_DEV;
289289

290-
if (phy->attached_dev_type == SATA_PENDING)
291-
dev->dev_type = SATA_PENDING;
290+
if (phy->attached_dev_type == SAS_SATA_PENDING)
291+
dev->dev_type = SAS_SATA_PENDING;
292292
else {
293293
int res;
294294

295-
dev->dev_type = SATA_DEV;
295+
dev->dev_type = SAS_SATA_DEV;
296296
res = sas_get_report_phy_sata(dev->parent, phy->phy_id,
297297
&dev->sata_dev.rps_resp);
298298
if (res) {
@@ -314,7 +314,7 @@ static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy)
314314
int res;
315315

316316
/* 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)
318318
return 1;
319319

320320
/* 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)
348348
return 0;
349349

350350
switch (ex_phy->attached_dev_type) {
351-
case SATA_PENDING:
351+
case SAS_SATA_PENDING:
352352
return 0;
353-
case SAS_END_DEV:
353+
case SAS_END_DEVICE:
354354
if (ex_phy->attached_sata_dev)
355355
return sas_ata_clear_pending(dev, ex_phy);
356356
default:
@@ -631,7 +631,7 @@ static void sas_get_ata_command_set(struct domain_device *dev)
631631
struct dev_to_host_fis *fis =
632632
(struct dev_to_host_fis *) dev->frame_rcvd;
633633

634-
if (dev->dev_type == SATA_PENDING)
634+
if (dev->dev_type == SAS_SATA_PENDING)
635635
return;
636636

637637
if ((fis->sector_count == 1 && /* ATA */
@@ -797,7 +797,7 @@ int sas_discover_sata(struct domain_device *dev)
797797
{
798798
int res;
799799

800-
if (dev->dev_type == SATA_PM)
800+
if (dev->dev_type == SAS_SATA_PM)
801801
return -ENODEV;
802802

803803
sas_get_ata_command_set(dev);

drivers/scsi/libsas/sas_discover.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
void sas_init_dev(struct domain_device *dev)
4040
{
4141
switch (dev->dev_type) {
42-
case SAS_END_DEV:
42+
case SAS_END_DEVICE:
4343
INIT_LIST_HEAD(&dev->ssp_dev.eh_list_node);
4444
break;
45-
case EDGE_DEV:
46-
case FANOUT_DEV:
45+
case SAS_EDGE_EXPANDER_DEVICE:
46+
case SAS_FANOUT_EXPANDER_DEVICE:
4747
INIT_LIST_HEAD(&dev->ex_dev.children);
4848
mutex_init(&dev->ex_dev.cmd_mutex);
4949
break;
@@ -93,9 +93,9 @@ static int sas_get_port_device(struct asd_sas_port *port)
9393
if (fis->interrupt_reason == 1 && fis->lbal == 1 &&
9494
fis->byte_count_low==0x69 && fis->byte_count_high == 0x96
9595
&& (fis->device & ~0x10) == 0)
96-
dev->dev_type = SATA_PM;
96+
dev->dev_type = SAS_SATA_PM;
9797
else
98-
dev->dev_type = SATA_DEV;
98+
dev->dev_type = SAS_SATA_DEV;
9999
dev->tproto = SAS_PROTOCOL_SATA;
100100
} else {
101101
struct sas_identify_frame *id =
@@ -109,21 +109,21 @@ static int sas_get_port_device(struct asd_sas_port *port)
109109

110110
dev->port = port;
111111
switch (dev->dev_type) {
112-
case SATA_DEV:
112+
case SAS_SATA_DEV:
113113
rc = sas_ata_init(dev);
114114
if (rc) {
115115
rphy = NULL;
116116
break;
117117
}
118118
/* fall through */
119-
case SAS_END_DEV:
119+
case SAS_END_DEVICE:
120120
rphy = sas_end_device_alloc(port->port);
121121
break;
122-
case EDGE_DEV:
122+
case SAS_EDGE_EXPANDER_DEVICE:
123123
rphy = sas_expander_alloc(port->port,
124124
SAS_EDGE_EXPANDER_DEVICE);
125125
break;
126-
case FANOUT_DEV:
126+
case SAS_FANOUT_EXPANDER_DEVICE:
127127
rphy = sas_expander_alloc(port->port,
128128
SAS_FANOUT_EXPANDER_DEVICE);
129129
break;
@@ -156,7 +156,7 @@ static int sas_get_port_device(struct asd_sas_port *port)
156156
dev->rphy = rphy;
157157
get_device(&dev->rphy->dev);
158158

159-
if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEV)
159+
if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEVICE)
160160
list_add_tail(&dev->disco_list_node, &port->disco_list);
161161
else {
162162
spin_lock_irq(&port->dev_list_lock);
@@ -315,7 +315,7 @@ void sas_free_device(struct kref *kref)
315315
dev->phy = NULL;
316316

317317
/* 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)
319319
kfree(dev->ex_dev.ex_phy);
320320

321321
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
343343
spin_unlock_irq(&port->dev_list_lock);
344344

345345
spin_lock_irq(&ha->lock);
346-
if (dev->dev_type == SAS_END_DEV &&
346+
if (dev->dev_type == SAS_END_DEVICE &&
347347
!list_empty(&dev->ssp_dev.eh_list_node)) {
348348
list_del_init(&dev->ssp_dev.eh_list_node);
349349
ha->eh_active--;
@@ -457,15 +457,15 @@ static void sas_discover_domain(struct work_struct *work)
457457
task_pid_nr(current));
458458

459459
switch (dev->dev_type) {
460-
case SAS_END_DEV:
460+
case SAS_END_DEVICE:
461461
error = sas_discover_end_dev(dev);
462462
break;
463-
case EDGE_DEV:
464-
case FANOUT_DEV:
463+
case SAS_EDGE_EXPANDER_DEVICE:
464+
case SAS_FANOUT_EXPANDER_DEVICE:
465465
error = sas_discover_root_expander(dev);
466466
break;
467-
case SATA_DEV:
468-
case SATA_PM:
467+
case SAS_SATA_DEV:
468+
case SAS_SATA_PM:
469469
#ifdef CONFIG_SCSI_SAS_ATA
470470
error = sas_discover_sata(dev);
471471
break;

0 commit comments

Comments
 (0)