soc: ti: knav: Use of_property_read_variable_u32_array()
There's no need to get the length of an DT array property before parsing the array. of_property_read_variable_u32_array() takes a minimum and maximum length and returns the actual length (or error code). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_find_property() leaks the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed. Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Link: https://lore.kernel.org/r/20240731201407.1838385-3-robh@kernel.org Signed-off-by: Nishanth Menon <nm@ti.com>
This commit is contained in:
parent
8737e167dc
commit
b2a0176620
@ -602,7 +602,7 @@ static int dma_init(struct device_node *cloud, struct device_node *dma_node)
|
|||||||
unsigned max_tx_chan, max_rx_chan, max_rx_flow, max_tx_sched;
|
unsigned max_tx_chan, max_rx_chan, max_rx_flow, max_tx_sched;
|
||||||
struct device_node *node = dma_node;
|
struct device_node *node = dma_node;
|
||||||
struct knav_dma_device *dma;
|
struct knav_dma_device *dma;
|
||||||
int ret, len, num_chan = 0;
|
int ret, num_chan = 0;
|
||||||
resource_size_t size;
|
resource_size_t size;
|
||||||
u32 timeout;
|
u32 timeout;
|
||||||
u32 i;
|
u32 i;
|
||||||
@ -615,25 +615,13 @@ static int dma_init(struct device_node *cloud, struct device_node *dma_node)
|
|||||||
INIT_LIST_HEAD(&dma->list);
|
INIT_LIST_HEAD(&dma->list);
|
||||||
INIT_LIST_HEAD(&dma->chan_list);
|
INIT_LIST_HEAD(&dma->chan_list);
|
||||||
|
|
||||||
if (!of_find_property(cloud, "ti,navigator-cloud-address", &len)) {
|
ret = of_property_read_variable_u32_array(cloud, "ti,navigator-cloud-address",
|
||||||
dev_err(kdev->dev, "unspecified navigator cloud addresses\n");
|
dma->qm_base_address, 1, DMA_MAX_QMS);
|
||||||
return -ENODEV;
|
if (ret < 0) {
|
||||||
}
|
|
||||||
|
|
||||||
dma->logical_queue_managers = len / sizeof(u32);
|
|
||||||
if (dma->logical_queue_managers > DMA_MAX_QMS) {
|
|
||||||
dev_warn(kdev->dev, "too many queue mgrs(>%d) rest ignored\n",
|
|
||||||
dma->logical_queue_managers);
|
|
||||||
dma->logical_queue_managers = DMA_MAX_QMS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = of_property_read_u32_array(cloud, "ti,navigator-cloud-address",
|
|
||||||
dma->qm_base_address,
|
|
||||||
dma->logical_queue_managers);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(kdev->dev, "invalid navigator cloud addresses\n");
|
dev_err(kdev->dev, "invalid navigator cloud addresses\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
dma->logical_queue_managers = ret;
|
||||||
|
|
||||||
dma->reg_global = pktdma_get_regs(dma, node, 0, &size);
|
dma->reg_global = pktdma_get_regs(dma, node, 0, &size);
|
||||||
if (IS_ERR(dma->reg_global))
|
if (IS_ERR(dma->reg_global))
|
||||||
|
Loading…
Reference in New Issue
Block a user