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

regulator: sy8106a: Get rid of struct sy8106a

All the fields in struct sy8106a are only used in sy8106a_i2c_probe(), so
use local variables instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Axel Lin and committed by
Mark Brown
5d7ebba3 b9816363

+13 -27
+13 -27
drivers/regulator/sy8106a-regulator.c
··· 22 22 */ 23 23 #define SY8106A_GO_BIT BIT(7) 24 24 25 - struct sy8106a { 26 - struct regulator_dev *rdev; 27 - struct regmap *regmap; 28 - u32 fixed_voltage; 29 - }; 30 - 31 25 static const struct regmap_config sy8106a_regmap_config = { 32 26 .reg_bits = 8, 33 27 .val_bits = 8, ··· 64 70 static int sy8106a_i2c_probe(struct i2c_client *i2c, 65 71 const struct i2c_device_id *id) 66 72 { 67 - struct sy8106a *chip; 68 73 struct device *dev = &i2c->dev; 69 - struct regulator_dev *rdev = NULL; 74 + struct regulator_dev *rdev; 70 75 struct regulator_config config = { }; 76 + struct regmap *regmap; 71 77 unsigned int reg, vsel; 78 + u32 fixed_voltage; 72 79 int error; 73 80 74 - chip = devm_kzalloc(&i2c->dev, sizeof(struct sy8106a), GFP_KERNEL); 75 - if (!chip) 76 - return -ENOMEM; 77 - 78 81 error = of_property_read_u32(dev->of_node, "silergy,fixed-microvolt", 79 - &chip->fixed_voltage); 82 + &fixed_voltage); 80 83 if (error) 81 84 return error; 82 85 83 - if (chip->fixed_voltage < SY8106A_MIN_MV * 1000 || 84 - chip->fixed_voltage > SY8106A_MAX_MV * 1000) 86 + if (fixed_voltage < SY8106A_MIN_MV * 1000 || 87 + fixed_voltage > SY8106A_MAX_MV * 1000) 85 88 return -EINVAL; 86 89 87 - chip->regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config); 88 - if (IS_ERR(chip->regmap)) { 89 - error = PTR_ERR(chip->regmap); 90 + regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config); 91 + if (IS_ERR(regmap)) { 92 + error = PTR_ERR(regmap); 90 93 dev_err(dev, "Failed to allocate register map: %d\n", error); 91 94 return error; 92 95 } 93 96 94 97 config.dev = &i2c->dev; 95 - config.regmap = chip->regmap; 96 - config.driver_data = chip; 98 + config.regmap = regmap; 97 99 98 100 config.of_node = dev->of_node; 99 101 config.init_data = of_get_regulator_init_data(dev, dev->of_node, ··· 99 109 return -ENOMEM; 100 110 101 111 /* Ensure GO_BIT is enabled when probing */ 102 - error = regmap_read(chip->regmap, SY8106A_REG_VOUT1_SEL, &reg); 112 + error = regmap_read(regmap, SY8106A_REG_VOUT1_SEL, &reg); 103 113 if (error) 104 114 return error; 105 115 106 116 if (!(reg & SY8106A_GO_BIT)) { 107 - vsel = (chip->fixed_voltage / 1000 - SY8106A_MIN_MV) / 117 + vsel = (fixed_voltage / 1000 - SY8106A_MIN_MV) / 108 118 SY8106A_STEP_MV; 109 119 110 - error = regmap_write(chip->regmap, SY8106A_REG_VOUT1_SEL, 120 + error = regmap_write(regmap, SY8106A_REG_VOUT1_SEL, 111 121 vsel | SY8106A_GO_BIT); 112 122 if (error) 113 123 return error; ··· 120 130 dev_err(&i2c->dev, "Failed to register SY8106A regulator: %d\n", error); 121 131 return error; 122 132 } 123 - 124 - chip->rdev = rdev; 125 - 126 - i2c_set_clientdata(i2c, chip); 127 133 128 134 return 0; 129 135 }