hog: Fill ev.u.create.{phys,uniq} for UHID_CREATE
PATCH 1/1 hog: Fill ev.u.create.{phys,uniq} for UHID_CREATE
Fill ev.u.create.{phys,uniq} fields when uHID device is created. These values are copied to kernel hid_device structure.
linux/include/linux/hid.h:
struct hid_device {
...
char name[128]; /* Device name */ char phys[64]; /* Device physical location */ char uniq[64]; /* Device unique identifier (serial #) */ --- profiles/input/hog.c | 7 +++++++ 1 file changed, 7 insertions(+)
profiles/input/hog.c +7 -0
@@ -92,6 +92,8 @@ struct hog_device {uint16_t ctrlpt_handle;uint8_t flags;char *name; +bdaddr_t src; +bdaddr_t dst; };struct report {
@@ -396,6 +398,8 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen,strncpy ((char *) ev.u.create.name, hogdev->name ? hogdev->name :"bluez-hog-device" ,sizeof (ev.u.create.name) -1 ); +ba2str (&hogdev->src, (char *) ev.u.create.phys); +ba2str (&hogdev->dst, (char *) ev.u.create.uniq); ev.u.create.vendor = vendor; ev.u.create.product = product; ev.u.create.version = version;
@@ -724,6 +728,7 @@ static void attio_disconnected_cb(gpointer user_data)static struct hog_device *hog_new_device (struct btd_device *device,uint16_t id) { +struct btd_adapter *adapter =device_get_adapter (device);struct hog_device *hogdev;char name[HCI_MAX_NAME_LENGTH +1 ];
@@ -736,6 +741,8 @@ static struct hog_device *hog_new_device(struct btd_device *device,device_get_name (device, name,sizeof (name));if (strlen (name) >0 ) hogdev->name =g_strdup (name); +bacpy (&hogdev->src,btd_adapter_get_address (adapter)); +bacpy (&hogdev->dst,device_get_address (device));return hogdev; }
Signature · 1 line
1.9.0.rc1.175.g0b1dcb5
Hi Petri,
Quoted 18 lines · On Wednesday 19 February 2014 12:15:45 Petri Gynther wrote:
Fill ev.u.create.{phys,uniq} fields when uHID device is created. These values are copied to kernel
hid_devicestructure.
linux/include/linux/hid.h:
structhid_device{
...char name[128]; /* Device name */ char phys[64]; /* Device physical location */ char uniq[64]; /* Device unique identifier (serial #) */ --- profiles/input/hog.c | 7 +++++++ 1 file changed, 7 insertions(+)profiles/input/hog.c +0
-0
profiles/input/hog.c struct hog_device { · line 98
Quoted 7 lines
profiles/input/hog.c +2
-0@@ -92,6 +92,8 @@ struct hog_device {uint16_t ctrlpt_handle;uint8_t flags;char *name; +bdaddr_t src; +bdaddr_t dst; };
struct hog_device already holds reference to btd_device and both src and dst can be taken from it where needed. No need to extend struct hog_device.
BTW same goes with name member which could be removed.
Quoted 28 lines
profiles/input/hog.c +0
-0struct report {@@ -396,6 +398,8 @@ static void report_map_read_cb(guint8 status, constguint8 *pdu, guint16 plen, strncpy((char *) ev.u.create.name,
hogdev->name?profiles/input/hog.c +5
-0hogdev->name : "bluez-hog-device", sizeof(ev.u.create.name) - 1); +ba2str (&hogdev->src, (char *) ev.u.create.phys); +ba2str (&hogdev->dst, (char *) ev.u.create.uniq); ev.u.create.vendor = vendor; ev.u.create.product = product; ev.u.create.version = version;@@ -724,6 +728,7 @@ static void attio_disconnected_cb(gpointer user_data)static struct hog_device *hog_new_device (struct btd_device *device,uint16_t id) { +struct btd_adapter *adapter =device_get_adapter (device);struct hog_device *hogdev;char name[HCI_MAX_NAME_LENGTH +1 ];@@ -736,6 +741,8 @@ static struct hog_device *hog_new_device(struct btd_device *device, device_get_name(device, name, sizeof(name));if (strlen (name) >0 ) hogdev->name =g_strdup (name); +bacpy (&hogdev->src,btd_adapter_get_address (adapter)); +bacpy (&hogdev->dst,device_get_address (device));return hogdev; }
Signature · 2 lines
Szymon K. Janc [email protected]
I used hogdev->device directly in:
http://marc.info/?l=linux-bluetooth&m=139105411019568&w=2
But Johan commented on that:
http://marc.info/?l=linux-bluetooth&m=139228316405777&w=2
So that's why I went this route and added name, src, dst.
-- Petri
Quoted 66 lines · Szymon Janc
Hi Petri,
Quoted 18 lines · On Wednesday 19 February 2014 12:15:45 Petri Gynther wrote:
Fill ev.u.create.{phys,uniq} fields when uHID device is created. These values are copied to kernel
hid_devicestructure.
linux/include/linux/hid.h:
structhid_device{
...char name[128]; /* Device name */ char phys[64]; /* Device physical location */ char uniq[64]; /* Device unique identifier (serial #) */ --- profiles/input/hog.c | 7 +++++++ 1 file changed, 7 insertions(+)profiles/input/hog.c +0
-0profiles/input/hog.c struct hog_device { · line 98
Quoted 7 lines
profiles/input/hog.c +2
-0@@ -92,6 +92,8 @@ struct hog_device {uint16_t ctrlpt_handle;uint8_t flags;char *name; +bdaddr_t src; +bdaddr_t dst; };struct
hog_devicealready holds reference tobtd_deviceand both src and dst can be taken from it where needed. No need to extend structhog_device.BTW same goes with name member which could be removed.
Quoted 20 lines
profiles/input/hog.c +0
-0struct report {@@ -396,6 +398,8 @@ static void report_map_read_cb(guint8 status, constguint8 *pdu, guint16 plen, strncpy((char *) ev.u.create.name,
hogdev->name?hogdev->name : "bluez-hog-device", sizeof(ev.u.create.name) - 1);profiles/input/hog.c +3
-0+ba2str (&hogdev->src, (char *) ev.u.create.phys); +ba2str (&hogdev->dst, (char *) ev.u.create.uniq); ev.u.create.vendor = vendor; ev.u.create.product = product; ev.u.create.version = version;@@ -724,6 +728,7 @@ static void attio_disconnected_cb(gpointer user_data)static struct hog_device *hog_new_device (struct btd_device *device,uint16_t id) { +struct btd_adapter *adapter =device_get_adapter (device);struct hog_device *hogdev;char name[HCI_MAX_NAME_LENGTH +1 ];profiles/input/hog.c static struct hog_device *hog_new_device(struct · line 748
Quoted 8 lines
profiles/input/hog.c +2
-0@@ -736,6 +741,8 @@ static struct hog_device *hog_new_device(struct btd_device *device, device_get_name(device, name, sizeof(name));if (strlen (name) >0 ) hogdev->name =g_strdup (name); +bacpy (&hogdev->src,btd_adapter_get_address (adapter)); +bacpy (&hogdev->dst,device_get_address (device));return hogdev; }--
Szymon K. Janc
[email protected]
Hi Petri,
Quoted 7 lines · On Wednesday 19 February 2014 13:15:32 Petri Gynther wrote:
I used
hogdev->devicedirectly in:
http://marc.info/?l=linux-bluetooth&m=139105411019568&w=2But Johan commented on that:
http://marc.info/?l=linux-bluetooth&m=139228316405777&w=2So that's why I went this route and added name, src, dst.
I suppose it was about using local adapter variable to avoid those nested calls as this is indeed quite hard to read.
Quoted 92 lines
-- Petri
Quoted 88 lines · Szymon Janc
Hi Petri,
Quoted 29 lines · On Wednesday 19 February 2014 12:15:45 Petri Gynther wrote:
Fill ev.u.create.{phys,uniq} fields when uHID device is created. These values are copied to kernel
hid_devicestructure.
linux/include/linux/hid.h:
structhid_device{...
char name[128]; /* Device name */ char phys[64]; /* Device physical location */ char uniq[64]; /* Device unique identifier (serial #) */---
profiles/input/hog.c | 7 +++++++ 1 file changed, 7 insertions(+)profiles/input/hog.c +2
-0@@ -92,6 +92,8 @@ struct hog_device {uint16_t ctrlpt_handle;uint8_t flags;char *name; +bdaddr_t src; +bdaddr_t dst;Quoted 1 line
};
struct
hog_devicealready holds reference tobtd_deviceand both src and dst can be taken from it where needed. No need to extend structhog_device.BTW same goes with name member which could be removed.
Quoted 41 lines
struct report {
profiles/input/hog.c +0
-0@@ -396,6 +398,8 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen, strncpy((char *) ev.u.create.name,
hogdev->name
?hogdev->name : "bluez-hog-device", sizeof(ev.u.create.name) - 1);profiles/input/hog.c +5
-0+ba2str (&hogdev->src, (char *) ev.u.create.phys); +ba2str (&hogdev->dst, (char *) ev.u.create.uniq); ev.u.create.vendor = vendor; ev.u.create.product = product; ev.u.create.version = version;@@ -724,6 +728,7 @@ static void attio_disconnected_cb(gpointer user_data)static struct hog_device *hog_new_device (struct btd_device *device,uint16_t id) { +struct btd_adapter *adapter =device_get_adapter (device);struct hog_device *hogdev;char name[HCI_MAX_NAME_LENGTH +1 ];@@ -736,6 +741,8 @@ static struct hog_device *hog_new_device(struct btd_device *device, device_get_name(device, name, sizeof(name));if (strlen (name) >0 ) hogdev->name =g_strdup (name); +bacpy (&hogdev->src,btd_adapter_get_address (adapter)); +bacpy (&hogdev->dst,device_get_address (device));Quoted 3 lines
return hogdev;}
--
Szymon K. Janc
[email protected]
Signature · 2 lines
Szymon K. Janc [email protected]
Hi Szymon,
Quoted 6 lines · Szymon Janc
Hi Petri,
Quoted 3 lines · On Wednesday 19 February 2014 13:15:32 Petri Gynther wrote:
I used
hogdev->devicedirectly in:
http://marc.info/?l=linux-bluetooth&m=139105411019568&w=2
Quoted 8 lines
Quoted 4 lines
But Johan commented on that:
http://marc.info/?l=linux-bluetooth&m=139228316405777&w=2So that's why I went this route and added name, src, dst.
I suppose it was about using local adapter variable to avoid those nested calls as this is indeed quite hard to read.
I think I misunderstood the comment. I ended up adding name, src, dst to hog_device to mimic input_device, which has those fields. However, I just realized that input_device also has a pointer to btd_device.
I'll rework the HoG code. And, I'll see if it is easy to do the same for input_device.
Quoted 96 lines
Quoted 92 lines
-- Petri
Quoted 88 lines · Szymon Janc
Hi Petri,
Quoted 29 lines · On Wednesday 19 February 2014 12:15:45 Petri Gynther wrote:
Fill ev.u.create.{phys,uniq} fields when uHID device is created. These values are copied to kernel
hid_devicestructure.
linux/include/linux/hid.h:
structhid_device{...
char name[128]; /* Device name */ char phys[64]; /* Device physical location */ char uniq[64]; /* Device unique identifier (serial #) */---
profiles/input/hog.c | 7 +++++++ 1 file changed, 7 insertions(+)profiles/input/hog.c +2
-0@@ -92,6 +92,8 @@ struct hog_device {uint16_t ctrlpt_handle;uint8_t flags;char *name; +bdaddr_t src; +bdaddr_t dst;Quoted 1 line
};
struct
hog_devicealready holds reference tobtd_deviceand both src and dst can be taken from it where needed. No need to extend structhog_device.BTW same goes with name member which could be removed.
Quoted 41 lines
struct report {
profiles/input/hog.c +0
-0@@ -396,6 +398,8 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen, strncpy((char *) ev.u.create.name,
hogdev->name
?hogdev->name : "bluez-hog-device", sizeof(ev.u.create.name) - 1);profiles/input/hog.c +5
-0+ba2str (&hogdev->src, (char *) ev.u.create.phys); +ba2str (&hogdev->dst, (char *) ev.u.create.uniq); ev.u.create.vendor = vendor; ev.u.create.product = product; ev.u.create.version = version;@@ -724,6 +728,7 @@ static void attio_disconnected_cb(gpointer user_data)static struct hog_device *hog_new_device (struct btd_device *device,uint16_t id) { +struct btd_adapter *adapter =device_get_adapter (device);struct hog_device *hogdev;char name[HCI_MAX_NAME_LENGTH +1 ];@@ -736,6 +741,8 @@ static struct hog_device *hog_new_device(struct btd_device *device, device_get_name(device, name, sizeof(name));if (strlen (name) >0 ) hogdev->name =g_strdup (name); +bacpy (&hogdev->src,btd_adapter_get_address (adapter)); +bacpy (&hogdev->dst,device_get_address (device));Quoted 3 lines
return hogdev;}
--
Szymon K. Janc
[email protected]--
Szymon K. Janc
[email protected]