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>
This commit is contained in:
parent
9915518887
commit
518945fbfb
2 changed files with 25 additions and 8 deletions
|
@ -72,8 +72,10 @@ enum nvec_msg_category {
|
||||||
NVEC_MSG_TX,
|
NVEC_MSG_TX,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00";
|
enum nvec_sleep_subcmds {
|
||||||
static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01";
|
GLOBAL_EVENTS,
|
||||||
|
};
|
||||||
|
|
||||||
static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15";
|
static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15";
|
||||||
|
|
||||||
static struct nvec_chip *nvec_power_handle;
|
static struct nvec_chip *nvec_power_handle;
|
||||||
|
@ -317,6 +319,20 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(nvec_write_sync);
|
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
|
* nvec_request_master - Process outgoing messages
|
||||||
* @work: A &struct work_struct (the tx_worker member of &struct nvec_chip)
|
* @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)
|
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);
|
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 */
|
/* enable event reporting */
|
||||||
nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING,
|
nvec_toggle_global_events(nvec, true);
|
||||||
sizeof(EC_ENABLE_EVENT_REPORTING));
|
|
||||||
|
|
||||||
nvec->nvec_status_notifier.notifier_call = nvec_status_notifier;
|
nvec->nvec_status_notifier.notifier_call = nvec_status_notifier;
|
||||||
nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0);
|
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);
|
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);
|
mfd_remove_devices(nvec->dev);
|
||||||
cancel_work_sync(&nvec->rx_work);
|
cancel_work_sync(&nvec->rx_work);
|
||||||
cancel_work_sync(&nvec->tx_work);
|
cancel_work_sync(&nvec->tx_work);
|
||||||
|
@ -891,7 +906,7 @@ static int nvec_resume(struct device *dev)
|
||||||
|
|
||||||
dev_dbg(nvec->dev, "resuming\n");
|
dev_dbg(nvec->dev, "resuming\n");
|
||||||
tegra_init_i2c_slave(nvec);
|
tegra_init_i2c_slave(nvec);
|
||||||
nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 3);
|
nvec_toggle_global_events(nvec, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,9 @@ enum nvec_event_size {
|
||||||
enum nvec_msg_type {
|
enum nvec_msg_type {
|
||||||
NVEC_SYS = 1,
|
NVEC_SYS = 1,
|
||||||
NVEC_BAT,
|
NVEC_BAT,
|
||||||
NVEC_KBD = 5,
|
NVEC_GPIO,
|
||||||
|
NVEC_SLEEP,
|
||||||
|
NVEC_KBD,
|
||||||
NVEC_PS2,
|
NVEC_PS2,
|
||||||
NVEC_CNTL,
|
NVEC_CNTL,
|
||||||
NVEC_KB_EVT = 0x80,
|
NVEC_KB_EVT = 0x80,
|
||||||
|
|
Loading…
Add table
Reference in a new issue