From patchwork Sun May 23 17:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12274969 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.7 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 A2FDAC47080 for ; Sun, 23 May 2021 17:12:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80F4561104 for ; Sun, 23 May 2021 17:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231829AbhEWRNa (ORCPT ); Sun, 23 May 2021 13:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbhEWRN3 (ORCPT ); Sun, 23 May 2021 13:13:29 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A271C061574; Sun, 23 May 2021 10:12:02 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id o59so13048107qva.1; Sun, 23 May 2021 10:12: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; bh=cWkW7YZCHAm4pyy3lSS9WKOT49WrgEzTAvg74zMHMjM=; b=A9KpUksGilU2qYWa3EBXb3HoXKhU/fhbXwShcPp5/icop3aJxNj7N5xfniHJwtFKtq MNit3H/qoGVovfeNjKjeA3Vsq2cvxqWm2uJQnqJ6LZ6xJSQIAAUvlUPpVPHy2bsSYZOW PWNuCpJH2jZy/VxPnX4dPDhfv4T0HvLnSp0Q2IbEGCifd7hMbM1HTrvk2VYvXEL5k61m RVj4nfxTqqgxPgjxtCPBnucpEp1aISdtDapwQd65aUOHziroA2cO223K4Un/YDMeooZ8 FcIVmi1y3Fcq07EXxnfRJ3wXQXtj7OpzfPpvb2ZvxtZ2Xrx+ZpVKCJBm9VW2BBdWAwI+ bBuw== 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=cWkW7YZCHAm4pyy3lSS9WKOT49WrgEzTAvg74zMHMjM=; b=TUkXkW9gWSrqVzJK01oaDxq2tYB9vyhdZB+i9wH/6jEZ87tauRiuSKXbMJhTQXf+85 CFgs8IKogbosRAh0nJKx6ozH3/9x26n2mC+aICAXGX1/Ex/RV4FBhwZpZhYwJQSToVz4 UC/Yom74ua1GZ1Sh+t7i2A9W69y4VdZBl7p6G7Y5XXdWynwMefRCIJ6QxR9wCOX58ulU nG52+WWgM+cKHdyRz9//knaM50rjnURfAGTDKyWN+KHJoQx0PgUPcuGE/mUYAVBtWqMd 6EInCq+0q5tNnqCs0BbgEIJ2GMrE7q1vvYTTtRRPCTBT7WlMJfaG9whDVhIaD6qVuPBJ pwbA== X-Gm-Message-State: AOAM531PjyqUIGeb4e8MnOiADJRH0ymG/a2DyyC+5YHjJeFFnJ9NoJpC fBT+NFIH0RUThYsH2NMW+Y4= X-Google-Smtp-Source: ABdhPJz7YKGJaYTbBhzf4mC/3Aeto2nd3Qjgo1xRMFjaAp936ZLFaMNKtuX6oHANG8brCcEIHOaOGA== X-Received: by 2002:a0c:ecd1:: with SMTP id o17mr20596533qvq.4.1621789921488; Sun, 23 May 2021 10:12:01 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9a01::1003]) by smtp.gmail.com with ESMTPSA id w5sm9159633qkf.14.2021.05.23.10.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 10:12:01 -0700 (PDT) Date: Sun, 23 May 2021 14:11:57 -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 v2 1/3] staging: iio: cdc: ad7746: remove ordinary comments Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Remove ordinary comments about typical driver structure. Also align one comment with wrong indentation. Signed-off-by: Lucas Stankus --- drivers/staging/iio/cdc/ad7746.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index c42fffa8b60e..12b2554a85b5 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -82,10 +82,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 */ @@ -562,10 +558,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: @@ -667,10 +663,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) { From patchwork Sun May 23 17:12:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12274971 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.7 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 4889AC4707A for ; Sun, 23 May 2021 17:12:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27DBD61004 for ; Sun, 23 May 2021 17:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231929AbhEWRNs (ORCPT ); Sun, 23 May 2021 13:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231907AbhEWRNs (ORCPT ); Sun, 23 May 2021 13:13:48 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79C5FC061574; Sun, 23 May 2021 10:12:21 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id k4so13780391qkd.0; Sun, 23 May 2021 10:12:21 -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=FVFwbzaqJkFQbw95QSxdKG72x5yeV8JgPBrXOT1pa2U=; b=TTZ3Z7RPhSXtLexI1i9Ez3Q6mw2GSrOOorQZ9Aq+R0u0SbXRK3OPck/1ARwAbenxwO CfCmANaKELZ0iT57dXSx0H9F96pl/Jk9BVcVigW+diVTTAIk8Ee/NDy1G3ouOT1Abfjv bIV/Ki6yTAjAXKMgHjIV6xp7al8d6RJndCL+2opSChmS8OFL4BIm068GL7mmQIBsLTr7 HTBogbSyzqneISWdAQWmZxDaljut1bTYxa3OwBxX1cfXEp/6fiT+0QsLxrI29aCYqRKc kVZAQN0HmzjPYE7UH+2qlYqBjF2vhdTKUYmpFU3qxUdfjTOjrz5u/wCq1Kqwy1vKsuYH l/RA== 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=FVFwbzaqJkFQbw95QSxdKG72x5yeV8JgPBrXOT1pa2U=; b=P7NxFsCSOVkLLb5f0piD5UBKbaSWEHMsnHwm11mPFPJI5LaaXkBrjIZIIEk1+WLHpl sj+IrD4ayVPnp8CkVkz3zunJypcMG0qSGqcziKRohrm9l0bv02ITrsMALrv37YO0iOex CC4JBr4nCn7LBQ8Hb4QsslFCSv++hRvfo1wE8JHTLhYExyLcbt4CxSKqFZOmj63UaqaW M+eOz2+pAtpP3tfJOskDc3uSLO7LStEb+ZwgtGiMu9zSi1xRWr2U6nYR7QsszUNSZKWe RTgfKZueEzjXF0oaxjnrGXEHkqizLpuIpub1/VKAhMN1L1VNlTBrAmM9X19fJ1L1T0sG X0Vg== X-Gm-Message-State: AOAM531ivVu3EMGtDW2JIEOt0GpjL6nYhUVKtLfU9yn2xmvlkfurlKTe 5u5wvtt+eflf3ZNNbw/IigfmSIpbO0GLRGFy X-Google-Smtp-Source: ABdhPJxegZy9XqDTwQ82b4AgKjzCAY2P7VQFa9Wik5QZofZ583lov1CO3I1oQIEp0eivCXwoMMDRFw== X-Received: by 2002:a37:b947:: with SMTP id j68mr23579888qkf.108.1621789940745; Sun, 23 May 2021 10:12:20 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9a01::1003]) by smtp.gmail.com with ESMTPSA id x28sm8975699qtm.71.2021.05.23.10.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 10:12:20 -0700 (PDT) Date: Sun, 23 May 2021 14:12:16 -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 v2 2/3] staging: iio: cdc: ad7746: clean up probe return Message-ID: <45443b8306893576824effaff57d40231de8e813.1621786036.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 Slight simplication of the probe return on device register. Signed-off-by: Lucas Stankus Reviewed-by: Alexandru Ardelean --- drivers/staging/iio/cdc/ad7746.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index 12b2554a85b5..367a5990ae35 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -734,11 +734,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 Sun May 23 17:12:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12274973 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.7 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 1DEFFC47080 for ; Sun, 23 May 2021 17:12:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3B2A61004 for ; Sun, 23 May 2021 17:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231907AbhEWROK (ORCPT ); Sun, 23 May 2021 13:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbhEWROJ (ORCPT ); Sun, 23 May 2021 13:14:09 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10568C061574; Sun, 23 May 2021 10:12:42 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id v8so24935334qkv.1; Sun, 23 May 2021 10:12:42 -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=NI6VGTgdO7QUPT8Xbl98mX1OA2u/yEB+lofSkIV6DFs=; b=Cv08fynHoQ3MdJJet/pK3X9cTxSniHt3KnvtbV43MHXpC8EgI7CB3ZmkQvDpeU+ldV AXOpIRVo9PUUPrhvkMkeyxlsh5BOWuSlIqbDhXA2XDHSkRn1UZLjpZWNow/c0qPzbeYu y5+5rLV9wslYZjJqRw87WlIG5v3AIYUXZuJbtgzmRUaw4rN3t6l44+o1eEVrhtCIS53w KxLyliwMZP1fltrBWLtvagEwSpnEx0Qa+uuBw9AG8VvSlskxvRLE2ZKrwYhuicVDloOU C/GFSfMFEfp/iNrpP5r7d29LimWwzj5Lp9aITO7UNutfDtwHS4attXoTHhcmMnM/BWVX i7jw== 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=NI6VGTgdO7QUPT8Xbl98mX1OA2u/yEB+lofSkIV6DFs=; b=CeoWQY2o4gFF80XDqdSMlIl7KHILG9ipISdGD2WozsnvvJkAEm3pdmNZepYwzsMEdM JezrzlLw6yDkHeJcLb1JMBnZVB2mhHgJZ+Bngq01uUG926QXmhxxCCvCYC/yHfLjd970 hAXFlItGDwNtSzqE1dvL0xE6/gJaRvvpIBdR/6lmhNL+JIKu3Z2+4bWZR55jBxQ5Ihp0 sloRKHlHEi4o+FVNN1KUB/o+MZJ25Uniejrv5ue5ffK8zVyvwazFmygd1IIDxsyA3Vjt lawtAe4/sYvBJGf4q/ID39co1tdN/EZNCKuEDpFYGrcZsgE7dYKi1FyUI5sbfD2e5pav 2vvQ== X-Gm-Message-State: AOAM531EoPNcPZ6luUOgncRlWdORmEzUdyr1kYAITLyeVYGJn43UAw0j Z8R4LDomyKuHvyjPKEWjFxI= X-Google-Smtp-Source: ABdhPJzMy+yWRIRNkHTk1RCYZRyY0+b9LlR7tq95R7QTH1YZgdH9euujbyRqArU714Yh2EL+jvrcKg== X-Received: by 2002:a37:aa4c:: with SMTP id t73mr26395487qke.79.1621789961284; Sun, 23 May 2021 10:12:41 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9a01::1003]) by smtp.gmail.com with ESMTPSA id n18sm9115529qkh.13.2021.05.23.10.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 10:12:40 -0700 (PDT) Date: Sun, 23 May 2021 14:12:37 -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 v2 3/3] staging: iio: cdc: ad7746: extract capac setup to own function Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Refactor the capac register write logic to own function. Also fixes the following checkpatch warning: CHECK: Alignment should match open parenthesis Signed-off-by: Lucas Stankus Reviewed-by: Alexandru Ardelean --- drivers/staging/iio/cdc/ad7746.c | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index 367a5990ae35..4221312f0a32 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -209,6 +209,19 @@ static const unsigned char ad7746_cap_filter_rate_table[][2] = { {16, 62 + 1}, {13, 77 + 1}, {11, 92 + 1}, {9, 110 + 1}, }; +static int ad7746_set_capdac(struct ad7746_chip_info *chip, int channel) +{ + int ret = i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAPDACA, + chip->capdac[channel][0]); + if (ret < 0) + return ret; + + return i2c_smbus_write_byte_data(chip->client, + AD7746_REG_CAPDACB, + chip->capdac[channel][1]); +} + static int ad7746_select_channel(struct iio_dev *indio_dev, struct iio_chan_spec const *chan) { @@ -224,17 +237,11 @@ static int ad7746_select_channel(struct iio_dev *indio_dev, AD7746_CONF_CAPFS_SHIFT; delay = ad7746_cap_filter_rate_table[idx][1]; + ret = ad7746_set_capdac(chip, chan->channel); + if (ret < 0) + return ret; + if (chip->capdac_set != chan->channel) { - ret = i2c_smbus_write_byte_data(chip->client, - 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]); - if (ret < 0) - return ret; chip->capdac_set = chan->channel; } @@ -478,14 +485,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, chip->capdac[chan->channel][chan->differential] = val > 0 ? AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0; - ret = i2c_smbus_write_byte_data(chip->client, - AD7746_REG_CAPDACA, - chip->capdac[chan->channel][0]); - if (ret < 0) - goto out; - ret = i2c_smbus_write_byte_data(chip->client, - AD7746_REG_CAPDACB, - chip->capdac[chan->channel][1]); + ret = ad7746_set_capdac(chip, chan->channel); if (ret < 0) goto out;