From: Florian Grandel <fgrandel@gmail.com>
To: Arman Uguray <armansito@chromium.org>
Cc: BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: Re: How to get the hci_dev from an adv instance's work struct in a linked list?
Date: Thu, 02 Apr 2015 11:58:37 +0200 [thread overview]
Message-ID: <551D12CD.4080705@gmail.com> (raw)
In-Reply-To: <CAHrH25Tq4cQhiaGu7HnTu1ep1XNd85UJJr-FbcGnyx5c9W9Evw@mail.gmail.com>
Hi Arman,
it's impressive how responsive you are on this list here. Really cool. :-)
>> I got quite far today refactoring from
>>
>> struct hci_dev { ... struct adv_info adv_instance; ... };
>>
>> to
>>
>> struct hci_dev { ... struct list_head adv_instances; ... };
>>
>> But in the end I got stuck on refactoring the adv timeout callback.
>> Originally it looked like this:
>>
>> static void adv_timeout_expired(struct work_struct *work)
>> {
>> struct hci_dev *hdev = container_of(work, struct hci_dev,
>> adv_instance.timeout_exp.work);
>> ...
>> }
>>
>> But now I would have to construct a pointer to the hci_dev struct from a
>> list entry:
>>
>> static void adv_timeout_expired(struct work_struct *work)
>> {
>> struct adv_info *adv_instance = container_of(work, struct adv_info,
>> timeout_exp.work);
>> ...
>> }
>>
>> I couldn't find a way to get the list head of the adv info list entry so
>> that I could retrieve its containing hci_dev structure, though.
>>
>
> Once simple solution is to add a struct hci_dev pointer to struct
> adv_info. Once you get the pointer to the instance then you can obtain
> the hci_dev pointer that way.
Yes, that's an obvious solution albeit it's a bit ugly as it introduces
extra redundancy. I thought of it, too, but I hoped I could avoid it.
Maybe I can solve it like that for now and then we see whether another
solution emerges once we got the refactored code in front of us.
Florian
prev parent reply other threads:[~2015-04-02 9:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-02 2:13 How to get the hci_dev from an adv instance's work struct in a linked list? Florian Grandel
2015-04-02 2:49 ` Arman Uguray
2015-04-02 9:58 ` Florian Grandel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=551D12CD.4080705@gmail.com \
--to=fgrandel@gmail.com \
--cc=armansito@chromium.org \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox