Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6739014rwb; Tue, 9 Aug 2022 23:34:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR7jXQ2mJ0lTiaqsXt51orgifWOpmZYKVOw5/zl7vn6jsIqye20JUpSsQeRtMLQny7ZO3wsN X-Received: by 2002:a17:902:d546:b0:16e:c70c:fdf5 with SMTP id z6-20020a170902d54600b0016ec70cfdf5mr27109848plf.100.1660113293996; Tue, 09 Aug 2022 23:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660113293; cv=none; d=google.com; s=arc-20160816; b=gdb6+oUuNAGw3JbFEcMAanhKNzl6gtmLusbdw6F5pe4ynXJJFF2fLNEGGu89PACsUI rQluzE7J1GMkM0IqlrPBlxdFiseuz6krT65UE6KcM6grzG+MC2288cw4euWAqhdvBplc LaGnY/yuz5GzmeFY+pRq1Vyzzq22OdH3CubWiT9Y8TEarUxvnCZad/Bznj7lcPImJAy+ EXv60JQD3ZGQjIWwwkWUrUNTMF/ivHqKG9kQBTJnuBB6Wif7cfFh5RNs8ieuRBOvu56A fG2Pqaqz3AC8FpHf8Ak/yUu1C5I8regDDUesvewsCj0emHVsfrEI57KsjWnW91I62a7d WK3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=QlBa19npdjPgpjrCBQ6hdELMXhm8tkXE401pFqPbnb0=; b=plGCZtzhEd1P3rReoF7AC0Mdr+kUuJlPBG4YfOSaHMhTsS6AkcPnCB1SsgtleOQSwm zmAAwKFihdrjuZnGFXLgHPebxA/kauf9PtVEFrMWrCKNdeY+0736K5SL9zpJN9QHBAGv cJwBklhg/uvCWEy4Ej8HuC5uetUKf7qpGSFrIFqaKJKRhsD/fn4bIsviqUYStS5KOFTz LwDtZy8LWsPIEUgxusaKKZg/0/t49IkxUbfCOEGv9eo14431Lra9N+Wip0Bl871vYtlX OOlUkGNw35V4Ws8PgQtTuNr/LGbRs/DEngkZCkAIczc6cCFKHFCq9QlKIOXM+CUxFwpl /ZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eJmKIYCY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a170902e88700b0016d785ef6ebsi11131970plg.104.2022.08.09.23.34.40; Tue, 09 Aug 2022 23:34:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eJmKIYCY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbiHJGBs (ORCPT + 99 others); Wed, 10 Aug 2022 02:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231217AbiHJGBK (ORCPT ); Wed, 10 Aug 2022 02:01:10 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD7226AF1 for ; Tue, 9 Aug 2022 23:01:09 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id w12-20020a17090a780c00b001f76ed0a1easo2641589pjk.0 for ; Tue, 09 Aug 2022 23:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=QlBa19npdjPgpjrCBQ6hdELMXhm8tkXE401pFqPbnb0=; b=eJmKIYCYCN91qGdXy7dqkM9QOmKtLlEdwFwNdU/NZG0JQuX+kMk9l2lpLVW26gS0xn kb1NHLqMsTBWLP5U6mLKXexB0rk/CifLn9hnGa/mjgeoY2ccfLaW07tOhrvM7hR626sI o1Wxf6k53d9enK4htKjLblZQkmtY2thm+sSPKA/YnztNkYjyLQiiHu7pgjBV9ndsMjEh pFs5qTn8XZdMyRnnPBN3fI5zloYW1GMq0HQyY5dSump5PVfdqEkRTmTSGIOB+3+Rzouw Vb8tYX2Edlrw8s9/NhIqxxJacQe8dgGAqtp30kKKkHE8RdXPPnT1cGXkSUpwpWq378Kp ahng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=QlBa19npdjPgpjrCBQ6hdELMXhm8tkXE401pFqPbnb0=; b=lGttv+dibepMaARKuFDyFeLpYl3koS4tE0DynIQHKelJKA/0a/MugMPHWr2g2t3Glb oS0Ntw73rw7rEoudq28cDZd7TY35EK54OrrftY1zGjHawvnyqclxiLNHQtaC91vhXCJM cyXFjAqvHin3mVbDXZjRAEpNcsrLfsazU5Z4VdierG51EGYBtd9/dZPyOXqfypL1Rfwu iUBLZEHrrJB1rGQ1tGG2bXo2rMwN6C2jeTpKUttz2itzAtfGNF4/qhg4yfX3+29cY3Gq O/W2G69VMo2k6XPGeByg5rqGN1PFNZbP5pIu/Gb0tQgtTOqD7GZrnz7gSnh/e99afcIX q6pg== X-Gm-Message-State: ACgBeo1ITGWGMdDjy+uGMwhipz/Ug1bfENXtpILi4as/lxh1WzdVJuht D4MBh+GKf7WXeVt1EdeFrUxQBbz022cN+pY= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:f21:76ca:766f:e0ab]) (user=saravanak job=sendgmr) by 2002:a63:6884:0:b0:415:b761:efa4 with SMTP id d126-20020a636884000000b00415b761efa4mr22285314pgc.274.1660111268410; Tue, 09 Aug 2022 23:01:08 -0700 (PDT) Date: Tue, 9 Aug 2022 23:00:36 -0700 In-Reply-To: <20220810060040.321697-1-saravanak@google.com> Message-Id: <20220810060040.321697-8-saravanak@google.com> Mime-Version: 1.0 References: <20220810060040.321697-1-saravanak@google.com> X-Mailer: git-send-email 2.37.1.559.g78731f0fdb-goog Subject: [PATCH v1 7/9] driver core: fw_devlink: Consolidate device link flag computation From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Linus Walleij , Bartosz Golaszewski , Rob Herring , Frank Rowand , Geert Uytterhoeven , Magnus Damm , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: Saravana Kannan , Abel Vesa , Alexander Stein , Tony Lindgren , Sudeep Holla , Geert Uytterhoeven , John Stultz , Doug Anderson , Guenter Roeck , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-acpi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Consolidate the code that computes the flags to be used when creating a device link from a fwnode link. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 28 +++++++++++++++------------- include/linux/fwnode.h | 1 - 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 0ec2c4d5ffaa..296cfb714fe1 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1725,8 +1725,11 @@ static int __init fw_devlink_strict_setup(char *arg) } early_param("fw_devlink.strict", fw_devlink_strict_setup); -u32 fw_devlink_get_flags(void) +static inline u32 fw_devlink_get_flags(u8 fwlink_flags) { + if (fwlink_flags & FWLINK_FLAG_CYCLE) + return FW_DEVLINK_FLAGS_PERMISSIVE | DL_FLAG_CYCLE; + return fw_devlink_flags; } @@ -1936,7 +1939,7 @@ static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode) * fw_devlink_create_devlink - Create a device link from a consumer to fwnode * @con: consumer device for the device link * @sup_handle: fwnode handle of supplier - * @flags: devlink flags + * @link: fwnode link that's being converted to a device link * * This function will try to create a device link between the consumer device * @con and the supplier device represented by @sup_handle. @@ -1953,10 +1956,17 @@ static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode) * possible to do that in the future */ static int fw_devlink_create_devlink(struct device *con, - struct fwnode_handle *sup_handle, u32 flags) + struct fwnode_handle *sup_handle, + struct fwnode_link *link) { struct device *sup_dev; int ret = 0; + u32 flags; + + if (con->fwnode == link->consumer) + flags = fw_devlink_get_flags(link->flags); + else + flags = FW_DEVLINK_FLAGS_PERMISSIVE; /* * In some cases, a device P might also be a supplier to its child node @@ -2085,7 +2095,6 @@ static void __fw_devlink_link_to_consumers(struct device *dev) struct fwnode_link *link, *tmp; list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { - u32 dl_flags = fw_devlink_get_flags(); struct device *con_dev; bool own_link = true; int ret; @@ -2115,14 +2124,13 @@ static void __fw_devlink_link_to_consumers(struct device *dev) con_dev = NULL; } else { own_link = false; - dl_flags = FW_DEVLINK_FLAGS_PERMISSIVE; } } if (!con_dev) continue; - ret = fw_devlink_create_devlink(con_dev, fwnode, dl_flags); + ret = fw_devlink_create_devlink(con_dev, fwnode, link); put_device(con_dev); if (!own_link || ret == -EAGAIN) continue; @@ -2163,19 +2171,13 @@ static void __fw_devlink_link_to_suppliers(struct device *dev, bool own_link = (dev->fwnode == fwnode); struct fwnode_link *link, *tmp; struct fwnode_handle *child = NULL; - u32 dl_flags; - - if (own_link) - dl_flags = fw_devlink_get_flags(); - else - dl_flags = FW_DEVLINK_FLAGS_PERMISSIVE; list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { int ret; struct device *sup_dev; struct fwnode_handle *sup = link->supplier; - ret = fw_devlink_create_devlink(dev, sup, dl_flags); + ret = fw_devlink_create_devlink(dev, sup, link); if (!own_link || ret == -EAGAIN) continue; diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index fdf2ee0285b7..5700451b300f 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -207,7 +207,6 @@ static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode, fwnode->flags &= ~FWNODE_FLAG_INITIALIZED; } -extern u32 fw_devlink_get_flags(void); extern bool fw_devlink_is_strict(void); int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup); void fwnode_links_purge(struct fwnode_handle *fwnode); -- 2.37.1.559.g78731f0fdb-goog