]> Git Repo - qemu.git/blobdiff - hw/usb-bt.c
Sparc64: fix PCI probe problems
[qemu.git] / hw / usb-bt.c
index 53ad9a8693fb72b23a8ae534fc8fc12029662800..56d1a6ce4a6c5ccf5f7185bdb25a4a2e94d9e4f8 100644 (file)
@@ -15,8 +15,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "qemu-common.h"
@@ -364,7 +363,7 @@ static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo,
     return len;
 }
 
-static void inline usb_bt_fifo_out_enqueue(struct USBBtState *s,
+static inline void usb_bt_fifo_out_enqueue(struct USBBtState *s,
                 struct usb_hci_out_fifo_s *fifo,
                 void (*send)(struct HCIInfo *, const uint8_t *, int),
                 int (*complete)(const uint8_t *, int),
@@ -615,25 +614,25 @@ static void usb_bt_handle_destroy(USBDevice *dev)
     s->hci->opaque = NULL;
     s->hci->evt_recv = NULL;
     s->hci->acl_recv = NULL;
-    qemu_free(s);
+}
+
+static int usb_bt_initfn(USBDevice *dev)
+{
+    struct USBBtState *s = DO_UPCAST(struct USBBtState, dev, dev);
+    s->dev.speed = USB_SPEED_HIGH;
+    return 0;
 }
 
 USBDevice *usb_bt_init(HCIInfo *hci)
 {
+    USBDevice *dev;
     struct USBBtState *s;
 
     if (!hci)
         return NULL;
-    s = qemu_mallocz(sizeof(struct USBBtState));
+    dev = usb_create_simple(NULL /* FIXME */, "usb-bt-dongle");
+    s = DO_UPCAST(struct USBBtState, dev, dev);
     s->dev.opaque = s;
-    s->dev.speed = USB_SPEED_HIGH;
-    s->dev.handle_packet = usb_generic_handle_packet;
-    pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU BT dongle");
-
-    s->dev.handle_reset = usb_bt_handle_reset;
-    s->dev.handle_control = usb_bt_handle_control;
-    s->dev.handle_data = usb_bt_handle_data;
-    s->dev.handle_destroy = usb_bt_handle_destroy;
 
     s->hci = hci;
     s->hci->opaque = s;
@@ -642,5 +641,23 @@ USBDevice *usb_bt_init(HCIInfo *hci)
 
     usb_bt_handle_reset(&s->dev);
 
-    return &s->dev;
+    return dev;
+}
+
+static struct USBDeviceInfo bt_info = {
+    .product_desc   = "QEMU BT dongle",
+    .qdev.name      = "usb-bt-dongle",
+    .qdev.size      = sizeof(struct USBBtState),
+    .init           = usb_bt_initfn,
+    .handle_packet  = usb_generic_handle_packet,
+    .handle_reset   = usb_bt_handle_reset,
+    .handle_control = usb_bt_handle_control,
+    .handle_data    = usb_bt_handle_data,
+    .handle_destroy = usb_bt_handle_destroy,
+};
+
+static void usb_bt_register_devices(void)
+{
+    usb_qdev_register(&bt_info);
 }
+device_init(usb_bt_register_devices)
This page took 0.027581 seconds and 4 git commands to generate.