summaryrefslogtreecommitdiff
path: root/drivers/staging/nvec
diff options
context:
space:
mode:
authorMarc Dietrich <marvin24@gmx.de>2013-01-27 17:43:41 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-29 23:25:09 -0500
commit518945fbfbe9e2bc39057115aa23e25b084a03e0 (patch)
tree544bbf437336a7bd5a489b6299f6de658a57a46d /drivers/staging/nvec
parent9915518887e83764269d5b617d01782893877ed3 (diff)
staging: nvec: move toggle global event reporting to its own function
Cleanup toggle of global event reporting by moving it to its own function. This simplifies the following cleanup. Signed-off-by: Marc Dietrich <marvin24@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/nvec')
-rw-r--r--drivers/staging/nvec/nvec.c29
-rw-r--r--drivers/staging/nvec/nvec.h4
2 files changed, 25 insertions, 8 deletions
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 2830946860d1..6fab02faa4a8 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -72,8 +72,10 @@ enum nvec_msg_category {
NVEC_MSG_TX,
};
-static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00";
-static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01";
+enum nvec_sleep_subcmds {
+ GLOBAL_EVENTS,
+};
+
static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15";
static struct nvec_chip *nvec_power_handle;
@@ -318,6 +320,20 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
EXPORT_SYMBOL(nvec_write_sync);
/**
+ * nvec_toggle_global_events - enables or disables global event reporting
+ * @nvec: nvec handle
+ * @state: true for enable, false for disable
+ *
+ * This switches on/off global event reports by the embedded controller.
+ */
+static void nvec_toggle_global_events(struct nvec_chip *nvec, bool state)
+{
+ unsigned char global_events[] = { NVEC_SLEEP, GLOBAL_EVENTS, state };
+
+ nvec_write_async(nvec, global_events, 3);
+}
+
+/**
* nvec_request_master - Process outgoing messages
* @work: A &struct work_struct (the tx_worker member of &struct nvec_chip)
*
@@ -711,7 +727,7 @@ static void nvec_disable_i2c_slave(struct nvec_chip *nvec)
static void nvec_power_off(void)
{
- nvec_write_async(nvec_power_handle, EC_DISABLE_EVENT_REPORTING, 3);
+ nvec_toggle_global_events(nvec_power_handle, false);
nvec_write_async(nvec_power_handle, "\x04\x01", 2);
}
@@ -815,8 +831,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
/* enable event reporting */
- nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING,
- sizeof(EC_ENABLE_EVENT_REPORTING));
+ nvec_toggle_global_events(nvec, true);
nvec->nvec_status_notifier.notifier_call = nvec_status_notifier;
nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0);
@@ -856,7 +871,7 @@ static int tegra_nvec_remove(struct platform_device *pdev)
{
struct nvec_chip *nvec = platform_get_drvdata(pdev);
- nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3);
+ nvec_toggle_global_events(nvec, false);
mfd_remove_devices(nvec->dev);
cancel_work_sync(&nvec->rx_work);
cancel_work_sync(&nvec->tx_work);
@@ -891,7 +906,7 @@ static int nvec_resume(struct device *dev)
dev_dbg(nvec->dev, "resuming\n");
tegra_init_i2c_slave(nvec);
- nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 3);
+ nvec_toggle_global_events(nvec, true);
return 0;
}
diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h
index ba6ed8f4e8a3..bfcd9a9b36e1 100644
--- a/drivers/staging/nvec/nvec.h
+++ b/drivers/staging/nvec/nvec.h
@@ -71,7 +71,9 @@ enum nvec_event_size {
enum nvec_msg_type {
NVEC_SYS = 1,
NVEC_BAT,
- NVEC_KBD = 5,
+ NVEC_GPIO,
+ NVEC_SLEEP,
+ NVEC_KBD,
NVEC_PS2,
NVEC_CNTL,
NVEC_KB_EVT = 0x80,