Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1405717imm; Thu, 19 Jul 2018 00:43:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmG3pKHfy0wWrWXKKIFSAneMu72TKsTyBCAFDL7dI9KFUJ1ZW6IzhVTNUMGOZY17qFn7CY X-Received: by 2002:a63:524e:: with SMTP id s14-v6mr9027830pgl.35.1531986190533; Thu, 19 Jul 2018 00:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531986190; cv=none; d=google.com; s=arc-20160816; b=oRWlmIriXHJvtPbykID/wDN3UIeKDvlBQOHcr1Z0W863PAnBwRoBPpNuGzJqFDj8sp P9/cGdsh/OG2Ot8TroUocX5t5jp6tzmPDQekbU7s2eYRZkXKHbqrDhOdcMmltMwiA3Zf KAWItaRBsvxTsECUZUV0pSCVu5xWKZ63olEIh4f6asYECoAthAAnn+GboUQ9FX+t2XUO 5BzA8xPLl1yVgEFIlh7vqvH7jr/cg3jhwddAQEDMUm19b9qiVMz4jPS00t/kAkAJo3uV MeB1oZyvxG+R1EwZHisIvoAbqP1VqJMmYcRmJv6Utx8WR+t/GjuPUn9u2uF5nV3rmFtt VXOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organisation:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=6I1nkiy0z86fI5wuS9EEdFs5ya+qGUOsUgwYWa5rY5Y=; b=jZYBlBmKWsSfNYnl/xe48mNQ3Ays5UIdOiB/f0hPD7+ya+iizmSBhjmwOa5K09casn IJjayU2/ru8entkBBEkO/q9z2m4zXXl9dqs0NDvugeXDzXl5vUPn3PRtcCe1hWl1J5f1 6zeiTfC8gN2M6qRHfa8PfKq0p+H3uIxrRZyU05LbAL2yXKu6G6hot/I7ITBtsODJXX7D vyli72um9kc+2H7PMELvP1FGhga8FnZXgabpBcgsiVymadlDa1f3ak6i+wVSQtAJgNKP xoqw6nq8PkpRWoQ8M7R41Eej7/IXQYkz6ltH2lAjy4UR7vc5vyegMcAX0qMtQJYeF4RM 2Yng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verge.net.au header.s=mail header.b=o0zzdLBT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5-v6si4703226plo.3.2018.07.19.00.42.55; Thu, 19 Jul 2018 00:43:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@verge.net.au header.s=mail header.b=o0zzdLBT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731293AbeGSIYB (ORCPT + 99 others); Thu, 19 Jul 2018 04:24:01 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:38691 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730123AbeGSIYA (ORCPT ); Thu, 19 Jul 2018 04:24:00 -0400 Received: from reginn.horms.nl (watermunt.horms.nl [80.127.179.77]) by kirsty.vergenet.net (Postfix) with ESMTPA id C4DA025B7BD; Thu, 19 Jul 2018 17:42:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1531986130; bh=UMLxiXAq6U7Aw7bmQ9CNEOqZk11AoR3BAuNvXs5hCtE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o0zzdLBT8qGxbpw3UYFKN3bEc2bOnpPWH+FbbX75aT+QWo6Z1fNwLFzI0pJroTq/y 0bt/oLm2HKSB6MRsGSvwxs3CHUER8hTqrOMkvZj2ifw4nMG+aDpWppWEXwrz4tmxz9 kHfWWkjfe4OyJjsUM4uO4uLVPoIgEeANGMgia0vY= Received: by reginn.horms.nl (Postfix, from userid 7100) id BFF8D940301; Thu, 19 Jul 2018 09:42:07 +0200 (CEST) Date: Thu, 19 Jul 2018 09:42:07 +0200 From: Simon Horman To: Phil Edworthy Cc: Andy Shevchenko , Jarkko Nikula , Geert Uytterhoeven , "linux-i2c@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , Mika Westerberg Subject: Re: [PATCH 2/2] i2c: designware: Add support for a bus clock Message-ID: <20180719074207.kg4kgibgszzac3on@verge.net.au> References: <1531731553-22979-3-git-send-email-phil.edworthy@renesas.com> <20180717120737.bipotpki3yhn6klf@verge.net.au> <40f2729f38bd565a829d60d9cc8f508e33b0dc65.camel@linux.intel.com> <20180718091448.fw2y7ea6sk2osi3g@verge.net.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organisation: Horms Solutions BV User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 18, 2018 at 09:21:22AM +0000, Phil Edworthy wrote: > Hi Simon, > > On 18 July 2018 10:15 Simon Horman wrote: > > On Tue, Jul 17, 2018 at 02:57:27PM +0000, Phil Edworthy wrote: > > > On 17 July 2018 15:47, Andy Shevchenko wrote: > > > > On Tue, 2018-07-17 at 14:40 +0000, Phil Edworthy wrote: > > > > > On 17 July 2018 15:19, Andy Shevchenko wrote: > > > > > > On Tue, 2018-07-17 at 12:42 +0000, Phil Edworthy wrote: > > > > > > > > > > > > > > While your point sounds valid (don't remember how clk_get() > > > > > > > > is implemented), NULL is also OK to have. > > > > > > > > > > > > > > Ok as in there is no bus clock, right? > > > > > > > So it should be: > > > > > > > if (!IS_ERR_OR_NULL (dev->busclk)) > > > > > > > > > > > > Nope, NULL is no error case for optional clock. > > > > > > > > > > I must be missing something here... > > > > > > > > See how clk_prepare_enable() is implemented. > > > Ok, if busclk is NULL the code can safely call clk_prepare_enable() > > > > > > > > I agree that NULL for an optional clock is not an error. However, > > > > > the code above is now: > > > > > + if (prepare) { > > > > > + /* Optional bus clock */ > > > > > > > > > + if (!IS_ERR_OR_NULL(dev->busclk)) { > > > > > > > > Check for NULL is redundant. > > > > > > > > > + ret = clk_prepare_enable(dev->busclk); > > > > > + if (ret) > > > > > + return ret; > > > > > + } > > > > > + > > > > > return clk_prepare_enable(dev->clk); > > > > > + } > > > > > > > > > > So, if you have a valid busclk, it gets enabled, otherwise it is > > > > > left alone. > > > > > > > So the code as sent in the original email is correct (aside from > > > Geert's comments about EPROBE_DEFER handling). > > > > > > Maybe I need some coffee :\ > > > Thanks > > > Phil > > > > My point is that errors should be treated as errors. > > > > In i2c_dw_prepare_clk() the following appears: > > > > if (IS_ERR(dev->clk)) > > return PTR_ERR(dev->clk); > > > > So dev->clk being an error value is treated as an error that is passed up to the > > caller. > > > > But in your patch (and the snippet below) dev->busclk is treated as the > > optional clock not being present. Even if the error stored nothing to do with > > the clock not being present - f.e. ENOMEM or as Geert mentioned > > elsewhere, EPROBE_DEFER. > > > > Assuming the absense of the optional clock is indicated by ENOENT, in my > > view correct code would include something like: > > > > ... > > > > if (IS_ERR(dev->clk)) > > return PTR_ERR(dev->clk); > > > > if (IS_ERR(dev->buslck) && PTR_ERR(dev->busclk) != -ENOENT) > > return PTR_ERR(dev->busclk); > > > > ... > > Yes, I completely agree! Great, sorry if I elaborated excessively.