/* * PECI device can be removed using sysfs, but the removal can also happen as * a result of controller being removed. * Mutex is used to protect PECI device from being double-deleted.
*/ static DEFINE_MUTEX(peci_device_del_lock);
req = peci_xfer_get_dib(device); if (IS_ERR(req)) return PTR_ERR(req);
/* * PECI device may be in a state where it is unable to return a proper * DIB, in which case it returns 0 as DIB value. * Let's treat this as an error to avoid carrying on with the detection * using invalid revision.
*/
dib = peci_request_dib_read(req); if (dib == 0) {
peci_request_free(req); return -EIO;
}
staticint peci_detect(struct peci_controller *controller, u8 addr)
{ /* * PECI Ping is a command encoded by tx_len = 0, rx_len = 0. * We expect correct Write FCS if the device at the target address * is able to respond.
*/ struct peci_request req = { 0 }; int ret;
mutex_lock(&controller->bus_lock);
ret = controller->ops->xfer(controller, addr, &req);
mutex_unlock(&controller->bus_lock);
int peci_device_create(struct peci_controller *controller, u8 addr)
{ struct peci_device *device; int ret;
if (!peci_addr_valid(addr)) return -EINVAL;
/* Check if we have already detected this device before. */
ret = device_for_each_child(&controller->dev, &addr, peci_dev_exists); if (ret) return 0;
ret = peci_detect(controller, addr); if (ret) { /* * Device not present or host state doesn't allow successful * detection at this time.
*/ if (ret == -EIO || ret == -ETIMEDOUT) return 0;
return ret;
}
device = kzalloc(sizeof(*device), GFP_KERNEL); if (!device) return -ENOMEM;
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.