linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niyas Sait <niyas.sait@linaro.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-gpio@vger.kernel.org, mika.westerberg@linux.intel.com,
	rafael@kernel.org, linus.walleij@linaro.org,
	fugang.duan@linaro.org
Subject: Re: [PATCH v3 1/2] pinctrl: add support for ACPI pin function and config resources
Date: Thu, 1 Dec 2022 09:27:07 +0000	[thread overview]
Message-ID: <a033178f-89f8-1843-ee02-321da8c2ca90@linaro.org> (raw)
In-Reply-To: <Y4fnoOKngSLW7dfb@smile.fi.intel.com>

 >>>> +++ b/Documentation/driver-api/pin-control-acpi.rst
 >>>
 >>> We have Documentation/firmware-guide/acpi/, but I'm not sure
 >>> which one suits better for this.
 >>
 >> I started with firmware-guide but then moved to driver-api as I 
wanted to
 >> cover driver related bits as well. Let me know if it is better at
 >> firmware-guide.
 >
 > My point is that I don't know. If it's more about ACPI tables and 
properties
 > there, it's related to firmware-guide, if it's about Linux kernel pin 
control
 > subsystem (programming, etc) it's better to have it under its own 
documentation
 > subfolder.

In that case, we probably should also move existing 
Documentation/driver-api/pin-control.rst to the new subfolder ?

...

>>>> +Pin control devices can add callbacks for following pinctrl_ops to handle ACPI
>>>> +pin resources.
>>>
>>> Why? What use case requires this?
>>> ACPI specification is more stricter in this than DT if I understand correctly
>>> the state of affairs.  So, can't we parse the tables in the same way for all?
>>>
>>> ...
>>>
>>>> +		case PINCTRL_ACPI_PIN_FUNCTION:
>>>
>>>> +		case PINCTRL_ACPI_PIN_CONFIG:
>>>
>>> These are definitely what we do not want to see in the individual drivers.
>>> (I understand that it might be that some OEMs will screw up and we would
>>>    need quirks, but not now)
>>
>> Hm. Please correct me if I am wrong here. My understanding is that we need
>> to do few mapping which only pin controller drivers can do such as ACPI
>> function number to internal functional name or selector.
> 
> Not sure I understand the use case here. The PinFunction() selects the mode for
> the pins in the list. But naming is hardware specific, indeed. And it seems
> there is no name field for the PinFunction().
> 
>> I could define
>> bindings to do those specific mappings rather than providing the current
>> general mapping interface. Would that be better ?
> 
> But that mapping can be provided by the driver at the initialization stage or
> generated automatically.
> 
> For the first we already have pin control APIs. For the second one I don't
> understand why driver should be involved.
> 
Yes ACPI PinFunction() only contains a function number and it is 
hardware specific.

AFAIA,the only way that would work without extra mapping is if drivers 
could populate the pinctrl function tree with the index matching the 
function number from ACPI table. I wasn't sure if that would work in all 
cases. We can start with that if that would be good enough for now. Let 
me know if there are other existing APIs that could help.

>>>> +	status = acpi_get_handle(NULL, pinctrl_acpi, &handle);
>>>> +	if (ACPI_FAILURE(status))
>>>> +		return NULL;
>>>> +
>>>> +	adev = acpi_get_acpi_dev(handle);
>>>> +	if (!adev)
>>>> +		return NULL;
>>>> +
>>>> +	dev_name = acpi_dev_name(adev);
>>>> +	if (!dev_name)
> 
> Resource leak is here (imbalanced reference counting).
> 
>>>> +		return NULL;
>>>> +
>>>> +	return get_pinctrl_dev_from_devname(dev_name);
>>>
>>> Are they all resource leakage-free?
>>
>> I hope so. Do you see something odd ?
> 
> I recommend to read documentation on the above APIs.
> 

Thanks. Got it

-- 
Niyas

  reply	other threads:[~2022-12-01  9:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 16:40 [PATCH v3 0/2] pinctrl: add ACPI support to pin controller Niyas Sait
2022-11-30 16:40 ` [PATCH v3 1/2] pinctrl: add support for ACPI pin function and config resources Niyas Sait
2022-11-30 21:02   ` Andy Shevchenko
2022-11-30 21:33     ` Niyas Sait
2022-11-30 23:30       ` Andy Shevchenko
2022-12-01  9:27         ` Niyas Sait [this message]
2022-12-01 23:04           ` Andy Shevchenko
2022-12-05  7:20             ` Niyas Sait
2022-12-05 12:47               ` Andy Shevchenko
2022-12-20 10:53                 ` Niyas Sait
2023-01-03 16:49                   ` Niyas Sait
2023-01-09 14:09                     ` Andy Shevchenko
2023-01-09 21:33                       ` Niyas Sait
2022-11-30 21:10   ` Andy Shevchenko
2022-11-30 21:36     ` Niyas Sait
2022-11-30 16:40 ` [PATCH v3 2/2] pinctrl: add support for ACPI pin groups Niyas Sait

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a033178f-89f8-1843-ee02-321da8c2ca90@linaro.org \
    --to=niyas.sait@linaro.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=fugang.duan@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).