summaryrefslogtreecommitdiffstats
path: root/drivers/power/supply/cpcap-battery.c
diff options
context:
space:
mode:
authorTang Bin <tangbin@cmss.chinamobile.com>2021-09-28 10:06:23 +0800
committerSebastian Reichel <sebastian.reichel@collabora.com>2021-10-02 17:58:38 +0200
commit0668281d329db2c21ba6494a7bfcb8331dd0f5fa (patch)
treeb356704733bcafce3c86bbcd2d41d057391386bc /drivers/power/supply/cpcap-battery.c
parentd0c27c9211fef3ce8083cc3ad2ca3067d211edc9 (diff)
downloadlinux-0668281d329db2c21ba6494a7bfcb8331dd0f5fa.tar.bz2
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>
Diffstat (limited to 'drivers/power/supply/cpcap-battery.c')
-rw-r--r--drivers/power/supply/cpcap-battery.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index 8d62d4241da3..18e3ff0e15d5 100644
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -1026,20 +1026,13 @@ static const struct power_supply_desc cpcap_charger_battery_desc = {
static int cpcap_battery_probe(struct platform_device *pdev)
{
struct cpcap_battery_ddata *ddata;
- const struct of_device_id *match;
struct power_supply_config psy_cfg = {};
int error;
+ const struct cpcap_battery_config *cfg;
- match = of_match_device(of_match_ptr(cpcap_battery_id_table),
- &pdev->dev);
- if (!match)
- return -EINVAL;
-
- if (!match->data) {
- dev_err(&pdev->dev, "no configuration data found\n");
-
+ cfg = device_get_match_data(&pdev->dev);
+ if (!cfg)
return -ENODEV;
- }
ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
@@ -1047,7 +1040,7 @@ static int cpcap_battery_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&ddata->irq_list);
ddata->dev = &pdev->dev;
- memcpy(&ddata->config, match->data, sizeof(ddata->config));
+ memcpy(&ddata->config, cfg, sizeof(ddata->config));
ddata->reg = dev_get_regmap(ddata->dev->parent, NULL);
if (!ddata->reg)