The cell_count argument is required when cells_name is NULL.
This patch adds this parameter in live tree API
- of_count_phandle_with_args
- ofnode_count_phandle_with_args
- dev_count_phandle_with_args
This parameter solves issue when these API is used to count
the number of element of a cell without cell name. This parameter
allow to force the size cell.
For example:
count = dev_count_phandle_with_args(dev, "array", NULL, 3);
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
* for each of them
*/
adc_count = ofnode_count_phandle_with_args(node, "st,adc_usb_pd",
- "#io-channel-cells");
+ "#io-channel-cells", 0);
if (adc_count < 0) {
if (adc_count == -ENOENT)
return 0;
bulk->count = 0;
- count = dev_count_phandle_with_args(dev, "clocks", "#clock-cells");
+ count = dev_count_phandle_with_args(dev, "clocks", "#clock-cells", 0);
if (count < 1)
return count;
int ret;
num_parents = dev_count_phandle_with_args(dev, "assigned-clock-parents",
- "#clock-cells");
+ "#clock-cells", 0);
if (num_parents < 0) {
debug("%s: could not read assigned-clock-parents for %p\n",
__func__, dev);
}
int of_count_phandle_with_args(const struct device_node *np,
- const char *list_name, const char *cells_name)
+ const char *list_name, const char *cells_name,
+ int cell_count)
{
- return __of_parse_phandle_with_args(np, list_name, cells_name, 0,
- -1, NULL);
+ return __of_parse_phandle_with_args(np, list_name, cells_name,
+ cell_count, -1, NULL);
}
static void of_alias_add(struct alias_prop *ap, struct device_node *np,
}
int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
- const char *cells_name)
+ const char *cells_name, int cell_count)
{
if (ofnode_is_np(node))
return of_count_phandle_with_args(ofnode_to_np(node),
- list_name, cells_name);
+ list_name, cells_name, cell_count);
else
return fdtdec_parse_phandle_with_args(gd->fdt_blob,
ofnode_to_offset(node), list_name, cells_name,
- 0, -1, NULL);
+ cell_count, -1, NULL);
}
ofnode ofnode_path(const char *path)
}
int dev_count_phandle_with_args(const struct udevice *dev,
- const char *list_name, const char *cells_name)
+ const char *list_name, const char *cells_name,
+ int cell_count)
{
return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
- cells_name);
+ cells_name, cell_count);
}
int dev_read_addr_cells(const struct udevice *dev)
int i, clock_nb;
priv->clock_count = 0;
- clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells");
+ clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
+ 0);
if (clock_nb > 0) {
priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
GFP_KERNEL);
if (!dev_read_prop(dev, "phys", NULL))
return 0;
- count = dev_count_phandle_with_args(dev, "phys", "#phy-cells");
+ count = dev_count_phandle_with_args(dev, "phys", "#phy-cells", 0);
if (count < 1)
return count;
int i, count, ret = 0;
count = dev_count_phandle_with_args(dev, "power-domains",
- "#power-domain-cells");
+ "#power-domain-cells", 0);
for (i = 0; i < count; i++) {
ret = power_domain_get_by_index(dev, &pd, i);
if (ret)
bulk->count = 0;
- count = ofnode_count_phandle_with_args(node, "resets", "#reset-cells");
+ count = ofnode_count_phandle_with_args(node, "resets", "#reset-cells",
+ 0);
if (count < 1)
return count;
err = 0;
priv->clock_count = 0;
clock_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "clocks",
- "#clock-cells");
+ "#clock-cells", 0);
if (clock_nb > 0) {
priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
GFP_KERNEL);
priv->reset_count = 0;
reset_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "resets",
- "#reset-cells");
+ "#reset-cells", 0);
if (reset_nb > 0) {
priv->resets = devm_kcalloc(dev, reset_nb,
sizeof(struct reset_ctl),
err = 0;
priv->clock_count = 0;
- clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells");
+ clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
+ 0);
if (clock_nb < 0)
return clock_nb;
err = 0;
priv->clock_count = 0;
- clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells");
+ clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
+ 0);
if (clock_nb > 0) {
priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
GFP_KERNEL);
}
priv->reset_count = 0;
- reset_nb = dev_count_phandle_with_args(dev, "resets", "#reset-cells");
+ reset_nb = dev_count_phandle_with_args(dev, "resets", "#reset-cells",
+ 0);
if (reset_nb > 0) {
priv->resets = devm_kcalloc(dev, reset_nb,
sizeof(struct reset_ctl),
* @np: pointer to a device tree node containing a list
* @list_name: property name that contains a list
* @cells_name: property name that specifies phandles' arguments count
+ * @cells_count: Cell count to use if @cells_name is NULL
* @return number of phandle found, -ENOENT if
* @list_name does not exist, -EINVAL if a phandle was not found,
* @cells_name could not be found, the arguments were truncated or there
*
*/
int of_count_phandle_with_args(const struct device_node *np,
- const char *list_name, const char *cells_name);
+ const char *list_name, const char *cells_name,
+ int cells_count);
/**
* of_alias_scan() - Scan all properties of the 'aliases' node
* @node: device tree node containing a list
* @list_name: property name that contains a list
* @cells_name: property name that specifies phandles' arguments count
+ * @cells_count: Cell count to use if @cells_name is NULL
* @return number of phandle on success, -ENOENT if @list_name does not
* exist, -EINVAL if a phandle was not found, @cells_name could not
* be found.
*/
int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
- const char *cells_name);
+ const char *cells_name, int cell_count);
/**
* ofnode_path() - find a node by full path
* @dev: device whose node containing a list
* @list_name: property name that contains a list
* @cells_name: property name that specifies phandles' arguments count
+ * @cells_count: Cell count to use if @cells_name is NULL
* @Returns number of phandle found on success, on error returns appropriate
* errno value.
*/
int dev_count_phandle_with_args(const struct udevice *dev,
- const char *list_name, const char *cells_name);
+ const char *list_name, const char *cells_name,
+ int cell_count);
/**
* dev_read_addr_cells() - Get the number of address cells for a device's node
}
static inline int dev_count_phandle_with_args(const struct udevice *dev,
- const char *list_name, const char *cells_name)
+ const char *list_name, const char *cells_name, int cell_count)
{
return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
- cells_name);
+ cells_name, cell_count);
}
static inline int dev_read_addr_cells(const struct udevice *dev)