diff --git a/drivers/media/platform/seco-cec/seco-cec.c b/drivers/media/platform/seco-cec/seco-cec.c index 1d0133f01e00..9cd60fe1867c 100644 --- a/drivers/media/platform/seco-cec/seco-cec.c +++ b/drivers/media/platform/seco-cec/seco-cec.c @@ -507,10 +507,10 @@ err: } struct cec_dmi_match { - char *sys_vendor; - char *product_name; - char *devname; - char *conn; + const char *sys_vendor; + const char *product_name; + const char *devname; + const char *conn; }; 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" }, }; -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; @@ -533,16 +534,15 @@ static int secocec_cec_get_notifier(struct cec_notifier **notify) d = bus_find_device_by_name(&pci_bus_type, NULL, m->devname); if (!d) - return -EPROBE_DEFER; + return ERR_PTR(-EPROBE_DEFER); - *notify = cec_notifier_get_conn(d, m->conn); put_device(d); - - return 0; + *conn = m->conn; + return d; } } - return -EINVAL; + return ERR_PTR(-EINVAL); } static int secocec_acpi_probe(struct secocec_data *sdev) @@ -573,9 +573,15 @@ static int secocec_probe(struct platform_device *pdev) { struct secocec_data *secocec; struct device *dev = &pdev->dev; + struct device *hdmi_dev; + const char *conn = NULL; int ret; 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); if (!secocec) return -ENOMEM; @@ -617,12 +623,6 @@ static int secocec_probe(struct platform_device *pdev) 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, secocec->irq, NULL, @@ -640,7 +640,8 @@ static int secocec_probe(struct platform_device *pdev) secocec->cec_adap = cec_allocate_adapter(&secocec_cec_adap_ops, secocec, dev_name(dev), - CEC_CAP_DEFAULTS, + CEC_CAP_DEFAULTS | + CEC_CAP_CONNECTOR_INFO, SECOCEC_MAX_ADDRS); if (IS_ERR(secocec->cec_adap)) { @@ -648,16 +649,20 @@ static int secocec_probe(struct platform_device *pdev) goto err; } + secocec->notifier = cec_notifier_cec_adap_register(hdmi_dev, conn, + secocec->cec_adap); + if (!secocec->notifier) { + ret = -ENOMEM; + goto err_delete_adapter; + } + ret = cec_register_adapter(secocec->cec_adap, dev); if (ret) - goto err_delete_adapter; - - if (secocec->notifier) - cec_register_cec_notifier(secocec->cec_adap, secocec->notifier); + goto err_notifier; ret = secocec_ir_probe(secocec); if (ret) - goto err_delete_adapter; + goto err_notifier; platform_set_drvdata(pdev, secocec); @@ -665,6 +670,8 @@ static int secocec_probe(struct platform_device *pdev) return ret; +err_notifier: + cec_notifier_cec_adap_unregister(secocec->notifier); err_delete_adapter: cec_delete_adapter(secocec->cec_adap); err: @@ -685,11 +692,9 @@ static int secocec_remove(struct platform_device *pdev) dev_dbg(&pdev->dev, "IR disabled"); } + cec_notifier_cec_adap_unregister(secocec->notifier); cec_unregister_adapter(secocec->cec_adap); - if (secocec->notifier) - cec_notifier_put(secocec->notifier); - release_region(BRA_SMB_BASE_ADDR, 7); dev_dbg(&pdev->dev, "CEC device removed");