Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp152541rdb; Thu, 8 Feb 2024 01:45:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+y7w8xoOSJvBPcAPdWrYTiuWws9ggKyfjJoISK2PFM4AB/wnJ+niG+mdhdT9EmCQobvom X-Received: by 2002:a17:90b:1d12:b0:296:bf9:dc6b with SMTP id on18-20020a17090b1d1200b002960bf9dc6bmr5001111pjb.27.1707385504277; Thu, 08 Feb 2024 01:45:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707385504; cv=pass; d=google.com; s=arc-20160816; b=GKwdzpIzBEu2lIWLljNpBGv54ScdwIatv21Rzcn15lJJ+DYsaCPpJZr6b8nkc5bhcL ATwgxV7J7yqHI8u78OYf+YzuVmlgyvId09WY6zcej0pMfJz8v6PAkcc/70LoAjEd4qh3 GLdvZvuzM4czKcNEgVT3menFr0GNwurDafIHzPPKN7/YyPWWTIE5H5+bTKAJN26bE/ll IQhrwSKUGa4eLHlwJwKk6hIw9G3ZhG3mPg9TiH3jnj9ekBBQAFJ2W3oMINX2xEnZz07h eZdff00+XNKt8U7ZWLTts8PsvSqPlMrxtNgtJDDaDJ+51PI9m6s0WsLA6B9Njp82+Rf5 bzTg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=X7p3K02PhD++htjnyCnKJ+dGMFyKbZmZX7f+kzBf0cY=; fh=Xu5QK2kabDFLXYPkxW7toLAMPU1ixKwZfZBOqYDrJzo=; b=alY16F34Sf/pZIMTuKb2EPTby66PX+6CgmLT8zcuZk1YT1nNKR9iPSrWXg2dmzasYE bvUm8UWJ7kmXRz6SrSC0irWNVW6NzVrCtU4pch6Vxn86goBw2YNZpkSceT1jP7KRsGf4 FcqE2FeRX60ZmhWDZuptcUSSVoM0VkBzaP7VbyA55ltzLraYibUSlgwU6PWl2vYIskXP +nMRi2HYNqS6d4gixkvurjHcPC5z+dwq2cLAKC5IkGEZ3UwQTQsG0WjMDqFQICSGK+FN QSDr4C9wFMJ9g/UXE4DNug8zmyj4uCrjb9ZgHXp102FgK/AWQKFcx1TUhjgKedbdqXdO V1ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=b1VVWaRQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57767-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXagz5s2Vo+xFMECOpt7k83bpqdf2HBSFuyTgf66LqiRi+o1Pf/USs7ZbfKmxqy6RZadI6Cmhch1C+Y7BLztUtTiY3TbPT/5Kl9Lk7gLw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f21-20020a17090ace1500b002966f6a3feesi965925pju.189.2024.02.08.01.45.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:45:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57767-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=@gmail.com header.s=20230601 header.b=b1VVWaRQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57767-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 0893F282F68 for ; Thu, 8 Feb 2024 09:44:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D15E56BB43; Thu, 8 Feb 2024 09:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b1VVWaRQ" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65A956BB2F; Thu, 8 Feb 2024 09:43:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707385440; cv=none; b=T1WSsmLGM8Tz/NNh5zq8JS2N5lU5trJA3GainDHuh3Ts6pWcSNyH0/NEXetqxsyDO7PTm1RTdojvrMt1Ed+zFd17ZFlLeZ/0FM0TR3sH7ApmHQ/UT88ATP/zKutDeWo7jkF+vdosskvRJRfzdPnVBlK6Vx93fd+180F3JrDjOLo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707385440; c=relaxed/simple; bh=4tBQV8gIEupd+sa2dqqJq1oLCjTr6Cb01Cl4c1CjyP8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=r6OmEf1t2SUdTW74iUGJ8Ezp023+HaTXVPzJZHjgeSCakLckA9ETt52JOyWjYsCIFKX4ES+eegnvcP/CbMbuOh9ZfBWE8/RSjWVVIbXjfZ/R78HvGFgkK7iDZeGK4Jc+ihX8KqQ0PYwMwyWWaoA1yYYf9zXVso5wvGl5rs+a26o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b1VVWaRQ; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-556c3f0d6c5so1914055a12.2; Thu, 08 Feb 2024 01:43:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707385436; x=1707990236; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=X7p3K02PhD++htjnyCnKJ+dGMFyKbZmZX7f+kzBf0cY=; b=b1VVWaRQ6jWv3rC5gs1fcsAqAuYhioNHnyhMjEtieVEK1NljC8MpkSNAwlDMseO5EQ qszNe2AyP5SeWYqdDHaAS31moaAJhTCDdBqeCHVjqvnW94QRiim+icTfAX0VE5niWH1/ KTLQ6/zx0oTqWhA0PtYzq7ByItgKqDYuoMJrj/6VkmrC5GYVVu1N3J9wiCTCk4hyk6Qk x0GF3zCYH115PpG/W6T4j4gYo+sisrMCHS/SmnItD0tn9Y6QkwBcA9R2kdeWN49J0+Wz HxTBOooAJ5fQnKdoOY0d/qYmnzgPMzTAFXJOIc0WjzvyiRmeIRGUdpdVqEAqCCSiEBV2 bApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707385436; x=1707990236; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X7p3K02PhD++htjnyCnKJ+dGMFyKbZmZX7f+kzBf0cY=; b=eOfJX/rhg4jh32E9pCV4IBpiYpWWCcripE7MeF30EluzxwMM2M1/KDg0oRQCWwJ7yq MVb9xphZxmMcLN8uUsphDZZH/Uuo7eFX0FE1eg3syaKp1tpWf88aAvMQZsw2kDX5hHl/ bJSxy1+CvliDy47dkGa22dqShTj/uuARO+Ea5qZjbirOCWemymX8JS9DWp1qksX2I2SK 2VqkkCZ080COohSlSWSvmX1AUDrmaM5/Q1bcNZRRT06f2/04DphuLnazuieEPZwIp3RV jtZIIOOav3REQIU7EVafbIq6fy3UF/5XaaI7ORqv+XpIr/EJ1zsm/SH+RpVxZhitMX5i vtxg== X-Gm-Message-State: AOJu0Yz0JfU9db+3IigZ7l9FjZj0hBPhNpQiVMycaRIHS9O1sH+O9wQC NzLDmBI78QFc9BO2XPiIS9HsWpHMBPzBB5cxa+w0Q7QlTm9AmZQ9 X-Received: by 2002:a17:906:c456:b0:a38:a6a1:3d7f with SMTP id ck22-20020a170906c45600b00a38a6a13d7fmr1796806ejb.4.1707385436404; Thu, 08 Feb 2024 01:43:56 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVMoZI4ou2aBBrPumIZDMSRTKAFeKwfzIrh7D56ujwnwLWECa4iZOeT0bATYWr6fPPAcus0BELZ1fjuT8YlRSs/8ysR7CphdSk6Nq5utClc9c8ASG9IjHFuYXtzJWIt4J0O8qLf31IW2Dk4qTQqFlJlMnBWd1JBlFmGjyCPJO68NxMYwznfmCi6lK3nRxkCATprpqKbIok6y5MzgsnQujUTyuvf Received: from localhost.localdomain (IN-84-15-188-071.bitemobile.lt. [84.15.188.71]) by smtp.gmail.com with ESMTPSA id tj7-20020a170907c24700b00a38a2fa2d4bsm937211ejc.45.2024.02.08.01.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:43:55 -0800 (PST) From: Arturas Moskvinas To: Jonathan.Cameron@huawei.com, oskar.andero@gmail.com, lars@metafoo.de, lukas@wunner.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Arturas Moskvinas Subject: [PATCH] iio: adc: mcp320x: Simplify device removal logic Date: Thu, 8 Feb 2024 11:43:39 +0200 Message-ID: <20240208094339.82633-1-arturas.moskvinas@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use devm_* APIs to enable regulator and to register in IIO infrastructure. Signed-off-by: Arturas Moskvinas --- drivers/iio/adc/mcp320x.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index f3b81798b3c9..4685eed35271 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -388,7 +388,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]; @@ -441,31 +440,17 @@ static int mcp320x_probe(struct spi_device *spi) if (IS_ERR(adc->reg)) return PTR_ERR(adc->reg); - ret = regulator_enable(adc->reg); + ret = devm_regulator_get_enable(&spi->dev, "vref"); if (ret < 0) return ret; mutex_init(&adc->lock); - ret = iio_device_register(indio_dev); - if (ret < 0) - goto reg_disable; - - return 0; - -reg_disable: - regulator_disable(adc->reg); - - return ret; + return devm_iio_device_register(&spi->dev, indio_dev); } static void mcp320x_remove(struct spi_device *spi) { - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct mcp320x *adc = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - regulator_disable(adc->reg); } static const struct of_device_id mcp320x_dt_ids[] = { base-commit: 047371968ffc470769f541d6933e262dc7085456 -- 2.43.0