Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp47250lqt; Thu, 18 Apr 2024 08:06:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyKUT5frtn44kaP7iepZe8aNBulNsiqNsQ8JlZ/8BVRsNMmhzeGiJPw8Z4lmyUFOOdP5BMlN58lRic5C4EqaAtJjRr/Fz8epUJVpgaHg== X-Google-Smtp-Source: AGHT+IFA+daakVY9Pe2tY2V4zdeSxdzNBvDoOwrNgtJnv/cL5/+54bbS0Jc7bN9XwdfOpgu5TcOo X-Received: by 2002:a17:902:d507:b0:1e4:6253:2f15 with SMTP id b7-20020a170902d50700b001e462532f15mr3635811plg.16.1713452817793; Thu, 18 Apr 2024 08:06:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713452817; cv=pass; d=google.com; s=arc-20160816; b=f1Sxpzsm+T/eASeujKGhiNftwX/9xy4Bsx6HYsb0uHC3xMLiOFGnUGD6szOzxoVnPV +U4Vb+kqvn4XwVtqtNck5o6qk6JVqs8+UyE6fv1/xQz7DGtbYSEEQYrykgZn6OwULPp/ kczC1jqgIOfDS1BBaPAV9NQMC0IrpprMZq+iqj6j6KcBQm/jNBde2PlDgl+8N6JNk42X xK6GQ02bku07HFRaiNvusOKyKlyJCudVQVx4cbmVXkCuOUhTw5Aa/w29I/ndKh7bqEXn gjHyfAhbZ97lAkv/74lpbIqXJowGM8TnYfb1BQPfA/OMQiVjuQuAiGg7BVCkdovdyuZR 5tKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date; bh=VCd0NHg7beAhJoKEm/QgbRTnUak2JYtg99vMXKxsa0M=; fh=VEoedhfMvetUwS8JwIhzylJ7uk9AT6d/rDGR6StcPxA=; b=Tvx0yFy7jhaAAV6inYzMqWnxALVPcsnFk/QIQBeLHqlRXi5rYfRzStpcuMsk6KC9VF NaRt+/XcJxluna22VmmfkrgYbImBHyPkGmYZAvuznwsc/ZGFFU5I5X+XLxAU5x5dVksF NdVin9TkgXJjq6ZCM0sS7xn+i/KfIRw4VZliFOHURryFjYclt4/ObvWxsZNA0Y8BJFt0 tplujV5itu6pX5mSLD8hxC+c8EUTHqdkVMrq6LEhCVcOjaFbycBrNEz5haoNh9C6C+7q Zoa9NBPEhJ513K5NyFgIDIvVT6MEyHQ+Esjbkngofavy82wW8LlirB7zBLOZ5N//Mz7S FUVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=p6RTzvLK; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-150365-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150365-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h7-20020a170902ac8700b001e05d7b6a38si1540602plr.400.2024.04.18.08.06.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 08:06:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150365-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=p6RTzvLK; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-150365-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150365-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4587D286BB0 for ; Thu, 18 Apr 2024 15:06:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEE7F16C451; Thu, 18 Apr 2024 15:06:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="p6RTzvLK" Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4947E16ABFA; Thu, 18 Apr 2024 15:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713452809; cv=none; b=lF0vhN1uF/y15BC/Q0BAqUs45o9B4xnMT95jy7lU1x6TwMt9nuWDIlrvHF2bhLOq09FKBNULqKpitaX4+zeWq0OhaZdhlAQhEecOq9yPbn/GfjbnkC/DaQSto+CrBXzahFbnnLEAQblV/eQnMEF1cqZMBrljKJTGL4MzFH9yJEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713452809; c=relaxed/simple; bh=oGcY+BupHlocn3xxw4/g576DsNISjK2nsy9HQ+Z9ZzE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Bbq0bPi8qHN5Rokyzg9yawWN1O5mwHyfmcBT1nxIq1Bk+l01L7z+k5VvV4XlsZpoIv3uRMh+xx6lE0v+QdwSA1DVxvkg++8JAFxuehvPU+wMljkWacPBZNV8VEUjirqDZdHJZ0eHF9tunRozgIlkgiw4jI9MRpdJlLImNgSRK9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=p6RTzvLK; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 732C7479B3; Thu, 18 Apr 2024 15:06:35 +0000 (UTC) Date: Thu, 18 Apr 2024 11:06:32 -0400 From: Aren To: Andy Shevchenko Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown , Ondrej Jirman , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: Re: [PATCH 2/4] iio: light: stk3310: Implement vdd supply and power it off during suspend Message-ID: References: <20240414175300.956243-1-aren@peacevolution.org> <20240414175716.958831-1-aren@peacevolution.org> <20240414175716.958831-2-aren@peacevolution.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spamd-Bar: / Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713452796; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding:in-reply-to:references; bh=VCd0NHg7beAhJoKEm/QgbRTnUak2JYtg99vMXKxsa0M=; b=p6RTzvLKnixYbPyShowQRtk19eTobmvfGZGGbbHynE1W98DtGm0Vh5jeKHhResC5i2ODzI QmnANwv6xJ5A5/etHiIwvwPYQc8XhSBcelf2FJGftSilB6sfgJ4ltbihnMVY+IUz+N9HFF voTKduELX/t3TDY4UpOiD+UwsPnkvag= On Mon, Apr 15, 2024 at 05:04:53PM +0300, Andy Shevchenko wrote: > On Sun, Apr 14, 2024 at 8:57 PM Aren Moynihan wrote: > > > > From: Ondrej Jirman > > > > VDD power input can be used to completely power off the chip during > > system suspend. Do so if available. > > ... > > > #include > > #include > > #include > > > +#include > > Move it to be ordered and add a blank line to separate iio/*.h group. > > ... > > > + data->vdd_reg = devm_regulator_get_optional(&client->dev, "vdd"); > > + if (IS_ERR(data->vdd_reg)) { > > + ret = PTR_ERR(data->vdd_reg); > > + if (ret == -ENODEV) > > + data->vdd_reg = NULL; > > > + else > > Redundant 'else' when you follow the pattern "check for error condition first". > > > + return dev_err_probe(&client->dev, ret, > > + "get regulator vdd failed\n"); > > + } > > ... > > > + if (data->vdd_reg) { > > + ret = regulator_enable(data->vdd_reg); > > + if (ret) > > + return dev_err_probe(&client->dev, ret, > > + "regulator vdd enable failed\n"); > > + > > + usleep_range(1000, 2000); > > fsleep() > > > + } > > ... > > > stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY); > > + if (data->vdd_reg) > > + regulator_disable(data->vdd_reg); > > I forgot to check the order of freeing resources, be sure you have no > devm_*() releases happening before this call. If I understand what you're saying, this should be fine. The driver just uses devm to clean up acquired resources after remove is called. Or am I missing something and resources could be freed before calling stk3310_remove? > ... > > > + usleep_range(1000, 2000); > > fsleep() Everything else makes sense, I'll include those in v2 along with a patch to switch stk3310_init to dev_err_probe. Thanks for taking the time to review - Aren