Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp598059pxf; Wed, 17 Mar 2021 11:17:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz03E39Li5kJi3h77xTxbouMvdRuhA/KWQ5cGEVg4afsZnBgQ1SacuiScNCyOZRQYmbATeC X-Received: by 2002:a17:906:4150:: with SMTP id l16mr37203659ejk.90.1616005020559; Wed, 17 Mar 2021 11:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616005020; cv=none; d=google.com; s=arc-20160816; b=gEl+QDR/DzOCoBYI3hn/0wWrTO/cKv6tk23pwrzw3ICPSBYp6frc7TN4L6OozkePcb laMrLkkySkVlxjOKg1ZuBMWpTKIjV8Rb+AxAeYy9VUFa9oO9UtVhSqpyhtTqZ3sMomtb dYCJ7dOxsnmfImGZ0Ec4PtS5/CcXByWLK7e7Yth/9/f3UBFwdTsoex1/enMqJb3UUcb+ TwuuC/Ue00/BeyOzc90Fnah8ewgVDs7IUBgea9nSKe5Yb6u+volWj5VI46mi7j/c2ugn UuuGSfITgirdyrhYPWe8UjauQ7eGFP/eL7hhvpGn1xIcACFAa8fomzuXBH2AOyqFFL3x N8Wg== 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=VJxxc1aWYvyrrwlQVS/dPT/va70MajmNF5/Ovh5tHqY=; b=Ulq0s737zRRchVwNZS5qzkqattTVoPKGQwr1jG/Y01raKWNTrmI2zA7RDhaDhmv9RV rqg5XzliK1PzD7ryFLTr3rQQ4cb0jILH5viGQdwzbOYKYhEcRpac4NfLgF4LRVWXrtwY fpByEnzYP9HkiSE4qldcgJvyPk+RLSoCVDjUDB6BMScIiAdDmeFmNUGnVQHZXKj8INSH c9wrRhV1WUUpcs7UMFW6gg/2W99yRwMEr4mf184V0TRSRIgeO2I+sMBQndZrfh3tZjnl ak8K/j5dOHKIpnPpU5h9vgAkGevV9bF2fA+Tvkb4smmOytDJnBU/uRIWsV1BPuvkQStx qo6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kyQ8Hiv4; 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 e12si17091005ejs.501.2021.03.17.11.16.35; Wed, 17 Mar 2021 11:17:00 -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=kyQ8Hiv4; 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 S232988AbhCQSN1 (ORCPT + 99 others); Wed, 17 Mar 2021 14:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbhCQSMx (ORCPT ); Wed, 17 Mar 2021 14:12:53 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A262C06175F for ; Wed, 17 Mar 2021 11:12:53 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id k68so29902143qke.2 for ; Wed, 17 Mar 2021 11:12:53 -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=VJxxc1aWYvyrrwlQVS/dPT/va70MajmNF5/Ovh5tHqY=; b=kyQ8Hiv4GYcoi4+iUdOGxaPKf5RLY4MOrgjWePaGv9iAOuYjxdMqJFk1uR/pqtJtHk XeYUeXcy79FaEhJ4181E7nrIVXSXkQLf3Ffm9UDzQuIYyIh1S/fSP0Qi2cAxuzjmDs2T AwHsNTd/tZDGjVvy1EPWNxnGm4xRYf8dXcXlHX1hGYa13+6oItJxzotqfQBwyJnvVtUk onK7S7VXY1ktUjilkSDedQsLEpxW36TPwbdbGDdkbn0iqTx37ESwwlvewXZfttSE2Jeb EmRgHWR8B7h81/49d32oY5XGve3qANSXjiroAjT6pq5nSZ+8x+MiU8DTf+hZ3Pf5sBOF tP3A== 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=VJxxc1aWYvyrrwlQVS/dPT/va70MajmNF5/Ovh5tHqY=; b=p3hd2GmWevmEA+m36yvntcvGLlxvlLYd8JyELzDa/ONgCIBlWmG1nHXr+isqgy8tcq /4oXQxEBFOW3IYo1XsgmMBNcnxq64ymsPb+2tHlE1HiO80WM3YHvbRd+rAzoFP/gKwvq 3ViUXBjUOZxxvJhgJntKXfoOsthAiTIOq2f77cHsejUndE5avqLeq3e1I+AJZ9kc7vva MokLdDgdPVLfavRpvhXIBLU6mwGgp9zxBmpgsvBNDHmYkXm6qfKoZUn1YfVKV71b0Mc7 w/IGhpFKdhi9MJaQCy6XVWdu1yyco8jQfiSew2bnU3UHbDZsNsGHmbsZa8oGHKctUYqW bQZg== X-Gm-Message-State: AOAM531MSzheWqrfHBr/XN4pNlzFV9W3rHDm6wEef1bAsU8DNGeBrTVb nVN4SN1lxsgLfYpCl2No0Mlypnax2o0= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:dc6b:2250:2aa4:b316]) (user=badhri job=sendgmr) by 2002:a05:6214:16c1:: with SMTP id d1mr370034qvz.29.1616004772217; Wed, 17 Mar 2021 11:12:52 -0700 (PDT) Date: Wed, 17 Mar 2021 11:12:48 -0700 Message-Id: <20210317181249.1062995-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v2] 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 , stable@vger.kernel.org, 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 properties 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 Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus --- Changes since V1: - Fixed commit message as per Guenter's suggestion - Added Reviewed-by tags - cc'ed stable --- 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