提交 766f271a 编写于 作者: I Ian Munsie 提交者: David Woodhouse

mtd: Fix endianness issues from device tree

This patch adds the appropriate conversions to correct the endianness
issues in the MTD driver whenever it accesses the device tree (which is
always big endian).
Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 d86fbdb8
...@@ -50,7 +50,7 @@ static int parse_obsolete_partitions(struct platform_device *dev, ...@@ -50,7 +50,7 @@ static int parse_obsolete_partitions(struct platform_device *dev,
{ {
int i, plen, nr_parts; int i, plen, nr_parts;
const struct { const struct {
u32 offset, len; __be32 offset, len;
} *part; } *part;
const char *names; const char *names;
...@@ -69,9 +69,9 @@ static int parse_obsolete_partitions(struct platform_device *dev, ...@@ -69,9 +69,9 @@ static int parse_obsolete_partitions(struct platform_device *dev,
names = of_get_property(dp, "partition-names", &plen); names = of_get_property(dp, "partition-names", &plen);
for (i = 0; i < nr_parts; i++) { for (i = 0; i < nr_parts; i++) {
info->parts[i].offset = part->offset; info->parts[i].offset = be32_to_cpu(part->offset);
info->parts[i].size = part->len & ~1; info->parts[i].size = be32_to_cpu(part->len) & ~1;
if (part->len & 1) /* bit 0 set signifies read only partition */ if (be32_to_cpu(part->len) & 1) /* bit 0 set signifies read only partition */
info->parts[i].mask_flags = MTD_WRITEABLE; info->parts[i].mask_flags = MTD_WRITEABLE;
if (names && (plen > 0)) { if (names && (plen > 0)) {
...@@ -226,11 +226,11 @@ static int __devinit of_flash_probe(struct platform_device *dev, ...@@ -226,11 +226,11 @@ static int __devinit of_flash_probe(struct platform_device *dev,
struct resource res; struct resource res;
struct of_flash *info; struct of_flash *info;
const char *probe_type = match->data; const char *probe_type = match->data;
const u32 *width; const __be32 *width;
int err; int err;
int i; int i;
int count; int count;
const u32 *p; const __be32 *p;
int reg_tuple_size; int reg_tuple_size;
struct mtd_info **mtd_list = NULL; struct mtd_info **mtd_list = NULL;
resource_size_t res_size; resource_size_t res_size;
...@@ -294,7 +294,7 @@ static int __devinit of_flash_probe(struct platform_device *dev, ...@@ -294,7 +294,7 @@ static int __devinit of_flash_probe(struct platform_device *dev,
info->list[i].map.name = dev_name(&dev->dev); info->list[i].map.name = dev_name(&dev->dev);
info->list[i].map.phys = res.start; info->list[i].map.phys = res.start;
info->list[i].map.size = res_size; info->list[i].map.size = res_size;
info->list[i].map.bankwidth = *width; info->list[i].map.bankwidth = be32_to_cpup(width);
err = -ENOMEM; err = -ENOMEM;
info->list[i].map.virt = ioremap(info->list[i].map.phys, info->list[i].map.virt = ioremap(info->list[i].map.phys,
......
...@@ -222,7 +222,7 @@ static int __devinit fun_probe(struct platform_device *ofdev, ...@@ -222,7 +222,7 @@ static int __devinit fun_probe(struct platform_device *ofdev,
{ {
struct fsl_upm_nand *fun; struct fsl_upm_nand *fun;
struct resource io_res; struct resource io_res;
const uint32_t *prop; const __be32 *prop;
int rnb_gpio; int rnb_gpio;
int ret; int ret;
int size; int size;
...@@ -270,7 +270,7 @@ static int __devinit fun_probe(struct platform_device *ofdev, ...@@ -270,7 +270,7 @@ static int __devinit fun_probe(struct platform_device *ofdev,
goto err1; goto err1;
} }
for (i = 0; i < fun->mchip_count; i++) for (i = 0; i < fun->mchip_count; i++)
fun->mchip_offsets[i] = prop[i]; fun->mchip_offsets[i] = be32_to_cpu(prop[i]);
} else { } else {
fun->mchip_count = 1; fun->mchip_count = 1;
} }
...@@ -295,13 +295,13 @@ static int __devinit fun_probe(struct platform_device *ofdev, ...@@ -295,13 +295,13 @@ static int __devinit fun_probe(struct platform_device *ofdev,
prop = of_get_property(ofdev->dev.of_node, "chip-delay", NULL); prop = of_get_property(ofdev->dev.of_node, "chip-delay", NULL);
if (prop) if (prop)
fun->chip_delay = *prop; fun->chip_delay = be32_to_cpup(prop);
else else
fun->chip_delay = 50; fun->chip_delay = 50;
prop = of_get_property(ofdev->dev.of_node, "fsl,upm-wait-flags", &size); prop = of_get_property(ofdev->dev.of_node, "fsl,upm-wait-flags", &size);
if (prop && size == sizeof(uint32_t)) if (prop && size == sizeof(uint32_t))
fun->wait_flags = *prop; fun->wait_flags = be32_to_cpup(prop);
else else
fun->wait_flags = FSL_UPM_WAIT_RUN_PATTERN | fun->wait_flags = FSL_UPM_WAIT_RUN_PATTERN |
FSL_UPM_WAIT_WRITE_BYTE; FSL_UPM_WAIT_WRITE_BYTE;
......
...@@ -663,7 +663,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op, ...@@ -663,7 +663,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op,
#endif #endif
struct nand_chip *chip; struct nand_chip *chip;
unsigned long regs_paddr, regs_size; unsigned long regs_paddr, regs_size;
const uint *chips_no; const __be32 *chips_no;
int resettime = 0; int resettime = 0;
int retval = 0; int retval = 0;
int rev, len; int rev, len;
...@@ -806,7 +806,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op, ...@@ -806,7 +806,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op,
} }
/* Detect NAND chips */ /* Detect NAND chips */
if (nand_scan(mtd, *chips_no)) { if (nand_scan(mtd, be32_to_cpup(chips_no))) {
dev_err(dev, "NAND Flash not found !\n"); dev_err(dev, "NAND Flash not found !\n");
devm_free_irq(dev, prv->irq, mtd); devm_free_irq(dev, prv->irq, mtd);
retval = -ENXIO; retval = -ENXIO;
......
...@@ -229,7 +229,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev, ...@@ -229,7 +229,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct ndfc_controller *ndfc = &ndfc_ctrl; struct ndfc_controller *ndfc = &ndfc_ctrl;
const u32 *reg; const __be32 *reg;
u32 ccr; u32 ccr;
int err, len; int err, len;
...@@ -244,7 +244,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev, ...@@ -244,7 +244,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev,
dev_err(&ofdev->dev, "unable read reg property (%d)\n", len); dev_err(&ofdev->dev, "unable read reg property (%d)\n", len);
return -ENOENT; return -ENOENT;
} }
ndfc->chip_select = reg[0]; ndfc->chip_select = be32_to_cpu(reg[0]);
ndfc->ndfcbase = of_iomap(ofdev->dev.of_node, 0); ndfc->ndfcbase = of_iomap(ofdev->dev.of_node, 0);
if (!ndfc->ndfcbase) { if (!ndfc->ndfcbase) {
...@@ -257,7 +257,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev, ...@@ -257,7 +257,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev,
/* It is ok if ccr does not exist - just default to 0 */ /* It is ok if ccr does not exist - just default to 0 */
reg = of_get_property(ofdev->dev.of_node, "ccr", NULL); reg = of_get_property(ofdev->dev.of_node, "ccr", NULL);
if (reg) if (reg)
ccr |= *reg; ccr |= be32_to_cpup(reg);
out_be32(ndfc->ndfcbase + NDFC_CCR, ccr); out_be32(ndfc->ndfcbase + NDFC_CCR, ccr);
...@@ -265,7 +265,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev, ...@@ -265,7 +265,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev,
reg = of_get_property(ofdev->dev.of_node, "bank-settings", NULL); reg = of_get_property(ofdev->dev.of_node, "bank-settings", NULL);
if (reg) { if (reg) {
int offset = NDFC_BCFG0 + (ndfc->chip_select << 2); int offset = NDFC_BCFG0 + (ndfc->chip_select << 2);
out_be32(ndfc->ndfcbase + offset, *reg); out_be32(ndfc->ndfcbase + offset, be32_to_cpup(reg));
} }
err = ndfc_chip_init(ndfc, ofdev->dev.of_node); err = ndfc_chip_init(ndfc, ofdev->dev.of_node);
......
...@@ -44,7 +44,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev, ...@@ -44,7 +44,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
pp = NULL; pp = NULL;
i = 0; i = 0;
while ((pp = of_get_next_child(node, pp))) { while ((pp = of_get_next_child(node, pp))) {
const u32 *reg; const __be32 *reg;
int len; int len;
reg = of_get_property(pp, "reg", &len); reg = of_get_property(pp, "reg", &len);
...@@ -53,8 +53,8 @@ int __devinit of_mtd_parse_partitions(struct device *dev, ...@@ -53,8 +53,8 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
continue; continue;
} }
(*pparts)[i].offset = reg[0]; (*pparts)[i].offset = be32_to_cpu(reg[0]);
(*pparts)[i].size = reg[1]; (*pparts)[i].size = be32_to_cpu(reg[1]);
partname = of_get_property(pp, "label", &len); partname = of_get_property(pp, "label", &len);
if (!partname) if (!partname)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册