Commit 0be81727 authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Johannes Berg

net: rfkill: gpio: spinlock-safe GPIO access

This sets the direction of the gpio once when it's requested,
and uses the spinlock-safe gpio_set_state() to change the
state.
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: default avatarRhyland Klein <rklein@nvidia.com>
Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent f02ae59b
...@@ -42,18 +42,18 @@ static int rfkill_gpio_set_power(void *data, bool blocked) ...@@ -42,18 +42,18 @@ static int rfkill_gpio_set_power(void *data, bool blocked)
if (blocked) { if (blocked) {
if (gpio_is_valid(rfkill->pdata->shutdown_gpio)) if (gpio_is_valid(rfkill->pdata->shutdown_gpio))
gpio_direction_output(rfkill->pdata->shutdown_gpio, 0); gpio_set_value(rfkill->pdata->shutdown_gpio, 0);
if (gpio_is_valid(rfkill->pdata->reset_gpio)) if (gpio_is_valid(rfkill->pdata->reset_gpio))
gpio_direction_output(rfkill->pdata->reset_gpio, 0); gpio_set_value(rfkill->pdata->reset_gpio, 0);
if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled) if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled)
clk_disable(rfkill->clk); clk_disable(rfkill->clk);
} else { } else {
if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled) if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
clk_enable(rfkill->clk); clk_enable(rfkill->clk);
if (gpio_is_valid(rfkill->pdata->reset_gpio)) if (gpio_is_valid(rfkill->pdata->reset_gpio))
gpio_direction_output(rfkill->pdata->reset_gpio, 1); gpio_set_value(rfkill->pdata->reset_gpio, 1);
if (gpio_is_valid(rfkill->pdata->shutdown_gpio)) if (gpio_is_valid(rfkill->pdata->shutdown_gpio))
gpio_direction_output(rfkill->pdata->shutdown_gpio, 1); gpio_set_value(rfkill->pdata->shutdown_gpio, 1);
} }
rfkill->clk_enabled = blocked; rfkill->clk_enabled = blocked;
...@@ -114,8 +114,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev) ...@@ -114,8 +114,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
rfkill->clk = devm_clk_get(&pdev->dev, pdata->power_clk_name); rfkill->clk = devm_clk_get(&pdev->dev, pdata->power_clk_name);
if (gpio_is_valid(pdata->reset_gpio)) { if (gpio_is_valid(pdata->reset_gpio)) {
ret = devm_gpio_request(&pdev->dev, pdata->reset_gpio, ret = devm_gpio_request_one(&pdev->dev, pdata->reset_gpio,
rfkill->reset_name); 0, rfkill->reset_name);
if (ret) { if (ret) {
pr_warn("%s: failed to get reset gpio.\n", __func__); pr_warn("%s: failed to get reset gpio.\n", __func__);
return ret; return ret;
...@@ -123,8 +123,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev) ...@@ -123,8 +123,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
} }
if (gpio_is_valid(pdata->shutdown_gpio)) { if (gpio_is_valid(pdata->shutdown_gpio)) {
ret = devm_gpio_request(&pdev->dev, pdata->shutdown_gpio, ret = devm_gpio_request_one(&pdev->dev, pdata->shutdown_gpio,
rfkill->shutdown_name); 0, rfkill->shutdown_name);
if (ret) { if (ret) {
pr_warn("%s: failed to get shutdown gpio.\n", __func__); pr_warn("%s: failed to get shutdown gpio.\n", __func__);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment