From patchwork Sun Feb 11 17:42:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 199496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2033657dyd; Sun, 11 Feb 2024 09:47:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRztJ5CcEcodapq056Wv4CcxjpFxrfAn+u+SLjj2wvXZ/iBIxhOn9W872G2D287ttztxKy X-Received: by 2002:a05:6358:8421:b0:178:799f:bcea with SMTP id b33-20020a056358842100b00178799fbceamr7473314rwk.7.1707673633778; Sun, 11 Feb 2024 09:47:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673633; cv=pass; d=google.com; s=arc-20160816; b=jTsNM+KP6of10VH1x6/M7GieM0gLR7amRfKDHlDSu76w236ITHs6YWsvZZQdgzPFke FVWIgpx+OOcO1IHosmgeNlyNhJNX19G4kUtUpIgzt0Y2RnRvrZFYy0+faCIwHRJvlL7a krWkVWas34eHW/lzHkE9dEP4Xh12Rgfo7CJr5uN7CwNGWqZ7sNgEUG0Mz6yUs98xw/qg u5hJTFoVIuBtXclk69mFcap//rSXwdLQ4CEVKEypVndwO8ezvhEFvRXtfbrns0w2SWpa q67hJ8PcPqXkaUvW6Z7JiSuJh3mHl8aUZw1OgKHfUWruifmZsPm/YJ/Mr5JA0a6Nnqhp bQfg== 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=rjlmNYMyWMjSdSWfSmRjwTQvtdD3MbOHm5LPbhDMTx4=; b=DaSoJEP8AHm3ZUQnOcxTWpUoYppX2Q3SrqgUGbdeIOVdHbuTKh9tA4C8I1jRciEkIT lQKIGVGu/cQL09dawltor+yBuCamSFDflUNMR6I7vuHODBkDUSeZ8aV26wFeADMQBl6s QOD8jfNbmCksC55l32eqOAMhnlVdXmLfclzpnM182IqAO+8rNgudg0JVzTPbuaSj2Me+ Q22aBGtlD8MXDJyrN4at9J5IwaoUxPWHD7Nlxzh+UrdZo63PaKvPa9Yuqku8jsr+/ltk pKabMMghDVLADS1+BSwU8gwauQj111OMxZaf9o2Tw9akUxk34tIA5LG7v97dJITxriIE 4uTw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60893-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUBcd8igRfvsQ9d0/D6DYOCEFIXOs3zYHCR8ngxKtDKnUiUB++VtFbd1moliAqwc46jsGXtF/WGjjSnrmYSAJuPfomsEw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y9-20020aa79e09000000b006e061bdc0fbsi3698295pfq.27.2024.02.11.09.47.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:47:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60893-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60893-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2D60FB2274B for ; Sun, 11 Feb 2024 17:45:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2603A5F57B; Sun, 11 Feb 2024 17:43:46 +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_S=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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790625587707421662 X-GMAIL-MSGID: 1790625587707421662 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); }