| .. | .. |
|---|
| 241 | 241 | struct power_supply_desc *psy_desc; |
|---|
| 242 | 242 | struct power_supply_config psy_cfg = {}; |
|---|
| 243 | 243 | struct gab_platform_data *pdata = pdev->dev.platform_data; |
|---|
| 244 | + enum power_supply_property *properties; |
|---|
| 244 | 245 | int ret = 0; |
|---|
| 245 | 246 | int chan; |
|---|
| 246 | 247 | int index = ARRAY_SIZE(gab_props); |
|---|
| .. | .. |
|---|
| 268 | 269 | * copying the static properties and allocating extra memory for holding |
|---|
| 269 | 270 | * the extra configurable properties received from platform data. |
|---|
| 270 | 271 | */ |
|---|
| 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) { |
|---|
| 276 | 277 | ret = -ENOMEM; |
|---|
| 277 | 278 | goto first_mem_fail; |
|---|
| 278 | 279 | } |
|---|
| 279 | 280 | |
|---|
| 280 | | - memcpy(psy_desc->properties, gab_props, sizeof(gab_props)); |
|---|
| 281 | + memcpy(properties, gab_props, sizeof(gab_props)); |
|---|
| 281 | 282 | |
|---|
| 282 | 283 | /* |
|---|
| 283 | 284 | * getting channel from iio and copying the battery properties |
|---|
| .. | .. |
|---|
| 294 | 295 | int index2; |
|---|
| 295 | 296 | |
|---|
| 296 | 297 | 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]) |
|---|
| 299 | 299 | break; /* already known */ |
|---|
| 300 | 300 | } |
|---|
| 301 | 301 | if (index2 == index) /* really new */ |
|---|
| 302 | | - psy_desc->properties[index++] = |
|---|
| 303 | | - gab_dyn_props[chan]; |
|---|
| 302 | + properties[index++] = gab_dyn_props[chan]; |
|---|
| 304 | 303 | any = true; |
|---|
| 305 | 304 | } |
|---|
| 306 | 305 | } |
|---|
| .. | .. |
|---|
| 317 | 316 | * as come channels may be not be supported by the device.So |
|---|
| 318 | 317 | * we need to take care of that. |
|---|
| 319 | 318 | */ |
|---|
| 319 | + psy_desc->properties = properties; |
|---|
| 320 | 320 | psy_desc->num_properties = index; |
|---|
| 321 | 321 | |
|---|
| 322 | 322 | adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg); |
|---|
| .. | .. |
|---|
| 358 | 358 | iio_channel_release(adc_bat->channel[chan]); |
|---|
| 359 | 359 | } |
|---|
| 360 | 360 | second_mem_fail: |
|---|
| 361 | | - kfree(psy_desc->properties); |
|---|
| 361 | + kfree(properties); |
|---|
| 362 | 362 | first_mem_fail: |
|---|
| 363 | 363 | return ret; |
|---|
| 364 | 364 | } |
|---|