From 1b15a5f93bbd9a6f5346cfa449720a7e32115f86 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Thu, 22 Mar 2012 21:00:52 +0100 Subject: mtd: docg3 refactor cascade floors structure Group floors into a common cascade structure. This will provide a common structure to store common data to all cascaded docg3 chips, like IO addressing, locking protection. Signed-off-by: Robert Jarzmik Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- drivers/mtd/devices/docg3.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/devices/docg3.h') diff --git a/drivers/mtd/devices/docg3.h b/drivers/mtd/devices/docg3.h index db0da436b493..642e60667cfd 100644 --- a/drivers/mtd/devices/docg3.h +++ b/drivers/mtd/devices/docg3.h @@ -22,6 +22,8 @@ #ifndef _MTD_DOCG3_H #define _MTD_DOCG3_H +#include + /* * Flash memory areas : * - 0x0000 .. 0x07ff : IPL @@ -266,10 +268,22 @@ */ #define DOC_LAYOUT_DPS_KEY_LENGTH 8 +/** + * struct docg3_cascade - Cascade of 1 to 4 docg3 chips + * @floors: floors (ie. one physical docg3 chip is one floor) + * @base: IO space to access all chips in the cascade + * @bch: the BCH correcting control structure + */ +struct docg3_cascade { + struct mtd_info *floors[DOC_MAX_NBFLOORS]; + void __iomem *base; + struct bch_control *bch; +}; + /** * struct docg3 - DiskOnChip driver private data * @dev: the device currently under control - * @base: mapped IO space + * @cascade: the cascade this device belongs to * @device_id: number of the cascaded DoCG3 device (0, 1, 2 or 3) * @if_cfg: if true, reads are on 16bits, else reads are on 8bits @@ -287,7 +301,7 @@ */ struct docg3 { struct device *dev; - void __iomem *base; + struct docg3_cascade *cascade; unsigned int device_id:4; unsigned int if_cfg:1; unsigned int reliable:2; -- cgit v1.2.3 From 7b0e67f604e1829e5292e1ad7743eb18dc42ea7c Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Thu, 22 Mar 2012 21:00:53 +0100 Subject: mtd: docg3 add protection against concurrency As docg3 is intolerant against reentrancy, especially because of its weird register access (ie. a register read is performed by a first register write), each access to the docg3 IO space must be locked. Lock the IO space with a mutex, shared by all chips on the same cascade, as they all share the same IO space. Signed-off-by: Robert Jarzmik Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- drivers/mtd/devices/docg3.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/mtd/devices/docg3.h') diff --git a/drivers/mtd/devices/docg3.h b/drivers/mtd/devices/docg3.h index 642e60667cfd..19fb93f96a3a 100644 --- a/drivers/mtd/devices/docg3.h +++ b/drivers/mtd/devices/docg3.h @@ -273,11 +273,13 @@ * @floors: floors (ie. one physical docg3 chip is one floor) * @base: IO space to access all chips in the cascade * @bch: the BCH correcting control structure + * @lock: lock to protect docg3 IO space from concurrent accesses */ struct docg3_cascade { struct mtd_info *floors[DOC_MAX_NBFLOORS]; void __iomem *base; struct bch_control *bch; + struct mutex lock; }; /** -- cgit v1.2.3