Skip to content

Commit 6a28311

Browse files
committed
usbmass: bd.devNr is usb port number
0=first port 1=second port Also move devNr responsibility 1 layer down, from scsi to usbmass.
1 parent deb7e93 commit 6a28311

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

iop/usb/usbmass_bd/src/imports.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ I_sceUsbdClosePipe
3636
I_sceUsbdSetPrivateData
3737
I_sceUsbdTransferPipe
3838
I_sceUsbdRegisterLdd
39+
I_sceUsbdGetDeviceLocation
3940
usbd_IMPORTS_end

iop/usb/usbmass_bd/src/include/scsi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct scsi_interface
55
{
66
void *priv;
77
char *name;
8+
unsigned int devNr;
89
unsigned int max_sectors;
910

1011
int (*get_max_lun)(struct scsi_interface *scsi);

iop/usb/usbmass_bd/src/scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ void scsi_connect(struct scsi_interface *scsi)
300300

301301
bd->priv = scsi;
302302
bd->name = scsi->name;
303+
bd->devNr = scsi->devNr;
303304
scsi_warmup(bd);
304305
bdm_connect_bd(bd);
305306
break;
@@ -330,7 +331,6 @@ int scsi_init(void)
330331
M_DEBUG("%s\n", __func__);
331332

332333
for (i = 0; i < NUM_DEVICES; ++i) {
333-
g_scsi_bd[i].devNr = i;
334334
g_scsi_bd[i].parNr = 0;
335335
g_scsi_bd[i].parId = 0x00;
336336

iop/usb/usbmass_bd/src/usb_mass.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,9 @@ static void usb_mass_update(void *arg)
764764
for (i = 0; i < new_devs_count; i += 1) {
765765
mass_dev *dev = new_devs[i];
766766
{
767+
u8 path[16] = {0};
767768
int ret;
769+
768770
if ((ret = usb_set_configuration(dev, dev->configId)) != USB_RC_OK) {
769771
M_PRINTF("ERROR: sending set_configuration %d\n", ret);
770772
usb_mass_release(dev);
@@ -784,6 +786,14 @@ static void usb_mass_update(void *arg)
784786
}
785787
}
786788

789+
sceUsbdGetDeviceLocation(dev->devId, path);
790+
if (path[0] == 1)
791+
dev->scsi.devNr = 0; // first USB port
792+
else if (path[0] == 2)
793+
dev->scsi.devNr = 1; // second USB port
794+
else
795+
dev->scsi.devNr = 2; // hub?
796+
787797
dev->status |= USBMASS_DEV_STAT_CONF;
788798
scsi_connect(&dev->scsi);
789799

0 commit comments

Comments
 (0)