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

power: supply: cpcap-battery: use device_get_match_data() to simplify code

In the function cpcap_battery_probe(), the driver only needs the
data object, so use device_get_match_data() instead, to make the
code cleaner.

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Tang Bin and committed by
Sebastian Reichel
0668281d d0c27c92

+4 -11
+4 -11
drivers/power/supply/cpcap-battery.c
··· 1026 1026 static int cpcap_battery_probe(struct platform_device *pdev) 1027 1027 { 1028 1028 struct cpcap_battery_ddata *ddata; 1029 - const struct of_device_id *match; 1030 1029 struct power_supply_config psy_cfg = {}; 1031 1030 int error; 1031 + const struct cpcap_battery_config *cfg; 1032 1032 1033 - match = of_match_device(of_match_ptr(cpcap_battery_id_table), 1034 - &pdev->dev); 1035 - if (!match) 1036 - return -EINVAL; 1037 - 1038 - if (!match->data) { 1039 - dev_err(&pdev->dev, "no configuration data found\n"); 1040 - 1033 + cfg = device_get_match_data(&pdev->dev); 1034 + if (!cfg) 1041 1035 return -ENODEV; 1042 - } 1043 1036 1044 1037 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); 1045 1038 if (!ddata) ··· 1040 1047 1041 1048 INIT_LIST_HEAD(&ddata->irq_list); 1042 1049 ddata->dev = &pdev->dev; 1043 - memcpy(&ddata->config, match->data, sizeof(ddata->config)); 1050 + memcpy(&ddata->config, cfg, sizeof(ddata->config)); 1044 1051 1045 1052 ddata->reg = dev_get_regmap(ddata->dev->parent, NULL); 1046 1053 if (!ddata->reg)