Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function
@ 2014-06-25  9:09 Luiz Augusto von Dentz
  2014-06-25  9:09 ` [PATCH BlueZ 2/2] android/hog: Fix code style Luiz Augusto von Dentz
  2014-06-25 15:36 ` [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-25  9:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hidhost.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index fdbe885..0c0d69d 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -155,6 +155,18 @@ static void hid_device_remove(struct hid_device *dev)
 	hid_device_free(dev);
 }
 
+static struct hid_device *hid_device_new(const bdaddr_t *addr)
+{
+	struct hid_device *dev;
+
+	dev = g_new0(struct hid_device, 1);
+	bacpy(&dev->dst, addr);
+	dev->state = HAL_HIDHOST_STATE_DISCONNECTED;
+	devices = g_slist_append(devices, dev);
+
+	return dev;
+}
+
 static bool hex2buf(const uint8_t *hex, uint8_t *buf, int buf_size)
 {
 	int i, j;
@@ -771,9 +783,7 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
 	}
 
 	if (!dev) {
-		dev = g_new0(struct hid_device, 1);
-		bacpy(&dev->dst, addr);
-		devices = g_slist_append(devices, dev);
+		dev = hid_device_new(addr);
 		bt_hid_notify_state(dev, HAL_HIDHOST_STATE_CONNECTING);
 	}
 
@@ -839,15 +849,11 @@ static void bt_hid_connect(const void *buf, uint16_t len)
 		goto failed;
 	}
 
-	dev = g_new0(struct hid_device, 1);
-	bacpy(&dev->dst, &dst);
-	dev->state = HAL_HIDHOST_STATE_DISCONNECTED;
+	dev = hid_device_new(&dst);
 
 	ba2str(&dev->dst, addr);
 	DBG("connecting to %s", addr);
 
-	devices = g_slist_append(devices, dev);
-
 	if (bt_is_device_le(&dst)) {
 		if (!hog_connect(dev)) {
 			status = HAL_STATUS_FAILED;
@@ -1394,8 +1400,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 		if (l)
 			return;
 
-		dev = g_new0(struct hid_device, 1);
-		bacpy(&dev->dst, &dst);
+		dev = hid_device_new(&dst);
 		dev->ctrl_io = g_io_channel_ref(chan);
 
 		sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
@@ -1406,8 +1411,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 			return;
 		}
 
-		devices = g_slist_append(devices, dev);
-
 		dev->ctrl_watch = g_io_add_watch(dev->ctrl_io,
 					G_IO_HUP | G_IO_ERR | G_IO_NVAL,
 					ctrl_watch_cb, dev);
-- 
1.9.3


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

* [PATCH BlueZ 2/2] android/hog: Fix code style
  2014-06-25  9:09 [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function Luiz Augusto von Dentz
@ 2014-06-25  9:09 ` Luiz Augusto von Dentz
  2014-06-25 15:36 ` [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-25  9:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hog.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/android/hog.c b/android/hog.c
index c7ac6d1..652c374 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -199,7 +199,6 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
 static void external_report_reference_cb(guint8 status, const guint8 *pdu,
 					guint16 plen, gpointer user_data);
 
-
 static void discover_descriptor_cb(uint8_t status, GSList *descs,
 								void *user_data)
 {
@@ -613,8 +612,7 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
 			report = g_new0(struct report, 1);
 			report->hog = hog;
 			report->decl = g_memdup(chr, sizeof(*chr));
-			hog->reports = g_slist_append(hog->reports,
-								report);
+			hog->reports = g_slist_append(hog->reports, report);
 			discover_descriptor(hog->attrib, start, end, report);
 		} else if (bt_uuid_cmp(&uuid, &report_map_uuid) == 0) {
 			gatt_read_char(hog->attrib, chr->value_handle,
@@ -635,8 +633,7 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
 	}
 
 	if (info_handle)
-		gatt_read_char(hog->attrib, info_handle, info_read_cb,
-									hog);
+		gatt_read_char(hog->attrib, info_handle, info_read_cb, hog);
 }
 
 static void report_free(void *data)
-- 
1.9.3


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

* Re: [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function
  2014-06-25  9:09 [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function Luiz Augusto von Dentz
  2014-06-25  9:09 ` [PATCH BlueZ 2/2] android/hog: Fix code style Luiz Augusto von Dentz
@ 2014-06-25 15:36 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-06-25 15:36 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Wednesday 25 of June 2014 12:09:25 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> ---
>  android/hidhost.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/android/hidhost.c b/android/hidhost.c
> index fdbe885..0c0d69d 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -155,6 +155,18 @@ static void hid_device_remove(struct hid_device *dev)
>  	hid_device_free(dev);
>  }
>  
> +static struct hid_device *hid_device_new(const bdaddr_t *addr)
> +{
> +	struct hid_device *dev;
> +
> +	dev = g_new0(struct hid_device, 1);
> +	bacpy(&dev->dst, addr);
> +	dev->state = HAL_HIDHOST_STATE_DISCONNECTED;
> +	devices = g_slist_append(devices, dev);
> +
> +	return dev;
> +}
> +
>  static bool hex2buf(const uint8_t *hex, uint8_t *buf, int buf_size)
>  {
>  	int i, j;
> @@ -771,9 +783,7 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib)
>  	}
>  
>  	if (!dev) {
> -		dev = g_new0(struct hid_device, 1);
> -		bacpy(&dev->dst, addr);
> -		devices = g_slist_append(devices, dev);
> +		dev = hid_device_new(addr);
>  		bt_hid_notify_state(dev, HAL_HIDHOST_STATE_CONNECTING);
>  	}
>  
> @@ -839,15 +849,11 @@ static void bt_hid_connect(const void *buf, uint16_t len)
>  		goto failed;
>  	}
>  
> -	dev = g_new0(struct hid_device, 1);
> -	bacpy(&dev->dst, &dst);
> -	dev->state = HAL_HIDHOST_STATE_DISCONNECTED;
> +	dev = hid_device_new(&dst);
>  
>  	ba2str(&dev->dst, addr);
>  	DBG("connecting to %s", addr);
>  
> -	devices = g_slist_append(devices, dev);
> -
>  	if (bt_is_device_le(&dst)) {
>  		if (!hog_connect(dev)) {
>  			status = HAL_STATUS_FAILED;
> @@ -1394,8 +1400,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  		if (l)
>  			return;
>  
> -		dev = g_new0(struct hid_device, 1);
> -		bacpy(&dev->dst, &dst);
> +		dev = hid_device_new(&dst);
>  		dev->ctrl_io = g_io_channel_ref(chan);
>  
>  		sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
> @@ -1406,8 +1411,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  			return;
>  		}
>  
> -		devices = g_slist_append(devices, dev);
> -
>  		dev->ctrl_watch = g_io_add_watch(dev->ctrl_io,
>  					G_IO_HUP | G_IO_ERR | G_IO_NVAL,
>  					ctrl_watch_cb, dev);
> 

Both patches applied, thanks.

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-06-25 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-25  9:09 [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function Luiz Augusto von Dentz
2014-06-25  9:09 ` [PATCH BlueZ 2/2] android/hog: Fix code style Luiz Augusto von Dentz
2014-06-25 15:36 ` [PATCH BlueZ 1/2] android/hidhost: Add hid_device_new helper function Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox