Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2067888rdb; Sun, 11 Feb 2024 09:45:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPnmoqJ00h6HobkIA+LEDnTYQpavwSZUY/d/zVwSHjGgeUlG692szJ8R4dPKZgdQewIMhj X-Received: by 2002:a05:6402:754:b0:55e:ef54:a4dc with SMTP id p20-20020a056402075400b0055eef54a4dcmr3735164edy.23.1707673526347; Sun, 11 Feb 2024 09:45:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673526; cv=pass; d=google.com; s=arc-20160816; b=B4cZj+PiDKRcInWqm8OV67+h8PUbq68tzKsFMFLyTtwniz9s4oAvZrjD5tVEmUur0a XuMERLC+bke65KsbF5akZri1Mg+AG0PnjsZyQxNU+0xXid2ZHdObbjlR2p1fO7tLbTVQ ojqqMhvSfsBaM6JyLBMsceYGgtYpcykBEMcKecaVqzFAmztbeh2DmY8POQjyKV310kKh mIhMMmRywhkSfwJ0IHVd4kkmhujQSw4qk56g9MWZ4a7PgEkcpT1opN5aJ1qLDyiseRfH agzIRACPhHnN9VRhqBlzkG9UNkgHB/yHi1BBUScvCv5OGW0EhD58JpZvjIKcDmyEezQc QrwA== 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 :date:subject:cc:to:from:dkim-signature; bh=xp/CsoF57mWiI8+dBWoEFGm72AqFSgmGcJeP0F8ffxI=; fh=y4MFJ5iH+R76P/iD9Lw/Ii/YSPfocvXSPyqt6J/6t9Y=; b=z0p26ztOYUykgwU/xNmuYh6YCCb3c0yq2n6ouIs1EuULvoDXaUwb1YfcbQOW9QmCLi +4cqDDv1kf6UUTXV+Q0mvX1m+HljHvmyQAEDFlVFlPNhb4WRg/XRxYZrRMSiKNw5AS4V SbnfHSMkbfzpkWdxT6r9bTqfwRUrElLGw73QEiGdyyTqERrfKAm3OPG6EjbyTl6KXV0E M5aWXY/eCnyg1jFDj28ROPZCA+XEBx1YVGyMdhjLcg013wqQyoAA5wOM/mzHtgnlOH0j iPNkn0+WXVRVXvN6TNBkOfkMN9DlXwA0PeAY9oYKooz4zh1+DXjT1dEQQ2oTML+YBqEK tf5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nc3tKS7C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60893-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60893-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCX1Ssq+o5usdl8vzF+w0rn7jhfQFSK5EHD/sBYIpOHjGn2f3NxbErzXip90EWbsg4XlhHlt+yvUeM6FbDXPnToyehKEbhvCckeLqruFvw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n6-20020a05640206c600b00561b9a3280esi90281edy.295.2024.02.11.09.45.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:45:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60893-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nc3tKS7C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60893-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60893-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1D5231F229A6 for ; Sun, 11 Feb 2024 17:45:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B3C65F844; Sun, 11 Feb 2024 17:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nc3tKS7C" 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 7B2AA5D73E; Sun, 11 Feb 2024 17:43:43 +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=1707673423; cv=none; b=RZCvmYWZFc8yHqyosMcCO8uw5R0XjJZxk/STw+VW0yGYIfWSmcBdib8WhhYS9bQF+TBMdePDkxqUVu7Nd/8K+wpXaBxccdAxUU4cz1TgorpXz/L9BQsGvdSvYwB8epk5C6j7SBndnxBxM+HHKLpTVhiZkztg2CDnbQKnYS72HC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673423; c=relaxed/simple; bh=oP7Cqkm/5T3pGBvjae33JMVHKBsSoCzjAMOiZeqVCQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uk+d2XyLnwDl29lpVzxbtv82pgbY/6iwHBpYjVO3SKVsIiFTGosXOgQHtzZF5BEs1JXhT+dN+wD7va49uPrcPRAcktj4Yz1zMU+HEIRLSH/hvdPUmwpnFdzmwkH/09ysny8v27eZscf8LvAC5SqptVnHAFOHZACZsgGDhsoFAKY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nc3tKS7C; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D96E8C433F1; Sun, 11 Feb 2024 17:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707673423; bh=oP7Cqkm/5T3pGBvjae33JMVHKBsSoCzjAMOiZeqVCQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nc3tKS7Cfm2B/aaEnOZz/NuKLMPYUqycHKpE821Nh54RAULRAh8B9c2A24fgokQCN mSouTJKqU7l8Xy35as8W/rK1xvuro0pmX+9zAsMlxBMnGRU+Q0rY6oVbgYe/rZuZjg hAMKM5XFu8F6EyP25nlWb81GKSZPuE/tDLhuCWx4y9fOzJV5gPx0+2a3puYGwHE/vK 3D2DDBybvc3hf7bz/eJP8ul93rejo+UpKblluzFuw303o1Yfc6b2PpOP7u5s1WhzL6 MpU6A0FVRYRefT7sIJsOuRZkWFOXQDv2UIqmBCvMzKlF/Ic/PBTC+CSWFXjg2onKJr OSB2XFbLyNwog== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Nicolas Palix , Sumera Priyadarsini , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron Subject: [PATCH 8/8] iio: adc: adi-axi-adc: Use __free(device_node) and guard(mutex) Date: Sun, 11 Feb 2024 17:42:36 +0000 Message-ID: <20240211174237.182947-9-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211174237.182947-1-jic23@kernel.org> References: <20240211174237.182947-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jonathan Cameron Avoid need to manually handle of_node_put() or the unlocking of the mutex. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/adi-axi-adc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index c247ff1541d2..3c85e8a6467b 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -248,19 +248,19 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev) { const struct adi_axi_adc_core_info *info; struct adi_axi_adc_client *cl; - struct device_node *cln; info = of_device_get_match_data(dev); if (!info) return ERR_PTR(-ENODEV); - cln = of_parse_phandle(dev->of_node, "adi,adc-dev", 0); + struct device_node *cln __free(device_node) = + of_parse_phandle(dev->of_node, "adi,adc-dev", 0); if (!cln) { dev_err(dev, "No 'adi,adc-dev' node defined\n"); return ERR_PTR(-ENODEV); } - mutex_lock(®istered_clients_lock); + guard(mutex)(®istered_clients_lock); list_for_each_entry(cl, ®istered_clients, entry) { if (!cl->dev) @@ -269,22 +269,14 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev) if (cl->dev->of_node != cln) continue; - if (!try_module_get(cl->dev->driver->owner)) { - mutex_unlock(®istered_clients_lock); - of_node_put(cln); + if (!try_module_get(cl->dev->driver->owner)) return ERR_PTR(-ENODEV); - } get_device(cl->dev); cl->info = info; - mutex_unlock(®istered_clients_lock); - of_node_put(cln); return cl; } - mutex_unlock(®istered_clients_lock); - of_node_put(cln); - return ERR_PTR(-EPROBE_DEFER); } -- 2.43.1