All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: mux: Fix copy-paste of the container_of
@ 2021-05-16  3:48 Bjorn Andersson
  2021-05-17  9:09 ` Heikki Krogerus
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Andersson @ 2021-05-16  3:48 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman, Andy Shevchenko
  Cc: linux-usb, linux-kernel

Some of the boilerplate code was copy pasted from the typec_switch and
retained the use of the switch's container_of macros. The two structs
are identical in this regard, so this change doesn't cause a functional
change today, but could possibly cause future issues.

Fixes: 3370db35193b ("usb: typec: Registering real device entries for the muxes")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/usb/typec/mux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index 8514bec7e1b8..e4467c4c3742 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -45,7 +45,7 @@ static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
 	dev = class_find_device(&typec_mux_class, NULL, fwnode,
 				switch_fwnode_match);
 
-	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
+	return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER);
 }
 
 /**
@@ -87,7 +87,7 @@ EXPORT_SYMBOL_GPL(typec_switch_put);
 
 static void typec_switch_release(struct device *dev)
 {
-	kfree(to_typec_switch(dev));
+	kfree(to_typec_mux(dev));
 }
 
 static const struct device_type typec_switch_dev_type = {
@@ -239,7 +239,7 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
 	dev = class_find_device(&typec_mux_class, NULL, fwnode,
 				mux_fwnode_match);
 
-	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
+	return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER);
 }
 
 /**
-- 
2.29.2


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

* Re: [PATCH] usb: typec: mux: Fix copy-paste of the container_of
  2021-05-16  3:48 [PATCH] usb: typec: mux: Fix copy-paste of the container_of Bjorn Andersson
@ 2021-05-17  9:09 ` Heikki Krogerus
  2021-05-17 15:04   ` Bjorn Andersson
  0 siblings, 1 reply; 3+ messages in thread
From: Heikki Krogerus @ 2021-05-17  9:09 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Greg Kroah-Hartman, Andy Shevchenko, linux-usb, linux-kernel

Hi,

On Sat, May 15, 2021 at 08:48:33PM -0700, Bjorn Andersson wrote:
> Some of the boilerplate code was copy pasted from the typec_switch and
> retained the use of the switch's container_of macros. The two structs
> are identical in this regard, so this change doesn't cause a functional
> change today, but could possibly cause future issues.
> 
> Fixes: 3370db35193b ("usb: typec: Registering real device entries for the muxes")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/usb/typec/mux.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
> index 8514bec7e1b8..e4467c4c3742 100644
> --- a/drivers/usb/typec/mux.c
> +++ b/drivers/usb/typec/mux.c
> @@ -45,7 +45,7 @@ static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
>  	dev = class_find_device(&typec_mux_class, NULL, fwnode,
>  				switch_fwnode_match);
>  
> -	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
> +	return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER);

That does not look correct to me?

>  }
>  
>  /**
> @@ -87,7 +87,7 @@ EXPORT_SYMBOL_GPL(typec_switch_put);
>  
>  static void typec_switch_release(struct device *dev)
>  {
> -	kfree(to_typec_switch(dev));
> +	kfree(to_typec_mux(dev));

Ditto.

>  }
>  
>  static const struct device_type typec_switch_dev_type = {
> @@ -239,7 +239,7 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
>  	dev = class_find_device(&typec_mux_class, NULL, fwnode,
>  				mux_fwnode_match);
>  
> -	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
> +	return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER);

That looks correct.

Either I'm missing something, or only the last change is needed.

thanks,

-- 
heikki

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

* Re: [PATCH] usb: typec: mux: Fix copy-paste of the container_of
  2021-05-17  9:09 ` Heikki Krogerus
@ 2021-05-17 15:04   ` Bjorn Andersson
  0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2021-05-17 15:04 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Greg Kroah-Hartman, Andy Shevchenko, linux-usb, linux-kernel

On Mon 17 May 04:09 CDT 2021, Heikki Krogerus wrote:

> Hi,
> 
> On Sat, May 15, 2021 at 08:48:33PM -0700, Bjorn Andersson wrote:
> > Some of the boilerplate code was copy pasted from the typec_switch and
> > retained the use of the switch's container_of macros. The two structs
> > are identical in this regard, so this change doesn't cause a functional
> > change today, but could possibly cause future issues.
> > 
> > Fixes: 3370db35193b ("usb: typec: Registering real device entries for the muxes")
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > ---
> >  drivers/usb/typec/mux.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
> > index 8514bec7e1b8..e4467c4c3742 100644
> > --- a/drivers/usb/typec/mux.c
> > +++ b/drivers/usb/typec/mux.c
> > @@ -45,7 +45,7 @@ static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
> >  	dev = class_find_device(&typec_mux_class, NULL, fwnode,
> >  				switch_fwnode_match);
> >  
> > -	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
> > +	return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER);
> 
> That does not look correct to me?
> 

No it doesn't, you're right. I spotted the last one and it being trivial
I obviously didn't pay enough attention when just "fixing" the other two
instances of "the same".

> >  }
> >  
> >  /**
> > @@ -87,7 +87,7 @@ EXPORT_SYMBOL_GPL(typec_switch_put);
> >  
> >  static void typec_switch_release(struct device *dev)
> >  {
> > -	kfree(to_typec_switch(dev));
> > +	kfree(to_typec_mux(dev));
> 
> Ditto.
> 
> >  }
> >  
> >  static const struct device_type typec_switch_dev_type = {
> > @@ -239,7 +239,7 @@ static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
> >  	dev = class_find_device(&typec_mux_class, NULL, fwnode,
> >  				mux_fwnode_match);
> >  
> > -	return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
> > +	return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER);
> 
> That looks correct.
> 
> Either I'm missing something, or only the last change is needed.
> 

Sorry about that, I'll fix it up and repost the patch.

Regards,
Bjorn

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

end of thread, other threads:[~2021-05-17 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16  3:48 [PATCH] usb: typec: mux: Fix copy-paste of the container_of Bjorn Andersson
2021-05-17  9:09 ` Heikki Krogerus
2021-05-17 15:04   ` Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.