d(&ati_remote->wait);
/* Set up irq_urb */
pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress);
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp;
usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
maxp, ati_remote_irq_in, ati_remote,
ati_remote->endpoint_in->bInterval);
ati_remote->irq_urb->transfer_dma = ati_remote->inbuf_dma;
ati_remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
/* Set up out_urb */
pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress);
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp;
usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
maxp, ati_remote_irq_out, ati_remote,
ati_remote->endpoint_out->bInterval);
ati_remote->out_urb->transfer_dma = ati_remote->outbuf_dma;
ati_remote->out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
/* send initialization strings */
if ((ati_remote_sendpacket(ati_remote, 0x8004, init1)) ||
(ati_remote_sendpacket(ati_remote, 0x8007, init2))) {
dev_err(&ati_remote->interface->dev,
"Initializing ati_remote hardware failed.\n");
return 1;
}
return 0;
}
/*
* ati_remote_probe
*/
static int ati_remote_probe(struct usb_interface *interface, const struct
usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(interface);
struct ati_remote *ati_remote = NULL;
struct usb_host_interface *iface_host;
int retval = -ENOMEM;
char path[64];
char *buf = NULL;
/* See if the offered device matches what we can accept */
if ((udev->descriptor.idVendor != ATI_REMOTE_VENDOR_ID) ||
( (udev->descriptor.idProduct != ATI_REMOTE_PRODUCT_ID) &&
(udev->descriptor.idProduct != LOLA_REMOTE_PRODUCT_ID) ))
return -ENODEV;
/* Allocate and clear an ati_remote struct */
if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL)))
return -ENOMEM;
memset(ati_remote, 0x00, sizeof (struct ati_remote));
iface_host = interface->cur_altsetting;
if (iface_host->desc.bNumEndpoints != 2) {
err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__);
retval = -ENODEV;
goto error;
}
ati_remote->endpoint_in = &(iface_host->endpoint[0].desc);
ati_remote->endpoint_out = &(iface_host->endpoint[1].desc);
ati_remote->udev = udev;
ati_remote->interface = interface;
if (!(ati_remote->endpoint_in->bEndpointAddress & 0x80)) {
err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__);
retval = -ENODEV;
goto error;
}
if ((ati_remote->endpoint_in->bmAttributes & 3) != 3) {
err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__);
retval = -ENODEV;
goto error;
}
if (ati_remote->endpoint_in->wMaxPacketSize == 0) {
err("%s: endpoint_in message size==0? \n", __FUNCTION__);
retval = -ENODEV;
goto error;
}
if (!(buf = kmalloc(NAME_BUFSIZE, GFP_KERNEL)))
goto error;
/* Allocate URB buffers, URBs */
ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC,
&ati_remote->inbuf_dma);
if (!ati_remote->inbuf)
goto error;
ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC,
&ati_remote->outbuf_dma);
if (!ati_remote->outbuf)
goto error;
ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!ati_remote->irq_urb)
goto error;
ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!ati_remote->out_urb)
goto error;
usb_make_path(udev, path, NAME_BUFSIZE);
sprintf(ati_remote->phys, "%s/input%d", path, ATI_INPUTNUM);
if (udev->descriptor.iManufacturer &&
(usb_string(udev, udev->descriptor.iManufacturer, buf,
NAME_BUFSIZE) > 0))
strcat(ati_remote->name, buf);
if (udev->descriptor.iProduct &&
(usb_string(udev, udev->descriptor.iProduct, buf, NAME_BUFSIZE) > 0))
sprintf(ati_remote->name, "%s %s", ati_remote->name, buf);
if (!strlen(ati_remote->name))
sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)",
ati_remote->udev->descriptor.idVendor,
ati_remote->udev->descriptor.idProduct);
/* Device Hardware Initialization - fills in ati_remote->idev from udev. */
retval = ati_remote_initialize(ati_remote);
if (retval)
goto error;
/* Set up and register input device */
ati_remote_input_init(ati_remote);
input_register_device(&ati_remote->idev);
dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n",
ati_remote->name, path);
usb_set_intfdata(interface, ati_remote);
ati_remote->present = 1;
error:
if (buf)
kfree(buf);
if (retval)
ati_remote_delete(ati_remote);
return retval;
}
/*
* ati_remote_disconnect
*/
static void ati_remote_disconnect(struct usb_interface *interface)
{
struct ati_remote *ati_