diff mbox series

[v6,4/6] usb: typec: mux: use fwnode's dev for driver module user count

Message ID 1606140096-1382-4-git-send-email-jun.li@nxp.com
State New
Headers show
Series [v6,1/6] dt-bindings: usb: add documentation for typec switch simple driver | expand

Commit Message

Jun Li Nov. 23, 2020, 2:01 p.m. UTC
As the typec switch provider driver's dev may not the parent of
typec_switch dev(may be the switch's parent's parent), but we use
the typec switch provider driver dev's fwnode anyway, so change to
use fwnode's dev to get driver's user count.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
New patch for v6.

 drivers/usb/typec/mux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Heikki Krogerus Nov. 26, 2020, 11:58 a.m. UTC | #1
On Mon, Nov 23, 2020 at 10:01:34PM +0800, Li Jun wrote:
> As the typec switch provider driver's dev may not the parent of

> typec_switch dev(may be the switch's parent's parent), but we use

> the typec switch provider driver dev's fwnode anyway, so change to

> use fwnode's dev to get driver's user count.

> 

> Signed-off-by: Li Jun <jun.li@nxp.com>


Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>


> ---

> New patch for v6.

> 

>  drivers/usb/typec/mux.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c

> index 3da17d1..0219aa4 100644

> --- a/drivers/usb/typec/mux.c

> +++ b/drivers/usb/typec/mux.c

> @@ -65,7 +65,7 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)

>  	sw = fwnode_connection_find_match(fwnode, "typec-orientation-switch",

>  					  NULL, typec_switch_match);

>  	if (!IS_ERR_OR_NULL(sw))

> -		WARN_ON(!try_module_get(sw->dev.parent->driver->owner));

> +		WARN_ON(!try_module_get(dev_fwnode(&sw->dev)->dev->driver->owner));

>  

>  	return sw;

>  }

> @@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(fwnode_typec_switch_get);

>  void typec_switch_put(struct typec_switch *sw)

>  {

>  	if (!IS_ERR_OR_NULL(sw)) {

> -		module_put(sw->dev.parent->driver->owner);

> +		module_put(dev_fwnode(&sw->dev)->dev->driver->owner);

>  		put_device(&sw->dev);

>  	}

>  }

> -- 

> 2.7.4


thanks,

-- 
heikki
diff mbox series

Patch

diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index 3da17d1..0219aa4 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -65,7 +65,7 @@  struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
 	sw = fwnode_connection_find_match(fwnode, "typec-orientation-switch",
 					  NULL, typec_switch_match);
 	if (!IS_ERR_OR_NULL(sw))
-		WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
+		WARN_ON(!try_module_get(dev_fwnode(&sw->dev)->dev->driver->owner));
 
 	return sw;
 }
@@ -80,7 +80,7 @@  EXPORT_SYMBOL_GPL(fwnode_typec_switch_get);
 void typec_switch_put(struct typec_switch *sw)
 {
 	if (!IS_ERR_OR_NULL(sw)) {
-		module_put(sw->dev.parent->driver->owner);
+		module_put(dev_fwnode(&sw->dev)->dev->driver->owner);
 		put_device(&sw->dev);
 	}
 }