Deleted Added
full compact
usb_controller.c (213435) usb_controller.c (215649)
1/* $FreeBSD: head/sys/dev/usb/controller/usb_controller.c 213435 2010-10-04 23:18:05Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/controller/usb_controller.c 215649 2010-11-22 01:11:28Z weongyo $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

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

56#include <dev/usb/usb_process.h>
57#include <dev/usb/usb_busdma.h>
58#include <dev/usb/usb_dynamic.h>
59#include <dev/usb/usb_device.h>
60#include <dev/usb/usb_hub.h>
61
62#include <dev/usb/usb_controller.h>
63#include <dev/usb/usb_bus.h>
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

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

56#include <dev/usb/usb_process.h>
57#include <dev/usb/usb_busdma.h>
58#include <dev/usb/usb_dynamic.h>
59#include <dev/usb/usb_device.h>
60#include <dev/usb/usb_hub.h>
61
62#include <dev/usb/usb_controller.h>
63#include <dev/usb/usb_bus.h>
64#include <dev/usb/usb_pf.h>
64
65/* function prototypes */
66
67static device_probe_t usb_probe;
68static device_attach_t usb_attach;
69static device_detach_t usb_detach;
70
71static void usb_attach_sub(device_t, struct usb_bus *);

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

542 mtx_init(&bus->bus_mtx, device_get_nameunit(bus->parent),
543 NULL, MTX_DEF | MTX_RECURSE);
544
545 usb_callout_init_mtx(&bus->power_wdog,
546 &bus->bus_mtx, 0);
547
548 TAILQ_INIT(&bus->intr_q.head);
549
65
66/* function prototypes */
67
68static device_probe_t usb_probe;
69static device_attach_t usb_attach;
70static device_detach_t usb_detach;
71
72static void usb_attach_sub(device_t, struct usb_bus *);

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

543 mtx_init(&bus->bus_mtx, device_get_nameunit(bus->parent),
544 NULL, MTX_DEF | MTX_RECURSE);
545
546 usb_callout_init_mtx(&bus->power_wdog,
547 &bus->bus_mtx, 0);
548
549 TAILQ_INIT(&bus->intr_q.head);
550
551 usbpf_attach(bus, &bus->uif);
552
550#if USB_HAVE_BUSDMA
551 usb_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
552 dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX);
553#endif
554 if ((bus->devices_max > USB_MAX_DEVICES) ||
555 (bus->devices_max < USB_MIN_DEVICES) ||
556 (bus->devices == NULL)) {
557 DPRINTFN(0, "Devices field has not been "

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

589{
590#if USB_HAVE_BUSDMA
591 if (cb) {
592 cb(bus, &usb_bus_mem_free_all_cb);
593 }
594 usb_dma_tag_unsetup(bus->dma_parent_tag);
595#endif
596
553#if USB_HAVE_BUSDMA
554 usb_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
555 dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX);
556#endif
557 if ((bus->devices_max > USB_MAX_DEVICES) ||
558 (bus->devices_max < USB_MIN_DEVICES) ||
559 (bus->devices == NULL)) {
560 DPRINTFN(0, "Devices field has not been "

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

592{
593#if USB_HAVE_BUSDMA
594 if (cb) {
595 cb(bus, &usb_bus_mem_free_all_cb);
596 }
597 usb_dma_tag_unsetup(bus->dma_parent_tag);
598#endif
599
600 usbpf_detach(bus);
601
597 mtx_destroy(&bus->bus_mtx);
598}
602 mtx_destroy(&bus->bus_mtx);
603}
604
605struct usb_bus *
606usb_bus_find(const char *name)
607{
608 struct usb_bus *ubus;
609 devclass_t dc;
610 device_t *devlist;
611 int devcount, error, i;
612 const char *nameunit;
613
614 dc = devclass_find("usbus");
615 if (dc == NULL)
616 return (NULL);
617 error = devclass_get_devices(dc, &devlist, &devcount);
618 if (error != 0)
619 return (NULL);
620 for (i = 0; i < devcount; i++) {
621 nameunit = device_get_nameunit(devlist[i]);
622 if (!strncmp(name, nameunit, strlen(nameunit))) {
623 ubus = device_get_ivars(devlist[i]);
624 free(devlist, M_TEMP);
625 return (ubus);
626 }
627 }
628 free(devlist, M_TEMP);
629 return (NULL);
630}