]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/spi/spi.c
Merge branch 'x86/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux...
[linux-2.6-omap-h63xx.git] / drivers / spi / spi.c
index 5e5d29bb2dd56aa2b44efa6d2c854327a0c95701..ecca4a6a6f94a8b02e9d8143ae2be88d11bd00b5 100644 (file)
@@ -76,39 +76,33 @@ static int spi_uevent(struct device *dev, struct kobj_uevent_env *env)
 
 #ifdef CONFIG_PM
 
-/*
- * NOTE:  the suspend() method for an spi_master controller driver
- * should verify that all its child devices are marked as suspended;
- * suspend requests delivered through sysfs power/state files don't
- * enforce such constraints.
- */
 static int spi_suspend(struct device *dev, pm_message_t message)
 {
-       int                     value;
+       int                     value = 0;
        struct spi_driver       *drv = to_spi_driver(dev->driver);
 
-       if (!drv || !drv->suspend)
-               return 0;
-
        /* suspend will stop irqs and dma; no more i/o */
-       value = drv->suspend(to_spi_device(dev), message);
-       if (value == 0)
-               dev->power.power_state = message;
+       if (drv) {
+               if (drv->suspend)
+                       value = drv->suspend(to_spi_device(dev), message);
+               else
+                       dev_dbg(dev, "... can't suspend\n");
+       }
        return value;
 }
 
 static int spi_resume(struct device *dev)
 {
-       int                     value;
+       int                     value = 0;
        struct spi_driver       *drv = to_spi_driver(dev->driver);
 
-       if (!drv || !drv->resume)
-               return 0;
-
        /* resume may restart the i/o queue */
-       value = drv->resume(to_spi_device(dev));
-       if (value == 0)
-               dev->power.power_state = PMSG_ON;
+       if (drv) {
+               if (drv->resume)
+                       value = drv->resume(to_spi_device(dev));
+               else
+                       dev_dbg(dev, "... can't resume\n");
+       }
        return value;
 }
 
@@ -224,6 +218,8 @@ struct spi_device *spi_new_device(struct spi_master *master,
        if (!spi_master_get(master))
                return NULL;
 
+       WARN_ON(strlen(chip->modalias) >= sizeof(proxy->modalias));
+
        proxy = kzalloc(sizeof *proxy, GFP_KERNEL);
        if (!proxy) {
                dev_err(dev, "can't alloc dev for cs%d\n",
@@ -235,7 +231,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
        proxy->max_speed_hz = chip->max_speed_hz;
        proxy->mode = chip->mode;
        proxy->irq = chip->irq;
-       proxy->modalias = chip->modalias;
+       strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias));
 
        snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id,
                        "%s.%u", master->dev.bus_id,
@@ -508,7 +504,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
        struct device           *dev;
        struct spi_master       *master = NULL;
 
-       dev = class_find_device(&spi_master_class, &bus_num,
+       dev = class_find_device(&spi_master_class, NULL, &bus_num,
                                __spi_master_match);
        if (dev)
                master = container_of(dev, struct spi_master, dev);