diff options
Diffstat (limited to 'drivers/scsi/ses.c')
-rw-r--r-- | drivers/scsi/ses.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index e946e05db7f7..c9146d751cbf 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -345,44 +345,21 @@ static int ses_enclosure_find_by_addr(struct enclosure_device *edev, | |||
345 | return 0; | 345 | return 0; |
346 | } | 346 | } |
347 | 347 | ||
348 | #define VPD_INQUIRY_SIZE 36 | ||
349 | |||
350 | static void ses_match_to_enclosure(struct enclosure_device *edev, | 348 | static void ses_match_to_enclosure(struct enclosure_device *edev, |
351 | struct scsi_device *sdev) | 349 | struct scsi_device *sdev) |
352 | { | 350 | { |
353 | unsigned char *buf = kmalloc(VPD_INQUIRY_SIZE, GFP_KERNEL); | 351 | unsigned char *buf; |
354 | unsigned char *desc; | 352 | unsigned char *desc; |
355 | u16 vpd_len; | 353 | unsigned int vpd_len; |
356 | struct efd efd = { | 354 | struct efd efd = { |
357 | .addr = 0, | 355 | .addr = 0, |
358 | }; | 356 | }; |
359 | unsigned char cmd[] = { | ||
360 | INQUIRY, | ||
361 | 1, | ||
362 | 0x83, | ||
363 | VPD_INQUIRY_SIZE >> 8, | ||
364 | VPD_INQUIRY_SIZE & 0xff, | ||
365 | 0 | ||
366 | }; | ||
367 | 357 | ||
358 | buf = scsi_get_vpd_page(sdev, 0x83); | ||
368 | if (!buf) | 359 | if (!buf) |
369 | return; | 360 | return; |
370 | 361 | ||
371 | if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, | 362 | vpd_len = ((buf[2] << 8) | buf[3]) + 4; |
372 | VPD_INQUIRY_SIZE, NULL, SES_TIMEOUT, SES_RETRIES, | ||
373 | NULL)) | ||
374 | goto free; | ||
375 | |||
376 | vpd_len = (buf[2] << 8) + buf[3]; | ||
377 | kfree(buf); | ||
378 | buf = kmalloc(vpd_len, GFP_KERNEL); | ||
379 | if (!buf) | ||
380 | return; | ||
381 | cmd[3] = vpd_len >> 8; | ||
382 | cmd[4] = vpd_len & 0xff; | ||
383 | if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, | ||
384 | vpd_len, NULL, SES_TIMEOUT, SES_RETRIES, NULL)) | ||
385 | goto free; | ||
386 | 363 | ||
387 | desc = buf + 4; | 364 | desc = buf + 4; |
388 | while (desc < buf + vpd_len) { | 365 | while (desc < buf + vpd_len) { |
@@ -393,7 +370,7 @@ static void ses_match_to_enclosure(struct enclosure_device *edev, | |||
393 | u8 type = desc[1] & 0x0f; | 370 | u8 type = desc[1] & 0x0f; |
394 | u8 len = desc[3]; | 371 | u8 len = desc[3]; |
395 | 372 | ||
396 | if (piv && code_set == 1 && assoc == 1 && code_set == 1 | 373 | if (piv && code_set == 1 && assoc == 1 |
397 | && proto == SCSI_PROTOCOL_SAS && type == 3 && len == 8) | 374 | && proto == SCSI_PROTOCOL_SAS && type == 3 && len == 8) |
398 | efd.addr = (u64)desc[4] << 56 | | 375 | efd.addr = (u64)desc[4] << 56 | |
399 | (u64)desc[5] << 48 | | 376 | (u64)desc[5] << 48 | |