hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/power/supply/generic-adc-battery.c
....@@ -138,6 +138,9 @@
138138 result);
139139 if (ret < 0)
140140 pr_err("read channel error\n");
141
+ else
142
+ *result *= 1000;
143
+
141144 return ret;
142145 }
143146
....@@ -241,6 +244,7 @@
241244 struct power_supply_desc *psy_desc;
242245 struct power_supply_config psy_cfg = {};
243246 struct gab_platform_data *pdata = pdev->dev.platform_data;
247
+ enum power_supply_property *properties;
244248 int ret = 0;
245249 int chan;
246250 int index = ARRAY_SIZE(gab_props);
....@@ -268,16 +272,16 @@
268272 * copying the static properties and allocating extra memory for holding
269273 * the extra configurable properties received from platform data.
270274 */
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) {
275
+ properties = kcalloc(ARRAY_SIZE(gab_props) +
276
+ ARRAY_SIZE(gab_chan_name),
277
+ sizeof(*properties),
278
+ GFP_KERNEL);
279
+ if (!properties) {
276280 ret = -ENOMEM;
277281 goto first_mem_fail;
278282 }
279283
280
- memcpy(psy_desc->properties, gab_props, sizeof(gab_props));
284
+ memcpy(properties, gab_props, sizeof(gab_props));
281285
282286 /*
283287 * getting channel from iio and copying the battery properties
....@@ -294,13 +298,11 @@
294298 int index2;
295299
296300 for (index2 = 0; index2 < index; index2++) {
297
- if (psy_desc->properties[index2] ==
298
- gab_dyn_props[chan])
301
+ if (properties[index2] == gab_dyn_props[chan])
299302 break; /* already known */
300303 }
301304 if (index2 == index) /* really new */
302
- psy_desc->properties[index++] =
303
- gab_dyn_props[chan];
305
+ properties[index++] = gab_dyn_props[chan];
304306 any = true;
305307 }
306308 }
....@@ -317,6 +319,7 @@
317319 * as come channels may be not be supported by the device.So
318320 * we need to take care of that.
319321 */
322
+ psy_desc->properties = properties;
320323 psy_desc->num_properties = index;
321324
322325 adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg);
....@@ -358,7 +361,7 @@
358361 iio_channel_release(adc_bat->channel[chan]);
359362 }
360363 second_mem_fail:
361
- kfree(psy_desc->properties);
364
+ kfree(properties);
362365 first_mem_fail:
363366 return ret;
364367 }