Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GTA02 bt - remember state of bluetooth in variable

Reading bt status before suspend for some reason does not work. It
always resumes with bluetooth turned off.

This patch remembers if bluetooth is switched on/off in variable
and after resume bluetooth ends up in the same state as was before
suspend.
  • Loading branch information...
commit 00875594c874c4ef32637e0bb08f040ea0b13408 1 parent b76e120
@radekp authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 arch/arm/mach-s3c2440/gta02-pm-bt.c
View
18 arch/arm/mach-s3c2440/gta02-pm-bt.c
@@ -56,7 +56,8 @@ static ssize_t bt_read(struct device *dev, struct device_attribute *attr,
}
}
-static void __gta02_pm_bt_toggle_radio(struct device *dev, unsigned int on)
+static void __gta02_pm_bt_toggle_radio(struct device *dev, unsigned int on,
+ bool remember_state)
{
struct gta02_pm_bt_data *bt_data = dev_get_drvdata(dev);
@@ -75,6 +76,9 @@ static void __gta02_pm_bt_toggle_radio(struct device *dev, unsigned int on)
}
s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, on);
+
+ if (remember_state)
+ bt_data->pre_resume_state = on;
}
@@ -82,7 +86,7 @@ static int bt_rfkill_set_block(void *data, bool blocked)
{
struct device *dev = data;
- __gta02_pm_bt_toggle_radio(dev, !blocked);
+ __gta02_pm_bt_toggle_radio(dev, !blocked, true);
return 0;
}
@@ -101,7 +105,7 @@ static ssize_t bt_write(struct device *dev, struct device_attribute *attr,
if (!strcmp(attr->attr.name, "power_on")) {
rfkill_set_sw_state(bt_data->rfkill, on ? 1 : 0);
- __gta02_pm_bt_toggle_radio(dev, on);
+ __gta02_pm_bt_toggle_radio(dev, on, true);
} else if (!strcmp(attr->attr.name, "reset")) {
/* reset is low-active, so we need to invert */
s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, on ? 0 : 1);
@@ -116,12 +120,12 @@ static DEVICE_ATTR(reset, 0644, bt_read, bt_write);
#ifdef CONFIG_PM
static int gta02_bt_suspend(struct platform_device *pdev, pm_message_t state)
{
- struct gta02_pm_bt_data *bt_data = dev_get_drvdata(&pdev->dev);
+/* struct gta02_pm_bt_data *bt_data = dev_get_drvdata(&pdev->dev); */
dev_dbg(&pdev->dev, DRVMSG ": suspending\n");
- bt_data->pre_resume_state = s3c2410_gpio_getpin(GTA02_GPIO_BT_EN);
- __gta02_pm_bt_toggle_radio(&pdev->dev, 0);
+ /* bt_data->pre_resume_state = s3c2410_gpio_getpin(GTA02_GPIO_BT_EN); */
+ __gta02_pm_bt_toggle_radio(&pdev->dev, 0, false);
return 0;
}
@@ -131,7 +135,7 @@ static int gta02_bt_resume(struct platform_device *pdev)
struct gta02_pm_bt_data *bt_data = dev_get_drvdata(&pdev->dev);
dev_dbg(&pdev->dev, DRVMSG ": resuming\n");
- __gta02_pm_bt_toggle_radio(&pdev->dev, bt_data->pre_resume_state);
+ __gta02_pm_bt_toggle_radio(&pdev->dev, bt_data->pre_resume_state, false);
return 0;
}
#else
Please sign in to comment.
Something went wrong with that request. Please try again.