* [PATCH] spi: spidev: Add ACPI probing support
@ 2016-07-04 10:38 Mika Westerberg
[not found] ` <1467628683-5783-1-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2016-07-04 10:38 UTC (permalink / raw)
To: linux-spi-u79uwXL29TY76Z2rM5mHXA
Cc: Mark Brown, Jarkko Nikula, Mika Westerberg
Some IoT and maker software stacks are using spidev to perform raw access
to the SPI bus instead of relying existing drivers provided by the kernel.
They then implement their own "drivers" in userspace on top of the spidev
raw interface. This is far from being an ideal solution but we do not want
to prevent using mainline Linux in these devices.
Now, it turns out that Windows has similar SPI devices than spidev which
allow raw access on the SPI bus to userspace programs as described in the
link below:
https://msdn.microsoft.com/windows/hardware/drivers/spb/spi-tests-in-mitt
These SPI test devices are also meant to be used during development and
testing.
In order to allow usage of spidev for development and testing in Linux, add
those same ACPI IDs to the spidev driver (which is Linux counterpart of the
Windows SPI test devices), but complain loudly so that users know it is not
good idea to use it in production systems. Instead they should be using
proper drivers for peripherals connected to the SPI bus.
Signed-off-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/spi/spidev.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e3c19f30f591..8dcad01b786d 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -29,6 +29,7 @@
#include <linux/compat.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/acpi.h>
#include <linux/spi/spi.h>
#include <linux/spi/spidev.h>
@@ -700,6 +701,16 @@ static const struct of_device_id spidev_dt_ids[] = {
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
#endif
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id spidev_acpi_ids[] = {
+ { "SPT0001" },
+ { "SPT0002" },
+ { "SPT0003" },
+ {},
+};
+MODULE_DEVICE_TABLE(acpi, spidev_acpi_ids);
+#endif
+
/*-------------------------------------------------------------------------*/
static int spidev_probe(struct spi_device *spi)
@@ -719,6 +730,15 @@ static int spidev_probe(struct spi_device *spi)
!of_match_device(spidev_dt_ids, &spi->dev));
}
+ /*
+ * The ACPI SPT000* devices are only meant for development and
+ * testing. Systems used in production should have a proper ACPI
+ * description of the connected peripheral and they should also use
+ * a proper driver instead of poking directly to the SPI bus.
+ */
+ if (has_acpi_companion(&spi->dev))
+ dev_warn(&spi->dev, "do not use this driver in production systems!\n");
+
/* Allocate driver data */
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
if (!spidev)
@@ -789,6 +809,7 @@ static struct spi_driver spidev_spi_driver = {
.driver = {
.name = "spidev",
.of_match_table = of_match_ptr(spidev_dt_ids),
+ .acpi_match_table = ACPI_PTR(spidev_acpi_ids),
},
.probe = spidev_probe,
.remove = spidev_remove,
--
2.8.1
--
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] 6+ messages in thread
* Re: [PATCH] spi: spidev: Add ACPI probing support
[not found] ` <1467628683-5783-1-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2016-07-04 12:56 ` Mark Brown
[not found] ` <20160704125600.GB6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2016-07-04 12:56 UTC (permalink / raw)
To: Mika Westerberg; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Jarkko Nikula
[-- Attachment #1: Type: text/plain, Size: 665 bytes --]
On Mon, Jul 04, 2016 at 01:38:03PM +0300, Mika Westerberg wrote:
> + /*
> + * The ACPI SPT000* devices are only meant for development and
> + * testing. Systems used in production should have a proper ACPI
> + * description of the connected peripheral and they should also use
> + * a proper driver instead of poking directly to the SPI bus.
> + */
> + if (has_acpi_companion(&spi->dev))
> + dev_warn(&spi->dev, "do not use this driver in production systems!\n");
> +
This is fine for now since all the ACPI devices are dummy ones but as
soon as someone comes up with an actual ACPI ID for something that
should be managed via spidev it'll need changing...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] spi: spidev: Add ACPI probing support
[not found] ` <20160704125600.GB6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2016-07-04 13:08 ` Mika Westerberg
[not found] ` <20160704130806.GB23527-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2016-07-04 13:08 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Jarkko Nikula
On Mon, Jul 04, 2016 at 02:56:00PM +0200, Mark Brown wrote:
> On Mon, Jul 04, 2016 at 01:38:03PM +0300, Mika Westerberg wrote:
>
> > + /*
> > + * The ACPI SPT000* devices are only meant for development and
> > + * testing. Systems used in production should have a proper ACPI
> > + * description of the connected peripheral and they should also use
> > + * a proper driver instead of poking directly to the SPI bus.
> > + */
> > + if (has_acpi_companion(&spi->dev))
> > + dev_warn(&spi->dev, "do not use this driver in production systems!\n");
> > +
>
> This is fine for now since all the ACPI devices are dummy ones but as
> soon as someone comes up with an actual ACPI ID for something that
> should be managed via spidev it'll need changing...
Sure. That's why the comment above also mentions SPT000* there.
--
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] 6+ messages in thread
* Re: [PATCH] spi: spidev: Add ACPI probing support
[not found] ` <20160704130806.GB23527-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2016-07-04 13:20 ` Mark Brown
[not found] ` <20160704132048.GC6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2016-07-04 13:20 UTC (permalink / raw)
To: Mika Westerberg; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Jarkko Nikula
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
On Mon, Jul 04, 2016 at 04:08:06PM +0300, Mika Westerberg wrote:
> On Mon, Jul 04, 2016 at 02:56:00PM +0200, Mark Brown wrote:
> > This is fine for now since all the ACPI devices are dummy ones but as
> > soon as someone comes up with an actual ACPI ID for something that
> > should be managed via spidev it'll need changing...
> Sure. That's why the comment above also mentions SPT000* there.
I'm trying to suggest that it'd be nice to write the code to check the
IDs and only warns when appropriate. :)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] spi: spidev: Add ACPI probing support
[not found] ` <20160704132048.GC6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2016-07-04 13:27 ` Mika Westerberg
[not found] ` <20160704132736.GD23527-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2016-07-04 13:27 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Jarkko Nikula
On Mon, Jul 04, 2016 at 03:20:48PM +0200, Mark Brown wrote:
> On Mon, Jul 04, 2016 at 04:08:06PM +0300, Mika Westerberg wrote:
> > On Mon, Jul 04, 2016 at 02:56:00PM +0200, Mark Brown wrote:
>
> > > This is fine for now since all the ACPI devices are dummy ones but as
> > > soon as someone comes up with an actual ACPI ID for something that
> > > should be managed via spidev it'll need changing...
>
> > Sure. That's why the comment above also mentions SPT000* there.
>
> I'm trying to suggest that it'd be nice to write the code to check the
> IDs and only warns when appropriate. :)
Ah right, got it now.
I'll update the patch then to check the IDs first.
--
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] 6+ messages in thread
* Re: [PATCH] spi: spidev: Add ACPI probing support
[not found] ` <20160704132736.GD23527-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2016-07-04 13:29 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2016-07-04 13:29 UTC (permalink / raw)
To: Mika Westerberg; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Jarkko Nikula
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
On Mon, Jul 04, 2016 at 04:27:36PM +0300, Mika Westerberg wrote:
> On Mon, Jul 04, 2016 at 03:20:48PM +0200, Mark Brown wrote:
> > I'm trying to suggest that it'd be nice to write the code to check the
> > IDs and only warns when appropriate. :)
> Ah right, got it now.
> I'll update the patch then to check the IDs first.
Thanks.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-04 13:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-04 10:38 [PATCH] spi: spidev: Add ACPI probing support Mika Westerberg
[not found] ` <1467628683-5783-1-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-07-04 12:56 ` Mark Brown
[not found] ` <20160704125600.GB6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-04 13:08 ` Mika Westerberg
[not found] ` <20160704130806.GB23527-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2016-07-04 13:20 ` Mark Brown
[not found] ` <20160704132048.GC6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-04 13:27 ` Mika Westerberg
[not found] ` <20160704132736.GD23527-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2016-07-04 13:29 ` Mark Brown
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).