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: accel: bma180: Convert enum->pointer for data in the match table

Convert enum->pointer for data in the match table, so that
device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
bus type match support added to it.

Replace enum->struct *bma180_part_info for data in the match table and
simplify bma180_probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230812141044.151520-1-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Biju Das and committed by
Jonathan Cameron
fe11e389 9f6001e3

+11 -16
+11 -16
drivers/iio/accel/bma180.c
··· 926 926 struct device *dev = &client->dev; 927 927 struct bma180_data *data; 928 928 struct iio_dev *indio_dev; 929 - enum chip_ids chip; 930 929 int ret; 931 930 932 931 indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); ··· 935 936 data = iio_priv(indio_dev); 936 937 i2c_set_clientdata(client, indio_dev); 937 938 data->client = client; 938 - if (client->dev.of_node) 939 - chip = (uintptr_t)of_device_get_match_data(dev); 940 - else 941 - chip = id->driver_data; 942 - data->part_info = &bma180_part_info[chip]; 939 + data->part_info = i2c_get_match_data(client); 943 940 944 941 ret = iio_read_mount_matrix(dev, &data->orientation); 945 942 if (ret) ··· 1087 1092 static DEFINE_SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume); 1088 1093 1089 1094 static const struct i2c_device_id bma180_ids[] = { 1090 - { "bma023", BMA023 }, 1091 - { "bma150", BMA150 }, 1092 - { "bma180", BMA180 }, 1093 - { "bma250", BMA250 }, 1094 - { "smb380", BMA150 }, 1095 + { "bma023", (kernel_ulong_t)&bma180_part_info[BMA023] }, 1096 + { "bma150", (kernel_ulong_t)&bma180_part_info[BMA150] }, 1097 + { "bma180", (kernel_ulong_t)&bma180_part_info[BMA180] }, 1098 + { "bma250", (kernel_ulong_t)&bma180_part_info[BMA250] }, 1099 + { "smb380", (kernel_ulong_t)&bma180_part_info[BMA150] }, 1095 1100 { } 1096 1101 }; 1097 1102 ··· 1100 1105 static const struct of_device_id bma180_of_match[] = { 1101 1106 { 1102 1107 .compatible = "bosch,bma023", 1103 - .data = (void *)BMA023 1108 + .data = &bma180_part_info[BMA023] 1104 1109 }, 1105 1110 { 1106 1111 .compatible = "bosch,bma150", 1107 - .data = (void *)BMA150 1112 + .data = &bma180_part_info[BMA150] 1108 1113 }, 1109 1114 { 1110 1115 .compatible = "bosch,bma180", 1111 - .data = (void *)BMA180 1116 + .data = &bma180_part_info[BMA180] 1112 1117 }, 1113 1118 { 1114 1119 .compatible = "bosch,bma250", 1115 - .data = (void *)BMA250 1120 + .data = &bma180_part_info[BMA250] 1116 1121 }, 1117 1122 { 1118 1123 .compatible = "bosch,smb380", 1119 - .data = (void *)BMA150 1124 + .data = &bma180_part_info[BMA150] 1120 1125 }, 1121 1126 { } 1122 1127 };