Skip to content

Commit 518945f

Browse files
marvintwentyfourgregkh
authored andcommitted
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>
1 parent 9915518 commit 518945f

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

‎drivers/staging/nvec/nvec.c‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ enum nvec_msg_category {
7272
NVEC_MSG_TX,
7373
};
7474

75-
static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00";
76-
static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01";
75+
enum nvec_sleep_subcmds {
76+
GLOBAL_EVENTS,
77+
};
78+
7779
static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15";
7880

7981
static struct nvec_chip *nvec_power_handle;
@@ -317,6 +319,20 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
317319
}
318320
EXPORT_SYMBOL(nvec_write_sync);
319321

322+
/**
323+
* nvec_toggle_global_events - enables or disables global event reporting
324+
* @nvec: nvec handle
325+
* @state: true for enable, false for disable
326+
*
327+
* This switches on/off global event reports by the embedded controller.
328+
*/
329+
static void nvec_toggle_global_events(struct nvec_chip *nvec, bool state)
330+
{
331+
unsigned char global_events[] = { NVEC_SLEEP, GLOBAL_EVENTS, state };
332+
333+
nvec_write_async(nvec, global_events, 3);
334+
}
335+
320336
/**
321337
* nvec_request_master - Process outgoing messages
322338
* @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)
711727

712728
static void nvec_power_off(void)
713729
{
714-
nvec_write_async(nvec_power_handle, EC_DISABLE_EVENT_REPORTING, 3);
730+
nvec_toggle_global_events(nvec_power_handle, false);
715731
nvec_write_async(nvec_power_handle, "\x04\x01", 2);
716732
}
717733

@@ -815,8 +831,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
815831

816832

817833
/* enable event reporting */
818-
nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING,
819-
sizeof(EC_ENABLE_EVENT_REPORTING));
834+
nvec_toggle_global_events(nvec, true);
820835

821836
nvec->nvec_status_notifier.notifier_call = nvec_status_notifier;
822837
nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0);
@@ -856,7 +871,7 @@ static int tegra_nvec_remove(struct platform_device *pdev)
856871
{
857872
struct nvec_chip *nvec = platform_get_drvdata(pdev);
858873

859-
nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3);
874+
nvec_toggle_global_events(nvec, false);
860875
mfd_remove_devices(nvec->dev);
861876
cancel_work_sync(&nvec->rx_work);
862877
cancel_work_sync(&nvec->tx_work);
@@ -891,7 +906,7 @@ static int nvec_resume(struct device *dev)
891906

892907
dev_dbg(nvec->dev, "resuming\n");
893908
tegra_init_i2c_slave(nvec);
894-
nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 3);
909+
nvec_toggle_global_events(nvec, true);
895910

896911
return 0;
897912
}

‎drivers/staging/nvec/nvec.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ enum nvec_event_size {
7171
enum nvec_msg_type {
7272
NVEC_SYS = 1,
7373
NVEC_BAT,
74-
NVEC_KBD = 5,
74+
NVEC_GPIO,
75+
NVEC_SLEEP,
76+
NVEC_KBD,
7577
NVEC_PS2,
7678
NVEC_CNTL,
7779
NVEC_KB_EVT = 0x80,

0 commit comments

Comments
 (0)