]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
Bluetooth: Introduce to_hci_conn
authorDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 9 Feb 2012 20:58:33 +0000 (21:58 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 13 Feb 2012 15:01:37 +0000 (17:01 +0200)
This avoids using the dev_set/get_drvdata() functions to retrieve a
pointer to our own structure. We can use simple pointer arithmetic here.
The drvdata field is actually not needed by any other code-path but this
makes the code more consistent with hci_dev.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_sysfs.c

index 4559189a22a12fadb09acc87dc7c4881e37f9d12..b20d990436b4cb384cbb4cfc76755f1176bf8dcd 100644 (file)
@@ -623,6 +623,7 @@ static inline struct hci_dev *hci_dev_hold(struct hci_dev *d)
 #define hci_dev_unlock(d)      mutex_unlock(&d->lock)
 
 #define to_hci_dev(d) container_of(d, struct hci_dev, dev)
+#define to_hci_conn(c) container_of(c, struct hci_conn, dev)
 
 static inline void *hci_get_drvdata(struct hci_dev *hdev)
 {
index 2a0243add1e455296864506ffcb4d48cb45e9ea7..17e6cd48ad4d000fe1549c1fad773db41bbd58c8 100644 (file)
@@ -33,19 +33,19 @@ static inline char *link_typetostr(int type)
 
 static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct hci_conn *conn = dev_get_drvdata(dev);
+       struct hci_conn *conn = to_hci_conn(dev);
        return sprintf(buf, "%s\n", link_typetostr(conn->type));
 }
 
 static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct hci_conn *conn = dev_get_drvdata(dev);
+       struct hci_conn *conn = to_hci_conn(dev);
        return sprintf(buf, "%s\n", batostr(&conn->dst));
 }
 
 static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct hci_conn *conn = dev_get_drvdata(dev);
+       struct hci_conn *conn = to_hci_conn(dev);
 
        return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
                                conn->features[0], conn->features[1],
@@ -79,7 +79,7 @@ static const struct attribute_group *bt_link_groups[] = {
 
 static void bt_link_release(struct device *dev)
 {
-       void *data = dev_get_drvdata(dev);
+       void *data = to_hci_conn(dev);
        kfree(data);
 }
 
@@ -120,8 +120,6 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
 
        dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
 
-       dev_set_drvdata(&conn->dev, conn);
-
        if (device_add(&conn->dev) < 0) {
                BT_ERR("Failed to register connection device");
                return;