Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB288C64EC4 for ; Tue, 21 Feb 2023 11:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234354AbjBULsl (ORCPT ); Tue, 21 Feb 2023 06:48:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233678AbjBULsi (ORCPT ); Tue, 21 Feb 2023 06:48:38 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB68268B; Tue, 21 Feb 2023 03:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676980117; x=1708516117; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=CUAx3128p+wcaUqqwGRKUOEkNdn9/lm8qFQQoeWtsK8=; b=N9KVEOCAO0YpGXjkkz74c3iTGHJDIaqkTmQhu1RkpR3vrRSnrovCA2Es 7G/PRy06pokMBsKu9LBdHAc47VLAMwW3xXwzdfCSAh0sRSdrqtbDJN42W 8E1p4yFdUwfiIC51TDrvpOQmqamWtWTgHSRuGZM6j9reELfOEMQtJa5dJ RSi+xobmsV48qj0RDZcigJOFp17fx2Vv9woU+RxJTLHVfaXot7eWhxvjJ P0X9mxn6PMLOSDsIiBeNmWwUmWw+Yh6bpRTXbpYDFTQRM7/2XOFqSrUWY QoHL8ev+EhKy2idB5kmvSYunqks9MV3UN03v4/T3ZDipGT+lSCFw6tMyx g==; X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="332616851" X-IronPort-AV: E=Sophos;i="5.97,315,1669104000"; d="scan'208";a="332616851" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2023 03:48:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="795498978" X-IronPort-AV: E=Sophos;i="5.97,315,1669104000"; d="scan'208";a="795498978" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga004.jf.intel.com with ESMTP; 21 Feb 2023 03:48:27 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pUR8B-009wIJ-2y; Tue, 21 Feb 2023 13:48:23 +0200 Date: Tue, 21 Feb 2023 13:48:23 +0200 From: Andy Shevchenko To: Pin-yen Lin Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck , linux-kernel@vger.kernel.org, Hsin-Yi Wang , Marek Vasut , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Xin Ji , Lyude Paul , Allen Chen , devicetree@vger.kernel.org, AngeloGioacchino Del Regno , =?iso-8859-1?Q?N=EDcolas_F_=2E_R_=2E_A_=2E?= Prado , chrome-platform@lists.linux.dev, Javier Martinez Canillas , linux-acpi@vger.kernel.org, Stephen Boyd , Douglas Anderson , "Gustavo A. R. Silva" , Imre Deak , Jani Nikula , Kees Cook Subject: Re: [PATCH v12 03/10] drm/display: Add Type-C switch helpers Message-ID: References: <20230221095054.1868277-1-treapking@chromium.org> <20230221095054.1868277-4-treapking@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230221095054.1868277-4-treapking@chromium.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21, 2023 at 05:50:47PM +0800, Pin-yen Lin wrote: > Add helpers to register and unregister Type-C "switches" for bridges > capable of switching their output between two downstream devices. > > The helper registers USB Type-C mode switches when the "mode-switch" > and the "reg" properties are available in Device Tree. > > Signed-off-by: Pin-yen Lin ... > + fwnode_for_each_typec_mode_switch(port, sw) > + switch_desc->num_typec_switches++; > + > + if (!switch_desc->num_typec_switches) { > + dev_dbg(dev, "No Type-C switches node found\n"); > + return 0; > + } What about static inline unsigned int typec_mode_switch_node_count(... *port) { ... *sw; unsigned int count = 0; for_each_typec_mode_switch_node(port, sw) count++; return count; } And then it seems something like unsigned int count; count = typec_mode_switch_node_count(port); if (!count) { ... } _switches = count; ... > + switch_desc->typec_ports = devm_kcalloc( > + dev, switch_desc->num_typec_switches, Strange indentation. > + sizeof(struct drm_dp_typec_port_data), GFP_KERNEL); > + Redundant blank line. > + if (!switch_desc->typec_ports) > + return -ENOMEM; ... > +void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc) > +{ > + int i; unsigned? > + for (i = 0; i < switch_desc->num_typec_switches; i++) > + typec_mux_unregister(switch_desc->typec_ports[i].typec_mux); > +} ... > #include > #include > +#include I don't see users of this. But a few forward declarations are missing. > #include > #include ... > +#define fwnode_for_each_typec_mode_switch(port, sw) \ > + fwnode_for_each_child_node((port), (sw)) \ > + for_each_if(fwnode_property_present((sw), "mode-switch")) Please don't use fwnode namespace (see above), something like #define for_each_typec_mode_switch_node(port, sw) \ ... -- With Best Regards, Andy Shevchenko