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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 1FCDAC433EF for ; Thu, 9 Sep 2021 13:10:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A4D5611AD for ; Thu, 9 Sep 2021 13:10:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356081AbhIINMB (ORCPT ); Thu, 9 Sep 2021 09:12:01 -0400 Received: from mga05.intel.com ([192.55.52.43]:21871 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354757AbhIINI1 (ORCPT ); Thu, 9 Sep 2021 09:08:27 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="306350650" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="306350650" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 06:01:54 -0700 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="470076390" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 06:01:51 -0700 Received: from andy by smile with local (Exim 4.95-RC2) (envelope-from ) id 1mOJga-001cpi-9x; Thu, 09 Sep 2021 16:01:48 +0300 Date: Thu, 9 Sep 2021 16:01:48 +0300 From: Andy Shevchenko To: Jacopo Mondi Cc: Jonathan Cameron , Lars-Peter Clausen , Matt Ranostay , Magnus Damm , linux-iio@vger.kernel.org, Peter Rosin , Wolfram Sang Subject: Re: [PATCH v5 3/4] iio: chemical: Add Senseair Sunrise 006-0-007 driver Message-ID: References: <20210909094537.218064-1-jacopo@jmondi.org> <20210909094537.218064-4-jacopo@jmondi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210909094537.218064-4-jacopo@jmondi.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Thu, Sep 09, 2021 at 11:45:36AM +0200, Jacopo Mondi wrote: > Add support for the Senseair Sunrise 006-0-0007 driver through the > IIO subsystem. ... > + /* > + * Wake up sensor by sending sensor address: START, sensor address, > + * STOP. Sensor will not ACK this byte. > + * > + * The chip enters a low power state after 15msec without msec --> ms (everybody understands 'ms' unit) > + * communications or after a complete read/write sequence. > + */ ... > + struct i2c_client *client = context; > + union i2c_smbus_data data; > + > + /* Discard reg address from values count. */ > + if (count < 1) > + return -EINVAL; > + count--; Wouldn't be more natural to decrement and then check against 0? ... > + memcpy(&data.block[1], (u8 *)val_buf + 1, count); Not sure I understand why you need an explicit casting here. ... > + mutex_lock(&sunrise->lock); > + ret = sunrise_read_word(sunrise, SUNRISE_ERROR_STATUS_REG, &value); > + if (ret) { > + mutex_unlock(&sunrise->lock); > + return -EINVAL; Why shadowing an actual error code? > + } ... > + /* > + * / 10^4 to comply with IIO scale for CO2 (percentage). "1 / 10^4" > + * The chip CO2 reading range is [400 - 5000] ppm > + * which corresponds to [0,004 - 0,5] %. > + */ -- With Best Regards, Andy Shevchenko