From: Mark Brown <broonie@kernel.org>
To: Michal Suchanek <hramrach@gmail.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] spi: spidev: create spidev device for all spi slaves.
Date: Mon, 18 Jul 2016 23:59:52 +0100 [thread overview]
Message-ID: <20160718225952.GW30372@sirena.org.uk> (raw)
In-Reply-To: <5bfcceff7b6132cf3447f97c24d1646043224164.1468880530.git.hramrach@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]
On Tue, Jul 19, 2016 at 12:35:40AM +0200, Michal Suchanek wrote:
> config SPI_SPIDEV
> - tristate "User mode SPI device driver support"
> + bool "User mode SPI device driver support"
This is a step back, it would require spidev to be built in.
> - spin_lock_irq(&spidev->spi_lock);
> - spi = spi_dev_get(spidev->spi);
> - spin_unlock_irq(&spidev->spi_lock);
> + spi = filp->private_data;
> + spi = spi_dev_get(spi);
All this refactoring to move spidev about should've been a separate
patch, it's hard to find the actual content in here.
> - mutex_lock(&device_list_lock);
> + dev = bus_find_device(&spi_bus_type, NULL, (void *) inode->i_rdev,
> + spidev_devt_match);
...
> - dev_dbg(&spidev->spi->dev, "open/ENOMEM\n");
> + spi = to_spi_device(dev);
> +
> + mutex_lock(&spi->buf_lock);
> + spin_lock_irq(&spi->spidev_lock);
> + spi->spidev_users++;
> + spin_unlock_irq(&spi->spidev_lock);
This is broken, it will unconditionally create a spidev for any chip
select regardless of if there's any actual hardware there and (even more
importantly) regardless if that hardware is actually a SPI device. This
is not safe, especially given some of the ideas people seem to have for
userspaces.
I am getting completely fed up of saying this, it's not OK to just
expose pins to userspace when we have no idea what they are connected
to.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-07-18 23:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 22:35 [PATCH v3 0/3] Spidev usability patchset update Michal Suchanek
2016-07-18 22:35 ` [PATCH v3 1/3] spi: spidev: create spidev device for all spi slaves Michal Suchanek
2016-07-18 22:59 ` Mark Brown [this message]
2016-07-19 11:17 ` Michal Suchanek
2016-07-19 12:44 ` Mark Brown
2016-07-19 15:32 ` Michal Suchanek
2016-07-19 17:19 ` Mark Brown
2016-07-19 18:33 ` Michal Suchanek
2016-07-27 18:27 ` Mark Brown
2016-07-20 7:16 ` [lkp] " Fengguang Wu
2016-07-18 22:35 ` [PATCH v3 2/3] spi: of: allow instantiating slaves without a driver Michal Suchanek
2016-07-18 23:02 ` Mark Brown
2016-07-19 8:31 ` Michal Suchanek
2016-07-19 10:52 ` Mark Brown
2016-07-30 17:45 ` Michal Suchanek
2016-07-18 22:35 ` [PATCH v3 3/3] spi: core: allow creating devices without spi-max-frequency Michal Suchanek
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=20160718225952.GW30372@sirena.org.uk \
--to=broonie@kernel.org \
--cc=hramrach@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome