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

hwmon (pmbus) use simple i2c probe function

pmbus_do_probe doesn't use the id information provided in its second
argument, so this can be removed, which then allows using the
single-parameter i2c probe function ("probe_new") for probes.

This avoids scanning the identifier tables during probes.

Drivers which didn't use the id are converted as-is; drivers which did
are modified as follows:

* if the information in i2c_client is sufficient, that's used instead
(client->name);
* configured v. probed comparisons are performed by comparing the
configured name to the detected name, instead of the ids; this
involves strcmp but is still cheaper than comparing all the device
names when scanning the tables;
* anything else is handled by calling i2c_match_id() with the same
level of error-handling (if any) as before.

Additionally, the mismatch message in the ltc2978 driver is adjusted
so that it no longer assumes that the driver_data is an index into
ltc2978_id.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Acked-by: Wolfram Sang <wsa@kernel.org>
Link: https://lore.kernel.org/r/20200808210004.30880-1-steve@sk2.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Stephen Kitt and committed by
Guenter Roeck
dd431939 e4035839

+131 -138
+1 -2
Documentation/hwmon/pmbus-core.rst
··· 270 270 271 271 :: 272 272 273 - int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 274 - struct pmbus_driver_info *info); 273 + int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info); 275 274 276 275 Execute probe function. Similar to standard probe function for other drivers, 277 276 with the pointer to struct pmbus_driver_info as additional argument. Calls
+3 -4
Documentation/hwmon/pmbus.rst
··· 143 143 | PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12, 144 144 }; 145 145 146 - static int ds1200_probe(struct i2c_client *client, 147 - const struct i2c_device_id *id) 146 + static int ds1200_probe(struct i2c_client *client) 148 147 { 149 - return pmbus_do_probe(client, id, &ds1200_info); 148 + return pmbus_do_probe(client, &ds1200_info); 150 149 } 151 150 152 151 static int ds1200_remove(struct i2c_client *client) ··· 165 166 .driver = { 166 167 .name = "ds1200", 167 168 }, 168 - .probe = ds1200_probe, 169 + .probe_new = ds1200_probe, 169 170 .remove = ds1200_remove, 170 171 .id_table = ds1200_id, 171 172 };
+5 -6
drivers/hwmon/pmbus/adm1275.c
··· 462 462 }; 463 463 MODULE_DEVICE_TABLE(i2c, adm1275_id); 464 464 465 - static int adm1275_probe(struct i2c_client *client, 466 - const struct i2c_device_id *id) 465 + static int adm1275_probe(struct i2c_client *client) 467 466 { 468 467 s32 (*config_read_fn)(const struct i2c_client *client, u8 reg); 469 468 u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; ··· 505 506 return -ENODEV; 506 507 } 507 508 508 - if (id->driver_data != mid->driver_data) 509 + if (strcmp(client->name, mid->name) != 0) 509 510 dev_notice(&client->dev, 510 511 "Device mismatch: Configured %s, detected %s\n", 511 - id->name, mid->name); 512 + client->name, mid->name); 512 513 513 514 if (mid->driver_data == adm1272 || mid->driver_data == adm1278 || 514 515 mid->driver_data == adm1293 || mid->driver_data == adm1294) ··· 789 790 info->R[PSC_TEMPERATURE] = coefficients[tindex].R; 790 791 } 791 792 792 - return pmbus_do_probe(client, id, info); 793 + return pmbus_do_probe(client, info); 793 794 } 794 795 795 796 static struct i2c_driver adm1275_driver = { 796 797 .driver = { 797 798 .name = "adm1275", 798 799 }, 799 - .probe = adm1275_probe, 800 + .probe_new = adm1275_probe, 800 801 .remove = pmbus_do_remove, 801 802 .id_table = adm1275_id, 802 803 };
+6 -5
drivers/hwmon/pmbus/bel-pfe.c
··· 87 87 }, 88 88 }; 89 89 90 - static int pfe_pmbus_probe(struct i2c_client *client, 91 - const struct i2c_device_id *id) 90 + static const struct i2c_device_id pfe_device_id[]; 91 + 92 + static int pfe_pmbus_probe(struct i2c_client *client) 92 93 { 93 94 int model; 94 95 95 - model = (int)id->driver_data; 96 + model = (int)i2c_match_id(pfe_device_id, client)->driver_data; 96 97 97 98 /* 98 99 * PFE3000-12-069RA devices may not stay in page 0 during device ··· 105 104 i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); 106 105 } 107 106 108 - return pmbus_do_probe(client, id, &pfe_driver_info[model]); 107 + return pmbus_do_probe(client, &pfe_driver_info[model]); 109 108 } 110 109 111 110 static const struct i2c_device_id pfe_device_id[] = { ··· 120 119 .driver = { 121 120 .name = "bel-pfe", 122 121 }, 123 - .probe = pfe_pmbus_probe, 122 + .probe_new = pfe_pmbus_probe, 124 123 .remove = pmbus_do_remove, 125 124 .id_table = pfe_device_id, 126 125 };
+12 -7
drivers/hwmon/pmbus/ibm-cffps.c
··· 91 91 struct led_classdev led; 92 92 }; 93 93 94 + static const struct i2c_device_id ibm_cffps_id[]; 95 + 94 96 #define to_psu(x, y) container_of((x), struct ibm_cffps, debugfs_entries[(y)]) 95 97 96 98 static ssize_t ibm_cffps_read_input_history(struct ibm_cffps *psu, ··· 475 473 .flags = PMBUS_SKIP_STATUS_CHECK, 476 474 }; 477 475 478 - static int ibm_cffps_probe(struct i2c_client *client, 479 - const struct i2c_device_id *id) 476 + static int ibm_cffps_probe(struct i2c_client *client) 480 477 { 481 478 int i, rc; 482 479 enum versions vs = cffps_unknown; ··· 483 482 struct dentry *ibm_cffps_dir; 484 483 struct ibm_cffps *psu; 485 484 const void *md = of_device_get_match_data(&client->dev); 485 + const struct i2c_device_id *id; 486 486 487 - if (md) 487 + if (md) { 488 488 vs = (enum versions)md; 489 - else if (id) 490 - vs = (enum versions)id->driver_data; 489 + } else { 490 + id = i2c_match_id(ibm_cffps_id, client); 491 + if (id) 492 + vs = (enum versions)id->driver_data; 493 + } 491 494 492 495 if (vs == cffps_unknown) { 493 496 u16 ccin_revision = 0; ··· 524 519 } 525 520 526 521 client->dev.platform_data = &ibm_cffps_pdata; 527 - rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs]); 522 + rc = pmbus_do_probe(client, &ibm_cffps_info[vs]); 528 523 if (rc) 529 524 return rc; 530 525 ··· 616 611 .name = "ibm-cffps", 617 612 .of_match_table = ibm_cffps_of_match, 618 613 }, 619 - .probe = ibm_cffps_probe, 614 + .probe_new = ibm_cffps_probe, 620 615 .remove = pmbus_do_remove, 621 616 .id_table = ibm_cffps_id, 622 617 };
+3 -4
drivers/hwmon/pmbus/inspur-ipsps.c
··· 190 190 .flags = PMBUS_SKIP_STATUS_CHECK, 191 191 }; 192 192 193 - static int ipsps_probe(struct i2c_client *client, 194 - const struct i2c_device_id *id) 193 + static int ipsps_probe(struct i2c_client *client) 195 194 { 196 195 client->dev.platform_data = &ipsps_pdata; 197 - return pmbus_do_probe(client, id, &ipsps_info); 196 + return pmbus_do_probe(client, &ipsps_info); 198 197 } 199 198 200 199 static const struct i2c_device_id ipsps_id[] = { ··· 215 216 .name = "inspur-ipsps", 216 217 .of_match_table = of_match_ptr(ipsps_of_match), 217 218 }, 218 - .probe = ipsps_probe, 219 + .probe_new = ipsps_probe, 219 220 .remove = pmbus_do_remove, 220 221 .id_table = ipsps_id, 221 222 };
+3 -4
drivers/hwmon/pmbus/ir35221.c
··· 67 67 return ret; 68 68 } 69 69 70 - static int ir35221_probe(struct i2c_client *client, 71 - const struct i2c_device_id *id) 70 + static int ir35221_probe(struct i2c_client *client) 72 71 { 73 72 struct pmbus_driver_info *info; 74 73 u8 buf[I2C_SMBUS_BLOCK_MAX]; ··· 122 123 | PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP; 123 124 info->func[1] = info->func[0]; 124 125 125 - return pmbus_do_probe(client, id, info); 126 + return pmbus_do_probe(client, info); 126 127 } 127 128 128 129 static const struct i2c_device_id ir35221_id[] = { ··· 136 137 .driver = { 137 138 .name = "ir35221", 138 139 }, 139 - .probe = ir35221_probe, 140 + .probe_new = ir35221_probe, 140 141 .remove = pmbus_do_remove, 141 142 .id_table = ir35221_id, 142 143 };
+3 -4
drivers/hwmon/pmbus/ir38064.c
··· 35 35 | PMBUS_HAVE_POUT, 36 36 }; 37 37 38 - static int ir38064_probe(struct i2c_client *client, 39 - const struct i2c_device_id *id) 38 + static int ir38064_probe(struct i2c_client *client) 40 39 { 41 - return pmbus_do_probe(client, id, &ir38064_info); 40 + return pmbus_do_probe(client, &ir38064_info); 42 41 } 43 42 44 43 static const struct i2c_device_id ir38064_id[] = { ··· 52 53 .driver = { 53 54 .name = "ir38064", 54 55 }, 55 - .probe = ir38064_probe, 56 + .probe_new = ir38064_probe, 56 57 .remove = pmbus_do_remove, 57 58 .id_table = ir38064_id, 58 59 };
+3 -4
drivers/hwmon/pmbus/irps5401.c
··· 38 38 .func[4] = IRPS5401_LDO_FUNC, 39 39 }; 40 40 41 - static int irps5401_probe(struct i2c_client *client, 42 - const struct i2c_device_id *id) 41 + static int irps5401_probe(struct i2c_client *client) 43 42 { 44 - return pmbus_do_probe(client, id, &irps5401_info); 43 + return pmbus_do_probe(client, &irps5401_info); 45 44 } 46 45 47 46 static const struct i2c_device_id irps5401_id[] = { ··· 54 55 .driver = { 55 56 .name = "irps5401", 56 57 }, 57 - .probe = irps5401_probe, 58 + .probe_new = irps5401_probe, 58 59 .remove = pmbus_do_remove, 59 60 .id_table = irps5401_id, 60 61 };
+6 -5
drivers/hwmon/pmbus/isl68137.c
··· 72 72 raa_dmpvr2_hv, 73 73 }; 74 74 75 + static const struct i2c_device_id raa_dmpvr_id[]; 76 + 75 77 static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client, 76 78 int page, 77 79 char *buf) ··· 220 218 | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT, 221 219 }; 222 220 223 - static int isl68137_probe(struct i2c_client *client, 224 - const struct i2c_device_id *id) 221 + static int isl68137_probe(struct i2c_client *client) 225 222 { 226 223 struct pmbus_driver_info *info; 227 224 ··· 229 228 return -ENOMEM; 230 229 memcpy(info, &raa_dmpvr_info, sizeof(*info)); 231 230 232 - switch (id->driver_data) { 231 + switch (i2c_match_id(raa_dmpvr_id, client)->driver_data) { 233 232 case raa_dmpvr1_2rail: 234 233 info->pages = 2; 235 234 info->R[PSC_VOLTAGE_IN] = 3; ··· 268 267 return -ENODEV; 269 268 } 270 269 271 - return pmbus_do_probe(client, id, info); 270 + return pmbus_do_probe(client, info); 272 271 } 273 272 274 273 static const struct i2c_device_id raa_dmpvr_id[] = { ··· 323 322 .driver = { 324 323 .name = "isl68137", 325 324 }, 326 - .probe = isl68137_probe, 325 + .probe_new = isl68137_probe, 327 326 .remove = pmbus_do_remove, 328 327 .id_table = raa_dmpvr_id, 329 328 };
+6 -5
drivers/hwmon/pmbus/lm25066.c
··· 211 211 212 212 #define to_lm25066_data(x) container_of(x, struct lm25066_data, info) 213 213 214 + static const struct i2c_device_id lm25066_id[]; 215 + 214 216 static int lm25066_read_word_data(struct i2c_client *client, int page, 215 217 int phase, int reg) 216 218 { ··· 418 416 return ret; 419 417 } 420 418 421 - static int lm25066_probe(struct i2c_client *client, 422 - const struct i2c_device_id *id) 419 + static int lm25066_probe(struct i2c_client *client) 423 420 { 424 421 int config; 425 422 struct lm25066_data *data; ··· 438 437 if (config < 0) 439 438 return config; 440 439 441 - data->id = id->driver_data; 440 + data->id = i2c_match_id(lm25066_id, client)->driver_data; 442 441 info = &data->info; 443 442 444 443 info->pages = 1; ··· 488 487 info->b[PSC_POWER] = coeff[PSC_POWER].b; 489 488 } 490 489 491 - return pmbus_do_probe(client, id, info); 490 + return pmbus_do_probe(client, info); 492 491 } 493 492 494 493 static const struct i2c_device_id lm25066_id[] = { ··· 507 506 .driver = { 508 507 .name = "lm25066", 509 508 }, 510 - .probe = lm25066_probe, 509 + .probe_new = lm25066_probe, 511 510 .remove = pmbus_do_remove, 512 511 .id_table = lm25066_id, 513 512 };
+8 -6
drivers/hwmon/pmbus/ltc2978.c
··· 649 649 return -ENODEV; 650 650 } 651 651 652 - static int ltc2978_probe(struct i2c_client *client, 653 - const struct i2c_device_id *id) 652 + static int ltc2978_probe(struct i2c_client *client) 654 653 { 655 654 int i, chip_id; 656 655 struct ltc2978_data *data; 657 656 struct pmbus_driver_info *info; 657 + const struct i2c_device_id *id; 658 658 659 659 if (!i2c_check_functionality(client->adapter, 660 660 I2C_FUNC_SMBUS_READ_WORD_DATA)) ··· 670 670 return chip_id; 671 671 672 672 data->id = chip_id; 673 + id = i2c_match_id(ltc2978_id, client); 673 674 if (data->id != id->driver_data) 674 675 dev_warn(&client->dev, 675 - "Device mismatch: Configured %s, detected %s\n", 676 + "Device mismatch: Configured %s (%d), detected %d\n", 676 677 id->name, 677 - ltc2978_id[data->id].name); 678 + (int) id->driver_data, 679 + chip_id); 678 680 679 681 info = &data->info; 680 682 info->write_word_data = ltc2978_write_word_data; ··· 834 832 } 835 833 #endif 836 834 837 - return pmbus_do_probe(client, id, info); 835 + return pmbus_do_probe(client, info); 838 836 } 839 837 840 838 ··· 874 872 .name = "ltc2978", 875 873 .of_match_table = of_match_ptr(ltc2978_of_match), 876 874 }, 877 - .probe = ltc2978_probe, 875 + .probe_new = ltc2978_probe, 878 876 .remove = pmbus_do_remove, 879 877 .id_table = ltc2978_id, 880 878 };
+3 -4
drivers/hwmon/pmbus/ltc3815.c
··· 178 178 .write_word_data = ltc3815_write_word_data, 179 179 }; 180 180 181 - static int ltc3815_probe(struct i2c_client *client, 182 - const struct i2c_device_id *id) 181 + static int ltc3815_probe(struct i2c_client *client) 183 182 { 184 183 int chip_id; 185 184 ··· 192 193 if ((chip_id & LTC3815_ID_MASK) != LTC3815_ID) 193 194 return -ENODEV; 194 195 195 - return pmbus_do_probe(client, id, &ltc3815_info); 196 + return pmbus_do_probe(client, &ltc3815_info); 196 197 } 197 198 198 199 static struct i2c_driver ltc3815_driver = { 199 200 .driver = { 200 201 .name = "ltc3815", 201 202 }, 202 - .probe = ltc3815_probe, 203 + .probe_new = ltc3815_probe, 203 204 .remove = pmbus_do_remove, 204 205 .id_table = ltc3815_id, 205 206 };
+3 -4
drivers/hwmon/pmbus/max16064.c
··· 85 85 .write_word_data = max16064_write_word_data, 86 86 }; 87 87 88 - static int max16064_probe(struct i2c_client *client, 89 - const struct i2c_device_id *id) 88 + static int max16064_probe(struct i2c_client *client) 90 89 { 91 - return pmbus_do_probe(client, id, &max16064_info); 90 + return pmbus_do_probe(client, &max16064_info); 92 91 } 93 92 94 93 static const struct i2c_device_id max16064_id[] = { ··· 102 103 .driver = { 103 104 .name = "max16064", 104 105 }, 105 - .probe = max16064_probe, 106 + .probe_new = max16064_probe, 106 107 .remove = pmbus_do_remove, 107 108 .id_table = max16064_id, 108 109 };
+3 -4
drivers/hwmon/pmbus/max16601.c
··· 239 239 i2c_unregister_device(data->vsa); 240 240 } 241 241 242 - static int max16601_probe(struct i2c_client *client, 243 - const struct i2c_device_id *id) 242 + static int max16601_probe(struct i2c_client *client) 244 243 { 245 244 struct device *dev = &client->dev; 246 245 u8 buf[I2C_SMBUS_BLOCK_MAX + 1]; ··· 287 288 288 289 data->info = max16601_info; 289 290 290 - return pmbus_do_probe(client, id, &data->info); 291 + return pmbus_do_probe(client, &data->info); 291 292 } 292 293 293 294 static const struct i2c_device_id max16601_id[] = { ··· 301 302 .driver = { 302 303 .name = "max16601", 303 304 }, 304 - .probe = max16601_probe, 305 + .probe_new = max16601_probe, 305 306 .remove = pmbus_do_remove, 306 307 .id_table = max16601_id, 307 308 };
+6 -5
drivers/hwmon/pmbus/max20730.c
··· 37 37 38 38 #define MAX20730_MFR_DEVSET1 0xd2 39 39 40 + static const struct i2c_device_id max20730_id[]; 41 + 40 42 /* 41 43 * Convert discreet value to direct data format. Strictly speaking, all passed 42 44 * values are constants, so we could do that calculation manually. On the ··· 297 295 }, 298 296 }; 299 297 300 - static int max20730_probe(struct i2c_client *client, 301 - const struct i2c_device_id *id) 298 + static int max20730_probe(struct i2c_client *client) 302 299 { 303 300 struct device *dev = &client->dev; 304 301 u8 buf[I2C_SMBUS_BLOCK_MAX + 1]; ··· 357 356 if (client->dev.of_node) 358 357 chip_id = (enum chips)of_device_get_match_data(dev); 359 358 else 360 - chip_id = id->driver_data; 359 + chip_id = i2c_match_id(max20730_id, client)->driver_data; 361 360 362 361 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 363 362 if (!data) ··· 371 370 return ret; 372 371 data->mfr_devset1 = ret; 373 372 374 - return pmbus_do_probe(client, id, &data->info); 373 + return pmbus_do_probe(client, &data->info); 375 374 } 376 375 377 376 static const struct i2c_device_id max20730_id[] = { ··· 399 398 .name = "max20730", 400 399 .of_match_table = max20730_of_match, 401 400 }, 402 - .probe = max20730_probe, 401 + .probe_new = max20730_probe, 403 402 .remove = pmbus_do_remove, 404 403 .id_table = max20730_id, 405 404 };
+3 -4
drivers/hwmon/pmbus/max20751.c
··· 26 26 PMBUS_HAVE_POUT, 27 27 }; 28 28 29 - static int max20751_probe(struct i2c_client *client, 30 - const struct i2c_device_id *id) 29 + static int max20751_probe(struct i2c_client *client) 31 30 { 32 - return pmbus_do_probe(client, id, &max20751_info); 31 + return pmbus_do_probe(client, &max20751_info); 33 32 } 34 33 35 34 static const struct i2c_device_id max20751_id[] = { ··· 42 43 .driver = { 43 44 .name = "max20751", 44 45 }, 45 - .probe = max20751_probe, 46 + .probe_new = max20751_probe, 46 47 .remove = pmbus_do_remove, 47 48 .id_table = max20751_id, 48 49 };
+4 -5
drivers/hwmon/pmbus/max31785.c
··· 324 324 return 0; 325 325 } 326 326 327 - static int max31785_probe(struct i2c_client *client, 328 - const struct i2c_device_id *id) 327 + static int max31785_probe(struct i2c_client *client) 329 328 { 330 329 struct device *dev = &client->dev; 331 330 struct pmbus_driver_info *info; ··· 353 354 if (ret == MAX31785A) { 354 355 dual_tach = true; 355 356 } else if (ret == MAX31785) { 356 - if (!strcmp("max31785a", id->name)) 357 + if (!strcmp("max31785a", client->name)) 357 358 dev_warn(dev, "Expected max3175a, found max31785: cannot provide secondary tachometer readings\n"); 358 359 } else { 359 360 return -ENODEV; ··· 365 366 return ret; 366 367 } 367 368 368 - return pmbus_do_probe(client, id, info); 369 + return pmbus_do_probe(client, info); 369 370 } 370 371 371 372 static const struct i2c_device_id max31785_id[] = { ··· 389 390 .name = "max31785", 390 391 .of_match_table = max31785_of_match, 391 392 }, 392 - .probe = max31785_probe, 393 + .probe_new = max31785_probe, 393 394 .remove = pmbus_do_remove, 394 395 .id_table = max31785_id, 395 396 };
+7 -6
drivers/hwmon/pmbus/max34440.c
··· 41 41 42 42 #define to_max34440_data(x) container_of(x, struct max34440_data, info) 43 43 44 + static const struct i2c_device_id max34440_id[]; 45 + 44 46 static int max34440_read_word_data(struct i2c_client *client, int page, 45 47 int phase, int reg) 46 48 { ··· 460 458 }, 461 459 }; 462 460 463 - static int max34440_probe(struct i2c_client *client, 464 - const struct i2c_device_id *id) 461 + static int max34440_probe(struct i2c_client *client) 465 462 { 466 463 struct max34440_data *data; 467 464 int rv; ··· 469 468 GFP_KERNEL); 470 469 if (!data) 471 470 return -ENOMEM; 472 - data->id = id->driver_data; 473 - data->info = max34440_info[id->driver_data]; 471 + data->id = i2c_match_id(max34440_id, client)->driver_data; 472 + data->info = max34440_info[data->id]; 474 473 475 474 if (data->id == max34451) { 476 475 rv = max34451_set_supported_funcs(client, data); ··· 478 477 return rv; 479 478 } 480 479 481 - return pmbus_do_probe(client, id, &data->info); 480 + return pmbus_do_probe(client, &data->info); 482 481 } 483 482 484 483 static const struct i2c_device_id max34440_id[] = { ··· 497 496 .driver = { 498 497 .name = "max34440", 499 498 }, 500 - .probe = max34440_probe, 499 + .probe_new = max34440_probe, 501 500 .remove = pmbus_do_remove, 502 501 .id_table = max34440_id, 503 502 };
+3 -4
drivers/hwmon/pmbus/max8688.c
··· 165 165 .write_word_data = max8688_write_word_data, 166 166 }; 167 167 168 - static int max8688_probe(struct i2c_client *client, 169 - const struct i2c_device_id *id) 168 + static int max8688_probe(struct i2c_client *client) 170 169 { 171 - return pmbus_do_probe(client, id, &max8688_info); 170 + return pmbus_do_probe(client, &max8688_info); 172 171 } 173 172 174 173 static const struct i2c_device_id max8688_id[] = { ··· 182 183 .driver = { 183 184 .name = "max8688", 184 185 }, 185 - .probe = max8688_probe, 186 + .probe_new = max8688_probe, 186 187 .remove = pmbus_do_remove, 187 188 .id_table = max8688_id, 188 189 };
+6 -5
drivers/hwmon/pmbus/pmbus.c
··· 20 20 u32 flags; 21 21 }; 22 22 23 + static const struct i2c_device_id pmbus_id[]; 24 + 23 25 /* 24 26 * Find sensor groups and status registers on each page. 25 27 */ ··· 161 159 return ret; 162 160 } 163 161 164 - static int pmbus_probe(struct i2c_client *client, 165 - const struct i2c_device_id *id) 162 + static int pmbus_probe(struct i2c_client *client) 166 163 { 167 164 struct pmbus_driver_info *info; 168 165 struct pmbus_platform_data *pdata = NULL; ··· 172 171 if (!info) 173 172 return -ENOMEM; 174 173 175 - device_info = (struct pmbus_device_info *)id->driver_data; 174 + device_info = (struct pmbus_device_info *)i2c_match_id(pmbus_id, client)->driver_data; 176 175 if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) { 177 176 pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data), 178 177 GFP_KERNEL); ··· 186 185 info->identify = pmbus_identify; 187 186 dev->platform_data = pdata; 188 187 189 - return pmbus_do_probe(client, id, info); 188 + return pmbus_do_probe(client, info); 190 189 } 191 190 192 191 static const struct pmbus_device_info pmbus_info_one = { ··· 237 236 .driver = { 238 237 .name = "pmbus", 239 238 }, 240 - .probe = pmbus_probe, 239 + .probe_new = pmbus_probe, 241 240 .remove = pmbus_do_remove, 242 241 .id_table = pmbus_id, 243 242 };
+1 -2
drivers/hwmon/pmbus/pmbus.h
··· 489 489 void pmbus_clear_faults(struct i2c_client *client); 490 490 bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); 491 491 bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); 492 - int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 493 - struct pmbus_driver_info *info); 492 + int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info); 494 493 int pmbus_do_remove(struct i2c_client *client); 495 494 const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client 496 495 *client);
+1 -2
drivers/hwmon/pmbus/pmbus_core.c
··· 2521 2521 } 2522 2522 #endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ 2523 2523 2524 - int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 2525 - struct pmbus_driver_info *info) 2524 + int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) 2526 2525 { 2527 2526 struct device *dev = &client->dev; 2528 2527 const struct pmbus_platform_data *pdata = dev_get_platdata(dev);
+3 -4
drivers/hwmon/pmbus/pxe1610.c
··· 78 78 .identify = pxe1610_identify, 79 79 }; 80 80 81 - static int pxe1610_probe(struct i2c_client *client, 82 - const struct i2c_device_id *id) 81 + static int pxe1610_probe(struct i2c_client *client) 83 82 { 84 83 struct pmbus_driver_info *info; 85 84 u8 buf[I2C_SMBUS_BLOCK_MAX]; ··· 114 115 if (!info) 115 116 return -ENOMEM; 116 117 117 - return pmbus_do_probe(client, id, info); 118 + return pmbus_do_probe(client, info); 118 119 } 119 120 120 121 static const struct i2c_device_id pxe1610_id[] = { ··· 130 131 .driver = { 131 132 .name = "pxe1610", 132 133 }, 133 - .probe = pxe1610_probe, 134 + .probe_new = pxe1610_probe, 134 135 .remove = pmbus_do_remove, 135 136 .id_table = pxe1610_id, 136 137 };
+3 -4
drivers/hwmon/pmbus/tps40422.c
··· 25 25 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 26 26 }; 27 27 28 - static int tps40422_probe(struct i2c_client *client, 29 - const struct i2c_device_id *id) 28 + static int tps40422_probe(struct i2c_client *client) 30 29 { 31 - return pmbus_do_probe(client, id, &tps40422_info); 30 + return pmbus_do_probe(client, &tps40422_info); 32 31 } 33 32 34 33 static const struct i2c_device_id tps40422_id[] = { ··· 42 43 .driver = { 43 44 .name = "tps40422", 44 45 }, 45 - .probe = tps40422_probe, 46 + .probe_new = tps40422_probe, 46 47 .remove = pmbus_do_remove, 47 48 .id_table = tps40422_id, 48 49 };
+6 -5
drivers/hwmon/pmbus/tps53679.c
··· 34 34 35 35 #define TPS53681_MFR_SPECIFIC_20 0xe4 /* Number of phases, per page */ 36 36 37 + static const struct i2c_device_id tps53679_id[]; 38 + 37 39 static int tps53679_identify_mode(struct i2c_client *client, 38 40 struct pmbus_driver_info *info) 39 41 { ··· 185 183 .pfunc[5] = PMBUS_HAVE_IOUT, 186 184 }; 187 185 188 - static int tps53679_probe(struct i2c_client *client, 189 - const struct i2c_device_id *id) 186 + static int tps53679_probe(struct i2c_client *client) 190 187 { 191 188 struct device *dev = &client->dev; 192 189 struct pmbus_driver_info *info; ··· 194 193 if (dev->of_node) 195 194 chip_id = (enum chips)of_device_get_match_data(dev); 196 195 else 197 - chip_id = id->driver_data; 196 + chip_id = i2c_match_id(tps53679_id, client)->driver_data; 198 197 199 198 info = devm_kmemdup(dev, &tps53679_info, sizeof(*info), GFP_KERNEL); 200 199 if (!info) ··· 221 220 return -ENODEV; 222 221 } 223 222 224 - return pmbus_do_probe(client, id, info); 223 + return pmbus_do_probe(client, info); 225 224 } 226 225 227 226 static const struct i2c_device_id tps53679_id[] = { ··· 250 249 .name = "tps53679", 251 250 .of_match_table = of_match_ptr(tps53679_of_match), 252 251 }, 253 - .probe = tps53679_probe, 252 + .probe_new = tps53679_probe, 254 253 .remove = pmbus_do_remove, 255 254 .id_table = tps53679_id, 256 255 };
+6 -7
drivers/hwmon/pmbus/ucd9000.c
··· 487 487 } 488 488 #endif /* CONFIG_DEBUG_FS */ 489 489 490 - static int ucd9000_probe(struct i2c_client *client, 491 - const struct i2c_device_id *id) 490 + static int ucd9000_probe(struct i2c_client *client) 492 491 { 493 492 u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; 494 493 struct ucd9000_data *data; ··· 522 523 if (client->dev.of_node) 523 524 chip = (enum chips)of_device_get_match_data(&client->dev); 524 525 else 525 - chip = id->driver_data; 526 + chip = mid->driver_data; 526 527 527 - if (chip != ucd9000 && chip != mid->driver_data) 528 + if (chip != ucd9000 && strcmp(client->name, mid->name) != 0) 528 529 dev_notice(&client->dev, 529 530 "Device mismatch: Configured %s, detected %s\n", 530 - id->name, mid->name); 531 + client->name, mid->name); 531 532 532 533 data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), 533 534 GFP_KERNEL); ··· 602 603 603 604 ucd9000_probe_gpio(client, mid, data); 604 605 605 - ret = pmbus_do_probe(client, mid, info); 606 + ret = pmbus_do_probe(client, info); 606 607 if (ret) 607 608 return ret; 608 609 ··· 620 621 .name = "ucd9000", 621 622 .of_match_table = of_match_ptr(ucd9000_of_match), 622 623 }, 623 - .probe = ucd9000_probe, 624 + .probe_new = ucd9000_probe, 624 625 .remove = pmbus_do_remove, 625 626 .id_table = ucd9000_id, 626 627 };
+6 -7
drivers/hwmon/pmbus/ucd9200.c
··· 71 71 }; 72 72 MODULE_DEVICE_TABLE(of, ucd9200_of_match); 73 73 74 - static int ucd9200_probe(struct i2c_client *client, 75 - const struct i2c_device_id *id) 74 + static int ucd9200_probe(struct i2c_client *client) 76 75 { 77 76 u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; 78 77 struct pmbus_driver_info *info; ··· 105 106 if (client->dev.of_node) 106 107 chip = (enum chips)of_device_get_match_data(&client->dev); 107 108 else 108 - chip = id->driver_data; 109 + chip = mid->driver_data; 109 110 110 - if (chip != ucd9200 && chip != mid->driver_data) 111 + if (chip != ucd9200 && strcmp(client->name, mid->name) != 0) 111 112 dev_notice(&client->dev, 112 113 "Device mismatch: Configured %s, detected %s\n", 113 - id->name, mid->name); 114 + client->name, mid->name); 114 115 115 116 info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), 116 117 GFP_KERNEL); ··· 191 192 if (mid->driver_data == ucd9240) 192 193 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12; 193 194 194 - return pmbus_do_probe(client, mid, info); 195 + return pmbus_do_probe(client, info); 195 196 } 196 197 197 198 /* This is the driver that will be inserted */ ··· 200 201 .name = "ucd9200", 201 202 .of_match_table = of_match_ptr(ucd9200_of_match), 202 203 }, 203 - .probe = ucd9200_probe, 204 + .probe_new = ucd9200_probe, 204 205 .remove = pmbus_do_remove, 205 206 .id_table = ucd9200_id, 206 207 };
+3 -4
drivers/hwmon/pmbus/xdpe12284.c
··· 127 127 .read_word_data = xdpe122_read_word_data, 128 128 }; 129 129 130 - static int xdpe122_probe(struct i2c_client *client, 131 - const struct i2c_device_id *id) 130 + static int xdpe122_probe(struct i2c_client *client) 132 131 { 133 132 struct pmbus_driver_info *info; 134 133 ··· 136 137 if (!info) 137 138 return -ENOMEM; 138 139 139 - return pmbus_do_probe(client, id, info); 140 + return pmbus_do_probe(client, info); 140 141 } 141 142 142 143 static const struct i2c_device_id xdpe122_id[] = { ··· 159 160 .name = "xdpe12284", 160 161 .of_match_table = of_match_ptr(xdpe122_of_match), 161 162 }, 162 - .probe = xdpe122_probe, 163 + .probe_new = xdpe122_probe, 163 164 .remove = pmbus_do_remove, 164 165 .id_table = xdpe122_id, 165 166 };
+5 -6
drivers/hwmon/pmbus/zl6100.c
··· 301 301 }; 302 302 MODULE_DEVICE_TABLE(i2c, zl6100_id); 303 303 304 - static int zl6100_probe(struct i2c_client *client, 305 - const struct i2c_device_id *id) 304 + static int zl6100_probe(struct i2c_client *client) 306 305 { 307 306 int ret; 308 307 struct zl6100_data *data; ··· 332 333 dev_err(&client->dev, "Unsupported device\n"); 333 334 return -ENODEV; 334 335 } 335 - if (id->driver_data != mid->driver_data) 336 + if (strcmp(client->name, mid->name) != 0) 336 337 dev_notice(&client->dev, 337 338 "Device mismatch: Configured %s, detected %s\n", 338 - id->name, mid->name); 339 + client->name, mid->name); 339 340 340 341 data = devm_kzalloc(&client->dev, sizeof(struct zl6100_data), 341 342 GFP_KERNEL); ··· 388 389 info->write_word_data = zl6100_write_word_data; 389 390 info->write_byte = zl6100_write_byte; 390 391 391 - return pmbus_do_probe(client, mid, info); 392 + return pmbus_do_probe(client, info); 392 393 } 393 394 394 395 static struct i2c_driver zl6100_driver = { 395 396 .driver = { 396 397 .name = "zl6100", 397 398 }, 398 - .probe = zl6100_probe, 399 + .probe_new = zl6100_probe, 399 400 .remove = pmbus_do_remove, 400 401 .id_table = zl6100_id, 401 402 };