Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp895532pxb; Tue, 1 Feb 2022 12:39:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFXFbOyEv1CLJi8O5lMAMOUEYth/0Rj/PxqYGKiKbsklpph3UxGpFdGl1FIOmNManmTnON X-Received: by 2002:a17:90b:1c84:: with SMTP id oo4mr4331037pjb.141.1643747995901; Tue, 01 Feb 2022 12:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643747995; cv=none; d=google.com; s=arc-20160816; b=gnVusL+OZKoryol6ACJ9t2zWqtKRNSO/mHm1RLpdIe+TIM+v92BFr7/YYF3h8Q8wm/ TyN6V31Oh+9YcTQ6UAHmwxUmUnXUZnHTmrS4D71ao6BsimbWlmJKxlQm8oVt+WnnG6xZ 54qb/AJVOieXI/GAuDKlHDsNVHQaZpXdsn6HgJqbqUtp47eIhrNMQ2tlLXJ6fGB1oonv br9bfzqDoCDdiD/p1d4fDpLebRxYhDISyiXd4roKNFoNzvnt6fb3sY/msLc831uwso6M lQxR+8TJdWfcWgLZm2/pcvUT2ZOHfLX3DVFdxvGL+F6kg/K1U1JM7DL9WULj4Qtyxqos KBOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=18GwVvUaCCamneFsSEY7BnvJ1YuKWq/Fqs4zn1uhQKg=; b=zmsZJFMOrjwFkGswKfQabddKFg0Lhktd2GoHC3kV5aahxn1p6Ir+TOzy28+yiwUJxd wFcCJlNEvUG4v9xVgbzVZv2+Z/qzK9qObJK6LBHrRohbwlXt9dO+hOlhiUR2PRjUHHhU ArGsbBlZILUe5VUm3I9zsZV+gTSFEI9ylYOHmdZWVMEQwYaAKvFRynGVZJoTHQXES/0x ROzSDHlaVodurXgEPlcG0h6Onu94l3woFpxoW4CrbdkvedtZArSeCjnqgNRvVo9AcKSW PRziKmJUD8/rQvcnKhEGbA38I+5oDiCLPC829rHSzvuYSU6CR4IjPlA8lAy9q+LGiYOg sbEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LrBChNDJ; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si17269807pgj.124.2022.02.01.12.39.42; Tue, 01 Feb 2022 12:39:55 -0800 (PST) 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=@intel.com header.s=Intel header.b=LrBChNDJ; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379125AbiAaNi3 (ORCPT + 99 others); Mon, 31 Jan 2022 08:38:29 -0500 Received: from mga11.intel.com ([192.55.52.93]:24460 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379018AbiAaNiZ (ORCPT ); Mon, 31 Jan 2022 08:38:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643636305; x=1675172305; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vV+EosjS0aKdpssFXwRRe5Zc72CZWBXPL31TLfqD2Qo=; b=LrBChNDJEmmY9fiUoCF5N8DXv4N6BqeYV2BZupqQGD419QCqiP/xUWFI otOkDxz3Impmq5BIvvUPsbb5ddcvlwXM0R5Jr1wsDIb1BQbtLkHWbsfgd CyulMbgKIoGS17SzxvcLWv1QiEBnrUzGiQWN+6k0+BLjDCV36cQIstPyx mTo8NUl9GX8rI1KAD+JmrsXi+pgXUiJJx0TEyXTwgmTHp3Z9bm6RB+3Vr 9DiZIExoBNN1dHQZB+7DlTFGpvLapzIQJ+8L/ifVlW8vd7zDILnxBhtHU Ao36KCw1mXN9fkLPrElK83jAP2QB1cYlvP7YV/UKUEITjhptRbaptkM0E A==; X-IronPort-AV: E=McAfee;i="6200,9189,10243"; a="245053765" X-IronPort-AV: E=Sophos;i="5.88,331,1635231600"; d="scan'208";a="245053765" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2022 05:38:24 -0800 X-IronPort-AV: E=Sophos;i="5.88,331,1635231600"; d="scan'208";a="565010093" Received: from smile.fi.intel.com ([10.237.72.61]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2022 05:38:19 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nEWrs-00Gsrq-Ge; Mon, 31 Jan 2022 15:37:16 +0200 Date: Mon, 31 Jan 2022 15:37:16 +0200 From: Andy Shevchenko To: Hans de Goede Cc: "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko , Wolfram Sang , Lee Jones , Sebastian Reichel , MyungJoo Ham , Chanwoo Choi , Ard Biesheuvel , Len Brown , linux-acpi@vger.kernel.org, Yauhen Kharuzhy , Tsuchiya Yuto , Fabio Aiuto , platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v4 01/20] power: supply: core: Refactor power_supply_set_input_current_limit_from_supplier() Message-ID: References: <20220130204557.15662-1-hdegoede@redhat.com> <20220130204557.15662-2-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220130204557.15662-2-hdegoede@redhat.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 30, 2022 at 09:45:38PM +0100, Hans de Goede wrote: > Some (USB) charger ICs have variants with USB D+ and D- pins to do their > own builtin charger-type detection, like e.g. the bq24190 and bq25890 and > also variants which lack this functionality, e.g. the bq24192 and bq25892. > > In case the charger-type; and thus the input-current-limit detection is > done outside the charger IC then we need some way to communicate this to > the charger IC. In the past extcon was used for this, but if the external > detection does e.g. full USB PD negotiation then the extcon cable-types do > not convey enough information. > > For these setups it was decided to model the external charging "brick" > and the parameters negotiated with it as a power_supply class-device > itself; and power_supply_set_input_current_limit_from_supplier() was > introduced to allow drivers to get the input-current-limit this way. > > But in some cases psy drivers may want to know other properties, e.g. the > bq25892 can do "quick-charge" negotiation by pulsing its current draw, > but this should only be done if the usb_type psy-property of its supplier > is set to DCP (and device-properties indicate the board allows higher > voltages). > > Instead of adding extra helper functions for each property which > a psy-driver wants to query from its supplier, refactor > power_supply_set_input_current_limit_from_supplier() into a > more generic power_supply_get_property_from_supplier() function. ... > + ret = power_supply_get_property_from_supplier(bdi->charger, > + POWER_SUPPLY_PROP_CURRENT_MAX, > + &val); > + if (ret == 0) Can it be as simple as if (ret) return; ... ? Or did I misunderstand the meaning of 0? -- With Best Regards, Andy Shevchenko