linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] hid2hci: Fix EALREADY handling after libusb removal
@ 2019-04-23 15:45 Ville Syrjala
  2019-04-23 15:45 ` [PATCH BlueZ 2/2] hid2hci: Fix the exit value on success Ville Syrjala
  0 siblings, 1 reply; 2+ messages in thread
From: Ville Syrjala @ 2019-04-23 15:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Marcel Holtmann

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

usb_control_msg() used to return the number bytes transferred wheras
the replacement (control_message()) just returns 0 vs. error. This
means the EALREADY handling is now broken. So let's just remove the
EALREADY handling entirely.

Cc: Marcel Holtmann <marcel@holtmann.org>
Fixes: e3cc40084ce4 ("tools: Remove libusb dependency from hid2hci")
---
 tools/hid2hci.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index 1e0f7aa2ab8b..206a5af032ae 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -111,10 +111,7 @@ static int usb_switch_csr(int fd, enum mode mode)
 	err = control_message(fd, USB_ENDPOINT_OUT | USB_TYPE_VENDOR  |
 							USB_RECIP_DEVICE,
 						0, mode, 0, NULL, 0, 10000);
-	if (err == 0) {
-		err = -1;
-		errno = EALREADY;
-	} else if (errno == ETIMEDOUT)
+	if (err < 0 && errno == ETIMEDOUT)
 		err = 0;
 
 	return err;
@@ -255,13 +252,8 @@ static int usb_switch_dell(int fd, enum mode mode)
 				USB_REQ_SET_CONFIGURATION,
 				0x7f | (0x03 << 8), 0,
 				report, sizeof(report), 5000);
-	if (err == 0) {
-		err = -1;
-		errno = EALREADY;
-	} else {
-		if (errno == ETIMEDOUT)
-			err = 0;
-	}
+	if (err < 0 && errno == ETIMEDOUT)
+		err = 0;
 
 	return err;
 }
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH BlueZ 2/2] hid2hci: Fix the exit value on success
  2019-04-23 15:45 [PATCH BlueZ 1/2] hid2hci: Fix EALREADY handling after libusb removal Ville Syrjala
@ 2019-04-23 15:45 ` Ville Syrjala
  0 siblings, 0 replies; 2+ messages in thread
From: Ville Syrjala @ 2019-04-23 15:45 UTC (permalink / raw)
  To: linux-bluetooth

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Presumably we would want the program exit value to indicate
success when things worked out. Do that.
---
 tools/hid2hci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index 206a5af032ae..2da7dd4ed7f8 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -432,6 +432,8 @@ int main(int argc, char *argv[])
 	if (err < 0)
 		fprintf(stderr, "error: switching device '%s' failed.\n",
 			udev_device_get_syspath(udev_dev));
+	else
+		rc = 0;
 exit:
 	udev_device_unref(udev_dev);
 	udev_unref(udev);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-23 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 15:45 [PATCH BlueZ 1/2] hid2hci: Fix EALREADY handling after libusb removal Ville Syrjala
2019-04-23 15:45 ` [PATCH BlueZ 2/2] hid2hci: Fix the exit value on success Ville Syrjala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).