|
@@ -100,11 +100,11 @@ static int goldfish_nand_erase(struct mtd_info *mtd, struct erase_info *instr)
|
|
{
|
|
{
|
|
loff_t ofs = instr->addr;
|
|
loff_t ofs = instr->addr;
|
|
u32 len = instr->len;
|
|
u32 len = instr->len;
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (ofs + len > mtd->size)
|
|
if (ofs + len > mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
- rem = do_div(ofs, mtd->writesize);
|
|
|
|
|
|
+ ofs = div_s64_rem(ofs, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
ofs *= (mtd->writesize + mtd->oobsize);
|
|
ofs *= (mtd->writesize + mtd->oobsize);
|
|
@@ -133,7 +133,7 @@ invalid_arg:
|
|
static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs,
|
|
static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs,
|
|
struct mtd_oob_ops *ops)
|
|
struct mtd_oob_ops *ops)
|
|
{
|
|
{
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (ofs + ops->len > mtd->size)
|
|
if (ofs + ops->len > mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
@@ -142,7 +142,7 @@ static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs,
|
|
if (ops->ooblen + ops->ooboffs > mtd->oobsize)
|
|
if (ops->ooblen + ops->ooboffs > mtd->oobsize)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
|
|
|
|
- rem = do_div(ofs, mtd->writesize);
|
|
|
|
|
|
+ ofs = div_s64_rem(ofs, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
ofs *= (mtd->writesize + mtd->oobsize);
|
|
ofs *= (mtd->writesize + mtd->oobsize);
|
|
@@ -165,7 +165,7 @@ invalid_arg:
|
|
static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs,
|
|
static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs,
|
|
struct mtd_oob_ops *ops)
|
|
struct mtd_oob_ops *ops)
|
|
{
|
|
{
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (ofs + ops->len > mtd->size)
|
|
if (ofs + ops->len > mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
@@ -174,7 +174,7 @@ static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs,
|
|
if (ops->ooblen + ops->ooboffs > mtd->oobsize)
|
|
if (ops->ooblen + ops->ooboffs > mtd->oobsize)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
|
|
|
|
- rem = do_div(ofs, mtd->writesize);
|
|
|
|
|
|
+ ofs = div_s64_rem(ofs, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
ofs *= (mtd->writesize + mtd->oobsize);
|
|
ofs *= (mtd->writesize + mtd->oobsize);
|
|
@@ -197,12 +197,12 @@ invalid_arg:
|
|
static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
|
|
static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
|
|
size_t *retlen, u_char *buf)
|
|
size_t *retlen, u_char *buf)
|
|
{
|
|
{
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (from + len > mtd->size)
|
|
if (from + len > mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
|
|
|
|
- rem = do_div(from, mtd->writesize);
|
|
|
|
|
|
+ from = div_s64_rem(from, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
from *= (mtd->writesize + mtd->oobsize);
|
|
from *= (mtd->writesize + mtd->oobsize);
|
|
@@ -219,12 +219,12 @@ invalid_arg:
|
|
static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
|
static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
|
size_t *retlen, const u_char *buf)
|
|
size_t *retlen, const u_char *buf)
|
|
{
|
|
{
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (to + len > mtd->size)
|
|
if (to + len > mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
|
|
|
|
- rem = do_div(to, mtd->writesize);
|
|
|
|
|
|
+ to = div_s64_rem(to, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
to *= (mtd->writesize + mtd->oobsize);
|
|
to *= (mtd->writesize + mtd->oobsize);
|
|
@@ -240,12 +240,12 @@ invalid_arg:
|
|
|
|
|
|
static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs)
|
|
static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs)
|
|
{
|
|
{
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (ofs >= mtd->size)
|
|
if (ofs >= mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
|
|
|
|
- rem = do_div(ofs, mtd->erasesize);
|
|
|
|
|
|
+ ofs = div_s64_rem(ofs, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
ofs *= mtd->erasesize / mtd->writesize;
|
|
ofs *= mtd->erasesize / mtd->writesize;
|
|
@@ -261,12 +261,12 @@ invalid_arg:
|
|
|
|
|
|
static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
|
|
static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
|
|
{
|
|
{
|
|
- u32 rem;
|
|
|
|
|
|
+ s32 rem;
|
|
|
|
|
|
if (ofs >= mtd->size)
|
|
if (ofs >= mtd->size)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
|
|
|
|
- rem = do_div(ofs, mtd->erasesize);
|
|
|
|
|
|
+ ofs = div_s64_rem(ofs, mtd->writesize, &rem);
|
|
if (rem)
|
|
if (rem)
|
|
goto invalid_arg;
|
|
goto invalid_arg;
|
|
ofs *= mtd->erasesize / mtd->writesize;
|
|
ofs *= mtd->erasesize / mtd->writesize;
|
|
@@ -321,7 +321,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev,
|
|
mtd->oobavail = mtd->oobsize;
|
|
mtd->oobavail = mtd->oobsize;
|
|
mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) /
|
|
mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) /
|
|
(mtd->writesize + mtd->oobsize) * mtd->writesize;
|
|
(mtd->writesize + mtd->oobsize) * mtd->writesize;
|
|
- do_div(mtd->size, mtd->writesize + mtd->oobsize);
|
|
|
|
|
|
+ mtd->size = div_s64(mtd->size, mtd->writesize + mtd->oobsize);
|
|
mtd->size *= mtd->writesize;
|
|
mtd->size *= mtd->writesize;
|
|
dev_dbg(&pdev->dev,
|
|
dev_dbg(&pdev->dev,
|
|
"goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n",
|
|
"goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n",
|