mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-07-01 23:53:16 -04:00
spi: spidev: Warn loudly if instantiated from DT as "spidev"
Since spidev is a detail of how Linux controls a device rather than a description of the hardware in the system we should never have a node described as "spidev" in DT, any SPI device could be a spidev so this is just not a useful description. In order to help prevent users from writing such device trees generate a warning if spidev is instantiated as a DT node without an ID in the match table. Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f20fbaad76
commit
956b200a84
1 changed files with 19 additions and 7 deletions
|
@ -703,6 +703,14 @@ static const struct file_operations spidev_fops = {
|
||||||
|
|
||||||
static struct class *spidev_class;
|
static struct class *spidev_class;
|
||||||
|
|
||||||
|
#ifdef CONFIG_OF
|
||||||
|
static const struct of_device_id spidev_dt_ids[] = {
|
||||||
|
{ .compatible = "rohm,dh2228fv" },
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static int spidev_probe(struct spi_device *spi)
|
static int spidev_probe(struct spi_device *spi)
|
||||||
|
@ -711,6 +719,17 @@ static int spidev_probe(struct spi_device *spi)
|
||||||
int status;
|
int status;
|
||||||
unsigned long minor;
|
unsigned long minor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* spidev should never be referenced in DT without a specific
|
||||||
|
* compatbile string, it is a Linux implementation thing
|
||||||
|
* rather than a description of the hardware.
|
||||||
|
*/
|
||||||
|
if (spi->dev.of_node && !of_match_device(spidev_dt_ids, &spi->dev)) {
|
||||||
|
dev_err(&spi->dev, "buggy DT: spidev listed directly in DT\n");
|
||||||
|
WARN_ON(spi->dev.of_node &&
|
||||||
|
!of_match_device(spidev_dt_ids, &spi->dev));
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate driver data */
|
/* Allocate driver data */
|
||||||
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
|
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
|
||||||
if (!spidev)
|
if (!spidev)
|
||||||
|
@ -777,13 +796,6 @@ static int spidev_remove(struct spi_device *spi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id spidev_dt_ids[] = {
|
|
||||||
{ .compatible = "rohm,dh2228fv" },
|
|
||||||
{},
|
|
||||||
};
|
|
||||||
|
|
||||||
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
|
|
||||||
|
|
||||||
static struct spi_driver spidev_spi_driver = {
|
static struct spi_driver spidev_spi_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "spidev",
|
.name = "spidev",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue