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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOMZO5B2_yq=m8Mer=iV-HsXvF-MZJ-BV2=LTg1CZN+O=yepSQ@mail.gmail.com>
Date:	Tue, 7 Feb 2012 17:25:48 -0200
From:	Fabio Estevam <festevam@...il.com>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc:	Sascha Hauer <s.hauer@...gutronix.de>,
	robert.marklund@...ricsson.com, netdev@...r.kernel.org,
	Sascha Hauer <kernel@...gutronix.de>
Subject: Re: Regulator support for smsc911x

Hi Mark,

On Fri, Feb 3, 2012 at 9:11 AM, Mark Brown
<broonie@...nsource.wolfsonmicro.com> wrote:

> There's also options c) set up the regulators for the board and d) don't
> enable the regulator API if the board doesn't use regulators.

Option c would require that we change every single board.

The patch below does option d.

What do you think?

diff --git a/arch/arm/mach-ux500/board-mop500.c
b/arch/arm/mach-ux500/board-mop500.c
index 5c00712..3fdd1c2 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -157,7 +157,8 @@ static struct platform_device snowball_key_dev = {
 static struct smsc911x_platform_config snowball_sbnet_cfg = {
 	.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
 	.irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
-	.flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
+	.flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY |
+							SMSC911X_USE_REGULATOR,
 	.shift = 1,
 };

diff --git a/drivers/net/ethernet/smsc/smsc911x.c
b/drivers/net/ethernet/smsc/smsc911x.c
index 6a1cd23..b9f6e67 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -377,8 +377,9 @@ static int smsc911x_enable_resources(struct
platform_device *pdev)
 	struct smsc911x_data *pdata = netdev_priv(ndev);
 	int ret = 0;

-	ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies),
-			pdata->supplies);
+	if (pdata->config.flags & SMSC911X_USE_REGULATOR)
+		ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
 	if (ret)
 		netdev_err(ndev, "failed to enable regulators %d\n",
 				ret);
@@ -394,8 +395,9 @@ static int smsc911x_disable_resources(struct
platform_device *pdev)
 	struct smsc911x_data *pdata = netdev_priv(ndev);
 	int ret = 0;

-	ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
-			pdata->supplies);
+	if (pdata->config.flags & SMSC911X_USE_REGULATOR)
+		ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
 	return ret;
 }

@@ -415,9 +417,11 @@ static int smsc911x_request_resources(struct
platform_device *pdev)
 	/* Request regulators */
 	pdata->supplies[0].supply = "vdd33a";
 	pdata->supplies[1].supply = "vddvario";
-	ret = regulator_bulk_get(&pdev->dev,
-			ARRAY_SIZE(pdata->supplies),
-			pdata->supplies);
+	
+	if (pdata->config.flags & SMSC911X_USE_REGULATOR)
+		ret = regulator_bulk_get(&pdev->dev,
+				ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
 	if (ret)
 		netdev_err(ndev, "couldn't get regulators %d\n",
 				ret);
@@ -434,8 +438,9 @@ static void smsc911x_free_resources(struct
platform_device *pdev)
 	struct smsc911x_data *pdata = netdev_priv(ndev);

 	/* Free regulators */
-	regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
-			pdata->supplies);
+	if (pdata->config.flags & SMSC911X_USE_REGULATOR)	
+		regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
+				pdata->supplies);
 }

 /* waits for MAC not busy, with timeout.  Only called by smsc911x_mac_read
diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h
index 4dde70e..91c59d9 100644
--- a/include/linux/smsc911x.h
+++ b/include/linux/smsc911x.h
@@ -48,6 +48,7 @@ struct smsc911x_platform_config {
 #define SMSC911X_FORCE_INTERNAL_PHY		(BIT(2))
 #define SMSC911X_FORCE_EXTERNAL_PHY 		(BIT(3))
 #define SMSC911X_SAVE_MAC_ADDRESS		(BIT(4))
+#define SMSC911X_USE_REGULATOR			(BIT(5))		

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