Make usb-bt-dongle configurable
PATCH 1/1 Make usb-bt-dongle configurable
usb-bt-dongle device can't be disabled as there's dependency in vl.c file. This patch add preprocesor condition to be able to disable it.
--- hw/usb/Makefile.objs | 1 - vl.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
hw/usb/Makefile.objs +0 -1
@@ -20,7 +20,6 @@ common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o common-obj-$(CONFIG_USB_NETWORK) += dev-network.o # FIXME: make configurable too -CONFIG_USB_BLUETOOTH := y common-obj-$(CONFIG_USB_BLUETOOTH) += dev-bluetooth.o ifeq ($(CONFIG_USB_SMARTCARD),y)
vl.c +14 -4
@@ -1526,8 +1526,10 @@ static void configure_msg(QemuOpts *opts)static int usb_device_add (const char *devname) { -const char *p;USBDevice *dev =NULL ; +#if defined(CONFIG_USB_BLUETOOTH ) || !defined(CONFIG_LINUX ) +const char *p; +#endif if (!usb_enabled (false)) {return -1 ;
@@ -1543,15 +1545,23 @@ static int usb_device_add(const char *devname)/* only the linux version is qdev-ified, usb-bsd still needs this */ if (strstart (devname,"host:" , &p)) { dev =usb_host_device_open (usb_bus_find (-1 ), p); - } else + goto devtest; + }#endif +#ifdef CONFIG_USB_BLUETOOTH if (!strcmp (devname,"bt" ) ||strstart (devname,"bt:" , &p)) { dev =usb_bt_init (usb_bus_find (-1 ), devname[2 ] ?hci_init (p) :bt_new_hci (qemu_find_bt_vlan (0 ))); - }else { -return -1 ; + goto devtest; } +#endif + +return -1 ; + +#if defined(CONFIG_USB_BLUETOOTH ) || !defined(CONFIG_LINUX ) +devtest: +#endif if (!dev)return -1 ;
Signature · 1 line
1.8.3.1
Am 19.08.2013 12:48, schrieb Miroslav Rezanina:
Quoted 1 line
usb-bt-dongle device can't be disabled as there's dependency in
vl.cfile. This patch add preprocesor condition to be able to disable it.
Please limit to 76 chars per line (check git log output).
Quoted 12 lines
Signed-off-by Miroslav Rezanina <[email protected]>--- hw/usb/Makefile.objs | 1 - vl.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)hw/usb/Makefile.objs +0
-0
hw/usb/Makefile.objs common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o · line 23
Quoted 4 lines
hw/usb/Makefile.objs +0
-1@@ -20,7 +20,6 @@ common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o common-obj-$(CONFIG_USB_NETWORK) += dev-network.o # FIXME: make configurable too -CONFIG_USB_BLUETOOTH := y
You probably should delete the FIXME alongside?
Quoted 8 lines
hw/usb/Makefile.objs +0
-0common-obj-$(CONFIG_USB_BLUETOOTH) += dev-bluetooth.o ifeq ($(CONFIG_USB_SMARTCARD),y)vl.c +0
-0
vl.c static void configure_msg(QemuOpts *opts) · line 1530
Quoted 6 lines
vl.c +1
-1@@ -1526,8 +1526,10 @@ static void configure_msg(QemuOpts *opts)static int usb_device_add (const char *devname) { -const char *p;USBDevice *dev =NULL ; +#if defined(CONFIG_USB_BLUETOOTH ) || !defined(CONFIG_LINUX )
Double space.
Quoted 19 lines
vl.c +5
-2+const char *p; +#endif if (!usb_enabled (false)) {return -1 ;@@ -1543,15 +1545,23 @@ static int usb_device_add(const char *devname)/* only the linux version is qdev-ified, usb-bsd still needs this */ if (strstart (devname,"host:" , &p)) { dev =usb_host_device_open (usb_bus_find (-1 ), p); - } else + goto devtest; + }#endif +#ifdef CONFIG_USB_BLUETOOTH if (!strcmp (devname,"bt" ) ||strstart (devname,"bt:" , &p)) { dev =usb_bt_init (usb_bus_find (-1 ), devname[2 ] ?hci_init (p) :bt_new_hci (qemu_find_bt_vlan (0 ))); - }else {
vl.c static int usb_device_add(const char *devname) · line 1564
Quoted 10 lines
vl.c +8
-1-return -1 ; + goto devtest; } +#endif + +return -1 ; + +#if defined(CONFIG_USB_BLUETOOTH ) || !defined(CONFIG_LINUX ) +devtest: +#endif
Why put only the label in an #if block? The below is dead code if not reached via devtest.
vl.c static int usb_device_add(const char *devname) · line 1567
Quoted 3 lines
vl.c +0
-0if (!dev)return -1 ;
Let's also not forget to CC Gerd as USB maintainer.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Il 19/08/2013 12:48, Miroslav Rezanina ha scritto:
Quoted 37 lines
usb-bt-dongle device can't be disabled as there's dependency in
vl.cfile. This patch add preprocesor condition to be able to disable it.Signed-off-by Miroslav Rezanina <[email protected]>--- hw/usb/Makefile.objs | 1 - vl.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)hw/usb/Makefile.objs +0
-1@@ -20,7 +20,6 @@ common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o common-obj-$(CONFIG_USB_NETWORK) += dev-network.o # FIXME: make configurable too -CONFIG_USB_BLUETOOTH := y common-obj-$(CONFIG_USB_BLUETOOTH) += dev-bluetooth.o ifeq ($(CONFIG_USB_SMARTCARD),y)vl.c +3
-1@@ -1526,8 +1526,10 @@ static void configure_msg(QemuOpts *opts)static int usb_device_add (const char *devname) { -const char *p;USBDevice *dev =NULL ; +#if defined(CONFIG_USB_BLUETOOTH ) || !defined(CONFIG_LINUX ) +const char *p; +#endif if (!usb_enabled (false)) {return -1 ;
vl.c static int usb_device_add(const char *devname) · line 1549
Quoted 6 lines
vl.c +2
-1@@ -1543,15 +1545,23 @@ static int usb_device_add(const char *devname)/* only the linux version is qdev-ified, usb-bsd still needs this */ if (strstart (devname,"host:" , &p)) { dev =usb_host_device_open (usb_bus_find (-1 ), p); - }else + goto devtest; + }
No need for the goto, since the following "if"s will fail...
vl.c static int usb_device_add(const char *devname) · line 1556
Quoted 9 lines
vl.c +2
-2#endif +#ifdef CONFIG_USB_BLUETOOTH if (!strcmp (devname,"bt" ) ||strstart (devname,"bt:" , &p)) { dev =usb_bt_init (usb_bus_find (-1 ), devname[2 ] ?hci_init (p) :bt_new_hci (qemu_find_bt_vlan (0 ))); - }else { -return -1 ; + goto devtest;
... same here...
vl.c static int usb_device_add(const char *devname) · line 1560
Quoted 4 lines
vl.c +3
-0} +#endif + +return -1 ;
... and no need for this return either: if you get here, dev will be NULL and the "if" just below will fail.
Paolo
Quoted 7 lines
vl.c +3
-0+#if defined(CONFIG_USB_BLUETOOTH ) || !defined(CONFIG_LINUX ) +devtest: +#endif if (!dev)return -1 ;
Quoted 19 lines · Andreas Färber
Am 19.08.2013 12:48, schrieb Miroslav Rezanina:
Quoted 1 line
usb-bt-dongle device can't be disabled as there's dependency in
vl.cfile. This patch add preprocesor condition to be able to disable it.Please limit to 76 chars per line (check
git logoutput).Quoted 14 lines
Signed-off-by Miroslav Rezanina <[email protected]>--- hw/usb/Makefile.objs | 1 - vl.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)hw/usb/Makefile.objs +0
-0@@ -20,7 +20,6 @@ common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o common-obj-$(CONFIG_USB_NETWORK) += dev-network.o
Quoted 4 lines
hw/usb/Makefile.objs common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o · line 23
Quoted 2 lines
hw/usb/Makefile.objs +0
-1# FIXME: make configurable too -CONFIG_USB_BLUETOOTH := yYou probably should delete the FIXME alongside?
What's everyone's opinion about CONFIG_USB_BLUETOOTH=y disappearing from the default build?
Thanks
Laszlo
Am 19.08.2013 15:30, schrieb Laszlo Ersek:
Quoted 20 lines · Andreas Färber
Quoted 19 lines
Am 19.08.2013 12:48, schrieb Miroslav Rezanina:
Quoted 1 line
usb-bt-dongle device can't be disabled as there's dependency in
vl.cfile. This patch add preprocesor condition to be able to disable it.Please limit to 76 chars per line (check
git logoutput).Quoted 14 lines
Signed-off-by Miroslav Rezanina <[email protected]>--- hw/usb/Makefile.objs | 1 - vl.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)hw/usb/Makefile.objs +0
-0@@ -20,7 +20,6 @@ common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o common-obj-$(CONFIG_USB_NETWORK) += dev-network.o
Quoted 7 lines
Quoted 4 lines
hw/usb/Makefile.objs common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o · line 23
Quoted 2 lines
hw/usb/Makefile.objs +0
-1# FIXME: make configurable too -CONFIG_USB_BLUETOOTH := yYou probably should delete the FIXME alongside?
What's everyone's opinion about
CONFIG_USB_BLUETOOTH=ydisappearing from the default build?
By my reading of git grep CONFIG_USB_BLUETOOTH it isn't disappearing, check default-configs/usb.mak. All targets that include usb.mak will have CONFIG_USB_BLUETOOTH.
It's only used in the build system and with this patch in vl.c, so assuming that Miroslav has checked that the build succeeds for all targets, this should be fine, I guess.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Il 19/08/2013 15:41, Andreas Färber ha scritto:
Quoted 7 lines
By my reading of
git grep CONFIG_USB_BLUETOOTHit isn't disappearing, check default-configs/usb.mak. All targets that include usb.mak will haveCONFIG_USB_BLUETOOTH.It's only used in the build system and with this patch in
vl.c, so assuming that Miroslav has checked that the build succeeds for all targets, this should be fine, I guess.
Actually, CONFIG_* symbols for devices are _not_ exposed to vl.c. Blue Swirl specifically wanted that to happen. So I'm afraid Mirek's patch breaks "-usb bt" even if CONFIG_USB_BLUETOOTH is set to y.
Paolo
Quoted 5 lines · Paolo Bonzini
Il 19/08/2013 15:41, Andreas Färber ha scritto:
Quoted 4 lines
By my reading of
git grep CONFIG_USB_BLUETOOTHit isn't disappearing, check default-configs/usb.mak. All targets that include usb.mak will haveCONFIG_USB_BLUETOOTH.
Quoted 7 lines
Quoted 3 lines
It's only used in the build system and with this patch in
vl.c, so assuming that Miroslav has checked that the build succeeds for all targets, this should be fine, I guess.Actually, CONFIG_* symbols for devices are _not_ exposed to
vl.c. Blue Swirl specifically wanted that to happen. So I'm afraid Mirek's patch breaks "-usb bt" even ifCONFIG_USB_BLUETOOTHis set to y.
"-usbdevice bt", to be exact.
I'd suggest to switch bluetooth over to use usb_legacy_register() to parse+handle the legacy -usbdevice cmd line option and zap the vl.c dependency this way.
cheers,
Gerd