All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-16 16:00 ` Opensource [Adam Thomson]
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Thomson @ 2018-05-16 16:00 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, support.opensource

For supply registration, provide of_node pointer of the port device,
via the power_supply_config structure, to allow other psy drivers
to add us as a supplier using the 'power-supplies' DT property.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 drivers/usb/typec/tcpm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 72996cc..e7c0b95 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
 	char *psy_name;
 
 	psy_cfg.drv_data = port;
+	psy_cfg.of_node = port->dev->of_node;
 	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
 	if (!psy_name)
 		return -ENOMEM;
-- 
1.9.1


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

* typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-16 16:00 ` Opensource [Adam Thomson]
  0 siblings, 0 replies; 12+ messages in thread
From: Opensource [Adam Thomson] @ 2018-05-16 16:00 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, support.opensource

For supply registration, provide of_node pointer of the port device,
via the power_supply_config structure, to allow other psy drivers
to add us as a supplier using the 'power-supplies' DT property.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 drivers/usb/typec/tcpm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 72996cc..e7c0b95 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
 	char *psy_name;
 
 	psy_cfg.drv_data = port;
+	psy_cfg.of_node = port->dev->of_node;
 	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
 	if (!psy_name)
 		return -ENOMEM;

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

* Re: [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 13:20   ` Heikki Krogerus
  0 siblings, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2018-05-21 13:20 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	support.opensource

Hi Adam,

On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> For supply registration, provide of_node pointer of the port device,
> via the power_supply_config structure, to allow other psy drivers
> to add us as a supplier using the 'power-supplies' DT property.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> ---
>  drivers/usb/typec/tcpm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 72996cc..e7c0b95 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
>  	char *psy_name;
>  
>  	psy_cfg.drv_data = port;
> +	psy_cfg.of_node = port->dev->of_node;
>  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
>  	if (!psy_name)
>  		return -ENOMEM;

Would it be possible to use fwnode here instead? It would mean that
you add a member for it to the struct power_supply_config, and handle
it separately in power_supply_core.c. You could just convert it to
of_node there for now.

That is just a request, I'm fine with this, but it would prepare this
driver for all types of platforms, so less patching would be needed
once we add ACPI support to the power_supply_core.c.


Thanks,

-- 
heikki

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

* typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 13:20   ` Heikki Krogerus
  0 siblings, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2018-05-21 13:20 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	support.opensource

Hi Adam,

On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> For supply registration, provide of_node pointer of the port device,
> via the power_supply_config structure, to allow other psy drivers
> to add us as a supplier using the 'power-supplies' DT property.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> ---
>  drivers/usb/typec/tcpm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 72996cc..e7c0b95 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
>  	char *psy_name;
>  
>  	psy_cfg.drv_data = port;
> +	psy_cfg.of_node = port->dev->of_node;
>  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
>  	if (!psy_name)
>  		return -ENOMEM;

Would it be possible to use fwnode here instead? It would mean that
you add a member for it to the struct power_supply_config, and handle
it separately in power_supply_core.c. You could just convert it to
of_node there for now.

That is just a request, I'm fine with this, but it would prepare this
driver for all types of platforms, so less patching would be needed
once we add ACPI support to the power_supply_core.c.


Thanks,

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

* RE: [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 13:58     ` Opensource [Adam Thomson]
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Thomson @ 2018-05-21 13:58 UTC (permalink / raw)
  To: Heikki Krogerus, Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

Hi Heikki,

On 21 May 2018 14:20, Heikki Krogerus wrote:

> On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > For supply registration, provide of_node pointer of the port device,
> > via the power_supply_config structure, to allow other psy drivers
> > to add us as a supplier using the 'power-supplies' DT property.
> >
> > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > ---
> >  drivers/usb/typec/tcpm.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > index 72996cc..e7c0b95 100644
> > --- a/drivers/usb/typec/tcpm.c
> > +++ b/drivers/usb/typec/tcpm.c
> > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> *port)
> >  	char *psy_name;
> >
> >  	psy_cfg.drv_data = port;
> > +	psy_cfg.of_node = port->dev->of_node;
> >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> >  	if (!psy_name)
> >  		return -ENOMEM;
> 
> Would it be possible to use fwnode here instead? It would mean that
> you add a member for it to the struct power_supply_config, and handle
> it separately in power_supply_core.c. You could just convert it to
> of_node there for now.
> 
> That is just a request, I'm fine with this, but it would prepare this
> driver for all types of platforms, so less patching would be needed
> once we add ACPI support to the power_supply_core.c.

Would the following commit from Hans, already present in power_supply_core.c,
not fit the bill:

[58a36bb06891ee779074db6ef84e98347c634d38]
power: supply: core: Add support for supplied-from device-property

Or was that just meant as a stop gap for something more?

I have no problems adding something further, but I don't have a means to verify
anything ACPI based, beyond a simple build test, so would ideally want someone
to verify that path through the code.

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

* typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 13:58     ` Opensource [Adam Thomson]
  0 siblings, 0 replies; 12+ messages in thread
From: Opensource [Adam Thomson] @ 2018-05-21 13:58 UTC (permalink / raw)
  To: Heikki Krogerus, Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

Hi Heikki,

On 21 May 2018 14:20, Heikki Krogerus wrote:

> On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > For supply registration, provide of_node pointer of the port device,
> > via the power_supply_config structure, to allow other psy drivers
> > to add us as a supplier using the 'power-supplies' DT property.
> >
> > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > ---
> >  drivers/usb/typec/tcpm.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > index 72996cc..e7c0b95 100644
> > --- a/drivers/usb/typec/tcpm.c
> > +++ b/drivers/usb/typec/tcpm.c
> > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> *port)
> >  	char *psy_name;
> >
> >  	psy_cfg.drv_data = port;
> > +	psy_cfg.of_node = port->dev->of_node;
> >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> >  	if (!psy_name)
> >  		return -ENOMEM;
> 
> Would it be possible to use fwnode here instead? It would mean that
> you add a member for it to the struct power_supply_config, and handle
> it separately in power_supply_core.c. You could just convert it to
> of_node there for now.
> 
> That is just a request, I'm fine with this, but it would prepare this
> driver for all types of platforms, so less patching would be needed
> once we add ACPI support to the power_supply_core.c.

Would the following commit from Hans, already present in power_supply_core.c,
not fit the bill:

[58a36bb06891ee779074db6ef84e98347c634d38]
power: supply: core: Add support for supplied-from device-property

Or was that just meant as a stop gap for something more?

I have no problems adding something further, but I don't have a means to verify
anything ACPI based, beyond a simple build test, so would ideally want someone
to verify that path through the code.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 14:55       ` Heikki Krogerus
  0 siblings, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2018-05-21 14:55 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

On Mon, May 21, 2018 at 01:58:16PM +0000, Adam Thomson wrote:
> Hi Heikki,
> 
> On 21 May 2018 14:20, Heikki Krogerus wrote:
> 
> > On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > > For supply registration, provide of_node pointer of the port device,
> > > via the power_supply_config structure, to allow other psy drivers
> > > to add us as a supplier using the 'power-supplies' DT property.
> > >
> > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > ---
> > >  drivers/usb/typec/tcpm.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > index 72996cc..e7c0b95 100644
> > > --- a/drivers/usb/typec/tcpm.c
> > > +++ b/drivers/usb/typec/tcpm.c
> > > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> > *port)
> > >  	char *psy_name;
> > >
> > >  	psy_cfg.drv_data = port;
> > > +	psy_cfg.of_node = port->dev->of_node;
> > >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> > >  	if (!psy_name)
> > >  		return -ENOMEM;
> > 
> > Would it be possible to use fwnode here instead? It would mean that
> > you add a member for it to the struct power_supply_config, and handle
> > it separately in power_supply_core.c. You could just convert it to
> > of_node there for now.
> > 
> > That is just a request, I'm fine with this, but it would prepare this
> > driver for all types of platforms, so less patching would be needed
> > once we add ACPI support to the power_supply_core.c.
> 
> Would the following commit from Hans, already present in power_supply_core.c,
> not fit the bill:
> 
> [58a36bb06891ee779074db6ef84e98347c634d38]
> power: supply: core: Add support for supplied-from device-property
> 
> Or was that just meant as a stop gap for something more?

I think the main idea with that patch was that it allows us to take
advantage of build-in device properties, but I think we could actually
improve also it if we had the fwnode handle assigned to the psy. We
would not have to assume the parent has those device properties then.

But ACPI actually defines a specific object called _PCL (power
consumer list) for power source objects that we should one day check
in power_supply_core.c. That's what I meant by ACPI support.

> I have no problems adding something further, but I don't have a means to verify
> anything ACPI based, beyond a simple build test, so would ideally want someone
> to verify that path through the code.

This is not really about ACPI. By using fwnode handle instead of
of_node, we would continue to keep tcpm.c agnostic about the type of
hw description.

So I don't expect any ACPI support to be added to the
power_supply_code.c at this point. You can use to_of_node(cfg->fwnode)
in __power_supply_register() for now:

        psy->of_node = cfg->of_node;
        if (cfg->fwnode)
                psy->of_node = to_of_node(cfg->fwnode);


Thanks,

-- 
heikki

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

* typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 14:55       ` Heikki Krogerus
  0 siblings, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2018-05-21 14:55 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

On Mon, May 21, 2018 at 01:58:16PM +0000, Adam Thomson wrote:
> Hi Heikki,
> 
> On 21 May 2018 14:20, Heikki Krogerus wrote:
> 
> > On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > > For supply registration, provide of_node pointer of the port device,
> > > via the power_supply_config structure, to allow other psy drivers
> > > to add us as a supplier using the 'power-supplies' DT property.
> > >
> > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > ---
> > >  drivers/usb/typec/tcpm.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > index 72996cc..e7c0b95 100644
> > > --- a/drivers/usb/typec/tcpm.c
> > > +++ b/drivers/usb/typec/tcpm.c
> > > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> > *port)
> > >  	char *psy_name;
> > >
> > >  	psy_cfg.drv_data = port;
> > > +	psy_cfg.of_node = port->dev->of_node;
> > >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> > >  	if (!psy_name)
> > >  		return -ENOMEM;
> > 
> > Would it be possible to use fwnode here instead? It would mean that
> > you add a member for it to the struct power_supply_config, and handle
> > it separately in power_supply_core.c. You could just convert it to
> > of_node there for now.
> > 
> > That is just a request, I'm fine with this, but it would prepare this
> > driver for all types of platforms, so less patching would be needed
> > once we add ACPI support to the power_supply_core.c.
> 
> Would the following commit from Hans, already present in power_supply_core.c,
> not fit the bill:
> 
> [58a36bb06891ee779074db6ef84e98347c634d38]
> power: supply: core: Add support for supplied-from device-property
> 
> Or was that just meant as a stop gap for something more?

