diff options
author | Thierry Reding <treding@nvidia.com> | 2014-10-14 05:12:32 -0400 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2014-11-13 07:55:34 -0500 |
commit | 9eb491f3eed26eb7edf4bf4b1a549895fb3301ea (patch) | |
tree | f714c8697fc5449179de232b994108c965af75e2 /drivers/gpu/drm/drm_mipi_dsi.c | |
parent | a52879e8d7cbeed69be5e54c69701e5edea8cc00 (diff) |
drm/dsi: Add DSI transfer helper
A common pattern is starting to emerge for higher level transfer
helpers. Create a new helper that encapsulates this pattern and avoids
code duplication.
Acked-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu/drm/drm_mipi_dsi.c')
-rw-r--r-- | drivers/gpu/drm/drm_mipi_dsi.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 44ff665f216f..0cc030a09c56 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c | |||
@@ -198,6 +198,20 @@ int mipi_dsi_detach(struct mipi_dsi_device *dsi) | |||
198 | } | 198 | } |
199 | EXPORT_SYMBOL(mipi_dsi_detach); | 199 | EXPORT_SYMBOL(mipi_dsi_detach); |
200 | 200 | ||
201 | static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi, | ||
202 | struct mipi_dsi_msg *msg) | ||
203 | { | ||
204 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; | ||
205 | |||
206 | if (!ops || !ops->transfer) | ||
207 | return -ENOSYS; | ||
208 | |||
209 | if (dsi->mode_flags & MIPI_DSI_MODE_LPM) | ||
210 | msg->flags |= MIPI_DSI_MSG_USE_LPM; | ||
211 | |||
212 | return ops->transfer(dsi->host, msg); | ||
213 | } | ||
214 | |||
201 | /** | 215 | /** |
202 | * mipi_dsi_packet_format_is_short - check if a packet is of the short format | 216 | * mipi_dsi_packet_format_is_short - check if a packet is of the short format |
203 | * @type: MIPI DSI data type of the packet | 217 | * @type: MIPI DSI data type of the packet |
@@ -327,16 +341,12 @@ EXPORT_SYMBOL(mipi_dsi_create_packet); | |||
327 | ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, const void *data, | 341 | ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, const void *data, |
328 | size_t len) | 342 | size_t len) |
329 | { | 343 | { |
330 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; | ||
331 | struct mipi_dsi_msg msg = { | 344 | struct mipi_dsi_msg msg = { |
332 | .channel = dsi->channel, | 345 | .channel = dsi->channel, |
333 | .tx_buf = data, | 346 | .tx_buf = data, |
334 | .tx_len = len | 347 | .tx_len = len |
335 | }; | 348 | }; |
336 | 349 | ||
337 | if (!ops || !ops->transfer) | ||
338 | return -ENOSYS; | ||
339 | |||
340 | switch (len) { | 350 | switch (len) { |
341 | case 0: | 351 | case 0: |
342 | return -EINVAL; | 352 | return -EINVAL; |
@@ -351,10 +361,7 @@ ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, const void *data, | |||
351 | break; | 361 | break; |
352 | } | 362 | } |
353 | 363 | ||
354 | if (dsi->mode_flags & MIPI_DSI_MODE_LPM) | 364 | return mipi_dsi_device_transfer(dsi, &msg); |
355 | msg.flags = MIPI_DSI_MSG_USE_LPM; | ||
356 | |||
357 | return ops->transfer(dsi->host, &msg); | ||
358 | } | 365 | } |
359 | EXPORT_SYMBOL(mipi_dsi_dcs_write); | 366 | EXPORT_SYMBOL(mipi_dsi_dcs_write); |
360 | 367 | ||
@@ -370,7 +377,6 @@ EXPORT_SYMBOL(mipi_dsi_dcs_write); | |||
370 | ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, | 377 | ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, |
371 | size_t len) | 378 | size_t len) |
372 | { | 379 | { |
373 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; | ||
374 | struct mipi_dsi_msg msg = { | 380 | struct mipi_dsi_msg msg = { |
375 | .channel = dsi->channel, | 381 | .channel = dsi->channel, |
376 | .type = MIPI_DSI_DCS_READ, | 382 | .type = MIPI_DSI_DCS_READ, |
@@ -380,13 +386,7 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, | |||
380 | .rx_len = len | 386 | .rx_len = len |
381 | }; | 387 | }; |
382 | 388 | ||
383 | if (!ops || !ops->transfer) | 389 | return mipi_dsi_device_transfer(dsi, &msg); |
384 | return -ENOSYS; | ||
385 | |||
386 | if (dsi->mode_flags & MIPI_DSI_MODE_LPM) | ||
387 | msg.flags = MIPI_DSI_MSG_USE_LPM; | ||
388 | |||
389 | return ops->transfer(dsi->host, &msg); | ||
390 | } | 390 | } |
391 | EXPORT_SYMBOL(mipi_dsi_dcs_read); | 391 | EXPORT_SYMBOL(mipi_dsi_dcs_read); |
392 | 392 | ||