Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 404D1C7EE32 for ; Thu, 2 Mar 2023 14:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbjCBOx0 (ORCPT ); Thu, 2 Mar 2023 09:53:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbjCBOxX (ORCPT ); Thu, 2 Mar 2023 09:53:23 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0FF4C30; Thu, 2 Mar 2023 06:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677768773; x=1709304773; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=ebv+yvAFYIWfjP1yIrOAZOb/TIWMmyj7FnJDi/XFutw=; b=IaoMi5KDYPn0LkW8Tc5SFLC5ixqSqERRwasSf1DAGIjP+lZgL7GnPNDi XOdRLQUkp3jEz1eFGIYv+2o3vWGACzHA5OPv6JnKPIkAyxDlX9OaE9IOZ aMFn6Z3KoKgwN5aXZr+VbnH34vQDlntk56TtOLdoKJWszvvDUYV3NtLEC Cv5UlwLTnmIYjRKe3yWveDcLyvXaf5wIfW8/vmT2+j8kcqgoeXJlyLX2f t0Fj6QCMoqvQc7/i0ON3m/gBryiE7BQTtG+LN07uiyVPNAT0ICBkNGWsH h1OG1oJwm2BUeH6w0151qOfpsK6zNJlW64PwO8c/xz9EX2yZGP85Q+Ola Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="323023336" X-IronPort-AV: E=Sophos;i="5.98,227,1673942400"; d="scan'208";a="323023336" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2023 06:24:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="764017574" X-IronPort-AV: E=Sophos;i="5.98,227,1673942400"; d="scan'208";a="764017574" Received: from smile.fi.intel.com ([10.237.72.54]) by FMSMGA003.fm.intel.com with ESMTP; 02 Mar 2023 06:24:09 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pXjqo-00ENf7-2z; Thu, 02 Mar 2023 16:24:06 +0200 Date: Thu, 2 Mar 2023 16:24:06 +0200 From: Andy Shevchenko To: Lars-Peter Clausen Cc: Mike Looijmans , devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Caleb Connolly , ChiYuan Huang , ChiaEn Wu , Cosmin Tanislav , Ibrahim Tilki , Jonathan Cameron , Ramona Bolboaca , William Breathitt Gray , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] iio: adc: Add TI ADS1100 and ADS1000 Message-ID: References: <20230228063151.17598-1-mike.looijmans@topic.nl> <20230228063151.17598-2-mike.looijmans@topic.nl> <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.0685d97e-4a28-499e-a9e3-3bafec126832@emailsignatures365.codetwo.com> <87bc192e-45ae-9480-5e84-8fe0adfc12e7@metafoo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 02, 2023 at 05:20:38AM -0800, Lars-Peter Clausen wrote: > On 3/2/23 05:16, Lars-Peter Clausen wrote: > > On 3/1/23 23:49, Mike Looijmans wrote: ... > > > > > +static int ads1100_runtime_suspend(struct device *dev) > > > > > +{ > > > > > +??? struct iio_dev *indio_dev = > > > > > i2c_get_clientdata(to_i2c_client(dev)); > > > > > +??? struct ads1100_data *data = iio_priv(indio_dev); > > > > > + > > > > > +??? ads1100_set_config_bits(data, ADS1100_CFG_SC, > > > > > ADS1100_SINGLESHOT); > > > > > +??? regulator_disable(data->reg_vdd); > > > > Wrong devm / non-devm ordering. > > > > > > Don't understand your remark, can you explain further please? > > > > > > devm / non-devm ordering would be related to the "probe" function. > > > As far as I can tell, I'm not allocating resources after the devm > > > calls. And the "remove" is empty. > > > > Strictly speaking we need to unregister the IIO device before disabling > > the regulator, otherwise there is a small window where the IIO device > > still exists, but doesn't work anymore. This is a very theoretical > > scenario though. > > > > You are lucky :) There is a new function > > `devm_regulator_get_enable()`[1], which will manage the > > regulator_disable() for you. Using that will also reduce the boilerplate > > in `probe()` a bit > > > > [1] https://lwn.net/Articles/904383/ > > > Sorry, just saw that Andy's comment was on the suspend() function, not > remove(). In that case there is of course no need for any devm things. But > still a good idea to use `devm_regulator_get_enable()` in probe for the > boiler plate. Yeah, sorry, I mistakenly took it as ->remove(). -- With Best Regards, Andy Shevchenko