Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4469184ybi; Tue, 11 Jun 2019 07:10:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIEb3Q8MQzc02fy7rrD7qyRtTspWokrgsRmFvv+COBFxpcnyb0E9v7RnQERxpDT86h1yPL X-Received: by 2002:a17:902:5c2:: with SMTP id f60mr75877743plf.61.1560262256330; Tue, 11 Jun 2019 07:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560262256; cv=none; d=google.com; s=arc-20160816; b=BEiy0AClC8kW1iIxdDcHVDrqZJ0Y/1gsumaYFK8pVWQ3uVJmugLyPBYskrFDEHBTiD yru5QfrKbsKLO3SxbI1cBNM8uNMIwfdlsHtiTKmpZjWjEjFq5dIjbBbrN2ALP9NdKERZ J3RPwRvh563N2UKSqVmK6i68EN+pRHX6gwxCrYASfqsDCwXsPVSAKpraqWi95quxQ3aD GBhKpEB9njA2hWHpAcOgt1wnNpaNofoX7zb2mqZe7KkGC1YzFLp4jAt+S7BLG4OPlOta moVN30Hnfr3zKElasN1Knd+fH+luMFU6LPu+pWJ+U5k9FPINFLKwrMAgbVpmbh/o8wJn wX8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PTshNnhFhcbogTEyPiXAbFSteqbTTAaKY98KYVAsn0U=; b=nj4zuGl3Amx7tLeCcU6QuXsZcNWu1zWKRP0x6O/hAhLpSXbgkPh0VN5Obonnx5b9OL KtHd5/bjpAZVM460Hlf6us83GR0I39b42//ZJXlXnVeXYqLqT6UYMR3F+W8KvynWJbPU VAnv71/3mO8+noSMLuiO48Nns07L34BUhxq7HiV+1kbkLwM/iujS7LoOfu+q88K6StZY Dp5TUtvunCUf/Lb4ubuziC1RzimtvX1/gl4duLvHsw45KUIiauIOGGeQRzOBNBbshB7X XJDi90AO67UY8B/VCbpQVLPvYu2SM3wCI5e1yO3FRfeWR6Jq3e53T7j5B63cyfDx4E7y 9heQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si13414906pla.22.2019.06.11.07.10.41; Tue, 11 Jun 2019 07:10:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389960AbfFKOFA (ORCPT + 99 others); Tue, 11 Jun 2019 10:05:00 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:55679 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387704AbfFKOFA (ORCPT ); Tue, 11 Jun 2019 10:05:00 -0400 Received: from [167.98.27.226] (helo=happy.office.codethink.co.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1hahOT-0003vU-5W; Tue, 11 Jun 2019 15:04:57 +0100 From: Michael Drake To: Andrzej Hajda , Laurent Pinchart , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Drake Cc: David Airlie , Daniel Vetter , Rob Herring , Mark Rutland , linux-kernel@lists.codethink.co.uk, Patrick Glaser , Nate Case Subject: [PATCH v1 05/11] ti948: Add alive check function using schedule_delayed_work() Date: Tue, 11 Jun 2019 15:04:06 +0100 Message-Id: <20190611140412.32151-6-michael.drake@codethink.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611140412.32151-1-michael.drake@codethink.co.uk> References: <20190611140412.32151-1-michael.drake@codethink.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Patrick Glaser Cc: Nate Case --- 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 #include +#include #include #include #include @@ -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