[PATCH v1 6/8] usb: otg: palmas-usb: call regulator enable/disable only on valid regulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The calls to regulator enable/disable was done unconditionally which
might result in warn dumps if *no_control_vbus* is set. So always call
regulator enable/disable on valid regulator.

Signed-off-by: Kishon Vijay Abraham I <kishon@xxxxxx>
---
 drivers/usb/otg/palmas-usb.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/otg/palmas-usb.c b/drivers/usb/otg/palmas-usb.c
index 2377836..442f09c 100644
--- a/drivers/usb/otg/palmas-usb.c
+++ b/drivers/usb/otg/palmas-usb.c
@@ -119,11 +119,13 @@ static irqreturn_t palmas_vbus_wakeup_irq(int irq, void *_palmas_usb)
 	regmap_read(palmas_usb->palmas->regmap[slave], addr, &vbus_line_state);
 
 	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
-		regulator_enable(palmas_usb->vbus_reg);
+		if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+			regulator_enable(palmas_usb->vbus_reg);
 		status = OMAP_DWC3_VBUS_VALID;
 	} else {
 		status = OMAP_DWC3_VBUS_OFF;
-		regulator_disable(palmas_usb->vbus_reg);
+		if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+			regulator_disable(palmas_usb->vbus_reg);
 	}
 
 	palmas_usb->linkstat = status;
@@ -144,7 +146,8 @@ static irqreturn_t palmas_id_wakeup_irq(int irq, void *_palmas_usb)
 	palmas_usb_read(palmas_usb->palmas, PALMAS_USB_ID_INT_LATCH_SET, &set);
 
 	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
-		regulator_enable(palmas_usb->vbus_reg);
+		if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+			regulator_enable(palmas_usb->vbus_reg);
 		palmas_usb_write(palmas_usb->palmas,
 					PALMAS_USB_ID_INT_EN_HI_SET,
 					PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
@@ -159,7 +162,8 @@ static irqreturn_t palmas_id_wakeup_irq(int irq, void *_palmas_usb)
 		palmas_usb_write(palmas_usb->palmas,
 					PALMAS_USB_ID_INT_EN_HI_CLR,
 					PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
-		regulator_disable(palmas_usb->vbus_reg);
+		if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+			regulator_disable(palmas_usb->vbus_reg);
 		status = OMAP_DWC3_ID_FLOAT;
 	}
 
@@ -191,6 +195,11 @@ static void palmas_set_vbus_work(struct work_struct *data)
 	struct palmas_usb *palmas_usb = container_of(data, struct palmas_usb,
 								set_vbus_work);
 
+	if (IS_ERR_OR_NULL(palmas_usb->vbus_reg)) {
+		dev_err(palmas_usb->dev, "invalid regulator\n");
+		return;
+	}
+
 	/*
 	 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
 	 * register. This enables boost mode.
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux