lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1474280295-17503-1-git-send-email-fabien.lahoudere@collabora.co.uk>
Date:   Mon, 19 Sep 2016 12:18:13 +0200
From:   Fabien Lahoudere <fabien.lahoudere@...labora.co.uk>
To:     hzpeterchen@...il.com
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Fabien Lahoudere <fabien.lahoudere@...labora.co.uk>
Subject: [PATCH 05/15] usb: chipidea: imx: Change switch order

Each USB controller have different behaviour, so in order to avoid to have
several "swicth(data->index)" and lock/unlock, we prefer to get the index
and then test for features if they exist for this index.

Signed-off-by: Fabien Lahoudere <fabien.lahoudere@...labora.co.uk>
---
 drivers/usb/chipidea/usbmisc_imx.c | 44 +++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 20d02a5..ed324d1 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -199,31 +199,45 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
 	val |= MX53_USB_PLL_DIV_24_MHZ;
 	writel(val, usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET);
 
-	if (data->disable_oc) {
-		spin_lock_irqsave(&usbmisc->lock, flags);
-		switch (data->index) {
+	spin_lock_irqsave(&usbmisc->lock, flags);
+
+	switch (data->index) {
 		case 0:
-			reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
-			val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
+			if (data->disable_oc) {
+				reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
+				val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
+				if (reg && val)
+					writel(val, reg);
+			}
 			break;
 		case 1:
-			reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
-			val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
+			if (data->disable_oc) {
+				reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
+				val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
+				if (reg && val)
+					writel(val, reg);
+			}
 			break;
 		case 2:
-			reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
-			val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+			if (data->disable_oc) {
+				reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
+				val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+				if (reg && val)
+					writel(val, reg);
+			}
 			break;
 		case 3:
-			reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
-			val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+			if (data->disable_oc) {
+				reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
+				val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+				if (reg && val)
+					writel(val, reg);
+			}
 			break;
-		}
-		if (reg && val)
-			writel(val, reg);
-		spin_unlock_irqrestore(&usbmisc->lock, flags);
 	}
 
+	spin_unlock_irqrestore(&usbmisc->lock, flags);
+
 	return 0;
 }
 
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