linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan O'Donovan <dan@emutex.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-acpi@vger.kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Jarkko Nikula <jarkko.nikula@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Mark Brown <broonie@kernel.org>, Len Brown <lenb@kernel.org>,
	linux-i2c@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
Date: Thu, 2 Feb 2017 13:30:21 +0000	[thread overview]
Message-ID: <dc44d52c-12f7-46f2-0594-b487edacd8a1@emutex.com> (raw)
In-Reply-To: <2538517.VnXrn8zi1x@aspire.rjw.lan>

On 02/02/2017 11:41 AM, Rafael J. Wysocki wrote:
> On Friday, January 27, 2017 01:30:13 PM Dan O'Donovan wrote:
>> From: Crestez Dan Leonard <leonard.crestez@intel.com>
>>
>> When using devicetree stuff like i2c_client.name or spi_device.modalias
>> is initialized to the first DT compatible id with the vendor prefix
>> stripped. Since some drivers rely on this try to replicate it when using
>> ACPI with DT ids.
>>
>> Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
>> Signed-off-by: Dan O'Donovan <dan@emutex.com>
>> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>> Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
>> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> First off, the original author of the patch doesn't seem to be reachable under
> the Intel address any more, so his S-o-b is meaningless and it shouldn't be
> there.  In such cases you can send the patch as From: you and give a credit
> to the original author in the changelog.
>
> Second, as Mark said ->
>
>> ---
>>  drivers/acpi/bus.c      | 35 +++++++++++++++++++++++++++++++++++
>>  include/acpi/acpi_bus.h |  1 +
>>  2 files changed, 36 insertions(+)
>>
>> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
>> index 95855cb..8b9657f 100644
>> --- a/drivers/acpi/bus.c
>> +++ b/drivers/acpi/bus.c
>> @@ -677,6 +677,41 @@ static bool acpi_of_match_device(struct acpi_device *adev,
>>  	return false;
>>  }
>>  
>> +/**
>> + * acpi_of_modalias - Like of_modalias_node for ACPI with DT ids
>> + * @adev:	ACPI device object to match.
>> + * @outstr:	Pointer to buffer for result
>> + * @outlen:	Length of outstr value
>> + *
>> + * This is a counterpart of of_modalias_node() for struct acpi_device
>> + * objects. If there is a compatible string for @adev, copy it to the
>> + * @outstr location with the vendor prefix stripped.
>> + *
>> + * Returns 0 on success or negative errno on failure.
>> + */
>> +int acpi_of_modalias(struct acpi_device *adev, char *outstr, size_t outlen)
> -> this could be a bool function and you could provide something like
> acpi_set_modalias() doing the entire
>
> if (!acpi_of_modalias(adev, outstr, outlen))
>                strlcpy(outstr, dev_name(&adev->dev), outlen);
>
> thing, so that its users don't have to duplicate this conditional.
>
> And then acpi_of_modalias() could be static and the only thing to export
> would be acpi_set_modalias().
Thanks Mark and Rafael for the latest feedback.  Those suggestions make
sense.  I'll send an updated patch-set soon.
>
>> +{
>> +	const union acpi_object *of_compatible;
>> +	const union acpi_object *obj;
>> +	const char *str, *chr;
>> +
>> +	of_compatible = adev->data.of_compatible;
>> +	if (!of_compatible)
>> +		return -ENODEV;
>> +
>> +	if (of_compatible->type == ACPI_TYPE_PACKAGE)
>> +		obj = of_compatible->package.elements;
>> +	else /* Must be ACPI_TYPE_STRING. */
>> +		obj = of_compatible;
>> +
>> +	str = obj->string.pointer;
>> +	chr = strchr(str, ',');
>> +	strlcpy(outstr, chr ? chr + 1 : str, outlen);
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_of_modalias);
>> +
>>  static bool __acpi_match_device_cls(const struct acpi_device_id *id,
>>  				    struct acpi_hardware_id *hwid)
>>  {
>> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
>> index 4242c31..351b4a4 100644
>> --- a/include/acpi/acpi_bus.h
>> +++ b/include/acpi/acpi_bus.h
>> @@ -522,6 +522,7 @@ void acpi_bus_trim(struct acpi_device *start);
>>  acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
>>  int acpi_match_device_ids(struct acpi_device *device,
>>  			  const struct acpi_device_id *ids);
>> +int acpi_of_modalias(struct acpi_device *adev, char *outstr, size_t outlen);
>>  int acpi_create_dir(struct acpi_device *);
>>  void acpi_remove_dir(struct acpi_device *);
> Thanks,
> Rafael
>
>


  reply	other threads:[~2017-02-02 13:30 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 11:53 [PATCH v2 0/3] Init device ids from ACPI of_compatible Crestez Dan Leonard
2016-07-13 11:53 ` [PATCH v2 3/3] acpi spi: Initialize modalias from of_compatible Crestez Dan Leonard
2016-07-13 12:22   ` Rafael J. Wysocki
2016-07-19  7:08     ` Mika Westerberg
2016-07-19 10:22   ` Mark Brown
2016-07-20 11:21     ` Crestez Dan Leonard
2016-07-20 11:37       ` Mark Brown
     [not found] ` <cover.1468409668.git.leonard.crestez-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-07-13 11:53   ` [PATCH v2 1/3] acpi: Export acpi_of_modalias equiv of of_modalias_node Crestez Dan Leonard
     [not found]     ` <fde8d7c9312a887553feab9877a33f01e5ceda47.1468409668.git.leonard.crestez-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-07-13 12:19       ` Rafael J. Wysocki
2016-07-19  7:14       ` Mika Westerberg
2016-07-13 11:53   ` [PATCH v2 2/3] acpi i2c: Initialize info.type from of_compatible Crestez Dan Leonard
2016-07-13 12:20     ` Rafael J. Wysocki
     [not found]       ` <CAJZ5v0jz-E0RTBWVzO0Vc_jChUSeSseFeewi1UtsjLudoVP7Pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-19  7:07         ` Mika Westerberg
2016-07-13 12:09   ` [PATCH v2 0/3] Init device ids from ACPI of_compatible Rafael J. Wysocki
2016-07-13 14:15 ` Dan O'Donovan
2017-01-23 16:08 ` [PATCH v3 " Dan O'Donovan
2017-01-23 16:08   ` [PATCH v3 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
2017-01-23 17:10     ` Andy Shevchenko
     [not found]   ` <1485187737-22414-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
2017-01-23 16:08     ` [PATCH v3 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node Dan O'Donovan
2017-01-23 16:08     ` [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible Dan O'Donovan
2017-01-23 17:11       ` Andy Shevchenko
2017-01-27 10:35         ` Dan O'Donovan
2017-01-27 13:43           ` Andy Shevchenko
2017-01-30  9:41       ` Rafael J. Wysocki
2017-01-31 20:17         ` Mark Brown
     [not found]           ` <20170131201736.cmiyq2obzrhgdsck-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2017-01-31 21:18             ` Rafael J. Wysocki
2017-01-23 17:13   ` [PATCH v3 0/3] Init device ids from ACPI of_compatible Andy Shevchenko
2017-01-24 15:11   ` Jarkko Nikula
     [not found]     ` <6ff3138c-ac16-d310-28b7-cee0b0e5f11c-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-24 15:19       ` Andy Shevchenko
2017-01-27 13:30   ` [PATCH v4 " Dan O'Donovan
2017-01-27 13:30     ` [PATCH v4 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node Dan O'Donovan
2017-02-02 11:41       ` Rafael J. Wysocki
2017-02-02 13:30         ` Dan O'Donovan [this message]
2017-01-27 13:30     ` [PATCH v4 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
2017-01-28 21:38       ` Wolfram Sang
2017-01-27 13:30     ` [PATCH v4 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
2017-02-01 18:34       ` Mark Brown
2017-02-04  8:00     ` [PATCH v5 0/3] Init device ids from ACPI of_compatible Dan O'Donovan
2017-02-04  8:00       ` [PATCH v5 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node Dan O'Donovan
     [not found]       ` <1486195228-10929-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
2017-02-04  8:00         ` [PATCH v5 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
2017-02-04  8:00       ` [PATCH v5 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
2017-02-04 10:16         ` Mark Brown
2017-02-05 16:30       ` [PATCH v6 0/3] Init device ids from ACPI of_compatible Dan O'Donovan
2017-02-05 16:30         ` [PATCH v6 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node Dan O'Donovan
2017-02-05 16:30         ` [PATCH v6 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
2017-02-05 16:30         ` [PATCH v6 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
     [not found]           ` <1486312214-20770-4-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
2017-02-06 16:31             ` Mark Brown
     [not found]         ` <1486312214-20770-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
2017-02-09 13:53           ` [PATCH v6 0/3] Init device ids from ACPI of_compatible Rafael J. Wysocki

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=dc44d52c-12f7-46f2-0594-b487edacd8a1@emutex.com \
    --to=dan@emutex.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jarkko.nikula@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=wsa@the-dreams.de \
    /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).