Message ID | 1621408490-23811-3-git-send-email-jun.li@nxp.com |
---|---|
State | New |
Headers | show |
Series | typec switch via mux controller | expand |
On Wed, May 19, 2021 at 03:14:48PM +0800, Li Jun wrote: > Asssign typec cap fwnode's of_node to typec port, then we can use > typec port device to get properties from its OF. > > Signed-off-by: Li Jun <jun.li@nxp.com> > --- > drivers/usb/typec/class.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index b9429c9f65f6..a29bf2c32233 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -8,6 +8,7 @@ > > #include <linux/module.h> > #include <linux/mutex.h> > +#include <linux/of.h> > #include <linux/property.h> > #include <linux/slab.h> > #include <linux/usb/pd_vdo.h> > @@ -2049,6 +2050,7 @@ struct typec_port *typec_register_port(struct device *parent, > port->dev.class = &typec_class; > port->dev.parent = parent; > port->dev.fwnode = cap->fwnode; > + port->dev.of_node = to_of_node(cap->fwnode); > port->dev.type = &typec_port_dev_type; > dev_set_name(&port->dev, "port%d", id); > dev_set_drvdata(&port->dev, cap->driver_data); No. I think this is what you want to do: diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 1fb22388e7e07..e30e8504c1d6d 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -424,7 +424,7 @@ static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) */ struct mux_control *mux_control_get(struct device *dev, const char *mux_name) { - struct device_node *np = dev->of_node; + struct device_node *np = to_of_node(dev_fwnode(dev)); struct of_phandle_args args; struct mux_chip *mux_chip; unsigned int controller; thanks, -- heikki
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index b9429c9f65f6..a29bf2c32233 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -8,6 +8,7 @@ #include <linux/module.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/property.h> #include <linux/slab.h> #include <linux/usb/pd_vdo.h> @@ -2049,6 +2050,7 @@ struct typec_port *typec_register_port(struct device *parent, port->dev.class = &typec_class; port->dev.parent = parent; port->dev.fwnode = cap->fwnode; + port->dev.of_node = to_of_node(cap->fwnode); port->dev.type = &typec_port_dev_type; dev_set_name(&port->dev, "port%d", id); dev_set_drvdata(&port->dev, cap->driver_data);
Asssign typec cap fwnode's of_node to typec port, then we can use typec port device to get properties from its OF. Signed-off-by: Li Jun <jun.li@nxp.com> --- drivers/usb/typec/class.c | 2 ++ 1 file changed, 2 insertions(+)