From patchwork Fri Mar 16 20:06:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10290061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 118F1602C2 for ; Fri, 16 Mar 2018 20:08:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 011B328E0F for ; Fri, 16 Mar 2018 20:08:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9A0028F90; Fri, 16 Mar 2018 20:08:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A86C28E0F for ; Fri, 16 Mar 2018 20:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752518AbeCPUHS (ORCPT ); Fri, 16 Mar 2018 16:07:18 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33017 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752519AbeCPUHP (ORCPT ); Fri, 16 Mar 2018 16:07:15 -0400 Received: by mail-pf0-f193.google.com with SMTP id q13so4576948pff.0; Fri, 16 Mar 2018 13:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G4Lc2Kav+q5jGNE0i6xvhkjMETHtr+oXsGio1pX8EUk=; b=gIzb8Tg/tMzf29KV2yQ4JS7+Iv8pluqwHDISwD+R71GHoGKG72CBXfFRni1NKkdds5 F1PpU7tlvMypBpthROIyilN87LDCbmasCh9lgkaeZsNkGbgdYvvbSbvWQ4JkdlJPmMMP hnr7joCcWgcPWAbNSj11vBRi6Zx1KDpHo3Pfn5QT6Lj/UEIxC6yJeTM4gjS6FALOgMEg otvvBgXafj5ThvjW3T5rdSzoqvKSQcU25FRvVBFMlnX/eh6x3S1wSs8EdXjpEZOJVYw4 vRlxOHO4reyT3CIgmQ7teoEyT8bOAEGjhYhequldFR4+xUIpaF8HZuQgp+1IkyDPgmBw /kaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G4Lc2Kav+q5jGNE0i6xvhkjMETHtr+oXsGio1pX8EUk=; b=Sn6+77/GQ2Y7MBTJHOe7VDEKmYLFifQKk3zNfckHU/yt1tOw1n91BKfCAZdD3BSeQc cwZarzFjpBCTvN0F/JaUsCI25/CyY+ilfMIyCfC+2S4juassZzfhk0mCEGxytOHzXMPy +yZBOXGBwA5k4Qbgswq3pBmciO/XsO644teCYXbZAIGrGr49NUsXpr36Kcv2MEbExys7 T9UMRxCHC0s4TUqNG1wxfzaGlNG1huCQk0U4NlSj/MJcb3OLD54fqXTUe6nWIIU8oQGp 8rTNyZxoW1kWEjYUaq+6st6yqJLzxFyznyCs0qBOhPU/p4dMYscwHkjs7fQbOxDfJpJU kg0A== X-Gm-Message-State: AElRT7GFWUZwPmGAK1qDvSVyEYi3dPdTdFJFxf/gz5qs9pVa7XQ1XSv4 3dc0PxZm4t5fQuu+0503JRo= X-Google-Smtp-Source: AG47ELsKPHEdPuraDo88FY6OfesgTfTBcqg1X1c6Bc/cHhmBkzpi+pyePkx3vtAEfLBIe6O/+lD95g== X-Received: by 10.98.101.69 with SMTP id z66mr2373476pfb.25.1521230834755; Fri, 16 Mar 2018 13:07:14 -0700 (PDT) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id s9sm15605347pfm.39.2018.03.16.13.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Mar 2018 13:07:14 -0700 (PDT) From: Himanshu Jha To: jic23@kernel.org Cc: lars@metafoo.de, Michael.Hennerich@analog.com, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, daniel.baluta@gmail.com, 21cnbao@gmail.com, Himanshu Jha Subject: [PATCH v2 5/9] Staging: iio: accel: adis16201: Add comments about units in read_raw() Date: Sat, 17 Mar 2018 01:36:22 +0530 Message-Id: <1521230786-18155-6-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521230786-18155-1-git-send-email-himanshujha199640@gmail.com> References: <1521230786-18155-1-git-send-email-himanshujha199640@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clarify the conversion and formation of resultant data in the adis16201_read_raw() with sufficient comments and remove the unnecessary comments. Signed-off-by: Himanshu Jha --- v2: -clarify voltage base conversions. drivers/staging/iio/accel/adis16201.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c index 8de3f27..97150ea 100644 --- a/drivers/staging/iio/accel/adis16201.c +++ b/drivers/staging/iio/accel/adis16201.c @@ -120,31 +120,43 @@ static int adis16201_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_VOLTAGE: if (chan->channel == 0) { + /* Voltage base units are mV hence 1.22 mV */ *val = 1; - *val2 = 220000; /* 1.22 mV */ + *val2 = 220000; } else { + /* Voltage base units are mV hence 0.61 mV */ *val = 0; - *val2 = 610000; /* 0.610 mV */ + *val2 = 610000; } return IIO_VAL_INT_PLUS_MICRO; case IIO_TEMP: - *val = -470; /* 0.47 C */ + *val = -470; *val2 = 0; return IIO_VAL_INT_PLUS_MICRO; case IIO_ACCEL: + /* + * IIO base unit for sensitivity of accelerometer + * is milli g. + * 1 LSB represents 0.244 mg. + */ *val = 0; - *val2 = IIO_G_TO_M_S_2(462400); /* 0.4624 mg */ + *val2 = IIO_G_TO_M_S_2(462400); return IIO_VAL_INT_PLUS_NANO; case IIO_INCLI: *val = 0; - *val2 = 100000; /* 0.1 degree */ + *val2 = 100000; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; } break; case IIO_CHAN_INFO_OFFSET: - *val = 25000 / -470 - 1278; /* 25 C = 1278 */ + /* + * The raw ADC value is 1278 when the temperature + * is 25 degrees and the scale factor per milli + * degree celcius is -470. + */ + *val = 25000 / -470 - 1278; return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: switch (chan->type) { @@ -252,13 +264,11 @@ static int adis16201_probe(struct spi_device *spi) struct adis *st; struct iio_dev *indio_dev; - /* setup the industrialio driver allocated elements */ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; @@ -277,7 +287,6 @@ static int adis16201_probe(struct spi_device *spi) if (ret) return ret; - /* Get the device into a sane initial state */ ret = adis_initial_startup(st); if (ret) goto error_cleanup_buffer_trigger;