From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 442D5C38A2B for ; Fri, 17 Apr 2020 14:23:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2806221924 for ; Fri, 17 Apr 2020 14:23:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgDQOXs (ORCPT ); Fri, 17 Apr 2020 10:23:48 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:58315 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725272AbgDQOXr (ORCPT ); Fri, 17 Apr 2020 10:23:47 -0400 X-Originating-IP: 86.202.105.35 Received: from localhost (lfbn-lyo-1-9-35.w86-202.abo.wanadoo.fr [86.202.105.35]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 83311C001E; Fri, 17 Apr 2020 14:23:45 +0000 (UTC) Date: Fri, 17 Apr 2020 16:23:45 +0200 From: Alexandre Belloni To: Andy Shevchenko Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Gregory CLEMENT , linux-iio , Linux Kernel Mailing List Subject: Re: [PATCH v2 1/2] iio: adc: ti-ads8344: properly byte swap value Message-ID: <20200417142345.GA34509@piout.net> References: <20200416205428.437503-1-alexandre.belloni@bootlin.com> <20200416205428.437503-2-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/04/2020 16:45:05+0300, Andy Shevchenko wrote: > On Thu, Apr 16, 2020 at 11:55 PM Alexandre Belloni > wrote: > > > > The first received byte is the MSB, followed by the LSB so the value needs > > to be byte swapped. > > > > Also, the ADC actually has a delay of one clock on the SPI bus. Read three > > bytes to get the last bit. > > > + return adc->rx_buf[0] << 9 | adc->rx_buf[1] << 1 | adc->rx_buf[2] >> 7; > > I just realize, isn't it an open coded variant of ror() / rol()? > No, this byteswaps and rotates. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com