Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp343698pxf; Thu, 1 Apr 2021 02:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrsGKTBGSDWDgdoQAyGMmi42ICXLCuaAwTJ2wEQ3ZkHC888av6CdfeFjl0Wjve2RImG579 X-Received: by 2002:a17:906:71d3:: with SMTP id i19mr8287938ejk.347.1617269933886; Thu, 01 Apr 2021 02:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617269933; cv=none; d=google.com; s=arc-20160816; b=qAUxkpx+2xzPoIYkbaFY85vfANuq+Iyz+lKZ2fVtYxZtb5t55kawR9Bllebcs6aW8v o0pefHI6QAzLTpk1mXevU7sXkelfpc59UXMPeeBAjvALcWXOby7+YF2K0Yn2MadgLNVd 5I/xJVa2trDjZjXaLvxT6xdnnebXKHqtMzwxJShCXGzl3ap1J5/J+CSZhZ5Z2rxiVVH8 HI9SYE/YbCp8xQet2tA40RVjP6sQvfQemb793FtUC5IAb649Pd525RiYMa3G4CLpUrAp ZC3hOx5mYWKh4LE5TWVEs6fbfk0+3zn7MMQWr5Ge8VXonRXQi9h+wwLcC8yv7IO9WH5P CZRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SRsyfN5Ras+hHwkeeBXTNewhBhlVp4my6jL5NaeELlI=; b=oryvs/W/wD8RKJq3lMi/uZy8mEa2XchYxloZIcNmpqPu1els8ykXEs9v85eS6Lcxtr uofs6PLs5/ZNn/JPuN3JtIK7B+B6fxHmfEhz8LX9mk11BCJugVrQFo+ei/hDOMUcqAoN lf4WgHZC5cKizwAz+pU2LdMmK8cFkqBqYiBWQYsd4nGfq7FI/6gXVecUxIdtXB7hDvZm yfjrz3dysxFlkZ/pqBq+LAN147mC1z94innZnqMPXFrm1VGEGggFyYtMKc7IuJ2J1S3B e1qTRKNWEXX3wm2n385R+uPE60fNoT97yNi10hYW/mPt9X6Ydvl+icj6ytpmzJGqj8iD KW6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lej32Bpo; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si4084495edr.560.2021.04.01.02.38.31; Thu, 01 Apr 2021 02:38:53 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=Lej32Bpo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233834AbhDAJhg (ORCPT + 99 others); Thu, 1 Apr 2021 05:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233936AbhDAJhJ (ORCPT ); Thu, 1 Apr 2021 05:37:09 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50451C0613E6; Thu, 1 Apr 2021 02:37:09 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so4456479pjb.0; Thu, 01 Apr 2021 02:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SRsyfN5Ras+hHwkeeBXTNewhBhlVp4my6jL5NaeELlI=; b=Lej32Bpor3H3GqOFCSPbJjhT7vpL+8wPDuSRWvaQ3bCsoETVVjOt0BXas1XVdQ6YY9 7/ybmE6RFsdZPFWDEtdrdMbS3yy4snajjI1c9W05NZhy7hLk8Gl7T2R5UYMTmce7Pgo3 xz7A16Ep0J468eGtyYU6ilvZN9DZMrD7ixoc1R7q7Wds+S72t1lfmNKyWadTRwCN20l5 UzhrQxdvaqsbIinbMCRxcrrKvjFUrPXAoUiiFJuQ/RdkEFymnh8S0YqDLj/kEn0zd/K+ A1nXOC8YV1g2cILkwZSjrykm2G7uofrusMGLbU9zM9RXSdjOeiIUN271T+p/zepH66tp XpLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SRsyfN5Ras+hHwkeeBXTNewhBhlVp4my6jL5NaeELlI=; b=kn21SBrsFCuMQ6q+99stx4CrkEDreeE0csLXD1N6dYahaHp3Ij8AwKykmtx4oiyJ4b skYwH+rdGx+6D7LuHVZIC9g4Pb4OT44Ilc55iQbtt3QfnIX9SqrPlW3FkzJZlhTVYih1 RznIBN+W5ogz9/aEJ899ciJH71caUZpCyDCxd84lWXRtDSFZZQjlcIdRNC2c3sTF4goT O0AHjyQv7J3fXgJQD0HzvcKXE2yh9oVS7nqdqHJD6DLpoVH6lRps+GGxbU1AQ+n5q24Y CSr+UiIkWs/nh7wkyYOqShEVZNX4Abk23Tljz/ADifyWBxdnljtX8UImimDLp6b3xJ3H HnPQ== X-Gm-Message-State: AOAM5303PdxcsC3+fNrKRNRiGBlH393eleeO/oFzw/UjIAmMulKIuxoC o45nwC0iQ4NiLtNP8/Xd0DgU8XR6XEBHxvjQBRo= X-Received: by 2002:a17:902:7883:b029:e7:32bd:6b97 with SMTP id q3-20020a1709027883b02900e732bd6b97mr7298169pll.0.1617269828761; Thu, 01 Apr 2021 02:37:08 -0700 (PDT) MIME-Version: 1.0 References: <20210401091648.87421-1-puranjay12@gmail.com> <20210401091648.87421-3-puranjay12@gmail.com> In-Reply-To: <20210401091648.87421-3-puranjay12@gmail.com> From: Andy Shevchenko Date: Thu, 1 Apr 2021 12:36:51 +0300 Message-ID: Subject: Re: [PATCH v2 2/2] iio: temperature: add driver support for ti tmp117 To: Puranjay Mohan Cc: Alexandru Ardelean , Jonathan Cameron , devicetree , Hartmut Knaack , linux-iio , Linux Kernel Mailing List , Lars-Peter Clausen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 1, 2021 at 12:19 PM Puranjay Mohan wrote: > > TMP117 is a Digital temperature sensor with integrated NV memory. > > Add support for tmp117 driver in iio subsystem. + blank line > Datasheet:-https://www.ti.com/lit/gpn/tmp117 Make it a tag, i.e. remove the following blank line and use a space after colon. > > Signed-off-by: Puranjay Mohan ... > +/* > + * tmp117.c - Digital temperature sensor with integrated NV memory It's useless and provokes an unneeded churn when having a file name inside the file. Please, drop it for good. > + * > + * Copyright (c) 2021 Puranjay Mohan > + * > + * Driver for the Texas Instruments TMP117 Temperature Sensor > + * Redundant blank line. > + * (7-bit I2C slave address (0x48 - 0x4B), changeable via ADD pins) > + * > + * Note: This driver assumes that the sensor has been calibrated beforehand. > + */ ... > +#include > +#include > +#include Missed: bitops.h //sign_extend32() types.h // s32 > + > +#include ... > +struct tmp117_data { > + struct i2c_client *client; > +}; Doesn't make any sense to have a separate structure for just one pointer member. Use that pointer directly. ... > + case IIO_CHAN_INFO_CALIBBIAS: > + ret = i2c_smbus_read_word_swapped(data->client, > + TMP117_REG_TEMP_OFFSET); > + if (ret < 0) > + return ret; > + *val = ((int16_t)ret * (int32_t)TMP117_RESOLUTION_10UC) > + / 10000; One line > + *val2 = ((int16_t)ret * (int32_t)TMP117_RESOLUTION_10UC) > + % 10000; One line. I'll be honest, I do not like these explicit castings at all. Can you revisit and try to refactor that you won't need them? For example, I can't understand how ret can be higher than 16 bit since we checked on negative values beforehand. > + return IIO_VAL_INT_PLUS_MICRO; > + > + case IIO_CHAN_INFO_SCALE: > + /* Conversion from 10s of uC to mC > + * as IIO reports temperature in mC > + */ > + *val = TMP117_RESOLUTION_10UC / 10000; > + *val2 = (TMP117_RESOLUTION_10UC % 10000) * 100; > + return IIO_VAL_INT_PLUS_MICRO; You use 10000 many times, can you give it an appropriate name (via #define)? ... > + s16 off; > + case IIO_CHAN_INFO_CALIBBIAS: > + off = (s16)val; Redundant explicit casting. > + return i2c_smbus_write_word_swapped(data->client, > + TMP117_REG_TEMP_OFFSET, off); ... > +static const struct of_device_id tmp117_of_match[] = { > + { .compatible = "ti,tmp117", }, > + { }, No need to comma in terminator line(s). > +}; -- With Best Regards, Andy Shevchenko