Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d88cc367 authored by Sangjung Woo's avatar Sangjung Woo Committed by Chanwoo Choi
Browse files

extcon: arizona: Use devm_extcon_dev_register()



Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: default avatarSangjung Woo <sangjung.woo@samsung.com>
Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
parent b4dad55a
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -1105,15 +1105,14 @@ static int arizona_extcon_probe(struct platform_device *pdev)
	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
	if (!info) {
	if (!info) {
		dev_err(&pdev->dev, "Failed to allocate memory\n");
		dev_err(&pdev->dev, "Failed to allocate memory\n");
		ret = -ENOMEM;
		return -ENOMEM;
		goto err;
	}
	}


	info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
	info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
	if (IS_ERR(info->micvdd)) {
	if (IS_ERR(info->micvdd)) {
		ret = PTR_ERR(info->micvdd);
		ret = PTR_ERR(info->micvdd);
		dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
		dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
		goto err;
		return ret;
	}
	}


	mutex_init(&info->lock);
	mutex_init(&info->lock);
@@ -1155,11 +1154,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
	info->edev.dev.parent = arizona->dev;
	info->edev.dev.parent = arizona->dev;
	info->edev.supported_cable = arizona_cable;
	info->edev.supported_cable = arizona_cable;


	ret = extcon_dev_register(&info->edev);
	ret = devm_extcon_dev_register(&pdev->dev, &info->edev);
	if (ret < 0) {
	if (ret < 0) {
		dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
		dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
			ret);
			ret);
		goto err;
		return ret;
	}
	}


	info->input = devm_input_allocate_device(&pdev->dev);
	info->input = devm_input_allocate_device(&pdev->dev);
@@ -1410,8 +1409,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
err_input:
err_input:
err_register:
err_register:
	pm_runtime_disable(&pdev->dev);
	pm_runtime_disable(&pdev->dev);
	extcon_dev_unregister(&info->edev);
err:
	return ret;
	return ret;
}
}


@@ -1445,7 +1442,6 @@ static int arizona_extcon_remove(struct platform_device *pdev)
	regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
	regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
			   ARIZONA_JD1_ENA, 0);
			   ARIZONA_JD1_ENA, 0);
	arizona_clk32k_disable(arizona);
	arizona_clk32k_disable(arizona);
	extcon_dev_unregister(&info->edev);


	return 0;
	return 0;
}
}