I think the main idea with that patch was that it allows us to take
advantage of build-in device properties, but I think we could actually
improve also it if we had the fwnode handle assigned to the psy. We
would not have to assume the parent has those device properties then.

But ACPI actually defines a specific object called _PCL (power
consumer list) for power source objects that we should one day check
in power_supply_core.c. That's what I meant by ACPI support.

> I have no problems adding something further, but I don't have a means to verify
> anything ACPI based, beyond a simple build test, so would ideally want someone
> to verify that path through the code.

This is not really about ACPI. By using fwnode handle instead of
of_node, we would continue to keep tcpm.c agnostic about the type of
hw description.

So I don't expect any ACPI support to be added to the
power_supply_code.c at this point. You can use to_of_node(cfg->fwnode)
in __power_supply_register() for now:

        psy->of_node = cfg->of_node;
        if (cfg->fwnode)
                psy->of_node = to_of_node(cfg->fwnode);


Thanks,

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

* RE: [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 15:34         ` Opensource [Adam Thomson]
  0 siblings, 0 replies; 12+ messages in thread
From: Adam Thomson @ 2018-05-21 15:34 UTC (permalink / raw)
  To: Heikki Krogerus, Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

On 21 May 2018 15:56, Heikki Krogerus wrote:

> On Mon, May 21, 2018 at 01:58:16PM +0000, Adam Thomson wrote:
> > Hi Heikki,
> >
> > On 21 May 2018 14:20, Heikki Krogerus wrote:
> >
> > > On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > > > For supply registration, provide of_node pointer of the port device,
> > > > via the power_supply_config structure, to allow other psy drivers
> > > > to add us as a supplier using the 'power-supplies' DT property.
> > > >
> > > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > > ---
> > > >  drivers/usb/typec/tcpm.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > > index 72996cc..e7c0b95 100644
> > > > --- a/drivers/usb/typec/tcpm.c
> > > > +++ b/drivers/usb/typec/tcpm.c
> > > > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> > > *port)
> > > >  	char *psy_name;
> > > >
> > > >  	psy_cfg.drv_data = port;
> > > > +	psy_cfg.of_node = port->dev->of_node;
> > > >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> > > >  	if (!psy_name)
> > > >  		return -ENOMEM;
> > >
> > > Would it be possible to use fwnode here instead? It would mean that
> > > you add a member for it to the struct power_supply_config, and handle
> > > it separately in power_supply_core.c. You could just convert it to
> > > of_node there for now.
> > >
> > > That is just a request, I'm fine with this, but it would prepare this
> > > driver for all types of platforms, so less patching would be needed
> > > once we add ACPI support to the power_supply_core.c.
> >
> > Would the following commit from Hans, already present in power_supply_core.c,
> > not fit the bill:
> >
> > [58a36bb06891ee779074db6ef84e98347c634d38]
> > power: supply: core: Add support for supplied-from device-property
> >
> > Or was that just meant as a stop gap for something more?
> 
> I think the main idea with that patch was that it allows us to take
> advantage of build-in device properties, but I think we could actually
> improve also it if we had the fwnode handle assigned to the psy. We
> would not have to assume the parent has those device properties then.
> 
> But ACPI actually defines a specific object called _PCL (power
> consumer list) for power source objects that we should one day check
> in power_supply_core.c. That's what I meant by ACPI support.

Ok, fair enough. Makes sense to me. Thanks for clarifying.

> > I have no problems adding something further, but I don't have a means to verify
> > anything ACPI based, beyond a simple build test, so would ideally want someone
> > to verify that path through the code.
> 
> This is not really about ACPI. By using fwnode handle instead of
> of_node, we would continue to keep tcpm.c agnostic about the type of
> hw description.
> 
> So I don't expect any ACPI support to be added to the
> power_supply_code.c at this point. You can use to_of_node(cfg->fwnode)
> in __power_supply_register() for now:
> 
>         psy->of_node = cfg->of_node;
>         if (cfg->fwnode)
>                 psy->of_node = to_of_node(cfg->fwnode);

OK, no problem. Will take a look and add that in.

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

* typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-21 15:34         ` Opensource [Adam Thomson]
  0 siblings, 0 replies; 12+ messages in thread
From: Opensource [Adam Thomson] @ 2018-05-21 15:34 UTC (permalink / raw)
  To: Heikki Krogerus, Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

On 21 May 2018 15:56, Heikki Krogerus wrote:

> On Mon, May 21, 2018 at 01:58:16PM +0000, Adam Thomson wrote:
> > Hi Heikki,
> >
> > On 21 May 2018 14:20, Heikki Krogerus wrote:
> >
> > > On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > > > For supply registration, provide of_node pointer of the port device,
> > > > via the power_supply_config structure, to allow other psy drivers
> > > > to add us as a supplier using the 'power-supplies' DT property.
> > > >
> > > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > > ---
> > > >  drivers/usb/typec/tcpm.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > > index 72996cc..e7c0b95 100644
> > > > --- a/drivers/usb/typec/tcpm.c
> > > > +++ b/drivers/usb/typec/tcpm.c
> > > > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> > > *port)
> > > >  	char *psy_name;
> > > >
> > > >  	psy_cfg.drv_data = port;
> > > > +	psy_cfg.of_node = port->dev->of_node;
> > > >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> > > >  	if (!psy_name)
> > > >  		return -ENOMEM;
> > >
> > > Would it be possible to use fwnode here instead? It would mean that
> > > you add a member for it to the struct power_supply_config, and handle
> > > it separately in power_supply_core.c. You could just convert it to
> > > of_node there for now.
> > >
> > > That is just a request, I'm fine with this, but it would prepare this
> > > driver for all types of platforms, so less patching would be needed
> > > once we add ACPI support to the power_supply_core.c.
> >
> > Would the following commit from Hans, already present in power_supply_core.c,
> > not fit the bill:
> >
> > [58a36bb06891ee779074db6ef84e98347c634d38]
> > power: supply: core: Add support for supplied-from device-property
> >
> > Or was that just meant as a stop gap for something more?
> 
> I think the main idea with that patch was that it allows us to take
> advantage of build-in device properties, but I think we could actually
> improve also it if we had the fwnode handle assigned to the psy. We
> would not have to assume the parent has those device properties then.
> 
> But ACPI actually defines a specific object called _PCL (power
> consumer list) for power source objects that we should one day check
> in power_supply_core.c. That's what I meant by ACPI support.

