{"id":2220041,"url":"http://patchwork.ozlabs.org/api/patches/2220041/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260405-ti-ads7950-facelift-v5-1-1f980ed3cf9e@gmail.com/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260405-ti-ads7950-facelift-v5-1-1f980ed3cf9e@gmail.com>","list_archive_url":null,"date":"2026-04-06T04:39:23","name":"[v5,1/4] iio: adc: ti-ads7950: switch to using guard() notation","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5d4f21067d46acad50b77c583897b5d12f622ccf","submitter":{"id":695,"url":"http://patchwork.ozlabs.org/api/people/695/?format=json","name":"Dmitry Torokhov","email":"dmitry.torokhov@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260405-ti-ads7950-facelift-v5-1-1f980ed3cf9e@gmail.com/mbox/","series":[{"id":498820,"url":"http://patchwork.ozlabs.org/api/series/498820/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=498820","date":"2026-04-06T04:39:22","name":"ti-ads7950: fix gpio handling and facelift","version":5,"mbox":"http://patchwork.ozlabs.org/series/498820/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2220041/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2220041/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-gpio+bounces-34694-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=LGv3t+uy;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-34694-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"LGv3t+uy\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=74.125.82.46","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fpxTQ6SnKz1yFt\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 06 Apr 2026 14:40:26 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id AB5E530191B3\n\tfor <incoming@patchwork.ozlabs.org>; Mon,  6 Apr 2026 04:39:33 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id BA63634DCE3;\n\tMon,  6 Apr 2026 04:39:32 +0000 (UTC)","from mail-dl1-f46.google.com (mail-dl1-f46.google.com\n [74.125.82.46])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CA02FE075\n\tfor <linux-gpio@vger.kernel.org>; Mon,  6 Apr 2026 04:39:31 +0000 (UTC)","by mail-dl1-f46.google.com with SMTP id\n a92af1059eb24-12776bebe9fso8410503c88.1\n        for <linux-gpio@vger.kernel.org>;\n Sun, 05 Apr 2026 21:39:30 -0700 (PDT)","from dtor-ws.sjc.corp.google.com\n ([2a00:79e0:2ebe:8:fe13:98b9:9e98:d1bb])\n        by smtp.gmail.com with ESMTPSA id\n a92af1059eb24-12bed93f861sm15182005c88.0.2026.04.05.21.39.28\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 05 Apr 2026 21:39:29 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775450372; cv=none;\n b=d9N/jcgt6QhzeY7Yw8epFIfThlzQIAmdYmEyvPe52o8ubrMsf0y9ZYGKz4ukwcQEXoCRr00DMODIUP/Grc3PbgKuciGJSIRzDSWJ9DBWWB0yljh3DmDPyESFfpPfkWW+1cRPuJq765aKBFLQcOAc7N3X3laxEZcaHzCDC5z6M3Y=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775450372; c=relaxed/simple;\n\tbh=Jp11lnnBrydu78xWpI7iQkASv1g6UtX/tycmB5OGwuo=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=r7NSomK3tIddcYvyOq2JhYD7ZC6VO/+Sh8v/y3zXDrV8XGcIxBf6crp0QQSjycjckR9+UnP9qHn07jVZDhNn36YFaZ6H2PvzXJlnAON8PFsjx4TxuPV3YowUBIfmY0i6IyI/Lst0RmxcqwcLOCdV8PhQeg4xvMbDoHiaf26hjjI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=LGv3t+uy; arc=none smtp.client-ip=74.125.82.46","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1775450370; x=1776055170;\n darn=vger.kernel.org;\n        h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n         :mime-version:subject:date:from:from:to:cc:subject:date:message-id\n         :reply-to;\n        bh=bm4XXEcWjidns3Evs84tEMwqC2yXbhhjm6W1vqULni0=;\n        b=LGv3t+uykzFn4AzECoZMV3TV+6IDSpFEr9A5rcl5TmCYxvMQ4GWOvDqbqkWEnQs99w\n         WdVxwcTRyTvtsieQ7vasOOqDKuqwL8vO++Zgmjv96jli/meVRsuY/lGhWwGb0mQiMJd2\n         5VCyEu5VS+DfzYriXJeIxmrGFLfeWQ0LWm7cxtMZOF4nxQTZkbnBNhfmiyaFHCeOt0LE\n         Ox0RSQkMc6otHc59ztM4dFpEaHfbQ4cKQGFTRl21fpeNsOmldRe1JyWI9v+rT0vWr6lu\n         BtzlqOZsnCJoD/RxpWbfrwkx34EcNWc2r+D3S35ImPasbfZDVLPSn6/Pvi7Qxjm5MqMM\n         7UBQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775450370; x=1776055170;\n        h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n         :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to\n         :cc:subject:date:message-id:reply-to;\n        bh=bm4XXEcWjidns3Evs84tEMwqC2yXbhhjm6W1vqULni0=;\n        b=EigHP8wa8yYDx+KLTd/9SfQW77sFd66mLpqFMU0bJEJI+ppFvg8QmJ6YLSrP6z3p5S\n         sxHujj/GySF2tFAGHI+JY4BnVj9K8Warxc2OtZ+5FXRQroNOuMDp4J4dtzpWFHhW6f4y\n         PmmA9ABfg2L3zx3YbUIbLhHF/A3K2BgW8onZKGH0Jr41loJZ7UaXgX7L02geaK9h1//y\n         equOsGlMmWeNxba7Wg905N2oHRKhS01iM2OlNwJUjIUtNh5EYwzYjlpWIsgAsdUrEYBg\n         iNOkXP2Jlz6kzwI9gGddUXjD0ZG2UpvdrvSXl0sjqOTYStETAhHpe85u/vy2izh/JuKO\n         +mBA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCU38ulHSSqqKib2hhjstM2UyfuA+Kx17paSU7pSE8vD55Rq1EFgbFmGRYVhd0w2HVgJ8RNzV7Ijn4XE@vger.kernel.org","X-Gm-Message-State":"AOJu0Yyvrh3gAzmXwqd7Vf9hfsptm5GnYvXRlMqxk3jGe0drN6da9WrL\n\tXYtyBRZRYQHDDWLWrmpp0WNG7rqZxs3/7fykJH1uGPxW+/gh0CqUXOIM","X-Gm-Gg":"AeBDiesup75YcXXLQwAsKKCscGJ1mikbMb6LF+Fg5uDpjzjbJGtbzERIr8g5lljYQ2r\n\t101fY1FGhrQ+40CCiNuanw3otNX9eA0X1M/CGeuzf2iEgqEu/A19yPpquWkEH3RMZPCWFDy1mop\n\tPyBOnwCMA2uhc8JOS3BWkmBwUYDl7EdxnAxJuOXEN3dgLlstr7OpEyecPNFTGOAGhxiXoJWaxpp\n\t8sFw8ESeROQpLQL0GCsovq7VO3gmpEeybKsbbJ2J6MWLStMiGDUjwQWTYFF+8PF3+kYAP3OSi+v\n\tgowr1b7PBnsQLV61KkcMww5ykXMn2DTwTZ8nZ7H26GqNVziOvcwDOG80sRUc5LeGY06fUrIXKsN\n\t9icjORopoMpmX30EHwe6gbrABWQtGP+Z955Z+WLoFjxdoJrQc4UwqTYlSiLPZVrs94MNjLjlBC8\n\tKTreyYD/ZYqO9PcNni6y2ByhpkdTYm0/Jos99Im0IoxjHuNaCvebOtUM5Xh4IbXZ/SQdBReDDsv\n\tFq9pyLUwZSuDiw=","X-Received":"by 2002:a05:7022:6092:b0:128:cbc7:4c28 with SMTP id\n a92af1059eb24-12bfb771ab5mr5387632c88.35.1775450370259;\n        Sun, 05 Apr 2026 21:39:30 -0700 (PDT)","From":"Dmitry Torokhov <dmitry.torokhov@gmail.com>","Date":"Sun, 05 Apr 2026 21:39:23 -0700","Subject":"[PATCH v5 1/4] iio: adc: ti-ads7950: switch to using guard()\n notation","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260405-ti-ads7950-facelift-v5-1-1f980ed3cf9e@gmail.com>","References":"<20260405-ti-ads7950-facelift-v5-0-1f980ed3cf9e@gmail.com>","In-Reply-To":"<20260405-ti-ads7950-facelift-v5-0-1f980ed3cf9e@gmail.com>","To":"Jonathan Cameron <jic23@kernel.org>,\n David Lechner <dlechner@baylibre.com>","Cc":"=?utf-8?q?Nuno_S=C3=A1?= <nuno.sa@analog.com>,\n  Andy Shevchenko <andy@kernel.org>, Linus Walleij <linusw@kernel.org>,\n  Bartosz Golaszewski <brgl@kernel.org>, linux-iio@vger.kernel.org,\n  linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,\n  Jonathan Cameron <Jonathan.Cameron@huawei.com>,\n  Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>","X-Mailer":"b4 0.16-dev-6911d"},"content":"guard() notation allows early returns when encountering errors, making\ncontrol flow more obvious. Use it.\n\nReviewed-by: David Lechner <dlechner@baylibre.com>\nReviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>\nSigned-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\n---\n drivers/iio/adc/ti-ads7950.c | 83 +++++++++++++++++---------------------------\n 1 file changed, 31 insertions(+), 52 deletions(-)","diff":"diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c\nindex 028acd42741f..6e9ea9cc33bf 100644\n--- a/drivers/iio/adc/ti-ads7950.c\n+++ b/drivers/iio/adc/ti-ads7950.c\n@@ -299,18 +299,19 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p)\n \tstruct ti_ads7950_state *st = iio_priv(indio_dev);\n \tint ret;\n \n-\tmutex_lock(&st->slock);\n-\tret = spi_sync(st->spi, &st->ring_msg);\n-\tif (ret < 0)\n-\t\tgoto out;\n-\n-\tiio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2],\n-\t\t\t\t\t      sizeof(*st->rx_buf) *\n-\t\t\t\t\t      TI_ADS7950_MAX_CHAN,\n-\t\t\t\t\t      iio_get_time_ns(indio_dev));\n-\n-out:\n-\tmutex_unlock(&st->slock);\n+\tdo {\n+\t\tguard(mutex)(&st->slock);\n+\n+\t\tret = spi_sync(st->spi, &st->ring_msg);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\n+\t\tiio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2],\n+\t\t\t\t\t\t      sizeof(*st->rx_buf) *\n+\t\t\t\t\t\t      TI_ADS7950_MAX_CHAN,\n+\t\t\t\t\t\t      iio_get_time_ns(indio_dev));\n+\t} while (0);\n+\n \tiio_trigger_notify_done(indio_dev->trig);\n \n \treturn IRQ_HANDLED;\n@@ -321,20 +322,16 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)\n \tstruct ti_ads7950_state *st = iio_priv(indio_dev);\n \tint ret, cmd;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n+\n \tcmd = TI_ADS7950_MAN_CMD(TI_ADS7950_CR_CHAN(ch));\n \tst->single_tx = cmd;\n \n \tret = spi_sync(st->spi, &st->scan_single_msg);\n \tif (ret)\n-\t\tgoto out;\n-\n-\tret = st->single_rx;\n-\n-out:\n-\tmutex_unlock(&st->slock);\n+\t\treturn ret;\n \n-\treturn ret;\n+\treturn st->single_rx;\n }\n \n static int ti_ads7950_get_range(struct ti_ads7950_state *st)\n@@ -400,9 +397,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,\n \t\t\t  int value)\n {\n \tstruct ti_ads7950_state *st = gpiochip_get_data(chip);\n-\tint ret;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \tif (value)\n \t\tst->cmd_settings_bitmask |= BIT(offset);\n@@ -410,11 +406,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,\n \t\tst->cmd_settings_bitmask &= ~BIT(offset);\n \n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\n-\tmutex_unlock(&st->slock);\n \n-\treturn ret;\n+\treturn spi_sync(st->spi, &st->scan_single_msg);\n }\n \n static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)\n@@ -423,13 +416,12 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)\n \tbool state;\n \tint ret;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \t/* If set as output, return the output */\n \tif (st->gpio_cmd_settings_bitmask & BIT(offset)) {\n \t\tstate = st->cmd_settings_bitmask & BIT(offset);\n-\t\tret = 0;\n-\t\tgoto out;\n+\t\treturn state;\n \t}\n \n \t/* GPIO data bit sets SDO bits 12-15 to GPIO input */\n@@ -437,7 +429,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)\n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n \tret = spi_sync(st->spi, &st->scan_single_msg);\n \tif (ret)\n-\t\tgoto out;\n+\t\treturn ret;\n \n \tstate = (st->single_rx >> 12) & BIT(offset);\n \n@@ -446,12 +438,9 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)\n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n \tret = spi_sync(st->spi, &st->scan_single_msg);\n \tif (ret)\n-\t\tgoto out;\n-\n-out:\n-\tmutex_unlock(&st->slock);\n+\t\treturn ret;\n \n-\treturn ret ?: state;\n+\treturn state;\n }\n \n static int ti_ads7950_get_direction(struct gpio_chip *chip,\n@@ -467,9 +456,8 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,\n \t\t\t\t     int input)\n {\n \tstruct ti_ads7950_state *st = gpiochip_get_data(chip);\n-\tint ret = 0;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \t/* Only change direction if needed */\n \tif (input && (st->gpio_cmd_settings_bitmask & BIT(offset)))\n@@ -477,15 +465,11 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,\n \telse if (!input && !(st->gpio_cmd_settings_bitmask & BIT(offset)))\n \t\tst->gpio_cmd_settings_bitmask |= BIT(offset);\n \telse\n-\t\tgoto out;\n+\t\treturn 0;\n \n \tst->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\n-out:\n-\tmutex_unlock(&st->slock);\n \n-\treturn ret;\n+\treturn spi_sync(st->spi, &st->scan_single_msg);\n }\n \n static int ti_ads7950_direction_input(struct gpio_chip *chip,\n@@ -508,9 +492,9 @@ static int ti_ads7950_direction_output(struct gpio_chip *chip,\n \n static int ti_ads7950_init_hw(struct ti_ads7950_state *st)\n {\n-\tint ret = 0;\n+\tint ret;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \t/* Settings for Manual/Auto1/Auto2 commands */\n \t/* Default to 5v ref */\n@@ -518,17 +502,12 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state *st)\n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n \tret = spi_sync(st->spi, &st->scan_single_msg);\n \tif (ret)\n-\t\tgoto out;\n+\t\treturn ret;\n \n \t/* Settings for GPIO command */\n \tst->gpio_cmd_settings_bitmask = 0x0;\n \tst->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\n-out:\n-\tmutex_unlock(&st->slock);\n-\n-\treturn ret;\n+\treturn spi_sync(st->spi, &st->scan_single_msg);\n }\n \n static int ti_ads7950_probe(struct spi_device *spi)\n","prefixes":["v5","1/4"]}