From patchwork Wed Dec 14 12:02:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13073014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88346C4332F for ; Wed, 14 Dec 2022 12:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238307AbiLNMCm (ORCPT ); Wed, 14 Dec 2022 07:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238283AbiLNMCU (ORCPT ); Wed, 14 Dec 2022 07:02:20 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF6E26AA0; Wed, 14 Dec 2022 04:01:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671019307; x=1702555307; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=T2h0MiLbTfn4i9o+IaErqzz+faLKb8LWwG9yfT/PdDY=; b=iyOhikuo/y7q24VuLtnsZk7tnJ4DLkYOY+CIhZzncgCCXMBDGpG/3W3E 0RN54eQxHU/UCV5lSPfWZ3io5KtQwnFZF3rWbPxQ5W1+56oDdyBJMar0q BL7+uHn9W1BPDdatTsTudFmBgSmeXSR5wd0Pb7nk/KBAwnz7v9WaYfOl3 fAdGpfBXrE292igf1HQ3JS4mtsAFFpTxEgRyqi9wPDfoMJSfPAS3Z29fh qFa5eomOf4dBvNUvqb+K6n5c1jsoLDdvidSA35cPqT3VHwMVoiUosHwpj ZEUEPewYkS/mJvCXqAPevqEy2dZnmY4+Kpe7NH+n9C2wR6pU0QuIXyZRy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="320243476" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="320243476" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2022 04:01:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="648999292" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="648999292" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 14 Dec 2022 04:01:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2A684F7; Wed, 14 Dec 2022 14:02:03 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 1/2] iio: adc: ti-adc128s052: Use get_unaligned_beXX() Date: Wed, 14 Dec 2022 14:02:01 +0200 Message-Id: <20221214120202.4658-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This makes the driver code slightly easier to read. While at it, use GENMASK() as well. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/ti-adc128s052.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index fc09ee6bb174..7c4e8025861c 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -9,6 +9,7 @@ * https://www.ti.com/lit/ds/symlink/adc124s021.pdf */ +#include #include #include #include @@ -17,6 +18,8 @@ #include #include +#include + struct adc128_configuration { const struct iio_chan_spec *channels; u8 num_channels; @@ -33,6 +36,7 @@ struct adc128 { static int adc128_adc_conversion(struct adc128 *adc, u8 channel) { + u16 value; int ret; mutex_lock(&adc->lock); @@ -53,7 +57,8 @@ static int adc128_adc_conversion(struct adc128 *adc, u8 channel) if (ret < 0) return ret; - return ((adc->buffer[0] << 8 | adc->buffer[1]) & 0xFFF); + value = get_unaligned_be16(&adc->buffer); + return value & GENMASK(11, 0); } static int adc128_read_raw(struct iio_dev *indio_dev, From patchwork Wed Dec 14 12:02:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13073015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02ECDC4332F for ; Wed, 14 Dec 2022 12:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237595AbiLNMCw (ORCPT ); Wed, 14 Dec 2022 07:02:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237495AbiLNMCb (ORCPT ); Wed, 14 Dec 2022 07:02:31 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3061F26ABB; Wed, 14 Dec 2022 04:01:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671019310; x=1702555310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2nnC8hqhsbGCXjQ/5cko/ZVY7VIV0k35M+A/Vnl8B3w=; b=fhNyrVPbEFKrRMp2RoCJvRp3F/E8tWRkg0iZFFd0g0DkkYtJyteaDhr7 cJN4HGsG8uqaZMybH2rmV7cRCdzadSoDHknmhC+ZegB5V3cTkttlMy6IL w8ptZy2pNovCmhk5nza/B0V5Nz5Eb4c6F01NGzoNAPCEC401VXh2ZO6vy s69QoHlTUuEqOSDYfGoyLZbidTzQc1ZhJTs1QvY/efJqXQOxQlzpIICc3 PVCmcPqJV/6v/+zSF6qrnPsmgpT1Nr21YRCGXYFvK8KiXnRM0JiLR+1fV e/2Eqn6iujPPgiv3ODX6oEXhPeE8CRvZi4yAcWQ0rOqqVU3naMByJfRlU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="320243481" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="320243481" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2022 04:01:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="626708582" X-IronPort-AV: E=Sophos;i="5.96,244,1665471600"; d="scan'208";a="626708582" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 14 Dec 2022 04:01:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 35AC4F4; Wed, 14 Dec 2022 14:02:03 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 2/2] iio: adc: ti-adc128s052: Sort headers Date: Wed, 14 Dec 2022 14:02:02 +0200 Message-Id: <20221214120202.4658-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221214120202.4658-1-andriy.shevchenko@linux.intel.com> References: <20221214120202.4658-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Sort the headers in alphabetic order in order to ease the maintenance for this part. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/ti-adc128s052.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 7c4e8025861c..a003264ca835 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -11,12 +11,12 @@ #include #include -#include -#include -#include #include +#include +#include #include #include +#include #include