From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guenter Roeck Subject: Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree Date: Mon, 23 Feb 2015 08:59:55 -0800 Message-ID: <20150223165955.GA9417@roeck-us.net> References: <1418897591-18332-1-git-send-email-l.majewski@samsung.com> <1424254056-5904-1-git-send-email-l.majewski@samsung.com> <1424254056-5904-8-git-send-email-l.majewski@samsung.com> <54E7D0B3.7040800@roeck-us.net> <20150223171336.2e09ce50@amdc2363> <20150223162305.GB2165@roeck-us.net> <20150223175122.2c0a4645@amdc2363> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20150223175122.2c0a4645@amdc2363> Sender: linux-samsung-soc-owner@vger.kernel.org To: Lukasz Majewski Cc: Eduardo Valentin , Kamil Debski , Jean Delvare , Kukjin Kim , lm-sensors@lm-sensors.org, Linux PM list , "linux-samsung-soc@vger.kernel.org" , devicetree@vger.kernel.org, Lukasz Majewski , Kukjin Kim , linux-kernel@vger.kernel.org, Sjoerd Simons , Abhilash Kesavan , Abhilash Kesavan List-Id: devicetree@vger.kernel.org On Mon, Feb 23, 2015 at 05:51:22PM +0100, Lukasz Majewski wrote: > 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). > Correct. > 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; This should probably be something like return ret ? : -EINVAL; or ret == 0 is not an error, and you should not display an error message in that case. Thanks, Guenter