.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Silicon Image SiI8620 HDMI/MHL bridge driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2015, Samsung Electronics Co., Ltd. |
---|
5 | 6 | * Andrzej Hajda <a.hajda@samsung.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #include <asm/unaligned.h> |
---|
13 | 10 | |
---|
14 | 11 | #include <drm/bridge/mhl.h> |
---|
| 12 | +#include <drm/drm_bridge.h> |
---|
15 | 13 | #include <drm/drm_crtc.h> |
---|
16 | 14 | #include <drm/drm_edid.h> |
---|
17 | 15 | #include <drm/drm_encoder.h> |
---|
.. | .. |
---|
607 | 605 | u8 *buf = &ctx->burst.tx_buf[ctx->burst.tx_count]; |
---|
608 | 606 | int size = len + 2; |
---|
609 | 607 | |
---|
610 | | - if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) { |
---|
| 608 | + if (ctx->burst.tx_count + size >= ARRAY_SIZE(ctx->burst.tx_buf)) { |
---|
611 | 609 | dev_err(ctx->dev, "TX-BLK buffer exhausted\n"); |
---|
612 | 610 | ctx->error = -EINVAL; |
---|
613 | 611 | return NULL; |
---|
.. | .. |
---|
624 | 622 | u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count]; |
---|
625 | 623 | int size = len + 1; |
---|
626 | 624 | |
---|
627 | | - if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) { |
---|
| 625 | + if (ctx->burst.rx_count + size >= ARRAY_SIZE(ctx->burst.rx_buf)) { |
---|
628 | 626 | dev_err(ctx->dev, "RX-BLK buffer exhausted\n"); |
---|
629 | 627 | ctx->error = -EINVAL; |
---|
630 | 628 | return NULL; |
---|
.. | .. |
---|
988 | 986 | |
---|
989 | 987 | static void sii8620_stop_video(struct sii8620 *ctx) |
---|
990 | 988 | { |
---|
991 | | - u8 uninitialized_var(val); |
---|
| 989 | + u8 val; |
---|
992 | 990 | |
---|
993 | 991 | sii8620_write_seq_static(ctx, |
---|
994 | 992 | REG_TPI_INTR_EN, 0, |
---|
.. | .. |
---|
1104 | 1102 | int ret; |
---|
1105 | 1103 | |
---|
1106 | 1104 | ret = drm_hdmi_avi_infoframe_from_display_mode(&frm.avi, |
---|
1107 | | - mode, |
---|
1108 | | - true); |
---|
| 1105 | + NULL, mode); |
---|
1109 | 1106 | if (ctx->use_packed_pixel) |
---|
1110 | 1107 | frm.avi.colorspace = HDMI_COLORSPACE_YUV422; |
---|
1111 | 1108 | |
---|
.. | .. |
---|
1763 | 1760 | |
---|
1764 | 1761 | scancode &= MHL_RCP_KEY_ID_MASK; |
---|
1765 | 1762 | |
---|
1766 | | - if (!ctx->rc_dev) { |
---|
1767 | | - dev_dbg(ctx->dev, "RCP input device not initialized\n"); |
---|
| 1763 | + if (!IS_ENABLED(CONFIG_RC_CORE) || !ctx->rc_dev) |
---|
1768 | 1764 | return false; |
---|
1769 | | - } |
---|
1770 | 1765 | |
---|
1771 | 1766 | if (pressed) |
---|
1772 | 1767 | rc_keydown(ctx->rc_dev, RC_PROTO_CEC, scancode, 0); |
---|
.. | .. |
---|
2103 | 2098 | struct rc_dev *rc_dev; |
---|
2104 | 2099 | int ret; |
---|
2105 | 2100 | |
---|
| 2101 | + if (!IS_ENABLED(CONFIG_RC_CORE)) |
---|
| 2102 | + return; |
---|
| 2103 | + |
---|
2106 | 2104 | rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE); |
---|
2107 | 2105 | if (!rc_dev) { |
---|
2108 | 2106 | dev_err(ctx->dev, "Failed to allocate RC device\n"); |
---|
.. | .. |
---|
2122 | 2120 | if (ret) { |
---|
2123 | 2121 | dev_err(ctx->dev, "Failed to register RC device\n"); |
---|
2124 | 2122 | ctx->error = ret; |
---|
2125 | | - rc_free_device(ctx->rc_dev); |
---|
| 2123 | + rc_free_device(rc_dev); |
---|
2126 | 2124 | return; |
---|
2127 | 2125 | } |
---|
2128 | 2126 | ctx->rc_dev = rc_dev; |
---|
.. | .. |
---|
2204 | 2202 | return container_of(bridge, struct sii8620, bridge); |
---|
2205 | 2203 | } |
---|
2206 | 2204 | |
---|
2207 | | -static int sii8620_attach(struct drm_bridge *bridge) |
---|
| 2205 | +static int sii8620_attach(struct drm_bridge *bridge, |
---|
| 2206 | + enum drm_bridge_attach_flags flags) |
---|
2208 | 2207 | { |
---|
2209 | 2208 | struct sii8620 *ctx = bridge_to_sii8620(bridge); |
---|
2210 | 2209 | |
---|
.. | .. |
---|
2216 | 2215 | static void sii8620_detach(struct drm_bridge *bridge) |
---|
2217 | 2216 | { |
---|
2218 | 2217 | struct sii8620 *ctx = bridge_to_sii8620(bridge); |
---|
| 2218 | + |
---|
| 2219 | + if (!IS_ENABLED(CONFIG_RC_CORE)) |
---|
| 2220 | + return; |
---|
2219 | 2221 | |
---|
2220 | 2222 | rc_unregister_device(ctx->rc_dev); |
---|
2221 | 2223 | } |
---|
.. | .. |
---|
2242 | 2244 | } |
---|
2243 | 2245 | |
---|
2244 | 2246 | static enum drm_mode_status sii8620_mode_valid(struct drm_bridge *bridge, |
---|
| 2247 | + const struct drm_display_info *info, |
---|
2245 | 2248 | const struct drm_display_mode *mode) |
---|
2246 | 2249 | { |
---|
2247 | 2250 | struct sii8620 *ctx = bridge_to_sii8620(bridge); |
---|
.. | .. |
---|
2297 | 2300 | INIT_LIST_HEAD(&ctx->mt_queue); |
---|
2298 | 2301 | |
---|
2299 | 2302 | ctx->clk_xtal = devm_clk_get(dev, "xtal"); |
---|
2300 | | - if (IS_ERR(ctx->clk_xtal)) { |
---|
2301 | | - dev_err(dev, "failed to get xtal clock from DT\n"); |
---|
2302 | | - return PTR_ERR(ctx->clk_xtal); |
---|
2303 | | - } |
---|
| 2303 | + if (IS_ERR(ctx->clk_xtal)) |
---|
| 2304 | + return dev_err_probe(dev, PTR_ERR(ctx->clk_xtal), |
---|
| 2305 | + "failed to get xtal clock from DT\n"); |
---|
2304 | 2306 | |
---|
2305 | 2307 | if (!client->irq) { |
---|
2306 | 2308 | dev_err(dev, "no irq provided\n"); |
---|
.. | .. |
---|
2311 | 2313 | sii8620_irq_thread, |
---|
2312 | 2314 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, |
---|
2313 | 2315 | "sii8620", ctx); |
---|
2314 | | - if (ret < 0) { |
---|
2315 | | - dev_err(dev, "failed to install IRQ handler\n"); |
---|
2316 | | - return ret; |
---|
2317 | | - } |
---|
| 2316 | + if (ret < 0) |
---|
| 2317 | + return dev_err_probe(dev, ret, |
---|
| 2318 | + "failed to install IRQ handler\n"); |
---|
2318 | 2319 | |
---|
2319 | 2320 | ctx->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); |
---|
2320 | | - if (IS_ERR(ctx->gpio_reset)) { |
---|
2321 | | - dev_err(dev, "failed to get reset gpio from DT\n"); |
---|
2322 | | - return PTR_ERR(ctx->gpio_reset); |
---|
2323 | | - } |
---|
| 2321 | + if (IS_ERR(ctx->gpio_reset)) |
---|
| 2322 | + return dev_err_probe(dev, PTR_ERR(ctx->gpio_reset), |
---|
| 2323 | + "failed to get reset gpio from DT\n"); |
---|
2324 | 2324 | |
---|
2325 | 2325 | ctx->supplies[0].supply = "cvcc10"; |
---|
2326 | 2326 | ctx->supplies[1].supply = "iovcc18"; |
---|