Changeset 0bd2879 in mainline for uspace/drv/uhci/utils/usb_device.c


Ignore:
Timestamp:
2011-01-08T21:51:41Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
977fcea
Parents:
602eac5
Message:

Refactoring move usb generics to usb_device.c

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/utils/usb_device.c

    r602eac5 r0bd2879  
    3232#include <usb/usbdrv.h>
    3333
    34 #include "identify.h"
     34#include "debug.h"
     35#include "usb_device.h"
    3536
     37/*----------------------------------------------------------------------------*/
     38#define CHECK_RET_RETURN(ret, child, message, args...)\
     39  if (ret < 0) { \
     40    uhci_print_error("Failed(%d) to "message, ret, ##args); \
     41    return ret; \
     42  } else (void)0
     43
     44int usb_device_init(device_t *device, device_t *hc, usb_address_t address,
     45  int hub_port)
     46{
     47        assert(device);
     48        assert(hc);
     49
     50        int ret = 0;
     51  char *name;
     52
     53  /* create name */
     54  ret = asprintf(&name, "usbdevice on hc%p/root_hub[%d]/%#x",
     55          hc, hub_port, address);
     56  CHECK_RET_RETURN(ret, child, "create device name.\n");
     57
     58  device->name = name;
     59
     60        /* use descriptors to identify the device */
     61  ret = usb_device_identify(device, hc, address);
     62  CHECK_RET_RETURN(ret, child, "identify device.\n");
     63
     64        return EOK;
     65}
     66/*----------------------------------------------------------------------------*/
    3667struct device_descriptor_packet
    3768{
     
    6697        }
    6798/*----------------------------------------------------------------------------*/
    68 int identify_device(device_t *hc, device_t *child, usb_address_t address)
     99int usb_device_identify(device_t *device, device_t *hc, usb_address_t address)
    69100{
     101        assert(device);
     102        assert(hc);
     103
    70104        struct device_descriptor_packet packet =
    71105          DEVICE_DESCRIPTOR_PACKET_INITIALIZER;
     
    73107  packet.descriptor.device_class = USB_CLASS_HUB;
    74108  usb_drv_create_match_ids_from_device_descriptor(
    75           &child->match_ids, &packet.descriptor );
     109          &device->match_ids, &packet.descriptor );
    76110
    77111        return 0;
    78112}
     113/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.