Hi Guenter, > On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote: > > Hi Guenter, > > > [ ... ] > > > > > > > If devicetree is not configured, of_property_count_elems_of_size > > > returns -ENOSYS, which is returned, causing the driver to fail > > > loading. > > > > Has of_property_count_elems_of_size() returns -ENOSYS? > > > > Maybe something has changed, but in my linux-vanila (3.19-rc4) > > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of > > elements. > > > > Have I missed something? > > > Hi Lukasz, > > Yes, you have. Check include/linux/of.h, line 484, in latest mainline.
Ok. Now I got it. The above situation shouldn't happen if I put of_find_property() check on the very beginning of this function (it returns NULL when DT support is not compiled). The function would look as follows: int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx) { struct device_node *np = dev->of_node; int num, i, ret; if (!of_find_property(np, "cooling-levels", NULL)) return 0; ret = of_property_count_u32_elems(np, "cooling-levels"); if (ret <= 0) { dev_err(dev, "Wrong data!\n"); return ret; } num = ret; ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32), GFP_KERNEL); if (!ctx->pwm_fan_cooling_levels) return -ENOMEM; ret = of_property_read_u32_array(np, "cooling-levels", ctx->pwm_fan_cooling_levels, num); if (ret) { dev_err(dev, "Property 'cooling-levels' cannot be read!\n"); return ret; } for (i = 0; i < num; i++) { if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) { dev_err(dev, "PWM fan state[%d]:%d > %d\n", i, ctx->pwm_fan_cooling_levels[i], MAX_PWM); return -EINVAL; } } ctx->pwm_fan_max_state = num - 1; return 0; } > > Guenter -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/