From patchwork Thu Mar 17 15:45:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Krzyszkowiak X-Patchwork-Id: 553308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22D9CC433EF for ; Thu, 17 Mar 2022 15:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236147AbiCQPuK (ORCPT ); Thu, 17 Mar 2022 11:50:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236174AbiCQPuF (ORCPT ); Thu, 17 Mar 2022 11:50:05 -0400 Received: from comms.puri.sm (comms.puri.sm [159.203.221.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C682FBB931; Thu, 17 Mar 2022 08:48:45 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 09CCBE0142; Thu, 17 Mar 2022 08:48:15 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wm80spgabJ9o; Thu, 17 Mar 2022 08:48:14 -0700 (PDT) From: Sebastian Krzyszkowiak To: Heikki Krogerus , linux-usb@vger.kernel.org Cc: Sebastian Krzyszkowiak , Greg Kroah-Hartman , Sven Peter , =?utf-8?q?Guido_G=C3=BCnther?= , Angus Ainslie , Hector Martin , "Bryan O'Donoghue" , linux-kernel@vger.kernel.org, kernel@puri.sm Subject: [PATCH 5/7] usb: typec: tipd: Provide POWER_SUPPLY_PROP_PRESENT Date: Thu, 17 Mar 2022 16:45:16 +0100 Message-Id: <20220317154518.4082046-6-sebastian.krzyszkowiak@puri.sm> In-Reply-To: <20220317154518.4082046-1-sebastian.krzyszkowiak@puri.sm> References: <20220317154518.4082046-1-sebastian.krzyszkowiak@puri.sm> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This allows userspace and downstream supplies to know whether something is plugged in. Signed-off-by: Sebastian Krzyszkowiak Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index f3e8f1183f5b..874528b02a99 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -108,6 +108,7 @@ struct tps6598x { static enum power_supply_property tps6598x_psy_props[] = { POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_CURRENT_MAX, POWER_SUPPLY_PROP_VOLTAGE_MAX, }; @@ -756,6 +757,9 @@ static int tps6598x_psy_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_ONLINE: ret = tps6598x_psy_get_online(tps, val); break; + case POWER_SUPPLY_PROP_PRESENT: + val->intval = !!tps->partner; + break; case POWER_SUPPLY_PROP_CURRENT_MAX: ret = tps6598x_psy_get_max_current(tps, val); break;