/** * cec_notifier_get_conn - find or create a new cec_notifier for the given * device and connector tuple. * @hdmi_dev: device that sends the events. * @port_name: the connector name from which the event occurs * * If a notifier for device @dev already exists, then increase the refcount * and return that notifier. * * If it doesn't exist, then allocate a new notifier struct and return a * pointer to that new struct. * * Return NULL if the memory could not be allocated.
*/ staticstruct cec_notifier *
cec_notifier_get_conn(struct device *hdmi_dev, constchar *port_name)
{ struct cec_notifier *n;
mutex_lock(&cec_notifiers_lock);
list_for_each_entry(n, &cec_notifiers, head) { if (n->hdmi_dev == hdmi_dev &&
(!port_name ||
(n->port_name && !strcmp(n->port_name, port_name)))) {
kref_get(&n->kref);
mutex_unlock(&cec_notifiers_lock); return n;
}
}
n = kzalloc(sizeof(*n), GFP_KERNEL); if (!n) goto unlock;
n->hdmi_dev = hdmi_dev; if (port_name) {
n->port_name = kstrdup(port_name, GFP_KERNEL); if (!n->port_name) {
kfree(n);
n = NULL; goto unlock;
}
}
n->phys_addr = CEC_PHYS_ADDR_INVALID;
if (!np) {
dev_err(dev, "Failed to find HDMI node in device tree\n"); return ERR_PTR(-ENODEV);
}
hdmi_pdev = of_find_device_by_node(np); if (hdmi_pdev)
hdmi_dev = &hdmi_pdev->dev; #if IS_REACHABLE(CONFIG_I2C) if (!hdmi_dev) { struct i2c_client *hdmi_client = of_find_i2c_device_by_node(np);
if (hdmi_client)
hdmi_dev = &hdmi_client->dev;
} #endif
of_node_put(np); if (!hdmi_dev) return ERR_PTR(-EPROBE_DEFER);
/* * Note that the device struct is only used as a key into the * cec_notifiers list, it is never actually accessed. * So we decrement the reference here so we don't leak * memory.
*/
put_device(hdmi_dev); return hdmi_dev;
}
EXPORT_SYMBOL_GPL(cec_notifier_parse_hdmi_phandle);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.