Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp873119lqb; Wed, 29 May 2024 13:11:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlIKpm5JpP1waRii+Udl3owZyjpirHWjmvzEZjQ/IRfg4XyXers8aDPDyBQxSqYGYLp9Qew5Ra2iPhbRht3Yh9wdj+MIPI4FAidMOIRA== X-Google-Smtp-Source: AGHT+IFxz/2GkGx+fnudZOQsaFb0msOV/kLKE1rWaA6W+gYRbKVWYhL2KCfvG3ufGLrP+GnK2cIZ X-Received: by 2002:a17:903:2013:b0:1f4:6af5:2737 with SMTP id d9443c01a7336-1f61a1ec675mr606405ad.49.1717013475560; Wed, 29 May 2024 13:11:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717013475; cv=pass; d=google.com; s=arc-20160816; b=t2RdUk3pRue6zTeitgGl4FmGl7gV9SuF+G9hX11d+LU+TSnqXAEAknUBquqge3ER/D PxAO8vJ7s0I4DUnQ6yu1kOgazlTce3gMhe2vDUIOr2xz5QYnwMgxpm30SdvDuYIA+2xh 980WEmsXAW+BCDqzZ054PVOYLnLL+s5J9rX+WpBHMIew+YkS808k8NCRH6IkMG5IEdMu LKYzm0txH5F/qYBlMXxSdMZ6xgMbjjYNpTiDGl0P6KCL3yBds3a1P13yTBlQVcq1zVJt wYgFbq8xFAP1ReCSB3f3XeEIOiWUXVebh63pB3O5dXpwUhZKnhaMLbSdoswlSAtZs4BU LnGw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=3Yw+tyisOoQIVKsFGGfntBjZv+48Mnl1871MjZUM50o=; fh=PXRmeP86YrFWfptF61YvM1Dqe+AYowdbmu/GGYht73g=; b=O8iRHnLImUy8T1Ygqdp+TY+ORSRs8kTKftVeYjDK20cwp0yZQKY33DmgNmpciE1NT9 YUx0JkT94mKfCssrP1nqrRb5mJFe+6zOfV1jz6tzwwhmfDOJb6d2+FNqxLwQo4YoaTNC YCcVaxrzF+Ipzo64174dhR52GBWqTSjSwQUbqUu31GM4RwpHbmdgfBY4jVaX2M6bIciS V53bXmh9A+nH3qdw+v64tTYNkylXk4sci3isXKK/Hoa1K+8yZCYjI+1Sy/FNFVq8uZF8 q/+iPwwJV5cpvw1EI8hNzflhoUa9QokbotP18O2ISlwC+Pi3na/EUdzlaD+VW9/vJdUF BRzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VDqD2Zlp; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f615010e95si3071815ad.277.2024.05.29.13.11.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 13:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VDqD2Zlp; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5D9F3288BF6 for ; Wed, 29 May 2024 20:03:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A7341C233F; Wed, 29 May 2024 20:03:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VDqD2Zlp" Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.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 1C8E91667D5; Wed, 29 May 2024 20:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717013005; cv=none; b=EERHIm6uIvg/pFTKuwbcR/US0NwLHs0uPKigiocVjHA1q5ZFIle1239dMJeR/DKJRwmGBCGtGVF2qUVK5OogsCWrMc03Mm8ZLdnd0AYsnOABViIBTy2aBjAWN85mBu/RYJNvUpe1wKvq/O2A2KQ1D+SRt2YxwGiZOOvs26FvnZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717013005; c=relaxed/simple; bh=0e9txGHxOrzqpvlxWGC074n3+ZQ2iC9PvcvIrOrFk68=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gQyfBXUsmmNRRtpXEFzAyRjhVj6vMRqwH7JcnsYCcHaklb1mFTonz/+5lyaG88/1/VvRNhkKxfGwiPQtQ7s5bw4zceEjSUFhClFqVzZknt4SUewYhFQaKt3V19S/zb3/hRGBKl82zzqqfii9+icgYD6aAniNJqvA5E0MBGPM618= 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=VDqD2Zlp; arc=none smtp.client-ip=209.85.216.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 Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2c1a99b75d8so77741a91.3; Wed, 29 May 2024 13:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717013003; x=1717617803; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3Yw+tyisOoQIVKsFGGfntBjZv+48Mnl1871MjZUM50o=; b=VDqD2ZlptrDQWX69TEbufjHk7oGuqiHAOCmsDz7FYijKmNGe233+0PErghRwRfEqKl bsM3zz3H27m8yihxH3cQzU8FBcAXWj5WbiPs8OTlQuUkKOFxZr7e1yJBDp5mbS4rYpZ+ bVT2abDuafhpYoPKH5ymnyyWcY3iPLsH0AJDln4q3lFDZIVz5ifPuVDkMvMaocdEbe23 8turRBez51c4Lft3GeGXVJ2EmxyeWR8eXsEtRwU4zGHhGYA0C0WCQ02/nLHWU7+jlx9Q 45OYax2Io8Zd9R0aVRp/kp6TI335WGD5tp2yodKpjt2p97qrjrdp9vkrRjK91fNhtaQb IKkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717013003; x=1717617803; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3Yw+tyisOoQIVKsFGGfntBjZv+48Mnl1871MjZUM50o=; b=w7noD0vARNPVloc+CsDZxcuxaeXreiPybtvLlUDvK9muyDAngcr90XyNp876linw78 yqlZtXiojmX3FRbGr2CF6tqZnilUcS4Wrp0ztESh0Db8G/uPRV0GGHQomSeSm4SwCEE/ txM569VCBEBx45AvxTglhSH87SpTjbC7Tch9h4PwCfCeqDUW493EFCZxMH5Y+vd0WUfB vABFS8NfNtkb7clNOnXhv7j11yhnctkP1yqji/rmHqWYIpflyOw4uH2FnHcVW1oUelIv rER5GDKinWhZ246DUgfYWnjtcmdIRpIYSrZlbXN3m4jZsCY8/tk95cxnIWjxR9jedNkS 3XTg== X-Forwarded-Encrypted: i=1; AJvYcCXjqV0Px4bLn0j2YaQOeezZ9o0H5P972Lc+ZxGGjKY5kFjU4l5dhng1N9qeyH31MvVMY+jC/c5e9oRQVn8bMRGkhzRjlurmOfzLDpRHNRZmcM+jc93zLguV/pYhs17D2zUeOr4BidufhA== X-Gm-Message-State: AOJu0Yx6y41zjPomHlGC+DEtGa8SNOj0fY4i8PAlo/AGdkq6imZ2gQ2C vQzOz6+UKLVbmXONr4JT4F4kuW2MJC2Eoxo/H/Yckm546zvXlj55 X-Received: by 2002:a17:90b:1883:b0:2c0:1fe6:b10f with SMTP id 98e67ed59e1d1-2c1ab9d9e45mr170095a91.7.1717013003271; Wed, 29 May 2024 13:03:23 -0700 (PDT) Received: from mari.. ([2804:431:cfd2:68a4:d1e5:41de:6992:6d45]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a779e835sm192127a91.48.2024.05.29.13.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 13:03:22 -0700 (PDT) From: MarileneGarcia To: Pavel Machek , Lee Jones , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Julia Lawall Cc: MarileneGarcia , Shuah Khan , Javier Carrasco , linux-leds@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 linux-next] leds: powernv: replace of_node_put to __free Date: Wed, 29 May 2024 17:02:33 -0300 Message-Id: <20240529200233.1188228-1-marilene.agarcia@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use __free for device_node values, and thus drop calls to of_node_put. The variable attribute __free adds a scope based cleanup to the device node. The goal is to reduce memory management issues in the kernel code. The of_node_put calls were removed, and the for_each_available_child_of_node was replaced to the equivalent for_each_available_child_of_node_scoped which use the __free. Suggested-by: Julia Lawall Signed-off-by: MarileneGarcia --- Changes v2: It was missing a blank line. Suggested-by: Julia Lawall Signed-off-by: MarileneGarcia --- drivers/leds/leds-powernv.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/leds/leds-powernv.c b/drivers/leds/leds-powernv.c index 4f01acb75727..8f94d2efed9f 100644 --- a/drivers/leds/leds-powernv.c +++ b/drivers/leds/leds-powernv.c @@ -246,29 +246,25 @@ static int powernv_led_classdev(struct platform_device *pdev, const char *cur = NULL; int rc = -1; struct property *p; - struct device_node *np; struct powernv_led_data *powernv_led; struct device *dev = &pdev->dev; - for_each_available_child_of_node(led_node, np) { + for_each_available_child_of_node_scoped(led_node, np) { p = of_find_property(np, "led-types", NULL); while ((cur = of_prop_next_string(p, cur)) != NULL) { powernv_led = devm_kzalloc(dev, sizeof(*powernv_led), GFP_KERNEL); - if (!powernv_led) { - of_node_put(np); + if (!powernv_led) return -ENOMEM; - } powernv_led->common = powernv_led_common; powernv_led->loc_code = (char *)np->name; rc = powernv_led_create(dev, powernv_led, cur); - if (rc) { - of_node_put(np); + if (rc) return rc; - } + } /* while end */ } @@ -278,12 +274,11 @@ static int powernv_led_classdev(struct platform_device *pdev, /* Platform driver probe */ static int powernv_led_probe(struct platform_device *pdev) { - struct device_node *led_node; struct powernv_led_common *powernv_led_common; struct device *dev = &pdev->dev; - int rc; + struct device_node *led_node __free(device_node) = + of_find_node_by_path("/ibm,opal/leds"); - led_node = of_find_node_by_path("/ibm,opal/leds"); if (!led_node) { dev_err(dev, "%s: LED parent device node not found\n", __func__); @@ -292,20 +287,15 @@ static int powernv_led_probe(struct platform_device *pdev) powernv_led_common = devm_kzalloc(dev, sizeof(*powernv_led_common), GFP_KERNEL); - if (!powernv_led_common) { - rc = -ENOMEM; - goto out; - } + if (!powernv_led_common) + return -ENOMEM; mutex_init(&powernv_led_common->lock); powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX); platform_set_drvdata(pdev, powernv_led_common); - rc = powernv_led_classdev(pdev, led_node, powernv_led_common); -out: - of_node_put(led_node); - return rc; + return powernv_led_classdev(pdev, led_node, powernv_led_common); } /* Platform driver remove */ -- 2.34.1