Deleted Added
full compact
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 */
103#if (USB_HAVE_FIXED_PORT != 0)
104 struct usb_hub sc_hub;
105#endif
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;
929 uint8_t x;
926 uint8_t nports;
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)
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)
1082 goto error;
1075 }
1083#else
1084 hub = &sc->sc_hub;
1085#endif
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;
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)
1254 free(hub, M_USBDEV);
1255#endif
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 ---