All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary
@ 2015-03-17  9:13 Luiz Augusto von Dentz
  2015-03-17  9:13 ` [PATCH BlueZ 2/4] core/device: Convert temporary flag to bool Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17  9:13 UTC (permalink / raw)
  To: linux-bluetooth

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

In case the device is set as not temporary it should trigger
store_device_info but the function checks if temporary flag is set but
since currently the code only set the flag after the call nothing really
happens.
---
 src/device.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/device.c b/src/device.c
index 97c0523..6100341 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4474,17 +4474,19 @@ void btd_device_set_temporary(struct btd_device *device, gboolean temporary)
 
 	DBG("temporary %d", temporary);
 
+	device->temporary = temporary;
+
 	if (temporary) {
 		if (device->bredr)
 			adapter_whitelist_remove(device->adapter, device);
 		adapter_connect_list_remove(device->adapter, device);
-	} else {
-		if (device->bredr)
-			adapter_whitelist_add(device->adapter, device);
-		store_device_info(device);
+		return;
 	}
 
-	device->temporary = temporary;
+	if (device->bredr)
+		adapter_whitelist_add(device->adapter, device);
+
+	store_device_info(device);
 }
 
 void btd_device_set_trusted(struct btd_device *device, gboolean trusted)
-- 
2.1.0


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

* [PATCH BlueZ 2/4] core/device: Convert temporary flag to bool
  2015-03-17  9:13 [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
@ 2015-03-17  9:13 ` Luiz Augusto von Dentz
  2015-03-17  9:13 ` [PATCH BlueZ 3/4] core/adapter: Remove checks to device_is_temporary Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17  9:13 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 plugins/sixaxis.c |  2 +-
 src/adapter.c     | 12 ++++++------
 src/device.c      | 20 ++++++++++----------
 src/device.h      |  2 +-
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index c93f5d4..fcc93bc 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -302,7 +302,7 @@ static bool setup_device(int fd, int index, struct btd_adapter *adapter)
 	btd_device_device_set_name(device, devices[index].name);
 	btd_device_set_pnpid(device, devices[index].source, devices[index].vid,
 				devices[index].pid, devices[index].version);
-	btd_device_set_temporary(device, FALSE);
+	btd_device_set_temporary(device, false);
 
 	return true;
 }
diff --git a/src/adapter.c b/src/adapter.c
index 3744c2b..09219e5 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2305,7 +2305,7 @@ static DBusMessage *remove_device(DBusConnection *conn,
 
 	device = list->data;
 
-	btd_device_set_temporary(device, TRUE);
+	btd_device_set_temporary(device, true);
 
 	if (!btd_device_is_connected(device)) {
 		btd_adapter_remove_device(adapter, device);
@@ -2948,7 +2948,7 @@ static void load_devices(struct btd_adapter *adapter)
 		if (!device)
 			goto free;
 
-		btd_device_set_temporary(device, FALSE);
+		btd_device_set_temporary(device, false);
 		adapter->devices = g_slist_append(adapter->devices, device);
 
 		/* TODO: register services from pre-loaded list of primaries */
@@ -6045,7 +6045,7 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 		device_set_bonded(device, BDADDR_BREDR);
 
 		if (device_is_temporary(device))
-			btd_device_set_temporary(device, FALSE);
+			btd_device_set_temporary(device, false);
 	}
 
 	bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
@@ -6163,7 +6163,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
 		device_set_bonded(device, addr->type);
 
 		if (device_is_temporary(device))
-			btd_device_set_temporary(device, FALSE);
+			btd_device_set_temporary(device, false);
 	}
 
 	bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
@@ -6265,7 +6265,7 @@ static void new_csrk_callback(uint16_t index, uint16_t length,
 								key->type);
 
 	if (device_is_temporary(device))
-		btd_device_set_temporary(device, FALSE);
+		btd_device_set_temporary(device, false);
 }
 
 static void store_irk(struct btd_adapter *adapter, const bdaddr_t *peer,
@@ -6353,7 +6353,7 @@ static void new_irk_callback(uint16_t index, uint16_t length,
 	store_irk(adapter, &addr->bdaddr, addr->type, irk->val);
 
 	if (device_is_temporary(device))
-		btd_device_set_temporary(device, FALSE);
+		btd_device_set_temporary(device, false);
 }
 
 static void store_conn_param(struct btd_adapter *adapter, const bdaddr_t *peer,
diff --git a/src/device.c b/src/device.c
index 6100341..14bfe7b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -205,7 +205,7 @@ struct btd_device {
 	GSList		*services;		/* List of btd_service */
 	GSList		*pending;		/* Pending services */
 	GSList		*watches;		/* List of disconnect_data */
-	gboolean	temporary;
+	bool		temporary;
 	guint		disconn_timer;
 	guint		discov_timer;
 	struct browse_req *browse;		/* service discover request */
@@ -1137,7 +1137,7 @@ int device_block(struct btd_device *device, gboolean update_only)
 
 	store_device_info(device);
 
-	btd_device_set_temporary(device, FALSE);
+	btd_device_set_temporary(device, false);
 
 	g_dbus_emit_property_changed(dbus_conn, device->path,
 						DEVICE_INTERFACE, "Blocked");
@@ -1336,7 +1336,7 @@ static void device_profile_connected(struct btd_device *dev,
 	DBG("%s %s (%d)", profile->name, strerror(-err), -err);
 
 	if (!err)
-		btd_device_set_temporary(dev, FALSE);
+		btd_device_set_temporary(dev, false);
 
 	if (dev->pending == NULL)
 		return;
@@ -1516,7 +1516,7 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type
 	if (!btd_adapter_get_powered(dev->adapter))
 		return btd_error_not_ready(msg);
 
-	btd_device_set_temporary(dev, FALSE);
+	btd_device_set_temporary(dev, false);
 
 	if (!state->svc_resolved)
 		goto resolve_services;
@@ -1609,7 +1609,7 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
 		if (dev->le_state.connected)
 			return dbus_message_new_method_return(msg);
 
-		btd_device_set_temporary(dev, FALSE);
+		btd_device_set_temporary(dev, false);
 
 		if (dev->disable_auto_connect) {
 			dev->disable_auto_connect = FALSE;
@@ -1975,7 +1975,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
 	uint8_t io_cap;
 	int err;
 
-	btd_device_set_temporary(device, FALSE);
+	btd_device_set_temporary(device, false);
 
 	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
@@ -2947,7 +2947,7 @@ static struct btd_device *device_new(struct btd_adapter *adapter,
 	}
 
 	device->adapter = adapter;
-	device->temporary = TRUE;
+	device->temporary = true;
 
 	gatt_db_register(device->db, gatt_service_added, gatt_service_removed,
 								device, NULL);
@@ -3942,7 +3942,7 @@ static void register_gatt_services(struct btd_device *device)
 	 */
 	gatt_db_foreach_service(device->db, NULL, add_primary, &services);
 
-	btd_device_set_temporary(device, FALSE);
+	btd_device_set_temporary(device, false);
 
 	if (req)
 		update_gatt_uuids(req, device->primaries, services);
@@ -4464,7 +4464,7 @@ gboolean device_is_temporary(struct btd_device *device)
 	return device->temporary;
 }
 
-void btd_device_set_temporary(struct btd_device *device, gboolean temporary)
+void btd_device_set_temporary(struct btd_device *device, bool temporary)
 {
 	if (!device)
 		return;
@@ -4631,7 +4631,7 @@ void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type)
 	g_dbus_emit_property_changed(dbus_conn, dev->path,
 						DEVICE_INTERFACE, "Paired");
 
-	btd_device_set_temporary(dev, TRUE);
+	btd_device_set_temporary(dev, true);
 
 	if (btd_device_is_connected(dev))
 		device_request_disconnect(dev, NULL);
diff --git a/src/device.h b/src/device.h
index 8edd0df..b17f53a 100644
--- a/src/device.h
+++ b/src/device.h
@@ -86,7 +86,7 @@ bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
 gboolean device_is_trusted(struct btd_device *device);
 void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
 void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
-void btd_device_set_temporary(struct btd_device *device, gboolean temporary);
+void btd_device_set_temporary(struct btd_device *device, bool temporary);
 void btd_device_set_trusted(struct btd_device *device, gboolean trusted);
 void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type);
 void device_set_legacy(struct btd_device *device, bool legacy);
-- 
2.1.0


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

* [PATCH BlueZ 3/4] core/adapter: Remove checks to device_is_temporary
  2015-03-17  9:13 [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
  2015-03-17  9:13 ` [PATCH BlueZ 2/4] core/device: Convert temporary flag to bool Luiz Augusto von Dentz
