aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2014-08-27 19:28:11 -0400
committerKishon Vijay Abraham I <kishon@ti.com>2014-09-24 05:48:33 -0400
commitdcc35b2160f32b8528973e91c25595fc91354e92 (patch)
tree2778b74b5d7b00c0d3dadd80765491e61408e888 /drivers/phy
parent48f48e172c45e66e5323813fccc7dfd34e404bbe (diff)
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: Tony Lindgren <tony@atomide.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/phy-twl4030-usb.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 24ff3c6f1499..1e0e2d1f7941 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -28,7 +28,6 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/spinlock.h>
32#include <linux/workqueue.h> 31#include <linux/workqueue.h>
33#include <linux/io.h> 32#include <linux/io.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
@@ -155,7 +154,7 @@ struct twl4030_usb {
155 struct regulator *usb3v1; 154 struct regulator *usb3v1;
156 155
157 /* for vbus reporting with irqs disabled */ 156 /* for vbus reporting with irqs disabled */
158 spinlock_t lock; 157 struct mutex lock;
159 158
160 /* pin configuration */ 159 /* pin configuration */
161 enum twl4030_usb_mode usb_mode; 160 enum twl4030_usb_mode usb_mode;
@@ -516,13 +515,12 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev,
516 struct device_attribute *attr, char *buf) 515 struct device_attribute *attr, char *buf)
517{ 516{
518 struct twl4030_usb *twl = dev_get_drvdata(dev); 517 struct twl4030_usb *twl = dev_get_drvdata(dev);
519 unsigned long flags;
520 int ret = -EINVAL; 518 int ret = -EINVAL;
521 519
522 spin_lock_irqsave(&twl->lock, flags); 520 mutex_lock(&twl->lock);
523 ret = sprintf(buf, "%s\n", 521 ret = sprintf(buf, "%s\n",
524 twl->vbus_supplied ? "on" : "off"); 522 twl->vbus_supplied ? "on" : "off");
525 spin_unlock_irqrestore(&twl->lock, flags); 523 mutex_unlock(&twl->lock);
526 524
527 return ret; 525 return ret;
528} 526}
@@ -536,12 +534,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
536 534
537 status = twl4030_usb_linkstat(twl); 535 status = twl4030_usb_linkstat(twl);
538 536
539 spin_lock_irq(&twl->lock); 537 mutex_lock(&twl->lock);
540 if (status >= 0 && status != twl->linkstat) { 538 if (status >= 0 && status != twl->linkstat) {
541 twl->linkstat = status; 539 twl->linkstat = status;
542 status_changed = true; 540 status_changed = true;
543 } 541 }
544 spin_unlock_irq(&twl->lock); 542 mutex_unlock(&twl->lock);
545 543
546 if (status_changed) { 544 if (status_changed) {
547 /* FIXME add a set_power() method so that B-devices can 545 /* 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 if (IS_ERR(phy_provider)) 693 if (IS_ERR(phy_provider))
696 return PTR_ERR(phy_provider); 694 return PTR_ERR(phy_provider);
697 695
698 /* init spinlock for workqueue */ 696 /* init mutex for workqueue */
699 spin_lock_init(&twl->lock); 697 mutex_init(&twl->lock);
700 698
701 INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work); 699 INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work);
702 700