From patchwork Tue Jun 11 14:04:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Drake X-Patchwork-Id: 10988735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDD7214BB for ; Wed, 12 Jun 2019 06:55:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB7DE28619 for ; Wed, 12 Jun 2019 06:55:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFB892863E; Wed, 12 Jun 2019 06:55:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72C1C28650 for ; Wed, 12 Jun 2019 06:55:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 393D3892D6; Wed, 12 Jun 2019 06:54:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from imap1.codethink.co.uk (imap1.codethink.co.uk [176.9.8.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB8AB890DB for ; Tue, 11 Jun 2019 14:24:06 +0000 (UTC) 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 1hahOU-0003vU-5F; Tue, 11 Jun 2019 15:04:58 +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 Subject: [PATCH v1 07/11] ti948: Add sysfs node for alive attribute Date: Tue, 11 Jun 2019 15:04:08 +0100 Message-Id: <20190611140412.32151-8-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 X-Mailman-Approved-At: Wed, 12 Jun 2019 06:53:41 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-kernel@lists.codethink.co.uk, David Airlie , Nate Case , Rob Herring , Patrick Glaser Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This may be used by userspace to determine the state of the device. Signed-off-by: Michael Drake Cc: Patrick Glaser Cc: Nate Case --- drivers/gpu/drm/bridge/ti948.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti948.c b/drivers/gpu/drm/bridge/ti948.c index b5c766711c4b..b624eaeabb43 100644 --- a/drivers/gpu/drm/bridge/ti948.c +++ b/drivers/gpu/drm/bridge/ti948.c @@ -412,6 +412,16 @@ static void ti948_alive_check(struct work_struct *work) schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY); } +static ssize_t alive_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev); + + return scnprintf(buf, PAGE_SIZE, "%u\n", (unsigned int)ti948->alive); +} + +static DEVICE_ATTR_RO(alive); + static int ti948_pm_resume(struct device *dev) { struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev); @@ -614,17 +624,31 @@ static int ti948_probe(struct i2c_client *client, i2c_set_clientdata(client, ti948); + ret = device_create_file(&client->dev, &dev_attr_alive); + if (ret) { + dev_err(&client->dev, "Could not create alive attr\n"); + return ret; + } + ret = ti948_pm_resume(&client->dev); - if (ret != 0) - return -EPROBE_DEFER; + if (ret != 0) { + ret = -EPROBE_DEFER; + goto error; + } dev_info(&ti948->i2c->dev, "End probe (addr: %x)\n", ti948->i2c->addr); return 0; + +error: + device_remove_file(&client->dev, &dev_attr_alive); + return ret; } static int ti948_remove(struct i2c_client *client) { + device_remove_file(&client->dev, &dev_attr_alive); + return ti948_pm_suspend(&client->dev); }