Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1299407imu; Tue, 11 Dec 2018 16:59:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/VQrDTNWN2GYh9touy7khSsYFurqgtkebKVRizhTCtsCvw6gos6kLbjHQqVLYO6GP9K73Jw X-Received: by 2002:a17:902:714c:: with SMTP id u12mr17797387plm.234.1544576372178; Tue, 11 Dec 2018 16:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544576372; cv=none; d=google.com; s=arc-20160816; b=ps20nUuzAWIAaWfBWCSSaOtk20s+MyOFQYvBNFoX1DmTJhBF0xJ++NwyWVcOAwdtg0 oz+AVXK+seHttRpX8hlHghRndZ8Ry6nNBf5wU/GqGQYvWceoOSK6hmF8x7ED1HNH1YnG MW018ls9zMdq5TJbQIP8Y7vSotYp9xLHqsnR90rhegsOaBsPgeKVwgnizy5YV+lvDt20 GEmHP/JphbxSHvR8BrJ3g5zAXGAP3ATVSUlWTucI/8jknWqM1rQwheZIY5f2TVdZincX PU3p6ZswednRek5xPBMzyY8ZhNDd0gkqRH5W0JhO6Sz56nDcEsPhh/g6LMw/IBZ8ltKQ bGvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c5E07akhdcWo/3PoSb43yQur9QVQnOkKDZoez6erp7I=; b=L0ueXJS+oZy0aLDlywoLo4MI5Pm4PtiZzH7au0pNFU5xM0l71VdHkuW5+3YPLvZ3Nu 8CL0dOW0L1nSSHoaQ6l3YR6l2U3P2dYseYaTal5DJM+b7B8iMnWNo9Xvbyx4JVwTAWIF jEpQzOQuNjGjnScc66vtfzsS1MwaqhVWKuOqvEkUrED7FwCl3hV6R4UTUucos4tgfGMR 5BGsXGE0GdT40mTEBq+z1rOEoVuXfFP999ucCJDW1m4GdK6yzZTWBSZfn2BsjB7xDfzH RAy9JBXp4goVIOenPahs0HqGbFWY+iHi+xV9ngXj+bxfKGzOQf8Oj2xeqzIUsIqdZYLJ f6Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d9ypycKj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si13190162pgi.181.2018.12.11.16.59.15; Tue, 11 Dec 2018 16:59:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d9ypycKj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726501AbeLLA4s (ORCPT + 99 others); Tue, 11 Dec 2018 19:56:48 -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-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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.19.1