Skip to content

Commit

Permalink
Bluetooth: make batostr() print in the right order
Browse files Browse the repository at this point in the history
The Bluetooth core uses the the BD_ADDR in the opposite order from the
human readable order. So we are changing batostr() to print in the
correct order and then removing some baswap(), as they are not needed
anymore.

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Gustavo F. Padovan committed Oct 12, 2010
1 parent cb810a1 commit d6b2eb2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
5 changes: 1 addition & 4 deletions net/bluetooth/cmtp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,10 @@ static int cmtp_session(void *arg)
int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
{
struct cmtp_session *session, *s;
bdaddr_t dst;
int i, err;

BT_DBG("");

baswap(&dst, &bt_sk(sock->sk)->dst);

session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL);
if (!session)
return -ENOMEM;
Expand All @@ -346,7 +343,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)

BT_DBG("mtu %d", session->mtu);

sprintf(session->name, "%s", batostr(&dst));
sprintf(session->name, "%s", batostr(&bt_sk(sock->sk)->dst));

session->sock = sock;
session->state = BT_CONFIG;
Expand Down
17 changes: 4 additions & 13 deletions net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ static ssize_t show_link_type(struct device *dev, struct device_attribute *attr,
static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf)
{
struct hci_conn *conn = dev_get_drvdata(dev);
bdaddr_t bdaddr;
baswap(&bdaddr, &conn->dst);
return sprintf(buf, "%s\n", batostr(&bdaddr));
return sprintf(buf, "%s\n", batostr(&conn->dst));
}

static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf)
Expand Down Expand Up @@ -238,9 +236,7 @@ static ssize_t show_class(struct device *dev, struct device_attribute *attr, cha
static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf)
{
struct hci_dev *hdev = dev_get_drvdata(dev);
bdaddr_t bdaddr;
baswap(&bdaddr, &hdev->bdaddr);
return sprintf(buf, "%s\n", batostr(&bdaddr));
return sprintf(buf, "%s\n", batostr(&hdev->bdaddr));
}

static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf)
Expand Down Expand Up @@ -408,10 +404,8 @@ static int inquiry_cache_show(struct seq_file *f, void *p)

for (e = cache->list; e; e = e->next) {
struct inquiry_data *data = &e->data;
bdaddr_t bdaddr;
baswap(&bdaddr, &data->bdaddr);
seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
batostr(&bdaddr),
batostr(&data->bdaddr),
data->pscan_rep_mode, data->pscan_period_mode,
data->pscan_mode, data->dev_class[2],
data->dev_class[1], data->dev_class[0],
Expand Down Expand Up @@ -445,13 +439,10 @@ static int blacklist_show(struct seq_file *f, void *p)

list_for_each(l, &hdev->blacklist) {
struct bdaddr_list *b;
bdaddr_t bdaddr;

b = list_entry(l, struct bdaddr_list, list);

baswap(&bdaddr, &b->bdaddr);

seq_printf(f, "%s\n", batostr(&bdaddr));
seq_printf(f, "%s\n", batostr(&b->bdaddr));
}

hci_dev_unlock_bh(hdev);
Expand Down
8 changes: 2 additions & 6 deletions net/bluetooth/hidp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ static int hidp_setup_hid(struct hidp_session *session,
struct hidp_connadd_req *req)
{
struct hid_device *hid;
bdaddr_t src, dst;
int err;

session->rd_data = kzalloc(req->rd_size, GFP_KERNEL);
Expand All @@ -781,18 +780,15 @@ static int hidp_setup_hid(struct hidp_session *session,

hid->driver_data = session;

baswap(&src, &bt_sk(session->ctrl_sock->sk)->src);
baswap(&dst, &bt_sk(session->ctrl_sock->sk)->dst);

hid->bus = BUS_BLUETOOTH;
hid->vendor = req->vendor;
hid->product = req->product;
hid->version = req->version;
hid->country = req->country;

strncpy(hid->name, req->name, 128);
strncpy(hid->phys, batostr(&src), 64);
strncpy(hid->uniq, batostr(&dst), 64);
strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);

hid->dev.parent = hidp_get_device(session);
hid->ll_driver = &hidp_hid_driver;
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ char *batostr(bdaddr_t *ba)

i ^= 1;
sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
ba->b[0], ba->b[1], ba->b[2],
ba->b[3], ba->b[4], ba->b[5]);
ba->b[5], ba->b[4], ba->b[3],
ba->b[2], ba->b[1], ba->b[0]);

return str[i];
}
Expand Down
4 changes: 1 addition & 3 deletions net/bluetooth/rfcomm/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ static struct device *rfcomm_get_device(struct rfcomm_dev *dev)
static ssize_t show_address(struct device *tty_dev, struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
bdaddr_t bdaddr;
baswap(&bdaddr, &dev->dst);
return sprintf(buf, "%s\n", batostr(&bdaddr));
return sprintf(buf, "%s\n", batostr(&dev->dst));
}

static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf)
Expand Down

0 comments on commit d6b2eb2

Please sign in to comment.