From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Tian Tao <tiantao6@hisilicon.com>
Cc: andreas.noever@gmail.com, michael.jamet@intel.com,
YehezkelShB@gmail.com, linux-usb@vger.kernel.org,
linuxarm@huawei.com
Subject: Re: [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of()
Date: Tue, 1 Sep 2020 10:08:47 +0300 [thread overview]
Message-ID: <20200901070847.GR1375436@lahna.fi.intel.com> (raw)
In-Reply-To: <1598922090-39482-1-git-send-email-tiantao6@hisilicon.com>
Hi,
On Tue, Sep 01, 2020 at 09:01:30AM +0800, Tian Tao wrote:
> Use kobj_to_dev() instead of container_of()
OK, but can you write here why it is better? :)
> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
> ---
> drivers/thunderbolt/domain.c | 2 +-
> drivers/thunderbolt/switch.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c
> index bba4cbf..7a192b7 100644
> --- a/drivers/thunderbolt/domain.c
> +++ b/drivers/thunderbolt/domain.c
> @@ -275,7 +275,7 @@ static struct attribute *domain_attrs[] = {
> static umode_t domain_attr_is_visible(struct kobject *kobj,
> struct attribute *attr, int n)
> {
> - struct device *dev = container_of(kobj, struct device, kobj);
> + struct device *dev = kobj_to_dev(kobj);
> struct tb *tb = container_of(dev, struct tb, dev);
>
> if (attr == &dev_attr_boot_acl.attr) {
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index a921de9..173ce3b 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -1649,7 +1649,7 @@ static struct attribute *switch_attrs[] = {
> static umode_t switch_attr_is_visible(struct kobject *kobj,
> struct attribute *attr, int n)
> {
> - struct device *dev = container_of(kobj, struct device, kobj);
> + struct device *dev = kobj_to_dev(kobj);
> struct tb_switch *sw = tb_to_switch(dev);
>
> if (attr == &dev_attr_device.attr) {
> --
> 2.7.4
next prev parent reply other threads:[~2020-09-01 7:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 1:01 [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of() Tian Tao
2020-09-01 7:08 ` Mika Westerberg [this message]
2020-09-01 7:37 ` 答复: " tiantao (H)
2020-09-01 7:42 ` Mika Westerberg
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=20200901070847.GR1375436@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=michael.jamet@intel.com \
--cc=tiantao6@hisilicon.com \
/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