Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: addac: ad74xxx: Constify struct iio_chan_spec​

'struct iio_chan_spec' are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
35749 5879 384 42012 a41c drivers/iio/addac/ad74115.o
32242 3297 384 35923 8c53 drivers/iio/addac/ad74413r.o

After:
=====
text data bss dec hex filename
39109 2519 384 42012 a41c drivers/iio/addac/ad74115.o
33842 1697 384 35923 8c53 drivers/iio/addac/ad74413r.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/da291278e78b983ea2e657a25769f7d82ea2a6d0.1725717045.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Christophe JAILLET and committed by
Jonathan Cameron
4f3333a6 3ad9e639

+20 -19
+9 -9
drivers/iio/addac/ad74115.c
··· 191 191 }; 192 192 193 193 struct ad74115_channels { 194 - struct iio_chan_spec *channels; 194 + const struct iio_chan_spec *channels; 195 195 unsigned int num_channels; 196 196 }; 197 197 ··· 1295 1295 _AD74115_ADC_CHANNEL(_type, index, BIT(IIO_CHAN_INFO_SCALE) \ 1296 1296 | BIT(IIO_CHAN_INFO_OFFSET)) 1297 1297 1298 - static struct iio_chan_spec ad74115_voltage_input_channels[] = { 1298 + static const struct iio_chan_spec ad74115_voltage_input_channels[] = { 1299 1299 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1300 1300 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1301 1301 }; 1302 1302 1303 - static struct iio_chan_spec ad74115_voltage_output_channels[] = { 1303 + static const struct iio_chan_spec ad74115_voltage_output_channels[] = { 1304 1304 AD74115_DAC_CHANNEL(IIO_VOLTAGE, AD74115_DAC_CH_MAIN), 1305 1305 AD74115_ADC_CHANNEL(IIO_CURRENT, AD74115_ADC_CH_CONV1), 1306 1306 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1307 1307 }; 1308 1308 1309 - static struct iio_chan_spec ad74115_current_input_channels[] = { 1309 + static const struct iio_chan_spec ad74115_current_input_channels[] = { 1310 1310 AD74115_ADC_CHANNEL(IIO_CURRENT, AD74115_ADC_CH_CONV1), 1311 1311 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1312 1312 }; 1313 1313 1314 - static struct iio_chan_spec ad74115_current_output_channels[] = { 1314 + static const struct iio_chan_spec ad74115_current_output_channels[] = { 1315 1315 AD74115_DAC_CHANNEL(IIO_CURRENT, AD74115_DAC_CH_MAIN), 1316 1316 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1317 1317 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1318 1318 }; 1319 1319 1320 - static struct iio_chan_spec ad74115_2_wire_resistance_input_channels[] = { 1320 + static const struct iio_chan_spec ad74115_2_wire_resistance_input_channels[] = { 1321 1321 _AD74115_ADC_CHANNEL(IIO_RESISTANCE, AD74115_ADC_CH_CONV1, 1322 1322 BIT(IIO_CHAN_INFO_PROCESSED)), 1323 1323 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1324 1324 }; 1325 1325 1326 - static struct iio_chan_spec ad74115_3_4_wire_resistance_input_channels[] = { 1326 + static const struct iio_chan_spec ad74115_3_4_wire_resistance_input_channels[] = { 1327 1327 AD74115_ADC_CHANNEL(IIO_RESISTANCE, AD74115_ADC_CH_CONV1), 1328 1328 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1329 1329 }; 1330 1330 1331 - static struct iio_chan_spec ad74115_digital_input_logic_channels[] = { 1331 + static const struct iio_chan_spec ad74115_digital_input_logic_channels[] = { 1332 1332 AD74115_DAC_CHANNEL(IIO_VOLTAGE, AD74115_DAC_CH_COMPARATOR), 1333 1333 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1334 1334 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1335 1335 }; 1336 1336 1337 - static struct iio_chan_spec ad74115_digital_input_loop_channels[] = { 1337 + static const struct iio_chan_spec ad74115_digital_input_loop_channels[] = { 1338 1338 AD74115_DAC_CHANNEL(IIO_CURRENT, AD74115_DAC_CH_MAIN), 1339 1339 AD74115_DAC_CHANNEL(IIO_VOLTAGE, AD74115_DAC_CH_COMPARATOR), 1340 1340 AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1),
+11 -10
drivers/iio/addac/ad74413r.c
··· 45 45 }; 46 46 47 47 struct ad74413r_channels { 48 - struct iio_chan_spec *channels; 49 - unsigned int num_channels; 48 + const struct iio_chan_spec *channels; 49 + unsigned int num_channels; 50 50 }; 51 51 52 52 struct ad74413r_state { ··· 1138 1138 AD74413R_ADC_CHANNEL(IIO_CURRENT, BIT(IIO_CHAN_INFO_SCALE) \ 1139 1139 | BIT(IIO_CHAN_INFO_OFFSET)) 1140 1140 1141 - static struct iio_chan_spec ad74413r_voltage_output_channels[] = { 1141 + static const struct iio_chan_spec ad74413r_voltage_output_channels[] = { 1142 1142 AD74413R_DAC_CHANNEL(IIO_VOLTAGE, BIT(IIO_CHAN_INFO_SCALE)), 1143 1143 AD74413R_ADC_CURRENT_CHANNEL, 1144 1144 }; 1145 1145 1146 - static struct iio_chan_spec ad74413r_current_output_channels[] = { 1146 + static const struct iio_chan_spec ad74413r_current_output_channels[] = { 1147 1147 AD74413R_DAC_CHANNEL(IIO_CURRENT, BIT(IIO_CHAN_INFO_SCALE)), 1148 1148 AD74413R_ADC_VOLTAGE_CHANNEL, 1149 1149 }; 1150 1150 1151 - static struct iio_chan_spec ad74413r_voltage_input_channels[] = { 1151 + static const struct iio_chan_spec ad74413r_voltage_input_channels[] = { 1152 1152 AD74413R_ADC_VOLTAGE_CHANNEL, 1153 1153 }; 1154 1154 1155 - static struct iio_chan_spec ad74413r_current_input_channels[] = { 1155 + static const struct iio_chan_spec ad74413r_current_input_channels[] = { 1156 1156 AD74413R_ADC_CURRENT_CHANNEL, 1157 1157 }; 1158 1158 1159 - static struct iio_chan_spec ad74413r_current_input_loop_channels[] = { 1159 + static const struct iio_chan_spec ad74413r_current_input_loop_channels[] = { 1160 1160 AD74413R_DAC_CHANNEL(IIO_CURRENT, BIT(IIO_CHAN_INFO_SCALE)), 1161 1161 AD74413R_ADC_CURRENT_CHANNEL, 1162 1162 }; 1163 1163 1164 - static struct iio_chan_spec ad74413r_resistance_input_channels[] = { 1164 + static const struct iio_chan_spec ad74413r_resistance_input_channels[] = { 1165 1165 AD74413R_ADC_CHANNEL(IIO_RESISTANCE, BIT(IIO_CHAN_INFO_PROCESSED)), 1166 1166 }; 1167 1167 1168 - static struct iio_chan_spec ad74413r_digital_input_channels[] = { 1168 + static const struct iio_chan_spec ad74413r_digital_input_channels[] = { 1169 1169 AD74413R_ADC_VOLTAGE_CHANNEL, 1170 1170 }; 1171 1171 ··· 1270 1270 { 1271 1271 struct ad74413r_state *st = iio_priv(indio_dev); 1272 1272 struct ad74413r_channel_config *config; 1273 - struct iio_chan_spec *channels, *chans; 1273 + const struct iio_chan_spec *chans; 1274 + struct iio_chan_spec *channels; 1274 1275 unsigned int i, num_chans, chan_i; 1275 1276 int ret; 1276 1277