From patchwork Sat Sep 28 19:47:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831654 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 A162338F97; Sat, 28 Sep 2024 19:47:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727552864; cv=none; b=p8fYTOFChNmby8A9Aru+f7kgi8C8YW8e2a9wo1ssmN9Brz4hgEg69Bj/hFI1HPtW3JIqnfaJhV30O7/w3JxQD/5O6Be98VItVkFYPlWIo/RSDP0/6NZxovxv+6C5QaVtUSk5bi0kcJes6J5LthcSByUIvjm4+O+Y2RiEL8LS2Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727552864; c=relaxed/simple; bh=UebfzqIPW+uuj+iBRyR34fzs/k+gmm86ojQNETSqj1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oOgD9f09P4sFYw2bwXFQyRDFkyLZmrHZ8/24T3RqJxnJT5qHZBdH2zpDsOATBOXqMFOhzSFo2tHAKKp6phNKZr9W9W7qz/cgrg4EVQawvlTNunXAj9dyxZBkLBbh8AzkJasxMfyfxFWVfUqv1NJOayRnpPKUuJNJ4WTNJCNz9Fo= 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=nKy9eoZm; arc=none smtp.client-ip=209.85.218.53 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="nKy9eoZm" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a7a843bef98so436129366b.2; Sat, 28 Sep 2024 12:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727552861; x=1728157661; 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=lQ2Y+OYT27gnAw1oY0Jt+LJqwQN0EEsJJqFWe00ZFj8=; b=nKy9eoZmfQCXwOXu2LLbbKbNhA6XXrmLO/mgnKxK8kZdhJGdGy83EdPgtmr1lcBUBQ foRCfFFLRpo2P2Yrh3/q1GdBaJDq3C6LiElAkAgK6FPi+hlC+48wzA+PgRDgUj1kS0uC 0llVx8znPYICxGAkjuCox9vfiLECfWI58fiI68ziXcWLw8ha4bxY83Db45/4x/9TuKiv m0exIFzGrTvll+2MS69HotEx/EPhK5ZJGNveZJDpUxFHLI3kbO7LqtF1yRTyBFQMkUQ4 eNiz5ivyuE91KUAaG6htADUHKG1R2xRrsS3Qhuom03cJmpHtDefy/yBhYKsdAggVJrc5 dkIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727552861; x=1728157661; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lQ2Y+OYT27gnAw1oY0Jt+LJqwQN0EEsJJqFWe00ZFj8=; b=oWc0CLaBZVQBg+wqtYNPUd+XugB0+D6jNEMix3UqnpjS1w+OZnxS1KlPtTJE1X9OSs q45dBt2LtENMc8CDaPLYintmHgpDvbehK0HFRqfdiBDJgIvbpoD9C8hCEXQ+V8D2vsNp 7YaGI2oaI7h/2uFhzmy+IKFCENXvZQqd6gLuq2qBw4ncog92GuWFvk9B0uIdqypvtdtc IGvKVQ4aeW53qmgsKiIaJX/k1RoJlPpbSsXg41St23t6SyPOpA0uaqXSSGWJMACgxsb4 rn/3o6d2CpSVWP79wGqKY9hkViPzdItBkxnHf2w4ddGd2/284993YlDq/8GnDA7XxJXX pN/A== X-Forwarded-Encrypted: i=1; AJvYcCUHL2GlYm4wcUru8FN2CQMuSEZu76rRcJJlwsVGpd41muzb1F27pMR9QdFHZSqLVQDnM2ccu0tb4aCfNEJ0@vger.kernel.org, AJvYcCVacRr/xDqRQeyc/NrsMft6RWeiV3Y6jrtgkkmVxRgJvCrL5fivqr9Osw+/ljOa8Z+bXDC37v8bfj18@vger.kernel.org X-Gm-Message-State: AOJu0YziH308c3P2FdHkCwdSkpVGP0FMIFwdNHwj+WyH6rsdLAqbvcOI Z5TNq8EpegXFvDsegsd7ertnlu9r7qiiWwj89x+v/4EDsDg7yYQASPy3Uw== X-Google-Smtp-Source: AGHT+IHYoDI0FBwnMWQaIkRID04jQi+9q4V/j7kSVTpwS6OSyvnWhESGAGjKsX6zc/FK/fFZnKBEsw== X-Received: by 2002:a17:907:7244:b0:a89:f1b9:d391 with SMTP id a640c23a62f3a-a93c491040emr675354066b.14.1727552860387; Sat, 28 Sep 2024 12:47:40 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-2243-8f1c-2a7e-ca73.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:2243:8f1c:2a7e:ca73]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c2775c22sm283707466b.20.2024.09.28.12.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 12:47:39 -0700 (PDT) From: Javier Carrasco Date: Sat, 28 Sep 2024 21:47:35 +0200 Subject: [PATCH 1/3] gpio: dwapb: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-gpio_device_for_each_child_node_scoped-v1-1-c20eff315f4f@gmail.com> References: <20240928-gpio_device_for_each_child_node_scoped-v1-0-c20eff315f4f@gmail.com> In-Reply-To: <20240928-gpio_device_for_each_child_node_scoped-v1-0-c20eff315f4f@gmail.com> To: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Mika Westerberg , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727552857; l=1496; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=UebfzqIPW+uuj+iBRyR34fzs/k+gmm86ojQNETSqj1I=; b=yylqffQpWwyfeh+roO6gds9YHY4qnBknJ0IeKvIu8ukAjKIbWAO1atKFlPtN/xn1ESol/c6xf O2Vso3g7QhJDGVzTLW67rkh51LWdeQzCMnNujo6qeClxJS5CxV7YNxr X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for a call to fwnode_handle_put() in the error path. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco Reviewed-by: Linus Walleij --- drivers/gpio/gpio-dwapb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 798235791f70..bd374fc27174 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -571,7 +571,6 @@ static void dwapb_get_irq(struct device *dev, struct fwnode_handle *fwnode, static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) { - struct fwnode_handle *fwnode; struct dwapb_platform_data *pdata; struct dwapb_port_property *pp; int nports; @@ -592,7 +591,7 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pdata->nports = nports; i = 0; - device_for_each_child_node(dev, fwnode) { + device_for_each_child_node_scoped(dev, fwnode) { pp = &pdata->properties[i++]; pp->fwnode = fwnode; @@ -600,7 +599,6 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pp->idx >= DWAPB_MAX_PORTS) { dev_err(dev, "missing/invalid port index for port%d\n", i); - fwnode_handle_put(fwnode); return ERR_PTR(-EINVAL); } From patchwork Sat Sep 28 19:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831338 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 6832816193C; Sat, 28 Sep 2024 19:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727552866; cv=none; b=XcK/WzeX2w/gUb2jC2COnMuwlPuZ5g6Q2u1g3rZa6OlBLnEk2vWaGnVssh/pE4seXtYOg1PDsYRDDQnbh/KgDqA3P+OQ5wZgKkqLhqL3SueVqxtKOtdMaSTGPdI2ukAMjVgBkiis2WmpEXufr2dg3gs+cZ3cSIEgj8Sv1SEeHlo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727552866; c=relaxed/simple; bh=qpWlHZ/NTb2o2BGag6w0MPuw2Qc51lis5IwTedMxSUc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PxMvORfbWu/ntYelnAmSzP1ZpFqmggME7k2rQoVOQzNEhadtR+rMBIE1wHlorJEooqcEZoCBnfeksiPdCxsoL5XkJTp+ymB6b0I6QQVGB0IgOW6I34uDpNdPmFmGf9+p9P1I+zsOlnzTiu5TDtdDZ/6bxKTEo/R+CiKMih8tfyY= 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=VnWCcuhk; arc=none smtp.client-ip=209.85.218.49 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="VnWCcuhk" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a8a7cdfdd80so484307666b.0; Sat, 28 Sep 2024 12:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727552862; x=1728157662; 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=D3oxEQMoTQStUkn3dra5fpJFLUFy7oc4EXVsPFNPtyI=; b=VnWCcuhkxuYY+eEhMqibieeXTgGQ3xMjbaSmv1hox582G7L67KGMPtOtSatXib8Lqt WRDvuSOQ27bnleX2XPicm4IpsmeHqLeAw+dpHHSeuSZlt5WUQni7JqgC3Jtq0WQ5hiS2 Zw0En85zvz5Xl5ifRL5chUVlRKC5M5MoheoVweLUyHglJ9tdtX3nHyfkDYaTbkjo4hA+ z35qoTj/xhyjMcdvyrIGmIIWmgJe9dAf//SD/6lVgjd+Qx/ajBkHu22R22rySsDSXORx S431dlsIwPMTyGPkFss28IF+Y5wSKT/p/PNQjy0A4BvFg6hTdL0VKl26ZDNO93Jtmrci hKMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727552862; x=1728157662; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D3oxEQMoTQStUkn3dra5fpJFLUFy7oc4EXVsPFNPtyI=; b=uK61+2amKV08AT0B0uBBhd7hBBD3F+3rLIr2UyC+cgoAtGuf39i4NNsPWKKFDTJviw ipvNQO0xiFRSOBuUekyDm7BsLu9YbV2EFyu/lZz87VpxBX7r20zfSr2MG64VEZ1FfcHs AEBm5OxCu9RpbEdgQw5pwKIeTTSNoHuT+hV6XAOAiGmlQ4kRZF1IaVhshfBkffX7zf34 dx0dZnKdWJpixqEYNriWsqKnjI4SnQMqOfP/KFeArbjm2pdGXqMqiE/3akqy4j+4lvUH zBsOq6wR4lh/P24XQ3dakm9N5ZDmSfW9rOqZPTCYG7d9e6xglIEvRm3y9IVRi9WADdK6 AlpQ== X-Forwarded-Encrypted: i=1; AJvYcCVgT4CnHwxBFIhD7ShvWifdF3/fQHiz+COHQRVTgsA75Z46d+mIdrB5GS9YkmctWY+I5Nf2XzIjHh03DLct@vger.kernel.org, AJvYcCX6PRXihAq783ysuoIEsAIKjho1a95CL8MWhPg3qSgvwTntWwPgq+BXPappAztJvQMIZ259CphPAnEW@vger.kernel.org X-Gm-Message-State: AOJu0YySuGOnyZLvDR+J/0ZiaCkCxAdHhgy6ay53FC/iQRYmYygI1+WT vV7XcybgtHZV2Xm75LzRNjCz8uq1w6X9z5kEhF4c0M933OnszlAmiszAAg== X-Google-Smtp-Source: AGHT+IGSWiSfi9MOzvxotcEzEItEyOMuxAJNIYYdCRTAk8pdsv6wrtk6mfojkV8nVlRWfO8G+BUGuw== X-Received: by 2002:a17:906:4787:b0:a86:8953:e1fe with SMTP id a640c23a62f3a-a93c4a69b1fmr805274666b.47.1727552862166; Sat, 28 Sep 2024 12:47:42 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-2243-8f1c-2a7e-ca73.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:2243:8f1c:2a7e:ca73]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c2775c22sm283707466b.20.2024.09.28.12.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 12:47:41 -0700 (PDT) From: Javier Carrasco Date: Sat, 28 Sep 2024 21:47:36 +0200 Subject: [PATCH 2/3] gpio: sim: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-gpio_device_for_each_child_node_scoped-v1-2-c20eff315f4f@gmail.com> References: <20240928-gpio_device_for_each_child_node_scoped-v1-0-c20eff315f4f@gmail.com> In-Reply-To: <20240928-gpio_device_for_each_child_node_scoped-v1-0-c20eff315f4f@gmail.com> To: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Mika Westerberg , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727552857; l=1102; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=qpWlHZ/NTb2o2BGag6w0MPuw2Qc51lis5IwTedMxSUc=; b=exW502MojY/GuHnYjnxzF0t5w2M1q4MukLV5X5wjFNs3gRlr63O1Py6ybGW/BnO8t5t1kPHbj pRliwo5CcS6BeQeBw6hh8NZmKPneKGcnxKRozQXVMyjBY+hELNjNjTR X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for a call to fwnode_handle_put() in the error path. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-sim.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index dcca1d7f173e..f387dad81f29 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -520,15 +520,12 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev) static int gpio_sim_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct fwnode_handle *swnode; int ret; - device_for_each_child_node(dev, swnode) { + device_for_each_child_node_scoped(dev, swnode) { ret = gpio_sim_add_bank(swnode, dev); - if (ret) { - fwnode_handle_put(swnode); + if (ret) return ret; - } } return 0; From patchwork Sat Sep 28 19:47:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831653 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 3EC8C176AAE; Sat, 28 Sep 2024 19:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727552867; cv=none; b=mfBSq5rtwG7rOs33TbrAUxzgG2tLM2DJy7W9mRZSvPL0PwBupIvuH8bPdPYpJQdhyjz/8dDUFlRztcdV7ajL+WJn7Q/wsbFBaiurK5iC22hF927zXP76CkjjHGlSyGMWM2Es4nOcfy4IYDG8pQifXcoi4k+Xlxj2mHI6WTCGVxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727552867; c=relaxed/simple; bh=OmSLqQKAb/QVwFN4C7eKhQPVnPYgmYpfMCMk1y2cALQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J1MTbxf7jQiJ4euHx93KFE9U+4xYhPySi6x7WAcnn0ES0/8LLK/MWs2RacJxpVZVyL9iqST2xEfpE7YmPxWamxYCxRwcePCADJJpCufmTGHrMOM/oGGetRH7MIXNMTwhH/XgAPu4wKbaosvl+LKRUleBz5TFh965L2l3lFtFFvY= 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=Lxyt+6Qa; arc=none smtp.client-ip=209.85.208.41 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="Lxyt+6Qa" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5c8844f0ccaso2210234a12.0; Sat, 28 Sep 2024 12:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727552864; x=1728157664; 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=2iltsOj2nm0hssOij02ApkpMdrgfT0iF/UOR+aKdBio=; b=Lxyt+6Qa4/Pw6iiDXG0IfYGlurKBQcY5Au4R1ByadIRIewKLgdXyZTmkk1xFjgKDNN aZwwInDU7REKF93cFLoejeCT0CA7/xkCtr7bfbx+VG/3Fc27aEnZ/Xu34feTv5sezSQK xzV/Zrh3utKQ/gu16JSb1ireDMrciEDFfjKhaQfV3JgdvWUu4YoEuvSRnhiEfgOuCmZy vUiMIoXVVqBEAEMQV6e2zypVUfMW+0Ohv+6xmipRIYE6pACXY0EJRfC772SPSNLn81py bOx+jQWwBIEMjLO/gCzDjm0O/7YitM/50L0uL79ERbGB/GJilscOQ4Pi7zBuSvZlIWjC K95w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727552864; x=1728157664; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2iltsOj2nm0hssOij02ApkpMdrgfT0iF/UOR+aKdBio=; b=O5hyp0U4wiWHDj/AKi+ij5tGX3UCkCw14i/3D8+jBYiyqEvrMup0Ucqf4U3TvqTgd2 wOYAGIUNBdQgD79YZBDfgp8RIDR+zIclDQCA3/T9DXW8K/ZwBjb0nNZdgCjWr9rrua4D DeJWWkRYGa9jBUDDqTS3CepL3HpDoyWWge/9cPzbu54afWRjDkkepgToFeSZ7aE3tSCW BTihOG6nDUz+2U/JSYpkQzlfWbmKSiBPfDBznlFodvSw7QceCh7lmWasWCmwWafW35ux pt2j3PFSswaxey+gvsNf53lkbduMTpppMQjYNXokj7kJsTSemtmy0dAZBFLP6JLdlGZT UlXw== X-Forwarded-Encrypted: i=1; AJvYcCW5ICVgDX9155HkRXDT1sm/d60pmdkYAFa+4BYhPAtS3qFT04NcvY+IevygywzeVCLFpGAjAyfvOy4SX6mF@vger.kernel.org, AJvYcCXZYu6JOcWmf/JPietJ66Zhim+6EfB71umky4BSiAEXhm/HyOqRrmh5+rtC8wmE/j+X/n4EY5/SpGbS@vger.kernel.org X-Gm-Message-State: AOJu0Yw+ewQ4s+Skc7L6fAxsatZL+IB4bB2xFkN3H2fwY/lVcGGKgW3Q Z6Z2Ad3GpKR0KL4eWSKT35JH84Nx6ckK+/A4P93ciYps0Kv+whgl1YgGEw== X-Google-Smtp-Source: AGHT+IFft1o19Zd9czA/C4i/Nk9M0s2es2Xe7eLAYuqbNn7Q27a2SfNiUuDSSopD0Eh+G1YkUuuPow== X-Received: by 2002:a17:907:6094:b0:a86:c372:14c3 with SMTP id a640c23a62f3a-a93c4a4e0e5mr933056566b.48.1727552863793; Sat, 28 Sep 2024 12:47:43 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-2243-8f1c-2a7e-ca73.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:2243:8f1c:2a7e:ca73]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c2775c22sm283707466b.20.2024.09.28.12.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 12:47:43 -0700 (PDT) From: Javier Carrasco Date: Sat, 28 Sep 2024 21:47:37 +0200 Subject: [PATCH 3/3] gpio: acpi: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-gpio_device_for_each_child_node_scoped-v1-3-c20eff315f4f@gmail.com> References: <20240928-gpio_device_for_each_child_node_scoped-v1-0-c20eff315f4f@gmail.com> In-Reply-To: <20240928-gpio_device_for_each_child_node_scoped-v1-0-c20eff315f4f@gmail.com> To: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Mika Westerberg , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727552857; l=1319; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=OmSLqQKAb/QVwFN4C7eKhQPVnPYgmYpfMCMk1y2cALQ=; b=eOSvEiYIr9MxSawrD21/c/lnXe8QWnJQBkoIprV+FI1oauBP+WU4gbv9Hmjc7olsJlQadDQEB S+NLzUpfVpSDtsni7kcxNDp/2MgJhtuDG9m4jl5nQ/Qvsoup86C5A4m X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for a call to fwnode_handle_put() in the error path. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/gpio/gpiolib-acpi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 78ecd56123a3..1f9fe50bba00 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1315,9 +1315,8 @@ acpi_gpiochip_parse_own_gpio(struct acpi_gpio_chip *achip, static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip) { struct gpio_chip *chip = achip->chip; - struct fwnode_handle *fwnode; - device_for_each_child_node(chip->parent, fwnode) { + device_for_each_child_node_scoped(chip->parent, fwnode) { unsigned long lflags; enum gpiod_flags dflags; struct gpio_desc *desc; @@ -1335,7 +1334,6 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip) ret = gpiod_hog(desc, name, lflags, dflags); if (ret) { dev_err(chip->parent, "Failed to hog GPIO\n"); - fwnode_handle_put(fwnode); return; } }