return (tegra_pmc_readl(PWRGATE_STATUS) & BIT(id)) != 0;
}
+static inline bool tegra_powergate_is_valid(int id)
+{
+ return (pmc->soc && pmc->soc->powergates[id]);
+}
+
/**
* tegra_powergate_set() - set the state of a partition
* @id: partition ID
*/
int tegra_powergate_power_on(unsigned int id)
{
- if (!pmc->soc || id >= pmc->soc->num_powergates)
+ if (!tegra_powergate_is_valid(id))
return -EINVAL;
return tegra_powergate_set(id, true);
*/
int tegra_powergate_power_off(unsigned int id)
{
- if (!pmc->soc || id >= pmc->soc->num_powergates)
+ if (!tegra_powergate_is_valid(id))
return -EINVAL;
return tegra_powergate_set(id, false);
{
int status;
- if (!pmc->soc || id >= pmc->soc->num_powergates)
+ if (!tegra_powergate_is_valid(id))
return -EINVAL;
mutex_lock(&pmc->powergates_lock);
{
u32 mask;
- if (!pmc->soc || id >= pmc->soc->num_powergates)
+ if (!tegra_powergate_is_valid(id))
return -EINVAL;
mutex_lock(&pmc->powergates_lock);