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

regulator: max20086: Make similar OF and ID table

Make similar OF and ID table to extend support for ID match using
i2c_match_data(). Currently it works only for OF match tables as the
driver_data is wrong for ID match.

While at it, drop blank lines before MODULE_DEVICE_TABLE* and remove
trailing comma in the terminator entry for OF/ID table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230903154257.70800-1-biju.das.jz@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Biju Das and committed by
Mark Brown
9d9cd8e6 9e38482c

+31 -34
+31 -34
drivers/regulator/max20086-regulator.c
··· 223 223 return -ENOMEM; 224 224 225 225 chip->dev = &i2c->dev; 226 - chip->info = device_get_match_data(chip->dev); 226 + chip->info = i2c_get_match_data(i2c); 227 227 228 228 i2c_set_clientdata(i2c, chip); 229 229 ··· 275 275 return 0; 276 276 } 277 277 278 - static const struct i2c_device_id max20086_i2c_id[] = { 279 - { "max20086" }, 280 - { "max20087" }, 281 - { "max20088" }, 282 - { "max20089" }, 283 - { /* Sentinel */ }, 278 + static const struct max20086_chip_info max20086_chip_info = { 279 + .id = MAX20086_DEVICE_ID_MAX20086, 280 + .num_outputs = 4, 284 281 }; 285 282 283 + static const struct max20086_chip_info max20087_chip_info = { 284 + .id = MAX20086_DEVICE_ID_MAX20087, 285 + .num_outputs = 4, 286 + }; 287 + 288 + static const struct max20086_chip_info max20088_chip_info = { 289 + .id = MAX20086_DEVICE_ID_MAX20088, 290 + .num_outputs = 2, 291 + }; 292 + 293 + static const struct max20086_chip_info max20089_chip_info = { 294 + .id = MAX20086_DEVICE_ID_MAX20089, 295 + .num_outputs = 2, 296 + }; 297 + 298 + static const struct i2c_device_id max20086_i2c_id[] = { 299 + { "max20086", (kernel_ulong_t)&max20086_chip_info }, 300 + { "max20087", (kernel_ulong_t)&max20087_chip_info }, 301 + { "max20088", (kernel_ulong_t)&max20088_chip_info }, 302 + { "max20089", (kernel_ulong_t)&max20089_chip_info }, 303 + { /* Sentinel */ } 304 + }; 286 305 MODULE_DEVICE_TABLE(i2c, max20086_i2c_id); 287 306 288 307 static const struct of_device_id max20086_dt_ids[] __maybe_unused = { 289 - { 290 - .compatible = "maxim,max20086", 291 - .data = &(const struct max20086_chip_info) { 292 - .id = MAX20086_DEVICE_ID_MAX20086, 293 - .num_outputs = 4, 294 - } 295 - }, { 296 - .compatible = "maxim,max20087", 297 - .data = &(const struct max20086_chip_info) { 298 - .id = MAX20086_DEVICE_ID_MAX20087, 299 - .num_outputs = 4, 300 - } 301 - }, { 302 - .compatible = "maxim,max20088", 303 - .data = &(const struct max20086_chip_info) { 304 - .id = MAX20086_DEVICE_ID_MAX20088, 305 - .num_outputs = 2, 306 - } 307 - }, { 308 - .compatible = "maxim,max20089", 309 - .data = &(const struct max20086_chip_info) { 310 - .id = MAX20086_DEVICE_ID_MAX20089, 311 - .num_outputs = 2, 312 - } 313 - }, 314 - { /* Sentinel */ }, 308 + { .compatible = "maxim,max20086", .data = &max20086_chip_info }, 309 + { .compatible = "maxim,max20087", .data = &max20087_chip_info }, 310 + { .compatible = "maxim,max20088", .data = &max20088_chip_info }, 311 + { .compatible = "maxim,max20089", .data = &max20089_chip_info }, 312 + { /* Sentinel */ } 315 313 }; 316 - 317 314 MODULE_DEVICE_TABLE(of, max20086_dt_ids); 318 315 319 316 static struct i2c_driver max20086_regulator_driver = {