From patchwork Fri Jun 14 16:32:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10995927 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 A9F5776 for ; Fri, 14 Jun 2019 16:32:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 989EB284D4 for ; Fri, 14 Jun 2019 16:32:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C8452868C; Fri, 14 Jun 2019 16:32:32 +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 2E039284D4 for ; Fri, 14 Jun 2019 16:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726177AbfFNQcb (ORCPT ); Fri, 14 Jun 2019 12:32:31 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42689 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725859AbfFNQcb (ORCPT ); Fri, 14 Jun 2019 12:32:31 -0400 Received: by mail-wr1-f65.google.com with SMTP id x17so3170995wrl.9; Fri, 14 Jun 2019 09:32:30 -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=Bk25I9bYJ1QkQE44oNBhQvDFUFwOGY+qKAFcfRif1YY=; b=u0OqxJ8w+zUXf1Wq56t/UtX2iY9Bnt5XmPJgxTE76bhzUIwdkWTp/aq3zzK03/kx3G dBfQWt76sNup1zwZxbZF4HN6BCuOrCg5ab+ng6DvY8Ec1l+7n3mNR4nQVWp/m2Rsnquh QoODp8H8okYFK9mawBvo7m9h4/AIajPEQO766drLGTyaCWQqnVmwMuYqNiishkrjoL3S fc+ZqTQVs5pw9P/1bk0qTZnK2u3slwLYu4BZouFS/B3JZNkloh1uvgDxjOd37MGXVXQ7 XTwy8p01wNLRjcdPQiJjl//zitZjiGh3l+NUV7y3Uql76uRrJSGoaPJnyVH7Weg0pV7d M3IA== 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=Bk25I9bYJ1QkQE44oNBhQvDFUFwOGY+qKAFcfRif1YY=; b=n1mwd7eqhRlG4Z2Mtag+ELwKt1qaz1t2ekjH1xEXgbjP1fQJr2YeYgQnQWKzhZ5kNW RxH8fiRJH0cY3g4ifUnYWeYTf/JPiB9O0lqW7WZadTsN08Ue2dmQ1GyHhaCGj23Ner1f nAq33utULbOC4gWppFro2yKRCGD6C7LF2QrtaP0MeLTM6T2hniY9WF9vIGlfek0G7QNw KYBxeqIzY4vfo/pHklv9MEWaUdPEznLLqfnXNbrQPsCE/kJ+7mthLQoJw3bR3FP0JY+m VQTM3f7cy+UCWgUADHkTRr6A8Vp82yHkB/UJrSMjtszwpyql6FQCN8VsVexrv0xxBwRM 49IQ== X-Gm-Message-State: APjAAAUGydPmYHfkbDWgnHQwYLBl2908DOYx7szYAgmMUGQCBjiQ4hoE 1Et6S1IrSLlN+khSU4sUjIk= X-Google-Smtp-Source: APXvYqwCqZPFUEltPB18dZHXPPr0GSGxTfJkT0oIbrSP8s/I7DkUQUrJKgTZImT1/eaVo9AJ0TapSg== X-Received: by 2002:a5d:620f:: with SMTP id y15mr8792301wru.262.1560529949634; Fri, 14 Jun 2019 09:32:29 -0700 (PDT) Received: from smtp.gmail.com (1.77.115.89.rev.vodafone.pt. [89.115.77.1]) by smtp.gmail.com with ESMTPSA id d17sm4880775wrx.9.2019.06.14.09.32.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 09:32:28 -0700 (PDT) Date: Fri, 14 Jun 2019 13:32:21 -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 v2 1/3] staging: iio: ad7150: use FIELD_GET and GENMASK Message-ID: <4f88fd66e478289006353645d84b7af1b5aa345c.1560529045.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 --- 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 8234da4b8c65..091aa33589d7 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 @@ -45,6 +46,9 @@ #define AD7150_SN0 22 #define AD7150_ID 23 +/* AD7150 masks */ +#define AD7150_THRESHTYPE_MSK GENMASK(6, 5) + /** * struct ad7150_chip_info - instance specific chip data * @client: i2c client for this device @@ -137,7 +141,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 Jun 14 16:32:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10995939 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 3068214BB for ; Fri, 14 Jun 2019 16:33:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F60A285B5 for ; Fri, 14 Jun 2019 16:33:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 135D92868C; Fri, 14 Jun 2019 16:33: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 AB660286CF for ; Fri, 14 Jun 2019 16:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725891AbfFNQdE (ORCPT ); Fri, 14 Jun 2019 12:33:04 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33798 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725859AbfFNQdD (ORCPT ); Fri, 14 Jun 2019 12:33:03 -0400 Received: by mail-wr1-f68.google.com with SMTP id k11so3210221wrl.1; Fri, 14 Jun 2019 09:33:02 -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=G8wdXxU4tFwUoWKvXvo7dS/CRtSW8huyMcBERdfUB8k=; b=Yl+QfPgKpr+w0DEtuQQNPcyl2qeLjOBYDIKp7qPHRYTQ2Liqly1IWx6TPG9HZGj5C/ kzHtRmn3uQ8RfnpiHyhiBAvq9b+p5U01g64vn3NOHFIIWqC75V9gfDdJm+DsV7tRgM++ StaP/9lRzyvgwUGCHgDrTsvEWx1SHHg9+SD8y1LA5acWvJj+cTyGvZVtsPLw0ty78FTF /GcJGyxhLkQLXyX/53RIz61bmYj3W6MSNaihi4DbW5RAG+UFGzcPaQjBct4quzL4fzgr Qdj50s+hsQvSM9jXCyxoWxtLvyUSr6mhifh7cn9uxsJPJQ3CZ7IznZCSejysmb9FVAyS 0Gtg== 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=G8wdXxU4tFwUoWKvXvo7dS/CRtSW8huyMcBERdfUB8k=; b=GRJ/z9s6B+5amioAeXIQr/KLXiPboHLo9PdFiJnYWecdZwdnG3kIAFwEEpFKXVpmKh Vp35Z6siSPOiWGrp+aZiT5R2bBdNc+E1iz6YhKvSRkEYoDNRstrOzc7i7XmJJZfRWVG4 BLFuBC6tzDdwxJv00pc4rRe+nJ60/N+I8cA9En70GcBIWlXPAJd7EpVdhpSZBQIhpYbP T228AgXfCWwJwwOzSX6O0DKSGhpoAkgWspVhq6GYbCpT7w72yA+87blncjHbufX75/lp A3I7k3Ihcx8w0hwAfcqYf4ghwmLGA52a2hx3Y+M62AHkDsevTlsMXZMKxNwT7pxHF1sW ejDA== X-Gm-Message-State: APjAAAVhO+Hu28p6hXeOpC/tTHzMQFXc4kA+XjjQccaP/PPD+UEX33vh oak5x0rq9Rum4DWfzNxSRdY= X-Google-Smtp-Source: APXvYqwgLGKA3ee1Gvw/tmD9xSuiS937SeFYyksGqPMuYPhYWpwerSjlNLOWmZxpMK+aJLOYh/ebOQ== X-Received: by 2002:a5d:5491:: with SMTP id h17mr6626926wrv.182.1560529982167; Fri, 14 Jun 2019 09:33:02 -0700 (PDT) Received: from smtp.gmail.com (1.77.115.89.rev.vodafone.pt. [89.115.77.1]) by smtp.gmail.com with ESMTPSA id d10sm5126806wrp.74.2019.06.14.09.33.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 09:33:01 -0700 (PDT) Date: Fri, 14 Jun 2019 13:32:54 -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 v2 2/3] staging: iio: ad7150: simplify i2c SMBus return treatment Message-ID: <90e8a25eca0825878d55fe0a9e760906b4689035.1560529045.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 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 091aa33589d7..7d56f10a19ed 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -202,16 +202,11 @@ 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, + 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 Jun 14 16:33:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 10995943 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 CC2B276 for ; Fri, 14 Jun 2019 16:33:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9CE3284D4 for ; Fri, 14 Jun 2019 16:33:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD76B2868C; Fri, 14 Jun 2019 16:33:30 +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 36DF1284D4 for ; Fri, 14 Jun 2019 16:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725944AbfFNQd3 (ORCPT ); Fri, 14 Jun 2019 12:33:29 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35224 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbfFNQd3 (ORCPT ); Fri, 14 Jun 2019 12:33:29 -0400 Received: by mail-wm1-f65.google.com with SMTP id c6so2948215wml.0; Fri, 14 Jun 2019 09:33:28 -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=fFqxIRcGH8oZzLwiEq09xzWUQlnGrozgrNZLPkvhIj4=; b=YNTWic+1630gnNTb8Sch4/BCNM++THosM5ESxK7efvK/NDqX1sXG4qNMCR5f5rC1nd n8QoPEdC1SHcx6nrTfTfubnsLaC7ny7AtItLgAGfU/TO02I7g9RT1kd2I1IW+T2/mu6i MV029DbEAYFmZR8tXvdtpd0uyW4verAT15QQTJeznWlLfI5+aXkZnl2/Zv7T3kDoxtzQ 4aI/vsNRAEM7Wym4D892XSVxXOrjiQogg2yJWUMZzdcZNLK6IS+vjMioakjvaVS/RXrW /gRQCdbIWWW31q7fRau0RSX1yqM2cdgqSZmLL2Me1dtzHXB13BViKgWORjzqDoDOxP+v RuTA== 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=fFqxIRcGH8oZzLwiEq09xzWUQlnGrozgrNZLPkvhIj4=; b=lRT5+UX9r8GP9SOId7z68ykoNkgBBATBY20lgfSelipQJBtv/Fkj5Cc1F4OoMd+Yeo 6hI4Og1sXiArOIGl+HCIm/BVbk3yVoKYNlvrWxdMhbWuXePUBxPNDycv4oVR8QLX+T/X 7h16SWQzJ6n8Q1OgsNXvXVXhzkYZZZrcOeP9nVHq46Cc41iCYiz3mNpgOH3L4oXQaLB1 IlqSLnaNmeCZ/EBcDEGHSJQFZKdMx6Wo6KP1ZoHzAbh5fh/85yPdZCB03N/1ia0uzJO1 NIUIJlX1Hccfvc0jbW8uL7yBp29FIJNSmKMvgSYDY3iju27j6ZE7J+1t9r3BVfcwCUMj wnkA== X-Gm-Message-State: APjAAAVeKV8o/UAnCslFq1GErASCLadhPceXg2PaUIPnpplXNEhrC/dX VUTiQYNchPUHzYVEZEcPI4A= X-Google-Smtp-Source: APXvYqz0OZbvPa2/1qYozLjynroXmsbH+4PiBzYOo8j3wFczAh/yCK9MUv672sSvaRrw7qPIY0NPgg== X-Received: by 2002:a1c:452:: with SMTP id 79mr8895726wme.149.1560530007368; Fri, 14 Jun 2019 09:33:27 -0700 (PDT) Received: from smtp.gmail.com (1.77.115.89.rev.vodafone.pt. [89.115.77.1]) by smtp.gmail.com with ESMTPSA id y6sm2864580wrp.12.2019.06.14.09.33.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 09:33:26 -0700 (PDT) Date: Fri, 14 Jun 2019 13:33:19 -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 v2 3/3] staging: iio: ad7150: clean up of comments Message-ID: 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 7d56f10a19ed..51d6b52bce8b 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -163,7 +163,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, @@ -479,10 +480,6 @@ static const struct iio_chan_spec ad7150_channels[] = { AD7150_CAPACITANCE_CHAN(1) }; -/* - * threshold events - */ - static irqreturn_t ad7150_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; @@ -571,10 +568,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) {