2021-01-19 10:50:18

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 6/7] platform: x86: Add intel_skl_int3472 driver

On Tue, Jan 19, 2021 at 12:11:40AM +0000, Daniel Scally wrote:
> On 18/01/2021 21:19, Daniel Scally wrote:

> I'm more and more confident that this will work, but it has some
> knock-on effects:
>
> The both clk and regulator gpio driver expects to be able to fetch the
> GPIO using devm_gpiod_get(&pdev->dev, "enable", ...). That won't work of
> course, so we need to add another GPIO lookup table so those drivers can
> see the GPIOs. For that, we need to know what dev_name(&pdev->dev) will
> be so we can set the .dev_id member of a gpiod_lookup_table to that
> value, but that isn't set until _after_ the pdev is registered (because
> it has to figure out the id, we can't manually set the IDs because there
> could be more than one instance of int3472-discrete bound to multiple
> PMIC devices, and we don't know which id the current one should have).
> Finally, we can't wait until the device is registered because it
> immediately probes, can't find the GPIO and then fails probe.
>
> It's similar problem that causes us to need the i2c-acpi name format
> macros, but complicated by the dynamic ID part of dev_name(&pdev->dev)
>
> Solving it is a bit of a sticky one; perhaps something like moving the
> dev_set_name() part of platform_device_add() [1] to its own function,
> that's called in both platform_device_alloc() and
> platform_device_register(). That way it would be available before the
> device itself was registered, meaning we could create the lookup table
> before it probes the driver.

See my previous reply. TL;DR: you have to modify clk-gpio.c to export couple of
methods to be able to use it as a library.

> (also, Laurent, if we did it this way we wouldn't be able to also handle
> the led-indicator GPIO here without some fairly major rework)

LED indicators are done as LED class devices (see plenty of examples in PDx86
drivers: drivers/platform/x86/)

--
With Best Regards,
Andy Shevchenko



2021-01-19 16:42:46

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v2 6/7] platform: x86: Add intel_skl_int3472 driver

Hi Andy,

On Tue, Jan 19, 2021 at 11:33:58AM +0200, Andy Shevchenko wrote:
> On Tue, Jan 19, 2021 at 12:11:40AM +0000, Daniel Scally wrote:
> > On 18/01/2021 21:19, Daniel Scally wrote:
> >
> > I'm more and more confident that this will work, but it has some
> > knock-on effects:
> >
> > The both clk and regulator gpio driver expects to be able to fetch the
> > GPIO using devm_gpiod_get(&pdev->dev, "enable", ...). That won't work of
> > course, so we need to add another GPIO lookup table so those drivers can
> > see the GPIOs. For that, we need to know what dev_name(&pdev->dev) will
> > be so we can set the .dev_id member of a gpiod_lookup_table to that
> > value, but that isn't set until _after_ the pdev is registered (because
> > it has to figure out the id, we can't manually set the IDs because there
> > could be more than one instance of int3472-discrete bound to multiple
> > PMIC devices, and we don't know which id the current one should have).
> > Finally, we can't wait until the device is registered because it
> > immediately probes, can't find the GPIO and then fails probe.
> >
> > It's similar problem that causes us to need the i2c-acpi name format
> > macros, but complicated by the dynamic ID part of dev_name(&pdev->dev)
> >
> > Solving it is a bit of a sticky one; perhaps something like moving the
> > dev_set_name() part of platform_device_add() [1] to its own function,
> > that's called in both platform_device_alloc() and
> > platform_device_register(). That way it would be available before the
> > device itself was registered, meaning we could create the lookup table
> > before it probes the driver.
>
> See my previous reply. TL;DR: you have to modify clk-gpio.c to export couple of
> methods to be able to use it as a library.

That seems really overkill given the very simple implementation of the
clock provided here.

> > (also, Laurent, if we did it this way we wouldn't be able to also handle
> > the led-indicator GPIO here without some fairly major rework)
>
> LED indicators are done as LED class devices (see plenty of examples in PDx86
> drivers: drivers/platform/x86/)

How do you expose the link between the sensor and its indicator LED to
userspace ? Isn't it better to handle it in the kernel to avoid rogue
userspace turning the camera on without notifying the user ?

--
Regards,

Laurent Pinchart

2021-01-19 22:37:07

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 6/7] platform: x86: Add intel_skl_int3472 driver

On Tue, Jan 19, 2021 at 06:36:31PM +0200, Laurent Pinchart wrote:
> On Tue, Jan 19, 2021 at 11:33:58AM +0200, Andy Shevchenko wrote:
> > On Tue, Jan 19, 2021 at 12:11:40AM +0000, Daniel Scally wrote:
> > > On 18/01/2021 21:19, Daniel Scally wrote:

...

> > See my previous reply. TL;DR: you have to modify clk-gpio.c to export couple of
> > methods to be able to use it as a library.
>
> That seems really overkill given the very simple implementation of the
> clock provided here.

Less code in the end is called an overkill? Hmm...
I think since we in Linux it's better to utilize what it provides. Do you want
me to prepare a patch to show that there is no overkill at all?

...

> > > (also, Laurent, if we did it this way we wouldn't be able to also handle
> > > the led-indicator GPIO here without some fairly major rework)
> >
> > LED indicators are done as LED class devices (see plenty of examples in PDx86
> > drivers: drivers/platform/x86/)
>
> How do you expose the link between the sensor and its indicator LED to
> userspace ? Isn't it better to handle it in the kernel to avoid rogue
> userspace turning the camera on without notifying the user ?

I didn't get this. It's completely a LED handling driver business. We may
expose it to user space or not, but it's orthogonal to the usage of LED class
IIUC. Am I mistaken here?

--
With Best Regards,
Andy Shevchenko