1 From 8af2552e862100e843b8d1f36543b718dde393ad Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 6 Jan 2020 18:47:53 +0100
4 Subject: [PATCH] drm/vc4: hdmi: Pass vc4_hdmi to CEC code
6 Our CEC code also retrieves the associated vc4_hdmi by setting the
7 vc4_dev pointer as its private data, and then dereferences its vc4_hdmi
10 In order to eventually get rid of that pointer, we can simply pass the
11 vc4_hdmi pointer directly.
13 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 drivers/gpu/drm/vc4/vc4_hdmi.c | 24 +++++++++---------------
16 1 file changed, 9 insertions(+), 15 deletions(-)
18 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
19 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
20 @@ -1043,8 +1043,7 @@ static int vc4_hdmi_audio_init(struct vc
21 #ifdef CONFIG_DRM_VC4_HDMI_CEC
22 static irqreturn_t vc4_cec_irq_handler_thread(int irq, void *priv)
24 - struct vc4_dev *vc4 = priv;
25 - struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
26 + struct vc4_hdmi *vc4_hdmi = priv;
28 if (vc4_hdmi->cec_irq_was_rx) {
29 if (vc4_hdmi->cec_rx_msg.len)
30 @@ -1064,9 +1063,8 @@ static irqreturn_t vc4_cec_irq_handler_t
34 -static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)
35 +static void vc4_cec_read_msg(struct vc4_hdmi *vc4_hdmi, u32 cntrl1)
37 - struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
38 struct cec_msg *msg = &vc4_hdmi->cec_rx_msg;
41 @@ -1084,8 +1082,7 @@ static void vc4_cec_read_msg(struct vc4_
43 static irqreturn_t vc4_cec_irq_handler(int irq, void *priv)
45 - struct vc4_dev *vc4 = priv;
46 - struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
47 + struct vc4_hdmi *vc4_hdmi = priv;
48 u32 stat = HDMI_READ(VC4_HDMI_CPU_STATUS);
51 @@ -1096,7 +1093,7 @@ static irqreturn_t vc4_cec_irq_handler(i
52 cntrl5 = HDMI_READ(VC4_HDMI_CEC_CNTRL_5);
53 vc4_hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT;
54 if (vc4_hdmi->cec_irq_was_rx) {
55 - vc4_cec_read_msg(vc4, cntrl1);
56 + vc4_cec_read_msg(vc4_hdmi, cntrl1);
57 cntrl1 |= VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
58 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, cntrl1);
59 cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
60 @@ -1112,8 +1109,7 @@ static irqreturn_t vc4_cec_irq_handler(i
62 static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
64 - struct vc4_dev *vc4 = cec_get_drvdata(adap);
65 - struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
66 + struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap);
67 /* clock period in microseconds */
68 const u32 usecs = 1000000 / CEC_CLOCK_FREQ;
69 u32 val = HDMI_READ(VC4_HDMI_CEC_CNTRL_5);
70 @@ -1156,8 +1152,7 @@ static int vc4_hdmi_cec_adap_enable(stru
72 static int vc4_hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
74 - struct vc4_dev *vc4 = cec_get_drvdata(adap);
75 - struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
76 + struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap);
78 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1,
79 (HDMI_READ(VC4_HDMI_CEC_CNTRL_1) & ~VC4_HDMI_CEC_ADDR_MASK) |
80 @@ -1168,8 +1163,7 @@ static int vc4_hdmi_cec_adap_log_addr(st
81 static int vc4_hdmi_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
82 u32 signal_free_time, struct cec_msg *msg)
84 - struct vc4_dev *vc4 = cec_get_drvdata(adap);
85 - struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
86 + struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap);
90 @@ -1315,7 +1309,7 @@ static int vc4_hdmi_bind(struct device *
92 #ifdef CONFIG_DRM_VC4_HDMI_CEC
93 vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
97 CEC_CAP_CONNECTOR_INFO, 1);
98 ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap);
99 @@ -1339,7 +1333,7 @@ static int vc4_hdmi_bind(struct device *
100 ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
102 vc4_cec_irq_handler_thread, 0,
103 - "vc4 hdmi cec", vc4);
104 + "vc4 hdmi cec", vc4_hdmi);
106 goto err_delete_cec_adap;
107 ret = cec_register_adapter(vc4_hdmi->cec_adap, dev);