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

regulator: pfuze100-regulator: Remove global variable

We should better not use a global 'struct pfuze_regulator' variable,
as this could cause problems if multiple regulator chips are used.

Place it inside the private struct instead.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Fabio Estevam and committed by
Mark Brown
12425654 1a695a90

+6 -7
+6 -7
drivers/regulator/pfuze100-regulator.c
··· 70 70 struct device *dev; 71 71 struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; 72 72 struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR]; 73 + struct pfuze_regulator *pfuze_regulators; 73 74 }; 74 75 75 76 static const int pfuze100_swbst[] = { ··· 335 334 PFUZE100_VGEN_REG(PFUZE3000, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), 336 335 }; 337 336 338 - static struct pfuze_regulator *pfuze_regulators; 339 - 340 337 #ifdef CONFIG_OF 341 338 /* PFUZE100 */ 342 339 static struct of_regulator_match pfuze100_matches[] = { ··· 562 563 /* use the right regulators after identify the right device */ 563 564 switch (pfuze_chip->chip_id) { 564 565 case PFUZE3000: 565 - pfuze_regulators = pfuze3000_regulators; 566 + pfuze_chip->pfuze_regulators = pfuze3000_regulators; 566 567 regulator_num = ARRAY_SIZE(pfuze3000_regulators); 567 568 sw_check_start = PFUZE3000_SW2; 568 569 sw_check_end = PFUZE3000_SW2; 569 570 sw_hi = 1 << 3; 570 571 break; 571 572 case PFUZE200: 572 - pfuze_regulators = pfuze200_regulators; 573 + pfuze_chip->pfuze_regulators = pfuze200_regulators; 573 574 regulator_num = ARRAY_SIZE(pfuze200_regulators); 574 575 sw_check_start = PFUZE200_SW2; 575 576 sw_check_end = PFUZE200_SW3B; 576 577 break; 577 578 case PFUZE100: 578 579 default: 579 - pfuze_regulators = pfuze100_regulators; 580 + pfuze_chip->pfuze_regulators = pfuze100_regulators; 580 581 regulator_num = ARRAY_SIZE(pfuze100_regulators); 581 582 sw_check_start = PFUZE100_SW2; 582 583 sw_check_end = PFUZE100_SW4; ··· 586 587 (pfuze_chip->chip_id == PFUZE100) ? "100" : 587 588 ((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000")); 588 589 589 - memcpy(pfuze_chip->regulator_descs, pfuze_regulators, 590 + memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators, 590 591 sizeof(pfuze_chip->regulator_descs)); 591 592 592 593 ret = pfuze_parse_regulators_dt(pfuze_chip); ··· 630 631 devm_regulator_register(&client->dev, desc, &config); 631 632 if (IS_ERR(pfuze_chip->regulators[i])) { 632 633 dev_err(&client->dev, "register regulator%s failed\n", 633 - pfuze_regulators[i].desc.name); 634 + pfuze_chip->pfuze_regulators[i].desc.name); 634 635 return PTR_ERR(pfuze_chip->regulators[i]); 635 636 } 636 637 }