Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8805796rwb; Thu, 24 Nov 2022 04:40:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4RuFvM2i46BllQC61X/eypOI4k3NzX8VFAJNJZwOQN13j09JkuiAtES2hjIcWsVVHdDRzE X-Received: by 2002:a63:e20:0:b0:440:6e64:fb02 with SMTP id d32-20020a630e20000000b004406e64fb02mr11466349pgl.84.1669293604276; Thu, 24 Nov 2022 04:40:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669293604; cv=none; d=google.com; s=arc-20160816; b=Zm5Li4Wai1h4ecZaUVTfqh+9v8l2xdXNJeRQayLBTMBmqlLTb9JtjsO/aFbHIgbD3O 6Ur3PoeDP6rufQypsLsWHSJbvRXivK/jugK1uAJ5kTzV9NcEAzzySoRQWRQGseTIpTLG F8T0Y/4qpMgcCGCh7HnGBVltv6sGd6kQwGmzkYhEyIMqZJxw8LGe1bVdHvyPMHFFnCuF BOftIZ7HvXPb3pOkrDP2u4gReLYCqLnY1B+1TTJnQVT/bwh7Fp7yUYog/XWXmq/jO+4R 5/eFxYMpQOkrPSwmat+mnEMrQ/zU2VxUMFdx+3T64v5CnnfIwSrgO0LSMjy3g8P4xHV1 Ha3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Ez2XsjOCMmolpJ9Tywgsg5+qRkuvUvrmAabRWe+l4ng=; b=vH5Qo/yQEcFqpHh8rLQ+R9oUvWVqcOxRuaRh2DHqd+wTaL4FMdahw5c5YZhmEc0WlY TUAVlPwfXE8gLSdV8vo4Ncxf6qqeDMH71phR0lSNktjTeOonpjBOSMSUA8tut5ZjSgBb LZYe2IeluczzYdv6RuwyVu/xudGHaqrCHzIopuLAFzJxE/KVzpezYSlgYqUAUZWjZS3Y SSvfWoAKiQgTCE7DeEtX0vEkKcya73QbLxkmBADDCfDIiH47DE3CBmKcoygu4mIRNYGi /LnTIUwfEx7ghp5h8lI0cPZAv+NHoEgPhxtVw3C1y/Nrxd6aZdCWFFuANF+mmN+t4V6J d14w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YUaMM5Ua; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a056a00228300b0052f80d1a588si1097320pfe.44.2022.11.24.04.39.53; Thu, 24 Nov 2022 04:40:04 -0800 (PST) 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=@intel.com header.s=Intel header.b=YUaMM5Ua; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229581AbiKXMSS (ORCPT + 86 others); Thu, 24 Nov 2022 07:18:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbiKXMSR (ORCPT ); Thu, 24 Nov 2022 07:18:17 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96CD9B2C; Thu, 24 Nov 2022 04:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669292296; x=1700828296; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=88JzpGsV3l3i1UU+gsY2jc1hU9imedkQHBbOB9+/b6U=; b=YUaMM5UaZqbyyEQpCuhXV1DJXir/vkLlfXYkOUdcTw/cKhvc2+y2aj2u perQAc4l5HrDbMZ8leMOjpNOOHKP8FiGTZBEgk6GSt5UR0DldnH1NcK7W oLexJdz/2LToiLelm4tIm2jLtj/Le4LxyMabLvcosKwivtKHhcaEf5Rst /ywUS2ubuFm7AMH1enD28QzWIbS1vmeBrj64EMK5xbzNvYaCz3Q7s/ZYl kAPsQsC8Rx3iDNuRYTp6odqnhI4Eg4mkdrBykL6AbFhEFt//1okNhVALo 3hrUk+ljQsoOt49nWNQwKyJPaaZXHwc8sCRX2Ilpk01lmXlt0HOzBtHNU g==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="312990215" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="312990215" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 04:18:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="887356125" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="887356125" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP; 24 Nov 2022 04:18:08 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oyBB6-00Gjps-36; Thu, 24 Nov 2022 14:18:04 +0200 Date: Thu, 24 Nov 2022 14:18:04 +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 , Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?iso-8859-1?Q?N=EDcolas_F_=2E_R_=2E_A_=2E?= Prado , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: Re: [PATCH v6 5/7] drm/bridge: anx7625: Register Type C mode switches Message-ID: References: <20221124102056.393220-1-treapking@chromium.org> <20221124102056.393220-6-treapking@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221124102056.393220-6-treapking@chromium.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 On Thu, Nov 24, 2022 at 06:20:54PM +0800, Pin-yen Lin wrote: > Register USB Type-C mode switches when the "mode-switch" property and > relevant port are available in Device Tree. Configure the crosspoint > switch based on the entered alternate mode for a specific Type-C > connector. ... > +static void anx7625_typec_two_ports_update(struct anx7625_data *ctx) > +{ > + if (ctx->typec_ports[0].dp_connected && ctx->typec_ports[1].dp_connected) > + /* Both ports available, do nothing to retain the current one. */ > + return; > + else if (ctx->typec_ports[0].dp_connected) This 'else' is redundant. I would rewrite above as /* Check if both ports available and do nothing to retain the current one */ if (ctx->typec_ports[0].dp_connected && ctx->typec_ports[1].dp_connected) return; if (ctx->typec_ports[0].dp_connected) > + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_NORMAL); > + else if (ctx->typec_ports[1].dp_connected) > + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_REVERSE); > +} ... > + data->dp_connected = (state->alt && state->alt->svid == USB_TYPEC_DP_SID && > + state->alt->mode == USB_TYPEC_DP_MODE); Parentheses are not needed. ... > + /* > + * <0 1> refers to SSRX1/SSTX1, and <2 3> refers to SSRX2/SSTX2. > + */ > + for (i = 0; i < num_lanes; i++) { > + if (port_num != -1 && port_num != dp_lanes[i] / 2) { > + dev_err(dev, "Invalid data lane numbers\n"); > + return -EINVAL; > + } According to Rob Linux must not validate device tree. If you need it, use proper YAML schema. > + port_num = dp_lanes[i] / 2; > + } ... > + if (!ctx->num_typec_switches) { > + dev_warn(dev, "No Type-C switches node found\n"); > + return ret; Why not to return 0 explicitly? > + } ... > + ctx->typec_ports = devm_kcalloc( Broken indentation. > + dev, ctx->num_typec_switches, sizeof(struct anx7625_port_data), > + GFP_KERNEL); > + if (!ctx->typec_ports) > + return -ENOMEM; ... > +struct anx7625_port_data { > + bool dp_connected; You can save some bytes on some architectures if move this to be last field. > + struct typec_mux_dev *typec_mux; > + struct anx7625_data *ctx; > +}; -- With Best Regards, Andy Shevchenko