@ 2015-03-17  9:13 ` Luiz Augusto von Dentz
  2015-03-17  9:13 ` [PATCH BlueZ 4/4] core: Make device_set_bonded reset temporary flag Luiz Augusto von Dentz
  2015-03-17 15:46 ` [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17  9:13 UTC (permalink / raw)
  To: linux-bluetooth

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

btd_device_set_temporary already checks if value is already set.
---
 src/adapter.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 09219e5..691549a 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -6044,8 +6044,7 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 
 		device_set_bonded(device, BDADDR_BREDR);
 
-		if (device_is_temporary(device))
-			btd_device_set_temporary(device, false);
+		btd_device_set_temporary(device, false);
 	}
 
 	bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
@@ -6162,8 +6161,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
 
 		device_set_bonded(device, addr->type);
 
-		if (device_is_temporary(device))
-			btd_device_set_temporary(device, false);
+		btd_device_set_temporary(device, false);
 	}
 
 	bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
@@ -6264,8 +6262,7 @@ static void new_csrk_callback(uint16_t index, uint16_t length,
 	store_csrk(bdaddr, &key->addr.bdaddr, key->addr.type, key->val, 0,
 								key->type);
 
-	if (device_is_temporary(device))
-		btd_device_set_temporary(device, false);
+	btd_device_set_temporary(device, false);
 }
 
 static void store_irk(struct btd_adapter *adapter, const bdaddr_t *peer,
@@ -6352,8 +6349,7 @@ static void new_irk_callback(uint16_t index, uint16_t length,
 
 	store_irk(adapter, &addr->bdaddr, addr->type, irk->val);
 
-	if (device_is_temporary(device))
-		btd_device_set_temporary(device, false);
+	btd_device_set_temporary(device, false);
 }
 
 static void store_conn_param(struct btd_adapter *adapter, const bdaddr_t *peer,
-- 
2.1.0


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

* [PATCH BlueZ 4/4] core: Make device_set_bonded reset temporary flag
  2015-03-17  9:13 [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
  2015-03-17  9:13 ` [PATCH BlueZ 2/4] core/device: Convert temporary flag to bool Luiz Augusto von Dentz
  2015-03-17  9:13 ` [PATCH BlueZ 3/4] core/adapter: Remove checks to device_is_temporary Luiz Augusto von Dentz
@ 2015-03-17  9:13 ` Luiz Augusto von Dentz
  2015-03-17 15:46 ` [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17  9:13 UTC (permalink / raw)
  To: linux-bluetooth

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

If device is set to bonded it means some info has been stored so it
cannot be temporary anymore.
---
 src/adapter.c | 4 ----
 src/device.c  | 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 691549a..6eeb2f9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -6043,8 +6043,6 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 								key->pin_len);
 
 		device_set_bonded(device, BDADDR_BREDR);
-
-		btd_device_set_temporary(device, false);
 	}
 
 	bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
@@ -6160,8 +6158,6 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
 					key->type, key->enc_size, ediv, rand);
 
 		device_set_bonded(device, addr->type);
-
-		btd_device_set_temporary(device, false);
 	}
 
 	bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
diff --git a/src/device.c b/src/device.c
index 14bfe7b..aaa9f43 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4518,6 +4518,8 @@ void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type)
 		device->bredr_state.bonded = true;
 	else
 		device->le_state.bonded = true;
+
+	btd_device_set_temporary(device, false);
 }
 
 void device_set_legacy(struct btd_device *device, bool legacy)
-- 
2.1.0


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

* Re: [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary
  2015-03-17  9:13 [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2015-03-17  9:13 ` [PATCH BlueZ 4/4] core: Make device_set_bonded reset temporary flag Luiz Augusto von Dentz
