From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from server.prisktech.co.nz ([115.188.14.127]:59210 "EHLO server.prisktech.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750930Ab3ABFbw (ORCPT ); Wed, 2 Jan 2013 00:31:52 -0500 Message-ID: <1357104713.30504.8.camel@gitbox> Subject: Re: [PATCH RESEND 6/6] clk: s5p-g2d: Fix incorrect usage of IS_ERR_OR_NULL From: Tony Prisk To: Dan Carpenter Cc: Sylwester Nawrocki , Sergei Shtylyov , kernel-janitors@vger.kernel.org, Tomasz Stanislawski , linux-kernel@vger.kernel.org, Kyungmin Park , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Date: Wed, 02 Jan 2013 18:31:53 +1300 In-Reply-To: References: <1355852048-23188-1-git-send-email-linux@prisktech.co.nz> <1355852048-23188-7-git-send-email-linux@prisktech.co.nz> <50D62BC9.9010706@mvista.com> <50E32C06.5020104@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org List-ID: On Wed, 2013-01-02 at 08:10 +0300, Dan Carpenter wrote: > clk_get() returns NULL if CONFIG_HAVE_CLK is disabled. > > I told Tony about this but everyone has been gone with end of year > holidays so it hasn't been addressed. > > Tony, please fix it so people don't apply these patches until > clk_get() is updated to not return NULL. It sucks to have to revert > patches. > > regards, > dan carpenter I posted the query to Mike Turquette, linux-kernel and linux-arm-kernel mailing lists, regarding the return of NULL when HAVE_CLK is undefined. Short Answer: A return value of NULL is valid and not an error therefore we should be using IS_ERR, not IS_ERR_OR_NULL on clk_get results. I see the obvious problem this creates, and asked this question: If the driver can't operate with a NULL clk, it should use a IS_ERR_OR_NULL test to test for failure, rather than IS_ERR. And Russell's answer: Why should a _consumer_ of a clock care? It is _very_ important that people get this idea - to a consumer, the struct clk is just an opaque cookie. The fact that it appears to be a pointer does _not_ mean that the driver can do any kind of dereferencing on that pointer - it should never do so. Thread can be viewed here: https://lkml.org/lkml/2012/12/20/105 Regards Tony Prisk