Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753218AbbBWQve (ORCPT ); Mon, 23 Feb 2015 11:51:34 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:28618 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751948AbbBWQvc (ORCPT ); Mon, 23 Feb 2015 11:51:32 -0500 X-AuditID: cbfee61b-f79d76d0000024d6-6f-54eb5a92b188 Date: Mon, 23 Feb 2015 17:51:22 +0100 From: Lukasz Majewski To: Guenter Roeck 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 Subject: Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree Message-id: <20150223175122.2c0a4645@amdc2363> In-reply-to: <20150223162305.GB2165@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> Organization: SPRC Poland X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRmVeSWpSXmKPExsVy+t9jAd1JUa9DDA7NFrJ4vGYxk8X8I+dY LeZfucZqsfTuJzaLH68vsFms+atk0bvgKptF/+PXzBZvHnFbXN41h83ic+8RRosZ5/cxWTxZ eIbJ4s60vWwW04+/ZXXg9/j7/DqLx85Zd9k9Nq3qZPN4MHE3m8e6aW+ZPXZ+b2D36NuyitFj 8+lqj8+b5AI4o7hsUlJzMstSi/TtErgyXkx+y1xwnr9i/62cBsbP3F2MnBwSAiYSs3d+YIWw xSQu3FvPBmILCSxilLh+SbCLkQvI/sUosWLLbrAiFgFVibtPlzCC2GwCehKf7z5lArFFBNQk mk+1sIE0MAvsZZH4/vEw2CRhgUiJA+2d7F2MHBy8QA0zDhmAhDkFDCUedp1ih1iwikmi/+kp sAX8ApIS7f9+MENcZCdx7tMGdhCbV0BQ4sfkeywgNrOAlsTmbU2sELa8xOY1b5knMArOQlI2 C0nZLCRlCxiZVzGKphYkFxQnpeca6RUn5haX5qXrJefnbmIEx9sz6R2MqxosDjEKcDAq8fA2 5L4KEWJNLCuuzD3EKMHBrCTC+0b3dYgQb0piZVVqUX58UWlOavEhRmkOFiVxXiX7thAhgfTE ktTs1NSC1CKYLBMHp1QD44Q9Dmrxe361565pabo/T3OPYTezbVBf+5dpfXZb497oKx+cplmo e+Kam3GEV9EK1uc2EjyK9wWLdNldbWb45vD/5yjhnjn10hmGK6+P7VjG/8RCSK35b/Cn4pXh b1LaF/w4em+WZ9mp5Xf4P5w8XHeQR2X7uzRT4QmTCuQOOOfnhkz92j17sRJLcUaioRZzUXEi AIIKVlCzAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2156 Lines: 93 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/