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

Commit 67c20cfb authored by Kristina Martšenko's avatar Kristina Martšenko Committed by Greg Kroah-Hartman
Browse files

staging: goldfish: switch from spinlock to mutex



Use a mutex instead of a spinlock in goldfish_nand.c, as suggested by
the TODO list.

Signed-off-by: default avatarKristina Martšenko <kristina.martsenko@gmail.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dff22267
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -5,7 +5,6 @@ Audio


NAND
NAND
----
----
- Switch from spinlock to mutex
- Remove excess checking of parameters in calls
- Remove excess checking of parameters in calls
- Use dma coherent memory not kmalloc/__pa for the memory (this is just
- Use dma coherent memory not kmalloc/__pa for the memory (this is just
  a cleanliness issue not a correctness one)
  a cleanliness issue not a correctness one)
+7 −8
Original line number Original line Diff line number Diff line
@@ -24,13 +24,14 @@
#include <linux/vmalloc.h>
#include <linux/vmalloc.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/mtd.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>


#include <asm/div64.h>
#include <asm/div64.h>


#include "goldfish_nand_reg.h"
#include "goldfish_nand_reg.h"


struct goldfish_nand {
struct goldfish_nand {
	spinlock_t              lock;
	struct mutex            lock;
	unsigned char __iomem  *base;
	unsigned char __iomem  *base;
	struct cmd_params       *cmd_params;
	struct cmd_params       *cmd_params;
	size_t                  mtd_count;
	size_t                  mtd_count;
@@ -77,10 +78,9 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
{
{
	struct goldfish_nand *nand = mtd->priv;
	struct goldfish_nand *nand = mtd->priv;
	u32 rv;
	u32 rv;
	unsigned long irq_flags;
	unsigned char __iomem  *base = nand->base;
	unsigned char __iomem  *base = nand->base;


	spin_lock_irqsave(&nand->lock, irq_flags);
	mutex_lock(&nand->lock);
	if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) {
	if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) {
		writel(mtd - nand->mtd, base + NAND_DEV);
		writel(mtd - nand->mtd, base + NAND_DEV);
		writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
		writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
@@ -90,7 +90,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
		writel(cmd, base + NAND_COMMAND);
		writel(cmd, base + NAND_COMMAND);
		rv = readl(base + NAND_RESULT);
		rv = readl(base + NAND_RESULT);
	}
	}
	spin_unlock_irqrestore(&nand->lock, irq_flags);
	mutex_unlock(&nand->lock);
	return rv;
	return rv;
}
}


@@ -307,12 +307,11 @@ static int goldfish_nand_init_device(struct platform_device *pdev,
	u32 name_len;
	u32 name_len;
	u32 result;
	u32 result;
	u32 flags;
	u32 flags;
	unsigned long irq_flags;
	unsigned char __iomem  *base = nand->base;
	unsigned char __iomem  *base = nand->base;
	struct mtd_info *mtd = &nand->mtd[id];
	struct mtd_info *mtd = &nand->mtd[id];
	char *name;
	char *name;


	spin_lock_irqsave(&nand->lock, irq_flags);
	mutex_lock(&nand->lock);
	writel(id, base + NAND_DEV);
	writel(id, base + NAND_DEV);
	flags = readl(base + NAND_DEV_FLAGS);
	flags = readl(base + NAND_DEV_FLAGS);
	name_len = readl(base + NAND_DEV_NAME_LEN);
	name_len = readl(base + NAND_DEV_NAME_LEN);
@@ -329,7 +328,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev,
		"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",
		       id, mtd->size, mtd->writesize,
		       id, mtd->size, mtd->writesize,
		       mtd->oobsize, mtd->erasesize);
		       mtd->oobsize, mtd->erasesize);
	spin_unlock_irqrestore(&nand->lock, irq_flags);
	mutex_unlock(&nand->lock);


	mtd->priv = nand;
	mtd->priv = nand;


@@ -405,7 +404,7 @@ static int goldfish_nand_probe(struct platform_device *pdev)
	if (nand == NULL)
	if (nand == NULL)
		return -ENOMEM;
		return -ENOMEM;


	spin_lock_init(&nand->lock);
	mutex_init(&nand->lock);
	nand->base = base;
	nand->base = base;
	nand->mtd_count = num_dev;
	nand->mtd_count = num_dev;
	platform_set_drvdata(pdev, nand);
	platform_set_drvdata(pdev, nand);