From patchwork Fri Jan 6 10:38:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Koch X-Patchwork-Id: 9500519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 60CF4606E0 for ; Fri, 6 Jan 2017 10:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FC552846F for ; Fri, 6 Jan 2017 10:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 549272847C; Fri, 6 Jan 2017 10:46:20 +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=-6.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 065CF2846F for ; Fri, 6 Jan 2017 10:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162847AbdAFKqP (ORCPT ); Fri, 6 Jan 2017 05:46:15 -0500 Received: from argos.tuxed.org ([176.9.87.227]:33477 "EHLO argos.tuxed.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161385AbdAFKpo (ORCPT ); Fri, 6 Jan 2017 05:45:44 -0500 Received: from thor.home.lan (unknown [IPv6:2a02:8071:3183:6700:3106:d333:69e5:69a4]) by argos.tuxed.org (Postfix) with ESMTPSA id E695F707A3; Fri, 6 Jan 2017 11:38:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alexanderkoch.net; s=default; t=1483699136; bh=HukKAHCtD/UjCXCbIuzlaIbZweEPAm9TzB4uRjbQAOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqKhnR54izd0uvR7WgqfiCrdfqaTVwOuS46ET8o3UjvWyYW8At00xY9gbVqRXFhVK lg+hZd4qRQ8tJAoapa+ox+lO6Mcl1eWKglvnOlIuZHmdEo1M7oFSSxnGuXTQ5nS4ME mkkvz+9xMOavLXeILCQTlrL6p7FkN+0/6slwlRUQ= From: Alexander Koch To: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org Cc: Rob Herring , Mark Rutland , Jean Delvare , Guenter Roeck , Michael Hornung , devicetree@vger.kernel.org, Alexander Koch Subject: [PATCH v3 4/4] hwmon: adc128d818: Preserve operation mode Date: Fri, 6 Jan 2017 11:38:17 +0100 Message-Id: <20170106103817.11588-5-mail@alexanderkoch.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170106103817.11588-1-mail@alexanderkoch.net> References: <20170106103817.11588-1-mail@alexanderkoch.net> X-Virus-Scanned: clamav-milter 0.99.2 at argos X-Virus-Status: Clean Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Preserve chip operation mode if no mode is specified via devicetree. This enables operation when chip configuration is done by BIOS/ROMMON. Signed-off-by: Alexander Koch Acked-by: Michael Hornung --- drivers/hwmon/adc128d818.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c index 0502af963f73..bbe3a5c5b3f5 100644 --- a/drivers/hwmon/adc128d818.c +++ b/drivers/hwmon/adc128d818.c @@ -491,7 +491,7 @@ static int adc128_probe(struct i2c_client *client, data->vref = 2560; /* 2.56V, in mV */ } - /* Operation mode is optional and defaults to mode 0 */ + /* Operation mode is optional. If unspecified, keep current mode */ if (of_property_read_u8(dev->of_node, "ti,mode", &data->mode) == 0) { if (data->mode > 3) { dev_err(dev, "invalid operation mode %d\n", @@ -500,7 +500,10 @@ static int adc128_probe(struct i2c_client *client, goto error; } } else { - data->mode = 0; + err = i2c_smbus_read_byte_data(client, ADC128_REG_CONFIG_ADV); + if (err < 0) + goto error; + data->mode = (err >> 1) & ADC128_REG_MASK; } data->client = client;