Skip to contentSkip to conversation

spi/pl022: make sure the chip_info dev pointer is set

PATCH New Linus Walleij 2 participants 3 messages Sep 30, 2010 – Oct 1, 2010 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi/pl022: make sure the chip_info dev pointer is set

We forgot to set the pointer back to the device if the user supplied all device settings, leading to crashing debug prints as controller data is verified.

---
 drivers/spi/amba-pl022.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/spi/amba-pl022.c +2 -0
index 4c37c4e..90a7e5d 100644
@@ -1574,6 +1574,8 @@ static int pl022_setup(struct spi_device *spi)
 		chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX;
 		chip_info->cs_control = null_cs_control;
 	} else {
+		/* Users should not set this field */
+		chip_info->dev = &spi->dev;
 		dev_dbg(&spi->dev,
 			"using user supplied controller_data settings\n");
 	}
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 spi/pl022: make sure the chip_info dev pointer is set

Quoted 14 lines · Linus Walleij

We forgot to set the pointer back to the device if the user supplied all device settings, leading to crashing debug prints as controller data is verified.

---
?drivers/spi/amba-pl022.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

drivers/spi/amba-pl022.c +0 -0
index 4c37c4e..90a7e5d 100644

drivers/spi/amba-pl022.c static int pl022_setup(struct spi_device *spi) · line 1581

Quoted 8 lines
drivers/spi/amba-pl022.c +2 -0
@@ -1574,6 +1574,8 @@ static int pl022_setup(struct spi_device *spi)
 ? ? ? ? ? ? ? ?chip_info->duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX;
 ? ? ? ? ? ? ? ?chip_info->cs_control = null_cs_control;
 ? ? ? ?} else {
+ ? ? ? ? ? ? ? /* Users should not set this field */
+ ? ? ? ? ? ? ? chip_info->dev = &spi->dev;
 ? ? ? ? ? ? ? ?dev_dbg(&spi->dev,
 ? ? ? ? ? ? ? ? ? ? ? ?"using user supplied controller_data settings\n");
 ? ? ? ?}

Nack. data passed to a driver via the controller_data must be immutable as far as the device driver is concerned. I realize that this has been rather sloppy in the past; but I'm enforcing it now. controller_data is static data passed to the driver, and the 'dev' member of pl022_config_chip needs to be removed.

So, instead of setting the dev pointer here; this code should *remove* the dev pointer from the structure and use spi->dev directly instead. I've looked at the driver, and I don't see any significant locations using chip_info that cannot get the chip_info directly from the struct spi_device.

g.

Quoted 4 lines

--
1.6.3.3

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#2 lore raw

PATCH 1/1 spi/pl022: make sure the chip_info dev pointer is set

Quoted 9 lines · Grant Likely

drivers/spi/amba-pl022.c static int pl022_setup(struct spi_device *spi) · line 1581

Quoted 6 lines
       } else {
drivers/spi/amba-pl022.c +2 -0
+               /* Users should not set this field */
+               chip_info->dev = &spi->dev;
               dev_dbg(&spi->dev,
                       "using user supplied controller_data settings\n");
       }

Nack. data passed to a driver via the controller_data must be immutable as far as the device driver is concerned.

I posted another patch removing it instead, that's obviously the right thing to do...

Yours,
Linus Walleij