Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2031877iog; Sun, 19 Jun 2022 05:40:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vED89cNXc5sVij2iaKdXmuuKM847Ks1iIb73PIIZVJSk4tJPxItCxBo7jxOxWhDiym0O33 X-Received: by 2002:a17:907:8b87:b0:715:e127:b64d with SMTP id tb7-20020a1709078b8700b00715e127b64dmr16641463ejc.481.1655642415841; Sun, 19 Jun 2022 05:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655642415; cv=none; d=google.com; s=arc-20160816; b=x697o8TC7EQlmAS8aF0ifLO5k3HsmkfHB/emCVRwpwxbamMGgyhQIH8fuk2SbGlOmb 0SUZxaufvuFxMK0ycCDybLC9g0xUXhYBc274r+74ax0rjin4Knh8e3W4tF6wX6vWXUhn e51e+3G+A2jhVViRah3WsBcqVpQ+HEwxsOTjYr5ib56i62NtihKPrPVowd5TFJG5ay5y iIoy4tf1GVlrGDxWhP7Szamr5TaA1OQ3mpZ2dlz+cpNjTV3PZeInqNLyYQ62iXfRnEbY 548JeasX7ay/CVwMMoyout4UaNt3XWzHVOd7RRLmgJxzG/NHPWCN+cXSJXUQ3RkJGGg3 cTJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Rh3hG6QoZqWeIWzLwR9qo/CDTIGgrXjwGtskY9V0r6g=; b=llt94np0uWo5YauROBLiJK77UTbqYNf7UBEvQvkRoV0qeOkH5ToJlGoNFUqf7b4Id3 xQD3bweWVFCrEXQM1Dg1jHpCG0eNMHNUAO6rB3oP2q7t7Irkdc9K7/3rCMTiHbpC54X8 1/RUuszlKHWkoymPwSr/J3vzBp6yuXGVwIzIYkFVSz0P3JJzr+TrSVDkudNTyD+GpU0f d7yPKi/u7/nZBVtXCVHN9DUttiJKhPI2fXBtrL768acg4QNCSx4tXwT8BURNl/+tF4Rj QADz3EySWtM4P6KDehcsFlnUt3Lu0w9xLUa1ItDH4QXzW7oFoEuvA7TdP8AUXMsnmNW+ GiTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ub9RWeLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt8-20020a170906b78800b0070795e99fe3si8641910ejb.984.2022.06.19.05.39.50; Sun, 19 Jun 2022 05:40:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ub9RWeLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235724AbiFSMfd (ORCPT + 99 others); Sun, 19 Jun 2022 08:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiFSMfc (ORCPT ); Sun, 19 Jun 2022 08:35:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F44D62DF; Sun, 19 Jun 2022 05:35:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5B175B80CAA; Sun, 19 Jun 2022 12:35:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 437C1C341D1; Sun, 19 Jun 2022 12:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655642128; bh=q6lkeo/SrEPWQ+2brReD5ukp5cS1BU9o1wOUu1pRlN8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ub9RWeLV6l+SAYChJ8kHMkq9JWcH1okn3+XjllXUvnylITVeaEUpE8zWiOzwCP0/K 4eUHLrfxcYEAbhSo7oA6aKL2BfWtfSzSJrJQ0JlYVd8yT+Eltlwh5SV9uJUJiMzeHz kE+diiOmDVNTHQhgdMnrTF+yxhvEJZ+HWRP5tRwDk5BaWSXmmvBFHpFaALJ/H2uT1h tZcWrXHrNiY+1+0axtDYoZ130v1TwoKYroJHqeBWnC+3RTg7ju1gfxzNsZuL+WiIgj SxBAxIW302hGzNkUadrjewhT//N1xTu3JQxAfldic3g7M/+L1vyCZehIZ01ZllMaf9 /es6eeG9kShcA== Date: Sun, 19 Jun 2022 13:44:43 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: Shreeya Patel , Lars-Peter Clausen , Rob Herring , Zhigang.Shi@liteon.com, krisman@collabora.com, linux-iio , devicetree , Linux Kernel Mailing List , Collabora Kernel ML , alvaro.soliverez@collabora.com, Dmitry Osipenko , kernel test robot Subject: Re: [PATCH v6 2/2] iio: light: Add support for ltrf216a sensor Message-ID: <20220619134443.23874255@jic23-huawei> In-Reply-To: References: <20220615135130.227236-1-shreeya.patel@collabora.com> <20220615135130.227236-3-shreeya.patel@collabora.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > + /* reset sensor, chip fails to respond to this, so ignore any errors */ > > + ltrf216a_reset(indio_dev); > > + > > + ret = pm_runtime_set_active(&client->dev); > > + if (ret) > > + goto error_power_down; > > Why do you need to power down here? > > > + pm_runtime_enable(&client->dev); We now have devm_pm_runtime_enable() which will also deal with disabling use_autosuspend for you and should help you sort out some of the ordering. > > + pm_runtime_set_autosuspend_delay(&client->dev, 5000); > > + pm_runtime_use_autosuspend(&client->dev); > > + > > + ltrf216a_set_power_state(data, true); > > The below code suggests that you are mixing badly devm_ with non-devm_ > APIs, don't do this. You have to group devm_ first followed by > non-devm_ calls. > > ... > > > +static int ltrf216a_remove(struct i2c_client *client) > > +{ > > + struct iio_dev *indio_dev = i2c_get_clientdata(client); > > + > > + iio_device_unregister(indio_dev); > > + pm_runtime_disable(&client->dev); > > + pm_runtime_set_suspended(&client->dev); > > + ltrf216a_disable(indio_dev); > > + > > + return 0; > > I believe the ordering of freeing resources and reverting state is not > in reverse. See above why. In particular you are calling disable there which is already handled by devm_ unwinding. > > > +} >