mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ahaslam@baylibre.com
To: gregkh@linuxfoundation.org, johan@kernel.org, robh+dt@kernel.org,
	nsekhar@ti.com, stern@rowland.harvard.edu, khilman@baylibre.com,
	sshtylyov@ru.mvista.com, david@lechnology.com,
	manjunath.goudar@linaro.org, broonie@kernel.org,
	abailon@baylibre.com
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Axel Haslam <ahaslam@baylibre.com>
Subject: [PATCH/RFT v2 10/17] USB: da8xx: use flag instead of bitmask for over current change
Date: Mon, 24 Oct 2016 18:46:27 +0200	[thread overview]
Message-ID: <20161024164634.4330-11-ahaslam@baylibre.com> (raw)
In-Reply-To: <20161024164634.4330-1-ahaslam@baylibre.com>

From: Axel Haslam <ahaslam@baylibre.com>

The da8xx ohci has only one port connected. In hub_control we
check that the port is 1, or else we bail out early. There is no point
in passing as argument the port number, if we know, and check that it
will always be 1.

Simplify functions and callbacks, by removing the port parameter, and
converting the over current indicatior change form a mask to a flag.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 arch/arm/mach-davinci/board-da830-evm.c     |  8 ++++----
 arch/arm/mach-davinci/board-omapl138-hawk.c |  8 ++++----
 drivers/usb/host/ohci-da8xx.c               | 29 ++++++++++++++---------------
 include/linux/platform_data/usb-davinci.h   |  9 ++++-----
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index b33fc6b..d12fcf5 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -50,18 +50,18 @@
 
 static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
 
-static int da830_evm_usb_set_power(unsigned port, int on)
+static int da830_evm_usb_set_power(int on)
 {
 	gpio_set_value(ON_BD_USB_DRV, on);
 	return 0;
 }
 
-static int da830_evm_usb_get_power(unsigned port)
+static int da830_evm_usb_get_power(void)
 {
 	return gpio_get_value(ON_BD_USB_DRV);
 }
 
-static int da830_evm_usb_get_oci(unsigned port)
+static int da830_evm_usb_get_oci(void)
 {
 	return !gpio_get_value(ON_BD_USB_OVC);
 }
@@ -100,7 +100,7 @@ static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
 
 static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
 {
-	da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1);
+	da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata);
 	return IRQ_HANDLED;
 }
 
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index c3ab7ea..1d31f45 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -189,18 +189,18 @@ static __init void omapl138_hawk_mmc_init(void)
 	-1
 };
 
-static int hawk_usb_set_power(unsigned port, int on)
+static int hawk_usb_set_power(int on)
 {
 	gpio_set_value(DA850_USB1_VBUS_PIN, on);
 	return 0;
 }
 
-static int hawk_usb_get_power(unsigned port)
+static int hawk_usb_get_power(void)
 {
 	return gpio_get_value(DA850_USB1_VBUS_PIN);
 }
 
-static int hawk_usb_get_oci(unsigned port)
+static int hawk_usb_get_oci(void)
 {
 	return !gpio_get_value(DA850_USB1_OC_PIN);
 }
@@ -237,7 +237,7 @@ static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler)
 
 static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id)
 {
-	hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1);
+	hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata);
 	return IRQ_HANDLED;
 }
 
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3656d7c..e98066d 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -25,8 +25,8 @@
 static struct clk *usb11_clk;
 static struct phy *usb11_phy;
 
-/* Over-current indicator change bitmask */
-static volatile u16 ocic_mask;
+/* Over-current indicator change flag */
+static int ocic_flag;
 
 static int ohci_da8xx_enable(void)
 {
@@ -64,14 +64,13 @@ static void ohci_da8xx_disable(void)
 /*
  * Handle the port over-current indicator change.
  */
-static void ohci_da8xx_ocic_handler(struct da8xx_ohci_root_hub *hub,
-				    unsigned port)
+static void ohci_da8xx_ocic_handler(struct da8xx_ohci_root_hub *hub)
 {
-	ocic_mask |= 1 << port;
+	ocic_flag = 1;
 
 	/* Once over-current is detected, the port needs to be powered down */
-	if (hub->get_oci(port) > 0)
-		hub->set_power(port, 0);
+	if (hub->get_oci() > 0)
+		hub->set_power(0);
 }
 
 static int ohci_da8xx_init(struct usb_hcd *hcd)
@@ -147,8 +146,8 @@ static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
 	int length		= ohci_hub_status_data(hcd, buf);
 
-	/* See if we have OCIC bit set on port 1 */
-	if (ocic_mask & (1 << 1)) {
+	/* See if we have OCIC flag set */
+	if (ocic_flag) {
 		dev_dbg(hcd->self.controller, "over-current indicator change "
 			"on port 1\n");
 
@@ -181,15 +180,15 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1);
 
 		/* The port power status (PPS) bit defaults to 1 */
-		if (hub->get_power && hub->get_power(wIndex) == 0)
+		if (hub->get_power && hub->get_power() == 0)
 			temp &= ~RH_PS_PPS;
 
 		/* The port over-current indicator (POCI) bit is always 0 */
-		if (hub->get_oci && hub->get_oci(wIndex) > 0)
+		if (hub->get_oci && hub->get_oci() > 0)
 			temp |=  RH_PS_POCI;
 
 		/* The over-current indicator change (OCIC) bit is 0 too */
-		if (ocic_mask & (1 << wIndex))
+		if (ocic_flag)
 			temp |=  RH_PS_OCIC;
 
 		put_unaligned(cpu_to_le32(temp), (__le32 *)buf);
@@ -213,16 +212,16 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			if (!hub->set_power)
 				return -EPIPE;
 
-			return hub->set_power(wIndex, temp) ? -EPIPE : 0;
+			return hub->set_power(temp) ? -EPIPE : 0;
 		case USB_PORT_FEAT_C_OVER_CURRENT:
 			dev_dbg(dev, "%sPortFeature(%u): %s\n",
 				temp ? "Set" : "Clear", wIndex,
 				"C_OVER_CURRENT");
 
 			if (temp)
-				ocic_mask |= 1 << wIndex;
+				ocic_flag = 1;
 			else
-				ocic_mask &= ~(1 << wIndex);
+				ocic_flag = 0;
 			return 0;
 		}
 	}
diff --git a/include/linux/platform_data/usb-davinci.h b/include/linux/platform_data/usb-davinci.h
index 0926e99..3217fbe 100644
--- a/include/linux/platform_data/usb-davinci.h
+++ b/include/linux/platform_data/usb-davinci.h
@@ -13,17 +13,16 @@
 
 struct	da8xx_ohci_root_hub;
 
-typedef void (*da8xx_ocic_handler_t)(struct da8xx_ohci_root_hub *hub,
-				     unsigned port);
+typedef void (*da8xx_ocic_handler_t)(struct da8xx_ohci_root_hub *hub);
 
 /* Passed as the platform data to the OHCI driver */
 struct	da8xx_ohci_root_hub {
 	/* Switch the port power on/off */
-	int	(*set_power)(unsigned port, int on);
+	int	(*set_power)(int on);
 	/* Read the port power status */
-	int	(*get_power)(unsigned port);
+	int	(*get_power)(void);
 	/* Read the port over-current indicator */
-	int	(*get_oci)(unsigned port);
+	int	(*get_oci)(void);
 	/* Over-current indicator change notification (pass NULL to disable) */
 	int	(*ocic_notify)(da8xx_ocic_handler_t handler);
 
-- 
1.9.1

  parent reply	other threads:[~2016-10-24 16:48 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 16:46 [PATCH/RFT v2 00/17] Add DT support for ohci-da8xx ahaslam
2016-10-24 16:46 ` [PATCH/RFT v2 01/17] ARM: davinci: da8xx: add usb phy clocks ahaslam
2016-10-24 16:46 ` [PATCH/RFT v2 02/17] ARM: davinci: da8xx: Add CFGCHIP syscon platform declaration ahaslam
2016-10-25  8:10   ` Sekhar Nori
2016-10-25  9:37     ` Axel Haslam
2016-10-25 10:17       ` Sekhar Nori
2016-10-25 15:53         ` David Lechner
2016-10-26  8:56           ` Sekhar Nori
2016-10-24 16:46 ` [PATCH/RFT v2 03/17] ARM: davinci: da8xx: Add USB PHY " ahaslam
2016-10-25  9:18   ` Sekhar Nori
2016-10-25  9:37     ` Axel Haslam
2016-10-24 16:46 ` [PATCH/RFT v2 04/17] ARM: DTS: da850: Add cfgchip syscon node ahaslam
2016-10-24 16:46 ` [PATCH/RFT v2 05/17] ARM: DTS: da850: Add usb phy node ahaslam
2016-10-24 16:46 ` [PATCH/RFT v2 06/17] ARM: davinci: da8xx: Fix some redefined symbol warnings ahaslam
2016-10-25 10:03   ` Sekhar Nori
2016-10-25 12:14     ` Alexandre Bailon
2016-10-24 16:46 ` [PATCH/RFT v2 07/17] ARM: davinci: da8xx: Enable the usb20 "per" clk on phy_clk_enable ahaslam
2016-10-25  2:53   ` David Lechner
2016-10-25 10:01     ` Axel Haslam
2016-10-25 10:12   ` Sekhar Nori
2016-10-25 16:05     ` David Lechner
2016-10-26  9:30       ` Sekhar Nori
2016-10-24 16:46 ` [PATCH/RFT v2 08/17] ARM: davinci: hawk: add full constraints for ohci plat boot ahaslam
2016-10-25 10:28   ` Sekhar Nori
2016-10-25 10:31     ` Axel Haslam
2016-10-24 16:46 ` [PATCH/RFT v2 09/17] regulator: fixed: Add over current event ahaslam
2016-10-24 17:43   ` Mark Brown
2016-10-24 17:53     ` Axel Haslam
2016-10-24 17:53   ` Mark Brown
2016-10-24 18:11     ` Axel Haslam
2016-10-24 18:19       ` Mark Brown
2016-10-25 12:55         ` Axel Haslam
2016-10-25 14:33           ` Mark Brown
2016-10-25 14:57             ` Axel Haslam
2016-10-25 15:07               ` Axel Haslam
2016-10-30 20:42   ` Rob Herring
2016-10-24 16:46 ` ahaslam [this message]
2016-10-24 16:46 ` [PATCH/RFT v2 11/17] USB: OHCI: make ohci-da8xx a separate driver ahaslam
2016-10-25  0:38   ` David Lechner
2016-10-25  7:39     ` Axel Haslam
2016-10-25 16:12       ` David Lechner
2016-10-25 16:21         ` Axel Haslam
2016-10-25 16:24           ` David Lechner
2016-10-24 16:46 ` [PATCH/RFT v2 12/17] USB: ochi-da8xx: Use a regulator for vbus/overcurrent ahaslam
2016-10-25  1:39   ` David Lechner
2016-10-25  8:24     ` Axel Haslam
2016-10-25 16:53       ` David Lechner
2016-10-25 17:32         ` Axel Haslam
2016-10-25 10:43   ` Sekhar Nori
2016-10-25 10:52     ` Axel Haslam
2016-10-24 16:46 ` [PATCH/RFT v2 13/17] USB: da8xx: use ohci priv data instead of globals ahaslam
2016-10-25  1:12   ` David Lechner
2016-10-25  9:56     ` Axel Haslam
2016-10-24 16:46 ` [PATCH/RFT v2 14/17] ARM: davinci: register the usb20_phy clock on the DT file ahaslam
2016-10-24 16:46 ` [PATCH/RFT v2 15/17] usb: host: ohci-da8xx: Add devicetree bindings documentation ahaslam
2016-10-25  1:02   ` David Lechner
2016-10-25  9:56     ` Axel Haslam
2016-10-24 16:46 ` [PATCH/RFT v2 16/17] USB: ohci-da8xx: Allow probing from DT ahaslam
2016-10-25  0:53   ` David Lechner
2016-10-25  8:10     ` Axel Haslam
2016-10-24 16:46 ` [PATCH/RFT v2 17/17] ARM: dts: da850: add usb device node ahaslam
2016-10-25  0:48   ` David Lechner
2016-10-25  8:03     ` Axel Haslam
2016-10-25 10:55 ` [PATCH/RFT v2 00/17] Add DT support for ohci-da8xx Sekhar Nori

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=20161024164634.4330-11-ahaslam@baylibre.com \
    --to=ahaslam@baylibre.com \
    --cc=abailon@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=david@lechnology.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=manjunath.goudar@linaro.org \
    --cc=nsekhar@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=sshtylyov@ru.mvista.com \
    --cc=stern@rowland.harvard.edu \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome