From: Giovanni Campagna <scampa.giovanni@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] hid2hci: fix regression in /dev format after moving away from libusb
Date: Wed, 2 Oct 2013 18:00:16 +0200 [thread overview]
Message-ID: <1380729616-26519-1-git-send-email-scampa.giovanni@gmail.com> (raw)
From: Giovanni Campagna <gcampagna@src.gnome.org>
The paths under /dev, in the default udev configuration, are formatted
with two leading zeros, but the number obtained from sysfs don't have
them, so we must convert them to integers and reformat them.
Signed-off-by: Giovanni Campagna <scampa.giovanni@gmail.com>
---
tools/hid2hci.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index bb8a521..76d0b5a 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -221,18 +221,21 @@ static int usb_switch_dell(int fd, enum mode mode)
static int find_device(struct udev_device *udev_dev)
{
char path[PATH_MAX];
- const char *busnum, *devnum;
+ const char *busnum_s, *devnum_s;
+ int busnum, devnum;
int fd;
- busnum = udev_device_get_sysattr_value(udev_dev, "busnum");
- if (!busnum)
+ busnum_s = udev_device_get_sysattr_value(udev_dev, "busnum");
+ if (!busnum_s)
return -1;
+ busnum = strtol(busnum_s, NULL, 10);
- devnum = udev_device_get_sysattr_value(udev_dev, "devnum");
- if (!devnum)
+ devnum_s = udev_device_get_sysattr_value(udev_dev, "devnum");
+ if (!devnum_s)
return -1;
+ devnum = strtol(devnum_s, NULL, 10);
- snprintf(path, sizeof(path), "/dev/bus/usb/%s/%s", busnum, devnum);
+ snprintf(path, sizeof(path), "/dev/bus/usb/%03d/%03d", busnum, devnum);
fd = open(path, O_RDWR, O_CLOEXEC);
if (fd < 0) {
--
1.8.3.1
next reply other threads:[~2013-10-02 16:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-02 16:00 Giovanni Campagna [this message]
2013-10-03 3:37 ` [PATCH] hid2hci: fix regression in /dev format after moving away from libusb Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380729616-26519-1-git-send-email-scampa.giovanni@gmail.com \
--to=scampa.giovanni@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox