Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e4e6e3f authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse
Browse files

mtd: return error code from mtd_unpoint



The 'mtd_unpoint()' API function should be able to return an error code because
it may fail if you specify incorrect offset. This patch changes this MTD API
function and amends all the drivers correspondingly.

Also return '-EOPNOTSUPP' from 'mtd_unpoint()' when the '->unpoint()' method is
undefined. We do not really need this currently, but this just makes
sense to be consistent with 'mtd_point()'.

Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent e2414f4c
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private **

static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len,
		     size_t *retlen, void **virt, resource_size_t *phys);
static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len);

static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
@@ -1369,12 +1369,12 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,
	return 0;
}

static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
	struct map_info *map = mtd->priv;
	struct cfi_private *cfi = map->fldrv_priv;
	unsigned long ofs;
	int chipnum;
	int chipnum, err = 0;

	/* Now unlock the chip(s) POINT state */

@@ -1382,7 +1382,7 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
	chipnum = (from >> cfi->chipshift);
	ofs = from - (chipnum <<  cfi->chipshift);

	while (len) {
	while (len && !err) {
		unsigned long thislen;
		struct flchip *chip;

@@ -1400,8 +1400,10 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
			chip->ref_point_counter--;
			if(chip->ref_point_counter == 0)
				chip->state = FL_READY;
		} else
			printk(KERN_ERR "%s: Warning: unpoint called on non pointed region\n", map->name); /* Should this give an error? */
		} else {
			printk(KERN_ERR "%s: Error: unpoint called on non pointed region\n", map->name);
			err = -EINVAL;
		}

		put_chip(map, chip, chip->start);
		mutex_unlock(&chip->mutex);
@@ -1410,6 +1412,8 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
		ofs = 0;
		chipnum++;
	}

	return err;
}

static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)
+2 −1
Original line number Diff line number Diff line
@@ -60,8 +60,9 @@ static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,
	return 0;
}

static void ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
static int ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
	return 0;
}

/*
+2 −1
Original line number Diff line number Diff line
@@ -70,8 +70,9 @@ static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
	return 0;
}

static void phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
static int phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
	return 0;
}

static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
+2 −1
Original line number Diff line number Diff line
@@ -206,11 +206,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
	return 0;
}

static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
static int pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
#ifdef CONFIG_MTD_PMC551_DEBUG
	printk(KERN_DEBUG "pmc551_unpoint()\n");
#endif
	return 0;
}

static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
+3 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ static slram_mtd_list_t *slram_mtdlist = NULL;
static int slram_erase(struct mtd_info *, struct erase_info *);
static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **,
		resource_size_t *);
static void slram_unpoint(struct mtd_info *, loff_t, size_t);
static int slram_unpoint(struct mtd_info *, loff_t, size_t);
static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);

@@ -119,8 +119,9 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
	return(0);
}

static void slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
static int slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
	return 0;
}

static int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
Loading