Ok, fair enough. Makes sense to me. Thanks for clarifying.

> > I have no problems adding something further, but I don't have a means to verify
> > anything ACPI based, beyond a simple build test, so would ideally want someone
> > to verify that path through the code.
> 
> This is not really about ACPI. By using fwnode handle instead of
> of_node, we would continue to keep tcpm.c agnostic about the type of
> hw description.
> 
> So I don't expect any ACPI support to be added to the
> power_supply_code.c at this point. You can use to_of_node(cfg->fwnode)
> in __power_supply_register() for now:
> 
>         psy->of_node = cfg->of_node;
>         if (cfg->fwnode)
>                 psy->of_node = to_of_node(cfg->fwnode);

OK, no problem. Will take a look and add that in.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-22  9:47           ` Heikki Krogerus
  0 siblings, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2018-05-22  9:47 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

On Mon, May 21, 2018 at 03:34:53PM +0000, Adam Thomson wrote:
> On 21 May 2018 15:56, Heikki Krogerus wrote:
> 
> > On Mon, May 21, 2018 at 01:58:16PM +0000, Adam Thomson wrote:
> > > Hi Heikki,
> > >
> > > On 21 May 2018 14:20, Heikki Krogerus wrote:
> > >
> > > > On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > > > > For supply registration, provide of_node pointer of the port device,
> > > > > via the power_supply_config structure, to allow other psy drivers
> > > > > to add us as a supplier using the 'power-supplies' DT property.
> > > > >
> > > > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > > > ---
> > > > >  drivers/usb/typec/tcpm.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > > > index 72996cc..e7c0b95 100644
> > > > > --- a/drivers/usb/typec/tcpm.c
> > > > > +++ b/drivers/usb/typec/tcpm.c
> > > > > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> > > > *port)
> > > > >  	char *psy_name;
> > > > >
> > > > >  	psy_cfg.drv_data = port;
> > > > > +	psy_cfg.of_node = port->dev->of_node;
> > > > >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> > > > >  	if (!psy_name)
> > > > >  		return -ENOMEM;
> > > >
> > > > Would it be possible to use fwnode here instead? It would mean that
> > > > you add a member for it to the struct power_supply_config, and handle
> > > > it separately in power_supply_core.c. You could just convert it to
> > > > of_node there for now.
> > > >
> > > > That is just a request, I'm fine with this, but it would prepare this
> > > > driver for all types of platforms, so less patching would be needed
> > > > once we add ACPI support to the power_supply_core.c.
> > >
> > > Would the following commit from Hans, already present in power_supply_core.c,
> > > not fit the bill:
> > >
> > > [58a36bb06891ee779074db6ef84e98347c634d38]
> > > power: supply: core: Add support for supplied-from device-property
> > >
> > > Or was that just meant as a stop gap for something more?
> > 
> > I think the main idea with that patch was that it allows us to take
> > advantage of build-in device properties, but I think we could actually
> > improve also it if we had the fwnode handle assigned to the psy. We
> > would not have to assume the parent has those device properties then.
> > 
> > But ACPI actually defines a specific object called _PCL (power
> > consumer list) for power source objects that we should one day check
> > in power_supply_core.c. That's what I meant by ACPI support.
> 
> Ok, fair enough. Makes sense to me. Thanks for clarifying.
> 
> > > I have no problems adding something further, but I don't have a means to verify
> > > anything ACPI based, beyond a simple build test, so would ideally want someone
> > > to verify that path through the code.
> > 
> > This is not really about ACPI. By using fwnode handle instead of
> > of_node, we would continue to keep tcpm.c agnostic about the type of
> > hw description.
> > 
> > So I don't expect any ACPI support to be added to the
> > power_supply_code.c at this point. You can use to_of_node(cfg->fwnode)
> > in __power_supply_register() for now:
> > 
> >         psy->of_node = cfg->of_node;
> >         if (cfg->fwnode)
> >                 psy->of_node = to_of_node(cfg->fwnode);
> 
> OK, no problem. Will take a look and add that in.

Thanks Adam!

-- 
heikki

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

* typec: tcpm: Provide of_node pointer as part of psy_cfg
@ 2018-05-22  9:47           ` Heikki Krogerus
  0 siblings, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2018-05-22  9:47 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Support Opensource

