Received: by 10.223.176.5 with SMTP id f5csp869692wra; Fri, 2 Feb 2018 07:25:47 -0800 (PST) X-Google-Smtp-Source: AH8x227wTQyx+6693Lq3tR8G/NCEgAzESMulA+F2mS9OcgDRMVCKyFEYPKKTyoTCaNk4TWI+oadR X-Received: by 10.98.163.79 with SMTP id s76mr40973645pfe.67.1517585146983; Fri, 02 Feb 2018 07:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517585146; cv=none; d=google.com; s=arc-20160816; b=weUItP8P4Q/nF9Iz3PgfHRPDRccBsU+WY2ckyOME4BynBNauzX1E2/MqAFXZOAPXLx 6pghZZ3xxFG/uX78fmw1IPMZ3eE7+9kz+hHePkE92pC23Nn8yoqgTi4azJTkZaMzfJS0 vWPScY2m7O/tEnIdHGOqQR/hqjmRkorlUPZxRjU9Rmn0fXNvaRi6U8dhvjvvEPi9NjHt Z5/CfuhxStegOK3mIyi8DP9GcDkoZB7gE0YF3fBgNUnlWCnX+KTWd0DdFAHYT7kATHlJ HinFYZKMbYEBuA/DscwMcR9JWcN77zwB7w8U7zTd+A6oYUaxRIEarasWytshOMj4M6Hq hS1A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Ytvnz4esOj7VYrjd6SlHYdIW/dIhgkvawv+5rzBmr1k=; b=mzwcDv9X8kAsYbMuBp5Zs//VWsv4xbm6BlbN4RAVACO/HBXs+GqeTOyXhVtW88CSwY FIwwwj6TdcKi42KkU+rAahEjU8cEHbUQInK9iLclID6V/kY+Blw/F2WZYK++dsREMTEn h4jbZumlkxvJqGxp2yAKLUzI/P6+7nIphU8xlChXhm6ktiVrnu61Pwhkg1PMaTvrLG8u d4MUoxbcFMZQNEBnWfo/74I3tOQnqH/bx4iiGQ50UeCcsBsSVU+r3UjTiFwHjAJyrWhQ T6wJf0y+219yDmhQDr6MlYMmskMYznrRlgg3XF0Rm5cBmmNoh3yVVWvoA6Vdlx9xz2Tx cBZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tDrEt/6x; 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=NONE 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 a81si1444389pfc.258.2018.02.02.07.25.31; Fri, 02 Feb 2018 07:25:46 -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=tDrEt/6x; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751774AbeBBPY7 (ORCPT + 99 others); Fri, 2 Feb 2018 10:24:59 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38957 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751611AbeBBPYx (ORCPT ); Fri, 2 Feb 2018 10:24:53 -0500 Received: by mail-wm0-f66.google.com with SMTP id b21so13135611wme.4; Fri, 02 Feb 2018 07:24:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Ytvnz4esOj7VYrjd6SlHYdIW/dIhgkvawv+5rzBmr1k=; b=tDrEt/6x3stNcmkd2f9VpJhNGmo38/XXwBIYNHLgMFTiRnkqPOR6rki7xZyqZ10xpB 2+EAHH5mvBvou+xvDMDaUM55VR57DbRXmnQ1VBnsWrAUjr9KuGxRSmqOdifRy8goutwK OOEgxIxuUg0JNhj9/KUaoP3msNfkqgEF3PfsQFGnIp7iCZ6RXvtn5GLKuIRmugErdatt fRFhseI4nmCNghCIPxeh3EBt4EPMbulchbNPE5WYscUHnsupYHvjlZeK5M/tU4ZobQQq O1pjtfgJA3qBt38L/p1KkH2sPOK318OhoVlo711/nx93GLTaiEJYwPpyrlp1dtJXu1OD 2Ilw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Ytvnz4esOj7VYrjd6SlHYdIW/dIhgkvawv+5rzBmr1k=; b=Dy1ltQMzOqVHNFHrsqB0N6Ie9wclZ6cqOBd8ZZ9HypkCd34Lq6z28B8AXN/9+IdFT4 UyUhuPtli3v9AwFO5eEfvpBfAgTJf8pSjqR2m/AujtXlWZqz/WJK0h4Tf2afGHgGnLDk 6KzsVg9IMY5cUSrzPVVwoB4Fj7ExGfZRrJJsIXhymc7qT31tnYPVmrnfFXL0rx1ZSjZs w5LrPea+bsLHuNSjYP/9ePbcc+mJW3RvI/FMJJMnVvI2ftGZNSZS72DzfUVsFRk1jLkB RMVNzf3mdunJVO3vQ6EiPoE84blXLSH74zb+F+BuC48cRRw+E6H6bdzRlqmtat6oaQHi 3GrA== X-Gm-Message-State: AKwxyteNh+041KRpYVsDEznSwk/u+c6LOfVHjdT4wKx97uWCwkAlABZS OMZzd5zJ+v74g8EAsrwJkB8= X-Received: by 10.80.205.17 with SMTP id z17mr53008751edi.83.1517585091498; Fri, 02 Feb 2018 07:24:51 -0800 (PST) Received: from [134.60.183.180] (eduroam183-180.wlan.uni-ulm.de. [134.60.183.180]) by smtp.gmail.com with ESMTPSA id t19sm2163682edh.66.2018.02.02.07.24.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 07:24:50 -0800 (PST) Subject: Re: [PATCH v2 07/16] iio: adc: sun4i-gpadc-iio: rework: support nvmem calibration data To: Maxime Ripard Cc: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, linux@armlinux.org.uk, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, davem@davemloft.net, hans.verkuil@cisco.com, mchehab@kernel.org, rask@formelder.dk, clabbe.montjoie@gmail.com, sean@mess.org, krzk@kernel.org, quentin.schulz@free-electrons.com, icenowy@aosc.io, edu.molinas@gmail.com, singhalsimran0@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com References: <20180128232919.12639-1-embed3d@gmail.com> <20180128232919.12639-8-embed3d@gmail.com> <20180129094045.sagz2dnzvdadd4yx@flea.lan> <20180130083642.cdpd7jnthkdrrk5r@flea.lan> From: Philipp Rossak Message-ID: Date: Fri, 2 Feb 2018 16:24:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180130083642.cdpd7jnthkdrrk5r@flea.lan> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> >>>> /* prevents concurrent reads of temperature and ADC */ >>>> struct mutex mutex; >>>> struct thermal_zone_device *tzd; >>>> @@ -561,6 +569,9 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, >>>> struct resource *mem; >>>> void __iomem *base; >>>> int ret; >>>> + struct nvmem_cell *cell; >>>> + ssize_t cell_size; >>>> + u64 *cell_data; >>>> info->data = of_device_get_match_data(&pdev->dev); >>>> if (!info->data) >>>> @@ -575,6 +586,39 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, >>>> if (IS_ERR(base)) >>>> return PTR_ERR(base); >>>> + info->has_calibration_data[0] = false; >>>> + info->has_calibration_data[1] = false; >>>> + >>>> + if (!info->data->supports_nvmem) >>>> + goto no_nvmem; >>>> + >>>> + cell = nvmem_cell_get(&pdev->dev, "calibration"); >>>> + if (IS_ERR(cell)) { >>>> + if (PTR_ERR(cell) == -EPROBE_DEFER) >>>> + return PTR_ERR(cell); >>>> + goto no_nvmem; >>> >>> goto considered evil ? :) >> >> this was a suggestion from Jonatan in version one, to make the code better >> readable. > > Isn't > > if (info->data->supports_nvmem && IS_ERR(cell = nvmem_cell_get())) > > pretty much the same thing? > > Maxime > I would say : if (info->data->supports_nvmem && !IS_ERR(cell = nvmem_cell_get())) is the same. This would require an else if statement like this: else if (info->data->supports_nvmem && PTR_ERR(cell) == -EPROBE_DEFER) return PTR_ERR(cell); to avoid errors if the thermal sensor is probed before the sid driver. Philipp