[PATCH 2/5] soc/tegra: pmc: Simplify IO rail bit handling

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

 



The function tegra_io_rail_prepare() converts the IO rail ID into a
bit position that is used to check the status and control the IO rail
in the PMC registers. However, rather than converting to a bit position
it is more useful to convert to a bit-mask because this is what is
actually used. By doing so the BIT() marco only needs to be used once
and we can use the IO_DPD_REQ_CODE_MASK when checking for erroneous rail
IDs.

Signed-off-by: Jon Hunter <jonathanh@xxxxxxxxxx>
---
 drivers/soc/tegra/pmc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index c99580aabcf6..6a6df6e8bfd6 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -913,13 +913,13 @@ static int tegra_io_rail_prepare(unsigned int id, unsigned long *request,
 {
 	unsigned long rate, value;
 
-	*bit = id % 32;
+	*bit = BIT(id % 32);
 
 	/*
 	 * There are two sets of 30 bits to select IO rails, but bits 30 and
 	 * 31 are control bits rather than IO rail selection bits.
 	 */
-	if (id > 63 || *bit == 30 || *bit == 31)
+	if (id > 63 || *bit & IO_DPD_REQ_CODE_MASK)
 		return -EINVAL;
 
 	if (id < 32) {
@@ -979,9 +979,9 @@ int tegra_io_rail_power_on(unsigned int id)
 	if (err)
 		goto error;
 
-	tegra_pmc_writel(IO_DPD_REQ_CODE_OFF | BIT(bit), request);
+	tegra_pmc_writel(IO_DPD_REQ_CODE_OFF | bit, request);
 
-	err = tegra_io_rail_poll(status, BIT(bit), 0, 250);
+	err = tegra_io_rail_poll(status, bit, 0, 250);
 	if (err) {
 		pr_info("tegra_io_rail_poll() failed: %d\n", err);
 		goto error;
@@ -1010,9 +1010,9 @@ int tegra_io_rail_power_off(unsigned int id)
 		goto error;
 	}
 
-	tegra_pmc_writel(IO_DPD_REQ_CODE_ON | BIT(bit), request);
+	tegra_pmc_writel(IO_DPD_REQ_CODE_ON | bit, request);
 
-	err = tegra_io_rail_poll(status, BIT(bit), BIT(bit), 250);
+	err = tegra_io_rail_poll(status, bit, bit, 250);
 	if (err)
 		goto error;
 
-- 
1.9.1

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



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux