From patchwork Thu Apr 10 11:52:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 879775 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 264EB1F0E39; Thu, 10 Apr 2025 11:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285933; cv=none; b=ehPbvULHupVJxTk6B40zF2JaqFs8I9bE+4GAChCKm2wwLH6AMLIcf/b5dslS71wYzl4D1T4UHIlYgfcVqJoBXs7zD16WYEzLxv32o1zN6WA8B2ZUGhyG/WtUzclR+J1xmAN1RLPrkjyuR6xytOCy32sXVZbPpPA05l7GaZfeQ74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744285933; c=relaxed/simple; bh=DxVcMRML2H41J7R4wgbVQO/G4dfCUcZYQKdJ+mRomt8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=mwwUhnPQTBReUmz57JOR9PkDNeghjW+1S6TpDtjhD69TGQx3r5qkyOC25qwhCoeeZ24wMXTHmaTzLunmKxFybUbuCDM8cwi6+bNisKELvlMmc3aOZS8dbfUbO3/mZG72Di6hcjbh4D8zFDNP020TjEvVySvM3GXAPzicyA7cAUo= 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=Exyy5lWN; arc=none smtp.client-ip=209.85.167.45 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="Exyy5lWN" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-54af20849adso767824e87.1; Thu, 10 Apr 2025 04:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744285929; x=1744890729; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Gz8iDaKPJnnJFHqBn+767ICwsMBT3pbftU1Ov0aGJv4=; b=Exyy5lWNIQPLMgCfCGGecqvHjwtx061YaemeYmQnk7TW0GonVUmMzctzmjWVyym+vo Ue+SljNBwOdVhh37MyHRxmo4qfWnY/U+W1ufEWBA0UAoV5UpwcNsFHuOIO/TlgxCiqOi Vf4SWSQD+tteMIdQFOUZOZML2f4dgU/8SFvJidoEQ9sDVZ5plJw1NPH/5HW+21eIoxfa O4C9wqSKvBGKL01czkp0zSmd2R1BGuYkdPNaiSIaLMIe9vIYNjYxFkuGTv+2TaF6oFYN JiQn4rYsXH8jFuSxJIf5mkOYFa1prZBwr/oOA+JcnsrV69uWCPCcrA1Fwrn7YjluCbGS OmFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744285929; x=1744890729; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gz8iDaKPJnnJFHqBn+767ICwsMBT3pbftU1Ov0aGJv4=; b=stBokGu3U7jjvX2zHyTLD/ACVbOaiokSQBkk5UXP+8U56VigTNjbkfkhr+zJHZKzb9 0qBXE81qTSkiB7BNJ6pn4ygfMVillPXzE2kvRSOUGKfmrqxs79XQzKt/X/K+3gT3XLnL ze/tnB0WManZuxLVGP4Ble+FKpBHwzd12DIUYZYKCiKHFECfeWJriw6yA3/MXjQxOvzd PviGi1BP9Hz7pA44qM78AfE43cTwXUg4wAzi6pnJgx3gKv6Y9/0j+NdT6O88MVyia125 KUtUB73lcmV3Yz6obBhWY2nfqkqYdPSPuZf9H5pZZpbdDcb0eBJMOp/shVzbE5svYbV6 z6Vw== X-Forwarded-Encrypted: i=1; AJvYcCXClKrh8HdUylSndT83aXMV220Q3Qb0tyaExYQNQvssE8HZCiGeP427f0QuRc0B3pR4UnTbKZsPmrfD@vger.kernel.org, AJvYcCXMqMaQ2p80rZVyZSlUqrd/iteoO85Q5ZSGWBKoeF5LXAwyNpTUGHCeJMCwrom0Ku7J32gbew+jnVr3aQEH@vger.kernel.org X-Gm-Message-State: AOJu0Yz37nmTyR0juKfsJC/MctXoSmiH3U7MWZDsunA8U8GpGYRWmaXX HmcS3nlKWT/I4S4kbwSgpmXIdMfxk1EdhNncmg/XG2hBgwHOZo2e X-Gm-Gg: ASbGnct/CNVI3QpjIKLhwyphsc5/P0kT5lwhQRiY1WyBw3PVUYTsMTMUgz/PW0rGW4x D4JAUj9HIKVn6DmbuE2AX0g7oKm3QSe6Xf5itOwcAYs/CDQwTl4T07FrI4hyydq5LYk25gsBQnb XkLHtkdYwkW/Yqr0eNEhnhTCTJ1pVHgaxbhiSQna7Z23HTQdTqrTUsLfsfwF/4KYPOf/eb393lj J0JfXq1ssMUWvDjAoChiQoROx4E5pW4XR5cVdHIoK+DOBCc7PCm5h8xsIoQmgLiejz27S54YEB8 ltjbWvoYiM/+LDAo0+KW86vDtd+tSlIa6CSfvuYfEK5o+Fs= X-Google-Smtp-Source: AGHT+IGOfbC9H3oM7GGaxbYZr8AyLgjLFjnYONagnIhbPpWt8QpO9xZbx5cMSJ0EqzgRE2HXq2uP7w== X-Received: by 2002:a05:6512:b22:b0:549:744c:fffb with SMTP id 2adb3069b0e04-54ce8a5919amr816604e87.23.1744285928908; Thu, 10 Apr 2025 04:52:08 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54d3d510b43sm129897e87.201.2025.04.10.04.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 04:52:07 -0700 (PDT) Date: Thu, 10 Apr 2025 14:52:00 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] property: Use tidy for_each_named_* macros Message-ID: Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Implementing if-conditions inside for_each_x() macros requires some thinking to avoid side effects in the calling code. Resulting code may look somewhat awkward, and there are couple of different ways it is usually done. Standardizing this to one way can help making it more obvious for a code reader and writer. The newly added for_each_if() is a way to achieve this. Use for_each_if() to make these macros look like many others which should in the long run help reading the code. Signed-off-by: Matti Vaittinen Acked-by: Sakari Ailus Reviewed-by: Andy Shevchenko --- The patch was crafted against the IIO/testing branch, and it depends on the 76125d7801e5 ("property: Add functions to iterate named child"). Hence I'd suggest taking this via IIO tree (if this gets accepted). include/linux/property.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) base-commit: 1c2409fe38d5c19015d69851d15ba543d1911932 diff --git a/include/linux/property.h b/include/linux/property.h index 3e83babac0b0..d937502a22d6 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -17,6 +17,7 @@ #include #include #include +#include struct device; @@ -169,7 +170,7 @@ struct fwnode_handle *fwnode_get_next_available_child_node( #define fwnode_for_each_named_child_node(fwnode, child, name) \ fwnode_for_each_child_node(fwnode, child) \ - if (!fwnode_name_eq(child, name)) { } else + for_each_if(fwnode_name_eq(child, name)) #define fwnode_for_each_available_child_node(fwnode, child) \ for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\ @@ -184,7 +185,7 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev, #define device_for_each_named_child_node(dev, child, name) \ device_for_each_child_node(dev, child) \ - if (!fwnode_name_eq(child, name)) { } else + for_each_if(fwnode_name_eq(child, name)) #define device_for_each_child_node_scoped(dev, child) \ for (struct fwnode_handle *child __free(fwnode_handle) = \ @@ -193,7 +194,7 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev, #define device_for_each_named_child_node_scoped(dev, child, name) \ device_for_each_child_node_scoped(dev, child) \ - if (!fwnode_name_eq(child, name)) { } else + for_each_if(fwnode_name_eq(child, name)) struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode, const char *childname);