Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp5092583qtf; Thu, 22 Jun 2023 08:13:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5NxbkjgkuUjI19KL+FAElLSD4nSfpjL3toYfngE/HVwkmIlJGTFl837xNki0w2+3xoKs3S X-Received: by 2002:a17:90a:f018:b0:25c:a96:93ca with SMTP id bt24-20020a17090af01800b0025c0a9693camr32994914pjb.15.1687446815475; Thu, 22 Jun 2023 08:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687446815; cv=none; d=google.com; s=arc-20160816; b=l8QyeEbwgeS//x+qZpnvq4ENF+5k9sWCcStezcHQNZXYLSxBKs4qtcJPRlBb8Ymoyf rkBdTV8rB0n5o1Ljumme86IClwj13lJSlMNb2rr+6Vz4XOXV96kSuJqJw72HwDIWS971 tCVNi0quh9KfqMYgcD7k3M0Pkx6IrNiqPp3ubtocC90sxsfG675kPdOPumybyQCPMUhQ Zpa24laKCb1GKHHh/cO9hnv/ACeyDMYKci6GnOgGBetSzJ8VtaE0NF955etWraVlSIG4 YntvrYFtpwz9G2Ixth1F2mjveE6EshgS8QdNROuWKjZjFzDgsRYz0eV8vhtogo83X9ss UN3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vZO0bLWsCUzvZiCFoSnFZwrtuz12yaBesFgNlWXPmT0=; b=T3dBp4jbC8ncseMYCBADP7W3X94VsfnFNOOW5mgdFgOLaFS+GEf7t6YUkcVuSQABkj QseufJ2W+juokIF1a3kncbipua3hzze2zVk20byyRCaES1ZLWY6rB8CXV5AoPbMY6bTm kRs+3z554EM0ziJ9he0hsmHxIZSi3ftqKNuW9tuEVNgnQ21EljRgeP8y+8+UuuHCcuoo 9tlMXOS4zfARYgrPe1NXXAYQ9EJ0RmEveN9d/kDu8F6mtX3JQmYLCe9AZp7Rzbz10wnp 5DSkCTstbzsPbnLzOsveIlRMb63WnnuFB/pvfmbT+0nJCDzMSZGKXG3zHBEH1qqGsIs7 rN9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=O4AQJntm; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx3-20020a17090b4b0300b00259c1100db5si3927415pjb.188.2023.06.22.08.13.23; Thu, 22 Jun 2023 08:13:35 -0700 (PDT) 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=@google.com header.s=20221208 header.b=O4AQJntm; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232289AbjFVPFk (ORCPT + 99 others); Thu, 22 Jun 2023 11:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232330AbjFVPE5 (ORCPT ); Thu, 22 Jun 2023 11:04:57 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F25A1FE3 for ; Thu, 22 Jun 2023 08:04:51 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-57003dac4a8so14974367b3.1 for ; Thu, 22 Jun 2023 08:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687446290; x=1690038290; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vZO0bLWsCUzvZiCFoSnFZwrtuz12yaBesFgNlWXPmT0=; b=O4AQJntmNrrzpA/osOkPU0d1y9/b3wfMewtlOXTOG5Pkz+psJggS/9wWf7apbcG6as cAnVTf9k+WP71BQEkHdZKkIv5GfJSWEm0zMljR8RE1LB5GBR4fbULYo6KFxYNwdDyWgy s5i3fr9/Km/GH6EjoblamoRcI6pmodeaHt6tKJweOD1zPHK/tceQ15xB5ThAPsg43Ekl KicSBo4d4GlRP7uFMqDKUsI5n3Ll1dgpa8WgqvyxbJxTIGdBW87/8XR3l2pLgSsv7T8/ D4Vsy9L8rsjqxAj9BuIASWaBIkOJWN/9I0o2Qadw0R4/wOwO6mtYgRhUz/srI1lEL9RO cgFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687446290; x=1690038290; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vZO0bLWsCUzvZiCFoSnFZwrtuz12yaBesFgNlWXPmT0=; b=A11M6dFBneoiZ0qsYtQl59bfA5CoV/o4OEBzcldGJ07XYlSvAF9TbIyNuNb76NLqez khSPb1tQr1SYWvLPgEV8AqldXYxVSkbqY0d4fyVAuGkkCSNgjsRWX1P5XO27ykvEj2fB 4+0FtYn10LsrnoN2XUecXiMcUFUU/TOFQGvrxAea6rVZEh+3rC9zI/mWk49cAN6fwrKS UA99b9OmTNv6B7EzKOLibjEDy0ftahndoWIiQCdNte0vADpmfON646yjLhzyT/kTTuiR o2ctWgbg1Nu6fTNmbpveq3hCoAkAA8YIClIqd83zcxzuOGK3GpESndlckWHhp8ka2gIZ aIXQ== X-Gm-Message-State: AC+VfDyWRQvw1T81FBKPyc80NHiXfGcbPmcud1yzDRg9dcvCtkziPpY9 lCG/ET2Yvm6RuUwu3ge7y6tHnlx/UpeO X-Received: from kyletso-p620lin01.ntc.corp.google.com ([2401:fa00:fc:202:b1ba:4098:b043:5e54]) (user=kyletso job=sendgmr) by 2002:a05:690c:b92:b0:565:8b2e:b324 with SMTP id ck18-20020a05690c0b9200b005658b2eb324mr12338278ywb.3.1687446290808; Thu, 22 Jun 2023 08:04:50 -0700 (PDT) Date: Thu, 22 Jun 2023 23:04:22 +0800 In-Reply-To: <20230622150423.3726894-1-kyletso@google.com> Mime-Version: 1.0 References: <20230622150423.3726894-1-kyletso@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230622150423.3726894-3-kyletso@google.com> Subject: [PATCH 2/3] usb: typec: Iterate pds array when showing the pd list From: Kyle Tso To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 The pointers of each usb_power_delivery handles are stored in "pds" array returned from the pd_get ops but not in the adjacent memory calculated from "pd". Get the handles from "pds" array directly instead of deriving them from "pd". Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners") Signed-off-by: Kyle Tso --- drivers/usb/typec/class.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 3b30948bf4b0..e7312295f8c9 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1277,8 +1277,7 @@ static ssize_t select_usb_power_delivery_show(struct device *dev, { struct typec_port *port = to_typec_port(dev); struct usb_power_delivery **pds; - struct usb_power_delivery *pd; - int ret = 0; + int i, ret = 0; if (!port->ops || !port->ops->pd_get) return -EOPNOTSUPP; @@ -1287,11 +1286,11 @@ static ssize_t select_usb_power_delivery_show(struct device *dev, if (!pds) return 0; - for (pd = pds[0]; pd; pd++) { - if (pd == port->pd) - ret += sysfs_emit(buf + ret, "[%s] ", dev_name(&pd->dev)); + for (i = 0; pds[i]; i++) { + if (pds[i] == port->pd) + ret += sysfs_emit(buf + ret, "[%s] ", dev_name(&pds[i]->dev)); else - ret += sysfs_emit(buf + ret, "%s ", dev_name(&pd->dev)); + ret += sysfs_emit(buf + ret, "%s ", dev_name(&pds[i]->dev)); } buf[ret - 1] = '\n'; -- 2.41.0.162.gfafddb0af9-goog