diff mbox

[v2] m25p80: add support for a callback to platform code on successful device probe

Message ID 1281431104-17546-1-git-send-email-sudhakar.raj@ti.com (mailing list archive)
State Superseded
Headers show

Commit Message

Rajashekhara, Sudhakar Aug. 10, 2010, 9:05 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 81e49a9..b832091 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -765,6 +765,7 @@  static int __devinit m25p_probe(struct spi_device *spi)
 	struct m25p			*flash;
 	struct flash_info		*info;
 	unsigned			i;
+	int				ret;
 
 	/* Platform data helps sort out which chip type we have, as
 	 * well as how this board partitions it.  If we don't have
@@ -924,13 +925,23 @@  static int __devinit m25p_probe(struct spi_device *spi)
 					(long long)(parts[i].size >> 10));
 			}
 			flash->partitioned = 1;
-			return add_mtd_partitions(&flash->mtd, parts, nr_parts);
+			ret = add_mtd_partitions(&flash->mtd, parts, nr_parts);
+			if (!ret)
+				goto out;
+
+			return ret;
 		}
 	} else if (data && data->nr_parts)
 		dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
 				data->nr_parts, data->name);
 
-	return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0;
+	ret = add_mtd_device(&flash->mtd);
+
+out:
+	if (data->setup && !ret)
+		(data->setup)(&flash->mtd, (void *)data->context);
+
+	return (ret == 1) ? -ENODEV : 0;
 }
 
 
diff --git a/include/linux/spi/flash.h b/include/linux/spi/flash.h
index 3f22932..daa4875 100644
--- a/include/linux/spi/flash.h
+++ b/include/linux/spi/flash.h
@@ -24,6 +24,8 @@  struct flash_platform_data {
 	unsigned int	nr_parts;
 
 	char		*type;
+	void		(*setup)(struct mtd_info *, void *context);
+	void		*context;
 
 	/* we'll likely add more ... use JEDEC IDs, etc */
 };