Lines Matching +full:motor +full:- +full:driver
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
4 * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
6 * USB/RS232 I-Force joysticks and wheels.
30 spin_lock_irqsave(&iforce->xmit_lock, flags); in __iforce_usb_xmit()
32 if (iforce->xmit.head == iforce->xmit.tail) { in __iforce_usb_xmit()
34 spin_unlock_irqrestore(&iforce->xmit_lock, flags); in __iforce_usb_xmit()
38 ((char *)iforce_usb->out->transfer_buffer)[0] = iforce->xmit.buf[iforce->xmit.tail]; in __iforce_usb_xmit()
39 XMIT_INC(iforce->xmit.tail, 1); in __iforce_usb_xmit()
40 n = iforce->xmit.buf[iforce->xmit.tail]; in __iforce_usb_xmit()
41 XMIT_INC(iforce->xmit.tail, 1); in __iforce_usb_xmit()
43 iforce_usb->out->transfer_buffer_length = n + 1; in __iforce_usb_xmit()
44 iforce_usb->out->dev = iforce_usb->usbdev; in __iforce_usb_xmit()
47 c = CIRC_CNT_TO_END(iforce->xmit.head, iforce->xmit.tail, XMIT_SIZE); in __iforce_usb_xmit()
50 memcpy(iforce_usb->out->transfer_buffer + 1, in __iforce_usb_xmit()
51 &iforce->xmit.buf[iforce->xmit.tail], in __iforce_usb_xmit()
54 memcpy(iforce_usb->out->transfer_buffer + 1 + c, in __iforce_usb_xmit()
55 &iforce->xmit.buf[0], in __iforce_usb_xmit()
56 n-c); in __iforce_usb_xmit()
58 XMIT_INC(iforce->xmit.tail, n); in __iforce_usb_xmit()
60 if ( (n=usb_submit_urb(iforce_usb->out, GFP_ATOMIC)) ) { in __iforce_usb_xmit()
61 dev_warn(&iforce_usb->intf->dev, in __iforce_usb_xmit()
69 spin_unlock_irqrestore(&iforce->xmit_lock, flags); in __iforce_usb_xmit()
74 if (!test_and_set_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)) in iforce_usb_xmit()
88 return -ENOMEM; in iforce_usb_get_id()
90 status = usb_control_msg(iforce_usb->usbdev, in iforce_usb_get_id()
91 usb_rcvctrlpipe(iforce_usb->usbdev, 0), in iforce_usb_get_id()
97 dev_err(&iforce_usb->intf->dev, in iforce_usb_get_id()
100 status = -EIO; in iforce_usb_get_id()
116 if (usb_submit_urb(iforce_usb->irq, GFP_KERNEL)) in iforce_usb_start_io()
117 return -EIO; in iforce_usb_start_io()
127 usb_kill_urb(iforce_usb->irq); in iforce_usb_stop_io()
128 usb_kill_urb(iforce_usb->out); in iforce_usb_stop_io()
140 struct iforce_usb *iforce_usb = urb->context; in iforce_usb_irq()
141 struct iforce *iforce = &iforce_usb->iforce; in iforce_usb_irq()
142 struct device *dev = &iforce_usb->intf->dev; in iforce_usb_irq()
145 switch (urb->status) { in iforce_usb_irq()
149 case -ECONNRESET: in iforce_usb_irq()
150 case -ENOENT: in iforce_usb_irq()
151 case -ESHUTDOWN: in iforce_usb_irq()
153 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in iforce_usb_irq()
154 __func__, urb->status); in iforce_usb_irq()
157 dev_dbg(dev, "%s - urb has status of: %d\n", in iforce_usb_irq()
158 __func__, urb->status); in iforce_usb_irq()
162 iforce_process_packet(iforce, iforce_usb->data_in[0], in iforce_usb_irq()
163 iforce_usb->data_in + 1, urb->actual_length - 1); in iforce_usb_irq()
168 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", in iforce_usb_irq()
174 struct iforce_usb *iforce_usb = urb->context; in iforce_usb_out()
175 struct iforce *iforce = &iforce_usb->iforce; in iforce_usb_out()
177 if (urb->status) { in iforce_usb_out()
178 dev_dbg(&iforce_usb->intf->dev, "urb->status %d, exiting\n", in iforce_usb_out()
179 urb->status); in iforce_usb_out()
186 wake_up_all(&iforce->wait); in iforce_usb_out()
196 int err = -ENOMEM; in iforce_usb_probe()
198 interface = intf->cur_altsetting; in iforce_usb_probe()
200 if (interface->desc.bNumEndpoints < 2) in iforce_usb_probe()
201 return -ENODEV; in iforce_usb_probe()
203 epirq = &interface->endpoint[0].desc; in iforce_usb_probe()
205 return -ENODEV; in iforce_usb_probe()
207 epout = &interface->endpoint[1].desc; in iforce_usb_probe()
209 return -ENODEV; in iforce_usb_probe()
215 iforce_usb->irq = usb_alloc_urb(0, GFP_KERNEL); in iforce_usb_probe()
216 if (!iforce_usb->irq) in iforce_usb_probe()
219 iforce_usb->out = usb_alloc_urb(0, GFP_KERNEL); in iforce_usb_probe()
220 if (!iforce_usb->out) in iforce_usb_probe()
223 iforce_usb->iforce.xport_ops = &iforce_usb_xport_ops; in iforce_usb_probe()
225 iforce_usb->usbdev = dev; in iforce_usb_probe()
226 iforce_usb->intf = intf; in iforce_usb_probe()
228 usb_fill_int_urb(iforce_usb->irq, dev, in iforce_usb_probe()
229 usb_rcvintpipe(dev, epirq->bEndpointAddress), in iforce_usb_probe()
230 iforce_usb->data_in, sizeof(iforce_usb->data_in), in iforce_usb_probe()
231 iforce_usb_irq, iforce_usb, epirq->bInterval); in iforce_usb_probe()
233 usb_fill_int_urb(iforce_usb->out, dev, in iforce_usb_probe()
234 usb_sndintpipe(dev, epout->bEndpointAddress), in iforce_usb_probe()
235 iforce_usb->data_out, sizeof(iforce_usb->data_out), in iforce_usb_probe()
236 iforce_usb_out, iforce_usb, epout->bInterval); in iforce_usb_probe()
238 err = iforce_init_device(&intf->dev, BUS_USB, &iforce_usb->iforce); in iforce_usb_probe()
247 usb_free_urb(iforce_usb->irq); in iforce_usb_probe()
248 usb_free_urb(iforce_usb->out); in iforce_usb_probe()
261 input_unregister_device(iforce_usb->iforce.dev); in iforce_usb_disconnect()
263 usb_free_urb(iforce_usb->irq); in iforce_usb_disconnect()
264 usb_free_urb(iforce_usb->out); in iforce_usb_disconnect()
270 { USB_DEVICE(0x044f, 0xa01c) }, /* Thrustmaster Motor Sport GT */
298 MODULE_DESCRIPTION("USB I-Force joysticks and wheels driver");