Skip to content

Commit

Permalink
[SCSI] ses: Use vpd information from scsi_device
Browse files Browse the repository at this point in the history
The scsi_device now has VPD page83 information attached, so
there is no need to query it again.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
hreinecke authored and James Bottomley committed Mar 27, 2014
1 parent b3ae878 commit c38c007
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions drivers/scsi/ses.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/enclosure.h>
#include <asm/unaligned.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
Expand Down Expand Up @@ -448,27 +449,18 @@ static void ses_enclosure_data_process(struct enclosure_device *edev,
static void ses_match_to_enclosure(struct enclosure_device *edev,
struct scsi_device *sdev)
{
unsigned char *buf;
unsigned char *desc;
unsigned int vpd_len;
struct efd efd = {
.addr = 0,
};

buf = kmalloc(INIT_ALLOC_SIZE, GFP_KERNEL);
if (!buf || scsi_get_vpd_page(sdev, 0x83, buf, INIT_ALLOC_SIZE))
goto free;

ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);

vpd_len = ((buf[2] << 8) | buf[3]) + 4;
kfree(buf);
buf = kmalloc(vpd_len, GFP_KERNEL);
if (!buf ||scsi_get_vpd_page(sdev, 0x83, buf, vpd_len))
goto free;
if (!sdev->vpd_pg83_len)
return;

desc = buf + 4;
while (desc < buf + vpd_len) {
desc = sdev->vpd_pg83 + 4;
while (desc < sdev->vpd_pg83 + sdev->vpd_pg83_len) {
enum scsi_protocol proto = desc[0] >> 4;
u8 code_set = desc[0] & 0x0f;
u8 piv = desc[1] & 0x80;
Expand All @@ -478,25 +470,15 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,

if (piv && code_set == 1 && assoc == 1
&& proto == SCSI_PROTOCOL_SAS && type == 3 && len == 8)
efd.addr = (u64)desc[4] << 56 |
(u64)desc[5] << 48 |
(u64)desc[6] << 40 |
(u64)desc[7] << 32 |
(u64)desc[8] << 24 |
(u64)desc[9] << 16 |
(u64)desc[10] << 8 |
(u64)desc[11];
efd.addr = get_unaligned_be64(&desc[4]);

desc += len + 4;
}
if (!efd.addr)
goto free;
if (efd.addr) {
efd.dev = &sdev->sdev_gendev;

efd.dev = &sdev->sdev_gendev;

enclosure_for_each_device(ses_enclosure_find_by_addr, &efd);
free:
kfree(buf);
enclosure_for_each_device(ses_enclosure_find_by_addr, &efd);
}
}

static int ses_intf_add(struct device *cdev,
Expand Down

0 comments on commit c38c007

Please sign in to comment.