Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp95472pxy; Tue, 20 Apr 2021 21:33:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAiV+lu43WBgIskVn5LTqNnNRWfHaP4oBhA7caQNgM+HC5cJbFOswhI94C6/2ijR43Qdpc X-Received: by 2002:a17:906:2a1b:: with SMTP id j27mr30513390eje.370.1618979591036; Tue, 20 Apr 2021 21:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618979591; cv=none; d=google.com; s=arc-20160816; b=MXMlHNzuHSsAbgcUiqlqWj2EJUS7N/jU8cd5R1SqHA+1Ar4evVsI0TAbUbHuyue5PY hAqB4Bb+lleVPyNoZknwDgf1kMsrlMGXHpsKx7glmakcMcowkpixAhFonx52gNf1o5Nf EddhO4ZllmmpqrXsDcwLLSwl75DFW4QUId4lq75f9vhVacXXZosSjIJCjoWcPk2et9Ov eluESE4tnvakO4JOY7VsIIU6t1BSIt8DwuCS6UGRt6QSx60/BG9c/02FzwqtTkajnBNx dVil9S4T5Bd++n2fSNpWyChPQgW656HaYC86AHrMR4In6CQManrZvFQpcCoFnL9d6X/y P8CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UFoByzns0zKKR0s/VA5elIm+z4agHNvAR8nRlMenl+0=; b=NfK75pErAfHpLBe2Ev7UD/Fgc03V7qz7S/6foEOVv+w1/LLvRZnGDyBPGwHP804WkM NTOtyXcPsWikCybG/076gMD4fVkM9FwXcFlwiSkWvZFAKhaAYFBuNbDznYeFjXoIWgB0 epdwWlItr/ie5OkcVTMRQG+p9+5egQdo/vlrkpFdQGsENRbPzFyOEKbq+X6PmKLn5uwz guTNihbY7nPY+Uh37sISjoF+X7JI5b3+Jh40I6lJaTFfSlnYN/AAJcTU0mwBkNRR8PiX B+vGAYMu1NcdSxOkOK680iStovQ1p5hTaG9uVYnQQDbGZu3TkmHbNj/YQCVx0/7/t4D6 THCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HXpye8Tn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si1008130edc.98.2021.04.20.21.32.47; Tue, 20 Apr 2021 21:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HXpye8Tn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbhDUEWA (ORCPT + 99 others); Wed, 21 Apr 2021 00:22:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234734AbhDUEV6 (ORCPT ); Wed, 21 Apr 2021 00:21:58 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEEDBC06174A for ; Tue, 20 Apr 2021 21:21:24 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id w10so28551754pgh.5 for ; Tue, 20 Apr 2021 21:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UFoByzns0zKKR0s/VA5elIm+z4agHNvAR8nRlMenl+0=; b=HXpye8TnFDEPX1Pim8Xayxqx78v/A8trwzZlMbGikEEtr18/JENjNcc2wK3zGfD0yz ilDiMpQ9iOBvsvPyt7ToBL+GXzidnH8B5rxqrlQLuLQvZcZ8BoLtZoyhOQCGjWdB2eDv 4EZm4aBGtHYKMfOuliWzxbr1ajk0PmJO7uG0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UFoByzns0zKKR0s/VA5elIm+z4agHNvAR8nRlMenl+0=; b=Gzi81EF8Vt+hgkehAyNF0GHgHNpzxyB37fj34hzpFGusBKvj9zKmbDbG8Z6NJ9hJ13 2TIJuak91z/aBuoOzi17ADySqtha1UCvn6dsexyJWuMjOu7bqtQPlnJhU2tL1sTyPTdL OIP9UAg646SPUaergd8QUNf1tjrWzENv1oWY3SIs3KnRH+it3F5iviUC4nrzTlM2kh7o 9Taaq+W/Ap/pWi7zh7VSaYfEza6/d6J5WpmOkqOkpKwNcGuYP7Tg8ChqFu9zjIjbzQoc POPekLOHYzbeAMX5TYnGqDdyJn7GavO/NN3D9Sb/cASjRPREoNvGBmbjys5pRZKLWKIK DOZQ== X-Gm-Message-State: AOAM533nc7ya+K4vMfOBEXUrga6hVXcBxtf23KeEikENQZn9QNwvQnsE TeErEXa/v/1FFcMU8Px2Bzg9GoIKELZ4kQ== X-Received: by 2002:a17:90b:e8b:: with SMTP id fv11mr8836631pjb.66.1618978884316; Tue, 20 Apr 2021 21:21:24 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:d3d3:f8d5:d9e2:fa85]) by smtp.gmail.com with ESMTPSA id n20sm576661pjq.45.2021.04.20.21.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:21:23 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH] platform/chrome: cros_ec_typec: Add DP mode check Date: Tue, 20 Apr 2021 21:21:09 -0700 Message-Id: <20210421042108.2002-1-pmalani@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are certain transitional situations where the dp_mode field in the PD_CONTROL response might not be populated with the right DP pin assignment value yet. Add a check for that to avoid sending an invalid value to the Type C mode switch. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index d3df1717a5fd..69646262fa9d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -486,6 +486,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec, return -ENOTSUPP; } + if (!pd_ctrl->dp_mode) { + dev_err(typec->dev, "No valid DP mode provided.\n"); + return -EINVAL; + } + /* Status VDO. */ dp_data.status = DP_STATUS_ENABLED; if (port->mux_flags & USB_PD_MUX_HPD_IRQ) -- 2.31.1.368.gbe11c130af-goog