Rename usbserial to usbserial_ftdi

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-07-18 16:31:42 +02:00
parent fd5b663793
commit dd20a7868b
3 changed files with 34 additions and 9 deletions

View file

@ -172,13 +172,22 @@ static struct grub_serial_driver grub_usbserial_driver =
.put = usbserial_hw_put .put = usbserial_hw_put
}; };
static const struct
{
grub_uint16_t vendor, product;
} products[] =
{
{0x0403, 0x6001} /* QEMU virtual USBserial. */
};
static int static int
grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno) grub_ftdi_attach (grub_usb_device_t usbdev, int configno, int interfno)
{ {
static struct grub_serial_port *port; static struct grub_serial_port *port;
int j; int j;
struct grub_usb_desc_if *interf struct grub_usb_desc_if *interf;
= usbdev->config[configno].interf[interfno].descif;
interf = usbdev->config[configno].interf[interfno].descif;
port = grub_malloc (sizeof (*port)); port = grub_malloc (sizeof (*port));
if (!port) if (!port)
@ -226,13 +235,28 @@ grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno)
return 1; return 1;
} }
static int
grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno)
{
unsigned j;
for (j = 0; j < ARRAY_SIZE (products); j++)
if (usbdev->descdev.vendorid == products[j].vendor
&& usbdev->descdev.prodid == products[j].product)
break;
if (j == ARRAY_SIZE (products))
return 0;
return grub_ftdi_attach (usbdev, configno, interfno);
}
struct grub_usb_attach_desc attach_hook = struct grub_usb_attach_desc attach_hook =
{ {
.class = 0xff, .class = 0xff,
.hook = grub_usbserial_attach .hook = grub_usbserial_attach
}; };
GRUB_MOD_INIT(usbserial) GRUB_MOD_INIT(usbserial_ftdi)
{ {
grub_usb_register_attach_hook_class (&attach_hook); grub_usb_register_attach_hook_class (&attach_hook);
} }

View file

@ -270,7 +270,8 @@ void grub_usb_device_attach (grub_usb_device_t dev)
grub_dl_load ("usb_keyboard"); grub_dl_load ("usb_keyboard");
break; break;
case 0xff: case 0xff:
grub_dl_load ("usbserial"); /* FIXME: don't load useless modules. */
grub_dl_load ("usbserial_ftdi");
break; break;
} }
} }

View file

@ -196,10 +196,10 @@ usb_mod_CFLAGS = $(COMMON_CFLAGS)
usb_mod_LDFLAGS = $(COMMON_LDFLAGS) usb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For serial.mod. # For serial.mod.
pkglib_MODULES += usbserial.mod pkglib_MODULES += usbserial_ftdi.mod
usbserial_mod_SOURCES = term/usbserial.c usbserial_ftdi_mod_SOURCES = bus/usb/serial/ftdi.c
usbserial_mod_CFLAGS = $(COMMON_CFLAGS) usbserial_ftdi_mod_CFLAGS = $(COMMON_CFLAGS)
usbserial_mod_LDFLAGS = $(COMMON_LDFLAGS) usbserial_ftdi_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usbtest.mod # For usbtest.mod
usbtest_mod_SOURCES = commands/usbtest.c usbtest_mod_SOURCES = commands/usbtest.c