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

From
Krystian Garbaciak <hidden>
Date
2012-08-29 13:32:57
Also in
linux-watchdog, lkml
Reply to
Guenter Roeck, 2012-08-24
+static const struct i_table vsys_tbl[] = {
quoted
+	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.
quoted
+
+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 }/
quoted
+};
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
Thread (19 messages) 19 messages, 4 authors, last reply 2012-08-31
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help