/** * cros_usbpd_register_notify - Register a notifier callback for PD events. * @nb: Notifier block pointer to register * * On ACPI platforms this corresponds to host events on the ECPD * "GOOG0003" ACPI device. On non-ACPI platforms this will filter mkbp events * for USB PD events. * * Return: 0 on success or negative error code.
*/ int cros_usbpd_register_notify(struct notifier_block *nb)
{ return blocking_notifier_chain_register(&cros_usbpd_notifier_list,
nb);
}
EXPORT_SYMBOL_GPL(cros_usbpd_register_notify);
/** * cros_usbpd_unregister_notify - Unregister notifier callback for PD events. * @nb: Notifier block pointer to unregister * * Unregister a notifier callback that was previously registered with * cros_usbpd_register_notify().
*/ void cros_usbpd_unregister_notify(struct notifier_block *nb)
{
blocking_notifier_chain_unregister(&cros_usbpd_notifier_list, nb);
}
EXPORT_SYMBOL_GPL(cros_usbpd_unregister_notify);
/* * We still send a 0 event out to older devices which don't * have the updated device heirarchy.
*/ if (!ec_dev) {
dev_dbg(dev, "EC device inaccessible; sending 0 event status.\n"); goto send_notify;
}
/* Check for PD host events on EC. */
ret = cros_ec_cmd(ec_dev, 0, EC_CMD_PD_HOST_EVENT_STATUS,
NULL, 0, &host_event_status, sizeof(host_event_status)); if (ret < 0) {
dev_warn(dev, "Can't get host event status (err: %d)\n", ret); goto send_notify;
}
pdnotify = devm_kzalloc(dev, sizeof(*pdnotify), GFP_KERNEL); if (!pdnotify) return -ENOMEM;
/* Get the EC device pointer needed to talk to the EC. */
ec_dev = dev_get_drvdata(dev->parent); if (!ec_dev) { /* * We continue even for older devices which don't have the * correct device heirarchy, namely, GOOG0003 is a child * of GOOG0004.
*/
dev_warn(dev, "Couldn't get Chrome EC device pointer.\n");
}
pdnotify->dev = dev;
pdnotify->ec = ec_dev;
status = acpi_install_notify_handler(adev->handle,
ACPI_ALL_NOTIFY,
cros_usbpd_notify_acpi,
pdnotify); if (ACPI_FAILURE(status)) {
dev_warn(dev, "Failed to register notify handler %08x\n",
status); return -EINVAL;
}
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.