Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp5094789qtf; Thu, 22 Jun 2023 08:16:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VYmZH4yy//ZaKGuz61pQC4jpCkaGkqS1ZZeeZmlq4jFJmq4Gh14fotoJE7dtUB1li6Gq2 X-Received: by 2002:a05:6808:650:b0:39a:ba7e:33bd with SMTP id z16-20020a056808065000b0039aba7e33bdmr20432060oih.0.1687446987227; Thu, 22 Jun 2023 08:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687446987; cv=none; d=google.com; s=arc-20160816; b=aXj1cxnKXdcHqolvDXqOdP5ayLBtNapK8Xdqfl7BPlzCbjNI7bIF1CUxS2KOufnxuI aCUi1e7Inl1J5KoWDs2a5rbFA07Zo4gic2+KZBcnKnUJIEkInhCzfguY8Ap+NCTdp4mF de0ibqzGb+BW4+Iftf1RISHPH7m3SqS4blRSi70SCSyvb8aEFdEYqUa9lbC42a4Gz5NG PWctHYKE+BCzHR/vZZVev8jvUao4MJ88DVDA/WO/PAx7ZoMoUA2n3gaLeCCVBLOywQQl l5lVh/QUclot4g5JJwEpsblPYwC6/3xo2joP6yMYWz1Gv/tBC52eg+fy76LUWvnaEk5Z rGyw== 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=6msxjfGSl7/M9KTU2PiCryY5ju9+3DU82TDMWlxq2Cw=; b=im8QLShpSCVQHK8bQCxJN+Zsnss1D+P7QEJuPBL8nm4mq0RMulkhMfMBubsK/4YrA0 oVGanI8RvQcYxl/T5SeiqpxUl3T54kmyH3xbDbGxoY1vFaOA4df+8BghbZwRAlw0NVMo sajVE96k61Rgk9iebZBxAy4kJ1bqmPgz6gVruucKqBjz+LR0I8kp1MgPN4CZsJ66XDEL ixk3IqXv5QQ1iryBrhue0axXXSfK32xVPQV5uZVm43oR8yYa+FBdxWzjezreGpl+P44V 04IK9LJp4DKFA44KDsmKpzEw8WiPqVVVVAItlNYxO7xEGqQIKW+43kOlAR3gymvyDXw3 1KFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=u81k2oss; 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 bv4-20020a632e04000000b005537cbc032esi3763674pgb.206.2023.06.22.08.16.15; Thu, 22 Jun 2023 08:16:27 -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=u81k2oss; 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 S232244AbjFVPFh (ORCPT + 99 others); Thu, 22 Jun 2023 11:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232249AbjFVPEx (ORCPT ); Thu, 22 Jun 2023 11:04:53 -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 9F71D10C1 for ; Thu, 22 Jun 2023 08:04:47 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-569e7aec37bso87130897b3.2 for ; Thu, 22 Jun 2023 08:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687446287; x=1690038287; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6msxjfGSl7/M9KTU2PiCryY5ju9+3DU82TDMWlxq2Cw=; b=u81k2ossffJeZlh2McBdWUMdmw5bSOOZ9+IZJXixIWqXinaFFtEvowwVnYqexAoXBk FKSwthoF4lqXQhJRcE64mXqPCsSfEoloq1p1ijm5if8G9ZnZaMusJzj7ZUX70vpiCBvR aaWr+3CjEpVy9JX88po4lTxc1QERRtodUS0jbPkfOfOv4agfTfCY86oMhxjCxZligekm a54R+an15LBK9YA1IQyYvZclaXk2HDro/gsGvRKfpjVClBdYSJVyZEOs21cFoK9zzuqU ZPHedBZgEBxmh6sT0+4z3YgTW5br1ZoGph3VNpo1KUejbQyzKDejqDJSmFZDlvoffBgL QAQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687446287; x=1690038287; 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=6msxjfGSl7/M9KTU2PiCryY5ju9+3DU82TDMWlxq2Cw=; b=COWGbaRPQHoH9Xgm33wlWdGcXz2IkuEesIEMYEV2nwbBqH+Je/5GzNl8zIeE86L2Es mRpWyuNAFwY299q3MZBHgTBjT/ToXV+xogu4vbGYQiBzNwY5ctDSYR6Glit2V6XPdNgU b7dwSQwAfiOU1YZnXR5ETDPpkWMqXTapytSCnFV4xxqZ5edYk77DLrSMT2fiEiahLrX7 AccVNmWtyDyOLzp11VPlxMynTBFn5iiJvU4PRZAy8tNblycyj7RID5/zb1KtPXdGtFtF 053//v/r8ZGrvPVnajkusmY+XdHOITJBQfSMYPd9R16ytPeNBQbw5sssHI9xbbI+Aq0J Azcw== X-Gm-Message-State: AC+VfDxIu1rqVMGoh/PG0Lu74TMbIy+HgLvIocSNI9NKaKZYHOZ3p6WQ i7SRTM0Q9ZwYc05wiJrXf95iDXpMejFz X-Received: from kyletso-p620lin01.ntc.corp.google.com ([2401:fa00:fc:202:b1ba:4098:b043:5e54]) (user=kyletso job=sendgmr) by 2002:a81:e24a:0:b0:56d:2abf:f0c with SMTP id z10-20020a81e24a000000b0056d2abf0f0cmr7755784ywl.10.1687446286806; Thu, 22 Jun 2023 08:04:46 -0700 (PDT) Date: Thu, 22 Jun 2023 23:04:21 +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-2-kyletso@google.com> Subject: [PATCH 1/3] usb: typec: Set port->pd before adding device for typec_port 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=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 When calling device_add in the registration of typec_port, it will do the NULL check on usb_power_delivery handle in typec_port for the visibility of the device attributes. It is always NULL because port->pd is set in typec_port_set_usb_power_delivery which is later than the device_add call. Set port->pd before device_add and only link the device after that. Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners") Signed-off-by: Kyle Tso --- drivers/usb/typec/class.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index faa184ae3dac..3b30948bf4b0 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -2288,6 +2288,8 @@ struct typec_port *typec_register_port(struct device *parent, return ERR_PTR(ret); } + port->pd = cap->pd; + ret = device_add(&port->dev); if (ret) { dev_err(parent, "failed to register port (%d)\n", ret); @@ -2295,7 +2297,7 @@ struct typec_port *typec_register_port(struct device *parent, return ERR_PTR(ret); } - ret = typec_port_set_usb_power_delivery(port, cap->pd); + ret = usb_power_delivery_link_device(port->pd, &port->dev); if (ret) { dev_err(&port->dev, "failed to link pd\n"); device_unregister(&port->dev); -- 2.41.0.162.gfafddb0af9-goog