From patchwork Wed Dec 12 00:54:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Fertic X-Patchwork-Id: 10725411 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 7F62F112E for ; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F52329FF0 for ; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 634972A17B; Wed, 12 Dec 2018 00:56:54 +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 0C8F429FF0 for ; Wed, 12 Dec 2018 00:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726282AbeLLA4r (ORCPT ); Tue, 11 Dec 2018 19:56:47 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:39742 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbeLLAzs (ORCPT ); Tue, 11 Dec 2018 19:55:48 -0500 Received: by mail-io1-f68.google.com with SMTP id k7so13460431iob.6; Tue, 11 Dec 2018 16:55:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c5E07akhdcWo/3PoSb43yQur9QVQnOkKDZoez6erp7I=; b=d9ypycKjkwzd6rqksdJh8AddulggNHT3Ns1qjmlEnNh8wwTtLc+J4H1BvdGsAnt5Dp 1YI0J2ebEyMRqEiMVhqp1EU+V7LhEqA3CPPILSPl4vOhr18NOMNxX8u/bzjsSEfA+OEV zThWhGujFHVV28PQNekszZW9gmhkr5mtr2exH2fFMEJEzXUI57zXQaMkx+v1R8dMFqLc nxBgEqtRMkfHOSVLL+TwXnPEgXcQLta+lEX/5zaGqRzDUG8x1lNtEV785f1TQJ3P4/+b +RnB0qgdakTrqnepEyHEnMiEUzV/N2okeeReMygGDOpqp0dNEHJTX66KqkJ/I1/hdrlo ZXQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c5E07akhdcWo/3PoSb43yQur9QVQnOkKDZoez6erp7I=; b=Yoqbx1y+wdFpz7NrxDxBQKmZVnEDcIt8LRAp+VL8rMJJcL0MayJ8e62jSXYA4GkZVn 2ZICRPaLoc5/WOQkfHgZ3g1AfBS0fuU911Pd8b4iYTmg0byd5QaID7O6psl/K50AF1iU uKnRvfHpl0EG5saN/byyup4yJpeVJAf1iknrgpBSL8a33t5Ski8jydorQRl5vzfLMOkD 2L3yCuifbFWGXQYTDYG3d9if0IgxqfeUOWJxabZ6GMywrdMaFHTeAUn7MzZ4lDdqDOrd qFNcSNXi1UV3yUtn01LimRCK7fPalWygZibQHUQjqCSZReSJzy8EAiFfxXS77yDb3VEh 3Ytw== X-Gm-Message-State: AA+aEWZGMCmAGUB6w4BZOzV+4P1GPt4ZyyNozlFiE5ea4G6xtm2Qb9eY jNGJvHM3hHCnwoIRepf2pG8= X-Google-Smtp-Source: AFSGD/W9lZHjxkQ4LfQfOa89lNKtI/Wf2Sjgfy7IBPZBbs6hTi8RZjmQkGfOLV6GttLxw7d2tZuhWg== X-Received: by 2002:a5d:9405:: with SMTP id v5mr2635510ion.250.1544576146266; Tue, 11 Dec 2018 16:55:46 -0800 (PST) Received: from r2700x.localdomain (c-75-70-96-103.hsd1.co.comcast.net. [75.70.96.103]) by smtp.gmail.com with ESMTPSA id l186sm1952445itl.22.2018.12.11.16.55.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 16:55:45 -0800 (PST) From: Jeremy Fertic To: Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Jeremy Fertic Subject: [PATCH 03/11] staging: iio: adt7316: fix dac_bits assignment Date: Tue, 11 Dec 2018 17:54:55 -0700 Message-Id: <20181212005503.28054-4-jeremyfertic@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212005503.28054-1-jeremyfertic@gmail.com> References: <20181212005503.28054-1-jeremyfertic@gmail.com> MIME-Version: 1.0 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 The only assignment to dac_bits is in adt7316_store_da_high_resolution(). This function enables or disables 10 bit dac resolution for the adt7316/7 and adt7516/7 when they're set to output voltage proportional to temperature. Remove these assignments since they're unnecessary for the dac high resolution functionality. Instead, assign a value to dac_bits in adt7316_probe() since the number of dac bits might be needed as soon as the device is registered and available to userspace. Signed-off-by: Jeremy Fertic --- drivers/staging/iio/addac/adt7316.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index e5e1f9d6357f..a9990e7f2a4d 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -651,17 +651,10 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev, u8 config3; int ret; - chip->dac_bits = 8; - - if (buf[0] == '1') { + if (buf[0] == '1') config3 = chip->config3 | ADT7316_DA_HIGH_RESOLUTION; - if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516) - chip->dac_bits = 12; - else if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517) - chip->dac_bits = 10; - } else { + else config3 = chip->config3 & (~ADT7316_DA_HIGH_RESOLUTION); - } ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG3, config3); if (ret) @@ -2123,6 +2116,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; + if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516) + chip->dac_bits = 12; + else if (chip->id == ID_ADT7317 || chip->id == ID_ADT7517) + chip->dac_bits = 10; + else + chip->dac_bits = 8; + chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", GPIOD_OUT_LOW); if (IS_ERR(chip->ldac_pin)) { ret = PTR_ERR(chip->ldac_pin);