lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190611140412.32151-6-michael.drake@codethink.co.uk>
Date:   Tue, 11 Jun 2019 15:04:06 +0100
From:   Michael Drake <michael.drake@...ethink.co.uk>
To:     Andrzej Hajda <a.hajda@...sung.com>,
        Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Michael Drake <michael.drake@...ethink.co.uk>
Cc:     David Airlie <airlied@...ux.ie>, Daniel Vetter <daniel@...ll.ch>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        linux-kernel@...ts.codethink.co.uk,
        Patrick Glaser <pglaser@...la.com>, Nate Case <ncase@...la.com>
Subject: [PATCH v1 05/11] ti948: Add alive check function using schedule_delayed_work()

This simply runs the function once every 5 seconds, while the
device is supposed to be active.  The alive check function is
currently simply a stub, that logs it has been called, and
re-inserts itself into the work queue.

Signed-off-by: Michael Drake <michael.drake@...ethink.co.uk>
Cc: Patrick Glaser <pglaser@...la.com>
Cc: Nate Case <ncase@...la.com>
---
 drivers/gpu/drm/bridge/ti948.c | 37 +++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/ti948.c b/drivers/gpu/drm/bridge/ti948.c
index 9cb37215f049..86daa3701b91 100644
--- a/drivers/gpu/drm/bridge/ti948.c
+++ b/drivers/gpu/drm/bridge/ti948.c
@@ -16,6 +16,7 @@
 
 #include <linux/regulator/consumer.h>
 #include <linux/of_device.h>
+#include <linux/workqueue.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/delay.h>
@@ -25,6 +26,9 @@
 /* Number of times to try checking for device on bringup. */
 #define TI948_DEVICE_ID_TRIES 10
 
+/* Alive check every 5 seconds. */
+#define TI948_ALIVE_CHECK_DELAY (5 * HZ)
+
 /**
  * enum ti948_reg - TI948 registers.
  *
@@ -374,9 +378,27 @@ static inline struct ti948_ctx *ti948_ctx_from_dev(struct device *dev)
 	return i2c_get_clientdata(client);
 }
 
+static inline struct ti948_ctx *delayed_work_to_ti948_ctx(
+		struct delayed_work *dwork)
+{
+	return container_of(dwork, struct ti948_ctx, alive_check);
+}
+
+static void ti948_alive_check(struct work_struct *work)
+{
+	struct delayed_work *dwork = to_delayed_work(work);
+	struct ti948_ctx *ti948 = delayed_work_to_ti948_ctx(dwork);
+
+	dev_info(&ti948->i2c->dev, "%s Alive check!\n", __func__);
+
+	/* Reschedule ourself for the next check. */
+	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
+}
+
 static int ti948_pm_resume(struct device *dev)
 {
 	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
+	bool scheduled;
 	int ret;
 
 	if (ti948 == NULL)
@@ -386,7 +408,18 @@ static int ti948_pm_resume(struct device *dev)
 	if (ret != 0)
 		return ret;
 
-	return ti948_write_config_seq(ti948);
+	ret = ti948_write_config_seq(ti948);
+	if (ret != 0)
+		return ret;
+
+	INIT_DELAYED_WORK(&ti948->alive_check, ti948_alive_check);
+
+	scheduled = schedule_delayed_work(
+			&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
+	if (!scheduled)
+		dev_warn(&ti948->i2c->dev, "Alive check already scheduled\n");
+
+	return 0;
 }
 
 static int ti948_pm_suspend(struct device *dev)
@@ -396,6 +429,8 @@ static int ti948_pm_suspend(struct device *dev)
 	if (ti948 == NULL)
 		return 0;
 
+	cancel_delayed_work_sync(&ti948->alive_check);
+
 	return ti948_power_off(ti948);
 }
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