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 D7AB8C64EC4 for ; Tue, 21 Feb 2023 11:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234106AbjBULhX (ORCPT ); Tue, 21 Feb 2023 06:37:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234201AbjBULhR (ORCPT ); Tue, 21 Feb 2023 06:37:17 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2965265B6; Tue, 21 Feb 2023 03:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676979411; x=1708515411; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=7ANYBaN3BRH6hFLUyPVgrXSlXGHP/g9XCIrZnmRZ6dA=; b=PKLY8I99MXQRA4zDr/tiszBffrLyM6qzAbeUfAkX26Ju39vzfjlj42vX 3E12KuqTzf9gw06J+itv0MrdvdtCEsSADwrZz2xmN/SRfvd1TgWx+Z2dt uBl7ZI4K9+bPGiMHvRy2U0GX7a0+qBEQPBS3/xSOJRXc93Ej3JgAFIEOx bN6Nu0Z+9/0VRsUclMP1k2v4xisBZ/a/fqvrpBWajIiSNMVxIiNlqLFci 3F9an3S+zu+fPPVoPcBHcglRDQW74h0D2NjJAvUsO9UMT83KS45XyBS0G fSbi1eljZ54/uIbBgHaheNn0ScQvFfqou/5md5joHgEP5Wy+R9rSUSeGA g==; X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="332614504" X-IronPort-AV: E=Sophos;i="5.97,315,1669104000"; d="scan'208";a="332614504" 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:36:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="795494041" X-IronPort-AV: E=Sophos;i="5.97,315,1669104000"; d="scan'208";a="795494041" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga004.jf.intel.com with ESMTP; 21 Feb 2023 03:36:24 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pUQwW-009w6O-31; Tue, 21 Feb 2023 13:36:20 +0200 Date: Tue, 21 Feb 2023 13:36:20 +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 , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Subject: Re: [PATCH v12 07/10] drm/bridge: anx7625: Register Type C mode switches Message-ID: References: <20230221095054.1868277-1-treapking@chromium.org> <20230221095054.1868277-8-treapking@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230221095054.1868277-8-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:51PM +0800, Pin-yen Lin wrote: > Register USB Type-C mode switches when the "mode-switch" property and > relevant ports are available in Device Tree. Configure the crosspoint > switch based on the entered alternate mode for a specific Type-C > connector. > > Crosspoint switch can also be used for switching the output signal for > different orientations of a single USB Type-C connector, but the > orientation switch is not implemented yet. A TODO is added for this. ... > +static void anx7625_typec_two_ports_update(struct anx7625_data *ctx) > +{ > + int i; unsigned? + Blank line. > + /* Check if both ports available and do nothing to retain the current one */ > + if (ctx->port_data[0].dp_connected && ctx->port_data[1].dp_connected) > + return; > + > + for (i = 0; i < 2; i++) { > + if (ctx->port_data[i].dp_connected) > + anx7625_set_crosspoint_switch(ctx, > + ctx->port_data[i].orientation); > + } > +} ... > + ctx->port_data[port->port_num].dp_connected = > + state->alt && state->alt->svid == USB_TYPEC_DP_SID && I would move the first parameter of && to the separate line for slightly better readability. > + state->alt->mode == USB_TYPEC_DP_MODE; ... > + for (i = 0; i < switch_desc->num_typec_switches; i++) { > + struct drm_dp_typec_port_data *port = &switch_desc->typec_ports[i]; > + struct fwnode_handle *fwnode = port->fwnode; > + > + num_lanes = fwnode_property_count_u32(fwnode, "data-lanes"); > + Redundant blank line. > + if (num_lanes < 0) { > + dev_err(dev, > + "Error on getting data lanes count from %pfwP: %d\n", > + fwnode, num_lanes); > + ret = num_lanes; Can be written differently: > + goto unregister_mux; > + } ret = ... if (ret < 0) { ... } num_lanes = ret; What if it's 0? > + ret = fwnode_property_read_u32_array(fwnode, "data-lanes", > + dp_lanes, num_lanes); > + if (ret) { > + dev_err(dev, > + "Failed to read the data-lanes variable: %d\n", > + ret); > + goto unregister_mux; > + } > + > + ctx->port_data[i].orientation = (dp_lanes[0] / 2 == 0) ? > + TYPEC_ORIENTATION_REVERSE : TYPEC_ORIENTATION_NORMAL; > + ctx->port_data[i].dp_connected = false; > + } > + complete_all(&ctx->mux_register); > + > + return 0; > + > +unregister_mux: > + complete_all(&ctx->mux_register); > + anx7625_unregister_typec_switches(ctx); > + return ret; > +} -- With Best Regards, Andy Shevchenko