On Mon, May 21, 2018 at 03:34:53PM +0000, Adam Thomson wrote:
> On 21 May 2018 15:56, Heikki Krogerus wrote:
> 
> > On Mon, May 21, 2018 at 01:58:16PM +0000, Adam Thomson wrote:
> > > Hi Heikki,
> > >
> > > On 21 May 2018 14:20, Heikki Krogerus wrote:
> > >
> > > > On Wed, May 16, 2018 at 05:00:46PM +0100, Adam Thomson wrote:
> > > > > For supply registration, provide of_node pointer of the port device,
> > > > > via the power_supply_config structure, to allow other psy drivers
> > > > > to add us as a supplier using the 'power-supplies' DT property.
> > > > >
> > > > > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > > > > ---
> > > > >  drivers/usb/typec/tcpm.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > > > > index 72996cc..e7c0b95 100644
> > > > > --- a/drivers/usb/typec/tcpm.c
> > > > > +++ b/drivers/usb/typec/tcpm.c
> > > > > @@ -4500,6 +4500,7 @@ static int devm_tcpm_psy_register(struct tcpm_port
> > > > *port)
> > > > >  	char *psy_name;
> > > > >
> > > > >  	psy_cfg.drv_data = port;
> > > > > +	psy_cfg.of_node = port->dev->of_node;
> > > > >  	psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> > > > >  	if (!psy_name)
> > > > >  		return -ENOMEM;
> > > >
> > > > Would it be possible to use fwnode here instead? It would mean that
> > > > you add a member for it to the struct power_supply_config, and handle
> > > > it separately in power_supply_core.c. You could just convert it to
> > > > of_node there for now.
> > > >
> > > > That is just a request, I'm fine with this, but it would prepare this
> > > > driver for all types of platforms, so less patching would be needed
> > > > once we add ACPI support to the power_supply_core.c.
> > >
> > > Would the following commit from Hans, already present in power_supply_core.c,
> > > not fit the bill:
> > >
> > > [58a36bb06891ee779074db6ef84e98347c634d38]
> > > power: supply: core: Add support for supplied-from device-property
> > >
> > > Or was that just meant as a stop gap for something more?
> > 
> > I think the main idea with that patch was that it allows us to take
> > advantage of build-in device properties, but I think we could actually
> > improve also it if we had the fwnode handle assigned to the psy. We
> > would not have to assume the parent has those device properties then.
> > 
> > But ACPI actually defines a specific object called _PCL (power
> > consumer list) for power source objects that we should one day check
> > in power_supply_core.c. That's what I meant by ACPI support.
> 
> Ok, fair enough. Makes sense to me. Thanks for clarifying.
> 
> > > I have no problems adding something further, but I don't have a means to verify
> > > anything ACPI based, beyond a simple build test, so would ideally want someone
> > > to verify that path through the code.
> > 
> > This is not really about ACPI. By using fwnode handle instead of
> > of_node, we would continue to keep tcpm.c agnostic about the type of
> > hw description.
> > 
> > So I don't expect any ACPI support to be added to the
> > power_supply_code.c at this point. You can use to_of_node(cfg->fwnode)
> > in __power_supply_register() for now:
> > 
> >         psy->of_node = cfg->of_node;
> >         if (cfg->fwnode)
> >                 psy->of_node = to_of_node(cfg->fwnode);
> 
> OK, no problem. Will take a look and add that in.

Thanks Adam!

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

end of thread, other threads:[~2018-05-22  9:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16 16:00 [PATCH] typec: tcpm: Provide of_node pointer as part of psy_cfg Adam Thomson
2018-05-16 16:00 ` Opensource [Adam Thomson]
2018-05-21 13:20 ` [PATCH] " Heikki Krogerus
2018-05-21 13:20   ` Heikki Krogerus
2018-05-21 13:58   ` [PATCH] " Adam Thomson
2018-05-21 13:58     ` Opensource [Adam Thomson]
2018-05-21 14:55     ` [PATCH] " Heikki Krogerus
2018-05-21 14:55       ` Heikki Krogerus
2018-05-21 15:34       ` [PATCH] " Adam Thomson
2018-05-21 15:34         ` Opensource [Adam Thomson]
2018-05-22  9:47         ` [PATCH] " Heikki Krogerus
2018-05-22  9:47           ` Heikki Krogerus

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.