Skip to content

Commit

Permalink
plat-stm32mp1: scmi_server: remove local function pwr_scmi_to_regu_id()
Browse files Browse the repository at this point in the history
Removes local function pwr_scmi_to_regu_id() since its called only once.
This change makes get_voltd_regulator() local function easier to read.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
etienne-lms committed Nov 3, 2023
1 parent 1c2bd5e commit 9b82fc1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions core/arch/arm/plat-stm32mp1/scmi_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,18 +622,6 @@ const char *plat_scmi_voltd_get_name(unsigned int channel_id,
return voltd->name;
}

static enum pwr_regulator pwr_scmi_to_regu_id(struct stm32_scmi_voltd *voltd)
{
if (!strcmp(voltd->priv_id, PWR_REG11_NAME_ID))
return PWR_REG11;
if (!strcmp(voltd->priv_id, PWR_REG18_NAME_ID))
return PWR_REG18;
if (!strcmp(voltd->priv_id, PWR_USB33_NAME_ID))
return PWR_USB33;

panic();
}

int32_t plat_scmi_voltd_levels_array(unsigned int channel_id,
unsigned int scmi_id, size_t start_index,
long *levels, size_t *nb_elts)
Expand Down Expand Up @@ -850,13 +838,21 @@ int32_t plat_scmi_voltd_set_config(unsigned int channel_id,

static void get_voltd_regulator(struct stm32_scmi_voltd *voltd)
{
enum pwr_regulator regu_id = PWR_REGU_COUNT;
enum pwr_regulator pwr_regu_id = PWR_REGU_COUNT;
enum iod_regulator_id __maybe_unused iod_regu_id = IOD_REGU_COUNT;

switch (voltd->priv_dev) {
case VOLTD_PWR:
regu_id = pwr_scmi_to_regu_id(voltd);
voltd->regulator = stm32mp1_pwr_get_regulator(regu_id);
if (!strcmp(voltd->priv_id, PWR_REG11_NAME_ID))
pwr_regu_id = PWR_REG11;
else if (!strcmp(voltd->priv_id, PWR_REG18_NAME_ID))
pwr_regu_id = PWR_REG18;
else if (!strcmp(voltd->priv_id, PWR_USB33_NAME_ID))
pwr_regu_id = PWR_USB33;
else
break;

voltd->regulator = stm32mp1_pwr_get_regulator(pwr_regu_id);
break;
case VOLTD_PMIC:
voltd->regulator = stm32mp_pmic_get_regulator(voltd->priv_id);
Expand Down

0 comments on commit 9b82fc1

Please sign in to comment.