Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3471085rwd; Sat, 3 Jun 2023 06:03:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7E1osa9nKq2zxXESg2XT4qfasY6UmgpQks4bOcfiqal7ccvZVmAxyzYAzBY6Mwbqoa2tO+ X-Received: by 2002:a17:90a:f18b:b0:250:aaea:4306 with SMTP id bv11-20020a17090af18b00b00250aaea4306mr1262483pjb.21.1685797393781; Sat, 03 Jun 2023 06:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685797393; cv=none; d=google.com; s=arc-20160816; b=Swtdi9gF3myWP5Thp6qTTKc8icW4VtakqQ5rwm+D7fo6PR49fbl1xlCX0F0sz7xdRk hIdo9mM9tjnHjEXk21Yb6vRjYxeIIJwTh707XSmyepzrD9MOD6tKRmSfnudDvVRU1tYq uFPUHEw1/aFdNoHEx7uEb7Ge5Y7DBkjGyH+AROl502vvcErd0WMGcazrpdQPmVGptiyb Ebjd5sg40OXAZ4pPH5uoGyqNDQxhoRs4Nj+CIkY0gOZJ/ZMFT/5TQ6eo7kZPbViQhS90 rUav9EVsSZFFgavHA1SpZdW9YfvHZ5TaHKSUTdzWcC8ZpPBb4K+NmAUpLmBktMTYWTWm wQkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from; bh=lvz+qky0BiM4a9WJuiHaJkCa1fAIDnXg14htzu7ulH8=; b=ZpIERtP4CXuVzsh6rOzZAGAdt9dOXKxFgcOEiGAV1Q56yuafGesDBDldcnRJXaJzyR cIBs2ZCBccsGH+W48jnWbmOJAONfwemWhI3zG8Z87a6ibGSu1PvlbI1rmmS8GbJ6sCdb 444kO6GBnCPl3TbvGF+qFjsjzwsrgVUdMk0ywaXBoZ2B9NK3+HaZAGQYk0KWdyzghxfu Jxh5F2SJDytZenOI1minlb+6aWPJZkm1nUMjqgPo6NwPTJrpm64BIJR5TgsRw/2dGdms C5Jyzja92hXG2TpVSb7cYecoGf52W/ZB3ZmTS371DFJijGpw2B2S04Hfd3/y0kZDO57O d6QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mj4-20020a17090b368400b00256414fdd5bsi4377282pjb.143.2023.06.03.06.02.11; Sat, 03 Jun 2023 06:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbjFCMQE (ORCPT + 99 others); Sat, 3 Jun 2023 08:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjFCMQB (ORCPT ); Sat, 3 Jun 2023 08:16:01 -0400 Received: from fgw21-7.mail.saunalahti.fi (fgw21-7.mail.saunalahti.fi [62.142.5.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC931A4 for ; Sat, 3 Jun 2023 05:15:59 -0700 (PDT) Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id 65404ae6-0208-11ee-abf4-005056bdd08f; Sat, 03 Jun 2023 15:15:57 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Sat, 3 Jun 2023 15:15:57 +0300 To: Astrid Rost Cc: Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@axis.com, Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Mathieu Othacehe Subject: Re: [PATCH v5 3/7] iio: light: vcnl4000: Add als_it for vcnl4040/4200 Message-ID: References: <20230530142405.1679146-1-astrid.rost@axis.com> <20230530142405.1679146-4-astrid.rost@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230530142405.1679146-4-astrid.rost@axis.com> X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tue, May 30, 2023 at 04:24:01PM +0200, Astrid Rost kirjoitti: > Add illuminance integration time for vcnl4040 and vcnl4200. > Add read/write attribute for illuminance integration time and read > attribute for available integration times. > Set scale and sampling rate according to the integration time. ... > +static int vcnl4040_read_als_it(struct vcnl4000_data *data, int *val, int *val2) > +{ > + int ret; > + > + ret = i2c_smbus_read_word_data(data->client, VCNL4200_AL_CONF); > + if (ret < 0) > + return ret; > + > + ret = FIELD_GET(VCNL4040_ALS_CONF_IT, ret); > + Redundant blank line. > + if (ret >= data->chip_spec->num_als_it_times) > + return -EINVAL; > + > + *val = (*data->chip_spec->als_it_times)[ret][0]; > + *val2 = (*data->chip_spec->als_it_times)[ret][1]; > + > + return 0; > +} ... > +static ssize_t vcnl4040_write_als_it(struct vcnl4000_data *data, int val) > +{ > + unsigned int i; > + int ret, reg_val = -1; > + u16 regval; Besides confusing naming schema (two variables with only a _ difference) unsigned int i; u16 regval; int ret; > + for (i = 0; i < data->chip_spec->num_als_it_times; i++) { > + if (val == (*data->chip_spec->als_it_times)[i][1]) { > + reg_val = i; Remove. > + break; > + } > + } > + if (reg_val < 0) if (i == data->chip_spec->num_als_it_times) > + return -EINVAL; (1) > + data->vcnl4200_al.sampling_rate = ktime_set(0, val * 1200); > + data->al_scale = div_u64(mul_u32_u32(data->chip_spec->ulux_step, > + (*data->chip_spec->als_it_times)[0][1]), > + val); > + > + mutex_lock(&data->vcnl4000_lock); > + > + ret = i2c_smbus_read_word_data(data->client, VCNL4200_AL_CONF); > + if (ret < 0) > + goto out_unlock; > + > + regval = (ret & ~VCNL4040_ALS_CONF_IT) | > + FIELD_PREP(VCNL4040_ALS_CONF_IT, reg_val); Use temporary variable for this field, u16 als_conf; ...See (1)... als_conf = FIELD_PREP(..., i); > + ret = i2c_smbus_write_word_data(data->client, > + VCNL4200_AL_CONF, > + regval); > + > +out_unlock: > + mutex_unlock(&data->vcnl4000_lock); > + return ret; > +} -- With Best Regards, Andy Shevchenko