All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btmgmt: Fix endianess in cmd_scan_params()
@ 2014-07-01 22:25 Andre Guedes
  2014-07-01 22:43 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Guedes @ 2014-07-01 22:25 UTC (permalink / raw)
  To: linux-bluetooth

The kernel expects Mgmt commands parameters in little-endian byte order
so this patch fixes cp.interval and cp.window in cmd_scan_params().
---
 tools/btmgmt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 066fde9..b0da592 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2404,6 +2404,7 @@ static void cmd_scan_params(struct mgmt *mgmt, uint16_t index,
 							int argc, char **argv)
 {
 	struct mgmt_cp_set_scan_params cp;
+	uint16_t interval, window;
 
 	if (argc < 3) {
 		scan_params_usage();
@@ -2413,8 +2414,11 @@ static void cmd_scan_params(struct mgmt *mgmt, uint16_t index,
 	if (index == MGMT_INDEX_NONE)
 		index = 0;
 
-	cp.interval = strtol(argv[1], NULL, 0);
-	cp.window = strtol(argv[2], NULL, 0);
+	interval = strtol(argv[1], NULL, 0);
+	window = strtol(argv[2], NULL, 0);
+
+	put_le16(interval, &cp.interval);
+	put_le16(window, &cp.window);
 
 	if (mgmt_send(mgmt, MGMT_OP_SET_SCAN_PARAMS, index, sizeof(cp), &cp,
 					scan_params_rsp, NULL, NULL) == 0) {
-- 
1.9.1


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

* Re: [PATCH] btmgmt: Fix endianess in cmd_scan_params()
  2014-07-01 22:25 [PATCH] btmgmt: Fix endianess in cmd_scan_params() Andre Guedes
@ 2014-07-01 22:43 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2014-07-01 22:43 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

Hi Andre,

> The kernel expects Mgmt commands parameters in little-endian byte order
> so this patch fixes cp.interval and cp.window in cmd_scan_params().
> ---
> tools/btmgmt.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/btmgmt.c b/tools/btmgmt.c
> index 066fde9..b0da592 100644
> --- a/tools/btmgmt.c
> +++ b/tools/btmgmt.c
> @@ -2404,6 +2404,7 @@ static void cmd_scan_params(struct mgmt *mgmt, uint16_t index,
> 							int argc, char **argv)
> {
> 	struct mgmt_cp_set_scan_params cp;
> +	uint16_t interval, window;
> 
> 	if (argc < 3) {
> 		scan_params_usage();
> @@ -2413,8 +2414,11 @@ static void cmd_scan_params(struct mgmt *mgmt, uint16_t index,
> 	if (index == MGMT_INDEX_NONE)
> 		index = 0;
> 
> -	cp.interval = strtol(argv[1], NULL, 0);
> -	cp.window = strtol(argv[2], NULL, 0);
> +	interval = strtol(argv[1], NULL, 0);
> +	window = strtol(argv[2], NULL, 0);
> +
> +	put_le16(interval, &cp.interval);
> +	put_le16(window, &cp.window);

the struct is already packed. So not need for unaligned access. Just use the standard endian conversion functions.

Regards

Marcel


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

end of thread, other threads:[~2014-07-01 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-01 22:25 [PATCH] btmgmt: Fix endianess in cmd_scan_params() Andre Guedes
2014-07-01 22:43 ` Marcel Holtmann

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.