linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Haslam <ahaslam@baylibre.com>
To: stern@rowland.harvard.edu, gregkh@linuxfoundation.org,
	nsekhar@ti.com, khilman@kernel.org, david@lechnology.com,
	robh+dt@kernel.org
Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Axel Haslam <ahaslam@baylibre.com>
Subject: [PATCH v3 07/10] USB: ohci: da8xx: use a flag instead of mask for ocic
Date: Mon,  7 Nov 2016 21:39:45 +0100	[thread overview]
Message-ID: <20161107203948.28324-8-ahaslam@baylibre.com> (raw)
In-Reply-To: <20161107203948.28324-1-ahaslam@baylibre.com>

Now that the platform callback is removed, we can move the over
current indictor changed flag to the private data structure.

Since the driver only handles a single port, there is no need
for ocic to be a mask, we can use a simple flag instead.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3dcbf1f..83b182e 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -43,12 +43,10 @@ struct da8xx_ohci_hcd {
 	struct regulator *vbus_reg;
 	struct notifier_block nb;
 	unsigned int is_powered;
+	unsigned int oc_changed;
 };
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
-/* Over-current indicator change bitmask */
-static volatile u16 ocic_mask;
-
 static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
 	struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
@@ -168,7 +166,7 @@ static int ohci_da8xx_regulator_event(struct notifier_block *nb,
 
 	if (event & REGULATOR_EVENT_OVER_CURRENT) {
 		dev_warn(dev, "over current event\n");
-		ocic_mask |= 1;
+		da8xx_ohci->oc_changed = 1;
 		ohci_da8xx_set_power(da8xx_ohci->hcd, 0);
 	}
 
@@ -241,10 +239,11 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
  */
 static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
+	struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
 	int length		= orig_ohci_hub_status_data(hcd, buf);
 
 	/* See if we have OCIC bit set on port 1 */
-	if (ocic_mask & (1 << 1)) {
+	if (da8xx_ohci->oc_changed) {
 		dev_dbg(hcd->self.controller, "over-current indicator change "
 			"on port 1\n");
 
@@ -262,6 +261,7 @@ static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				  u16 wIndex, char *buf, u16 wLength)
 {
+	struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
 	struct device *dev		= hcd->self.controller;
 	int temp;
 
@@ -284,7 +284,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			temp |=  RH_PS_POCI;
 
 		/* The over-current indicator change (OCIC) bit is 0 too */
-		if (ocic_mask & (1 << wIndex))
+		if (da8xx_ohci->oc_changed)
 			temp |=  RH_PS_OCIC;
 
 		put_unaligned(cpu_to_le32(temp), (__le32 *)buf);
@@ -311,10 +311,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				temp ? "Set" : "Clear", wIndex,
 				"C_OVER_CURRENT");
 
-			if (temp)
-				ocic_mask |= 1 << wIndex;
-			else
-				ocic_mask &= ~(1 << wIndex);
+			da8xx_ohci->oc_changed = temp;
 			return 0;
 		}
 	}
-- 
2.10.1

  parent reply	other threads:[~2016-11-07 20:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-07 20:39 [PATCH v3 00/10] Add DT support for ohci-da8xx Axel Haslam
2016-11-07 20:39 ` [PATCH v3 01/10] USB: ohci: da8xx: use ohci priv data instead of globals Axel Haslam
2016-11-07 20:39 ` [PATCH v3 02/10] USB: ohci: da8xx: Prepare to remove platform callbacks Axel Haslam
2016-11-07 20:39 ` [PATCH v3 03/10] USB: ohci: da8xx: Allow a regulator to handle VBUS Axel Haslam
2016-11-07 20:39 ` [PATCH v3 04/10] ARM: davinci: da830: Handle vbus with a regulator Axel Haslam
2016-11-07 20:39 ` [PATCH v3 05/10] ARM: davinci: hawk: Remove vbus and over current gpios Axel Haslam
2016-11-07 20:39 ` [PATCH v3 06/10] USB: ohci: da8xx: Remove ohci platform callbacks Axel Haslam
2016-11-07 20:39 ` Axel Haslam [this message]
2016-11-07 20:39 ` [PATCH v3 08/10] USB: ohci: da8xx: Add devicetree bindings Axel Haslam
2016-11-07 20:39 ` [PATCH v3 09/10] USB: ohci: da8xx: Allow probing from DT Axel Haslam
2016-11-07 20:39 ` [PATCH v3 10/10] ARM: dts: da850: add usb device node Axel Haslam
2016-11-21  2:42   ` David Lechner
2016-11-21 10:27     ` Axel Haslam
2016-11-21 10:46       ` Sekhar Nori
2016-11-21 10:49         ` Sekhar Nori
2016-11-21 10:53           ` Axel Haslam
2016-11-08 16:37 ` [PATCH v3 00/10] Add DT support for ohci-da8xx Axel Haslam
2016-11-10 12:02   ` Greg KH
2016-11-10 17:28     ` Axel Haslam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161107203948.28324-8-ahaslam@baylibre.com \
    --to=ahaslam@baylibre.com \
    --cc=david@lechnology.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --subject='Re: [PATCH v3 07/10] USB: ohci: da8xx: use a flag instead of mask for ocic' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).