Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1359283pxb; Sat, 30 Oct 2021 11:33:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR3K3JvcR4c5czOMYLEflsZjD5FQz6i2Xhfv+6dgehqxbFc4pLnd05gcwxmWDMh1YR5aHJ X-Received: by 2002:a50:bf48:: with SMTP id g8mr26417606edk.10.1635618793245; Sat, 30 Oct 2021 11:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635618793; cv=none; d=google.com; s=arc-20160816; b=pXLFUK4tgMymBiOrArr1Qmww/weMErJbzE4Bic5MHzVI1bPLpxRCGnoeN163OrI/zw ypX5ULNaccYQ0p3CPL3344nbR5VwSeH/R56jI+CqGehipn40qnkYgf6moXBagr8Xqh/n yNdyqiEkbuWwc7lKYfbQ+TFiXZUB/cqOfVwlOcZTUTggh1mbhJT4ZSBvbPG6FxpGmPEs jtVFv3ZyXWSc9UeKY/TaiDfIqmjFDXyNUOnoT2+IVN2tkbo53eFZYIiEp4AR+TTo+Cpg tpIqm0m68kc0+64V2qc9g8e1MBxNKu74gLxkcNFE+dyCqpJNkgFC+nKTlI8iQjIL5lPl b1WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/bfr/J+hsxQ0Z01UTG2JJSH9Wj47Az2V8snWyLCXfIg=; b=bvf0NGWtQ/TJ9C5F0e4j4NCxdPWpDJtl+4H1aaxAlcUHk3SqOjKuceCg8ATre3YKzI 4Vcp4YKGAsvGnLhmP0TzWnCfIctANu+jNf0XQAweLexqPLOoosgMD2+0HrVBlq0Jp+bE KkiZIM/7fVAo2pBPpaAWp8ZmiCkfBVgFNuP9eFnv0FlAhvujh38b3j4cOtTjLJzYm6wO eS17gvuFvrtbAup9rjPpch/4dqTI0qMuD6sep5pUDh+cAAUgLc8AbJEYY1tMInLrkDCm ZuuCV7o8EY8p+flEMkm7tAyzW4kxARqKlek6yQmjH88xdktJefmiJUVz24BE0WLTA013 HsQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZrgvTVIR; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds16si2300386ejc.131.2021.10.30.11.32.19; Sat, 30 Oct 2021 11:33:13 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=ZrgvTVIR; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232115AbhJ3Sbi (ORCPT + 99 others); Sat, 30 Oct 2021 14:31:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25214 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232075AbhJ3SbW (ORCPT ); Sat, 30 Oct 2021 14:31:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635618530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/bfr/J+hsxQ0Z01UTG2JJSH9Wj47Az2V8snWyLCXfIg=; b=ZrgvTVIRap9Ga8nqI011dodvQADRHGmCz7qmw10KBuSfDrE2xK9UEGrp16CulpwF55y7hX wlBZ1kVxJN4ziaAzt9uDCx0atm235lVN80Xn5qlAmWG5VBLa4G0FhuIUmYFPgkY0/9vsZx wuN3rN9/tj5YDg9bVM8x/n8oEOxXJ9E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506--IRfLJ7hO1a66JEzzKlLJg-1; Sat, 30 Oct 2021 14:28:47 -0400 X-MC-Unique: -IRfLJ7hO1a66JEzzKlLJg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 579D710A8E07; Sat, 30 Oct 2021 18:28:45 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 896A55F4E1; Sat, 30 Oct 2021 18:28:42 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Wolfram Sang , Sebastian Reichel , MyungJoo Ham , Chanwoo Choi , Ard Biesheuvel Cc: Hans de Goede , Yauhen Kharuzhy , Tsuchiya Yuto , platform-driver-x86@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH 09/13] power: supply: bq25890: Add bq25890_set_otg_cfg() helper Date: Sat, 30 Oct 2021 20:28:09 +0200 Message-Id: <20211030182813.116672-10-hdegoede@redhat.com> In-Reply-To: <20211030182813.116672-1-hdegoede@redhat.com> References: <20211030182813.116672-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a bq25890_set_otg_cfg() helper function, this is a preparation patch for adding regulator support. Signed-off-by: Hans de Goede --- drivers/power/supply/bq25890_charger.c | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 163ca5d761aa..7504e30f1e4d 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -773,6 +773,17 @@ static int bq25890_power_supply_init(struct bq25890_device *bq) return PTR_ERR_OR_ZERO(bq->charger); } +static int bq25890_set_otg_cfg(struct bq25890_device *bq, u8 val) +{ + int ret; + + ret = bq25890_field_write(bq, F_OTG_CFG, val); + if (ret < 0) + dev_err(bq->dev, "Error switching to boost/charger mode: %d\n", ret); + + return ret; +} + static void bq25890_usb_work(struct work_struct *data) { int ret; @@ -782,25 +793,16 @@ static void bq25890_usb_work(struct work_struct *data) switch (bq->usb_event) { case USB_EVENT_ID: /* Enable boost mode */ - ret = bq25890_field_write(bq, F_OTG_CFG, 1); - if (ret < 0) - goto error; + bq25890_set_otg_cfg(bq, 1); break; case USB_EVENT_NONE: /* Disable boost mode */ - ret = bq25890_field_write(bq, F_OTG_CFG, 0); - if (ret < 0) - goto error; - - power_supply_changed(bq->charger); + ret = bq25890_set_otg_cfg(bq, 0); + if (ret == 0) + power_supply_changed(bq->charger); break; } - - return; - -error: - dev_err(bq->dev, "Error switching to boost/charger mode.\n"); } static int bq25890_usb_notifier(struct notifier_block *nb, unsigned long val, -- 2.31.1