@ 2015-03-17 15:46 ` Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17 15:46 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Tue, Mar 17, 2015 at 11:13 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> In case the device is set as not temporary it should trigger
> store_device_info but the function checks if temporary flag is set but
> since currently the code only set the flag after the call nothing really
> happens.
> ---
>  src/device.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/src/device.c b/src/device.c
> index 97c0523..6100341 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -4474,17 +4474,19 @@ void btd_device_set_temporary(struct btd_device *device, gboolean temporary)
>
>         DBG("temporary %d", temporary);
>
> +       device->temporary = temporary;
> +
>         if (temporary) {
>                 if (device->bredr)
>                         adapter_whitelist_remove(device->adapter, device);
>                 adapter_connect_list_remove(device->adapter, device);
> -       } else {
> -               if (device->bredr)
> -                       adapter_whitelist_add(device->adapter, device);
> -               store_device_info(device);
> +               return;
>         }
>
> -       device->temporary = temporary;
> +       if (device->bredr)
> +               adapter_whitelist_add(device->adapter, device);
> +
> +       store_device_info(device);
>  }
>
>  void btd_device_set_trusted(struct btd_device *device, gboolean trusted)
> --
> 2.1.0

Applied.


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2015-03-17 15:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17  9:13 [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz
2015-03-17  9:13 ` [PATCH BlueZ 2/4] core/device: Convert temporary flag to bool Luiz Augusto von Dentz
2015-03-17  9:13 ` [PATCH BlueZ 3/4] core/adapter: Remove checks to device_is_temporary Luiz Augusto von Dentz
2015-03-17  9:13 ` [PATCH BlueZ 4/4] core: Make device_set_bonded reset temporary flag Luiz Augusto von Dentz
2015-03-17 15:46 ` [PATCH BlueZ 1/4] core/device: Fix btd_device_set_temporary Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.