mtd: harmonize mtd_point interface implementation
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 8 Feb 2012 13:13:26 +0000 (15:13 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 26 Mar 2012 23:32:11 +0000 (00:32 +0100)
Some MTD drivers return -EINVAL if the 'phys' parameter is not NULL, trying to
convey that they cannot return the physical address. However, this is not very
logical because they still can return the virtual address ('virt'). But some
drivers (lpddr) just ignore the 'phys' parameter instead, which is a more
logical thing to do.

Let's harmonize this and:

1. Always initialize 'virt' and 'phys' to 'NULL' in 'mtd_point()'.
2. Do not return an error if the physical address cannot be found.

So as a result, all drivers will set 'phys' to 'NULL' if it is not supported.
None of the 'mtd_point()' users use 'phys' anyway, so this should not break
anything. I guess we could also just delete this parameter later.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/devices/mtdram.c
drivers/mtd/devices/phram.c
drivers/mtd/devices/pmc551.c
drivers/mtd/devices/slram.c
drivers/mtd/mtdcore.c

index 0e0e6ed4443c1af40880184294c198235c41e87b..ec59d65897fbe38976112ab071741b6c2d3b9189 100644 (file)
@@ -43,9 +43,6 @@ static int ram_erase(struct mtd_info *mtd, struct erase_info *instr)
 static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,
                size_t *retlen, void **virt, resource_size_t *phys)
 {
-       /* can we return a physical address with this driver? */
-       if (phys)
-               return -EINVAL;
        *virt = mtd->priv + from;
        *retlen = len;
        return 0;
index d3474a48d097b4d08d8619310a85b06178ccb84b..9d2bf1741fb2905f346ed88878b469509c925fc5 100644 (file)
@@ -51,10 +51,6 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
 static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
                size_t *retlen, void **virt, resource_size_t *phys)
 {
-       /* can we return a physical address with this driver? */
-       if (phys)
-               return -EINVAL;
-
        *virt = mtd->priv + from;
        *retlen = len;
        return 0;
index 6269a434f304a69580dd13f24983f8a77cffd784..c4368ec39d5cd8ca4c323ffa675b8be2d0a6ab55 100644 (file)
@@ -205,10 +205,6 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
        printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len);
 #endif
 
-       /* can we return a physical address with this driver? */
-       if (phys)
-               return -EINVAL;
-
        soff_hi = from & ~(priv->asize - 1);
        soff_lo = from & (priv->asize - 1);
 
index 842e4890d771658cb850dce052102ba40427c21e..ccd39ff509b168895e34d4b0235eb79544f69ae1 100644 (file)
@@ -99,9 +99,6 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
 {
        slram_priv_t *priv = mtd->priv;
 
-       /* can we return a physical address with this driver? */
-       if (phys)
-               return -EINVAL;
        *virt = priv->start + from;
        *retlen = len;
        return(0);
index ead52b38849217c85ba643ef41f3a7e9228b91ac..b20346e9fecb7dd47bb01d6732c2d3d5711b972c 100644 (file)
@@ -706,6 +706,9 @@ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
              void **virt, resource_size_t *phys)
 {
        *retlen = 0;
+       *virt = NULL;
+       if (phys)
+               *phys = 0;
        if (!mtd->_point)
                return -EOPNOTSUPP;
        if (from < 0 || from > mtd->size || len > mtd->size - from)
This page took 0.047321 seconds and 5 git commands to generate.