Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp617183pxb; Tue, 1 Feb 2022 07:05:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJydnqyghxEsjqZVqHfzjRNVA98udlaLNxTBWB6tZkZiBu+gOjPG8OHe4BTmyxUm/+BUyVzl X-Received: by 2002:a05:6402:35d0:: with SMTP id z16mr25794917edc.149.1643727949463; Tue, 01 Feb 2022 07:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643727949; cv=none; d=google.com; s=arc-20160816; b=IeSyCTGSTrnsG7z0xCFIPG+Kj7+KABD8hGA2rIeeuVirnJCIQSOJB3wVUADvvjUUlD sJX2xq1zvKgwIDXbpFBHBWS8V6kOSagyAxZmuhAI3Ce/vtG1gvASNgAOVN9+g5UB4kh6 YCIGAos2xBUn2Xdw+SlfJidgChsnpkFqmu2/gGY6CdrvEtRKF/cZLg9lrROlXSa+ic2M D00R9/SARZPfiJpyCbrgzz2ILBEFv8buZBm+34oozpG7iiyMjp3FM2I195n7bRBA4tiF qrJ52+/i8aOFGJjIcDyVEUBZdy2Xapa1aYmMJkEe7uZuHpWAMONAZojMNXZKJhMwuHWb 7qAg== 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=rkHMjBM63zGg47ORcfkgLOvjulrZ8Qq0h9KQnMkwKnc=; b=P8O0y4odq/0m4K5AGPFRAdTRECE+Dd/W5FOpvfe1lzpEDDzoHKRwV2acMuzahGnrsN VIl2NW/qgHJb+4Unb3D5wwzg1+cDrk4HZXvG/Sz0hrEuTDt10/8+CIchq0WDILZZBqrQ jDrjpGX3BGXJdX4z+gGCQCNf2w6UdBOrllMvMmGpVuRxhlQ23EX+O8WrTVw3CvxdmDjU XnNgU5RRsrfKzVzt7oOP3h8vrRQqrfj8bLnghOyyZx8DHPzjWUv6rvai4NzC/cmoMw8N t8gh4EMQTP/5QkvVJfGFO1lccrvLOrAyWK6zO1IpguFdjAbx6I9c+hp6ijZ/kml857HP 9cGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ijp7uMOp; 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 m19si10120474edd.539.2022.02.01.07.05.22; Tue, 01 Feb 2022 07:05:49 -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=@redhat.com header.s=mimecast20190719 header.b=Ijp7uMOp; 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 S1356257AbiA3UrO (ORCPT + 99 others); Sun, 30 Jan 2022 15:47:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22517 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356255AbiA3UrL (ORCPT ); Sun, 30 Jan 2022 15:47:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643575631; 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=rkHMjBM63zGg47ORcfkgLOvjulrZ8Qq0h9KQnMkwKnc=; b=Ijp7uMOprH3aX1It/bL1wzeZPUnj89YMgNC3tUMl2OD3cjf5COJVYoeQh9af7037CwjAHJ zBPcGyqZ/POJzZlzjRkwxDpiqRZPwIy408eLMwxgS1H9lRPKfT8zhM7WQtNxnmKywEYgsP DDOFPpJVEPBBL9USHfRi/R02RfbBjlI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-332--9mU_lNdMkmLguuV0mrLiQ-1; Sun, 30 Jan 2022 15:47:07 -0500 X-MC-Unique: -9mU_lNdMkmLguuV0mrLiQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EC801006AA3; Sun, 30 Jan 2022 20:47:05 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id C03CE61093; Sun, 30 Jan 2022 20:47:01 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko , Wolfram Sang , Lee Jones , Sebastian Reichel , MyungJoo Ham , Chanwoo Choi , Ard Biesheuvel Cc: Hans de Goede , 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: [PATCH v4 09/20] power: supply: bq25890: Add bq25890_set_otg_cfg() helper Date: Sun, 30 Jan 2022 21:45:46 +0100 Message-Id: <20220130204557.15662-10-hdegoede@redhat.com> In-Reply-To: <20220130204557.15662-1-hdegoede@redhat.com> References: <20220130204557.15662-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 548d1a793e31..162bffb02410 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -832,6 +832,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; @@ -841,25 +852,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.33.1