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>
This commit is contained in:
Родитель
354cf00339
Коммит
00ccd263ee
|
@ -17,7 +17,6 @@ struct cec_gpio {
|
||||||
struct gpio_desc *cec_gpio;
|
struct gpio_desc *cec_gpio;
|
||||||
int cec_irq;
|
int cec_irq;
|
||||||
bool cec_is_low;
|
bool cec_is_low;
|
||||||
bool cec_have_irq;
|
|
||||||
|
|
||||||
struct gpio_desc *hpd_gpio;
|
struct gpio_desc *hpd_gpio;
|
||||||
int hpd_irq;
|
int hpd_irq;
|
||||||
|
@ -55,9 +54,6 @@ static void cec_gpio_low(struct cec_adapter *adap)
|
||||||
|
|
||||||
if (cec->cec_is_low)
|
if (cec->cec_is_low)
|
||||||
return;
|
return;
|
||||||
if (WARN_ON_ONCE(cec->cec_have_irq))
|
|
||||||
free_irq(cec->cec_irq, cec);
|
|
||||||
cec->cec_have_irq = false;
|
|
||||||
cec->cec_is_low = true;
|
cec->cec_is_low = true;
|
||||||
gpiod_set_value(cec->cec_gpio, 0);
|
gpiod_set_value(cec->cec_gpio, 0);
|
||||||
}
|
}
|
||||||
|
@ -114,14 +110,7 @@ static bool cec_gpio_enable_irq(struct cec_adapter *adap)
|
||||||
{
|
{
|
||||||
struct cec_gpio *cec = cec_get_drvdata(adap);
|
struct cec_gpio *cec = cec_get_drvdata(adap);
|
||||||
|
|
||||||
if (cec->cec_have_irq)
|
enable_irq(cec->cec_irq);
|
||||||
return true;
|
|
||||||
|
|
||||||
if (request_irq(cec->cec_irq, cec_gpio_irq_handler,
|
|
||||||
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
|
||||||
adap->name, cec))
|
|
||||||
return false;
|
|
||||||
cec->cec_have_irq = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,9 +118,7 @@ static void cec_gpio_disable_irq(struct cec_adapter *adap)
|
||||||
{
|
{
|
||||||
struct cec_gpio *cec = cec_get_drvdata(adap);
|
struct cec_gpio *cec = cec_get_drvdata(adap);
|
||||||
|
|
||||||
if (cec->cec_have_irq)
|
disable_irq(cec->cec_irq);
|
||||||
free_irq(cec->cec_irq, cec);
|
|
||||||
cec->cec_have_irq = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cec_gpio_status(struct cec_adapter *adap, struct seq_file *file)
|
static void cec_gpio_status(struct cec_adapter *adap, struct seq_file *file)
|
||||||
|
@ -139,8 +126,7 @@ static void cec_gpio_status(struct cec_adapter *adap, struct seq_file *file)
|
||||||
struct cec_gpio *cec = cec_get_drvdata(adap);
|
struct cec_gpio *cec = cec_get_drvdata(adap);
|
||||||
|
|
||||||
seq_printf(file, "mode: %s\n", cec->cec_is_low ? "low-drive" : "read");
|
seq_printf(file, "mode: %s\n", cec->cec_is_low ? "low-drive" : "read");
|
||||||
if (cec->cec_have_irq)
|
seq_printf(file, "using irq: %d\n", cec->cec_irq);
|
||||||
seq_printf(file, "using irq: %d\n", cec->cec_irq);
|
|
||||||
if (cec->hpd_gpio)
|
if (cec->hpd_gpio)
|
||||||
seq_printf(file, "hpd: %s\n",
|
seq_printf(file, "hpd: %s\n",
|
||||||
cec->hpd_is_high ? "high" : "low");
|
cec->hpd_is_high ? "high" : "low");
|
||||||
|
@ -215,6 +201,14 @@ static int cec_gpio_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(cec->adap))
|
if (IS_ERR(cec->adap))
|
||||||
return PTR_ERR(cec->adap);
|
return PTR_ERR(cec->adap);
|
||||||
|
|
||||||
|
ret = devm_request_irq(dev, cec->cec_irq, cec_gpio_irq_handler,
|
||||||
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
||||||
|
cec->adap->name, cec);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
cec_gpio_disable_irq(cec->adap);
|
||||||
|
|
||||||
if (cec->hpd_gpio) {
|
if (cec->hpd_gpio) {
|
||||||
cec->hpd_irq = gpiod_to_irq(cec->hpd_gpio);
|
cec->hpd_irq = gpiod_to_irq(cec->hpd_gpio);
|
||||||
ret = devm_request_threaded_irq(dev, cec->hpd_irq,
|
ret = devm_request_threaded_irq(dev, cec->hpd_irq,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче