From patchwork Tue Apr 28 17:29:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11515267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C69A14DD for ; Tue, 28 Apr 2020 17:30:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03539208E0 for ; Tue, 28 Apr 2020 17:30:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cGsRUGMk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728654AbgD1RaK (ORCPT ); Tue, 28 Apr 2020 13:30:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38670 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728634AbgD1RaG (ORCPT ); Tue, 28 Apr 2020 13:30:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588095004; 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=lLZMiljCIltohbNQWZRwTC2fGxuOtHqilTjd/ELRkRY=; b=cGsRUGMkLoudxKShQMIAi97VUggpGEyUAtfz2EvXasNvZc54UkJb7jv/E8smoHsi8OpRff JzZk/+owvMPfQzjax068kbh7N60b3wm1fFuAXhrUxLToHPu3A3tPU7G+SnyuUnvIEiGO83 5Ne1NTC0LD4xR49ZUuNJfVTyJBgC774= 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-252-rNegJiDaPDK7LHpLxLD7WQ-1; Tue, 28 Apr 2020 13:29:59 -0400 X-MC-Unique: rNegJiDaPDK7LHpLxLD7WQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C82B81937FC4; Tue, 28 Apr 2020 17:29:57 +0000 (UTC) Received: from x1.localdomain.com (ovpn-114-62.ams2.redhat.com [10.36.114.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4DF95C240; Tue, 28 Apr 2020 17:29:52 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Darren Hart , Andy Shevchenko , 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, Andy Shevchenko Subject: [PATCH v3 09/11] iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings Date: Tue, 28 Apr 2020 19:29:21 +0200 Message-Id: <20200428172923.567806-9-hdegoede@redhat.com> In-Reply-To: <20200428172923.567806-1-hdegoede@redhat.com> References: <20200428172923.567806-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Make lux_per_bit and lux_per_bit_base_it settings stored in struct cm32181_chip instead of a hardcoded (defined) values. This is a preparation patch for reading some ACPI tables which specify a device specific lux_per_bit value. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/iio/light/cm32181.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c index 1ad7d4582d1c..cae2264e4336 100644 --- a/drivers/iio/light/cm32181.c +++ b/drivers/iio/light/cm32181.c @@ -69,6 +69,8 @@ struct cm32181_chip { u16 conf_regs[CM32181_CONF_REG_NUM]; unsigned long init_regs_bitmap; int calibscale; + int lux_per_bit; + int lux_per_bit_base_it; int num_als_it; const int *als_it_bits; const int *als_it_values; @@ -114,6 +116,8 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181) CM32181_CMD_ALS_IT_DEFAULT | CM32181_CMD_ALS_SM_DEFAULT; cm32181->init_regs_bitmap = BIT(CM32181_REG_ADDR_CMD); cm32181->calibscale = CM32181_CALIBSCALE_DEFAULT; + cm32181->lux_per_bit = CM32181_LUX_PER_BIT; + cm32181->lux_per_bit_base_it = CM32181_LUX_PER_BIT_BASE_IT; /* Initialize registers*/ for_each_set_bit(i, &cm32181->init_regs_bitmap, CM32181_CONF_REG_NUM) { @@ -210,8 +214,8 @@ static int cm32181_get_lux(struct cm32181_chip *cm32181) if (ret < 0) return -EINVAL; - lux = CM32181_LUX_PER_BIT; - lux *= CM32181_LUX_PER_BIT_BASE_IT; + lux = cm32181->lux_per_bit; + lux *= cm32181->lux_per_bit_base_it; lux = div_u64(lux, als_it); ret = i2c_smbus_read_word_data(client, CM32181_REG_ADDR_ALS);