From patchwork Tue May 11 20:54:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12252037 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 5554AC433B4 for ; Tue, 11 May 2021 20:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12AD461879 for ; Tue, 11 May 2021 20:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhEKUzN (ORCPT ); Tue, 11 May 2021 16:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEKUzM (ORCPT ); Tue, 11 May 2021 16:55:12 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D47BAC061574; Tue, 11 May 2021 13:54:05 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id y12so15693302qtx.11; Tue, 11 May 2021 13:54:05 -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; bh=ZxFj0ccRxKQQbjYoJjS1IKzFQXvXDhwcAqvWSKfVmnU=; b=sQ4VMQmbrMV7yPR1Qc3XFEWSWnjSee4xuYcU7j9ovloYCbJeq37CV7LPsY3UF16ULV 1N6YwbKLLh2hS/JItDH0Zi2oyACuoxQz4nAcPwSj3tDIg2PGxYsOooPOHCTYm7xHZaLp ceBjPymEqBa37C+sTlmFJ2fYHuJ1XJ/RdrniefWfKobMOCgKVEcRAlzUNvB+sZmjI859 fqPDllnbUX15XH4924WsAbGuXG0aDnVYOfLMPTY9A/W2Ihjf1F6iFWIY4ADMTRt4gdbt bywkTkv8ivMK2/H+th1OjCeqr9QcW5y7YclycAcccxttnzvg2gPdGY/oqN9uazaDXjVL wTCQ== 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; bh=ZxFj0ccRxKQQbjYoJjS1IKzFQXvXDhwcAqvWSKfVmnU=; b=ShSOhH9jPTFDQE+2XacALOvrJNO7H0qj1D+s1anLE8qBrxaX8sE5c6aGkXosTTeeQD p/1KKtxZMy7CH9TVkLOXdZjnNRHjVAtYI+yCHlEmBgHqQ+uldzujJ/yhBYFSKqeDOfYt EZJKbItKeYm9Y0n9qrmQp5yeqB8zPmpJdbT6fnyNfiRhVv2g6ifkHsDcJb5oKsJXuCEU Vzxr2r7kBKT8zdwrwxtBqfH3lFNIRrkTg2ojU81B07shictuWJwzUYp8e2VD1xhQypxB GE1B1OtHQy0/40lsBRnHbQx+jyVEPuY+F4NaDhlcAABGX2km1SZ7p9f+HMUwG9qR7+xw smRw== X-Gm-Message-State: AOAM530qn+hbUT04eoenyjLCXfaaB5EZMDaVaroZP6WOr+w3rEE8DCwo M8oR61MwgoPHslWCx7DQfyOVT5WGDxSUbPkW X-Google-Smtp-Source: ABdhPJxaziLBqRYjQK3sY8CA90daeQi0PBrtno/UAMRXnQHPfPnSmDnNmszGkrgMNugb0iATYZq/kw== X-Received: by 2002:a05:622a:208:: with SMTP id b8mr28982925qtx.28.1620766445185; Tue, 11 May 2021 13:54:05 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9a01::1002]) by smtp.gmail.com with ESMTPSA id y12sm13268960qkf.5.2021.05.11.13.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 13:54:04 -0700 (PDT) Date: Tue, 11 May 2021 17:54:01 -0300 From: Lucas Stankus To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, gregkh@linuxfoundation.org Cc: linux-iio@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] staging: iio: cdc: ad7746: clean up driver comments and probe return Message-ID: <687a1923add71303da13e3a838e97a6ffc7dcda7.1620766020.git.lucas.p.stankus@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Remove vague comments, align temperature comment with indent block and simplify probe return on device register. Also fix the following checkpatch warning: CHECK: Alignment should match open parenthesis Signed-off-by: Lucas Stankus --- drivers/staging/iio/cdc/ad7746.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index dfd71e99e872..e03d010b2f4c 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -84,10 +84,6 @@ #define AD7746_CAPDAC_DACEN BIT(7) #define AD7746_CAPDAC_DACP(x) ((x) & 0x7F) -/* - * struct ad7746_chip_info - chip specific information - */ - struct ad7746_chip_info { struct i2c_client *client; struct mutex lock; /* protect sensor state */ @@ -232,13 +228,14 @@ static int ad7746_select_channel(struct iio_dev *indio_dev, if (chip->capdac_set != chan->channel) { ret = i2c_smbus_write_byte_data(chip->client, - AD7746_REG_CAPDACA, - chip->capdac[chan->channel][0]); + AD7746_REG_CAPDACA, + chip->capdac[chan->channel][0]); if (ret < 0) return ret; + ret = i2c_smbus_write_byte_data(chip->client, - AD7746_REG_CAPDACB, - chip->capdac[chan->channel][1]); + AD7746_REG_CAPDACB, + chip->capdac[chan->channel][1]); if (ret < 0) return ret; @@ -564,10 +561,10 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_TEMP: - /* - * temperature in milli degrees Celsius - * T = ((*val / 2048) - 4096) * 1000 - */ + /* + * temperature in milli degrees Celsius + * T = ((*val / 2048) - 4096) * 1000 + */ *val = (*val * 125) / 256; break; case IIO_VOLTAGE: @@ -669,10 +666,6 @@ static const struct iio_info ad7746_info = { .write_raw = ad7746_write_raw, }; -/* - * device probe and remove - */ - static int ad7746_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -730,11 +723,7 @@ static int ad7746_probe(struct i2c_client *client, if (ret < 0) return ret; - ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); - if (ret) - return ret; - - return 0; + return devm_iio_device_register(indio_dev->dev.parent, indio_dev); } static const struct i2c_device_id ad7746_id[] = { From patchwork Tue May 11 20:54:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12252039 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 A5B8BC433B4 for ; Tue, 11 May 2021 20:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E7BC61879 for ; Tue, 11 May 2021 20:54:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhEKUzb (ORCPT ); Tue, 11 May 2021 16:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEKUzb (ORCPT ); Tue, 11 May 2021 16:55:31 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B5AC061574; Tue, 11 May 2021 13:54:23 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id v4so6892292qtp.1; Tue, 11 May 2021 13:54:23 -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; bh=AgQ2n9+6IeoVaWhLZCiArb6AeGJGZzOWQRj/aOD3WEo=; b=tI8lM54Ig4ZEpd1yVxTqNQjEdAZ/Ew5lU8A5S6uPMke+7+KqWhNhJ3aInBN78lfoVU rDweYDB2VrTUBJDyFrgenM+E0exe4vjN/5GahDOtsabouUTukm5LeEU+9zuUb1EJdl2Z 7/onCUq0aoe6fAYQkHXhK9AOYhqg4f5kuKCK0DBc/LSruU5a110n2MeXwyS9Dr7MXCfa XrOiV25he75aevKQGLM3f9fEd/lK1j+45MFX5MWUUmxBzLxxROidIdWaBS3iay2/XEEa dmC4qqTs5dE0ot0p+9tSUOlXx379iFinl+b/PbQAHN85qWi5A2sWb6in8g7vQGHvkl2j +Cwg== 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; bh=AgQ2n9+6IeoVaWhLZCiArb6AeGJGZzOWQRj/aOD3WEo=; b=jQ+0Ee8Es5qkJ2WqFdOPoi/vg9JH1E8I0AlPgefhDKiZvOTz8V1ikk13tkWMaehJxF +u2Ztyv9kBE9zoO/CwzRTH9H7Im/SKI5TRm9D7FPG4p2TKGYaBBOhXDdxqY5YrLJyu+V 8+nQhJLWGMj91QUflLF5Tpg9xEXRixi5nRagq7DrU52W468N4IEuBODlkJOcDRV3Eg9a lLKH35xeK/LZK5FpFTmezSBnr2PoBW6mEKerFeZE+evMN34iHXIzuQVnX4JYWPmTzXJN 99j9j+S8TiCwf2JRETX/zT3VErKVTTd1JK641HtRDMCYoUToHAx6xLFvn+a1guyn88ba siIg== X-Gm-Message-State: AOAM5332vH5nKe2XsnSpKXStZ4d2sqQowsSJNiW6NpCr30I2nmGEVVVP eR1tSeEERIA3dVZEK08SefY= X-Google-Smtp-Source: ABdhPJzrlW5lo/tug8ic0QrjBCgy0r+P3AsCn/10snv0/LkF0zKsxj0+sJb11TkUGkgiCEEiYEZO9g== X-Received: by 2002:aed:306c:: with SMTP id 99mr29292534qte.352.1620766462799; Tue, 11 May 2021 13:54:22 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9a01::1002]) by smtp.gmail.com with ESMTPSA id c20sm16824280qtg.84.2021.05.11.13.54.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 13:54:21 -0700 (PDT) Date: Tue, 11 May 2021 17:54:18 -0300 From: Lucas Stankus To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, gregkh@linuxfoundation.org Cc: linux-iio@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] staging: iio: cdc: ad7746: avoid overwrite of num_channels Message-ID: <09e65d3a235febfc4c3ee172b573ba8c9cde94b8.1620766020.git.lucas.p.stankus@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org AD7745 devices don't have the CIN2 pins and therefore can't handle related channels. Forcing the number of AD7746 channels may lead to enabling more channels than what the hardware actually supports. Avoid num_channels being overwritten after first assignment. Signed-off-by: Lucas Stankus --- drivers/staging/iio/cdc/ad7746.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index e03d010b2f4c..9e0da43b2871 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -693,7 +693,6 @@ static int ad7746_probe(struct i2c_client *client, indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); else indio_dev->num_channels = ARRAY_SIZE(ad7746_channels) - 2; - indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); indio_dev->modes = INDIO_DIRECT_MODE; if (pdata) {