aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/hub.c136
1 files changed, 88 insertions, 48 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 34be27a6cbb4..65d9ea1e6d71 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1220,54 +1220,14 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1220#endif 1220#endif
1221 1221
1222/** 1222/**
1223 * usb_new_device - perform initial device setup (usbcore-internal) 1223 * usb_configure_device_otg - FIXME (usbcore-internal)
1224 * @udev: newly addressed device (in ADDRESS state) 1224 * @udev: newly addressed device (in ADDRESS state)
1225 * 1225 *
1226 * This is called with devices which have been enumerated, but not yet 1226 * Do configuration for On-The-Go devices
1227 * configured. The device descriptor is available, but not descriptors
1228 * for any device configuration. The caller must have locked either
1229 * the parent hub (if udev is a normal device) or else the
1230 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1231 * udev has already been installed, but udev is not yet visible through
1232 * sysfs or other filesystem code.
1233 *
1234 * It will return if the device is configured properly or not. Zero if
1235 * the interface was registered with the driver core; else a negative
1236 * errno value.
1237 *
1238 * This call is synchronous, and may not be used in an interrupt context.
1239 *
1240 * Only the hub driver or root-hub registrar should ever call this.
1241 */ 1227 */
1242int usb_new_device(struct usb_device *udev) 1228static int usb_configure_device_otg(struct usb_device *udev)
1243{ 1229{
1244 int err; 1230 int err = 0;
1245
1246 /* Determine quirks */
1247 usb_detect_quirks(udev);
1248
1249 err = usb_get_configuration(udev);
1250 if (err < 0) {
1251 dev_err(&udev->dev, "can't read configurations, error %d\n",
1252 err);
1253 goto fail;
1254 }
1255
1256 /* read the standard strings and cache them if present */
1257 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
1258 udev->manufacturer = usb_cache_string(udev,
1259 udev->descriptor.iManufacturer);
1260 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
1261
1262 /* Tell the world! */
1263 dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, "
1264 "SerialNumber=%d\n",
1265 udev->descriptor.iManufacturer,
1266 udev->descriptor.iProduct,
1267 udev->descriptor.iSerialNumber);
1268 show_string(udev, "Product", udev->product);
1269 show_string(udev, "Manufacturer", udev->manufacturer);
1270 show_string(udev, "SerialNumber", udev->serial);
1271 1231
1272#ifdef CONFIG_USB_OTG 1232#ifdef CONFIG_USB_OTG
1273 /* 1233 /*
@@ -1329,8 +1289,82 @@ int usb_new_device(struct usb_device *udev)
1329 err = -ENOTSUPP; 1289 err = -ENOTSUPP;
1330 goto fail; 1290 goto fail;
1331 } 1291 }
1292fail:
1332#endif 1293#endif
1294 return err;
1295}
1333 1296
1297
1298/**
1299 * usb_configure_device - Detect and probe device intfs/otg (usbcore-internal)
1300 * @udev: newly addressed device (in ADDRESS state)
1301 *
1302 * This is only called by usb_new_device() and usb_authorize_device()
1303 * and FIXME -- all comments that apply to them apply here wrt to
1304 * environment.
1305 *
1306 * If the device is WUSB and not authorized, we don't attempt to read
1307 * the string descriptors, as they will be errored out by the device
1308 * until it has been authorized.
1309 */
1310static int usb_configure_device(struct usb_device *udev)
1311{
1312 int err;
1313
1314 if (udev->config == NULL) {
1315 err = usb_get_configuration(udev);
1316 if (err < 0) {
1317 dev_err(&udev->dev, "can't read configurations, error %d\n",
1318 err);
1319 goto fail;
1320 }
1321 }
1322 if (udev->wusb == 1 && udev->authorized == 0) {
1323 udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
1324 udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
1325 udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
1326 }
1327 else {
1328 /* read the standard strings and cache them if present */
1329 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
1330 udev->manufacturer = usb_cache_string(udev,
1331 udev->descriptor.iManufacturer);
1332 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
1333 }
1334 err = usb_configure_device_otg(udev);
1335fail:
1336 return err;
1337}
1338
1339
1340/**
1341 * usb_new_device - perform initial device setup (usbcore-internal)
1342 * @udev: newly addressed device (in ADDRESS state)
1343 *
1344 * This is called with devices which have been enumerated, but not yet
1345 * configured. The device descriptor is available, but not descriptors
1346 * for any device configuration. The caller must have locked either
1347 * the parent hub (if udev is a normal device) or else the
1348 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1349 * udev has already been installed, but udev is not yet visible through
1350 * sysfs or other filesystem code.
1351 *
1352 * It will return if the device is configured properly or not. Zero if
1353 * the interface was registered with the driver core; else a negative
1354 * errno value.
1355 *
1356 * This call is synchronous, and may not be used in an interrupt context.
1357 *
1358 * Only the hub driver or root-hub registrar should ever call this.
1359 */
1360int usb_new_device(struct usb_device *udev)
1361{
1362 int err;
1363
1364 usb_detect_quirks(udev); /* Determine quirks */
1365 err = usb_configure_device(udev); /* detect & probe dev/intfs */
1366 if (err < 0)
1367 goto fail;
1334 /* export the usbdev device-node for libusb */ 1368 /* export the usbdev device-node for libusb */
1335 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, 1369 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
1336 (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); 1370 (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
@@ -1346,17 +1380,23 @@ int usb_new_device(struct usb_device *udev)
1346 err = device_add(&udev->dev); 1380 err = device_add(&udev->dev);
1347 if (err) { 1381 if (err) {
1348 dev_err(&udev->dev, "can't device_add, error %d\n", err); 1382 dev_err(&udev->dev, "can't device_add, error %d\n", err);
1349 if (udev->parent)
1350 usb_autosuspend_device(udev->parent);
1351 goto fail; 1383 goto fail;
1352 } 1384 }
1353 1385
1354exit: 1386 /* Tell the world! */
1387 dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, "
1388 "SerialNumber=%d\n",
1389 udev->descriptor.iManufacturer,
1390 udev->descriptor.iProduct,
1391 udev->descriptor.iSerialNumber);
1392 show_string(udev, "Product", udev->product);
1393 show_string(udev, "Manufacturer", udev->manufacturer);
1394 show_string(udev, "SerialNumber", udev->serial);
1355 return err; 1395 return err;
1356 1396
1357fail: 1397fail:
1358 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1398 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1359 goto exit; 1399 return err;
1360} 1400}
1361 1401
1362static int hub_port_status(struct usb_hub *hub, int port1, 1402static int hub_port_status(struct usb_hub *hub, int port1,