Skip to content

Commit f68afce

Browse files
ukleinekjic23
authored andcommitted
iio: Initialize i2c_device_id arrays using member names
While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition. The mentioned robustness is relevant for a planned change to struct i2c_device_id that replaces .driver_data by an anonymous union. This patch doesn't modify the compiled arrays, only their representation in source form benefits. The former was confirmed with x86 and arm64 builds. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Reviewed-by: Siratul Islam <email@sirat.me> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent c465785 commit f68afce

208 files changed

Lines changed: 680 additions & 658 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/iio/accel/adxl345_i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static const struct adxl345_chip_info adxl375_i2c_info = {
4343
};
4444

4545
static const struct i2c_device_id adxl345_i2c_id[] = {
46-
{ "adxl345", (kernel_ulong_t)&adxl345_i2c_info },
47-
{ "adxl375", (kernel_ulong_t)&adxl375_i2c_info },
46+
{ .name = "adxl345", .driver_data = (kernel_ulong_t)&adxl345_i2c_info },
47+
{ .name = "adxl375", .driver_data = (kernel_ulong_t)&adxl375_i2c_info },
4848
{ }
4949
};
5050
MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id);

drivers/iio/accel/adxl355_i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static int adxl355_i2c_probe(struct i2c_client *client)
3838
}
3939

4040
static const struct i2c_device_id adxl355_i2c_id[] = {
41-
{ "adxl355", (kernel_ulong_t)&adxl35x_chip_info[ADXL355] },
42-
{ "adxl359", (kernel_ulong_t)&adxl35x_chip_info[ADXL359] },
41+
{ .name = "adxl355", .driver_data = (kernel_ulong_t)&adxl35x_chip_info[ADXL355] },
42+
{ .name = "adxl359", .driver_data = (kernel_ulong_t)&adxl35x_chip_info[ADXL359] },
4343
{ }
4444
};
4545
MODULE_DEVICE_TABLE(i2c, adxl355_i2c_id);

drivers/iio/accel/adxl367_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int adxl367_i2c_probe(struct i2c_client *client)
6161
}
6262

6363
static const struct i2c_device_id adxl367_i2c_id[] = {
64-
{ "adxl367" },
64+
{ .name = "adxl367" },
6565
{ }
6666
};
6767
MODULE_DEVICE_TABLE(i2c, adxl367_i2c_id);

drivers/iio/accel/adxl372_i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ static int adxl372_i2c_probe(struct i2c_client *client)
4444
}
4545

4646
static const struct i2c_device_id adxl372_i2c_id[] = {
47-
{ "adxl371", (kernel_ulong_t)&adxl371_chip_info },
48-
{ "adxl372", (kernel_ulong_t)&adxl372_chip_info },
47+
{ .name = "adxl371", .driver_data = (kernel_ulong_t)&adxl371_chip_info },
48+
{ .name = "adxl372", .driver_data = (kernel_ulong_t)&adxl372_chip_info },
4949
{ }
5050
};
5151
MODULE_DEVICE_TABLE(i2c, adxl372_i2c_id);

drivers/iio/accel/adxl380_i2c.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ static int adxl380_i2c_probe(struct i2c_client *client)
3333
}
3434

3535
static const struct i2c_device_id adxl380_i2c_id[] = {
36-
{ "adxl318", (kernel_ulong_t)&adxl318_chip_info },
37-
{ "adxl319", (kernel_ulong_t)&adxl319_chip_info },
38-
{ "adxl380", (kernel_ulong_t)&adxl380_chip_info },
39-
{ "adxl382", (kernel_ulong_t)&adxl382_chip_info },
36+
{ .name = "adxl318", .driver_data = (kernel_ulong_t)&adxl318_chip_info },
37+
{ .name = "adxl319", .driver_data = (kernel_ulong_t)&adxl319_chip_info },
38+
{ .name = "adxl380", .driver_data = (kernel_ulong_t)&adxl380_chip_info },
39+
{ .name = "adxl382", .driver_data = (kernel_ulong_t)&adxl382_chip_info },
4040
{ }
4141
};
4242
MODULE_DEVICE_TABLE(i2c, adxl380_i2c_id);

drivers/iio/accel/bma180.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,11 +1083,11 @@ static int bma180_resume(struct device *dev)
10831083
static DEFINE_SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
10841084

10851085
static const struct i2c_device_id bma180_ids[] = {
1086-
{ "bma023", (kernel_ulong_t)&bma180_part_info[BMA023] },
1087-
{ "bma150", (kernel_ulong_t)&bma180_part_info[BMA150] },
1088-
{ "bma180", (kernel_ulong_t)&bma180_part_info[BMA180] },
1089-
{ "bma250", (kernel_ulong_t)&bma180_part_info[BMA250] },
1090-
{ "smb380", (kernel_ulong_t)&bma180_part_info[BMA150] },
1086+
{ .name = "bma023", .driver_data = (kernel_ulong_t)&bma180_part_info[BMA023] },
1087+
{ .name = "bma150", .driver_data = (kernel_ulong_t)&bma180_part_info[BMA150] },
1088+
{ .name = "bma180", .driver_data = (kernel_ulong_t)&bma180_part_info[BMA180] },
1089+
{ .name = "bma250", .driver_data = (kernel_ulong_t)&bma180_part_info[BMA250] },
1090+
{ .name = "smb380", .driver_data = (kernel_ulong_t)&bma180_part_info[BMA150] },
10911091
{ }
10921092
};
10931093

drivers/iio/accel/bma220_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static const struct of_device_id bma220_i2c_match[] = {
4747
MODULE_DEVICE_TABLE(of, bma220_i2c_match);
4848

4949
static const struct i2c_device_id bma220_i2c_id[] = {
50-
{ "bma220" },
50+
{ .name = "bma220" },
5151
{ }
5252
};
5353
MODULE_DEVICE_TABLE(i2c, bma220_i2c_id);

drivers/iio/accel/bma400_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static int bma400_i2c_probe(struct i2c_client *client)
2828
}
2929

3030
static const struct i2c_device_id bma400_i2c_ids[] = {
31-
{ "bma400" },
31+
{ .name = "bma400" },
3232
{ }
3333
};
3434
MODULE_DEVICE_TABLE(i2c, bma400_i2c_ids);

drivers/iio/accel/bmi088-accel-i2c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ static const struct of_device_id bmi088_of_match[] = {
4545
MODULE_DEVICE_TABLE(of, bmi088_of_match);
4646

4747
static const struct i2c_device_id bmi088_accel_id[] = {
48-
{ "bmi085-accel", BOSCH_BMI085 },
49-
{ "bmi088-accel", BOSCH_BMI088 },
50-
{ "bmi090l-accel", BOSCH_BMI090L },
48+
{ .name = "bmi085-accel", .driver_data = BOSCH_BMI085 },
49+
{ .name = "bmi088-accel", .driver_data = BOSCH_BMI088 },
50+
{ .name = "bmi090l-accel", .driver_data = BOSCH_BMI090L },
5151
{ }
5252
};
5353
MODULE_DEVICE_TABLE(i2c, bmi088_accel_id);

drivers/iio/accel/da280.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ static const struct acpi_device_id da280_acpi_match[] = {
162162
MODULE_DEVICE_TABLE(acpi, da280_acpi_match);
163163

164164
static const struct i2c_device_id da280_i2c_id[] = {
165-
{ "da217", (kernel_ulong_t)&da217_match_data },
166-
{ "da226", (kernel_ulong_t)&da226_match_data },
167-
{ "da280", (kernel_ulong_t)&da280_match_data },
165+
{ .name = "da217", .driver_data = (kernel_ulong_t)&da217_match_data },
166+
{ .name = "da226", .driver_data = (kernel_ulong_t)&da226_match_data },
167+
{ .name = "da280", .driver_data = (kernel_ulong_t)&da280_match_data },
168168
{ }
169169
};
170170
MODULE_DEVICE_TABLE(i2c, da280_i2c_id);

0 commit comments

Comments
 (0)