Skip to content

Commit

Permalink
staging: nvec: move toggle global event reporting to its own function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marc Dietrich authored and Greg Kroah-Hartman committed Jan 30, 2013
1 parent 9915518 commit 518945f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
29 changes: 22 additions & 7 deletions drivers/staging/nvec/nvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -317,6 +319,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)
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/staging/nvec/nvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 518945f

Please sign in to comment.