Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp466129rbb; Sat, 24 Feb 2024 08:04:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWlRDxK5SmT5Af8XFjAIDuhxbaL4BTgmqpGOr1Qfs+aYLpqCEF+PLyC/BaaJNXI22kucQESsBrJb/CGr6cRzft+nO67auP3v79NvVYqmw== X-Google-Smtp-Source: AGHT+IF1AJxUAvZEPnRc8LohZm0rvRmqOFQa7ZKE4PGKLGA/gd3xIEaih7PSBBoZLDcDnSaduIk1 X-Received: by 2002:a17:90a:c7c7:b0:29a:6ba0:df43 with SMTP id gf7-20020a17090ac7c700b0029a6ba0df43mr2355504pjb.31.1708790645486; Sat, 24 Feb 2024 08:04:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708790645; cv=pass; d=google.com; s=arc-20160816; b=NQps++SjgO1usJ0pD0ud9yV7q4EsiTvD8525LluzmFKaIH2HklYcmxJohmXlGBvksB VVLhyN2E8qyKXebSCXmQLcOUcCRETmDH0YSa0BoyV+CSU4SI2Z3KLLqKQ+VMI1QfbWbW eBJ/KvDASco/9Bc0NA2nYskJ7Qm7UBWSuZqzhlsi9oHp7bOiJ3NzayaH2Hsy8XvqBc9H BtYZr1vGE6ETm/iZPbYDFCVXquT/nrj9iQ4GhwkW0CK9La5dz1xOGvIoXdc3kRkaUuSq DAVweJazwmu/jOUQ5/Pg603HhNmB5eilYtKz7iy6BlRRBVcJOMXynrwlPOEwcF8GDnHX Kskw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=J6OTG39XoV1/cl8/JaMsaAp6abH+pHSBQJIVPINhxLE=; fh=Ft1uzAQF0qelGsj2O99CQp8o0qaqPKf64QuZTvIa4LQ=; b=gb3zQqTw7PoG7bS1a0huRFU8AZRQEOCxtO2kZCInovsiGTtUAEEX7T9bMjdeyx4cqG SLS7WfiSB9CjTCPmDNgLclqHqxBVf42COCBARi6Uu+nt4k72MxQiWn+cZQ1+rt5r/lyW BYNunrUgncOsCM8nJnKET1CEAI2inQS7C+uruPBP3zsJwaYK2YJW2DODhCyzAXnup4Xo cyn/F9maEm645if+PiqHM/HON+lH0HjzoG09OZcyezn7qUzNEBnTD+CuKGdaUKeBdbhp ZGNTA8WjEq7Ln3WkFDCZQpygMZ+Ghs02XqXWDafcLyH4OICzkVyCkzfaQfrIfH1QUmW6 tZZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=npXLMhhw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79731-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n8-20020a17090a9f0800b00299363fde59si2842895pjp.18.2024.02.24.08.04.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 08:04:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79731-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=@kernel.org header.s=k20201202 header.b=npXLMhhw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79731-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 07AA2283369 for ; Sat, 24 Feb 2024 16:04:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73B4347A7A; Sat, 24 Feb 2024 16:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="npXLMhhw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9A3C14642A; Sat, 24 Feb 2024 16:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708790638; cv=none; b=BwAGyp4j2olwrOKAzadpZm6SmZ95mHtzHzVm7HsNfZ6zQKq2wvWTP2GF9Q2jigOFEsnvj/6o2RoIM6Am7YMRqna3gQ+Pu0mz9YvZC2B4J93RNWUHlg9UfWn8uZdq2e5mKMUYSAKv+9GvFu1htsUGnBTIrmSb7dy1uccKs2RINsU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708790638; c=relaxed/simple; bh=1r4k3QAJpDE4euxXFH0/VkZbwY2Jf+GxPeLp35ybxak=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EAyCgdylLc5SB1U4dNAQLEzcs55UoS3vBacUTs5ZsXYyuQvxR2Bm9NfB0gilezXk0sm78EPsB5WCS1HCoz5Nj46gImVnzkx1QxSUBgZJ1ZHqXsyr0GhK7UNuDGEwq4I5EC5Rud4ae7chZcJv5aST5D1Z7k1+y1KWBeL4oPs2XjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=npXLMhhw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E053C433F1; Sat, 24 Feb 2024 16:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708790638; bh=1r4k3QAJpDE4euxXFH0/VkZbwY2Jf+GxPeLp35ybxak=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=npXLMhhwobQkfE5ybRsfEzJLe23/vw2a6aNks5xKZ+B4aeAgB8ooqdYzVSdIA6D0o zjjiEBxHgHENgT5USYN+NYUTrFvibuwn8ncGRUMZA9CMzYTAtzb8PgOc7v2iyCPIN8 EH/iMD0zB+JMW0w3Ni6Foem9h6Ri27vz/MhFHMlrvy2mPF0pogMs4nLLvNjb9+ALyu dRpbgEOVl244BGG74cC1YI5uDIwDAY86XLLbcFCHeCn2be9699/YfvggEE/W6lNNjz Sl+XpIqofRYjV8IWQ0tHqM3SmBGYcy1uMEqdqaBO+RX8C9VxnioDIeHG7IthLGI0Xd J3sVQwUgN4tMg== Date: Sat, 24 Feb 2024 16:03:46 +0000 From: Jonathan Cameron To: Arturas Moskvinas Cc: Jonathan.Cameron@huawei.com, oskar.andero@gmail.com, lars@metafoo.de, lukas@wunner.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: adc: mcp320x: Simplify device removal logic Message-ID: <20240224160346.61675eba@jic23-huawei> In-Reply-To: <20240219074139.193464-2-arturas.moskvinas@gmail.com> References: <20240219074139.193464-2-arturas.moskvinas@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 19 Feb 2024 09:41:40 +0200 Arturas Moskvinas wrote: > Use devm_* APIs to enable/disable regulator and to register in IIO infrastructure. > > Signed-off-by: Arturas Moskvinas Applied to the togreg branch of iio.git. Initially pushed out as testing to let 0-day have a first go at pointing out what we missed in review. Thanks, Jonathan > > --- > v1 -> v2: > - Use devm_add_action_or_reset instead of devm_regulator_get_enable to automate disabling regulator > - Remove empty mcp320x_remove function > --- > drivers/iio/adc/mcp320x.c | 29 +++++++++-------------------- > 1 file changed, 9 insertions(+), 20 deletions(-) > > diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c > index f3b81798b3c9..da1421bd7b62 100644 > --- a/drivers/iio/adc/mcp320x.c > +++ b/drivers/iio/adc/mcp320x.c > @@ -371,6 +371,11 @@ static const struct mcp320x_chip_info mcp320x_chip_infos[] = { > }, > }; > > +static void mcp320x_regulator_disable(void *reg) > +{ > + regulator_disable(reg); > +} > + > static int mcp320x_probe(struct spi_device *spi) > { > struct iio_dev *indio_dev; > @@ -388,7 +393,6 @@ static int mcp320x_probe(struct spi_device *spi) > indio_dev->name = spi_get_device_id(spi)->name; > indio_dev->modes = INDIO_DIRECT_MODE; > indio_dev->info = &mcp320x_info; > - spi_set_drvdata(spi, indio_dev); > > device_index = spi_get_device_id(spi)->driver_data; > chip_info = &mcp320x_chip_infos[device_index]; > @@ -445,27 +449,13 @@ static int mcp320x_probe(struct spi_device *spi) > if (ret < 0) > return ret; > > - mutex_init(&adc->lock); > - > - ret = iio_device_register(indio_dev); > + ret = devm_add_action_or_reset(&spi->dev, mcp320x_regulator_disable, adc->reg); > if (ret < 0) > - goto reg_disable; > - > - return 0; > - > -reg_disable: > - regulator_disable(adc->reg); > - > - return ret; > -} > + return ret; > > -static void mcp320x_remove(struct spi_device *spi) > -{ > - struct iio_dev *indio_dev = spi_get_drvdata(spi); > - struct mcp320x *adc = iio_priv(indio_dev); > + mutex_init(&adc->lock); > > - iio_device_unregister(indio_dev); > - regulator_disable(adc->reg); > + return devm_iio_device_register(&spi->dev, indio_dev); > } > > static const struct of_device_id mcp320x_dt_ids[] = { > @@ -520,7 +510,6 @@ static struct spi_driver mcp320x_driver = { > .of_match_table = mcp320x_dt_ids, > }, > .probe = mcp320x_probe, > - .remove = mcp320x_remove, > .id_table = mcp320x_id, > }; > module_spi_driver(mcp320x_driver); > > base-commit: 8d3dea210042f54b952b481838c1e7dfc4ec751d