/** * device_add_property_set - Add a collection of properties to a device object. * @dev: Device to add properties to. * @pset: Collection of properties to add. * * Associate a collection of device properties represented by @pset with @dev * as its secondary firmware node. */ void device_add_property_set(struct device *dev, struct property_set *pset) { if (pset) pset->fwnode.type = FWNODE_PDATA; set_secondary_fwnode(dev, &pset->fwnode); }
/** * device_add_properties - Add a collection of properties to a device object. * @dev: Device to add properties to. * @properties: Collection of properties to add. * * Associate a collection of device properties represented by @properties with * @dev. The function takes a copy of @properties. * * WARNING: The callers should not use this function if it is known that there * is no real firmware node associated with @dev! In that case the callers * should create a software node and assign it to @dev directly. */ int device_add_properties(struct device *dev, const struct property_entry *properties) { struct fwnode_handle *fwnode; fwnode = fwnode_create_software_node(properties, NULL); if (IS_ERR(fwnode)) return PTR_ERR(fwnode); set_secondary_fwnode(dev, fwnode); return 0; }
/** * device_remove_properties - Remove properties from a device object. * @dev: Device whose properties to remove. * * The function removes properties previously associated to the device * firmware node with device_add_properties(). Memory allocated to the * properties will also be released. */ void device_remove_properties(struct device *dev) { struct fwnode_handle *fwnode = dev_fwnode(dev); if (!fwnode) return; if (is_software_node(fwnode->secondary)) { fwnode_remove_software_node(fwnode->secondary); set_secondary_fwnode(dev, NULL); } }
/** * device_add_property_set - Add a collection of properties to a device object. * @dev: Device to add properties to. * @pset: Collection of properties to add. * * Associate a collection of device properties represented by @pset with @dev * as its secondary firmware node. The function takes a copy of @pset. */ int device_add_property_set(struct device *dev, const struct property_set *pset) { struct property_set *p; if (!pset) return -EINVAL; p = pset_copy_set(pset); if (IS_ERR(p)) return PTR_ERR(p); p->fwnode.type = FWNODE_PDATA; set_secondary_fwnode(dev, &p->fwnode); return 0; }
/** * device_remove_property_set - Remove properties from a device object. * @dev: Device whose properties to remove. * * The function removes properties previously associated to the device * secondary firmware node with device_add_property_set(). Memory allocated * to the properties will also be released. */ void device_remove_property_set(struct device *dev) { struct fwnode_handle *fwnode; fwnode = dev_fwnode(dev); if (!fwnode) return; /* * Pick either primary or secondary node depending which one holds * the pset. If there is no real firmware node (ACPI/DT) primary * will hold the pset. */ if (!is_pset_node(fwnode)) fwnode = fwnode->secondary; if (!IS_ERR(fwnode) && is_pset_node(fwnode)) pset_free_set(to_pset_node(fwnode)); set_secondary_fwnode(dev, NULL); }
/** * device_add_properties - Add a collection of properties to a device object. * @dev: Device to add properties to. * @properties: Collection of properties to add. * * Associate a collection of device properties represented by @properties with * @dev as its secondary firmware node. The function takes a copy of * @properties. */ int device_add_properties(struct device *dev, const struct property_entry *properties) { struct property_set *p, pset; if (!properties) return -EINVAL; pset.properties = properties; p = pset_copy_set(&pset); if (IS_ERR(p)) return PTR_ERR(p); p->fwnode.type = FWNODE_PDATA; set_secondary_fwnode(dev, &p->fwnode); return 0; }