Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2229380pxm; Fri, 4 Mar 2022 11:53:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXK7wdxc8rrRHCGwCLqBqcm99YB885q904xbx897wKlFsoJNiu26aFs05KkjxVvz1GQeOH X-Received: by 2002:a17:90a:4b4c:b0:1be:e5da:dc89 with SMTP id o12-20020a17090a4b4c00b001bee5dadc89mr12489688pjl.45.1646423604353; Fri, 04 Mar 2022 11:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646423604; cv=none; d=google.com; s=arc-20160816; b=dOA33/CSGSbL/1/p3WK5xp6mZVXBK4ZYfB/vMTEN5k7bBArCoySJbdxEmBRdG5rDSn IJSTkUlH0DdhwxCpPCU1Xmu7VvCbWAPn0c5kQlbRYSaw8JVWqxSPkQV+yC9gS0RR1k5b iG6NH+ZZIZsEU4etxUevNJXz6xkHOwfGmyFXZnAhU3rLHHShRl3FSq0i7hJ74Dzz0dnD LFnVQgO14dKUGef+99MrqTxFlBzvgNlN/qjYXE4oyaT8Zccw2BFFJO0aO4ZSBnSlpXgC VP+wwrNGA47btDXSU+Hf/KZ3ZRa467iCXrtTZadgDiPTOMEzBExCIaa6RuFKrDz8ghj3 lZLQ== 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=HVo+Dc5vspkzn94ThW8fA3HR3U9xqjL0pf2ClhwXOaw=; b=a1MyK52OxWAF/c7JWIISwgj5DwS7AD7qg8LcpBa0BDbY9jfGIxuci165bYPzUOM7Kc 4wju1iP05Rt0iiFsTMxsga43uYlI7kz+Pt+H+i/DzfPOpZPbee1MrK4vM8Uvk7zqMfXj 5XPbdjOjK4EFN15FqWQ2On6Ydz65zBpfg4mzs8HmTMbBlfTtUxdJqQhRhe8Sz2hNGcgd wSZL9B01f/H0bEx6mG3jcoaTgoCPjoZZ+BQL+XRN82wSH5JtjFrHnC4bax18w5KPdWRd ef0jcPd7mFJVF9gIRM7bLH1S15q9GyR/aqNPuBpLHqXFrsh0BOMIkfyAXtJLKFScV+mW pTwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nOzgqITR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h14-20020a056a00230e00b004e1bf2a3379si5796540pfh.347.2022.03.04.11.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 11:53:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nOzgqITR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 24CC023F3CB; Fri, 4 Mar 2022 11:22:03 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbiCDN43 (ORCPT + 99 others); Fri, 4 Mar 2022 08:56:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbiCDN42 (ORCPT ); Fri, 4 Mar 2022 08:56:28 -0500 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3606619D634; Fri, 4 Mar 2022 05:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646402141; x=1677938141; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=c4N+V43B3i0c7JWoTDHNDNh4DYCcViChbXoi/oxgYJ4=; b=nOzgqITRsYTt3w3jH6R4vrDtROCF2kN2Q9RZ329aWoWgCxUGPkyE9FpJ 0bKMjYn5S7aBex4XDPD8gm24Tm4uJCFYISHl/XYMwPY/TtRp+WQ8OgQoG O5b+8Ex3mDwyKX4QJECQeZioe8utkAHvxS7bbjPJ2/FaKr/rzGBbaqU5Z d78vi5BtDMNxNxJbdZWGkSzfNsM5fqJ5BARrDdhoxVHIAOgg1PSnEV0qn mS9EmC3sZ8Y/x+XFOlomzjmmbAmQjSEMgU4s0Ex8EdbOMDIM42NKGbcXj QpIHWBjW0HADYY/407JMXkOxFCUm/SkNXVVRQ1sMsi8pzn3nWuWdMwXL8 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="314693087" X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="314693087" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 05:55:40 -0800 X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="511854676" Received: from smile.fi.intel.com ([10.237.72.59]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 05:55:37 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nQ8OR-00BF8a-QX; Fri, 04 Mar 2022 15:54:51 +0200 Date: Fri, 4 Mar 2022 15:54:51 +0200 From: Andy Shevchenko To: Bjorn Andersson Cc: Rob Herring , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Hans de Goede , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Dmitry Baryshkov Subject: Re: [PATCH v3 4/6] typec: mux: Allow multiple mux_devs per mux Message-ID: References: <20220303223351.141238-1-bjorn.andersson@linaro.org> <20220303223351.141238-4-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220303223351.141238-4-bjorn.andersson@linaro.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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, Mar 03, 2022 at 02:33:49PM -0800, Bjorn Andersson wrote: > In the Qualcomm platforms the USB/DP PHY handles muxing and orientation > switching of the SuperSpeed lines, but the SBU lines needs to be > connected and switched by external (to the SoC) hardware. > > It's therefor necessary to be able to have the TypeC controller operate > multiple TypeC muxes and switches. Use the newly introduced indirection > object to handle this, to avoid having to taint the TypeC controllers > with knowledge about the downstream hardware configuration. > > The max number of devs per indirection is set to 3, which account for > being able to mux/switch the USB HS, SS and SBU lines, as per defined > defined in the usb-c-connector binding. This number could be grown if > need arrises at a later point in time. ... > + for (i = 0; i < count; i++) { > + if (IS_ERR(sw_devs[i])) { > + err = PTR_ERR(sw_devs[i]); > + goto put_sw_devs; > + } > + } > > - sw->sw_dev = sw_dev; > + for (i = 0; i < count; i++) { > + WARN_ON(!try_module_get(sw_devs[i]->dev.parent->driver->owner)); > + sw->sw_devs[i] = sw_devs[i]; > + } > + > + sw->num_sw_devs = count; > > return sw; > + > +put_sw_devs: > + for (i = 0; i < count; i++) { Shouldn't it be while (i--) ? > + if (!IS_ERR(sw_devs[i])) We may get rid of this check if we guarantee that the device is NULL. > + put_device(&sw_devs[i]->dev); > + } > + > + kfree(sw); > + > + return ERR_PTR(err); > } ... > + for (i = 0; i < count; i++) { > + if (IS_ERR(mux_devs[i])) { > + err = PTR_ERR(mux_devs[i]); > + goto put_mux_devs; > + } Ditto. > + } ... > +put_mux_devs: > + for (i = 0; i < count; i++) { > + if (!IS_ERR(mux_devs[i])) > + put_device(&mux_devs[i]->dev); > + } Ditto. -- With Best Regards, Andy Shevchenko