Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1064813yba; Fri, 3 May 2019 15:26:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1mYRAXQ+qBU9N9Tbgqc8mZ+5ms4NnILNiN5VoBh+WUo3mnl9HFvNbZ8U+3bxVsSqTYG8s X-Received: by 2002:aa7:9206:: with SMTP id 6mr14431112pfo.71.1556922392026; Fri, 03 May 2019 15:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556922392; cv=none; d=google.com; s=arc-20160816; b=FfaBN7a6Q9TKwHMoTce6OHKeRtY3w6NbYO50d5QOH/wfIJ6REkVF+DexoUm0EG8cPW UgX/7t17r+mrekQZj6QFg/w/ym2YCM3DpFGK5a4YHy1dn2rHUx/o2KRS/cAVo2/6Qaiy 2ioHSh+O3ZXDXFA0OcEGWJvrrFZ+C7nhypsOQWHhDSJrB4mL/57V0mmTnezLUJtO3qj1 t8UrwYJBeXPWms0DywGu0NeIdTSAtQWxuMlD+kDy9GDnxRtVr1SkamWrn02wxdwvNFGf MUX8CP8P2nFN+d9GvEhpiuyusYUJijk16bqh56QrFMTfWOt7tOQDxdOtCoPUf3FPjpGs OKyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7k8Wov7jQEYM2rfxCLHxgiTqZOyUz2SP9zMZgrjLstQ=; b=VrQz1Ekr2yLYDsUHWIdBPueV1KXshbzXEyV0wQAre6rs0JnnhLstIHJmHJipWZW9CR CTz8V8VyZCrYQPU5p4zTrB5Misu7Q0AZkHgNAptS//C/dFsDNDesSOhNQfcamKm/7vSQ woe1Ww9axc31YwKHrqG0YMSuQjOZTRVtrr2xz5SfGk16XZKtew70afDapNzGW96uOyxJ hBlgNtFxsMBgNvoWTcqbCRvPICBET3DcDPbMHJlgzCNhcxtkSCsvhWQOg7BJzg/lxFx7 YAfcZvx8SoUH5ADsQgoXkSe90BX2OioKfNCiMXzqc+24q7KvV3AkpYONtDOX64kIr8/1 mM0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bhw7KkQU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j7si4544603pfb.75.2019.05.03.15.26.16; Fri, 03 May 2019 15:26:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bhw7KkQU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727036AbfECWOE (ORCPT + 99 others); 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-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.20.1