@@ -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;
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@nvidia.com> --- drivers/soc/tegra/pmc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)