Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2035059pxa; Mon, 24 Aug 2020 03:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlZ8ClrqXiDt/9Kw9o5VMyjXRomGk7Ij/+h5YIlX+YDPr7OjyI0WZFLQcW7CNrhTIyeLhX X-Received: by 2002:a17:906:8748:: with SMTP id hj8mr4961076ejb.477.1598264186983; Mon, 24 Aug 2020 03:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598264186; cv=none; d=google.com; s=arc-20160816; b=kfHsuspVswfLJiI796qxbCPCsi/bicLtK3P/P32DAXgGt1voGuJ/aJsD/c43P7NCaz C3z6J8WIWm9LnIyaZPLbcM/P5gsf9UP8T56j4tF37tDVxR3P6ZdoIqNVb7cUhKJ9exZv 8vGWa/oUza9KjUSmbQEJU1+Mj1//eudKJjMG3OuRWpahPQocGdcLy7XdX+yE1Xd3oI5k fmewknagmVUAy9tIsz78b9rw7Eodv4UTPRtQPtLIs6NJ5alMFSsAQjEtCbvvoIXl3r8C 1B9Yaau2qxIUPuh4mNKINW7hiErEbzAHDJndiM1cAHYJsuDRCeAB6y8JeK9XaiK+kdWt DZkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=PopS7tz4RHPbFcMqsr0Vw0tUhpKwXC6ruZfWKH1KnSk=; b=yaarssn3ka5Elskz/oM36rMG392p78lTMmfFhTyvP6EQhNC5Tc9vnU0eS/1CouLHUM hg9NCYflTZ30jhNBJuj4yjApVPM1bjbC0NC3op9ZpNZIodrbirUq5dN7TPg3Gu86zWic yHYWOfe5IpnoFFWxbJkdf64fkzIjGAuw7cZzVexF4W/0rgMjfnWvZtVlbzyvNJu39Kcp Z63bUeCK29DKDsrE8tWkunLHU5GGDvfM31TByOPZnz1T97UlhqchS27irHoXrnRVXq6h qcblFmCA0lpIV0M7IVLXfTB+L4zdKgsZ2zvVNK+sMTwsAeKI58G34AWbufuCV8iNTK05 OkQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq22si6029588edb.609.2020.08.24.03.16.03; Mon, 24 Aug 2020 03:16:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbgHXKPD (ORCPT + 99 others); Mon, 24 Aug 2020 06:15:03 -0400 Received: from mga12.intel.com ([192.55.52.136]:18743 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgHXKPB (ORCPT ); Mon, 24 Aug 2020 06:15:01 -0400 IronPort-SDR: qBbXJuqGL2q7Plg2GnUr+UxzniZWmEDEdwMX8mE8DDdCzwF2En7mZ/4RTwhAyXXo3j49LUMbi7 TFMTTsxHtSiA== X-IronPort-AV: E=McAfee;i="6000,8403,9722"; a="135416480" X-IronPort-AV: E=Sophos;i="5.76,348,1592895600"; d="scan'208";a="135416480" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 03:15:00 -0700 IronPort-SDR: +1K6+IOcnplflhLmEToWJpcdL/LSAqLYEAscJLX0cLn3OT3K7Ns4k7HWcjTDAUPpuxkru8/RBc jUzt+G+CNW5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,348,1592895600"; d="scan'208";a="328440827" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 24 Aug 2020 03:14:56 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kA9V8-00B1PV-Oz; Mon, 24 Aug 2020 13:14:54 +0300 Date: Mon, 24 Aug 2020 13:14:54 +0300 From: Andy Shevchenko To: "Tanwar, Rahul" Cc: u.kleine-koenig@pengutronix.de, linux-pwm@vger.kernel.org, lee.jones@linaro.org, thierry.reding@gmail.com, p.zabel@pengutronix.de, robh+dt@kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, songjun.Wu@intel.com, cheol.yong.kim@intel.com, qi-ming.wu@intel.com, rahul.tanwar.linux@gmail.com, rtanwar@maxlinear.com Subject: Re: [PATCH v10 2/2] Add PWM fan controller driver for LGM SoC Message-ID: <20200824101454.GK1891694@smile.fi.intel.com> References: <05b664b961e37c1c35fa7d5d1cfc9ae244bc86bc.1598240097.git.rahul.tanwar@linux.intel.com> <20200824081715.GA1891694@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 24, 2020 at 05:36:47PM +0800, Tanwar, Rahul wrote: > On 24/8/2020 4:17 pm, Andy Shevchenko wrote: > > On Mon, Aug 24, 2020 at 11:36:37AM +0800, Rahul Tanwar wrote: ... > >> + ret = reset_control_deassert(pc->rst); > >> + if (ret) { > >> + if (ret != -EPROBE_DEFER) > >> + dev_err_probe(dev, ret, "cannot deassert reset control\n"); > >> + return ret; > >> + } > > Please, spend a bit of time to understand the changes you are doing. There are > > already few examples how to use dev_err_probe() properly. > > I guess your point is that the check of (ret !- -EPROBE_DEFER) is not needed > when using dev_err_probe() as it encapsulates it. It does even more. Look at the existing examples. > Sorry, i missed it. Will > fix it. I am not able to find any other missing point after referring to > two driver examples which uses dev_err_probe() ? There are three drivers that are using it in Linux Next. All of them utilizing it correctly, look at them. > >> + ret = clk_prepare_enable(pc->clk); > >> + if (ret) { > >> + dev_err(dev, "failed to enable clock\n"); > >> + return ret; > >> + } > >> + > >> + ret = devm_add_action_or_reset(dev, lgm_pwm_action, pc); > >> + if (ret) > >> + return ret; > > You have also ordering issues here. > > > > So, what I can see about implementation is that > > > > > > static void ..._clk_disable(void *data) > > { > > clk_disable_unprepare(data); > > } > > > > static int ..._clk_enable(...) > > { > > int ret; > > > > ret = clk_preare_enable(...); > > if (ret) > > return ret; > > return devm_add_action_or_reset(..., ..._clk_disable); > > } > > > > > > Similar for reset control. > > > > Then in the ->probe() something like this: > > > > ret = devm_reset_control_get...; > > if (ret) > > return ret; > > > > ret = ..._reset_deassert(...); > > if (ret) > > return ret; > > > > followed by similar section for the clock. > > > > Regarding ordering: In early rounds of review, feedback about ordering was that > it is recommended to be reverse of the sequence in probe i.e. > if in probe: > 1. reset_control_deassert() > 2. clk_prepare_enable() > then in remove: > 1. clk_disable_uprepare() > 2. reset_control_assert() > > That's the reason i added a generic action() which reverses order. Yes, and my suggestion follows this. > I understand your suggested way as explained above but not sure if that would > ensure reverse ordering during unwind. You have: devm r1 devm r2 enable r1 enable r2 (and here you have broken error path) My suggestion has it like this (and no broken error path): devm r1 enable r1 devm r2 enable r2 -- With Best Regards, Andy Shevchenko