From patchwork Fri May 3 22:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10929337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B39311395 for ; Fri, 3 May 2019 22:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1C9D287D2 for ; Fri, 3 May 2019 22:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95218287DA; Fri, 3 May 2019 22:14:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 1CA5C287D2 for ; Fri, 3 May 2019 22:14:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726320AbfECWOE (ORCPT ); Fri, 3 May 2019 18:14:04 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44073 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfECWOE (ORCPT ); Fri, 3 May 2019 18:14:04 -0400 Received: by mail-qt1-f195.google.com with SMTP id a26so6185362qtp.11; Fri, 03 May 2019 15:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7k8Wov7jQEYM2rfxCLHxgiTqZOyUz2SP9zMZgrjLstQ=; b=Bhw7KkQUjZsiqWbLEaDqz97+HBxqEteaEk12AYSCalIVlFVcTyWL0lcdvsSn1woeVQ 3IZ+BFbtj2bFspdtExTUPbfZEEkvTg6T3V9++z29O5TOiQ+6Re43iO4pupPy9yE3zIS3 nQLNvCghkaGekDf+dAuNdyIAWf1r8LGdrfkWb0ZVzdB1xRwxt9cIa+GEwiApuYLvYVXk 6nR2gwKh0/xIQeIU4RadyzNjS7pZRUBnMrEUzXc+AZWlsHp15kgjqFK5ShGOSOLEJE2T hNCvD4268hVd2H4D1zVIjFwex02ybMk0pl6sPbFjTSQTzUNvdcEPFuAAXcQr+daLyAtb v0rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7k8Wov7jQEYM2rfxCLHxgiTqZOyUz2SP9zMZgrjLstQ=; b=LakYH8oLfkrc5XuJvZihVqcIK+TNwKoHXHMppnAK6LWBESjVNFOy4R8XCj2Y0Hqj3r FXqiZtyG9YCTTo4XGj/hw9as2lbOA2gXbmhws0GP7ohL03IKv10f7sSAl4HjAeJWfh3B ydtTnf/KtyeKa2h2DQqba/LF4FYDclBc4ZIKPzHQgPLPdUBbPLnk9pgodCdbhYwmBPoR UBzprQfe0QStB/lmWxB7zO98NPjWg1yLWfVLs0bmT8BX3tI04bjGzMLfPnuWjDWJmi7A CjZsWgorNxPdjZQDJKA3TtVId1eYkyh8goH5/Q9rD24YQ2x0Ufc6QjidY77eokHrd94C iGZA== X-Gm-Message-State: APjAAAX8u5hh3OOez+eKxH3lNsc4OeuL6/YGFGZjxuBZlIqI1I83oyOl FHh9fw/lJoqH2QEdNOLw368= X-Google-Smtp-Source: APXvYqykYNGfLyRHcSceDFKQLfRdvTv1c51cU0Ka04/27TJyn/P9BrF/GYdVDBaKulcrLEZytrEBHQ== X-Received: by 2002:a0c:c956:: with SMTP id v22mr10511251qvj.164.1556921642900; Fri, 03 May 2019 15:14:02 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id s185sm1844500qkf.74.2019.05.03.15.13.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 03 May 2019 15:14:01 -0700 (PDT) Date: Fri, 3 May 2019 19:13:50 -0300 From: Melissa Wen To: Lars-Peter Clausen , Michael Hennerich , Stefan Popa , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Barry Song <21cnbao@gmail.com> Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH 1/4] staging: iio: ad7150: organize registers definition Message-ID: <10781f40fa8a403480833e49b7356ade5af57b94.1556919363.git.melissa.srw@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 Use the suffix REG to make the register addresses clear and indentation to highlight field names. Signed-off-by: Melissa Wen --- drivers/staging/iio/cdc/ad7150.c | 75 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index dd7fcab8e19e..24601ba7db88 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -15,35 +15,34 @@ #include #include #include -/* - * AD7150 registers definition - */ -#define AD7150_STATUS 0 -#define AD7150_STATUS_OUT1 BIT(3) -#define AD7150_STATUS_OUT2 BIT(5) -#define AD7150_CH1_DATA_HIGH 1 -#define AD7150_CH2_DATA_HIGH 3 -#define AD7150_CH1_AVG_HIGH 5 -#define AD7150_CH2_AVG_HIGH 7 -#define AD7150_CH1_SENSITIVITY 9 -#define AD7150_CH1_THR_HOLD_H 9 -#define AD7150_CH1_TIMEOUT 10 -#define AD7150_CH1_SETUP 11 -#define AD7150_CH2_SENSITIVITY 12 -#define AD7150_CH2_THR_HOLD_H 12 -#define AD7150_CH2_TIMEOUT 13 -#define AD7150_CH2_SETUP 14 -#define AD7150_CFG 15 -#define AD7150_CFG_FIX BIT(7) -#define AD7150_PD_TIMER 16 -#define AD7150_CH1_CAPDAC 17 -#define AD7150_CH2_CAPDAC 18 -#define AD7150_SN3 19 -#define AD7150_SN2 20 -#define AD7150_SN1 21 -#define AD7150_SN0 22 -#define AD7150_ID 23 +/* AD7150 registers */ + +#define AD7150_STATUS_REG 0x00 +#define AD7150_STATUS_OUT1 BIT(3) +#define AD7150_STATUS_OUT2 BIT(5) +#define AD7150_CH1_DATA_HIGH_REG 0x01 +#define AD7150_CH2_DATA_HIGH_REG 0x03 +#define AD7150_CH1_AVG_HIGH_REG 0x05 +#define AD7150_CH2_AVG_HIGH_REG 0x07 +#define AD7150_CH1_SENSITIVITY_REG 0x09 +#define AD7150_CH1_THR_HOLD_H_REG 0x09 +#define AD7150_CH2_SENSITIVITY_REG 0x0C +#define AD7150_CH1_TIMEOUT_REG 0x0A +#define AD7150_CH1_SETUP_REG 0x0B +#define AD7150_CH2_THR_HOLD_H_REG 0x0C +#define AD7150_CH2_TIMEOUT_REG 0x0D +#define AD7150_CH2_SETUP_REG 0x0E +#define AD7150_CFG_REG 0x0F +#define AD7150_CFG_FIX BIT(7) +#define AD7150_PD_TIMER_REG 0x10 +#define AD7150_CH1_CAPDAC_REG 0x11 +#define AD7150_CH2_CAPDAC_REG 0x12 +#define AD7150_SN3_REG 0x13 +#define AD7150_SN2_REG 0x14 +#define AD7150_SN1_REG 0x15 +#define AD7150_SN0_REG 0x16 +#define AD7150_ID_REG 0x17 /** * struct ad7150_chip_info - instance specific chip data @@ -85,12 +84,12 @@ struct ad7150_chip_info { */ static const u8 ad7150_addresses[][6] = { - { AD7150_CH1_DATA_HIGH, AD7150_CH1_AVG_HIGH, - AD7150_CH1_SETUP, AD7150_CH1_THR_HOLD_H, - AD7150_CH1_SENSITIVITY, AD7150_CH1_TIMEOUT }, - { AD7150_CH2_DATA_HIGH, AD7150_CH2_AVG_HIGH, - AD7150_CH2_SETUP, AD7150_CH2_THR_HOLD_H, - AD7150_CH2_SENSITIVITY, AD7150_CH2_TIMEOUT }, + { AD7150_CH1_DATA_HIGH_REG, AD7150_CH1_AVG_HIGH_REG, + AD7150_CH1_SETUP_REG, AD7150_CH1_THR_HOLD_H_REG, + AD7150_CH1_SENSITIVITY_REG, AD7150_CH1_TIMEOUT_REG }, + { AD7150_CH2_DATA_HIGH_REG, AD7150_CH2_AVG_HIGH_REG, + AD7150_CH2_SETUP_REG, AD7150_CH2_THR_HOLD_H_REG, + AD7150_CH2_SENSITIVITY_REG, AD7150_CH2_TIMEOUT_REG }, }; static int ad7150_read_raw(struct iio_dev *indio_dev, @@ -133,7 +132,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, bool adaptive; struct ad7150_chip_info *chip = iio_priv(indio_dev); - ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); + ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG_REG); if (ret < 0) return ret; @@ -229,7 +228,7 @@ static int ad7150_write_event_config(struct iio_dev *indio_dev, if (event_code == chip->current_event) return 0; mutex_lock(&chip->state_lock); - ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); + ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG_REG); if (ret < 0) goto error_ret; @@ -264,7 +263,7 @@ static int ad7150_write_event_config(struct iio_dev *indio_dev, cfg |= (!adaptive << 7) | (thresh_type << 5); - ret = i2c_smbus_write_byte_data(chip->client, AD7150_CFG, cfg); + ret = i2c_smbus_write_byte_data(chip->client, AD7150_CFG_REG, cfg); if (ret < 0) goto error_ret; @@ -497,7 +496,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) s64 timestamp = iio_get_time_ns(indio_dev); int ret; - ret = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS); + ret = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS_REG); if (ret < 0) return IRQ_HANDLED; From patchwork Fri May 3 22:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10929341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A18BE912 for ; Fri, 3 May 2019 22:14:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91439287D2 for ; Fri, 3 May 2019 22:14:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82A53287DA; Fri, 3 May 2019 22:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 7619E287D2 for ; Fri, 3 May 2019 22:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbfECWOr (ORCPT ); Fri, 3 May 2019 18:14:47 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:39999 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfECWOq (ORCPT ); Fri, 3 May 2019 18:14:46 -0400 Received: by mail-qk1-f196.google.com with SMTP id w20so4584318qka.7; Fri, 03 May 2019 15:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XY7o10BOh3Ussnn5GQ0UW2n/49hS/5+Ve7RxK2jXxNA=; b=eREjwxSw2EQeXDa6ksr5nzPOyVNCTRHxcTWHOnVQB7xAzBXKbRlBz1u2a7CTKV3ahr uwpsFRonSG8RzXz9Q++OMESMD0wEBw7K8bRAmbByfVG5IL3iqFWRzhC0NHM6HJKkuNBV fNxyn4sVWRcJcKF54kGwRhha/HztOU80rQBKjaHKijtVABONs6jEpGBapMrtzmLjcSYA 3oABiLWxYY23G7oUSdA0GPDx0cOr//BkHKDp/vJyvLeAAbAwjDHJnt0ny4AhDsw6efqY 7Ug57FMsTz/xaNTWZIPBUlmtH8Q5sG88jy7XuSYFxJTbgQyORvCmiSn8pp9V5SmQ2zQ5 no1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XY7o10BOh3Ussnn5GQ0UW2n/49hS/5+Ve7RxK2jXxNA=; b=Ntw/FqLiDez9IgIe43EjHbdgXFi7I4FOB2TEV4CTYWeHJmFsztoetIkvGg5P+YcalG rv7J0cUcz+vwo2zJ+LBh+5PujijEX95UEOwWMng2X9KpteOaNc3/0PreTGjzn7NKRTLn MfCUB4x2cQ09LuTXqbV17qpnbzg3WzCENaZNK+8BofQhC4iMV6NImaILGxRnT0ZsXBR5 4poXyde6tGoPHHQ8mofblLlkYf6n1s2oW1aKOH613/zunXbGwV2fV06kNWk062F52SXn Ss2H3Z+GnyHO4jRR3Chdkq8O4OosEhDXeAFKS5FSX3QK1hNRXauGELX+GuzXNZWyg/bs JCwQ== X-Gm-Message-State: APjAAAVpkXszw522e++ozdQ/dCF5fW4Rmy7Goo48JwZcnQRIZJf2bQRb 8/1u9HftBgQjO7I6oLJCyw0= X-Google-Smtp-Source: APXvYqy5/bIS6yRa4NkV4HaJxxsvNL19MtRuXYXfmxFxNLAlDYxjEuZ0SK3X0Ba3xKcP90ctdRWWIw== X-Received: by 2002:a37:2f05:: with SMTP id v5mr10123294qkh.157.1556921685702; Fri, 03 May 2019 15:14:45 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id 33sm1842035qtg.94.2019.05.03.15.14.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 03 May 2019 15:14:44 -0700 (PDT) Date: Fri, 3 May 2019 19:14:33 -0300 From: Melissa Wen To: Lars-Peter Clausen , Michael Hennerich , Stefan Popa , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Barry Song <21cnbao@gmail.com> Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH 2/4] staging: iio: ad7150: use FIELD_GET and GENMASK Message-ID: <7f7d36348bca1de25bd70350b7c665be6441250f.1556919363.git.melissa.srw@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 Use the bitfield macro FIELD_GET, and GENMASK to do the shift and mask in one go. This makes the code more readable than explicit masking followed by a shift. Signed-off-by: Melissa Wen Acked-by: Alexandru Ardelean --- drivers/staging/iio/cdc/ad7150.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 24601ba7db88..4ba46fb6ac02 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -5,6 +5,7 @@ * Copyright 2010-2011 Analog Devices Inc. */ +#include #include #include #include @@ -44,6 +45,9 @@ #define AD7150_SN0_REG 0x16 #define AD7150_ID_REG 0x17 +/* AD7150 masks */ +#define AD7150_THRESHTYPE_MSK GENMASK(6, 5) + /** * struct ad7150_chip_info - instance specific chip data * @client: i2c client for this device @@ -136,7 +140,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, if (ret < 0) return ret; - threshtype = (ret >> 5) & 0x03; + threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret); adaptive = !!(ret & 0x80); switch (type) { From patchwork Fri May 3 22:15:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10929347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAAA613AD for ; Fri, 3 May 2019 22:15:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA1EF287DA for ; Fri, 3 May 2019 22:15:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEC5F287DE; Fri, 3 May 2019 22:15:40 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 60D1F287DB for ; Fri, 3 May 2019 22:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726480AbfECWPj (ORCPT ); Fri, 3 May 2019 18:15:39 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46693 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfECWPj (ORCPT ); Fri, 3 May 2019 18:15:39 -0400 Received: by mail-qt1-f193.google.com with SMTP id i31so8488515qti.13; Fri, 03 May 2019 15:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SAG93eFHh+qaETzoOcFQNdt8rlclJfMfJCEB5tyPneU=; b=cxRMJufioKVdvfnJKfWHBXy6aUljGfxrLWnsauz+050JKcWB0haJPWdy0XJ3iBvW+Y svO5sSi08Sbc+rOJkObJqDwPph9vSPQoyflUwSt0ZOcbeJH+atKZxoZ98zBxY2qN5IOv hucZoLfhj7xtykRJhiwXWK0vJ/5+0weq/mTzoE3Ge591qXyOnsAZVAjWOmD+bN7/2Edf UmPQZ2hQLydG6WVM6AoQUCqxxX0MAMCzsLSVBTjh9qgRM5CEjzfi1eWBTauTms96wQDO QmL0grDYx7346Ad4PNAtBT/X4o4OIyE5ifb0K7zHfKV3qGvKn280hfiVDyQ5Sz7TWpy1 j4qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SAG93eFHh+qaETzoOcFQNdt8rlclJfMfJCEB5tyPneU=; b=FUc0vbkkYd+HbHIXpJajzCHgJ0uyFdUt9iMRO+55azxgFpWb9loAA4lJHkmhvinalB d28VQn8bDMx4RCr38VApmhhlCp8DNQycd2YyZ0pQeORmc7CDKm8GKlems3g4k+M+rnI8 aQltGCKyUiVgd3Xlg/k+8Ofdz2TYdzYgxyQf53cGFFFPURVvYbvMB/ke7M9B7QyJjzhZ y46ncjdYtI3pg1cj0T+PiIVNC9B5BP5eFZ9r7Njp8kC0dgiSY77QCC8T1jJ7sNrT3LKp RzYxYHMYxYcft77W1/fUHD7Mtvw3v2eqh4SzbMWw08q12djQQdXk0rObXLsmtHr/DNZH +rjA== X-Gm-Message-State: APjAAAUgSN36s81bADPjO8hz94DK+M6TGYojs+d3uFmlfCwErALhPZ56 boJdEydhrZIISG3vumfLBHM= X-Google-Smtp-Source: APXvYqwN3xXPr46LsBvXQoeM3xNHTgtquMHHKh1QvdRhT3+X053Z7iIDcWI/TfvRozWj41FcfVP6LA== X-Received: by 2002:a0c:92af:: with SMTP id b44mr4193122qvb.141.1556921738622; Fri, 03 May 2019 15:15:38 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id t26sm1807490qkm.82.2019.05.03.15.15.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 03 May 2019 15:15:37 -0700 (PDT) Date: Fri, 3 May 2019 19:15:25 -0300 From: Melissa Wen To: Lars-Peter Clausen , Michael Hennerich , Stefan Popa , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Barry Song <21cnbao@gmail.com> Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH 3/4] staging: iio: ad7150: simplify i2c SMBus return treatment Message-ID: <18725f7ddc3ac42b1c781b1848b05fabd4bd8320.1556919363.git.melissa.srw@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 Since i2c_smbus_write_byte_data returns no-positive value, this commit making the treatment of its return value less verbose. Signed-off-by: Melissa Wen --- drivers/staging/iio/cdc/ad7150.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 4ba46fb6ac02..3a4572a9e5ec 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -201,16 +201,12 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev, ret = i2c_smbus_write_byte_data(chip->client, ad7150_addresses[chan][4], sens); - if (ret < 0) + if (ret) return ret; - - ret = i2c_smbus_write_byte_data(chip->client, + else + return i2c_smbus_write_byte_data(chip->client, ad7150_addresses[chan][5], timeout); - if (ret < 0) - return ret; - - return 0; } static int ad7150_write_event_config(struct iio_dev *indio_dev, From patchwork Fri May 3 22:16:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10929351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FDD01398 for ; Fri, 3 May 2019 22:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F851287DB for ; Fri, 3 May 2019 22:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1140D287E0; Fri, 3 May 2019 22:16:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 B5304287DB for ; Fri, 3 May 2019 22:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726402AbfECWQ0 (ORCPT ); Fri, 3 May 2019 18:16:26 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:45659 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfECWQZ (ORCPT ); Fri, 3 May 2019 18:16:25 -0400 Received: by mail-qk1-f195.google.com with SMTP id d5so318007qko.12; Fri, 03 May 2019 15:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HXos2jVvt23sEGQ2FQBQJsKRHBVFtxk8JTRDuuOZjhU=; b=cshVJY3SgZerxIj0AHhggAibB5NZbPleKezdrPUdWojsti39ecMZQU/GdNIbxlhrYu jkcn/oslpB1yTTpXF5+cBKLS3JTLfkGsWuWlqNRp8FnSXSGjdhUaoRcxaB1fiwkFL28O L8H8TCMUJ64MaQZlHsePK5mBFq/OsUqCFBRpE3LwHv6ed7Eetpxhhrz7G1ipwt8RoLFN 2VxwMozP6w/7IccThhvPKf1UDFw5oTJ6FvZ0czG4U3APBy1gnCnlp56lNnluraNqwx5Y coAUj0L4rf/TTiwYb+DdbQmjk/OcVSqM61xn4FvLzjJdUWlBncBeNs0UGumszChPweLZ gS0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HXos2jVvt23sEGQ2FQBQJsKRHBVFtxk8JTRDuuOZjhU=; b=Bw24jrWtsjDfnymean2rC2GD2JiQ6oLX04UKReZ4oIFHnlZcjqPMbl5V1X3KlMC7PG ygVh7PhMTXvTqKTizDtbNEIP9wVWQx4wKCB1EZOltbX/GSQIXpDP7uwZBvXndcL2+8bI iJW9aruRh5oDKDxEp7jYDdLaDijcSh1W5qAtnDftBrV9XaR5PLD7MWNmk7QeFlPWMFvJ hwhORWl9nBYZk8wCNy84oFKHCtnDxGI7F3ueloZkFyFyzdVNAwvcHGWlNGOvr0tLLz4s KmSezMPh7glblmIOcQdCA4N8/SRGmlyWsjXWnQo3MB2prtdlR/G/Qx3aR4nHoX+HMcbn VJwA== X-Gm-Message-State: APjAAAWT2TUId3UPpWcbp6mlbs3Yy7nqJE5crQTdbkzuMnUQKLWL1mo7 Ru9AYBgUO/sFVKvZDa4Lzjg= X-Google-Smtp-Source: APXvYqwloUvPCdvnkCdnkj6YxY613wMJymZiRu4zYZ9KXa+nkanvvNwayrSaDiyLrWtFFgviThhyZA== X-Received: by 2002:a05:620a:1326:: with SMTP id p6mr8885799qkj.265.1556921784672; Fri, 03 May 2019 15:16:24 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id j39sm2050285qtj.69.2019.05.03.15.16.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 03 May 2019 15:16:23 -0700 (PDT) Date: Fri, 3 May 2019 19:16:13 -0300 From: Melissa Wen To: Lars-Peter Clausen , Michael Hennerich , Stefan Popa , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Barry Song <21cnbao@gmail.com> Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH 4/4] staging: iio: ad7150: clean up of comments Message-ID: <35ccb46902d0a9a79b5c481d3d3cb9256a390c99.1556919363.git.melissa.srw@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 General cleaning of comments to remove useless information or improve description. Signed-off-by: Melissa Wen --- drivers/staging/iio/cdc/ad7150.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 3a4572a9e5ec..775818b0761e 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -162,7 +162,8 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, return -EINVAL; } -/* lock should be held */ +/* state_lock should be held to ensure consistent state*/ + static int ad7150_write_event_params(struct iio_dev *indio_dev, unsigned int chan, enum iio_event_type type, @@ -484,10 +485,6 @@ static const struct iio_chan_spec ad7150_channels[] = { }, }; -/* - * threshold events - */ - static irqreturn_t ad7150_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; @@ -576,10 +573,6 @@ static const struct iio_info ad7150_info = { .write_event_value = &ad7150_write_event_value, }; -/* - * device probe and remove - */ - static int ad7150_probe(struct i2c_client *client, const struct i2c_device_id *id) {