Re: [PATCH 3/4] Bluetooth: Introduce to_hci_conn

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrei

On Fri, Jan 27, 2012 at 6:01 PM, Andrei Emeltchenko
<andrei.emeltchenko.news@xxxxxxxxx> wrote:
> Hi David,
>
>> 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@xxxxxxxxxxxxxx>
>> ---
>>  include/net/bluetooth/hci_core.h |    1 +
>>  net/bluetooth/hci_sysfs.c        |   10 ++++------
>>  2 files changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/net/bluetooth/hci_core.h
>> b/include/net/bluetooth/hci_core.h
>> index 9780f42..8784da1 100644
>> --- a/include/net/bluetooth/hci_core.h
>> +++ b/include/net/bluetooth/hci_core.h
>> @@ -612,6 +612,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)
>>  {
>> diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
>> index 2a0243a..17e6cd4 100644
>> --- a/net/bluetooth/hci_sysfs.c
>> +++ b/net/bluetooth/hci_sysfs.c
>> @@ -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);
>
> I personally think it was more readable before.

I didn't write it to make it more readable but to make it conform to
other subsystems using the drvdata field. I think using a pointer in a
structure if we could also use container_of is a waste of memory.
Anyway, in this case we will keep the drvdata field anyway as we
cannot remove it so I have no objections if you drop this patch.
Personally I'd prefer to_hci_conn, though, as we are no driver but a
bus so "get_drvdata" sounds not right here.

Regards
David

> --Andrei
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux