Skip to content

Commit eab0dce

Browse files
robherringmartinkpetersen
authored andcommitted
scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length
Replace of_get_property() with the type specific of_property_count_u32_elems() to get the property length. This is part of a larger effort to remove callers of of_get_property() and similar functions. of_get_property() leaks the DT property data pointer which is a problem for dynamically allocated nodes which may be freed. Signed-off-by: Rob Herring (Arm) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent fd9cb96 commit eab0dce

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/ufs/host/ufshcd-pltfrm.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
3131
const char *name;
3232
u32 *clkfreq = NULL;
3333
struct ufs_clk_info *clki;
34-
int len = 0;
3534
size_t sz = 0;
3635

3736
if (!np)
@@ -50,15 +49,12 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
5049
if (cnt <= 0)
5150
goto out;
5251

53-
if (!of_get_property(np, "freq-table-hz", &len)) {
52+
sz = of_property_count_u32_elems(np, "freq-table-hz");
53+
if (sz <= 0) {
5454
dev_info(dev, "freq-table-hz property not specified\n");
5555
goto out;
5656
}
5757

58-
if (len <= 0)
59-
goto out;
60-
61-
sz = len / sizeof(*clkfreq);
6258
if (sz != 2 * cnt) {
6359
dev_err(dev, "%s len mismatch\n", "freq-table-hz");
6460
ret = -EINVAL;

0 commit comments

Comments
 (0)