Commit 276c821f authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: seco-cec: use cec_notifier_cec_adap_(un)register

Use cec_notifier_cec_adap_(un)register instead of
cec_notifier_get_conn, cec_notifier_put and cec_register_cec_notifier.

Also enable the CEC_CAP_CONNECTOR_INFO capability.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Ettore Chimenti <ek5.chimenti@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent e6777689
...@@ -507,10 +507,10 @@ static irqreturn_t secocec_irq_handler(int irq, void *priv) ...@@ -507,10 +507,10 @@ static irqreturn_t secocec_irq_handler(int irq, void *priv)
} }
struct cec_dmi_match { struct cec_dmi_match {
char *sys_vendor; const char *sys_vendor;
char *product_name; const char *product_name;
char *devname; const char *devname;
char *conn; const char *conn;
}; };
static const struct cec_dmi_match secocec_dmi_match_table[] = { static const struct cec_dmi_match secocec_dmi_match_table[] = {
...@@ -518,7 +518,8 @@ static const struct cec_dmi_match secocec_dmi_match_table[] = { ...@@ -518,7 +518,8 @@ static const struct cec_dmi_match secocec_dmi_match_table[] = {
{ "SECO", "UDOO x86", "0000:00:02.0", "Port B" }, { "SECO", "UDOO x86", "0000:00:02.0", "Port B" },
}; };
static int secocec_cec_get_notifier(struct cec_notifier **notify) static struct device *secocec_cec_find_hdmi_dev(struct device *dev,
const char **conn)
{ {
int i; int i;
...@@ -533,16 +534,15 @@ static int secocec_cec_get_notifier(struct cec_notifier **notify) ...@@ -533,16 +534,15 @@ static int secocec_cec_get_notifier(struct cec_notifier **notify)
d = bus_find_device_by_name(&pci_bus_type, NULL, d = bus_find_device_by_name(&pci_bus_type, NULL,
m->devname); m->devname);
if (!d) if (!d)
return -EPROBE_DEFER; return ERR_PTR(-EPROBE_DEFER);
*notify = cec_notifier_get_conn(d, m->conn);
put_device(d); put_device(d);
*conn = m->conn;
return 0; return d;
} }
} }
return -EINVAL; return ERR_PTR(-EINVAL);
} }
static int secocec_acpi_probe(struct secocec_data *sdev) static int secocec_acpi_probe(struct secocec_data *sdev)
...@@ -573,9 +573,15 @@ static int secocec_probe(struct platform_device *pdev) ...@@ -573,9 +573,15 @@ static int secocec_probe(struct platform_device *pdev)
{ {
struct secocec_data *secocec; struct secocec_data *secocec;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device *hdmi_dev;
const char *conn = NULL;
int ret; int ret;
u16 val; u16 val;
hdmi_dev = secocec_cec_find_hdmi_dev(&pdev->dev, &conn);
if (IS_ERR(hdmi_dev))
return PTR_ERR(hdmi_dev);
secocec = devm_kzalloc(dev, sizeof(*secocec), GFP_KERNEL); secocec = devm_kzalloc(dev, sizeof(*secocec), GFP_KERNEL);
if (!secocec) if (!secocec)
return -ENOMEM; return -ENOMEM;
...@@ -617,12 +623,6 @@ static int secocec_probe(struct platform_device *pdev) ...@@ -617,12 +623,6 @@ static int secocec_probe(struct platform_device *pdev)
goto err; goto err;
} }
ret = secocec_cec_get_notifier(&secocec->notifier);
if (ret) {
dev_err(dev, "no CEC notifier available\n");
goto err;
}
ret = devm_request_threaded_irq(dev, ret = devm_request_threaded_irq(dev,
secocec->irq, secocec->irq,
NULL, NULL,
...@@ -640,7 +640,8 @@ static int secocec_probe(struct platform_device *pdev) ...@@ -640,7 +640,8 @@ static int secocec_probe(struct platform_device *pdev)
secocec->cec_adap = cec_allocate_adapter(&secocec_cec_adap_ops, secocec->cec_adap = cec_allocate_adapter(&secocec_cec_adap_ops,
secocec, secocec,
dev_name(dev), dev_name(dev),
CEC_CAP_DEFAULTS, CEC_CAP_DEFAULTS |
CEC_CAP_CONNECTOR_INFO,
SECOCEC_MAX_ADDRS); SECOCEC_MAX_ADDRS);
if (IS_ERR(secocec->cec_adap)) { if (IS_ERR(secocec->cec_adap)) {
...@@ -648,16 +649,20 @@ static int secocec_probe(struct platform_device *pdev) ...@@ -648,16 +649,20 @@ static int secocec_probe(struct platform_device *pdev)
goto err; goto err;
} }
ret = cec_register_adapter(secocec->cec_adap, dev); secocec->notifier = cec_notifier_cec_adap_register(hdmi_dev, conn,
if (ret) secocec->cec_adap);
if (!secocec->notifier) {
ret = -ENOMEM;
goto err_delete_adapter; goto err_delete_adapter;
}
if (secocec->notifier) ret = cec_register_adapter(secocec->cec_adap, dev);
cec_register_cec_notifier(secocec->cec_adap, secocec->notifier); if (ret)
goto err_notifier;
ret = secocec_ir_probe(secocec); ret = secocec_ir_probe(secocec);
if (ret) if (ret)
goto err_delete_adapter; goto err_notifier;
platform_set_drvdata(pdev, secocec); platform_set_drvdata(pdev, secocec);
...@@ -665,6 +670,8 @@ static int secocec_probe(struct platform_device *pdev) ...@@ -665,6 +670,8 @@ static int secocec_probe(struct platform_device *pdev)
return ret; return ret;
err_notifier:
cec_notifier_cec_adap_unregister(secocec->notifier);
err_delete_adapter: err_delete_adapter:
cec_delete_adapter(secocec->cec_adap); cec_delete_adapter(secocec->cec_adap);
err: err:
...@@ -685,11 +692,9 @@ static int secocec_remove(struct platform_device *pdev) ...@@ -685,11 +692,9 @@ static int secocec_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "IR disabled"); dev_dbg(&pdev->dev, "IR disabled");
} }
cec_notifier_cec_adap_unregister(secocec->notifier);
cec_unregister_adapter(secocec->cec_adap); cec_unregister_adapter(secocec->cec_adap);
if (secocec->notifier)
cec_notifier_put(secocec->notifier);
release_region(BRA_SMB_BASE_ADDR, 7); release_region(BRA_SMB_BASE_ADDR, 7);
dev_dbg(&pdev->dev, "CEC device removed"); dev_dbg(&pdev->dev, "CEC device removed");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment