Commit dcc35b21 authored by Tony Lindgren's avatar Tony Lindgren Committed by Kishon Vijay Abraham I

usb: phy: twl4030-usb: Use mutex instead of spinlock for protecting the data

We're using threaded irq on a I2C bus and we're sleeping in
twl4030_usb_irq() as it calls twl4030_usb_linkstat() which
calls the i2c functions. If we ever need to lock for longer
I2C transaction sequences a mutex will allow us to do that
easily.
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent 48f48e17
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -155,7 +154,7 @@ struct twl4030_usb { ...@@ -155,7 +154,7 @@ struct twl4030_usb {
struct regulator *usb3v1; struct regulator *usb3v1;
/* for vbus reporting with irqs disabled */ /* for vbus reporting with irqs disabled */
spinlock_t lock; struct mutex lock;
/* pin configuration */ /* pin configuration */
enum twl4030_usb_mode usb_mode; enum twl4030_usb_mode usb_mode;
...@@ -516,13 +515,12 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev, ...@@ -516,13 +515,12 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct twl4030_usb *twl = dev_get_drvdata(dev); struct twl4030_usb *twl = dev_get_drvdata(dev);
unsigned long flags;
int ret = -EINVAL; int ret = -EINVAL;
spin_lock_irqsave(&twl->lock, flags); mutex_lock(&twl->lock);
ret = sprintf(buf, "%s\n", ret = sprintf(buf, "%s\n",
twl->vbus_supplied ? "on" : "off"); twl->vbus_supplied ? "on" : "off");
spin_unlock_irqrestore(&twl->lock, flags); mutex_unlock(&twl->lock);
return ret; return ret;
} }
...@@ -536,12 +534,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) ...@@ -536,12 +534,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
status = twl4030_usb_linkstat(twl); status = twl4030_usb_linkstat(twl);
spin_lock_irq(&twl->lock); mutex_lock(&twl->lock);
if (status >= 0 && status != twl->linkstat) { if (status >= 0 && status != twl->linkstat) {
twl->linkstat = status; twl->linkstat = status;
status_changed = true; status_changed = true;
} }
spin_unlock_irq(&twl->lock); mutex_unlock(&twl->lock);
if (status_changed) { if (status_changed) {
/* FIXME add a set_power() method so that B-devices can /* FIXME add a set_power() method so that B-devices can
...@@ -695,8 +693,8 @@ static int twl4030_usb_probe(struct platform_device *pdev) ...@@ -695,8 +693,8 @@ static int twl4030_usb_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider)) if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider); return PTR_ERR(phy_provider);
/* init spinlock for workqueue */ /* init mutex for workqueue */
spin_lock_init(&twl->lock); mutex_init(&twl->lock);
INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work); INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work);
......
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