Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp618343pxb; Tue, 1 Feb 2022 07:06:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkAnwXgbho9SgVfvdRh55RL/AUHjegV85EL3fqSO43hqxSj9daFHI1DN+UZhmEMtr3eI+p X-Received: by 2002:a05:6402:3596:: with SMTP id y22mr15496574edc.370.1643728007594; Tue, 01 Feb 2022 07:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643728007; cv=none; d=google.com; s=arc-20160816; b=IL6GN797kqD6+GJzKansw2EgL3xUFQatn9ctIxqS69VeCm4QF8L4QheFh4wpJ9db0h fGGBZQpZaXDczqVkt9HECXaljSWoNQpdDBo9rZ293hXYsarhoPfFwiTgsJKuGigcGZId JxmCrkaMmMbUuuJlp4hhlYsp3uWF46bdfttt5FmeB3NlMP8iOOZ3n4q1WJhmmZQfkaUZ awd4L1UfKayggDfMEby3jPZ8moTDTft+qSwo02EH48BBKPb/raJVyKvVtin8/upEx9Cr XK86FOc+r9/79rNuXv4tW39ylcT0s6U3KA+2DY4D7lVVZX0VR7lBVZyIsAbDm0fe5ZTt qH5w== 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=NSFllL0K7X0KVTucBJnSMumxKusMGygWrLDj1HKAn7A=; b=mhpwieg/+zCMeY7sxHki8uRNguvSDrOAq877bbADGaw2hPOkYKIVcsxdg8MUQz3dLQ 36OuUXWA7jqqk4fC8PNeGf3ypP2YwGUeV2a626xcw0vChquqbLxVarcuQD+E8/WvO6cj RhMGiPHDelQAGUrbywi+jsHxhAORv8tNR5w7YJ+kx+F2P9f4Vkz8V/ZW2o76ZzP1yRGm CzEkOAUct2lezXG9tYzMvC+luz4EslvQSueCwtmrA5YQqFhEZdxdBYLV3TLStanm6qD5 /BTFlmwNXJZLRlvMjc+1nAz7f7H6lffh6MLzG12Z6D726ILZZBv1u8GPwD2QlT0gLPDl 53ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PLBM4ETc; 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 19si9523070edx.305.2022.02.01.07.06.20; Tue, 01 Feb 2022 07:06:47 -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=PLBM4ETc; 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 S1356288AbiA3Urn (ORCPT + 99 others); Sun, 30 Jan 2022 15:47:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46534 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356295AbiA3Urb (ORCPT ); Sun, 30 Jan 2022 15:47:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643575650; 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=NSFllL0K7X0KVTucBJnSMumxKusMGygWrLDj1HKAn7A=; b=PLBM4ETc7YDlKromNM5tkujHsbTg3OzEyv2ORYdckfWaCSnY2u5pawF9dDbixzQv74P/s2 0QUPk4bgwexW7TGkuUPU5eHRM2Xzfoo7+ue508GI4TNt2Z6HcqNufW+EhfLY0gHQ7EDCcl tzvK5riFIzWebc4f9dHmeuI9FHm9jHM= 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-539-x_bNB88xPy2MWfIC91eylg-1; Sun, 30 Jan 2022 15:47:24 -0500 X-MC-Unique: x_bNB88xPy2MWfIC91eylg-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 4971E18397A7; Sun, 30 Jan 2022 20:47:22 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9FFB61093; Sun, 30 Jan 2022 20:47:18 +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 13/20] power: supply: bq25890: Use the devm_regmap_field_bulk_alloc() helper Date: Sun, 30 Jan 2022 21:45:50 +0100 Message-Id: <20220130204557.15662-14-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 Use the devm_regmap_field_bulk_alloc() helper function instead of open-coding this ourselves. Signed-off-by: Hans de Goede --- Changes in v3: - This is a new patch in v3 of this patch-series --- drivers/power/supply/bq25890_charger.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 179abed92f9b..852a6fec4339 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -1165,7 +1165,6 @@ static int bq25890_probe(struct i2c_client *client, struct device *dev = &client->dev; struct bq25890_device *bq; int ret; - int i; bq = devm_kzalloc(dev, sizeof(*bq), GFP_KERNEL); if (!bq) @@ -1182,15 +1181,10 @@ static int bq25890_probe(struct i2c_client *client, return dev_err_probe(dev, PTR_ERR(bq->rmap), "failed to allocate register map\n"); - for (i = 0; i < ARRAY_SIZE(bq25890_reg_fields); i++) { - const struct reg_field *reg_fields = bq25890_reg_fields; - - bq->rmap_fields[i] = devm_regmap_field_alloc(dev, bq->rmap, - reg_fields[i]); - if (IS_ERR(bq->rmap_fields[i])) - return dev_err_probe(dev, PTR_ERR(bq->rmap_fields[i]), - "cannot allocate regmap field\n"); - } + ret = devm_regmap_field_bulk_alloc(dev, bq->rmap, bq->rmap_fields, + bq25890_reg_fields, F_MAX_FIELDS); + if (ret) + return ret; i2c_set_clientdata(client, bq); -- 2.33.1