aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-03-14 12:08:46 -0400
committerGustavo Padovan <gustavo@padovan.org>2012-05-08 23:41:30 -0400
commiteb55ef07a211eea95088eb0e6cdbd53cd65d9755 (patch)
tree4f6fac717c3e12a54b92196276a308006a33167b /net
parentcdbaccca733c9dde3faf150150102dade311c91f (diff)
Bluetooth: Fix broken usage of put_unaligned_le16
In case the struct is already __packed, there is no need to use unaligned access to the data. So just use cpu_to_le16 or __constant_cpu_to_le16 in these cases. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/mgmt.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5e88fda42f1f..194a0426a3e5 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -225,7 +225,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status)
225 225
226 ev = (void *) skb_put(skb, sizeof(*ev)); 226 ev = (void *) skb_put(skb, sizeof(*ev));
227 ev->status = status; 227 ev->status = status;
228 put_unaligned_le16(cmd, &ev->opcode); 228 ev->opcode = cpu_to_le16(cmd);
229 229
230 err = sock_queue_rcv_skb(sk, skb); 230 err = sock_queue_rcv_skb(sk, skb);
231 if (err < 0) 231 if (err < 0)
@@ -255,7 +255,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status,
255 hdr->len = cpu_to_le16(sizeof(*ev) + rp_len); 255 hdr->len = cpu_to_le16(sizeof(*ev) + rp_len);
256 256
257 ev = (void *) skb_put(skb, sizeof(*ev) + rp_len); 257 ev = (void *) skb_put(skb, sizeof(*ev) + rp_len);
258 put_unaligned_le16(cmd, &ev->opcode); 258 ev->opcode = cpu_to_le16(cmd);
259 ev->status = status; 259 ev->status = status;
260 260
261 if (rp) 261 if (rp)
@@ -276,7 +276,7 @@ static int read_version(struct sock *sk, struct hci_dev *hdev, void *data,
276 BT_DBG("sock %p", sk); 276 BT_DBG("sock %p", sk);
277 277
278 rp.version = MGMT_VERSION; 278 rp.version = MGMT_VERSION;
279 put_unaligned_le16(MGMT_REVISION, &rp.revision); 279 rp.revision = __constant_cpu_to_le16(MGMT_REVISION);
280 280
281 return cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_VERSION, 0, &rp, 281 return cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_VERSION, 0, &rp,
282 sizeof(rp)); 282 sizeof(rp));
@@ -286,8 +286,8 @@ static int read_commands(struct sock *sk, struct hci_dev *hdev, void *data,
286 u16 data_len) 286 u16 data_len)
287{ 287{
288 struct mgmt_rp_read_commands *rp; 288 struct mgmt_rp_read_commands *rp;
289 u16 num_commands = ARRAY_SIZE(mgmt_commands); 289 const u16 num_commands = ARRAY_SIZE(mgmt_commands);
290 u16 num_events = ARRAY_SIZE(mgmt_events); 290 const u16 num_events = ARRAY_SIZE(mgmt_events);
291 u16 *opcode; 291 u16 *opcode;
292 size_t rp_size; 292 size_t rp_size;
293 int i, err; 293 int i, err;
@@ -300,8 +300,8 @@ static int read_commands(struct sock *sk, struct hci_dev *hdev, void *data,
300 if (!rp) 300 if (!rp)
301 return -ENOMEM; 301 return -ENOMEM;
302 302
303 put_unaligned_le16(num_commands, &rp->num_commands); 303 rp->num_commands = __constant_cpu_to_le16(num_commands);
304 put_unaligned_le16(num_events, &rp->num_events); 304 rp->num_events = __constant_cpu_to_le16(num_events);
305 305
306 for (i = 0, opcode = rp->opcodes; i < num_commands; i++, opcode++) 306 for (i = 0, opcode = rp->opcodes; i < num_commands; i++, opcode++)
307 put_unaligned_le16(mgmt_commands[i], opcode); 307 put_unaligned_le16(mgmt_commands[i], opcode);
@@ -342,14 +342,14 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
342 return -ENOMEM; 342 return -ENOMEM;
343 } 343 }
344 344
345 put_unaligned_le16(count, &rp->num_controllers); 345 rp->num_controllers = cpu_to_le16(count);
346 346
347 i = 0; 347 i = 0;
348 list_for_each_entry(d, &hci_dev_list, list) { 348 list_for_each_entry(d, &hci_dev_list, list) {
349 if (test_bit(HCI_SETUP, &d->dev_flags)) 349 if (test_bit(HCI_SETUP, &d->dev_flags))
350 continue; 350 continue;
351 351
352 put_unaligned_le16(d->id, &rp->index[i++]); 352 rp->index[i++] = cpu_to_le16(d->id);
353 BT_DBG("Added hci%u", d->id); 353 BT_DBG("Added hci%u", d->id);
354 } 354 }
355 355
@@ -665,8 +665,7 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev,
665 bacpy(&rp.bdaddr, &hdev->bdaddr); 665 bacpy(&rp.bdaddr, &hdev->bdaddr);
666 666
667 rp.version = hdev->hci_ver; 667 rp.version = hdev->hci_ver;
668 668 rp.manufacturer = cpu_to_le16(hdev->manufacturer);
669 put_unaligned_le16(hdev->manufacturer, &rp.manufacturer);
670 669
671 rp.supported_settings = cpu_to_le32(get_supported_settings(hdev)); 670 rp.supported_settings = cpu_to_le32(get_supported_settings(hdev));
672 rp.current_settings = cpu_to_le32(get_current_settings(hdev)); 671 rp.current_settings = cpu_to_le32(get_current_settings(hdev));
@@ -1571,7 +1570,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
1571 goto unlock; 1570 goto unlock;
1572 } 1571 }
1573 1572
1574 put_unaligned_le16(conn->handle, &dc.handle); 1573 dc.handle = cpu_to_le16(conn->handle);
1575 dc.reason = 0x13; /* Remote User Terminated Connection */ 1574 dc.reason = 0x13; /* Remote User Terminated Connection */
1576 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc); 1575 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc);
1577 if (err < 0) 1576 if (err < 0)
@@ -1624,7 +1623,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data,
1624 goto failed; 1623 goto failed;
1625 } 1624 }
1626 1625
1627 put_unaligned_le16(conn->handle, &dc.handle); 1626 dc.handle = cpu_to_le16(conn->handle);
1628 dc.reason = 0x13; /* Remote User Terminated Connection */ 1627 dc.reason = 0x13; /* Remote User Terminated Connection */
1629 1628
1630 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc); 1629 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc);
@@ -1698,7 +1697,7 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data,
1698 i++; 1697 i++;
1699 } 1698 }
1700 1699
1701 put_unaligned_le16(i, &rp->conn_count); 1700 rp->conn_count = cpu_to_le16(i);
1702 1701
1703 /* Recalculate length in case of filtered SCO connections, etc */ 1702 /* Recalculate length in case of filtered SCO connections, etc */
1704 rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); 1703 rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info));
@@ -2992,7 +2991,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
2992 eir_len = eir_append_data(ev->eir, eir_len, 2991 eir_len = eir_append_data(ev->eir, eir_len,
2993 EIR_CLASS_OF_DEV, dev_class, 3); 2992 EIR_CLASS_OF_DEV, dev_class, 3);
2994 2993
2995 put_unaligned_le16(eir_len, &ev->eir_len); 2994 ev->eir_len = cpu_to_le16(eir_len);
2996 2995
2997 return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, buf, 2996 return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, buf,
2998 sizeof(*ev) + eir_len, NULL); 2997 sizeof(*ev) + eir_len, NULL);
@@ -3517,7 +3516,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
3517 eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV, 3516 eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
3518 dev_class, 3); 3517 dev_class, 3);
3519 3518
3520 put_unaligned_le16(eir_len, &ev->eir_len); 3519 ev->eir_len = cpu_to_le16(eir_len);
3521 3520
3522 ev_size = sizeof(*ev) + eir_len; 3521 ev_size = sizeof(*ev) + eir_len;
3523 3522
@@ -3542,7 +3541,7 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
3542 eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name, 3541 eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name,
3543 name_len); 3542 name_len);
3544 3543
3545 put_unaligned_le16(eir_len, &ev->eir_len); 3544 ev->eir_len = cpu_to_le16(eir_len);
3546 3545
3547 return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, 3546 return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev,
3548 sizeof(*ev) + eir_len, NULL); 3547 sizeof(*ev) + eir_len, NULL);