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

i2c: rk3x: account for const type of of_device_id.data

This driver creates a number of const structures that it stores in
the data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified. The
const-discarding cast on the extraction from the data field is thus
no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Julia Lawall and committed by
Wolfram Sang
d032a2eb f89813ec

+8 -8
+8 -8
drivers/i2c/busses/i2c-rk3x.c
··· 194 194 struct rk3x_i2c { 195 195 struct i2c_adapter adap; 196 196 struct device *dev; 197 - struct rk3x_i2c_soc_data *soc_data; 197 + const struct rk3x_i2c_soc_data *soc_data; 198 198 199 199 /* Hardware resources */ 200 200 void __iomem *regs; ··· 1164 1164 static const struct of_device_id rk3x_i2c_match[] = { 1165 1165 { 1166 1166 .compatible = "rockchip,rv1108-i2c", 1167 - .data = (void *)&rv1108_soc_data 1167 + .data = &rv1108_soc_data 1168 1168 }, 1169 1169 { 1170 1170 .compatible = "rockchip,rk3066-i2c", 1171 - .data = (void *)&rk3066_soc_data 1171 + .data = &rk3066_soc_data 1172 1172 }, 1173 1173 { 1174 1174 .compatible = "rockchip,rk3188-i2c", 1175 - .data = (void *)&rk3188_soc_data 1175 + .data = &rk3188_soc_data 1176 1176 }, 1177 1177 { 1178 1178 .compatible = "rockchip,rk3228-i2c", 1179 - .data = (void *)&rk3228_soc_data 1179 + .data = &rk3228_soc_data 1180 1180 }, 1181 1181 { 1182 1182 .compatible = "rockchip,rk3288-i2c", 1183 - .data = (void *)&rk3288_soc_data 1183 + .data = &rk3288_soc_data 1184 1184 }, 1185 1185 { 1186 1186 .compatible = "rockchip,rk3399-i2c", 1187 - .data = (void *)&rk3399_soc_data 1187 + .data = &rk3399_soc_data 1188 1188 }, 1189 1189 {}, 1190 1190 }; ··· 1207 1207 return -ENOMEM; 1208 1208 1209 1209 match = of_match_node(rk3x_i2c_match, np); 1210 - i2c->soc_data = (struct rk3x_i2c_soc_data *)match->data; 1210 + i2c->soc_data = match->data; 1211 1211 1212 1212 /* use common interface to get I2C timing properties */ 1213 1213 i2c_parse_fw_timings(&pdev->dev, &i2c->t, true);