Re: [PATCH] regulator: Fix bug in regulator_mode_to_status() core function.

From: Krystian Garbaciak
Date: Wed Aug 29 2012 - 09:32:51 EST


> +static const struct i_table vsys_tbl[] = {
> > + ILINE(0, DA906X_ADC_MAX, 2500, 5500)
> > +};
> > +
> > +static const struct i_table adcin_tbl[] = {
> > + ILINE(0, DA906X_ADC_MAX, 0, 2500)
> > +};
> > +
> > +static const struct i_table tjunc_tbl[] = {
> > + ILINE(0, DA906X_ADC_MAX, 333, -86)
> > +};
> > +
> > +static const struct i_table vbbat_tbl[] = {
> > + ILINE(0, DA906X_ADC_MAX, 0, 5000)
> > +};
>
> Since the first parameter to ILINE is always 0, it is not needed. This means
> that x0 in itable is also always 0 and thus not needed.
>
> > +
> > +static const struct channel_info da906x_channels[] = {
> > + [DA906X_VSYS] = { "VSYS",
> > + vsys_tbl, ARRAY_SIZE(vsys_tbl) - 1,
> > + DA906X_REG_VSYS_RES },
> > + [DA906X_ADCIN1] = { "ADCIN1",
> > + adcin_tbl, ARRAY_SIZE(adcin_tbl) - 1,
> > + DA906X_REG_ADCIN1_RES },
> > + [DA906X_ADCIN2] = { "ADCIN2",
> > + adcin_tbl, ARRAY_SIZE(adcin_tbl) - 1,
> > + DA906X_REG_ADCIN2_RES },
> > + [DA906X_ADCIN3] = { "ADCIN3",
> > + adcin_tbl, ARRAY_SIZE(adcin_tbl) - 1,
> > + DA906X_REG_ADCIN3_RES },
> > + [DA906X_TJUNC] = { "TJUNC",
> > + tjunc_tbl, ARRAY_SIZE(tjunc_tbl) - 1 },
> > + [DA906X_VBBAT] = { "VBBAT",
> > + vbbat_tbl, ARRAY_SIZE(vbbat_tbl) - 1}
>
> s/1}/1 }/
>
> > +};
>
> You lost me here a bit (I am missing something ?).
>
> Seems to be each table has exactly one entry. Since the table size is 1,
> ARRAY_SIZE(vbbat_tbl) - 1 is 0, and ...

An initial idea was to make the interpolation of the channel values using more
ILINE segments. Eventually, it ended up with one linear segment for every
channel, so it makes sense to reduce the code as you propose.

As suggested, driver name will be changed from "da906x" to "da9063".
I will adapt proposed changes and fixes.

Thank you for your comments,
Krystian

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