Skip to content

Commit 75f0cb3

Browse files
robherringUwe Kleine-König
authored andcommitted
pwm: lp3943: 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] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent f9ecc2f commit 75f0cb3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/pwm/pwm-lp3943.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int lp3943_pwm_parse_dt(struct device *dev,
218218
struct lp3943_platform_data *pdata;
219219
struct lp3943_pwm_map *pwm_map;
220220
enum lp3943_pwm_output *output;
221-
int i, err, proplen, count = 0;
221+
int i, err, count = 0;
222222
u32 num_outputs;
223223

224224
if (!node)
@@ -234,11 +234,8 @@ static int lp3943_pwm_parse_dt(struct device *dev,
234234
*/
235235

236236
for (i = 0; i < LP3943_NUM_PWMS; i++) {
237-
if (!of_get_property(node, name[i], &proplen))
238-
continue;
239-
240-
num_outputs = proplen / sizeof(u32);
241-
if (num_outputs == 0)
237+
num_outputs = of_property_count_u32_elems(node, name[i]);
238+
if (num_outputs <= 0)
242239
continue;
243240

244241
output = devm_kcalloc(dev, num_outputs, sizeof(*output),

0 commit comments

Comments
 (0)