Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4513963pxf; Tue, 16 Mar 2021 15:57:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpVq9Nz8a0GYb8IVsSvjxa3NaMnDFxAhzw8OA5Fr9lxGBbQ8+yNEDVUWDV2wjsaWPvk70n X-Received: by 2002:a17:906:f0d0:: with SMTP id dk16mr32706568ejb.48.1615935443440; Tue, 16 Mar 2021 15:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615935443; cv=none; d=google.com; s=arc-20160816; b=iCDiIzMrPY3oi5KLf0IwwAdeafq3NwrwuA93DUmsdK3qsp4Ku7yHbughw9TAydsHw7 dg8jwJ19AbyWwypJsDeaUC5c3KV2RzXxxLL8BhQgc+Quym/18nxHxI2QF+VX+G6CVH2G vA0FMaWN6hHwcPe/qPsj3xTwjiVCkA2iDy/OL+0Rhs/JC6ix+9DlUX+vSrXdirERwXWO s78j6ufqVRvk1f5m1fYl4NIMDZW0yAUHU+RahNAv/YQaEInlP3P9mh+4r1ut+p1+njAP wjUCK0wG8eeuwvf6LgJL/SxoG6PqxmGPcrZatJkv4vSyrv8UdRN/kE4RhFv42muFcgV4 GaqA== 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:mime-version:message-id:date :dkim-signature; bh=6DfkZN7WQbO1dvbjrdbjBHr+qM1rCOx1KfIaAxgNHAw=; b=xMzKe/c+MaBduNu2jegseTdx6sQe0gXJ6dvxmnFeg3Sj1NqAa2Wvr82lIspm3UZT60 xpeUNGcavOX5iYO3DmnC0ZKsGOT23QGF+tE/eoEfWiNctIeIlonq/5b3ZbjyHAea55Jb i34jZeAcallLDlzIU8rmYrZI82Tf/337KEQxB7b7laRHpguCips6AujKWLZoJsB3SiHb xtNjI7CushRgGTicB8JK9TaWvmmGifnTootYE/1SJ0hMAkUGhcziUdpPYwFUKt+r7wq3 nZouQMGVFkosGJE+ZcB2gEn29o/HxABRTB8dqsJ44kZEkrfxpwP1xnP3Y4UawOY5t2sq ph4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RmnPRgfn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si14302965eds.451.2021.03.16.15.57.00; Tue, 16 Mar 2021 15:57:23 -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=@google.com header.s=20161025 header.b=RmnPRgfn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbhCPV5E (ORCPT + 99 others); Tue, 16 Mar 2021 17:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbhCPV5D (ORCPT ); Tue, 16 Mar 2021 17:57:03 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E49AC061756 for ; Tue, 16 Mar 2021 14:57:03 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id da16so26305219qvb.2 for ; Tue, 16 Mar 2021 14:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=6DfkZN7WQbO1dvbjrdbjBHr+qM1rCOx1KfIaAxgNHAw=; b=RmnPRgfnot0nvRyG2KYcw9NGB4ZvTwu9Igo7aDUa0v8DYGP12qcseVIbhjRiNJ/+uC X9Zz8L+09dHMJQYpEyyoKSBmkx+o9d26i0jb/7HcIeElMU4NsXQerYAwjgl6BuXcsmwe OdjYwfyVGMHkDjpdcfAZBkE0p6L2wUVUN4q+77H9EQe8iEebfD49iT9/tKwdrKdXdNs2 ekLoYHO6ptkiLYW8sxBlcmi+iOy+9nmqp2W1dbZwWZvNSZIwR3ON1Dugrl45Hr942Oxn VdX3JYqqT/ei+W/6E6cNbOd92PzpKmZNczxv5EnLoR+JVf8YIwJ8rL9vue1on0rneoum nBYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=6DfkZN7WQbO1dvbjrdbjBHr+qM1rCOx1KfIaAxgNHAw=; b=Tb/+pm1qYXvTIJAJMvVFdZ5hInETbZXrAtVGSflVsR1wZqBH2PsGb1K+MpdsYNN6Y6 w87s+9EkUf7BEOf8+3ebFLqAf2g81YAsrtFUHYm+9n3TLAoLNw4+1SStIY9jdtB746D5 JoliCG9wJoLKHBRPHARrLEA2oqkytfcHWMmgfErqKWN4cdeIeVVdky4/Oz/mUMAdkACD kr7QRlOSRiboZvFNAyHPrDTYAHYBRGEIs0aSg1sI1enY0WA/vBJVRt2eaT7rBPKdZNoO Fh0fV4xEDPSKXO713MfJscuk4uyMWBLBM/EGh2QnvZQbNr7lytvL21NNMlLpZv4Dzd1Y Oh6Q== X-Gm-Message-State: AOAM5307Iixw86GmZMme2U5ntiUzjisoPVg0ut/5dg9qD1tFPxpmwBuG VCCgD3+tek53BVFexwNbJUPHzl/dXfk= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:e53d:77e7:f975:af74]) (user=badhri job=sendgmr) by 2002:a0c:8ec1:: with SMTP id y1mr2065111qvb.11.1615931822559; Tue, 16 Mar 2021 14:57:02 -0700 (PDT) Date: Tue, 16 Mar 2021 14:56:57 -0700 Message-Id: <20210316215657.387357-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Thomson , Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tcpm-source-psy- does not invoke power_supply_changed API when one of the published power supply property is changed. power_supply_changed needs to be called to notify userspace clients(uevents) and kernel clients. Fixes: f2a8aa053c176("typec: tcpm: Represent source supply through power_supply") Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 11d0c40bc47d..e8936ea17f80 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -945,6 +945,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv) port->supply_voltage = mv; port->current_limit = max_ma; + power_supply_changed(port->psy); if (port->tcpc->set_current_limit) ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv); @@ -2931,6 +2932,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, port->pps_data.supported = false; port->usb_type = POWER_SUPPLY_USB_TYPE_PD; + power_supply_changed(port->psy); /* * Select the source PDO providing the most power which has a @@ -2955,6 +2957,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, port->pps_data.supported = true; port->usb_type = POWER_SUPPLY_USB_TYPE_PD_PPS; + power_supply_changed(port->psy); } continue; default: @@ -3112,6 +3115,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) port->pps_data.out_volt)); port->pps_data.op_curr = min(port->pps_data.max_curr, port->pps_data.op_curr); + power_supply_changed(port->psy); } return src_pdo; @@ -3347,6 +3351,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge) return ret; } port->vbus_charge = charge; + power_supply_changed(port->psy); return 0; } @@ -3530,6 +3535,7 @@ static void tcpm_reset_port(struct tcpm_port *port) port->try_src_count = 0; port->try_snk_count = 0; port->usb_type = POWER_SUPPLY_USB_TYPE_C; + power_supply_changed(port->psy); port->nr_sink_caps = 0; port->sink_cap_done = false; if (port->tcpc->enable_frs) @@ -5957,7 +5963,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy, ret = -EINVAL; break; } - + power_supply_changed(port->psy); return ret; } @@ -6110,6 +6116,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) err = devm_tcpm_psy_register(port); if (err) goto out_role_sw_put; + power_supply_changed(port->psy); port->typec_port = typec_register_port(port->dev, &port->typec_caps); if (IS_ERR(port->typec_port)) { -- 2.31.0.rc2.261.g7f71774620-goog