Date: Thu, 21 May 2009 01:05:21 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r192500 - in head/sys/dev/usb: . controller template Message-ID: <200905210105.n4L15LQK049618@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Thu May 21 01:05:21 2009 New Revision: 192500 URL: http://svn.freebsd.org/changeset/base/192500 Log: Use enums for speed and rev data types. Modified: head/sys/dev/usb/controller/usb_controller.c head/sys/dev/usb/template/usb_template.c head/sys/dev/usb/usb_bus.h head/sys/dev/usb/usb_compat_linux.h head/sys/dev/usb/usb_controller.h head/sys/dev/usb/usb_core.h head/sys/dev/usb/usb_device.c head/sys/dev/usb/usb_device.h head/sys/dev/usb/usb_hub.c head/sys/dev/usb/usb_revision.h head/sys/dev/usb/usb_transfer.c head/sys/dev/usb/usb_transfer.h Modified: head/sys/dev/usb/controller/usb_controller.c ============================================================================== --- head/sys/dev/usb/controller/usb_controller.c Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/controller/usb_controller.c Thu May 21 01:05:21 2009 (r192500) @@ -290,7 +290,7 @@ usb2_bus_attach(struct usb2_proc_msg *pm struct usb2_device *child; device_t dev; usb2_error_t err; - uint8_t speed; + enum usb_dev_speed speed; bus = ((struct usb2_bus_msg *)pm)->bus; dev = bus->bdev; Modified: head/sys/dev/usb/template/usb_template.c ============================================================================== --- head/sys/dev/usb/template/usb_template.c Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/template/usb_template.c Thu May 21 01:05:21 2009 (r192500) @@ -167,7 +167,7 @@ usb2_make_endpoint_desc(struct usb2_temp temp->err = USB_ERR_INVAL; return; } - mps = ted->pPacketSize->mps[temp->usb2_speed]; + mps = ted->pPacketSize->mps[temp->usb_speed]; if (mps == 0) { /* not initialized */ temp->err = USB_ERR_INVAL; @@ -194,9 +194,9 @@ usb2_make_endpoint_desc(struct usb2_temp /* setup bInterval parameter */ if (ted->pIntervals && - ted->pIntervals->bInterval[temp->usb2_speed]) { + ted->pIntervals->bInterval[temp->usb_speed]) { ed->bInterval = - ted->pIntervals->bInterval[temp->usb2_speed]; + ted->pIntervals->bInterval[temp->usb_speed]; } else { switch (et) { case UE_BULK: @@ -204,7 +204,7 @@ usb2_make_endpoint_desc(struct usb2_temp ed->bInterval = 0; /* not used */ break; case UE_INTERRUPT: - switch (temp->usb2_speed) { + switch (temp->usb_speed) { case USB_SPEED_LOW: case USB_SPEED_FULL: ed->bInterval = 1; /* 1 ms */ @@ -215,7 +215,7 @@ usb2_make_endpoint_desc(struct usb2_temp } break; default: /* UE_ISOCHRONOUS */ - switch (temp->usb2_speed) { + switch (temp->usb_speed) { case USB_SPEED_LOW: case USB_SPEED_FULL: ed->bInterval = 1; /* 1 ms */ @@ -435,7 +435,7 @@ usb2_make_device_desc(struct usb2_temp_s USETW(utd->udq.bcdUSB, 0x0200); utd->udq.bMaxPacketSize0 = 0; - switch (temp->usb2_speed) { + switch (temp->usb_speed) { case USB_SPEED_LOW: USETW(utd->udd.bcdUSB, 0x0110); utd->udd.bMaxPacketSize = 8; @@ -622,9 +622,9 @@ usb2_hw_ep_get_needs(struct usb2_hw_ep_s struct usb2_descriptor *desc; struct usb2_interface_descriptor *id; struct usb2_endpoint_descriptor *ed; + enum usb_dev_speed speed; uint16_t wMaxPacketSize; uint16_t temp; - uint8_t speed; uint8_t ep_no; ep_iface = ues->ep_max; @@ -1192,7 +1192,7 @@ usb2_temp_setup(struct usb2_device *udev bzero(uts, sizeof(*uts)); - uts->usb2_speed = udev->speed; + uts->usb_speed = udev->speed; uts->self_powered = udev->flags.self_powered; /* first pass */ Modified: head/sys/dev/usb/usb_bus.h ============================================================================== --- head/sys/dev/usb/usb_bus.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_bus.h Thu May 21 01:05:21 2009 (r192500) @@ -93,7 +93,7 @@ struct usb2_bus { uint8_t alloc_failed; /* Set if memory allocation failed. */ uint8_t driver_added_refcount; /* Current driver generation count */ - uint8_t usbrev; /* USB revision. See "USB_REV_XXX". */ + enum usb_revision usbrev; /* USB revision. See "USB_REV_XXX". */ uint8_t devices_max; /* maximum number of USB devices */ uint8_t do_probe; /* set if USB BUS should be re-probed */ Modified: head/sys/dev/usb/usb_compat_linux.h ============================================================================== --- head/sys/dev/usb/usb_compat_linux.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_compat_linux.h Thu May 21 01:05:21 2009 (r192500) @@ -370,7 +370,7 @@ struct usb_device { uint16_t devnum; - uint8_t speed; /* USB_SPEED_XXX */ + enum usb_dev_speed speed; /* USB_SPEED_XXX */ } __aligned(USB_HOST_ALIGN); /* Modified: head/sys/dev/usb/usb_controller.h ============================================================================== --- head/sys/dev/usb/usb_controller.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_controller.h Thu May 21 01:05:21 2009 (r192500) @@ -171,7 +171,7 @@ struct usb2_hw_ep_scratch { struct usb2_temp_setup { void *buf; usb2_size_t size; - uint8_t usb2_speed; + enum usb_dev_speed usb_speed; uint8_t self_powered; uint8_t bNumEndpoints; uint8_t bInterfaceNumber; Modified: head/sys/dev/usb/usb_core.h ============================================================================== --- head/sys/dev/usb/usb_core.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_core.h Thu May 21 01:05:21 2009 (r192500) @@ -515,7 +515,7 @@ typedef struct malloc_type *usb2_malloc_ /* prototypes */ const char *usb2_errstr(usb2_error_t error); -const char *usb2_statestr(enum usb2_dev_state state); +const char *usb2_statestr(enum usb_dev_state state); struct usb2_config_descriptor *usb2_get_config_descriptor( struct usb2_device *udev); struct usb2_device_descriptor *usb2_get_device_descriptor( @@ -530,7 +530,7 @@ uint8_t usb2_get_interface_altindex(stru usb2_error_t usb2_set_alt_interface_index(struct usb2_device *udev, uint8_t iface_index, uint8_t alt_index); enum usb_hc_mode usb2_get_mode(struct usb2_device *udev); -uint8_t usb2_get_speed(struct usb2_device *udev); +enum usb_dev_speed usb2_get_speed(struct usb2_device *udev); uint32_t usb2_get_isoc_fps(struct usb2_device *udev); usb2_error_t usb2_transfer_setup(struct usb2_device *udev, const uint8_t *ifaces, struct usb2_xfer **pxfer, Modified: head/sys/dev/usb/usb_device.c ============================================================================== --- head/sys/dev/usb/usb_device.c Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_device.c Thu May 21 01:05:21 2009 (r192500) @@ -99,7 +99,7 @@ static const char* statestr[USB_STATE_MA }; const char * -usb2_statestr(enum usb2_dev_state state) +usb2_statestr(enum usb_dev_state state) { return ((state < USB_STATE_MAX) ? statestr[state] : "UNKNOWN"); } @@ -1417,7 +1417,7 @@ usb2_clear_stall_proc(struct usb2_proc_m struct usb2_device * usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus, struct usb2_device *parent_hub, uint8_t depth, uint8_t port_index, - uint8_t port_no, uint8_t speed, enum usb_hc_mode mode) + uint8_t port_no, enum usb_dev_speed speed, enum usb_hc_mode mode) { struct usb2_attach_arg uaa; struct usb2_device *udev; @@ -2249,7 +2249,7 @@ usb2_get_mode(struct usb2_device *udev) * Returns: * See: USB_SPEED_XXX */ -uint8_t +enum usb_dev_speed usb2_get_speed(struct usb2_device *udev) { return (udev->speed); @@ -2459,7 +2459,7 @@ usb2_peer_can_wakeup(struct usb2_device } void -usb2_set_device_state(struct usb2_device *udev, enum usb2_dev_state state) +usb2_set_device_state(struct usb2_device *udev, enum usb_dev_state state) { KASSERT(state < USB_STATE_MAX, ("invalid udev state")); Modified: head/sys/dev/usb/usb_device.h ============================================================================== --- head/sys/dev/usb/usb_device.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_device.h Thu May 21 01:05:21 2009 (r192500) @@ -145,7 +145,8 @@ struct usb2_device { #endif usb2_ticks_t plugtime; /* copy of "ticks" */ - enum usb2_dev_state state; + enum usb_dev_state state; + enum usb_dev_speed speed; uint16_t refcount; #define USB_DEV_REF_MAX 0xffff @@ -157,7 +158,6 @@ struct usb2_device { uint8_t curr_config_index; /* current configuration index */ uint8_t curr_config_no; /* current configuration number */ uint8_t depth; /* distance from root HUB */ - uint8_t speed; /* low/full/high speed */ uint8_t port_index; /* parent HUB port index */ uint8_t port_no; /* parent HUB port number */ uint8_t hs_hub_addr; /* high-speed HUB address */ @@ -189,8 +189,8 @@ extern int usb2_template; struct usb2_device *usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus, struct usb2_device *parent_hub, uint8_t depth, - uint8_t port_index, uint8_t port_no, uint8_t speed, - enum usb_hc_mode mode); + uint8_t port_index, uint8_t port_no, + enum usb_dev_speed speed, enum usb_hc_mode mode); struct usb2_pipe *usb2_get_pipe(struct usb2_device *udev, uint8_t iface_index, const struct usb2_config *setup); struct usb2_pipe *usb2_get_pipe_by_addr(struct usb2_device *udev, uint8_t ea_val); @@ -213,6 +213,6 @@ void usb_linux_free_device(struct usb_de uint8_t usb2_peer_can_wakeup(struct usb2_device *udev); struct usb2_pipe *usb2_pipe_foreach(struct usb2_device *udev, struct usb2_pipe *pipe); void usb2_set_device_state(struct usb2_device *udev, - enum usb2_dev_state state); + enum usb_dev_state state); #endif /* _USB2_DEVICE_H_ */ Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_hub.c Thu May 21 01:05:21 2009 (r192500) @@ -273,10 +273,10 @@ uhub_reattach_port(struct uhub_softc *sc { struct usb2_device *child; struct usb2_device *udev; + enum usb_dev_speed speed; + enum usb_hc_mode mode; usb2_error_t err; uint8_t timeout; - uint8_t speed; - enum usb_hc_mode mode; DPRINTF("reattaching port %d\n", portno); @@ -1098,7 +1098,7 @@ usb2_intr_schedule_adjust(struct usb2_de { struct usb2_bus *bus = udev->bus; struct usb2_hub *hub; - uint8_t speed; + enum usb_dev_speed speed; USB_BUS_LOCK_ASSERT(bus, MA_OWNED); Modified: head/sys/dev/usb/usb_revision.h ============================================================================== --- head/sys/dev/usb/usb_revision.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_revision.h Thu May 21 01:05:21 2009 (r192500) @@ -30,7 +30,7 @@ /* * The "USB_SPEED" macros defines all the supported USB speeds. */ -enum usb2_speed { +enum usb_dev_speed { USB_SPEED_VARIABLE, USB_SPEED_LOW, USB_SPEED_FULL, @@ -42,7 +42,7 @@ enum usb2_speed { /* * The "USB_REV" macros defines all the supported USB revisions. */ -enum usb2_revision { +enum usb_revision { USB_REV_UNKNOWN, USB_REV_PRE_1_0, USB_REV_1_0, @@ -66,7 +66,7 @@ enum usb_hc_mode { /* * The "USB_MODE" macros defines all the supported device states. */ -enum usb2_dev_state { +enum usb_dev_state { USB_STATE_DETACHED, USB_STATE_ATTACHED, USB_STATE_POWERED, Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_transfer.c Thu May 21 01:05:21 2009 (r192500) @@ -93,7 +93,7 @@ static void usb2_dma_delay_done_cb(void static void usb2_transfer_start_cb(void *); static uint8_t usb2_callback_wrapper_sub(struct usb2_xfer *); static void usb2_get_std_packet_size(struct usb2_std_packet_size *ptr, - uint8_t type, uint8_t usb_speed); + uint8_t type, enum usb_dev_speed speed); /*------------------------------------------------------------------------* * usb2_request_callback @@ -2742,8 +2742,8 @@ usb2_do_poll(struct usb2_xfer **ppxfer, } static void -usb2_get_std_packet_size(struct usb2_std_packet_size *ptr, - uint8_t type, uint8_t usb_speed) +usb2_get_std_packet_size(struct usb2_std_packet_size *ptr, + uint8_t type, enum usb_dev_speed speed) { static const uint16_t intr_range_max[USB_SPEED_MAX] = { [USB_SPEED_LOW] = 8, @@ -2783,16 +2783,16 @@ usb2_get_std_packet_size(struct usb2_std switch (type) { case UE_INTERRUPT: - ptr->range.max = intr_range_max[usb_speed]; + ptr->range.max = intr_range_max[speed]; break; case UE_ISOCHRONOUS: - ptr->range.max = isoc_range_max[usb_speed]; + ptr->range.max = isoc_range_max[speed]; break; default: if (type == UE_BULK) - temp = bulk_min[usb_speed]; + temp = bulk_min[speed]; else /* UE_CONTROL */ - temp = control_min[usb_speed]; + temp = control_min[speed]; /* default is fixed */ ptr->fixed[0] = temp; @@ -2800,13 +2800,13 @@ usb2_get_std_packet_size(struct usb2_std ptr->fixed[2] = temp; ptr->fixed[3] = temp; - if (usb_speed == USB_SPEED_FULL) { + if (speed == USB_SPEED_FULL) { /* multiple sizes */ ptr->fixed[1] = 16; ptr->fixed[2] = 32; ptr->fixed[3] = 64; } - if ((usb_speed == USB_SPEED_VARIABLE) && + if ((speed == USB_SPEED_VARIABLE) && (type == UE_BULK)) { /* multiple sizes */ ptr->fixed[2] = 1024; Modified: head/sys/dev/usb/usb_transfer.h ============================================================================== --- head/sys/dev/usb/usb_transfer.h Thu May 21 00:04:17 2009 (r192499) +++ head/sys/dev/usb/usb_transfer.h Thu May 21 01:05:21 2009 (r192500) @@ -104,7 +104,7 @@ struct usb2_setup_params { uint16_t hc_max_frame_size; uint16_t hc_max_packet_size; uint8_t hc_max_packet_count; - uint8_t speed; + enum usb_dev_speed speed; uint8_t dma_tag_max; usb2_error_t err; };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905210105.n4L15LQK049618>