Linux USB
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of()
@ 2020-09-01  1:01 Tian Tao
  2020-09-01  7:08 ` Mika Westerberg
  0 siblings, 1 reply; 4+ messages in thread
From: Tian Tao @ 2020-09-01  1:01 UTC (permalink / raw)
  To: andreas.noever, michael.jamet, mika.westerberg, YehezkelShB,
	linux-usb
  Cc: linuxarm

Use kobj_to_dev() instead of container_of()

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of()
  2020-09-01  1:01 [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of() Tian Tao
@ 2020-09-01  7:08 ` Mika Westerberg
  2020-09-01  7:37   ` 答复: " tiantao (H)
  0 siblings, 1 reply; 4+ messages in thread
From: Mika Westerberg @ 2020-09-01  7:08 UTC (permalink / raw)
  To: Tian Tao; +Cc: andreas.noever, michael.jamet, YehezkelShB, linux-usb, linuxarm

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 答复: [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of()
  2020-09-01  7:08 ` Mika Westerberg
@ 2020-09-01  7:37   ` tiantao (H)
  2020-09-01  7:42     ` Mika Westerberg
  0 siblings, 1 reply; 4+ messages in thread
From: tiantao (H) @ 2020-09-01  7:37 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: andreas.noever@gmail.com, michael.jamet@intel.com,
	YehezkelShB@gmail.com, linux-usb@vger.kernel.org, Linuxarm

Hi:

Doesn't really matter for an individual driver, but it may get coppied to lots more. 
I consider it's a little tidy up.


-----邮件原件-----
发件人: Mika Westerberg [mailto:mika.westerberg@linux.intel.com] 
发送时间: 2020年9月1日 15:09
收件人: tiantao (H) <tiantao6@hisilicon.com>
抄送: andreas.noever@gmail.com; michael.jamet@intel.com; YehezkelShB@gmail.com; linux-usb@vger.kernel.org; Linuxarm <linuxarm@huawei.com>
主题: Re: [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of()

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 答复: [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of()
  2020-09-01  7:37   ` 答复: " tiantao (H)
@ 2020-09-01  7:42     ` Mika Westerberg
  0 siblings, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2020-09-01  7:42 UTC (permalink / raw)
  To: tiantao (H)
  Cc: andreas.noever@gmail.com, michael.jamet@intel.com,
	YehezkelShB@gmail.com, linux-usb@vger.kernel.org, Linuxarm

On Tue, Sep 01, 2020 at 07:37:48AM +0000, tiantao (H) wrote:
> Hi:
> 
> Doesn't really matter for an individual driver, but it may get coppied to lots more. 
> I consider it's a little tidy up.

That's fine but please write it down in the commit message as well :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-01  7:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-01  1:01 [PATCH] thunderbolt: Use kobj_to_dev() instead of container_of() Tian Tao
2020-09-01  7:08 ` Mika Westerberg
2020-09-01  7:37   ` 答复: " tiantao (H)
2020-09-01  7:42     ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox