LP8727 platform data is optional, so the driver should work even the platform data is NULL. To check the platform data, charging parameter data should be changed to the pointer type. Fix NULL point access problem when getting the battery properties. When the data is NULL, just return as invalid value.
Showing the changes to include/linux/platform_data (1 of 2 files). Show all
Unified · Split
| @@ -51,15 +51,16 @@ struct lp8727_chg_param { · 50 unmodified lines | |||
| 51 | * @get_batt_level : get battery voltage (mV) | 51 | * @get_batt_level : get battery voltage (mV) |
| 52 | * @get_batt_capacity : get battery capacity (%) | 52 | * @get_batt_capacity : get battery capacity (%) |
| 53 | * @get_batt_temp : get battery temperature | 53 | * @get_batt_temp : get battery temperature |
| 54 | * @ac, @usb : charging parameters each charger type | 54 | * @ac : charging parameters for AC type charger |
| 55 | * @usb : charging parameters for USB type charger | ||
| 55 | */ | 56 | */ |
| 56 | struct lp8727_platform_data { | 57 | struct lp8727_platform_data { |
| 57 | u8 (*get_batt_present)(void); | 58 | u8 (*get_batt_present)(void); |
| 58 | u16 (*get_batt_level)(void); | 59 | u16 (*get_batt_level)(void); |
| 59 | u8 (*get_batt_capacity)(void); | 60 | u8 (*get_batt_capacity)(void); |
| 60 | u8 (*get_batt_temp)(void); | 61 | u8 (*get_batt_temp)(void); |
| 61 | struct lp8727_chg_param ac; | 62 | struct lp8727_chg_param *ac; |
| 62 | struct lp8727_chg_param usb; | 63 | struct lp8727_chg_param *usb; |
| 63 | }; | 64 | }; |
| 64 | 65 | ||
| 65 | #endif | 66 | #endif |