From patchwork Tue Apr 21 00:31:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B726A18EC for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F4C0206CD for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726294AbgDUAbk (ORCPT ); Mon, 20 Apr 2020 20:31:40 -0400 Received: from mga06.intel.com ([134.134.136.31]:1770 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbgDUAbj (ORCPT ); Mon, 20 Apr 2020 20:31:39 -0400 IronPort-SDR: gUgr8fIGwCb+KesxVonCShvStQt9ikeXtsrkvTLkK+G8PWkKETBosF8m7qtTGN341Xue06nRii jyfsg7OkK3cg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:39 -0700 IronPort-SDR: iVHb9kVFSdraTjZD0PzJ9l6wUour1qaM4OXU6FeDa2+fOn5paTKzwFjDxec5TyhAZPdFfg3MZE Oda50asD/+MA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="365175463" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 20 Apr 2020 17:31:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 68AB6190; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich Subject: [PATCH v1 01/16] iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:20 +0300 Message-Id: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Cc: Lars-Peter Clausen Cc: Michael Hennerich Signed-off-by: Andy Shevchenko Acked-by: Nuno Sá --- drivers/iio/adc/ad_sigma_delta.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index 8115b6de1d6c..dd3d54b3bc8b 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -70,9 +70,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg, switch (size) { case 3: - data[1] = val >> 16; - data[2] = val >> 8; - data[3] = val; + put_unaligned_be24(val, &data[1]); break; case 2: put_unaligned_be16(val, &data[1]); @@ -157,9 +155,7 @@ int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta, *val = get_unaligned_be32(sigma_delta->data); break; case 3: - *val = (sigma_delta->data[0] << 16) | - (sigma_delta->data[1] << 8) | - sigma_delta->data[2]; + *val = get_unaligned_be24(&sigma_delta->data[0]); break; case 2: *val = get_unaligned_be16(sigma_delta->data); From patchwork Tue Apr 21 00:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57C1B112C for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41409206CD for ; Tue, 21 Apr 2020 00:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbgDUAbi (ORCPT ); Mon, 20 Apr 2020 20:31:38 -0400 Received: from mga12.intel.com ([192.55.52.136]:14368 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbgDUAbi (ORCPT ); Mon, 20 Apr 2020 20:31:38 -0400 IronPort-SDR: BcN4WwZbXe9SnogNRTQXFGBK6vaSss0UktJhwd230sDK+su/3LW67mSYagUwb/3nzYSHYweEbD zdtOTyKGLCXA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:38 -0700 IronPort-SDR: meXAvUcpVOh42i9bLUwteUinHNOCl9wSQIUkGoCPEK09T3z+doRkCjbnShH8JcWPyeUQc2peAQ CVcssNkTYeYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="290282128" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 20 Apr 2020 17:31:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 775A517F; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 02/16] iio: adc: mpc3422: Use get_unaligned_beXX() Date: Tue, 21 Apr 2020 03:31:21 +0300 Message-Id: <20200421003135.23060-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/mcp3422.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index ea24d7c58b12..b247eb209f10 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -117,11 +117,11 @@ static int mcp3422_read(struct mcp3422 *adc, int *value, u8 *config) if (sample_rate == MCP3422_SRATE_3) { ret = i2c_master_recv(adc->i2c, buf, 4); - temp = buf[0] << 16 | buf[1] << 8 | buf[2]; + temp = get_unaligned_be24(&buf[0]); *config = buf[3]; } else { ret = i2c_master_recv(adc->i2c, buf, 3); - temp = buf[0] << 8 | buf[1]; + temp = get_unaligned_be16(&buf[0]); *config = buf[2]; } From patchwork Tue Apr 21 00:31:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B66781 for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53D46214AF for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbgDUAbj (ORCPT ); Mon, 20 Apr 2020 20:31:39 -0400 Received: from mga05.intel.com ([192.55.52.43]:54519 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgDUAbi (ORCPT ); Mon, 20 Apr 2020 20:31:38 -0400 IronPort-SDR: sCjClnDdZSIQS2MaL4EmEj2VVJ37vUETEQLaAGs6DGfXV1FgORntQdyHUhd/zdcy6DLr+27U3y r3PqndSD0Y4g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:38 -0700 IronPort-SDR: mo6a4o2LqsorKOHeq2OFr6ANkFkPqzKdp0UvEmW25KLsEcq9TFvXjQvkS8uOoZ0Yv0wT7Hj8je N8sOscIvKyCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="245528002" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 20 Apr 2020 17:31:36 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 87162233; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 03/16] iio: adc: ti-ads124s08: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:22 +0300 Message-Id: <20200421003135.23060-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/ti-ads124s08.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index 552c2be8d87a..2516e42ad00d 100644 --- a/drivers/iio/adc/ti-ads124s08.c +++ b/drivers/iio/adc/ti-ads124s08.c @@ -188,7 +188,6 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan) { struct ads124s_private *priv = iio_priv(indio_dev); int ret; - u32 tmp; struct spi_transfer t[] = { { .tx_buf = &priv->data[0], @@ -208,9 +207,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan) if (ret < 0) return ret; - tmp = priv->data[2] << 16 | priv->data[3] << 8 | priv->data[4]; - - return tmp; + return get_unaligned_be24(&priv->data[2]); } static int ads124s_read_raw(struct iio_dev *indio_dev, From patchwork Tue Apr 21 00:31:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DDC217EA for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70BDF206CD for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726325AbgDUAbj (ORCPT ); Mon, 20 Apr 2020 20:31:39 -0400 Received: from mga04.intel.com ([192.55.52.120]:20088 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgDUAbj (ORCPT ); Mon, 20 Apr 2020 20:31:39 -0400 IronPort-SDR: 5RhkfgyHtc9yrzkvxN64qXpHjthDH0G3Q4scxcfzIxdz3bQ6MTcAfatLqU6NohmXnCGXsSUysP YDYTQKzKgdCg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:38 -0700 IronPort-SDR: QUhch9b00CvjXDN7rloaIAg2mmkJBFHnbCl073WPPWK4LsjojfX4eiO/vl4Tg11m/VU5RMu4S5 SK/US9/L3PCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="255113798" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2020 17:31:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 90E19206; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 04/16] iio: dac: ltc2632: Use put_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:23 +0300 Message-Id: <20200421003135.23060-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/dac/ltc2632.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c index 7adc91056aa1..5123776cb63e 100644 --- a/drivers/iio/dac/ltc2632.c +++ b/drivers/iio/dac/ltc2632.c @@ -75,9 +75,7 @@ static int ltc2632_spi_write(struct spi_device *spi, * 10-, 8-bit input code followed by 4, 6, or 8 don't care bits. */ data = (cmd << 20) | (addr << 16) | (val << shift); - msg[0] = data >> 16; - msg[1] = data >> 8; - msg[2] = data; + put_unaligned_be24(data, &msg[0]); return spi_write(spi, msg, sizeof(msg)); } From patchwork Tue Apr 21 00:31:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A5C814B4 for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83717206CD for ; Tue, 21 Apr 2020 00:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgDUAbj (ORCPT ); Mon, 20 Apr 2020 20:31:39 -0400 Received: from mga05.intel.com ([192.55.52.43]:54519 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726294AbgDUAbj (ORCPT ); Mon, 20 Apr 2020 20:31:39 -0400 IronPort-SDR: 7BtgwoEoZM0GajdqgceMbpwvGN8wdCcz9EZVBWEm2VvUIFNI/2qdBVanFd1dS8+4Ego4Dqw5X0 0o0es91iy44A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:39 -0700 IronPort-SDR: X1FMPXsp5KTf+RaL9L3bxflMNVUc5I8np2KoXJZOoRJ0OLkgsWQAsnZVwz8pdodhvZcmTDy+qL Nqtp9Yi2eJTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="300437795" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Apr 2020 17:31:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A083D29A; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich Subject: [PATCH v1 05/16] iio: dac: ad5624r_spi: Use put_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:24 +0300 Message-Id: <20200421003135.23060-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Cc: Lars-Peter Clausen Cc: Michael Hennerich Signed-off-by: Andy Shevchenko Acked-by: Nuno Sá --- drivers/iio/dac/ad5624r_spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index e6c022e1dc1c..394d9d23ba63 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c @@ -35,11 +35,9 @@ static int ad5624r_spi_write(struct spi_device *spi, * for the AD5664R, AD5644R, and AD5624R, respectively. */ data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift); - msg[0] = data >> 16; - msg[1] = data >> 8; - msg[2] = data; + put_unaligned_be24(data, &msg[0]); - return spi_write(spi, msg, 3); + return spi_write(spi, msg, sizeof(msg)); } static int ad5624r_read_raw(struct iio_dev *indio_dev, From patchwork Tue Apr 21 00:31:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C11C714B4 for ; Tue, 21 Apr 2020 00:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF1DB206CD for ; Tue, 21 Apr 2020 00:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726707AbgDUAbn (ORCPT ); Mon, 20 Apr 2020 20:31:43 -0400 Received: from mga12.intel.com ([192.55.52.136]:14368 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: eLDQb+hPgZ+mpfelpYuGsuH5dCwn/nzFh6WWI3ImnFyMvWZNUYZMs+rKuje50B5rlsTeKOiWTN tSgpa3GMHSig== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:40 -0700 IronPort-SDR: 2OKV5EqA48DG5SAYMSuF/3f0YLoZtHAIRQA2Uj1ofyRJMzGs/vj98YUQN2+fb//djDgqKDPero LBk8a516XPWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="290282134" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A5F24238; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich Subject: [PATCH v1 06/16] iio: dac: ad5446: Use put_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:25 +0300 Message-Id: <20200421003135.23060-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Cc: Lars-Peter Clausen Cc: Michael Hennerich Signed-off-by: Andy Shevchenko --- drivers/iio/dac/ad5446.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c index 61c670f7fc5f..87ff863bdc10 100644 --- a/drivers/iio/dac/ad5446.c +++ b/drivers/iio/dac/ad5446.c @@ -302,9 +302,7 @@ static int ad5660_write(struct ad5446_state *st, unsigned val) struct spi_device *spi = to_spi_device(st->dev); uint8_t data[3]; - data[0] = (val >> 16) & 0xFF; - data[1] = (val >> 8) & 0xFF; - data[2] = val & 0xFF; + put_unaligned_be24(val, &data[0]); return spi_write(spi, data, sizeof(data)); } From patchwork Tue Apr 21 00:31:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A711814B4 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C2D622250 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbgDUAbm (ORCPT ); Mon, 20 Apr 2020 20:31:42 -0400 Received: from mga05.intel.com ([192.55.52.43]:54519 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: gt7oVZaZooz3NyijR7vBzx6nSXffUvUewaBsroOc5W7UwFeEvn819pO/IXzuUYBjhdOO0Cdns5 ynM0sT4F62uQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:41 -0700 IronPort-SDR: NK0nZThW8tBiJ0KD43QIzPLN7+Wpm637bmqDLUvB6/pI31ocnIH/5g1al2mv3llNumBwJqi7h7 UeqKLXMCDcQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="300437801" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B50FE426; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich Subject: [PATCH v1 07/16] iio: gyro: adis16130: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:26 +0300 Message-Id: <20200421003135.23060-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Cc: Lars-Peter Clausen Cc: Michael Hennerich Signed-off-by: Andy Shevchenko Acked-by: Nuno Sá --- drivers/iio/gyro/adis16130.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c index 79e63c8a2ea8..b8d626bc30ad 100644 --- a/drivers/iio/gyro/adis16130.c +++ b/drivers/iio/gyro/adis16130.c @@ -59,7 +59,7 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val) ret = spi_sync_transfer(st->us, &xfer, 1); if (ret == 0) - *val = (st->buf[1] << 16) | (st->buf[2] << 8) | st->buf[3]; + *val = get_unaligned_be24(&st->buf[1]); mutex_unlock(&st->buf_lock); return ret; From patchwork Tue Apr 21 00:31:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0A0414B4 for ; Tue, 21 Apr 2020 00:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6E8222247 for ; Tue, 21 Apr 2020 00:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726445AbgDUAbm (ORCPT ); Mon, 20 Apr 2020 20:31:42 -0400 Received: from mga04.intel.com ([192.55.52.120]:20088 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: UAcz9cRvbSUQsE6mrrYM8RE5ulDD57wVFstnJOc8BKJjS9Iqpnp9mVwT2ndq4bl/Caq4ik7yNP Um6j0+aVStUQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:40 -0700 IronPort-SDR: Y6jY1HYt0fG061j2RRqe7uANxyzoHPLMZZKfw+DC0VNl1writdPT2Mk5JIZ1rU4oJS9uOD0j2K 3RxslXe5YLtw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="255113824" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BA976403; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 08/16] iio: health: afe4403: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:27 +0300 Message-Id: <20200421003135.23060-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/health/afe4403.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index dc22dc363a99..db44b53e9330 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -220,13 +220,11 @@ static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val) if (ret) return ret; - ret = spi_write_then_read(afe->spi, ®, 1, rx, 3); + ret = spi_write_then_read(afe->spi, ®, 1, rx, sizeof(rx)); if (ret) return ret; - *val = (rx[0] << 16) | - (rx[1] << 8) | - (rx[2]); + *val = get_unaligned_be24(&rx[0]); /* Disable reading from the device */ tx[3] = AFE440X_CONTROL0_WRITE; @@ -322,13 +320,11 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private) indio_dev->masklength) { ret = spi_write_then_read(afe->spi, &afe4403_channel_values[bit], 1, - rx, 3); + rx, sizeof(rx)); if (ret) goto err; - buffer[i++] = (rx[0] << 16) | - (rx[1] << 8) | - (rx[2]); + buffer[i++] = get_unaligned_be24(&rx[0]); } /* Disable reading from the device */ From patchwork Tue Apr 21 00:31:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33001112C for ; Tue, 21 Apr 2020 00:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B38B22247 for ; Tue, 21 Apr 2020 00:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 Received: from mga05.intel.com ([192.55.52.43]:54521 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: ptrFF53BKQJ1L71TuP8DUSWp3L3AiJHlArusSARncOiBQVmr+gDYzOz02XU4uuN38CjwyHLkAD esyG602530lA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:40 -0700 IronPort-SDR: KMBMpteIQPdTFsV9ys07O2aEzfXwNCEE6WWZ3ggwNaUOFjlXtvS+cY/SrQHbzVNKtDaBq/DtnJ VjGxf+PbkLHA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="300437802" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C932C556; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , =?utf-8?q?Maxime_Ro?= =?utf-8?q?ussin-B=C3=A9langer?= Subject: [PATCH v1 09/16] iio: light: si1133: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:28 +0300 Message-Id: <20200421003135.23060-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Cc: Maxime Roussin-Bélanger Signed-off-by: Andy Shevchenko --- drivers/iio/light/si1133.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c index 9174ab928880..8931a8afbafc 100644 --- a/drivers/iio/light/si1133.c +++ b/drivers/iio/light/si1133.c @@ -104,8 +104,6 @@ #define SI1133_LUX_BUFFER_SIZE 9 #define SI1133_MEASURE_BUFFER_SIZE 3 -#define SI1133_SIGN_BIT_INDEX 23 - static const int si1133_scale_available[] = { 1, 2, 4, 8, 16, 32, 64, 128}; @@ -633,8 +631,7 @@ static int si1133_measure(struct si1133_data *data, if (err) return err; - *val = sign_extend32((buffer[0] << 16) | (buffer[1] << 8) | buffer[2], - SI1133_SIGN_BIT_INDEX); + *val = sign_extend32(get_unaligned_be24(&buffer[0]), 23); return err; } @@ -723,16 +720,11 @@ static int si1133_get_lux(struct si1133_data *data, int *val) if (err) return err; - high_vis = - sign_extend32((buffer[0] << 16) | (buffer[1] << 8) | buffer[2], - SI1133_SIGN_BIT_INDEX); + high_vis = sign_extend32(get_unaligned_be24(&buffer[0]), 23); - low_vis = - sign_extend32((buffer[3] << 16) | (buffer[4] << 8) | buffer[5], - SI1133_SIGN_BIT_INDEX); + low_vis = sign_extend32(get_unaligned_be24(&buffer[3]), 23); - ir = sign_extend32((buffer[6] << 16) | (buffer[7] << 8) | buffer[8], - SI1133_SIGN_BIT_INDEX); + ir = sign_extend32(get_unaligned_be24(&buffer[6]), 23); if (high_vis > SI1133_ADC_THRESHOLD || ir > SI1133_ADC_THRESHOLD) lux = si1133_calc_polynomial(high_vis, ir, From patchwork Tue Apr 21 00:31:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4097A17EA for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3193A22251 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 Received: from mga05.intel.com ([192.55.52.43]:54519 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726445AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: TLqs7GL6a87bEg9F9cIwWheJtN4mNISUmE/KkyLxoM6c6G53wf0LvyXBn3DoAaahz8QK7CpxAE yl7WK/kRGkWw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:40 -0700 IronPort-SDR: Gp7CVy/mvGKxooyN7+gqr02uUv3P7JZcbNROcgr9vUYijrWDBf5XxPgDPApBuC9gL5dTzNByP3 ST5Itgi3MfRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="300437803" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CE45148C; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 10/16] iio: light: zopt2201: Use get_unaligned_le24() Date: Tue, 21 Apr 2020 03:31:29 +0300 Message-Id: <20200421003135.23060-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/light/zopt2201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/zopt2201.c b/drivers/iio/light/zopt2201.c index 5f54f39e7a4c..0df45b42c091 100644 --- a/drivers/iio/light/zopt2201.c +++ b/drivers/iio/light/zopt2201.c @@ -219,7 +219,7 @@ static int zopt2201_read(struct zopt2201_data *data, u8 reg) goto fail; mutex_unlock(&data->lock); - return (buf[2] << 16) | (buf[1] << 8) | buf[0]; + return get_unaligned_le24(&buf[0]); fail: mutex_unlock(&data->lock); From patchwork Tue Apr 21 00:31:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AE4A81 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 118C322250 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbgDUAbm (ORCPT ); Mon, 20 Apr 2020 20:31:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:14371 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: ThDCAsS8TNmZ8ZPeMUNBuVenSKbV1wmtLaXOCW+ssIISDo0rwNwrBthMwUILrsihEJ0JEKAOvC 4Lb28fRAp3hQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:41 -0700 IronPort-SDR: r4m44uXAf1E6UkhoqwsU7DPpk0BSIPKbq/aoBTqKJ6vVYTGmwLKwob12dUWVCxOSW0CVjs9748 vhDylAxP6eiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="290282135" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DC9F46D8; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , Song Qiang Subject: [PATCH v1 11/16] iio: magnetometer: rm3100: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:30 +0300 Message-Id: <20200421003135.23060-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Cc: Song Qiang Signed-off-by: Andy Shevchenko --- drivers/iio/magnetometer/rm3100-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c index 7c20918d8108..b3ae9a6c439b 100644 --- a/drivers/iio/magnetometer/rm3100-core.c +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -223,8 +223,7 @@ static int rm3100_read_mag(struct rm3100_data *data, int idx, int *val) goto unlock_return; mutex_unlock(&data->lock); - *val = sign_extend32((buffer[0] << 16) | (buffer[1] << 8) | buffer[2], - 23); + *val = sign_extend32(get_unalinged_be24(&buffer[0]), 23); return IIO_VAL_INT; From patchwork Tue Apr 21 00:31:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA40D112C for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD70C208E4 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726659AbgDUAbm (ORCPT ); Mon, 20 Apr 2020 20:31:42 -0400 Received: from mga17.intel.com ([192.55.52.151]:43075 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: xy+b+FcIGusK1VJRxyBUF6ew8aTC+qAmrODbaR5HQ6w4UVLFofEDne7GQtjwBG8j80gsSiiiJW 5AcWbo4PvGGw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:41 -0700 IronPort-SDR: Y0Sac913DexQRxUYT+71bofMzSOE2YoK9DIpm8h9NC8HCyP/SkZvWL5g1bAppyKmkq0FNdoz+k YeIOKjyfDXNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="244002919" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E1BC25F5; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 12/16] iio: pressure: hp206c: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:31 +0300 Message-Id: <20200421003135.23060-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/pressure/hp206c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c index 3ac3632e7242..d746882eccc8 100644 --- a/drivers/iio/pressure/hp206c.c +++ b/drivers/iio/pressure/hp206c.c @@ -93,12 +93,12 @@ static int hp206c_read_20bit(struct i2c_client *client, u8 cmd) int ret; u8 values[3]; - ret = i2c_smbus_read_i2c_block_data(client, cmd, 3, values); + ret = i2c_smbus_read_i2c_block_data(client, cmd, sizeof(values), values); if (ret < 0) return ret; - if (ret != 3) + if (ret != sizeof(values)) return -EIO; - return ((values[0] & 0xF) << 16) | (values[1] << 8) | (values[2]); + return get_unaligned_be24(&values[0]) & GENMASK(19, 0); } /* Spin for max 160ms until DEV_RDY is 1, or return error. */ From patchwork Tue Apr 21 00:31:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2012217EA for ; Tue, 21 Apr 2020 00:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1173A208E4 for ; Tue, 21 Apr 2020 00:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgDUAbn (ORCPT ); Mon, 20 Apr 2020 20:31:43 -0400 Received: from mga07.intel.com ([134.134.136.100]:58406 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbgDUAbm (ORCPT ); Mon, 20 Apr 2020 20:31:42 -0400 IronPort-SDR: uAJTQRTeDeaBTNa21S3CiELzbwg8iX2ZGBBHgxX0f+2uCfqKRRPChYrhvVH1b7rq3x9mqheFSR ISBpwakLZFaQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:41 -0700 IronPort-SDR: 61i1H+BB99Ipc6Q5tjkfUjpPhlbU19LZCORx6vN38UV8Ttvf/PnloqvIX7xXidD5jc5S906Jaz Qj4n353Uvnog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="291433482" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 20 Apr 2020 17:31:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id EB48E70F; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 13/16] iio: pressure: ms5611: Use get_unaligned_be24() Date: Tue, 21 Apr 2020 03:31:32 +0300 Message-Id: <20200421003135.23060-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko Acked-by: Tomasz Duszynski --- drivers/iio/pressure/ms5611_i2c.c | 2 +- drivers/iio/pressure/ms5611_spi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/ms5611_i2c.c b/drivers/iio/pressure/ms5611_i2c.c index 8089c59adce5..ced83162ae94 100644 --- a/drivers/iio/pressure/ms5611_i2c.c +++ b/drivers/iio/pressure/ms5611_i2c.c @@ -50,7 +50,7 @@ static int ms5611_i2c_read_adc(struct ms5611_state *st, s32 *val) if (ret < 0) return ret; - *val = (buf[0] << 16) | (buf[1] << 8) | buf[2]; + *val = get_unaligned_be24(&buf[0]); return 0; } diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c index b463eaa799ab..517295616869 100644 --- a/drivers/iio/pressure/ms5611_spi.c +++ b/drivers/iio/pressure/ms5611_spi.c @@ -45,7 +45,7 @@ static int ms5611_spi_read_adc(struct device *dev, s32 *val) if (ret < 0) return ret; - *val = (buf[0] << 16) | (buf[1] << 8) | buf[2]; + *val = get_unaligned_be24(&buf[0]); return 0; } From patchwork Tue Apr 21 00:31:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA13781 for ; Tue, 21 Apr 2020 00:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BF6B206CD for ; Tue, 21 Apr 2020 00:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbgDUAbn (ORCPT ); Mon, 20 Apr 2020 20:31:43 -0400 Received: from mga04.intel.com ([192.55.52.120]:20091 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbgDUAbl (ORCPT ); Mon, 20 Apr 2020 20:31:41 -0400 IronPort-SDR: ItCgPnFJd5G99rqV5bV625d2n/5+EGxApajqlkp6aijxVeX7KsnIrnjDqt5Tyj2ioGGQDZL1B6 29UaHg4kG61Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:41 -0700 IronPort-SDR: I/yaiVRXp1g4FoxCVFxrorLhD6mnpIw5vzhoJdd8y2ZvxyrnQ0NwxPgsA4h/Y6ZyEOVBYNt42c XlgLMO0QS+UA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="255113827" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2020 17:31:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id F2020796; Tue, 21 Apr 2020 03:31:36 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 14/16] iio: pressure: zpa2326: Use get_unaligned_le24() Date: Tue, 21 Apr 2020 03:31:33 +0300 Message-Id: <20200421003135.23060-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/pressure/zpa2326.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index 99dfe33ee402..c2ad106e3d5b 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -1005,22 +1005,20 @@ static int zpa2326_fetch_raw_sample(const struct iio_dev *indio_dev, struct regmap *regs = ((struct zpa2326_private *) iio_priv(indio_dev))->regmap; int err; + u8 v[3]; switch (type) { case IIO_PRESSURE: zpa2326_dbg(indio_dev, "fetching raw pressure sample"); - err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, value, - 3); + err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, v, sizeof(v)); if (err) { zpa2326_warn(indio_dev, "failed to fetch pressure (%d)", err); return err; } - /* Pressure is a 24 bits wide little-endian unsigned int. */ - *value = (((u8 *)value)[2] << 16) | (((u8 *)value)[1] << 8) | - ((u8 *)value)[0]; + *value = get_unaligned_le24(&v[0]); return IIO_VAL_INT; From patchwork Tue Apr 21 00:31:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4EFF1892 for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5E20206CD for ; Tue, 21 Apr 2020 00:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726611AbgDUAbn (ORCPT ); Mon, 20 Apr 2020 20:31:43 -0400 Received: from mga17.intel.com ([192.55.52.151]:43075 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbgDUAbm (ORCPT ); Mon, 20 Apr 2020 20:31:42 -0400 IronPort-SDR: mcBSU+F0+cFdfBVJjkqnHO2h6/9gqn6YCHtbsbqkmCw7hVYFKQqqcG0RuHDWTg46SlQxTEGhZm j/8DcMRd2kSw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:41 -0700 IronPort-SDR: YE7B1vJBS/5fNRUTiAVB0uvXr0Zbu4sCaeJamsZ+JBQE6OfRtyVtK76Go83ycD2sV3YbmO5vj8 C2/dMp/6hsng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="244002922" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 20 Apr 2020 17:31:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 04B8A871; Tue, 21 Apr 2020 03:31:37 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 15/16] iio: temperature: max31856: Use get_unaligned_beXX() Date: Tue, 21 Apr 2020 03:31:34 +0300 Message-Id: <20200421003135.23060-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko --- drivers/iio/temperature/max31856.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index b4cb21ab2e85..e1966889a962 100644 --- a/drivers/iio/temperature/max31856.c +++ b/drivers/iio/temperature/max31856.c @@ -168,7 +168,7 @@ static int max31856_thermocouple_read(struct max31856_data *data, if (ret) return ret; /* Skip last 5 dead bits of LTCBL */ - *val = (reg_val[0] << 16 | reg_val[1] << 8 | reg_val[2]) >> 5; + *val = get_unaligned_be24(®_val[0]) >> 5; /* Check 7th bit of LTCBH reg. value for sign*/ if (reg_val[0] & 0x80) *val -= 0x80000; @@ -185,7 +185,7 @@ static int max31856_thermocouple_read(struct max31856_data *data, /* Get Cold Junction Temp. offset register value */ offset_cjto = reg_val[0]; /* Get CJTH and CJTL value and skip last 2 dead bits of CJTL */ - *val = (reg_val[1] << 8 | reg_val[2]) >> 2; + *val = get_unaligned_be16(®_val[1]) >> 2; /* As per datasheet add offset into CJTH and CJTL */ *val += offset_cjto; /* Check 7th bit of CJTH reg. value for sign */ From patchwork Tue Apr 21 00:31:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11500161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D0A7112C for ; Tue, 21 Apr 2020 00:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F9D7208E4 for ; Tue, 21 Apr 2020 00:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgDUAbo (ORCPT ); Mon, 20 Apr 2020 20:31:44 -0400 Received: from mga04.intel.com ([192.55.52.120]:20093 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbgDUAbn (ORCPT ); Mon, 20 Apr 2020 20:31:43 -0400 IronPort-SDR: nVD3TA90F3be5FCUqcSBWEu3xgPSvq0aEGaQLxL6VJ+iWEDIoRILkLJsufAicDXM8y+QHLgKN5 xGpOXJ6TfCxg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 17:31:42 -0700 IronPort-SDR: IwmJ/v6ATFdORK3NQ+Bs2Wl+ntg8k5kXOeXmpMZFACWJ9t95s/1IHZewauu+/2bKm+GNfMoXCY HVPFomfUpOpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,408,1580803200"; d="scan'208";a="255113840" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2020 17:31:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0B60B881; Tue, 21 Apr 2020 03:31:37 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Cc: Andy Shevchenko , Denis Ciocca Subject: [PATCH v1 16/16] iio: st_sensors: Use get_unaligned_be24() and sign_extend32() Date: Tue, 21 Apr 2020 03:31:35 +0300 Message-Id: <20200421003135.23060-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> References: <20200421003135.23060-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use these functions instead of open-coding them. Cc: Denis Ciocca Signed-off-by: Andy Shevchenko --- drivers/iio/common/st_sensors/st_sensors_core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 0e35ff06f9af..bfc39ef64718 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -20,11 +20,6 @@ #include "st_sensors_core.h" -static inline u32 st_sensors_get_unaligned_le24(const u8 *p) -{ - return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8; -} - int st_sensors_write_data_with_mask(struct iio_dev *indio_dev, u8 reg_addr, u8 mask, u8 data) { @@ -545,7 +540,7 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev, else if (byte_for_channel == 2) *data = (s16)get_unaligned_le16(outdata); else if (byte_for_channel == 3) - *data = (s32)st_sensors_get_unaligned_le24(outdata); + *data = (s32)sign_extend32(get_unaligned_le24(outdata), 23); st_sensors_free_memory: kfree(outdata);