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

Commit 0dd5235f authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse
Browse files

mtd: harmonize mtd_point interface implementation



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: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent c3faac4a
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -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,
static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,
		size_t *retlen, void **virt, resource_size_t *phys)
		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;
	*virt = mtd->priv + from;
	*retlen = len;
	*retlen = len;
	return 0;
	return 0;
+0 −4
Original line number Original line Diff line number Diff line
@@ -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,
static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
		size_t *retlen, void **virt, resource_size_t *phys)
		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;
	*virt = mtd->priv + from;
	*retlen = len;
	*retlen = len;
	return 0;
	return 0;
+0 −4
Original line number Original line Diff line number Diff line
@@ -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);
	printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len);
#endif
#endif


	/* can we return a physical address with this driver? */
	if (phys)
		return -EINVAL;

	soff_hi = from & ~(priv->asize - 1);
	soff_hi = from & ~(priv->asize - 1);
	soff_lo = from & (priv->asize - 1);
	soff_lo = from & (priv->asize - 1);


+0 −3
Original line number Original line Diff line number Diff line
@@ -99,9 +99,6 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
{
{
	slram_priv_t *priv = mtd->priv;
	slram_priv_t *priv = mtd->priv;


	/* can we return a physical address with this driver? */
	if (phys)
		return -EINVAL;
	*virt = priv->start + from;
	*virt = priv->start + from;
	*retlen = len;
	*retlen = len;
	return(0);
	return(0);
+3 −0
Original line number Original line Diff line number Diff line
@@ -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)
	      void **virt, resource_size_t *phys)
{
{
	*retlen = 0;
	*retlen = 0;
	*virt = NULL;
	if (phys)
		*phys = 0;
	if (!mtd->_point)
	if (!mtd->_point)
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
	if (from < 0 || from > mtd->size || len > mtd->size - from)
	if (from < 0 || from > mtd->size || len > mtd->size - from)