Commit a6774aaf authored by Madhusudhan Chikkature's avatar Madhusudhan Chikkature Committed by Tony Lindgren

HDQ driver:replace semaphore with mutex

This patch replaces the usage of semaphore by mutex.
Signed-off-by: default avatarMadhusudhan Chikkature <madhu.cr@ti.com>
Acked-by: default avatarEvgeniy Polyakov <johnpol@2ka.mipt.ru>
Acked-by: default avatarFelipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent d98ff22b
...@@ -55,7 +55,7 @@ static int w1_id; ...@@ -55,7 +55,7 @@ static int w1_id;
struct hdq_data { struct hdq_data {
struct device *dev; struct device *dev;
void __iomem *hdq_base; void __iomem *hdq_base;
struct semaphore hdq_semlock; struct mutex hdq_mutex;
int hdq_usecount; int hdq_usecount;
struct clk *hdq_ick; struct clk *hdq_ick;
struct clk *hdq_fck; struct clk *hdq_fck;
...@@ -308,12 +308,12 @@ omap_hdq_break(struct hdq_data *hdq_data) ...@@ -308,12 +308,12 @@ omap_hdq_break(struct hdq_data *hdq_data)
u8 tmp_status; u8 tmp_status;
unsigned long irqflags; unsigned long irqflags;
ret = down_interruptible(&hdq_data->hdq_semlock); ret = mutex_lock_interruptible(&hdq_data->hdq_mutex);
if (ret < 0) if (ret < 0)
return -EINTR; return -EINTR;
if (!hdq_data->hdq_usecount) { if (!hdq_data->hdq_usecount) {
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -EINVAL; return -EINVAL;
} }
...@@ -335,7 +335,7 @@ omap_hdq_break(struct hdq_data *hdq_data) ...@@ -335,7 +335,7 @@ omap_hdq_break(struct hdq_data *hdq_data)
hdq_data->hdq_irqstatus, OMAP_HDQ_TIMEOUT); hdq_data->hdq_irqstatus, OMAP_HDQ_TIMEOUT);
if (ret < 0) { if (ret < 0) {
dev_dbg(hdq_data->dev, "wait interrupted"); dev_dbg(hdq_data->dev, "wait interrupted");
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -EINTR; return -EINTR;
} }
...@@ -346,7 +346,7 @@ omap_hdq_break(struct hdq_data *hdq_data) ...@@ -346,7 +346,7 @@ omap_hdq_break(struct hdq_data *hdq_data)
if (!(tmp_status & OMAP_HDQ_INT_STATUS_TIMEOUT)) { if (!(tmp_status & OMAP_HDQ_INT_STATUS_TIMEOUT)) {
dev_dbg(hdq_data->dev, "timeout waiting for TIMEOUT, %x", dev_dbg(hdq_data->dev, "timeout waiting for TIMEOUT, %x",
tmp_status); tmp_status);
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
/* /*
...@@ -361,7 +361,7 @@ omap_hdq_break(struct hdq_data *hdq_data) ...@@ -361,7 +361,7 @@ omap_hdq_break(struct hdq_data *hdq_data)
dev_dbg(hdq_data->dev, "timeout waiting INIT&GO bits" dev_dbg(hdq_data->dev, "timeout waiting INIT&GO bits"
"return to zero, %x", tmp_status); "return to zero, %x", tmp_status);
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return ret; return ret;
} }
...@@ -371,12 +371,12 @@ static int hdq_read_byte(struct hdq_data *hdq_data, u8 *val) ...@@ -371,12 +371,12 @@ static int hdq_read_byte(struct hdq_data *hdq_data, u8 *val)
u8 status; u8 status;
unsigned long irqflags; unsigned long irqflags;
ret = down_interruptible(&hdq_data->hdq_semlock); ret = mutex_lock_interruptible(&hdq_data->hdq_mutex);
if (ret < 0) if (ret < 0)
return -EINTR; return -EINTR;
if (!hdq_data->hdq_usecount) { if (!hdq_data->hdq_usecount) {
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -EINVAL; return -EINVAL;
} }
...@@ -407,13 +407,13 @@ static int hdq_read_byte(struct hdq_data *hdq_data, u8 *val) ...@@ -407,13 +407,13 @@ static int hdq_read_byte(struct hdq_data *hdq_data, u8 *val)
if (!(status & OMAP_HDQ_INT_STATUS_RXCOMPLETE)) { if (!(status & OMAP_HDQ_INT_STATUS_RXCOMPLETE)) {
dev_dbg(hdq_data->dev, "timeout waiting for" dev_dbg(hdq_data->dev, "timeout waiting for"
"RXCOMPLETE, %x", status); "RXCOMPLETE, %x", status);
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
} }
/* the data is ready. Read it in! */ /* the data is ready. Read it in! */
*val = hdq_reg_in(hdq_data, OMAP_HDQ_RX_DATA); *val = hdq_reg_in(hdq_data, OMAP_HDQ_RX_DATA);
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return 0; return 0;
...@@ -427,13 +427,13 @@ omap_hdq_get(struct hdq_data *hdq_data) ...@@ -427,13 +427,13 @@ omap_hdq_get(struct hdq_data *hdq_data)
{ {
int ret = 0; int ret = 0;
ret = down_interruptible(&hdq_data->hdq_semlock); ret = mutex_lock_interruptible(&hdq_data->hdq_mutex);
if (ret < 0) if (ret < 0)
return -EINTR; return -EINTR;
if (OMAP_HDQ_MAX_USER == hdq_data->hdq_usecount) { if (OMAP_HDQ_MAX_USER == hdq_data->hdq_usecount) {
dev_dbg(hdq_data->dev, "attempt to exceed the max use count"); dev_dbg(hdq_data->dev, "attempt to exceed the max use count");
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
ret = -EINVAL; ret = -EINVAL;
} else { } else {
hdq_data->hdq_usecount++; hdq_data->hdq_usecount++;
...@@ -443,14 +443,14 @@ omap_hdq_get(struct hdq_data *hdq_data) ...@@ -443,14 +443,14 @@ omap_hdq_get(struct hdq_data *hdq_data)
dev_dbg(hdq_data->dev, "Can not enable ick\n"); dev_dbg(hdq_data->dev, "Can not enable ick\n");
clk_put(hdq_data->hdq_ick); clk_put(hdq_data->hdq_ick);
clk_put(hdq_data->hdq_fck); clk_put(hdq_data->hdq_fck);
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -ENODEV; return -ENODEV;
} }
if (clk_enable(hdq_data->hdq_fck)) { if (clk_enable(hdq_data->hdq_fck)) {
dev_dbg(hdq_data->dev, "Can not enable fck\n"); dev_dbg(hdq_data->dev, "Can not enable fck\n");
clk_put(hdq_data->hdq_ick); clk_put(hdq_data->hdq_ick);
clk_put(hdq_data->hdq_fck); clk_put(hdq_data->hdq_fck);
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return -ENODEV; return -ENODEV;
} }
...@@ -472,7 +472,7 @@ omap_hdq_get(struct hdq_data *hdq_data) ...@@ -472,7 +472,7 @@ omap_hdq_get(struct hdq_data *hdq_data)
} }
} }
} }
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return ret; return ret;
} }
...@@ -484,7 +484,7 @@ omap_hdq_put(struct hdq_data *hdq_data) ...@@ -484,7 +484,7 @@ omap_hdq_put(struct hdq_data *hdq_data)
{ {
int ret = 0; int ret = 0;
ret = down_interruptible(&hdq_data->hdq_semlock); ret = mutex_lock_interruptible(&hdq_data->hdq_mutex);
if (ret < 0) if (ret < 0)
return -EINTR; return -EINTR;
...@@ -500,7 +500,7 @@ omap_hdq_put(struct hdq_data *hdq_data) ...@@ -500,7 +500,7 @@ omap_hdq_put(struct hdq_data *hdq_data)
clk_disable(hdq_data->hdq_fck); clk_disable(hdq_data->hdq_fck);
} }
} }
up(&hdq_data->hdq_semlock); mutex_unlock(&hdq_data->hdq_mutex);
return ret; return ret;
} }
...@@ -614,7 +614,7 @@ static int __init omap_hdq_probe(struct platform_device *pdev) ...@@ -614,7 +614,7 @@ static int __init omap_hdq_probe(struct platform_device *pdev)
} }
hdq_data->hdq_usecount = 0; hdq_data->hdq_usecount = 0;
sema_init(&hdq_data->hdq_semlock, 1); mutex_init(&hdq_data->hdq_mutex);
if (clk_enable(hdq_data->hdq_ick)) { if (clk_enable(hdq_data->hdq_ick)) {
dev_dbg(&pdev->dev, "Can not enable ick\n"); dev_dbg(&pdev->dev, "Can not enable ick\n");
...@@ -689,12 +689,14 @@ static int omap_hdq_remove(struct platform_device *pdev) ...@@ -689,12 +689,14 @@ static int omap_hdq_remove(struct platform_device *pdev)
{ {
struct hdq_data *hdq_data = platform_get_drvdata(pdev); struct hdq_data *hdq_data = platform_get_drvdata(pdev);
down_interruptible(&hdq_data->hdq_semlock); mutex_lock(&hdq_data->hdq_mutex);
if (0 != hdq_data->hdq_usecount) { if (0 != hdq_data->hdq_usecount) {
dev_dbg(&pdev->dev, "removed when use count is not zero\n"); dev_dbg(&pdev->dev, "removed when use count is not zero\n");
return -EBUSY; return -EBUSY;
} }
up(&hdq_data->hdq_semlock);
mutex_unlock(&hdq_data->hdq_mutex);
/* remove module dependency */ /* remove module dependency */
clk_put(hdq_data->hdq_ick); clk_put(hdq_data->hdq_ick);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment