[PATCH] spi: add spi_set_drvdata() and spi_get_drvdata()
authorBen Dooks <ben@fluff.org>
Mon, 12 Feb 2007 08:52:41 +0000 (00:52 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 12 Feb 2007 17:48:30 +0000 (09:48 -0800)
Add wrappers for getting and setting the driver data using spi_device
instead of using dev_{get|set}_drvdata with &spi->dev, to mirror the
platform_{get|set}_drvdata.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/spi/spi-summary
include/linux/spi/spi.h

index 72795796b13d64a4667ab233ebded8c2bcad4297..81b6230d3d223629644d6f71947144141f009e98 100644 (file)
@@ -312,7 +312,7 @@ might look like this unless you're creating a class_device:
                chip = kzalloc(sizeof *chip, GFP_KERNEL);
                if (!chip)
                        return -ENOMEM;
-               dev_set_drvdata(&spi->dev, chip);
+               spi_set_drvdata(spi, chip);
 
                ... etc
                return 0;
index 176f6e36dbfacbf4279593500a56c83230947095..e25fcae89d3bf63d15c5e5c2cc9c19c816980dac 100644 (file)
@@ -114,6 +114,17 @@ static inline void spi_set_ctldata(struct spi_device *spi, void *state)
        spi->controller_state = state;
 }
 
+/* device driver data */
+
+static inline void spi_set_drvdata(struct spi_device *spi, void *data)
+{
+       dev_set_drvdata(&spi->dev, data);
+}
+
+static inline void *spi_get_drvdata(struct spi_device *spi)
+{
+       return dev_get_drvdata(&spi->dev);
+}
 
 struct spi_message;