From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D9F3C5519A for ; Sun, 26 Apr 2020 11:03:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DAC920706 for ; Sun, 26 Apr 2020 11:03:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MhCftpC1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726132AbgDZLDw (ORCPT ); Sun, 26 Apr 2020 07:03:52 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22275 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726200AbgDZLDQ (ORCPT ); Sun, 26 Apr 2020 07:03:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587898994; 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=Zci4D4v3HlWIjmVig8Pa2ZNuZ0x19ofFsfo6QhGjtJI=; b=MhCftpC1EaogcPMhZmLwY8qeTAwwOlluOSr5+gOw9vS2AawnoI7Rg1YYlBU1pqO1kjc19r ZXTPvdRSJJPg+IjSTUYijsPWRICDZ7ahX/fbjtAZ5WftoKq06zWraMQrzxyPvnBo7qIms5 ExwppwBXMJCT0XCd/WgpXRAlUFvd4q8= 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-390-19y_YxCiMzKI0YntwX-mkQ-1; Sun, 26 Apr 2020 07:03:13 -0400 X-MC-Unique: 19y_YxCiMzKI0YntwX-mkQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 50C9B8015CB; Sun, 26 Apr 2020 11:03:11 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-32.ams2.redhat.com [10.36.112.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC35510013A1; Sun, 26 Apr 2020 11:03:08 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Darren Hart , Andy Shevchenko , Kevin Tsai , Jonathan Cameron Cc: Hans de Goede , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH 4/8] iio: light: cm32181: Change reg_init to use a bitmap of which registers to init Date: Sun, 26 Apr 2020 13:02:52 +0200 Message-Id: <20200426110256.218186-4-hdegoede@redhat.com> In-Reply-To: <20200426110256.218186-1-hdegoede@redhat.com> References: <20200426110256.218186-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Content-Transfer-Encoding: quoted-printable Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This is a preparation patch for reading some ACPI tables which give init values for multiple registers. Signed-off-by: Hans de Goede --- drivers/iio/light/cm32181.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c index e8be20d3902c..e31c1005b03d 100644 --- a/drivers/iio/light/cm32181.c +++ b/drivers/iio/light/cm32181.c @@ -26,7 +26,7 @@ #define CM32181_REG_ADDR_ID 0x07 =20 /* Number of Configurable Registers */ -#define CM32181_CONF_REG_NUM 0x01 +#define CM32181_CONF_REG_NUM 4 =20 /* CMD register */ #define CM32181_CMD_ALS_DISABLE BIT(0) @@ -53,10 +53,6 @@ =20 #define SMBUS_ALERT_RESPONSE_ADDRESS 0x0c =20 -static const u8 cm32181_reg[CM32181_CONF_REG_NUM] =3D { - CM32181_REG_ADDR_CMD, -}; - /* CM3218 Family */ static const int cm3218_als_it_bits[] =3D { 0, 1, 2, 3 }; static const int cm3218_als_it_values[] =3D { 100000, 200000, 400000, 80= 0000 }; @@ -71,6 +67,7 @@ struct cm32181_chip { struct i2c_client *client; struct mutex lock; u16 conf_regs[CM32181_CONF_REG_NUM]; + int init_regs_bitmap; int calibscale; int num_als_it; const int *als_it_bits; @@ -117,14 +114,17 @@ static int cm32181_reg_init(struct cm32181_chip *cm= 32181) /* Default Values */ cm32181->conf_regs[CM32181_REG_ADDR_CMD] =3D CM32181_CMD_ALS_IT_DEFAULT | CM32181_CMD_ALS_SM_DEFAULT; + cm32181->init_regs_bitmap =3D BIT(CM32181_REG_ADDR_CMD); cm32181->calibscale =3D CM32181_CALIBSCALE_DEFAULT; =20 /* Initialize registers*/ for (i =3D 0; i < CM32181_CONF_REG_NUM; i++) { - ret =3D i2c_smbus_write_word_data(client, cm32181_reg[i], - cm32181->conf_regs[i]); - if (ret < 0) - return ret; + if (cm32181->init_regs_bitmap & BIT(i)) { + ret =3D i2c_smbus_write_word_data(client, i, + cm32181->conf_regs[i]); + if (ret < 0) + return ret; + } } =20 return 0; --=20 2.26.0