Linux bluetooth development
 help / color / mirror / Atom feed
From: Florian Grandel <fgrandel@gmail.com>
To: BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: How to get the hci_dev from an adv instance's work struct in a linked list?
Date: Thu, 02 Apr 2015 04:13:16 +0200	[thread overview]
Message-ID: <551CA5BC.5040307@gmail.com> (raw)

Hi!

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.

How would I construct the required hci_dev struct from the work pointer 
in this case? Any ideas?

Florian

             reply	other threads:[~2015-04-02  2:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02  2:13 Florian Grandel [this message]
2015-04-02  2:49 ` How to get the hci_dev from an adv instance's work struct in a linked list? Arman Uguray
2015-04-02  9:58   ` Florian Grandel

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=551CA5BC.5040307@gmail.com \
    --to=fgrandel@gmail.com \
    --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