Deleted Added
full compact
usb_hub.c (246759) usb_hub.c (250207)
1/* $FreeBSD: head/sys/dev/usb/usb_hub.c 246759 2013-02-13 12:35:17Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/usb_hub.c 250207 2013-05-03 11:10:04Z hselasky $ */
2/*-
3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
5 * Copyright (c) 2008-2010 Hans Petter Selasky. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:

--- 85 unchanged lines hidden (view full) ---

95
96struct uhub_current_state {
97 uint16_t port_change;
98 uint16_t port_status;
99};
100
101struct uhub_softc {
102 struct uhub_current_state sc_st;/* current state */
2/*-
3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
5 * Copyright (c) 2008-2010 Hans Petter Selasky. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:

--- 85 unchanged lines hidden (view full) ---

95
96struct uhub_current_state {
97 uint16_t port_change;
98 uint16_t port_status;
99};
100
101struct uhub_softc {
102 struct uhub_current_state sc_st;/* current state */
103#if (USB_HAVE_FIXED_PORT != 0)
104 struct usb_hub sc_hub;
105#endif
103 device_t sc_dev; /* base device */
104 struct mtx sc_mtx; /* our mutex */
105 struct usb_device *sc_udev; /* USB device */
106 struct usb_xfer *sc_xfer[UHUB_N_TRANSFER]; /* interrupt xfer */
107 uint8_t sc_flags;
108#define UHUB_FLAG_DID_EXPLORE 0x01
109};
110

--- 806 unchanged lines hidden (view full) ---

917 struct uhub_softc *sc = device_get_softc(dev);
918 struct usb_attach_arg *uaa = device_get_ivars(dev);
919 struct usb_device *udev = uaa->device;
920 struct usb_device *parent_hub = udev->parent_hub;
921 struct usb_hub *hub;
922 struct usb_hub_descriptor hubdesc20;
923 struct usb_hub_ss_descriptor hubdesc30;
924 uint16_t pwrdly;
106 device_t sc_dev; /* base device */
107 struct mtx sc_mtx; /* our mutex */
108 struct usb_device *sc_udev; /* USB device */
109 struct usb_xfer *sc_xfer[UHUB_N_TRANSFER]; /* interrupt xfer */
110 uint8_t sc_flags;
111#define UHUB_FLAG_DID_EXPLORE 0x01
112};
113

--- 806 unchanged lines hidden (view full) ---

920 struct uhub_softc *sc = device_get_softc(dev);
921 struct usb_attach_arg *uaa = device_get_ivars(dev);
922 struct usb_device *udev = uaa->device;
923 struct usb_device *parent_hub = udev->parent_hub;
924 struct usb_hub *hub;
925 struct usb_hub_descriptor hubdesc20;
926 struct usb_hub_ss_descriptor hubdesc30;
927 uint16_t pwrdly;
928 uint16_t nports;
925 uint8_t x;
929 uint8_t x;
926 uint8_t nports;
927 uint8_t portno;
928 uint8_t removable;
929 uint8_t iface_index;
930 usb_error_t err;
931
932 sc->sc_udev = udev;
933 sc->sc_dev = dev;
934

--- 127 unchanged lines hidden (view full) ---

1062 /* default power delay */
1063 pwrdly = ((10 * UHD_PWRON_FACTOR) + usb_extra_power_up_time);
1064 break;
1065 }
1066 if (nports == 0) {
1067 DPRINTFN(0, "portless HUB\n");
1068 goto error;
1069 }
930 uint8_t portno;
931 uint8_t removable;
932 uint8_t iface_index;
933 usb_error_t err;
934
935 sc->sc_udev = udev;
936 sc->sc_dev = dev;
937

--- 127 unchanged lines hidden (view full) ---

1065 /* default power delay */
1066 pwrdly = ((10 * UHD_PWRON_FACTOR) + usb_extra_power_up_time);
1067 break;
1068 }
1069 if (nports == 0) {
1070 DPRINTFN(0, "portless HUB\n");
1071 goto error;
1072 }
1073 if (nports > USB_MAX_PORTS) {
1074 DPRINTF("Port limit exceeded\n");
1075 goto error;
1076 }
1077#if (USB_HAVE_FIXED_PORT == 0)
1070 hub = malloc(sizeof(hub[0]) + (sizeof(hub->ports[0]) * nports),
1071 M_USBDEV, M_WAITOK | M_ZERO);
1072
1078 hub = malloc(sizeof(hub[0]) + (sizeof(hub->ports[0]) * nports),
1079 M_USBDEV, M_WAITOK | M_ZERO);
1080
1073 if (hub == NULL) {
1081 if (hub == NULL)
1074 goto error;
1082 goto error;
1075 }
1083#else
1084 hub = &sc->sc_hub;
1085#endif
1076 udev->hub = hub;
1077
1078 /* initialize HUB structure */
1079 hub->hubsoftc = sc;
1080 hub->explore = &uhub_explore;
1081 hub->nports = nports;
1082 hub->hubudev = udev;
1083

--- 108 unchanged lines hidden (view full) ---

1192
1193 usbd_set_power_mode(udev, USB_POWER_MODE_SAVE);
1194
1195 return (0);
1196
1197error:
1198 usbd_transfer_unsetup(sc->sc_xfer, UHUB_N_TRANSFER);
1199
1086 udev->hub = hub;
1087
1088 /* initialize HUB structure */
1089 hub->hubsoftc = sc;
1090 hub->explore = &uhub_explore;
1091 hub->nports = nports;
1092 hub->hubudev = udev;
1093

--- 108 unchanged lines hidden (view full) ---

1202
1203 usbd_set_power_mode(udev, USB_POWER_MODE_SAVE);
1204
1205 return (0);
1206
1207error:
1208 usbd_transfer_unsetup(sc->sc_xfer, UHUB_N_TRANSFER);
1209
1200 if (udev->hub) {
1201 free(udev->hub, M_USBDEV);
1202 udev->hub = NULL;
1203 }
1210#if (USB_HAVE_FIXED_PORT == 0)
1211 free(udev->hub, M_USBDEV);
1212#endif
1213 udev->hub = NULL;
1204
1205 mtx_destroy(&sc->sc_mtx);
1206
1207 return (ENXIO);
1208}
1209
1210/*
1211 * Called from process context when the hub is gone.

--- 23 unchanged lines hidden (view full) ---

1235 }
1236
1237 /*
1238 * Free USB device and all subdevices, if any.
1239 */
1240 usb_free_device(child, 0);
1241 }
1242
1214
1215 mtx_destroy(&sc->sc_mtx);
1216
1217 return (ENXIO);
1218}
1219
1220/*
1221 * Called from process context when the hub is gone.

--- 23 unchanged lines hidden (view full) ---

1245 }
1246
1247 /*
1248 * Free USB device and all subdevices, if any.
1249 */
1250 usb_free_device(child, 0);
1251 }
1252
1253#if (USB_HAVE_FIXED_PORT == 0)
1243 free(hub, M_USBDEV);
1254 free(hub, M_USBDEV);
1255#endif
1244 sc->sc_udev->hub = NULL;
1245
1246 mtx_destroy(&sc->sc_mtx);
1247
1248 return (0);
1249}
1250
1251static int

--- 1285 unchanged lines hidden ---
1256 sc->sc_udev->hub = NULL;
1257
1258 mtx_destroy(&sc->sc_mtx);
1259
1260 return (0);
1261}
1262
1263static int

--- 1285 unchanged lines hidden ---