From patchwork Mon Mar 22 12:27:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 406781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79BC5C433E2 for ; Mon, 22 Mar 2021 12:34:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56C7C619BD for ; Mon, 22 Mar 2021 12:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbhCVMdj (ORCPT ); Mon, 22 Mar 2021 08:33:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:55618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbhCVMcw (ORCPT ); Mon, 22 Mar 2021 08:32:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DF5B60C3D; Mon, 22 Mar 2021 12:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416372; bh=HduXnkpgaGEVxGOkeCW2FrCsDahfW4MfHaIsYuQ3T9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XgKClUz2U4VngHq6TPD5RhDSYoEY9FeP6Gl/u0y4s5Hm+EuRGHZNhD8x5CNW/aOCQ vg+Y1PnJ8pYdkBzyQIJOIMUGBj7ZuJ4WJZw0kAfMr2UYL63tnqQ46rQnQBqNGyjGyl gGLS3DWHuweEI5hIPpt2c4Ncmrhyb1RAbNZ1AUlo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Heikki Krogerus , Badhri Jagan Sridharan Subject: [PATCH 5.11 082/120] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- Date: Mon, 22 Mar 2021 13:27:45 +0100 Message-Id: <20210322121932.413344728@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121929.669628946@linuxfoundation.org> References: <20210322121929.669628946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Badhri Jagan Sridharan commit 86629e098a077922438efa98dc80917604dfd317 upstream. 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") Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus Signed-off-by: Badhri Jagan Sridharan Cc: stable Link: https://lore.kernel.org/r/20210317181249.1062995-1-badhri@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -797,6 +797,7 @@ static int tcpm_set_current_limit(struct 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); @@ -2345,6 +2346,7 @@ static int tcpm_pd_select_pdo(struct tcp 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 @@ -2369,6 +2371,7 @@ static int tcpm_pd_select_pdo(struct tcp port->pps_data.supported = true; port->usb_type = POWER_SUPPLY_USB_TYPE_PD_PPS; + power_supply_changed(port->psy); } continue; default: @@ -2526,6 +2529,7 @@ static unsigned int tcpm_pd_select_pps_a 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; @@ -2761,6 +2765,7 @@ static int tcpm_set_charge(struct tcpm_p return ret; } port->vbus_charge = charge; + power_supply_changed(port->psy); return 0; } @@ -2935,6 +2940,7 @@ static void tcpm_reset_port(struct tcpm_ 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) @@ -5129,7 +5135,7 @@ static int tcpm_psy_set_prop(struct powe ret = -EINVAL; break; } - + power_supply_changed(port->psy); return ret; } @@ -5281,6 +5287,7 @@ struct tcpm_port *tcpm_register_port(str 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)) {