[PATCH 1/4] drm/dsi: Make mipi_dsi_dcs_write() return ssize_t

Andrzej Hajda a.hajda at samsung.com
Wed Jul 23 01:18:21 PDT 2014


On 07/23/2014 09:27 AM, Thierry Reding wrote:
> On Tue, Jul 22, 2014 at 12:23:07PM +0200, Andrzej Hajda wrote:
>> Hi Thierry,
>>
>> YoungJun's comment refreshed my memory about mipi_dsi_dcs_write return
>> value. It should be rather int than ssize_t. Why?
>> .transfer() returns the number of read bytes or error, but in case
>> of dcs write no bytes are read, so it in fact returns error or 0.
>> This is why return value was implemented originally as int.
>> So I do not think this patch is necessary.
> I think it should return the number of bytes written or an error. That
> way we give callers the maximum amount of information. They may still
> choose to only handle < 0 for convenience, but at least the information
> will be there should it become required at some point.

AFAIK DSI write operation is atomic, ie either all requested bytes have
been sent
either there was an error and in such case we should assume no byte have
been sent.
Returning number of written bytes in this case is just returning length
of write buffer -
something caller already knows. Additionally it suggests that partial
write is possible
which is not true.
I know it is implemented such way in i2c (which is non atomic) but the
comment
in i2c_transfer shows its weakness [1].

[1]: http://lxr.free-electrons.com/source/drivers/i2c/i2c-core.c#L1782

Regards
Andrzej

>
> Thierry



More information about the dri-devel mailing list