Re: [PATCH v1 07/11] ti948: Add sysfs node for alive attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Laurent,

On 11/06/2019 19:11, Laurent Pinchart wrote:
> Hi Michael,
> 
> Thank you for the patch.

My pleasure, and thank you for the feedback!

> On Tue, Jun 11, 2019 at 03:04:08PM +0100, Michael Drake wrote:
>> This may be used by userspace to determine the state
>> of the device.
> 
> Why is this needed ? Userspace shouldn't even be aware that this device
> exists.

The display (containing the ti948) could be unplugged.  (See my
response to the feedback on the previous commit in the series.)

If you can suggest a better or more standard way of doing this
I would be very happy to learn of it.

>> Signed-off-by: Michael Drake <michael.drake@xxxxxxxxxxxxxxx>
>> Cc: Patrick Glaser <pglaser@xxxxxxxxx>
>> Cc: Nate Case <ncase@xxxxxxxxx>
>> ---
>>  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);
>>  }
>>  
> 

-- 
Michael Drake                 https://www.codethink.co.uk/
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux