Date:2011-07-06 16:39:30 (9 years 2 months ago)
Author:Werner Almesberger
Commit:0d9f58be0e881b0f32f5a1b3b40f8babb26ee811
Message:atusb: added section titles and moved code in a more logical order

Signed-off-by: Werner Almesberger <werner@almesberger.net>
Files: drivers/spi/atusb.c (5 diffs)

Change Details

drivers/spi/atusb.c
105105#define ATUSB_FROM_DEV (USB_TYPE_VENDOR | USB_DIR_IN)
106106#define ATUSB_TO_DEV (USB_TYPE_VENDOR | USB_DIR_OUT)
107107
108
109/* ----- Control transfers ------------------------------------------------- */
110
111
108112static void atusb_ctrl_cb(struct urb *urb)
109113{
110114    struct atusb_local *atusb = urb->context;
...... 
159163    usb_free_urb(urb);
160164}
161165
162static int atusb_get_and_show_revision(struct atusb_local *atusb)
163{
164    struct usb_device *dev = atusb->udev;
165    int retval;
166
167    /* Get a couple of the ATMega Firmware values */
168    retval = usb_control_msg(dev,
169        usb_rcvctrlpipe(dev, 0),
170        ATUSB_ID, ATUSB_FROM_DEV, 0, 0,
171        atusb->buffer, 3, 1000);
172    if (retval < 0) {
173        dev_info(&dev->dev,
174            "failed submitting urb for ATUSB_ID, error %d", retval);
175        return retval == -ENOMEM ? retval : -EIO;
176    }
177
178    atusb->ep0_atusb_major = atusb->buffer[0];
179    atusb->ep0_atusb_minor = atusb->buffer[1];
180    atusb->atusb_hw_type = atusb->buffer[2];
181    dev_info(&dev->dev,
182        "Firmware: major: %u, minor: %u, hardware type: %u\n",
183        atusb->ep0_atusb_major, atusb->ep0_atusb_minor,
184        atusb->atusb_hw_type);
185
186    return 0;
187}
188
189static int atusb_get_and_show_build(struct atusb_local *atusb)
190{
191    struct usb_device *dev = atusb->udev;
192    char build[ATUSB_BUILD_SIZE+1];
193    int retval;
194
195    retval = usb_control_msg(dev,
196        usb_rcvctrlpipe(atusb->udev, 0),
197        ATUSB_BUILD, ATUSB_FROM_DEV, 0, 0,
198        build, ATUSB_BUILD_SIZE+1, 1000);
199    if (retval < 0) {
200        dev_info(&dev->dev,
201            "failed submitting urb for ATUSB_BUILD, error %d", retval);
202        return retval == -ENOMEM ? retval : -EIO;
203    }
204
205    dev_info(&dev->dev, "Firmware: build %s\n", build);
206
207    return 0;
208}
209
210static void atusb_reset(void *reset_data)
211{
212    int retval;
213    struct atusb_local *atusb = reset_data;
214
215    retval = usb_control_msg(atusb->udev,
216        usb_rcvctrlpipe(atusb->udev, 0),
217        ATUSB_RF_RESET, ATUSB_TO_DEV, 0, 0,
218        NULL, 0, 1000);
219    if (retval < 0) {
220        dev_info(&atusb->udev->dev,
221            "%s: error doing reset retval = %d\n",
222            __func__, retval);
223    }
224}
225
226166static int submit_control_msg(struct atusb_local *atusb,
227167    __u8 request, __u8 requesttype, __u16 value, __u16 index,
228168    void *data, __u16 size, usb_complete_t complete_fn, void *context)
...... 
266206}
267207
268208
209/* ----- SPI transfers ----------------------------------------------------- */
210
211
269212static int atusb_read1(struct atusb_local *atusb,
270213    uint8_t tx, uint8_t *rx, int len)
271214{
...... 
395338{
396339    return 0;
397340}
341
342
343/* ----- Interrupt handling ------------------------------------------------ */
344
345
398346#if 0
399347static irqreturn_t atusb_irq(int irq, void *data)
400348{
...... 
424372    .irq_unmask = atusb_irq_unmask,
425373};
426374
375
376/* ----- Transceiver reset ------------------------------------------------- */
377
378
379static void atusb_reset(void *reset_data)
380{
381    int retval;
382    struct atusb_local *atusb = reset_data;
383
384    retval = usb_control_msg(atusb->udev,
385        usb_rcvctrlpipe(atusb->udev, 0),
386        ATUSB_RF_RESET, ATUSB_TO_DEV, 0, 0,
387        NULL, 0, 1000);
388    if (retval < 0) {
389        dev_info(&atusb->udev->dev,
390            "%s: error doing reset retval = %d\n",
391            __func__, retval);
392    }
393}
394
395
396/* ----- Firmware version information -------------------------------------- */
397
398
399static int atusb_get_and_show_revision(struct atusb_local *atusb)
400{
401    struct usb_device *dev = atusb->udev;
402    int retval;
403
404    /* Get a couple of the ATMega Firmware values */
405    retval = usb_control_msg(dev,
406        usb_rcvctrlpipe(dev, 0),
407        ATUSB_ID, ATUSB_FROM_DEV, 0, 0,
408        atusb->buffer, 3, 1000);
409    if (retval < 0) {
410        dev_info(&dev->dev,
411            "failed submitting urb for ATUSB_ID, error %d", retval);
412        return retval == -ENOMEM ? retval : -EIO;
413    }
414
415    atusb->ep0_atusb_major = atusb->buffer[0];
416    atusb->ep0_atusb_minor = atusb->buffer[1];
417    atusb->atusb_hw_type = atusb->buffer[2];
418    dev_info(&dev->dev,
419        "Firmware: major: %u, minor: %u, hardware type: %u\n",
420        atusb->ep0_atusb_major, atusb->ep0_atusb_minor,
421        atusb->atusb_hw_type);
422
423    return 0;
424}
425
426static int atusb_get_and_show_build(struct atusb_local *atusb)
427{
428    struct usb_device *dev = atusb->udev;
429    char build[ATUSB_BUILD_SIZE+1];
430    int retval;
431
432    retval = usb_control_msg(dev,
433        usb_rcvctrlpipe(atusb->udev, 0),
434        ATUSB_BUILD, ATUSB_FROM_DEV, 0, 0,
435        build, ATUSB_BUILD_SIZE+1, 1000);
436    if (retval < 0) {
437        dev_info(&dev->dev,
438            "failed submitting urb for ATUSB_BUILD, error %d", retval);
439        return retval == -ENOMEM ? retval : -EIO;
440    }
441
442    dev_info(&dev->dev, "Firmware: build %s\n", build);
443
444    return 0;
445}
446
447
448/* ----- Setup ------------------------------------------------------------- */
449
450
427451struct at86rf230_platform_data at86rf230_platform_data = {
428452    .rstn = -1,
429453    .slp_tr = -1,

Archive Download the corresponding diff file



interactive