Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbdHFOYg (ORCPT ); Sun, 6 Aug 2017 10:24:36 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:35804 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbdHFOYe (ORCPT ); Sun, 6 Aug 2017 10:24:34 -0400 Subject: Re: [PATCH 09/18] staging: typec: fusb302: Use tcpm_set_current_limit_psy To: Hans de Goede , Darren Hart , Andy Shevchenko , Wolfram Sang , Sebastian Reichel , Greg Kroah-Hartman , Heikki Krogerus Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Liam Breck , Tony Lindgren , linux-pm@vger.kernel.org, devel@driverdev.osuosl.org References: <20170806123555.5124-1-hdegoede@redhat.com> <20170806123555.5124-10-hdegoede@redhat.com> From: Guenter Roeck Message-ID: Date: Sun, 6 Aug 2017 07:24:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170806123555.5124-10-hdegoede@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2211 Lines: 58 On 08/06/2017 05:35 AM, Hans de Goede wrote: > Register a power_supply and use tcpm_set_current_limit_psy as > set_current_limit so that another driver (e.g. the charger driver) can > pick the limit up and configure the system accordingly. > > Signed-off-by: Hans de Goede > --- > drivers/staging/typec/fusb302/fusb302.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c > index 1d8c9b66df2f..e1e08f57af99 100644 > --- a/drivers/staging/typec/fusb302/fusb302.c > +++ b/drivers/staging/typec/fusb302/fusb302.c > @@ -854,17 +854,6 @@ static int tcpm_set_vbus(struct tcpc_dev *dev, bool on, bool charge) > return ret; > } > > -static int tcpm_set_current_limit(struct tcpc_dev *dev, u32 max_ma, u32 mv) > -{ > - struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, > - tcpc_dev); > - > - fusb302_log(chip, "current limit: %d ma, %d mv (not implemented)", > - max_ma, mv); > - > - return 0; > -} > - Same comment as before. I think the fusb code should do what tcpm_set_current_limit_psy is doing, ie register with a power supply. > static int fusb302_pd_tx_flush(struct fusb302_chip *chip) > { > return fusb302_i2c_set_bits(chip, FUSB_REG_CONTROL0, > @@ -1208,7 +1197,7 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev) > fusb302_tcpc_dev->set_polarity = tcpm_set_polarity; > fusb302_tcpc_dev->set_vconn = tcpm_set_vconn; > fusb302_tcpc_dev->set_vbus = tcpm_set_vbus; > - fusb302_tcpc_dev->set_current_limit = tcpm_set_current_limit; > + fusb302_tcpc_dev->set_current_limit = tcpm_set_current_limit_psy; > fusb302_tcpc_dev->set_pd_rx = tcpm_set_pd_rx; > fusb302_tcpc_dev->set_roles = tcpm_set_roles; > fusb302_tcpc_dev->start_drp_toggling = tcpm_start_drp_toggling; > @@ -1733,6 +1722,11 @@ static int fusb302_probe(struct i2c_client *client, > return -EPROBE_DEFER; > } > > + ret = tcpm_register_psy(chip->dev, &chip->tcpc_dev, > + "fusb302-typec-source"); > + if (ret < 0) > + return ret; > + > ret = fusb302_debugfs_init(chip); > if (ret < 0) > return ret; >