mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Drake <michael.drake@codethink.co.uk>
To: Andrzej Hajda <a.hajda@samsung.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Michael Drake <michael.drake@codethink.co.uk>
Cc: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-kernel@lists.codethink.co.uk,
	Patrick Glaser <pglaser@tesla.com>, Nate Case <ncase@tesla.com>
Subject: [PATCH v1 07/11] ti948: Add sysfs node for alive attribute
Date: Tue, 11 Jun 2019 15:04:08 +0100	[thread overview]
Message-ID: <20190611140412.32151-8-michael.drake@codethink.co.uk> (raw)
In-Reply-To: <20190611140412.32151-1-michael.drake@codethink.co.uk>

This may be used by userspace to determine the state
of the device.

Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
Cc: Patrick Glaser <pglaser@tesla.com>
Cc: Nate Case <ncase@tesla.com>
---
 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);
 }
 
-- 
2.20.1


  parent reply	other threads:[~2019-06-11 14:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-11 14:04 [PATCH v1 00/11] Add ti948 and ti949 display bridge drivers Michael Drake
2019-06-11 14:04 ` [PATCH v1 01/11] dt-bindings: display/bridge: Add bindings for ti948 Michael Drake
2019-06-11 18:03   ` Laurent Pinchart
2019-07-12 12:42     ` Michael Drake
2019-06-11 14:04 ` [PATCH v1 02/11] ti948: i2c device driver for TI DS90UB948-Q1 Michael Drake
2019-06-11 14:04 ` [PATCH v1 03/11] dt-bindings: display/bridge: Add config property for ti948 Michael Drake
2019-06-11 18:07   ` Laurent Pinchart
2019-07-12 12:43     ` Michael Drake
2019-06-11 14:04 ` [PATCH v1 04/11] ti948: Add support for configuration via device properties Michael Drake
2019-06-11 14:04 ` [PATCH v1 05/11] ti948: Add alive check function using schedule_delayed_work() Michael Drake
2019-06-11 14:04 ` [PATCH v1 06/11] ti948: Reconfigure in the alive check when device returns Michael Drake
2019-06-11 18:10   ` Laurent Pinchart
2019-07-12 12:43     ` Michael Drake
2019-06-11 14:04 ` Michael Drake [this message]
2019-06-11 18:11   ` [PATCH v1 07/11] ti948: Add sysfs node for alive attribute Laurent Pinchart
2019-07-12 12:43     ` Michael Drake
2019-06-11 14:04 ` [PATCH v1 08/11] dt-bindings: display/bridge: Add bindings for ti949 Michael Drake
2019-06-11 18:13   ` Laurent Pinchart
2019-07-12 12:43     ` Michael Drake
2019-06-11 14:04 ` [PATCH v1 09/11] ti949: i2c device driver for TI DS90UB949-Q1 Michael Drake
2019-06-11 14:04 ` [PATCH v1 10/11] dt-bindings: display/bridge: Add config property for ti949 Michael Drake
2019-06-11 14:04 ` [PATCH v1 11/11] ti949: Add support for configuration via device properties Michael Drake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190611140412.32151-8-michael.drake@codethink.co.uk \
    --to=michael.drake@codethink.co.uk \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ncase@tesla.com \
    --cc=pglaser@tesla.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®