* 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"
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),
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;
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)