Skip to content

Commit 00ccd26

Browse files
Hans Verkuilmchehab
authored andcommitted
media: cec-gpio: use disable/enable_irq
Due to limitations in gpiolib it was impossible to disable the interrupt of an input gpio and then switch it to gpio output and drive it. The only way to achieve that was to free the interrupt first, then switch the direction. When going back to gpio input and using interrupts to read the gpio pin you had to request the irq again. This limitation was lifted in gpiolib in kernel 4.20, but the cec-gpio driver was still using the old workaround implementation. This patch updates the cec-gpio driver to just enable and disable the irq. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent 354cf00 commit 00ccd26

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

‎drivers/media/platform/cec-gpio/cec-gpio.c‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ struct cec_gpio {
1717
struct gpio_desc *cec_gpio;
1818
int cec_irq;
1919
bool cec_is_low;
20-
bool cec_have_irq;
2120

2221
struct gpio_desc *hpd_gpio;
2322
int hpd_irq;
@@ -55,9 +54,6 @@ static void cec_gpio_low(struct cec_adapter *adap)
5554

5655
if (cec->cec_is_low)
5756
return;
58-
if (WARN_ON_ONCE(cec->cec_have_irq))
59-
free_irq(cec->cec_irq, cec);
60-
cec->cec_have_irq = false;
6157
cec->cec_is_low = true;
6258
gpiod_set_value(cec->cec_gpio, 0);
6359
}
@@ -114,33 +110,23 @@ static bool cec_gpio_enable_irq(struct cec_adapter *adap)
114110
{
115111
struct cec_gpio *cec = cec_get_drvdata(adap);
116112

117-
if (cec->cec_have_irq)
118-
return true;
119-
120-
if (request_irq(cec->cec_irq, cec_gpio_irq_handler,
121-
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
122-
adap->name, cec))
123-
return false;
124-
cec->cec_have_irq = true;
113+
enable_irq(cec->cec_irq);
125114
return true;
126115
}
127116

128117
static void cec_gpio_disable_irq(struct cec_adapter *adap)
129118
{
130119
struct cec_gpio *cec = cec_get_drvdata(adap);
131120

132-
if (cec->cec_have_irq)
133-
free_irq(cec->cec_irq, cec);
134-
cec->cec_have_irq = false;
121+
disable_irq(cec->cec_irq);
135122
}
136123

137124
static void cec_gpio_status(struct cec_adapter *adap, struct seq_file *file)
138125
{
139126
struct cec_gpio *cec = cec_get_drvdata(adap);
140127

141128
seq_printf(file, "mode: %s\n", cec->cec_is_low ? "low-drive" : "read");
142-
if (cec->cec_have_irq)
143-
seq_printf(file, "using irq: %d\n", cec->cec_irq);
129+
seq_printf(file, "using irq: %d\n", cec->cec_irq);
144130
if (cec->hpd_gpio)
145131
seq_printf(file, "hpd: %s\n",
146132
cec->hpd_is_high ? "high" : "low");
@@ -215,6 +201,14 @@ static int cec_gpio_probe(struct platform_device *pdev)
215201
if (IS_ERR(cec->adap))
216202
return PTR_ERR(cec->adap);
217203

204+
ret = devm_request_irq(dev, cec->cec_irq, cec_gpio_irq_handler,
205+
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
206+
cec->adap->name, cec);
207+
if (ret)
208+
return ret;
209+
210+
cec_gpio_disable_irq(cec->adap);
211+
218212
if (cec->hpd_gpio) {
219213
cec->hpd_irq = gpiod_to_irq(cec->hpd_gpio);
220214
ret = devm_request_threaded_irq(dev, cec->hpd_irq,

0 commit comments

Comments
 (0)