gdev_node = to_software_node(fwnode); if (!gdev_node || !gdev_node->name) return ERR_PTR(-EINVAL);
/* * Check for a special node that identifies undefined GPIOs, this is * primarily used as a key for internal chip selects in SPI bindings.
*/ if (IS_ENABLED(CONFIG_GPIO_SWNODE_UNDEFINED) &&
!strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME)) return ERR_PTR(-ENOENT);
/* * FIXME: The GPIO device reference is put at return but the descriptor * is passed on. Find a proper solution.
*/
desc = gpio_device_get_desc(gdev, args.args[0]);
*flags = args.args[1]; /* We expect native GPIO flags */
pr_debug("%s: parsed '%s' property of node '%pfwP[%d]' - status (%d)\n",
__func__, propname, fwnode, idx, PTR_ERR_OR_ZERO(desc));
return desc;
}
/** * swnode_gpio_count - count the GPIOs associated with a device / function * @fwnode: firmware node of the GPIO consumer, can be %NULL for * system-global GPIOs * @con_id: function within the GPIO consumer * * Returns: * The number of GPIOs associated with a device / function or %-ENOENT, * if no GPIO has been assigned to the requested function.
*/ int swnode_gpio_count(conststruct fwnode_handle *fwnode, constchar *con_id)
{ struct fwnode_reference_args args; char propname[32]; int count;
/* * This is not very efficient, but GPIO lists usually have only * 1 or 2 entries.
*/
for_each_gpio_property_name(propname, con_id) {
count = 0; while (swnode_gpio_get_reference(fwnode, propname, count, &args) == 0) {
fwnode_handle_put(args.fwnode);
count++;
} if (count) return count;
}
return -ENOENT;
}
#if IS_ENABLED(CONFIG_GPIO_SWNODE_UNDEFINED) /* * A special node that identifies undefined GPIOs, this is primarily used as * a key for internal chip selects in SPI bindings.
*/ conststruct software_node swnode_gpio_undefined = {
.name = GPIOLIB_SWNODE_UNDEFINED_NAME,
};
EXPORT_SYMBOL_NS_GPL(swnode_gpio_undefined, "GPIO_SWNODE");
staticint __init swnode_gpio_init(void)
{ int ret;
ret = software_node_register(&swnode_gpio_undefined); if (ret < 0)
pr_err("failed to register swnode: %d\n", ret);
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.