hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/power/supply/generic-adc-battery.c
....@@ -241,6 +241,7 @@
241241 struct power_supply_desc *psy_desc;
242242 struct power_supply_config psy_cfg = {};
243243 struct gab_platform_data *pdata = pdev->dev.platform_data;
244
+ enum power_supply_property *properties;
244245 int ret = 0;
245246 int chan;
246247 int index = ARRAY_SIZE(gab_props);
....@@ -268,16 +269,16 @@
268269 * copying the static properties and allocating extra memory for holding
269270 * the extra configurable properties received from platform data.
270271 */
271
- psy_desc->properties = kcalloc(ARRAY_SIZE(gab_props) +
272
- ARRAY_SIZE(gab_chan_name),
273
- sizeof(*psy_desc->properties),
274
- GFP_KERNEL);
275
- if (!psy_desc->properties) {
272
+ properties = kcalloc(ARRAY_SIZE(gab_props) +
273
+ ARRAY_SIZE(gab_chan_name),
274
+ sizeof(*properties),
275
+ GFP_KERNEL);
276
+ if (!properties) {
276277 ret = -ENOMEM;
277278 goto first_mem_fail;
278279 }
279280
280
- memcpy(psy_desc->properties, gab_props, sizeof(gab_props));
281
+ memcpy(properties, gab_props, sizeof(gab_props));
281282
282283 /*
283284 * getting channel from iio and copying the battery properties
....@@ -294,13 +295,11 @@
294295 int index2;
295296
296297 for (index2 = 0; index2 < index; index2++) {
297
- if (psy_desc->properties[index2] ==
298
- gab_dyn_props[chan])
298
+ if (properties[index2] == gab_dyn_props[chan])
299299 break; /* already known */
300300 }
301301 if (index2 == index) /* really new */
302
- psy_desc->properties[index++] =
303
- gab_dyn_props[chan];
302
+ properties[index++] = gab_dyn_props[chan];
304303 any = true;
305304 }
306305 }
....@@ -317,6 +316,7 @@
317316 * as come channels may be not be supported by the device.So
318317 * we need to take care of that.
319318 */
319
+ psy_desc->properties = properties;
320320 psy_desc->num_properties = index;
321321
322322 adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg);
....@@ -358,7 +358,7 @@
358358 iio_channel_release(adc_bat->channel[chan]);
359359 }
360360 second_mem_fail:
361
- kfree(psy_desc->properties);
361
+ kfree(properties);
362362 first_mem_fail:
363363 return ret;
364364 }