platform:media:cros-ec-cec: adapt to new notifier API
Subsystems (2)
PATCH 1/1 platform:media:cros-ec-cec: adapt to new notifier API
Update ChromeOS CEC EC driver to the new notifier API.
Signed-off-by Dariusz Marcinkiewicz <[email protected]>
--- .../media/platform/cros-ec-cec/cros-ec-cec.c | 70 ++++++++++++------- 1 file changed, 44 insertions(+), 26 deletions(-)
drivers/media/platform/cros-ec-cec/cros-ec-cec.c +44 -26
@@ -217,8 +217,9 @@ static const struct cec_dmi_match cec_dmi_match_table[] = { { "Google", "Fizz", "0000:00:02.0", "Port B" }, }; -static int cros_ec_cec_get_notifier (struct device *dev, -struct cec_notifier **notify) +static int cros_ec_cec_get_hdmi_dev (struct device *dev, +struct device **hdmi_dev, +const char **conn_name) {int i;
@@ -227,16 +228,13 @@ static int cros_ec_cec_get_notifier(struct device *dev,if (dmi_match (DMI_SYS_VENDOR , m->sys_vendor) &&dmi_match (DMI_PRODUCT_NAME , m->product_name)) { -struct device *d; -/* Find the device, bail out if not yet registered */ - d =bus_find_device_by_name (&pci_bus_type,NULL , - m->devname); -if (!d) + *hdmi_dev =bus_find_device_by_name (&pci_bus_type,NULL , + m->devname); +if (*hdmi_dev ==NULL )return -EPROBE_DEFER ; - *notify =cec_notifier_get_conn (d, m->conn); -put_device (d); + *conn_name = m->conn;return 0 ; } }
@@ -249,8 +247,9 @@ static int cros_ec_cec_get_notifier(struct device *dev,#else -static int cros_ec_cec_get_notifier (struct device *dev, -struct cec_notifier **notify) +static int cros_ec_cec_get_hdmi_dev (struct device *dev, +struct cec_notifier **hdmi_dev, +const char **conn_name) {return -ENODEV ; }
@@ -262,6 +261,8 @@ static int cros_ec_cec_probe(struct platform_device *pdev)struct cros_ec_dev *ec_dev =dev_get_drvdata (pdev->dev.parent);struct cros_ec_device *cros_ec = ec_dev->ec_dev;struct cros_ec_cec *cros_ec_cec; +struct device *hdmi_dev; +const char *conn_name;int ret; cros_ec_cec = devm_kzalloc(&pdev->dev, sizeof(*cros_ec_cec),
@@ -272,20 +273,33 @@ static int cros_ec_cec_probe(struct platform_device *pdev)platform_set_drvdata (pdev, cros_ec_cec); cros_ec_cec->cros_ec = cros_ec; - ret =cros_ec_cec_get_notifier (&pdev->dev, &cros_ec_cec->notify); + ret =cros_ec_cec_get_hdmi_dev (&pdev->dev, &hdmi_dev, &conn_name);if (ret)return ret; ret =device_init_wakeup (&pdev->dev,1 );if (ret) {dev_err (&pdev->dev,"failed to initialize wakeup\n" ); -return ret; + goto err_put_hdmi_dev; } cros_ec_cec->adap =cec_allocate_adapter (&cros_ec_cec_ops, cros_ec_cec, -DRV_NAME ,CEC_CAP_DEFAULTS ,1 ); -if (IS_ERR (cros_ec_cec->adap)) -return PTR_ERR (cros_ec_cec->adap); +DRV_NAME , +CEC_CAP_DEFAULTS | +CEC_CAP_CONNECTOR_INFO ,1 ); +if (IS_ERR (cros_ec_cec->adap)) { + ret =PTR_ERR (cros_ec_cec->adap); + goto err_put_hdmi_dev; + } + + cros_ec_cec->notify = +cec_notifier_cec_adap_register (hdmi_dev, conn_name, + cros_ec_cec->adap); +if (!cros_ec_cec->notify) { + ret = -ENOMEM ; + goto err_adap_del; + } +/* Get CEC events from the EC. */ cros_ec_cec->notifier.notifier_call = cros_ec_cec_event;
@@ -293,19 +307,25 @@ static int cros_ec_cec_probe(struct platform_device *pdev) &cros_ec_cec->notifier);if (ret) {dev_err (&pdev->dev,"failed to register notifier\n" ); -cec_delete_adapter (cros_ec_cec->adap); -return ret; + goto err_notifier_adap_unreg; } ret =cec_register_adapter (cros_ec_cec->adap, &pdev->dev); -if (ret <0 ) { -cec_delete_adapter (cros_ec_cec->adap); -return ret; - } +if (ret <0 ) + goto err_notifier_adap_unreg; -cec_register_cec_notifier (cros_ec_cec->adap, cros_ec_cec->notify); +put_device (hdmi_dev);return 0 ; + +err_notifier_adap_unreg: +cec_notifier_cec_adap_unregister (cros_ec_cec->notify); +err_adap_del: +cec_delete_adapter (cros_ec_cec->adap); +err_put_hdmi_dev: +put_device (hdmi_dev); + +return ret; }static int cros_ec_cec_remove (struct platform_device *pdev)
@@ -324,9 +344,7 @@ static int cros_ec_cec_remove(struct platform_device *pdev) }cec_unregister_adapter (cros_ec_cec->adap); - -if (cros_ec_cec->notify) -cec_notifier_put (cros_ec_cec->notify); +cec_notifier_cec_adap_unregister (cros_ec_cec->notify);return 0 ; }
Signature · 1 line
2.18.1