* [PATCH v3 2/3] i2c: acpi: Initialize info.type from of_compatible
2017-01-23 16:08 ` [PATCH v3 " Dan O'Donovan
@ 2017-01-23 16:08 ` Dan O'Donovan
2017-01-23 17:10 ` Andy Shevchenko
[not found] ` <1485187737-22414-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
` (3 subsequent siblings)
4 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-23 16:08 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan, Crestez Dan Leonard
From: Crestez Dan Leonard <leonard.crestez@intel.com>
When using devicetree i2c_board_info.type is set to the compatible
string with the vendor prefix removed. For I2C devices described via
ACPI the i2c_board_info.type string is set to the ACPI device name. When
using ACPI and DT ids this string ends up something like "PRP0001:00".
If the of_compatible property is present try to use that instead. This
makes it easier to instantiate i2c drivers through ACPI with DT ids.
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Signed-off-by: Dan O'Donovan <dan@emutex.com>
---
drivers/i2c/i2c-core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 583e950..a83dbc7 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -221,7 +221,13 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
acpi_dev_free_resource_list(&resource_list);
- strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
+ /*
+ * Populate modalias from compatible property if available,
+ * otherwise use native ACPI information
+ */
+ if ((!adev->data.of_compatible) ||
+ acpi_of_modalias(adev, info->type, sizeof(info->type)))
+ strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH v3 2/3] i2c: acpi: Initialize info.type from of_compatible
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
0 siblings, 0 replies; 48+ messages in thread
From: Andy Shevchenko @ 2017-01-23 17:10 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel, Crestez Dan Leonard
On Mon, Jan 23, 2017 at 6:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
> From: Crestez Dan Leonard <leonard.crestez@intel.com>
>
> When using devicetree i2c_board_info.type is set to the compatible
> string with the vendor prefix removed. For I2C devices described via
> ACPI the i2c_board_info.type string is set to the ACPI device name. When
> using ACPI and DT ids this string ends up something like "PRP0001:00".
>
> If the of_compatible property is present try to use that instead. This
> makes it easier to instantiate i2c drivers through ACPI with DT ids.
> - strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
> + /*
> + * Populate modalias from compatible property if available,
> + * otherwise use native ACPI information
> + */
> + if ((!adev->data.of_compatible) ||
> + acpi_of_modalias(adev, info->type, sizeof(info->type)))
Redundant parens in lvalue. After removing them is it possible to use
one line for it?
> + strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 48+ messages in thread
[parent not found: <1485187737-22414-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>]
* [PATCH v3 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
[not found] ` <1485187737-22414-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
@ 2017-01-23 16:08 ` Dan O'Donovan
2017-01-23 16:08 ` [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible Dan O'Donovan
1 sibling, 0 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-23 16:08 UTC (permalink / raw)
To: linux-acpi-u79uwXL29TY76Z2rM5mHXA, Rafael J . Wysocki,
Jarkko Nikula, Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan O'Donovan,
Crestez Dan Leonard
From: Crestez Dan Leonard <leonard.crestez-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dan O'Donovan <dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
Reviewed-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
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)
+{
+ 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 *);
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 48+ messages in thread
* [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible
[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 ` Dan O'Donovan
2017-01-23 17:11 ` Andy Shevchenko
2017-01-30 9:41 ` Rafael J. Wysocki
1 sibling, 2 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-23 16:08 UTC (permalink / raw)
To: linux-acpi-u79uwXL29TY76Z2rM5mHXA, Rafael J . Wysocki,
Jarkko Nikula, Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan O'Donovan,
Crestez Dan Leonard
From: Crestez Dan Leonard <leonard.crestez-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
When using devicetree spi_device.modalias is set to the compatible
string with the vendor prefix removed. For SPI devices described via
ACPI the spi_device.modalias string is initialized by acpi_device_hid.
When using ACPI and DT ids this string ends up something like "PRP0001".
Change acpi_register_spi_device to use the of_compatible property if
present. This makes it easier to instantiate spi drivers through ACPI
with DT ids.
Signed-off-by: Crestez Dan Leonard <leonard.crestez-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dan O'Donovan <dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 656dd3e..4b562e8 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1722,13 +1722,21 @@ static acpi_status acpi_register_spi_device(struct spi_master *master,
return AE_OK;
}
+ /*
+ * Populate modalias from compatible property if available,
+ * otherwise use native ACPI information
+ */
+ if ((!adev->data.of_compatible) ||
+ acpi_of_modalias(adev, spi->modalias, sizeof(spi->modalias)))
+ strlcpy(spi->modalias, acpi_device_hid(adev),
+ sizeof(spi->modalias));
+
if (spi->irq < 0)
spi->irq = acpi_dev_gpio_irq_get(adev, 0);
acpi_device_set_enumerated(adev);
adev->power.flags.ignore_parent = true;
- strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias));
if (spi_add_device(spi)) {
adev->power.flags.ignore_parent = false;
dev_err(&master->dev, "failed to add SPI device %s from ACPI\n",
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible
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-30 9:41 ` Rafael J. Wysocki
1 sibling, 1 reply; 48+ messages in thread
From: Andy Shevchenko @ 2017-01-23 17:11 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel, Crestez Dan Leonard
On Mon, Jan 23, 2017 at 6:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
> From: Crestez Dan Leonard <leonard.crestez@intel.com>
>
> When using devicetree spi_device.modalias is set to the compatible
> string with the vendor prefix removed. For SPI devices described via
> ACPI the spi_device.modalias string is initialized by acpi_device_hid.
> When using ACPI and DT ids this string ends up something like "PRP0001".
>
> Change acpi_register_spi_device to use the of_compatible property if
> present. This makes it easier to instantiate spi drivers through ACPI
> with DT ids.
> + /*
> + * Populate modalias from compatible property if available,
> + * otherwise use native ACPI information
> + */
> + if ((!adev->data.of_compatible) ||
> + acpi_of_modalias(adev, spi->modalias, sizeof(spi->modalias)))
Same comment as in patch 2.
> + strlcpy(spi->modalias, acpi_device_hid(adev),
> + sizeof(spi->modalias));
Could this be one line?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible
2017-01-23 17:11 ` Andy Shevchenko
@ 2017-01-27 10:35 ` Dan O'Donovan
2017-01-27 13:43 ` Andy Shevchenko
0 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-27 10:35 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel, Crestez Dan Leonard
On 01/23/2017 05:11 PM, Andy Shevchenko wrote:
> On Mon, Jan 23, 2017 at 6:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
>> From: Crestez Dan Leonard <leonard.crestez@intel.com>
>>
>> When using devicetree spi_device.modalias is set to the compatible
>> string with the vendor prefix removed. For SPI devices described via
>> ACPI the spi_device.modalias string is initialized by acpi_device_hid.
>> When using ACPI and DT ids this string ends up something like "PRP0001".
>>
>> Change acpi_register_spi_device to use the of_compatible property if
>> present. This makes it easier to instantiate spi drivers through ACPI
>> with DT ids.
>> + /*
>> + * Populate modalias from compatible property if available,
>> + * otherwise use native ACPI information
>> + */
>> + if ((!adev->data.of_compatible) ||
>> + acpi_of_modalias(adev, spi->modalias, sizeof(spi->modalias)))
> Same comment as in patch 2.
Thanks for the feedback, Andy. The check on of_compatible is redundant,
because its repeated in acpi_of_modalias(), so I'll remove it here (and
in patch 2) to reduce this to one line. v4 on the way.
>> + strlcpy(spi->modalias, acpi_device_hid(adev),
>> + sizeof(spi->modalias));
> Could this be one line?
I couldn't see a way to reduce this to one line without exceeding 80
chars or adding another line somewhere else, so I'll leave this one as
it is if that's ok.
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible
2017-01-27 10:35 ` Dan O'Donovan
@ 2017-01-27 13:43 ` Andy Shevchenko
0 siblings, 0 replies; 48+ messages in thread
From: Andy Shevchenko @ 2017-01-27 13:43 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel, Crestez Dan Leonard
On Fri, Jan 27, 2017 at 12:35 PM, Dan O'Donovan <dan@emutex.com> wrote:
> On 01/23/2017 05:11 PM, Andy Shevchenko wrote:
>> On Mon, Jan 23, 2017 at 6:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
>>> + strlcpy(spi->modalias, acpi_device_hid(adev),
>>> + sizeof(spi->modalias));
>> Could this be one line?
> I couldn't see a way to reduce this to one line without exceeding 80
> chars or adding another line somewhere else, so I'll leave this one as
> it is if that's ok.
80 characters per line is not carved in stone. How many do you have
over? 3 like "s);"?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible
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-30 9:41 ` Rafael J. Wysocki
2017-01-31 20:17 ` Mark Brown
1 sibling, 1 reply; 48+ messages in thread
From: Rafael J. Wysocki @ 2017-01-30 9:41 UTC (permalink / raw)
To: Dan O'Donovan, Mark Brown
Cc: ACPI Devel Maling List, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
Linux Kernel Mailing List, Crestez Dan Leonard
On Mon, Jan 23, 2017 at 5:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
> From: Crestez Dan Leonard <leonard.crestez@intel.com>
>
> When using devicetree spi_device.modalias is set to the compatible
> string with the vendor prefix removed. For SPI devices described via
> ACPI the spi_device.modalias string is initialized by acpi_device_hid.
> When using ACPI and DT ids this string ends up something like "PRP0001".
>
> Change acpi_register_spi_device to use the of_compatible property if
> present. This makes it easier to instantiate spi drivers through ACPI
> with DT ids.
>
> Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
> Signed-off-by: Dan O'Donovan <dan@emutex.com>
> ---
> drivers/spi/spi.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 656dd3e..4b562e8 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1722,13 +1722,21 @@ static acpi_status acpi_register_spi_device(struct spi_master *master,
> return AE_OK;
> }
>
> + /*
> + * Populate modalias from compatible property if available,
> + * otherwise use native ACPI information
> + */
> + if ((!adev->data.of_compatible) ||
> + acpi_of_modalias(adev, spi->modalias, sizeof(spi->modalias)))
> + strlcpy(spi->modalias, acpi_device_hid(adev),
> + sizeof(spi->modalias));
> +
> if (spi->irq < 0)
> spi->irq = acpi_dev_gpio_irq_get(adev, 0);
>
> acpi_device_set_enumerated(adev);
>
> adev->power.flags.ignore_parent = true;
> - strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias));
> if (spi_add_device(spi)) {
> adev->power.flags.ignore_parent = false;
> dev_err(&master->dev, "failed to add SPI device %s from ACPI\n",
> --
Mark, any objections here?
Thanks,
Rafael
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v3 3/3] spi: acpi: Initialize modalias from of_compatible
2017-01-30 9:41 ` Rafael J. Wysocki
@ 2017-01-31 20:17 ` Mark Brown
[not found] ` <20170131201736.cmiyq2obzrhgdsck-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
0 siblings, 1 reply; 48+ messages in thread
From: Mark Brown @ 2017-01-31 20:17 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Dan O'Donovan, ACPI Devel Maling List, Rafael J . Wysocki,
Jarkko Nikula, Mika Westerberg, Len Brown, linux-i2c,
Wolfram Sang, linux-spi, Linux Kernel Mailing List,
Crestez Dan Leonard
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
On Mon, Jan 30, 2017 at 10:41:33AM +0100, Rafael J. Wysocki wrote:
> On Mon, Jan 23, 2017 at 5:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
> Mark, any objections here?
I've not looked yet, please allow a reasonable time for review (there
still seemed to be ongoing discussion at the ACPI level). I continue to
be concerned about the amount of duplication and special casing that the
various firmware paths seem to entail.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v3 0/3] Init device ids from ACPI of_compatible
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
[not found] ` <1485187737-22414-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
@ 2017-01-23 17:13 ` Andy Shevchenko
2017-01-24 15:11 ` Jarkko Nikula
2017-01-27 13:30 ` [PATCH v4 " Dan O'Donovan
4 siblings, 0 replies; 48+ messages in thread
From: Andy Shevchenko @ 2017-01-23 17:13 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel
On Mon, Jan 23, 2017 at 6:08 PM, Dan O'Donovan <dan@emutex.com> wrote:
> (Re-submitting this patch set originally created by Leonard Crestez,
> possibly abandoned by Leonard due to a change in employment)
>
> 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 in order to differentiate between
> hardware variants try to replicate it when using ACPI with DT ids.
>
> This also makes it so that the i2c_device_id parameter passed to probe is
> non-NULL when matching with ACPI and DT ids.
>
> Tested using ACPI overlays but there is no actual dependency. This series
> just extends the PRP0001 feature to be more useful for I2C/SPI.
>
> The patches only touches the ACPI-specific parts of the i2c and spi core.
The series looks good. Few nitpicks in the comments of corresponding
patches though.
FWIW:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> Here is an example .dsl for an SPI accelerometer connected to minnowboard max:
>
> Device (ACCL)
> {
> Name (_ADR, Zero)
> Name (_HID, "PRP0001")
> Name (_UID, One)
>
> Method (_CRS, 0, Serialized)
> {
> Name (RBUF, ResourceTemplate ()
> {
> SPISerialBus(1, PolarityLow, FourWireMode, 16,
> ControllerInitiated, 1000000, ClockPolarityLow,
> ClockPhaseFirst, "\\_SB.SPI1",)
> GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000,
> "\\_SB.GPO2", 0x00, ResourceConsumer, , )
> { // Pin list
> 1
> }
> })
> Return (RBUF)
> }
> Name (_DSD, Package ()
> {
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> Package ()
> {
> Package () {"compatible", "st,lis3dh"},
> }
> })
> }
>
> Link to v2: https://lkml.org/lkml/2016/7/13/392
> Changes:
> * Use appropriate subject prefix for each subsystem (Mark Brown)
> * Use ACPI info as before if getting OF info fails (Mark Brown)
> * Minor cosmetic/readability improvements (Rafael J. Wysocki)
>
> Link to v1: https://www.spinics.net/lists/linux-acpi/msg66469.html
> Changes:
> * Rebase on after acpi overlays got it.
> * Change acpi_of_modalias outlen param to size_t
> * Use {} after else
>
> Crestez Dan Leonard (3):
> ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
> i2c: acpi: Initialize info.type from of_compatible
> spi: acpi: Initialize modalias from of_compatible
>
> drivers/acpi/bus.c | 35 +++++++++++++++++++++++++++++++++++
> drivers/i2c/i2c-core.c | 8 +++++++-
> drivers/spi/spi.c | 10 +++++++++-
> include/acpi/acpi_bus.h | 1 +
> 4 files changed, 52 insertions(+), 2 deletions(-)
>
> --
> 2.7.4
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v3 0/3] Init device ids from ACPI of_compatible
2017-01-23 16:08 ` [PATCH v3 " Dan O'Donovan
` (2 preceding siblings ...)
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-27 13:30 ` [PATCH v4 " Dan O'Donovan
4 siblings, 1 reply; 48+ messages in thread
From: Jarkko Nikula @ 2017-01-24 15:11 UTC (permalink / raw)
To: Dan O'Donovan, linux-acpi, Rafael J . Wysocki,
Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel
On 01/23/2017 06:08 PM, Dan O'Donovan wrote:
> (Re-submitting this patch set originally created by Leonard Crestez,
> possibly abandoned by Leonard due to a change in employment)
>
> 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 in order to differentiate between
> hardware variants try to replicate it when using ACPI with DT ids.
>
> This also makes it so that the i2c_device_id parameter passed to probe is
> non-NULL when matching with ACPI and DT ids.
>
> Tested using ACPI overlays but there is no actual dependency. This series
> just extends the PRP0001 feature to be more useful for I2C/SPI.
>
> The patches only touches the ACPI-specific parts of the i2c and spi core.
>
> Here is an example .dsl for an SPI accelerometer connected to minnowboard max:
>
> Device (ACCL)
> {
> Name (_ADR, Zero)
> Name (_HID, "PRP0001")
> Name (_UID, One)
>
> Method (_CRS, 0, Serialized)
> {
> Name (RBUF, ResourceTemplate ()
> {
> SPISerialBus(1, PolarityLow, FourWireMode, 16,
> ControllerInitiated, 1000000, ClockPolarityLow,
> ClockPhaseFirst, "\\_SB.SPI1",)
> GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000,
> "\\_SB.GPO2", 0x00, ResourceConsumer, , )
> { // Pin list
> 1
> }
> })
> Return (RBUF)
> }
> Name (_DSD, Package ()
> {
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> Package ()
> {
> Package () {"compatible", "st,lis3dh"},
> }
> })
> }
>
> Link to v2: https://lkml.org/lkml/2016/7/13/392
> Changes:
> * Use appropriate subject prefix for each subsystem (Mark Brown)
> * Use ACPI info as before if getting OF info fails (Mark Brown)
> * Minor cosmetic/readability improvements (Rafael J. Wysocki)
>
> Link to v1: https://www.spinics.net/lists/linux-acpi/msg66469.html
> Changes:
> * Rebase on after acpi overlays got it.
> * Change acpi_of_modalias outlen param to size_t
> * Use {} after else
>
> Crestez Dan Leonard (3):
> ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
> i2c: acpi: Initialize info.type from of_compatible
> spi: acpi: Initialize modalias from of_compatible
>
> drivers/acpi/bus.c | 35 +++++++++++++++++++++++++++++++++++
> drivers/i2c/i2c-core.c | 8 +++++++-
> drivers/spi/spi.c | 10 +++++++++-
> include/acpi/acpi_bus.h | 1 +
> 4 files changed, 52 insertions(+), 2 deletions(-)
>
After addressing comments from Andy
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v4 0/3] Init device ids from ACPI of_compatible
2017-01-23 16:08 ` [PATCH v3 " Dan O'Donovan
` (3 preceding siblings ...)
2017-01-24 15:11 ` Jarkko Nikula
@ 2017-01-27 13:30 ` 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
` (3 more replies)
4 siblings, 4 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-27 13:30 UTC (permalink / raw)
To: linux-acpi, Andy Shevchenko, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
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 in order to differentiate between
hardware variants, try to replicate it when using ACPI with DT ids.
This also makes it so that the i2c_device_id parameter passed to probe is
non-NULL when matching with ACPI and DT ids.
Tested using ACPI overlays but there is no actual dependency. This series
just extends the PRP0001 feature to be more useful for I2C/SPI.
The patches only touches the ACPI-specific parts of the i2c and spi core.
Here is an example .dsl for an SPI accelerometer connected to minnowboard max:
Device (ACCL)
{
Name (_ADR, Zero)
Name (_HID, "PRP0001")
Name (_UID, One)
Method (_CRS, 0, Serialized)
{
Name (RBUF, ResourceTemplate ()
{
SPISerialBus(1, PolarityLow, FourWireMode, 16,
ControllerInitiated, 1000000, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.SPI1",)
GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000,
"\\_SB.GPO2", 0x00, ResourceConsumer, , )
{ // Pin list
1
}
})
Return (RBUF)
}
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"compatible", "st,lis3dh"},
}
})
}
Link to v3: http://www.spinics.net/lists/linux-acpi/msg71531.html
Changes:
* Minor cosmetic/readability improvements (Andy Shevchenko)
Link to v2: https://lkml.org/lkml/2016/7/13/392
Changes:
* Use appropriate subject prefix for each subsystem (Mark Brown)
* Use ACPI info as before if getting OF info fails (Mark Brown)
* Minor cosmetic/readability improvements (Rafael J. Wysocki)
Link to v1: https://www.spinics.net/lists/linux-acpi/msg66469.html
Changes:
* Rebase on after acpi overlays got it.
* Change acpi_of_modalias outlen param to size_t
* Use {} after else
Crestez Dan Leonard (3):
ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
i2c: acpi: Initialize info.type from of_compatible
spi: acpi: Initialize modalias from of_compatible
drivers/acpi/bus.c | 35 +++++++++++++++++++++++++++++++++++
drivers/i2c/i2c-core.c | 7 ++++++-
drivers/spi/spi.c | 9 ++++++++-
include/acpi/acpi_bus.h | 1 +
4 files changed, 50 insertions(+), 2 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v4 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
2017-01-27 13:30 ` [PATCH v4 " Dan O'Donovan
@ 2017-01-27 13:30 ` Dan O'Donovan
2017-02-02 11:41 ` Rafael J. Wysocki
2017-01-27 13:30 ` [PATCH v4 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
` (2 subsequent siblings)
3 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-27 13:30 UTC (permalink / raw)
To: linux-acpi, Andy Shevchenko, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan, Crestez Dan Leonard
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>
---
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)
+{
+ 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 *);
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH v4 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
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
0 siblings, 1 reply; 48+ messages in thread
From: Rafael J. Wysocki @ 2017-02-02 11:41 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Andy Shevchenko, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel
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().
> +{
> + 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
^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH v4 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
2017-02-02 11:41 ` Rafael J. Wysocki
@ 2017-02-02 13:30 ` Dan O'Donovan
0 siblings, 0 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-02 13:30 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: linux-acpi, Andy Shevchenko, Jarkko Nikula, Mika Westerberg,
Mark Brown, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel
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
>
>
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v4 2/3] i2c: acpi: Initialize info.type from of_compatible
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-01-27 13:30 ` 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-04 8:00 ` [PATCH v5 0/3] Init device ids from ACPI of_compatible Dan O'Donovan
3 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-27 13:30 UTC (permalink / raw)
To: linux-acpi, Andy Shevchenko, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan, Crestez Dan Leonard
From: Crestez Dan Leonard <leonard.crestez@intel.com>
When using devicetree i2c_board_info.type is set to the compatible
string with the vendor prefix removed. For I2C devices described via
ACPI the i2c_board_info.type string is set to the ACPI device name. When
using ACPI and DT ids this string ends up something like "PRP0001:00".
If the of_compatible property is present try to use that instead. This
makes it easier to instantiate i2c drivers through 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: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/i2c/i2c-core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 583e950..6e99431 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -221,7 +221,12 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
acpi_dev_free_resource_list(&resource_list);
- strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
+ /*
+ * Populate modalias from compatible property if available,
+ * otherwise use native ACPI information
+ */
+ if (acpi_of_modalias(adev, info->type, sizeof(info->type)))
+ strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH v4 2/3] i2c: acpi: Initialize info.type from of_compatible
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
0 siblings, 0 replies; 48+ messages in thread
From: Wolfram Sang @ 2017-01-28 21:38 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Andy Shevchenko, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Mark Brown, Len Brown, linux-i2c, linux-spi,
linux-kernel, Crestez Dan Leonard
[-- Attachment #1: Type: text/plain, Size: 978 bytes --]
On Fri, Jan 27, 2017 at 01:30:14PM +0000, Dan O'Donovan wrote:
> From: Crestez Dan Leonard <leonard.crestez@intel.com>
>
> When using devicetree i2c_board_info.type is set to the compatible
> string with the vendor prefix removed. For I2C devices described via
> ACPI the i2c_board_info.type string is set to the ACPI device name. When
> using ACPI and DT ids this string ends up something like "PRP0001:00".
>
> If the of_compatible property is present try to use that instead. This
> makes it easier to instantiate i2c drivers through 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: Andy Shevchenko <andy.shevchenko@gmail.com>
> Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
I assume this shall go in as one series via ACPI tree, so:
Acked-by: Wolfram Sang <wsa@the-dreams.de>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v4 3/3] spi: acpi: Initialize modalias from of_compatible
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-01-27 13:30 ` [PATCH v4 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
@ 2017-01-27 13:30 ` 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
3 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-01-27 13:30 UTC (permalink / raw)
To: linux-acpi, Andy Shevchenko, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan, Crestez Dan Leonard
From: Crestez Dan Leonard <leonard.crestez@intel.com>
When using devicetree spi_device.modalias is set to the compatible
string with the vendor prefix removed. For SPI devices described via
ACPI the spi_device.modalias string is initialized by acpi_device_hid.
When using ACPI and DT ids this string ends up something like "PRP0001".
Change acpi_register_spi_device to use the of_compatible property if
present. This makes it easier to instantiate spi drivers through 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: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/spi/spi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 656dd3e..9a8c880 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1722,13 +1722,20 @@ static acpi_status acpi_register_spi_device(struct spi_master *master,
return AE_OK;
}
+ /*
+ * Populate modalias from compatible property if available,
+ * otherwise use native ACPI information
+ */
+ if (acpi_of_modalias(adev, spi->modalias, sizeof(spi->modalias)))
+ strlcpy(spi->modalias, acpi_device_hid(adev),
+ sizeof(spi->modalias));
+
if (spi->irq < 0)
spi->irq = acpi_dev_gpio_irq_get(adev, 0);
acpi_device_set_enumerated(adev);
adev->power.flags.ignore_parent = true;
- strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias));
if (spi_add_device(spi)) {
adev->power.flags.ignore_parent = false;
dev_err(&master->dev, "failed to add SPI device %s from ACPI\n",
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH v4 3/3] spi: acpi: Initialize modalias from of_compatible
2017-01-27 13:30 ` [PATCH v4 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
@ 2017-02-01 18:34 ` Mark Brown
0 siblings, 0 replies; 48+ messages in thread
From: Mark Brown @ 2017-02-01 18:34 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Andy Shevchenko, Rafael J . Wysocki, Jarkko Nikula,
Mika Westerberg, Len Brown, linux-i2c, Wolfram Sang, linux-spi,
linux-kernel, Crestez Dan Leonard
[-- Attachment #1: Type: text/plain, Size: 684 bytes --]
On Fri, Jan 27, 2017 at 01:30:15PM +0000, Dan O'Donovan wrote:
> + if (acpi_of_modalias(adev, spi->modalias, sizeof(spi->modalias)))
> + strlcpy(spi->modalias, acpi_device_hid(adev),
> + sizeof(spi->modalias));
I can't help but think that this would be simpler to use if the
interface were something like acpi_set_modalias() and it did the
fallback to the ACPI HID internally. It'd both avoid a small amount of
code duplication and make the code read a bit more naturally - I have to
think to realise that this means "if there isn't an OF name use the
HID" since it looks like a boolean function. Then again just putting a
!= 0 in the test would have the same effect probably.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v5 0/3] Init device ids from ACPI of_compatible
2017-01-27 13:30 ` [PATCH v4 " Dan O'Donovan
` (2 preceding siblings ...)
2017-01-27 13:30 ` [PATCH v4 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
@ 2017-02-04 8:00 ` 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
` (3 more replies)
3 siblings, 4 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-04 8:00 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
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 in order to differentiate between
hardware variants, try to replicate it when using ACPI with DT ids.
This also makes it so that the i2c_device_id parameter passed to probe is
non-NULL when matching with ACPI and DT ids.
Tested using ACPI overlays but there is no actual dependency. This series
just extends the PRP0001 feature to be more useful for I2C/SPI.
The patches only touches the ACPI-specific parts of the i2c and spi core.
Here is an example .dsl for an SPI accelerometer connected to minnowboard max:
Device (ACCL)
{
Name (_ADR, Zero)
Name (_HID, "PRP0001")
Name (_UID, One)
Method (_CRS, 0, Serialized)
{
Name (RBUF, ResourceTemplate ()
{
SPISerialBus(1, PolarityLow, FourWireMode, 16,
ControllerInitiated, 1000000, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.SPI1",)
GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000,
"\\_SB.GPO2", 0x00, ResourceConsumer, , )
{ // Pin list
1
}
})
Return (RBUF)
}
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"compatible", "st,lis3dh"},
}
})
}
Credit to Leonard Crestez for the original version of this patch set.
Link to v4: http://www.spinics.net/lists/linux-acpi/msg71657.html
Changes:
* add acpi_set_modalias wrapper to handle fallback to ACPI ID (Mark Brown)
Link to v3: http://www.spinics.net/lists/linux-acpi/msg71531.html
Changes:
* Minor cosmetic/readability improvements (Andy Shevchenko)
Link to v2: https://lkml.org/lkml/2016/7/13/392
Changes:
* Use appropriate subject prefix for each subsystem (Mark Brown)
* Use ACPI info as before if getting OF info fails (Mark Brown)
* Minor cosmetic/readability improvements (Rafael J. Wysocki)
Link to v1: https://www.spinics.net/lists/linux-acpi/msg66469.html
Changes:
* Rebase on after acpi overlays got it.
* Change acpi_of_modalias outlen param to size_t
* Use {} after else
Dan O'Donovan (3):
ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
i2c: acpi: Initialize info.type from of_compatible
spi: acpi: Initialize modalias from of_compatible
drivers/acpi/bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++
drivers/i2c/i2c-core.c | 3 ++-
drivers/spi/spi.c | 4 +++-
include/acpi/acpi_bus.h | 2 ++
4 files changed, 49 insertions(+), 2 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v5 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
2017-02-04 8:00 ` [PATCH v5 0/3] Init device ids from ACPI of_compatible Dan O'Donovan
@ 2017-02-04 8:00 ` Dan O'Donovan
[not found] ` <1486195228-10929-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
` (2 subsequent siblings)
3 siblings, 0 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-04 8:00 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
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: 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>
---
drivers/acpi/bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++
include/acpi/acpi_bus.h | 2 ++
2 files changed, 44 insertions(+)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 95855cb..80cb5eb 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -677,6 +677,48 @@ static bool acpi_of_match_device(struct acpi_device *adev,
return false;
}
+static bool acpi_of_modalias(struct acpi_device *adev,
+ char *modalias, size_t len)
+{
+ 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 false;
+
+ 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(modalias, chr ? chr + 1 : str, len);
+
+ return true;
+}
+
+/**
+ * acpi_set_modalias - Set modalias using "compatible" property or supplied ID
+ * @adev: ACPI device object to match
+ * @default_id: ID string to use as default if no compatible string found
+ * @modalias: Pointer to buffer that modalias value will be copied into
+ * @len: Length of modalias buffer
+ *
+ * This is a counterpart of of_modalias_node() for struct acpi_device objects.
+ * If there is a compatible string for @adev, it will be copied to @modalias
+ * with the vendor prefix stripped; otherwise, @default_id will be used.
+ */
+void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
+ char *modalias, size_t len)
+{
+ if (!acpi_of_modalias(adev, modalias, len))
+ strlcpy(modalias, default_id, len);
+}
+EXPORT_SYMBOL_GPL(acpi_set_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..ef0ae8a 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -522,6 +522,8 @@ 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);
+void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
+ char *modalias, size_t len);
int acpi_create_dir(struct acpi_device *);
void acpi_remove_dir(struct acpi_device *);
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
[parent not found: <1486195228-10929-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>]
* [PATCH v5 2/3] i2c: acpi: Initialize info.type from of_compatible
[not found] ` <1486195228-10929-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
@ 2017-02-04 8:00 ` Dan O'Donovan
0 siblings, 0 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-04 8:00 UTC (permalink / raw)
To: linux-acpi-u79uwXL29TY76Z2rM5mHXA, Rafael J . Wysocki,
Jarkko Nikula, Mika Westerberg, Mark Brown
Cc: Len Brown, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan O'Donovan
When using devicetree i2c_board_info.type is set to the compatible
string with the vendor prefix removed. For I2C devices described via
ACPI the i2c_board_info.type string is set to the ACPI device name. When
using ACPI and DT ids this string ends up something like "PRP0001:00".
If the of_compatible property is present try to use that instead. This
makes it easier to instantiate i2c drivers through ACPI with DT ids.
Signed-off-by: Dan O'Donovan <dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Tested-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Acked-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
---
drivers/i2c/i2c-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 583e950..28d2181 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -221,7 +221,8 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
acpi_dev_free_resource_list(&resource_list);
- strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
+ acpi_set_modalias(adev, dev_name(&adev->dev),
+ info->type, sizeof(info->type));
return 0;
}
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 48+ messages in thread
* [PATCH v5 3/3] spi: acpi: Initialize modalias from of_compatible
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 ` 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
3 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-04 8:00 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
When using devicetree spi_device.modalias is set to the compatible
string with the vendor prefix removed. For SPI devices described via
ACPI the spi_device.modalias string is initialized by acpi_device_hid.
When using ACPI and DT ids this string ends up something like "PRP0001".
Change acpi_register_spi_device to use the of_compatible property if
present. This makes it easier to instantiate spi drivers through ACPI
with DT ids.
Signed-off-by: Dan O'Donovan <dan@emutex.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>
---
drivers/spi/spi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 656dd3e..d9afc32 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1722,13 +1722,15 @@ static acpi_status acpi_register_spi_device(struct spi_master *master,
return AE_OK;
}
+ acpi_set_modalias(adev, acpi_device_hid(adev),
+ spi->modalias, sizeof(spi->modalias));
+
if (spi->irq < 0)
spi->irq = acpi_dev_gpio_irq_get(adev, 0);
acpi_device_set_enumerated(adev);
adev->power.flags.ignore_parent = true;
- strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias));
if (spi_add_device(spi)) {
adev->power.flags.ignore_parent = false;
dev_err(&master->dev, "failed to add SPI device %s from ACPI\n",
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH v5 3/3] spi: acpi: Initialize modalias from of_compatible
2017-02-04 8:00 ` [PATCH v5 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
@ 2017-02-04 10:16 ` Mark Brown
0 siblings, 0 replies; 48+ messages in thread
From: Mark Brown @ 2017-02-04 10:16 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 310 bytes --]
On Sat, Feb 04, 2017 at 08:00:28AM +0000, Dan O'Donovan wrote:
> + acpi_set_modalias(adev, acpi_device_hid(adev),
> + spi->modalias, sizeof(spi->modalias));
> +
The formatting here is really weird (why isn't the third argument on the
line above?) but otherwise
Acked-by: Mark Brown <broonie@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v6 0/3] Init device ids from ACPI of_compatible
2017-02-04 8:00 ` [PATCH v5 0/3] Init device ids from ACPI of_compatible Dan O'Donovan
` (2 preceding siblings ...)
2017-02-04 8:00 ` [PATCH v5 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
@ 2017-02-05 16:30 ` 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
` (3 more replies)
3 siblings, 4 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-05 16:30 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
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 in order to differentiate between
hardware variants, try to replicate it when using ACPI with DT ids.
This also makes it so that the i2c_device_id parameter passed to probe is
non-NULL when matching with ACPI and DT ids.
Tested using ACPI overlays but there is no actual dependency. This series
just extends the PRP0001 feature to be more useful for I2C/SPI.
The patches only touches the ACPI-specific parts of the i2c and spi core.
Here is an example .dsl for an SPI accelerometer connected to minnowboard max:
Device (ACCL)
{
Name (_ADR, Zero)
Name (_HID, "PRP0001")
Name (_UID, One)
Method (_CRS, 0, Serialized)
{
Name (RBUF, ResourceTemplate ()
{
SPISerialBus(1, PolarityLow, FourWireMode, 16,
ControllerInitiated, 1000000, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.SPI1",)
GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000,
"\\_SB.GPO2", 0x00, ResourceConsumer, , )
{ // Pin list
1
}
})
Return (RBUF)
}
Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () {"compatible", "st,lis3dh"},
}
})
}
Credit to Leonard Crestez for the original version of this patch set.
Link to v5: http://www.spinics.net/lists/linux-acpi/msg71902.html
Changes:
* Change formatting of arguments passed to acpi_set_modalias (Mark Brown)
Link to v4: http://www.spinics.net/lists/linux-acpi/msg71657.html
Changes:
* add acpi_set_modalias wrapper to handle fallback to ACPI ID (Mark Brown)
Link to v3: http://www.spinics.net/lists/linux-acpi/msg71531.html
Changes:
* Minor cosmetic/readability improvements (Andy Shevchenko)
Link to v2: https://lkml.org/lkml/2016/7/13/392
Changes:
* Use appropriate subject prefix for each subsystem (Mark Brown)
* Use ACPI info as before if getting OF info fails (Mark Brown)
* Minor cosmetic/readability improvements (Rafael J. Wysocki)
Link to v1: https://www.spinics.net/lists/linux-acpi/msg66469.html
Changes:
* Rebase on after acpi overlays got it.
* Change acpi_of_modalias outlen param to size_t
* Use {} after else
Dan O'Donovan (3):
ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
i2c: acpi: Initialize info.type from of_compatible
spi: acpi: Initialize modalias from of_compatible
drivers/acpi/bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++
drivers/i2c/i2c-core.c | 3 ++-
drivers/spi/spi.c | 4 +++-
include/acpi/acpi_bus.h | 2 ++
4 files changed, 49 insertions(+), 2 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH v6 1/3] ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
2017-02-05 16:30 ` [PATCH v6 0/3] Init device ids from ACPI of_compatible Dan O'Donovan
@ 2017-02-05 16:30 ` Dan O'Donovan
2017-02-05 16:30 ` [PATCH v6 2/3] i2c: acpi: Initialize info.type from of_compatible Dan O'Donovan
` (2 subsequent siblings)
3 siblings, 0 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-05 16:30 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
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: 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>
---
drivers/acpi/bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++
include/acpi/acpi_bus.h | 2 ++
2 files changed, 44 insertions(+)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 95855cb..80cb5eb 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -677,6 +677,48 @@ static bool acpi_of_match_device(struct acpi_device *adev,
return false;
}
+static bool acpi_of_modalias(struct acpi_device *adev,
+ char *modalias, size_t len)
+{
+ 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 false;
+
+ 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(modalias, chr ? chr + 1 : str, len);
+
+ return true;
+}
+
+/**
+ * acpi_set_modalias - Set modalias using "compatible" property or supplied ID
+ * @adev: ACPI device object to match
+ * @default_id: ID string to use as default if no compatible string found
+ * @modalias: Pointer to buffer that modalias value will be copied into
+ * @len: Length of modalias buffer
+ *
+ * This is a counterpart of of_modalias_node() for struct acpi_device objects.
+ * If there is a compatible string for @adev, it will be copied to @modalias
+ * with the vendor prefix stripped; otherwise, @default_id will be used.
+ */
+void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
+ char *modalias, size_t len)
+{
+ if (!acpi_of_modalias(adev, modalias, len))
+ strlcpy(modalias, default_id, len);
+}
+EXPORT_SYMBOL_GPL(acpi_set_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..ef0ae8a 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -522,6 +522,8 @@ 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);
+void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
+ char *modalias, size_t len);
int acpi_create_dir(struct acpi_device *);
void acpi_remove_dir(struct acpi_device *);
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* [PATCH v6 2/3] i2c: acpi: Initialize info.type from of_compatible
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 ` Dan O'Donovan
2017-02-05 16:30 ` [PATCH v6 3/3] spi: acpi: Initialize modalias " Dan O'Donovan
[not found] ` <1486312214-20770-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
3 siblings, 0 replies; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-05 16:30 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
When using devicetree i2c_board_info.type is set to the compatible
string with the vendor prefix removed. For I2C devices described via
ACPI the i2c_board_info.type string is set to the ACPI device name. When
using ACPI and DT ids this string ends up something like "PRP0001:00".
If the of_compatible property is present try to use that instead. This
makes it easier to instantiate i2c drivers through ACPI with DT ids.
Signed-off-by: Dan O'Donovan <dan@emutex.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>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
---
drivers/i2c/i2c-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 583e950..1e52395 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -221,7 +221,8 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
acpi_dev_free_resource_list(&resource_list);
- strlcpy(info->type, dev_name(&adev->dev), sizeof(info->type));
+ acpi_set_modalias(adev, dev_name(&adev->dev), info->type,
+ sizeof(info->type));
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
* [PATCH v6 3/3] spi: acpi: Initialize modalias from of_compatible
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 ` Dan O'Donovan
[not found] ` <1486312214-20770-4-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
[not found] ` <1486312214-20770-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
3 siblings, 1 reply; 48+ messages in thread
From: Dan O'Donovan @ 2017-02-05 16:30 UTC (permalink / raw)
To: linux-acpi, Rafael J . Wysocki, Jarkko Nikula, Mika Westerberg,
Mark Brown
Cc: Len Brown, linux-i2c, Wolfram Sang, linux-spi, linux-kernel,
Dan O'Donovan
When using devicetree spi_device.modalias is set to the compatible
string with the vendor prefix removed. For SPI devices described via
ACPI the spi_device.modalias string is initialized by acpi_device_hid.
When using ACPI and DT ids this string ends up something like "PRP0001".
Change acpi_register_spi_device to use the of_compatible property if
present. This makes it easier to instantiate spi drivers through ACPI
with DT ids.
Signed-off-by: Dan O'Donovan <dan@emutex.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>
Acked-by: Mark Brown <broonie@kernel.org>
---
drivers/spi/spi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 656dd3e..ad7f638 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1722,13 +1722,15 @@ static acpi_status acpi_register_spi_device(struct spi_master *master,
return AE_OK;
}
+ acpi_set_modalias(adev, acpi_device_hid(adev), spi->modalias,
+ sizeof(spi->modalias));
+
if (spi->irq < 0)
spi->irq = acpi_dev_gpio_irq_get(adev, 0);
acpi_device_set_enumerated(adev);
adev->power.flags.ignore_parent = true;
- strlcpy(spi->modalias, acpi_device_hid(adev), sizeof(spi->modalias));
if (spi_add_device(spi)) {
adev->power.flags.ignore_parent = false;
dev_err(&master->dev, "failed to add SPI device %s from ACPI\n",
--
2.7.4
^ permalink raw reply related [flat|nested] 48+ messages in thread
[parent not found: <1486312214-20770-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH v6 0/3] Init device ids from ACPI of_compatible
[not found] ` <1486312214-20770-1-git-send-email-dan-M3NBUjLqch7QT0dZR+AlfA@public.gmane.org>
@ 2017-02-09 13:53 ` Rafael J. Wysocki
0 siblings, 0 replies; 48+ messages in thread
From: Rafael J. Wysocki @ 2017-02-09 13:53 UTC (permalink / raw)
To: Dan O'Donovan
Cc: linux-acpi-u79uwXL29TY76Z2rM5mHXA, Jarkko Nikula,
Mika Westerberg, Mark Brown, Len Brown,
linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Sunday, February 05, 2017 04:30:11 PM Dan O'Donovan wrote:
> 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 in order to differentiate between
> hardware variants, try to replicate it when using ACPI with DT ids.
>
> This also makes it so that the i2c_device_id parameter passed to probe is
> non-NULL when matching with ACPI and DT ids.
>
> Tested using ACPI overlays but there is no actual dependency. This series
> just extends the PRP0001 feature to be more useful for I2C/SPI.
>
> The patches only touches the ACPI-specific parts of the i2c and spi core.
>
> Here is an example .dsl for an SPI accelerometer connected to minnowboard max:
>
> Device (ACCL)
> {
> Name (_ADR, Zero)
> Name (_HID, "PRP0001")
> Name (_UID, One)
>
> Method (_CRS, 0, Serialized)
> {
> Name (RBUF, ResourceTemplate ()
> {
> SPISerialBus(1, PolarityLow, FourWireMode, 16,
> ControllerInitiated, 1000000, ClockPolarityLow,
> ClockPhaseFirst, "\\_SB.SPI1",)
> GpioInt (Edge, ActiveHigh, Exclusive, PullDown, 0x0000,
> "\\_SB.GPO2", 0x00, ResourceConsumer, , )
> { // Pin list
> 1
> }
> })
> Return (RBUF)
> }
> Name (_DSD, Package ()
> {
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> Package ()
> {
> Package () {"compatible", "st,lis3dh"},
> }
> })
> }
>
> Credit to Leonard Crestez for the original version of this patch set.
>
> Link to v5: http://www.spinics.net/lists/linux-acpi/msg71902.html
> Changes:
> * Change formatting of arguments passed to acpi_set_modalias (Mark Brown)
>
> Link to v4: http://www.spinics.net/lists/linux-acpi/msg71657.html
> Changes:
> * add acpi_set_modalias wrapper to handle fallback to ACPI ID (Mark Brown)
>
> Link to v3: http://www.spinics.net/lists/linux-acpi/msg71531.html
> Changes:
> * Minor cosmetic/readability improvements (Andy Shevchenko)
>
> Link to v2: https://lkml.org/lkml/2016/7/13/392
> Changes:
> * Use appropriate subject prefix for each subsystem (Mark Brown)
> * Use ACPI info as before if getting OF info fails (Mark Brown)
> * Minor cosmetic/readability improvements (Rafael J. Wysocki)
>
> Link to v1: https://www.spinics.net/lists/linux-acpi/msg66469.html
> Changes:
> * Rebase on after acpi overlays got it.
> * Change acpi_of_modalias outlen param to size_t
> * Use {} after else
>
> Dan O'Donovan (3):
> ACPI / bus: Export acpi_of_modalias equiv of of_modalias_node
> i2c: acpi: Initialize info.type from of_compatible
> spi: acpi: Initialize modalias from of_compatible
All [1-3/3] applied.
Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 48+ messages in thread