Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp788094imm; Fri, 1 Jun 2018 09:31:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLE777Bk/F61du0xgeBLrvr6dboHGyAPQ0SdeRQtZG00hKAuB1SRftd40ns4c11SoQtmAOu X-Received: by 2002:a63:7209:: with SMTP id n9-v6mr9524781pgc.146.1527870704532; Fri, 01 Jun 2018 09:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527870704; cv=none; d=google.com; s=arc-20160816; b=T/s5U66oTe9CCvLp06LjLK8XQhmUUjKQ++KOE34IUfSykBThvoXF/ojRmR0ak1ybZk /4kDk1SL9XqZ1GaaFBpbfcFGmtjzRUhZ7EC39Fu24yGSda3RB8BuZZvLETMgGa/CFqit yUsreyK/1d2lcbjTSOL+D8mppczqnyUyzIdsAgvTzLeQulE6Ma+v4kDdLWCGWPQ3Hpfz O0SYS5wVYWOl5rBsp9llje70U5eRCFbvM0Z5kUjbYV+X4gOIrfpgxB8ytDt3dBC0/Klx b9dGT+uhssATSOPd7gWmMr4CH9006e+Uk1vlhnFmK1S3EAUOIVHuV1nFC5Pb/eQi26Dr Hfcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ELvGtA53IXB70AHS6KA7f6NBM58yvLKjbIjZV70ak1s=; b=SwU2/Yq4NSu4TkAUdPCGqX5ILq/N5xJlRh7EiDvg7x1o9nhwTcO43IzAni0lkXxUPS GqVoOnsM5M46XXbcFfM9LhstnVMKD88TLXucyOpYPftRXd2vBZtSBDLq1V+ah01086sj ycUjbp2aT4dZ0Iza8IpR7G54gV4v2HtSBbdQlii48UxmFO66KnX999fH0KUp6LxtZI7H lcFpX91RNtSf33fjEj2OFEyIrc6T5IllVVEOGgiQiQ9JJtB1ZtVUMreeES7goiULAXcS zKq4ExtojB0t8y5HJZB5k7BfIAytciS6ssUv0OdXUq40HKvgEEUg6JO17fyKWdpK3/eR 8bJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=txmqAPXr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p84-v6si39752518pfa.180.2018.06.01.09.31.30; Fri, 01 Jun 2018 09:31:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=txmqAPXr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752642AbeFAQbB (ORCPT + 99 others); Fri, 1 Jun 2018 12:31:01 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:46243 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751792AbeFAQa6 (ORCPT ); Fri, 1 Jun 2018 12:30:58 -0400 Received: by mail-qt0-f193.google.com with SMTP id h5-v6so24861031qtm.13; Fri, 01 Jun 2018 09:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ELvGtA53IXB70AHS6KA7f6NBM58yvLKjbIjZV70ak1s=; b=txmqAPXrc4PEM4wx/QTi6aqkJHEHyzwvgoWF5wOrrmvOzbzDN/SNBiU4d0F0zBApuy hR44t2Z7CeXMnfyvfPbqJYD3u3BVUSKyZOXVDIs0c5oPhQ865Cj7d9UsPb0X1lqksxEK q9xrxfkEK4zAKJ6jEQuZam+yUkJ/MW+AGGZbkkRH5gF0Sua5rvo5Rumb3GqAHCliwc22 i4hoS3bQW/HWCPof0DmEf0Lo2hRqWCu/UAU4/As0fPUMFyKPURFzvmmz6IRVw2F/KiC4 /11mBBUwGMft+5M3nAqy92u1C524u1ITVV7m65jqdIS815eKI2z6f1ISwl1d5IqCGBw1 Lmtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ELvGtA53IXB70AHS6KA7f6NBM58yvLKjbIjZV70ak1s=; b=h4JUpeoZq/ke8a9kvRoojQuXLuHTRfnxEzwZCwD2HJBdFWHHfcoFPtxMhOOr6skjxp gzqLekWd1qoHNaX3f0Ya1yqUk+Lo40jZ1705J2zkewcxIonWOjjK6PsZD0O87/6X+ot8 LVzAsWKDrHseYl21R4JHuRbMMXlpGOYeFxsB0jbC3dxDqzYAwOIb4wAMSALyL/icLZlO yqC6PAvxhcKeMcNGE0dS9QA2EbJjMoVJJLYqvxXUsmrffdLltKWc/67UIzfB8rNzGR+T b/jqABixCMJdJ/45ORyaWROc5LNxsFNzfjQCZlMINd4SrvW+ZRJ5vFwM0R3ohEvFpn8w KJ1w== X-Gm-Message-State: APt69E3d1JOXSyv33RJKtUnWWSL1nAGAEmy3Rd0AlquivS1UwvK9RRKb jdaZCXVyz1rJtQhucO2/29vpi3NELFeBycpebI9XXw== X-Received: by 2002:ac8:4106:: with SMTP id q6-v6mr11840399qtl.267.1527870658086; Fri, 01 Jun 2018 09:30:58 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:51:0:0:0:0:0 with HTTP; Fri, 1 Jun 2018 09:30:57 -0700 (PDT) In-Reply-To: <20180530031704.18597-4-fparent@baylibre.com> References: <20180530031704.18597-1-fparent@baylibre.com> <20180530031704.18597-4-fparent@baylibre.com> From: Enric Balletbo Serra Date: Fri, 1 Jun 2018 18:30:57 +0200 Message-ID: Subject: Re: [PATCH 3/3] power: supply: cros: add property to detect connected ports To: Fabien Parent Cc: Sebastian Reichel , Linux PM list , linux-kernel , gpain@baylibre.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Fabien, Many thanks for the patch. 2018-05-30 5:17 GMT+02:00 Fabien Parent : > When a port is connected but acting as a source, its 'online' and > 'status' properties are identical to a port that is not connected. This > makes it tedious for userspace to know for sure whether a port is > connected or not. > > This commit adds a new property 'present' to reflect whether a port > is connected or not. > Actually, there is an attempt to align the usage of the different properties between drivers [1]. According to current documentation, the present property is used to report whether a battery is present or not in the system. So, I am not sure if using the present property is the proper way to do it. Maybe Sebastian can give us some clues or preferences? [1] https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/tree/Documentation/ABI/testing/sysfs-class-power?h=for-next&id=91dabc54073324006d5eaba483679c47b6eb93a8#n159 Best regards, Enric > Signed-off-by: Fabien Parent > --- > drivers/power/supply/cros_usbpd-charger.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c > index 808688a6586c..d44ab35670ab 100644 > --- a/drivers/power/supply/cros_usbpd-charger.c > +++ b/drivers/power/supply/cros_usbpd-charger.c > @@ -32,6 +32,7 @@ struct port_data { > struct power_supply_desc psy_desc; > int psy_usb_type; > int psy_online; > + int psy_present; > int psy_status; > int psy_current_max; > int psy_voltage_max_design; > @@ -54,6 +55,7 @@ struct charger_data { > > static enum power_supply_property cros_usbpd_charger_props[] = { > POWER_SUPPLY_PROP_ONLINE, > + POWER_SUPPLY_PROP_PRESENT, > POWER_SUPPLY_PROP_STATUS, > POWER_SUPPLY_PROP_CURRENT_MAX, > POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, > @@ -65,6 +67,7 @@ static enum power_supply_property cros_usbpd_charger_props[] = { > > static enum power_supply_property cros_usbpd_dedicated_charger_props[] = { > POWER_SUPPLY_PROP_ONLINE, > + POWER_SUPPLY_PROP_PRESENT, > POWER_SUPPLY_PROP_STATUS, > POWER_SUPPLY_PROP_VOLTAGE_NOW, > }; > @@ -205,18 +208,22 @@ static int cros_usbpd_charger_get_power_info(struct port_data *port) > case USB_PD_PORT_POWER_DISCONNECTED: > port->psy_status = POWER_SUPPLY_STATUS_NOT_CHARGING; > port->psy_online = 0; > + port->psy_present = 0; > break; > case USB_PD_PORT_POWER_SOURCE: > port->psy_status = POWER_SUPPLY_STATUS_NOT_CHARGING; > port->psy_online = 0; > + port->psy_present = 1; > break; > case USB_PD_PORT_POWER_SINK: > port->psy_status = POWER_SUPPLY_STATUS_CHARGING; > port->psy_online = 1; > + port->psy_present = 1; > break; > case USB_PD_PORT_POWER_SINK_NOT_CHARGING: > port->psy_status = POWER_SUPPLY_STATUS_NOT_CHARGING; > port->psy_online = 1; > + port->psy_present = 1; > break; > default: > dev_err(dev, "Unknown role %d\n", resp.role); > @@ -362,6 +369,7 @@ static int cros_usbpd_charger_get_prop(struct power_supply *psy, > */ > if (ec_device->mkbp_event_supported || port->psy_online) > break; > + case POWER_SUPPLY_PROP_PRESENT: > case POWER_SUPPLY_PROP_CURRENT_MAX: > case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: > case POWER_SUPPLY_PROP_VOLTAGE_NOW: > @@ -380,6 +388,9 @@ static int cros_usbpd_charger_get_prop(struct power_supply *psy, > case POWER_SUPPLY_PROP_ONLINE: > val->intval = port->psy_online; > break; > + case POWER_SUPPLY_PROP_PRESENT: > + val->intval = port->psy_present; > + break; > case POWER_SUPPLY_PROP_STATUS: > val->intval = port->psy_status; > break; > -- > 2.17.0 >