From nobody Thu Apr 2 09:18:47 2026 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (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 D85D130FC21 for ; Sun, 29 Mar 2026 22:47:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824435; cv=none; b=DFGNeVjgvlFYj2+2XrZeJHcurg3Cx/0wWCmvfqTDeoKhgxyLtJHWUHLhbFfJ/3iEMBn7ZNjknO5PEElLZ+SXwdP94MafYQ8dxjj6fE2y97iohJR2ZAWuB+aavwxUoiQxZBfNVB4tjwpmUccbOUnWJyV3yAHn7h3fkOYzhYh7rU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824435; c=relaxed/simple; bh=xIe8W+1jIXINgmxwa9p/U0LcjRjeCYfnSgMBa9JCf9s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oJKR5VgKrDQ5XnzQgn0+PGQNQUAgwfLTSuDAvxRuDZ/CVKLqaxu6EGvtKw80yGT0zGJHuf2AH0m2SBad8Zsbk/xVfnylZAlX1MRcs6RerRznfRWfeeP1SP7TeTi+tqR1D7gWyydMFU8d8NQ6BWAVVktCfAcY7SxNmBC6VTdsHy4= 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=pgjaB1Ku; arc=none smtp.client-ip=74.125.82.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pgjaB1Ku" Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-2c56aa62931so467035eec.0 for ; Sun, 29 Mar 2026 15:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774824433; x=1775429233; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+vjudEEXqzxPRbybQTwtbPdouiJ0uhGQsqsaFK6mvh4=; b=pgjaB1KuyntZIlWVUj4gkhYhItg5ID7LnV7IN+zlMzTuT5k7K0X2b64ipOwahkRfQu Uys5MpawM0bA+SEdkOgt34sDbT7X4FUoczU7DiqN0kwPBZwV78HD7JqZcVEcUmYYkbw9 K9Ngu5jNsgdm7IDMN9XoflcC74cFiQ7TWvqaYLwS9+N/SazV/yJkVARRhs9ig9f+NwJ1 bhqpQJz09ikLGygGo7MxUQNryGSWbHC7nDNhK1v95htuvRPK7EJOv/oEI3sH+u1Tfrhw XFtd51vQUtpdiSb8/hxdaBlzlIde8P/W/uC5klvzcNcLhMpAwcit6I8iq9cSvTDyALoF Kveg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774824433; x=1775429233; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+vjudEEXqzxPRbybQTwtbPdouiJ0uhGQsqsaFK6mvh4=; b=ESiHZyiDkM33QpOXgb4lul5dWf6x0YnmySK5OJX64a3lvVqTvBsG83e4oW+SN+0hY4 EqXUM9FHqOHLLwlxwiSeZ8ux2WFAG4tJ2+RD4RRt5DXXI6emq/lFSm4z+sUqvJg+kkCz Jg8qqviFE7OzYCOZrkkjjxDxA+tcV8RN/iS/+b39ACXkK8nU6cUdZqN41pXOhxrz7bDe 4K3Ev1AJw7nLkDO8brCPThbELJCV8milhFz5Mqa48xYRc9xCw9Q/xEvdG9uUoZK696wT hiHuABskygvpHk7N/N1iNjxXukuHi9kg95QNJARwec4ngmHPKgNmiwDKwDqzaLIs0Vn4 J1Bg== X-Forwarded-Encrypted: i=1; AJvYcCX9rn7zzob2el/fDxmfDN+3ttIdMa44AbjxySvuwuBwOfA354IZ0trgvfN68uVdJOdLSSqiXBanMyrw5JA=@vger.kernel.org X-Gm-Message-State: AOJu0YzqR9GtPc+CZb9m7TaFasCtCKXYaSA5fD7suE+ytQrOEnwU9Fvm h7tecjV8LNTVcGdhN8ndtFC/8AzYoBWfdra2eBpaOt+S9fFoC1WFlSAh X-Gm-Gg: ATEYQzxR75SHOYw++h1aWdrDfUYeF8uKA3UJ08fq19JlnSskToUpyf8RT+Gfw9UdTbf +wcVBbfE1pfGTLMyyLg337977rWYPxS8X5AJTV6lo7EZuUYsTGWifirv+xEagxO33SK/MINVod+ Gp9jBjXYYudreo+0wqxS7NxfrR2RkGEgAJqsplLqQ13cC47CK8QN6lIeF2RWISQ4dpns8QkqaKd j6aEeXloKstsl3ftFfxLzdw0UTlVscTWgGEibGUxZtHDa5lJkB9VJkvFxa0tobKcKxzBPN+2G74 JvhD+kuXfWL8y/WeXUWQF7cwFI+7lfhBZiAjRftrLL5LiNn73FQD+7gKHuO5pvXDgd4XxtBldfZ zRK9XVQPdiYEWJQJMu8roB0Zyfx8v8i7qNMDLw5ZdjkOtaF5Gn29/6bbZ/rsk0bg3YOG0hv6wWM alSbT6hi7pGEVvIEvdQDdYRX+e1mS8/OdZOBvET7mkvNeZD2Vp+ePfvQIJyhtrR46lhSDitnhjo nlRtuylhIF8qm4= X-Received: by 2002:a05:7301:3d19:b0:2ba:7875:10c9 with SMTP id 5a478bee46e88-2c185e4da2dmr5231209eec.26.1774824433027; Sun, 29 Mar 2026 15:47:13 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:7265:773a:8e51:c62f]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c7971d97sm5840295eec.30.2026.03.29.15.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 15:47:12 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 29 Mar 2026 15:47:06 -0700 Subject: [PATCH v4 1/4] iio: adc: ti-ads7950: switch to using guard() notation 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-Transfer-Encoding: quoted-printable Message-Id: <20260329-ti-ads7950-facelift-v4-1-c568c508c49a@gmail.com> References: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> In-Reply-To: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> To: Jonathan Cameron , David Lechner Cc: =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Jonathan Cameron X-Mailer: b4 0.15-dev-a6826 guard() notation allows early returns when encountering errors, making control flow more obvious. Use it. Reviewed-by: David Lechner Signed-off-by: Dmitry Torokhov Reviewed-by: Bartosz Golaszewski --- drivers/iio/adc/ti-ads7950.c | 83 +++++++++++++++++-----------------------= ---- 1 file changed, 31 insertions(+), 52 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index 028acd42741f..6e9ea9cc33bf 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -299,18 +299,19 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq= , void *p) struct ti_ads7950_state *st =3D iio_priv(indio_dev); int ret; =20 - mutex_lock(&st->slock); - ret =3D spi_sync(st->spi, &st->ring_msg); - if (ret < 0) - goto out; - - iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2], - sizeof(*st->rx_buf) * - TI_ADS7950_MAX_CHAN, - iio_get_time_ns(indio_dev)); - -out: - mutex_unlock(&st->slock); + do { + guard(mutex)(&st->slock); + + ret =3D spi_sync(st->spi, &st->ring_msg); + if (ret) + break; + + iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2], + sizeof(*st->rx_buf) * + TI_ADS7950_MAX_CHAN, + iio_get_time_ns(indio_dev)); + } while (0); + iio_trigger_notify_done(indio_dev->trig); =20 return IRQ_HANDLED; @@ -321,20 +322,16 @@ static int ti_ads7950_scan_direct(struct iio_dev *ind= io_dev, unsigned int ch) struct ti_ads7950_state *st =3D iio_priv(indio_dev); int ret, cmd; =20 - mutex_lock(&st->slock); + guard(mutex)(&st->slock); + cmd =3D TI_ADS7950_MAN_CMD(TI_ADS7950_CR_CHAN(ch)); st->single_tx =3D cmd; =20 ret =3D spi_sync(st->spi, &st->scan_single_msg); if (ret) - goto out; - - ret =3D st->single_rx; - -out: - mutex_unlock(&st->slock); + return ret; =20 - return ret; + return st->single_rx; } =20 static int ti_ads7950_get_range(struct ti_ads7950_state *st) @@ -400,9 +397,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsig= ned int offset, int value) { struct ti_ads7950_state *st =3D gpiochip_get_data(chip); - int ret; =20 - mutex_lock(&st->slock); + guard(mutex)(&st->slock); =20 if (value) st->cmd_settings_bitmask |=3D BIT(offset); @@ -410,11 +406,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsi= gned int offset, st->cmd_settings_bitmask &=3D ~BIT(offset); =20 st->single_tx =3D TI_ADS7950_MAN_CMD_SETTINGS(st); - ret =3D spi_sync(st->spi, &st->scan_single_msg); - - mutex_unlock(&st->slock); =20 - return ret; + return spi_sync(st->spi, &st->scan_single_msg); } =20 static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) @@ -423,13 +416,12 @@ static int ti_ads7950_get(struct gpio_chip *chip, uns= igned int offset) bool state; int ret; =20 - mutex_lock(&st->slock); + guard(mutex)(&st->slock); =20 /* If set as output, return the output */ if (st->gpio_cmd_settings_bitmask & BIT(offset)) { state =3D st->cmd_settings_bitmask & BIT(offset); - ret =3D 0; - goto out; + return state; } =20 /* GPIO data bit sets SDO bits 12-15 to GPIO input */ @@ -437,7 +429,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsig= ned int offset) st->single_tx =3D TI_ADS7950_MAN_CMD_SETTINGS(st); ret =3D spi_sync(st->spi, &st->scan_single_msg); if (ret) - goto out; + return ret; =20 state =3D (st->single_rx >> 12) & BIT(offset); =20 @@ -446,12 +438,9 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsi= gned int offset) st->single_tx =3D TI_ADS7950_MAN_CMD_SETTINGS(st); ret =3D spi_sync(st->spi, &st->scan_single_msg); if (ret) - goto out; - -out: - mutex_unlock(&st->slock); + return ret; =20 - return ret ?: state; + return state; } =20 static int ti_ads7950_get_direction(struct gpio_chip *chip, @@ -467,9 +456,8 @@ static int _ti_ads7950_set_direction(struct gpio_chip *= chip, int offset, int input) { struct ti_ads7950_state *st =3D gpiochip_get_data(chip); - int ret =3D 0; =20 - mutex_lock(&st->slock); + guard(mutex)(&st->slock); =20 /* Only change direction if needed */ if (input && (st->gpio_cmd_settings_bitmask & BIT(offset))) @@ -477,15 +465,11 @@ static int _ti_ads7950_set_direction(struct gpio_chip= *chip, int offset, else if (!input && !(st->gpio_cmd_settings_bitmask & BIT(offset))) st->gpio_cmd_settings_bitmask |=3D BIT(offset); else - goto out; + return 0; =20 st->single_tx =3D TI_ADS7950_GPIO_CMD_SETTINGS(st); - ret =3D spi_sync(st->spi, &st->scan_single_msg); - -out: - mutex_unlock(&st->slock); =20 - return ret; + return spi_sync(st->spi, &st->scan_single_msg); } =20 static int ti_ads7950_direction_input(struct gpio_chip *chip, @@ -508,9 +492,9 @@ static int ti_ads7950_direction_output(struct gpio_chip= *chip, =20 static int ti_ads7950_init_hw(struct ti_ads7950_state *st) { - int ret =3D 0; + int ret; =20 - mutex_lock(&st->slock); + guard(mutex)(&st->slock); =20 /* Settings for Manual/Auto1/Auto2 commands */ /* Default to 5v ref */ @@ -518,17 +502,12 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state= *st) st->single_tx =3D TI_ADS7950_MAN_CMD_SETTINGS(st); ret =3D spi_sync(st->spi, &st->scan_single_msg); if (ret) - goto out; + return ret; =20 /* Settings for GPIO command */ st->gpio_cmd_settings_bitmask =3D 0x0; st->single_tx =3D TI_ADS7950_GPIO_CMD_SETTINGS(st); - ret =3D spi_sync(st->spi, &st->scan_single_msg); - -out: - mutex_unlock(&st->slock); - - return ret; + return spi_sync(st->spi, &st->scan_single_msg); } =20 static int ti_ads7950_probe(struct spi_device *spi) --=20 2.53.0.1018.g2bb0e51243-goog From nobody Thu Apr 2 09:18:47 2026 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (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 5D60536CE16 for ; Sun, 29 Mar 2026 22:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824436; cv=none; b=qlTJyS9EXUyZpxmGsUadjop0fJM7SJ9ZZRo+EWSm9YblShwwBlnSNG0P63hli3nmuRMf/IkVxRRrCLrtSYUuYkKy2HyLAN5Gkb5hlHdJDC5sA7SesBTMal3u7NyZ2nfgIm3icCNHSBj6n93HeNufI0r3NlsFUELeUyhxfGMSrxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824436; c=relaxed/simple; bh=fuZck8myQoX8k0WCv45I/UW0qdwIBbPx5XxBl9G6Pa8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gZInOYSh4nhizqr5GY+CKfd9R+1Pkhhvboq6EltEHnhAQgRwuVxFmzRuPEr0eZW82E6brsKTXNbx16R1WnwbXFQB4N5HKDePznmBvCfgkAYmvGrSC6kjOFQODASfOSgGivrWIuUdc4qi47sfTl9CeDrTKi1LbI7RkVaI0PZhN88= 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=c8Ez01XZ; arc=none smtp.client-ip=74.125.82.179 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c8Ez01XZ" Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-2ba9c484e5eso3327828eec.1 for ; Sun, 29 Mar 2026 15:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774824435; x=1775429235; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TKnXDyPHxP+Y+5jS7Wois35p2rZi45QRMmQZExuHS7U=; b=c8Ez01XZ20lPhRSjFztQaSiOooyWOLC/zUH1IxSOM4gnDe35As2xPkWAdKr6RYqpRA 6nMA5dWfws/sfvul0aeMfrqBhGirC/YsgoPA2w5nv7dqWe0RKUgg88sIjE/oxasMKqpq TFWu0FVaziDi37+Kd33tnJh2q7rtIzX2A/9OYQxUFRPF3AOppVSf/lJvoDEl5yMw64v4 7yPIEjv/Z0sLa5OdivySGGnhIvYIhCki6PmK8xG5vLwsNJ5JroE5A00l5Os2QNbx5n3Z 65Irthiq31dE+BWY2YEXVugOLsnp7idnvMFDewBVsvTNA3VYTqUyK/k4YeLCmwYnHzoj htqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774824435; x=1775429235; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=TKnXDyPHxP+Y+5jS7Wois35p2rZi45QRMmQZExuHS7U=; b=NBFDztcSlYLXVXCwOjfZ2JRExxesFe8X5C4XzmQyVxJqvLZ/GPrDWJ2ZL4VO2yr4Hk atPPIe+EX8/LQqtEJ4xx/oDQd5KhxS6COVcPc41HopXwb7MoZ6/utR6J2I3d/qJcUEva Ti18ib8TB8oq+1xhcw170Y/IzM5hJOglrASfy3vFWy6/VWc5sxC/C9F/TwXl5RB9HZ6c /bjMb0SNkTguuGPIomJEoeKRbIQN5hXdlW/36ADkfJhdJZ/+XrUIo3tJUQSgJtPkA+2q Ve2KgXchXCBzu8fpcjKfBpUDpvLhZCawEKTV+QzC0vsH+jZ8VcG7qDOSP1IJ+t6G4KD6 xBbw== X-Forwarded-Encrypted: i=1; AJvYcCXDY5WcCHJU0a6loyObBJiu44ZqrF0oZyQlyUU9aXCL6pAVwzqP1uwjTXivG6mjuuEMYV/31DbZrshTKAU=@vger.kernel.org X-Gm-Message-State: AOJu0YxBkZrCJvaHQ9ic/JalsW1tyjaKR38PrnuX3AsyJoBgln8+j5Zz FKvHOi1TS5y6q5HKeQ/pc8M1wOv+V+T192kEUBB4iFTDTLhTEnlM5yrY X-Gm-Gg: ATEYQzzjahT5EWAd/WZxUefyDTDzbftqIP4GVTcEbsRPxfgJTB4Nu9XZtvUtM6caq91 Me73H7KQY3TQo4dZ9PdxGwFHEB55w27ARCgNJOinJcReFqx8bnXKCclEgbvddtTHdmDZJTcYGwP /nIrSW8b7wPm8sXr0f7WUM6CBBN8gFDpP0DC00caigd2nqU9r+vDOvCND0NSymvyr0uGCdDx8Gv 98qd6UGJ4xcZySUVAbAfbeEAL5pFdhEuebX4UMOnOHmY7Bi8PI/MYHFODQ7XzqJk06Hzpk0sJ8E DDfWELqQI4iS6haCHp51+zXY40BTPTZpoY0W7Q+lDwyEMVihNSEfaRuQ+TdzYL43EbL+l9dMT7v aNaoV3GEwlUyrl2P23SAU5RWNoscXB+gLDSFXOHU2Vmhu2F8qLvZLq/AoN+6tLQpVL/3x1eLGjE iTnV2Gp4EC7r5doL0iRHujRBbcMK3J//lNphzS7w2hFzaN5fMOor2OPSkwc7NNp9c48rffxoKmK KBI3JEsB91+sWE= X-Received: by 2002:a05:7301:6781:b0:2c0:c9ba:1192 with SMTP id 5a478bee46e88-2c185e069eamr5267348eec.18.1774824434599; Sun, 29 Mar 2026 15:47:14 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:7265:773a:8e51:c62f]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c7971d97sm5840295eec.30.2026.03.29.15.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 15:47:13 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 29 Mar 2026 15:47:07 -0700 Subject: [PATCH v4 2/4] iio: adc: ti-ads7950: simplify check for spi_setup() failures 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-Transfer-Encoding: quoted-printable Message-Id: <20260329-ti-ads7950-facelift-v4-2-c568c508c49a@gmail.com> References: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> In-Reply-To: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> To: Jonathan Cameron , David Lechner Cc: =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Jonathan Cameron X-Mailer: b4 0.15-dev-a6826 spi_setup() specifies that it returns 0 on success or negative error on failure. Therefore we can simply check for the return code being 0 or not. Reviewed-by: David Lechner Signed-off-by: Dmitry Torokhov Reviewed-by: Bartosz Golaszewski --- drivers/iio/adc/ti-ads7950.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index 6e9ea9cc33bf..c31c706c92a9 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -520,7 +520,7 @@ static int ti_ads7950_probe(struct spi_device *spi) spi->bits_per_word =3D 16; spi->mode |=3D SPI_CS_WORD; ret =3D spi_setup(spi); - if (ret < 0) { + if (ret) { dev_err(&spi->dev, "Error in spi setup\n"); return ret; } --=20 2.53.0.1018.g2bb0e51243-goog From nobody Thu Apr 2 09:18:47 2026 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 F214238228A for ; Sun, 29 Mar 2026 22:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824438; cv=none; b=B506qgDffzsSJ2hOP2UMyUoZBaeqLGQWO0ZGt95ewo2NDI9u1N22iDoqDmJ7BdqUCDWB72cwNn/8Fw6filBqA3SfdfjzZLOKoaxRpzInZeRMbsphfiBxFq3gcgcqRdsodc2UA+jjDBKKGVo3jRxow5BuokW1TKuQsoLf44j99Go= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824438; c=relaxed/simple; bh=qKG/Dk+YwmU5YXsCQA9AtevlFGr051QfNe264bDQuZg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M8z5HJ83jL9kKr71HLFJu94Qb/282X4VGvKjMT13dtkvw+I9wCn5/UC6FJ1aMGkKJstO4QSltuaXo5es/hdWB2l906sAkb2SuL6o5HjmroTRsxRxg7fCKsC4md+pvAHP78P1QLvB4QitbQa6EmPyovZ/L/6rN5HaKTl361j/aCc= 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=opsU/Xj2; arc=none smtp.client-ip=74.125.82.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="opsU/Xj2" Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-2c66eafc1easo349248eec.1 for ; Sun, 29 Mar 2026 15:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774824436; x=1775429236; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xjnte4r6ScLiwT0fTQiZsZDg6SDDULG2OwlHg75Fmwg=; b=opsU/Xj2tS3Jtx/E3effpQYBTOCbK/HGgoMi2CjbHvYhmU12HfqKIb1076Xs7nvqmV 25U4n1hjBReW14UkhTupn+c66972mwi0iQZD4OmQD4THPqwcvwUwEOte+psWpM/+V/8y x2vU/6aVW/23PReohDfzD4d2EwNz6zAgzcTFt4rl5ZvE48WfSp5mU5bdt3XwHG9qHUtw adc6dlnOG2GInLtiNf2YSFVlS2IQ906qdyRLWac/IDYyNOVl1RKjHs6o9Ku/SQ51nxVO h4VUIOkD0b6O2V0NGUlBjIuInlqqJ6NsZVZuxWRVya9kyGkBohZer4CobqYvS9bGcFNE /RRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774824436; x=1775429236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=xjnte4r6ScLiwT0fTQiZsZDg6SDDULG2OwlHg75Fmwg=; b=MRrIEm0EouDBrLOXZliQ9zZH4u62e+ZJEtUtBaLOxA90Z1RE8CrAWhQfymZDc18Zov Jeg1sVoPaAyPSCtfwyFI2D3MhNphLr+WnKXUAndNaKwKaUoTRxY9q2kALGjUyJAhluet HDA3I+NLN0wCxp4Xy0wbmVznNCfKclm7e4dk0gdX3kV7mt17GUGLkI6FVSwQwEeG1vj2 l9HTKVfRSKHyO1Up3X1XrEZtpY8E5bgMws1ZiHPy2ghTOacMejieIZ2/7R91ZoXKEL6V xA1xRQC6ccyw/QBjvg9k+4M2r5ICF/LXW0QRlMnFFM47IpRvp4lYrmcbIL9oRuU7KvEG t73g== X-Forwarded-Encrypted: i=1; AJvYcCWirWUC5KNe0BZSj3PUWyvAK1legcNLZWdI33nVR9+0MK9AbOWgDh8EmpLkBmu0cniXRLFxwGdTeRxolGU=@vger.kernel.org X-Gm-Message-State: AOJu0YyNzMGYjH3yMsRBbVPaAREglyEUkhChBvpNvuOEOJMaXwUXAxu5 aZAYikkgVvjhsQa91XLgsFWk9kjHzuLquf+zxGFkBRpfx1plmrhbpiEb X-Gm-Gg: ATEYQzz7IyPp5I9geZ1T2vtkInZA6c3I81s7bu00X5ge7VOZGZ1p0vUGy2Tv/+NlUEK +RU4gnodvGRY+tytNaWpoAe7dG5rcM+OfhoeMmB6b1kQmlTnUWrJ7oQQMl8oAHSymMdVIxqzP+m +b0gWTg3+92hp7JwvGz/Rjtq11ZbJMV0ULIENEzvanEV0MmDzQV1ZWOQhQk5IL8XsO4khGRedHm QOeBhd06VGQVSpDySCm9ukn4c1IjLYL6jwNTRL5u5rpGAKEZH01j34JS8ORd7pRSViSPror5kmp KEQIPjkf7c0U1MxmxGwynJkw+bqNeGAJP050+zc0IAkPxkPqknjWZRbHrwefQ4ivz324asPb0zv MYWZ46KfdF5ZURNhLC48/NYgDs5fotuxggJLIrCJTzMqgJ9qcSTfu+oUdCHhEqJxiVMTSb3zQvP EihDhufg2eSnXeMU5lgfn5m4dUPW6J0fmRgzfseRE0tIRnKRV8disb6kRemeaw7ILlQGalX2Gg6 lHtcjqye5e8nKf/iH4GoAmYXg== X-Received: by 2002:a05:7300:1489:b0:2c5:220c:5673 with SMTP id 5a478bee46e88-2c5220c616bmr2019888eec.5.1774824436043; Sun, 29 Mar 2026 15:47:16 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:7265:773a:8e51:c62f]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c7971d97sm5840295eec.30.2026.03.29.15.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 15:47:15 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 29 Mar 2026 15:47:08 -0700 Subject: [PATCH v4 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage() 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-Transfer-Encoding: quoted-printable Message-Id: <20260329-ti-ads7950-facelift-v4-3-c568c508c49a@gmail.com> References: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> In-Reply-To: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> To: Jonathan Cameron , David Lechner Cc: =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Jonathan Cameron X-Mailer: b4 0.15-dev-a6826 The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time. Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code. Suggested-by: David Lechner Signed-off-by: Dmitry Torokhov Reviewed-by: Bartosz Golaszewski --- drivers/iio/adc/ti-ads7950.c | 48 ++++++++++++----------------------------= ---- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index c31c706c92a9..0b98c8e7385d 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -334,19 +334,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indi= o_dev, unsigned int ch) return st->single_rx; } =20 -static int ti_ads7950_get_range(struct ti_ads7950_state *st) +static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st) { - int vref; - - if (st->vref_mv) { - vref =3D st->vref_mv; - } else { - vref =3D regulator_get_voltage(st->reg); - if (vref < 0) - return vref; - - vref /=3D 1000; - } + unsigned int vref =3D st->vref_mv; =20 if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V) vref *=3D 2; @@ -375,11 +365,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_d= ev, =20 return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - ret =3D ti_ads7950_get_range(st); - if (ret < 0) - return ret; - - *val =3D ret; + *val =3D ti_ads7950_get_range(st); *val2 =3D (1 << chan->scan_type.realbits) - 1; =20 return IIO_VAL_FRACTIONAL; @@ -573,30 +559,25 @@ static int ti_ads7950_probe(struct spi_device *spi) spi_message_init_with_transfers(&st->scan_single_msg, st->scan_single_xfer, 3); =20 - /* Use hard coded value for reference voltage in ACPI case */ - if (ACPI_COMPANION(&spi->dev)) - st->vref_mv =3D TI_ADS7950_VA_MV_ACPI_DEFAULT; - mutex_init(&st->slock); =20 - st->reg =3D devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) { - ret =3D dev_err_probe(&spi->dev, PTR_ERR(st->reg), - "Failed to get regulator \"vref\"\n"); - goto error_destroy_mutex; - } + /* Use hard coded value for reference voltage in ACPI case */ + if (ACPI_COMPANION(&spi->dev)) { + st->vref_mv =3D TI_ADS7950_VA_MV_ACPI_DEFAULT; + } else { + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, "vref"); + if (ret < 0) + return dev_err_probe(&spi->dev, ret, + "Failed to get regulator \"vref\"\n"); =20 - ret =3D regulator_enable(st->reg); - if (ret) { - dev_err(&spi->dev, "Failed to enable regulator \"vref\"\n"); - goto error_destroy_mutex; + st->vref_mv =3D ret / 1000; } =20 ret =3D iio_triggered_buffer_setup(indio_dev, NULL, &ti_ads7950_trigger_handler, NULL); if (ret) { dev_err(&spi->dev, "Failed to setup triggered buffer\n"); - goto error_disable_reg; + goto error_destroy_mutex; } =20 ret =3D ti_ads7950_init_hw(st); @@ -636,8 +617,6 @@ static int ti_ads7950_probe(struct spi_device *spi) iio_device_unregister(indio_dev); error_cleanup_ring: iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - regulator_disable(st->reg); error_destroy_mutex: mutex_destroy(&st->slock); =20 @@ -652,7 +631,6 @@ static void ti_ads7950_remove(struct spi_device *spi) gpiochip_remove(&st->chip); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(st->reg); mutex_destroy(&st->slock); } =20 --=20 2.53.0.1018.g2bb0e51243-goog From nobody Thu Apr 2 09:18:47 2026 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (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 39DF437D114 for ; Sun, 29 Mar 2026 22:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824442; cv=none; b=VFzqdwUOXFdKB97t3+xsqs26tksRafAH4PflsE4CkOxhh55Zh/NQh8MCOcpwEU5ikhz8FgKnzlmeahzZkR4QeNHhEGk5SYwIxe3yrNyPkI2oIcmU88IKDT9XBEURtPYqOZ8xm35ndtuxVnKbT9+bcmxImDnMWYbnrfBH6xC8jUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824442; c=relaxed/simple; bh=vwpbqrdZWg2IZwLAqAvEpGuR5LpR+6ltHKabiSi+AJE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r6NDTF6dKdBI59hQwUbcALVltJX8pSQlCxMAracPQ2pGnJw4C5j4nBB+szo0BmqOrF4Bh39h/SXRRKfEBV5chedw2Kx71aVBUJO/K6KERZ699i/jrSGoNcaNP78biwv1UDTZ8ZS6AG1QbgF+DZmj6dgWIk1ZF1KKo77FszjpjbY= 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=cfewBTZe; arc=none smtp.client-ip=74.125.82.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cfewBTZe" Received: by mail-dy1-f169.google.com with SMTP id 5a478bee46e88-2c54c68db4dso1391310eec.0 for ; Sun, 29 Mar 2026 15:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774824437; x=1775429237; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3+M5YsOq3vk2JVYTGrQ8f5AMbXIKgHmkOF2OORVkBAw=; b=cfewBTZeel9IF/6M+EKcatDd1aajhVSb5EHkuvat9le936bVm77lu0t9j3HCktW8ah o3iflk+1eZPzNsmt/xIifQtLyks/9pu5M5YWo5KvOHaqAloB2H2iPitpNCnxCHwPsm8W iMtQDs9oIkcXQmND30JFKYDa77nrxeXOTHayQy5syFNohe9nCSGZZlcIhTLKUgMo7Fjm KAT7lCF9pf9OrJEIichFEJ0OHuZXhjuNu9tqiG9hKP1YWDxTcjpkwgk2FuCxJL0pdyBf z98LwKgu5Jy4z3IvsVDbt85xhpFgl9ymFn8W7E0ooRb0FCPfhQGMNB5EzCTmqvDfjMAf 9ESw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774824437; x=1775429237; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=3+M5YsOq3vk2JVYTGrQ8f5AMbXIKgHmkOF2OORVkBAw=; b=r1CbnPgx6PR4huQv7Qjpi1UBMxTezLfyFCz67vIsim+/tF66+AgV4nsCk6r5BDaSR5 FK5CnMiKnmfja+ChvkFBGJEwvbtj0B5UA5ZRjmRnGjBtrTs1ZHNYNRZlqSpWdLrVZX6o A2sJpQz+V6EAjDnp6CL0XVCexoZy7tKpv31ycCK5kJkxRcwa6Op/5RNRnH4A/EiLFOFc 8y/LgT2ggO0gmY0y0gPzbiC1M4/Y+WVDGgqsGYQaE640Lp4dh2U9rGAbRJjpkEcj0Qb4 xQVXhGL1PMPUVGYFGb3Q42zsB06DDYqT0XsWN0VxowWRdqHmDJ5QBTUP/swQ1DymYPWX mNVA== X-Forwarded-Encrypted: i=1; AJvYcCUF0qFG89kpFi7EhVfWP0YBz+NsSvtn4iQthmkNG1irG42Mx1rO/p0PNxT/qY9A/uoTffsvA+V7UmcyfQA=@vger.kernel.org X-Gm-Message-State: AOJu0Yzk+tSnHKRTFztt/OHNngeYMFjn8H6WWY+45RBfz2mMlVtJyTyK iU/1ULKO1+UOVYGujS7UlutBOKnVolKadp+bp4Bm6r8uDj2tNulfo0rf X-Gm-Gg: ATEYQzwhxNFtb2nHawXIBI58ZEIFp+PQ2tGgdP4qXNGev9+LW87pIU1oe1NnKQPLRUc qVIbtzBh9ZvEP0u3Z1EpcvBqwjGGGJIuXU0dwcQJxT463SDEMy5F2SS0LBm8i6WLV2oFvU2bPYC PxbnHFIFD9XU44xirX8V5odRc4YBLOScE7U49oMJs+urbAlbr36YK/dB1qyZRJk/gxtvvsvn6Zo nY4NWqCHY2ExypmKTK6p/SVLj+Osmiw4P0u3Bv29Twan43B8H6B86KtEpAHAsiD+4dvPH9UcdK0 O7c9E5p2eRgKmi7Aa4lwYV1pImoQQGA8nZSlhKASIblXW0+g0kNvYEgiodLp7meshF/B3evRQMy LNgY9ZS2BZbFCEeV3syiZCGTqTLO1W/2sl0tNFbQ5QXzC27tMFUDFFn6GUjKXou643Pgw6GjAMN 8A1HQrdV9xOAHHO8Zv2cVEAcxiU/YwaddScQwX9LAqVb+ZXIMQFtKDLn2LP1odthWAyA7WkrAgC vgdQYB04d4+XMA= X-Received: by 2002:a05:693c:3282:b0:2c0:c96a:a4db with SMTP id 5a478bee46e88-2c185d8e84emr5487052eec.4.1774824437396; Sun, 29 Mar 2026 15:47:17 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:7265:773a:8e51:c62f]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c7971d97sm5840295eec.30.2026.03.29.15.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 15:47:16 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 29 Mar 2026 15:47:09 -0700 Subject: [PATCH v4 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources 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-Transfer-Encoding: quoted-printable Message-Id: <20260329-ti-ads7950-facelift-v4-4-c568c508c49a@gmail.com> References: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> In-Reply-To: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> To: Jonathan Cameron , David Lechner Cc: =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Jonathan Cameron X-Mailer: b4 0.15-dev-a6826 All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove(). Reviewed-by: David Lechner Signed-off-by: Dmitry Torokhov --- drivers/iio/adc/ti-ads7950.c | 66 +++++++++++++---------------------------= ---- 1 file changed, 19 insertions(+), 47 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index 0b98c8e7385d..234249ab76d8 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -506,10 +506,8 @@ static int ti_ads7950_probe(struct spi_device *spi) spi->bits_per_word =3D 16; spi->mode |=3D SPI_CS_WORD; ret =3D spi_setup(spi); - if (ret) { - dev_err(&spi->dev, "Error in spi setup\n"); - return ret; - } + if (ret) + return dev_err_probe(&spi->dev, ret, "Error in spi setup\n"); =20 indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) @@ -517,8 +515,6 @@ static int ti_ads7950_probe(struct spi_device *spi) =20 st =3D iio_priv(indio_dev); =20 - spi_set_drvdata(spi, indio_dev); - st->spi =3D spi; =20 info =3D spi_get_device_match_data(spi); @@ -573,24 +569,22 @@ static int ti_ads7950_probe(struct spi_device *spi) st->vref_mv =3D ret / 1000; } =20 - ret =3D iio_triggered_buffer_setup(indio_dev, NULL, - &ti_ads7950_trigger_handler, NULL); - if (ret) { - dev_err(&spi->dev, "Failed to setup triggered buffer\n"); - goto error_destroy_mutex; - } + ret =3D devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + &ti_ads7950_trigger_handler, + NULL); + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to setup triggered buffer\n"); =20 ret =3D ti_ads7950_init_hw(st); - if (ret) { - dev_err(&spi->dev, "Failed to init adc chip\n"); - goto error_cleanup_ring; - } + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to init adc chip\n"); =20 - ret =3D iio_device_register(indio_dev); - if (ret) { - dev_err(&spi->dev, "Failed to register iio device\n"); - goto error_cleanup_ring; - } + ret =3D devm_iio_device_register(&spi->dev, indio_dev); + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to register iio device\n"); =20 /* Add GPIO chip */ st->chip.label =3D dev_name(&st->spi->dev); @@ -605,33 +599,12 @@ static int ti_ads7950_probe(struct spi_device *spi) st->chip.get =3D ti_ads7950_get; st->chip.set =3D ti_ads7950_set; =20 - ret =3D gpiochip_add_data(&st->chip, st); - if (ret) { - dev_err(&spi->dev, "Failed to init GPIOs\n"); - goto error_iio_device; - } + ret =3D devm_gpiochip_add_data(&spi->dev, &st->chip, st); + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to init GPIOs\n"); =20 return 0; - -error_iio_device: - iio_device_unregister(indio_dev); -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_destroy_mutex: - mutex_destroy(&st->slock); - - return ret; -} - -static void ti_ads7950_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev =3D spi_get_drvdata(spi); - struct ti_ads7950_state *st =3D iio_priv(indio_dev); - - gpiochip_remove(&st->chip); - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - mutex_destroy(&st->slock); } =20 static const struct spi_device_id ti_ads7950_id[] =3D { @@ -674,7 +647,6 @@ static struct spi_driver ti_ads7950_driver =3D { .of_match_table =3D ads7950_of_table, }, .probe =3D ti_ads7950_probe, - .remove =3D ti_ads7950_remove, .id_table =3D ti_ads7950_id, }; module_spi_driver(ti_ads7950_driver); --=20 2.53.0.1018.g2bb0e51243-goog