Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp464529rdb; Thu, 18 Jan 2024 08:38:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMmGTJsm2wlGQIYyWD5WxpDKW4E2+S5RRMzvIU5PJLitjPSlKUEfcvaqKOs0FDXZK736J2 X-Received: by 2002:ac2:4243:0:b0:50e:73b7:b551 with SMTP id m3-20020ac24243000000b0050e73b7b551mr658728lfl.84.1705595886348; Thu, 18 Jan 2024 08:38:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705595886; cv=pass; d=google.com; s=arc-20160816; b=R8fB8yFgkFmKntPyMvT7YjAD5jtiK+G1apMPlQ5SxGnqjDfGMeN6E42Jcj3Iv68TIZ oWqaJ+m9+U+1Jdzdj24OmpM8T7hoat9goYeTuQhrhEst08h/2KMvq0Vxf/qx9VEcsWx8 33ypEMp2RW2hHwBtgPsAy9G04JgYcAgvsF5J40dG/JhvMTjnmWnWVL7F+/3KrUOzBThE Is8cBM4bnEr4augvo/JmxayhPK/9yuD5JZKt6wCUWOSSpqcvMYpqpHEU5W/opFUABlPL UFGGJ7wljA2/HVaM8ZDW6JGf/1KU00cRTx9Ubfowh8mO4ztxJTbOx9jUsjo9a/4LVg4F BLcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=KVFO3/auyr2zJ09RykGkElEusljuvXTip3QuV7SQMtI=; fh=Z7oyAyT7CAMDQJsgH7LqH10JpaoMIXs/I+P4/RIspJI=; b=eTe3qGqleIKgoMssQnSPgjgxCCvLgZB1zaXUqrT/5jVBfY5f3M3BF5h2BUJFdBFq7o QxygyZUfCVSyO5qoG1U9K+s4rNlwCysn1D5HcuZEyXPSCFucsBRbOlJIZq0UuLLvJtp4 1OxP8GixboYsMr/KMVE/eF/cKzVynCZxqLKSc53NgicCueirnUQxg29SS2o4zgCr1HQJ W4ITwgS3+Ovx1xa34QPhQ8S2YgvyrdHeXPu5rfE7EO8nFZHzcE7gam10llAmS+SpnqqD 72I55GI9TgZVH0DodFgYUtAmdMoCnjXRBfe5z4Bwa0xGQFFcX5MdOC2bnnG/22iCCGFW q8/w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="ej/9Pa+5"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i9-20020a05640242c900b00558a692e19asi6961423edc.105.2024.01.18.08.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 08:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="ej/9Pa+5"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C08BD1F219F4 for ; Thu, 18 Jan 2024 16:38:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26DA92C1B1; Thu, 18 Jan 2024 16:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ej/9Pa+5" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B947E25770; Thu, 18 Jan 2024 16:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705595866; cv=none; b=Z51lSxNLtyQCfKkggQAdhXSAk0OQHDGcolEB0mAzvGp7SJmaxFxLySCFFh3piL5q+oeF0fenKNX+gBsWbKLbPIRO8SzGRWnexXyx7z9h3T7NuBodn7m6j67bxecZf/ZWVDJgCeQQt34rBXZQD1TlcFMLuaeHzQ3XrV2i2tt2j6Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705595866; c=relaxed/simple; bh=CqRZXXHBP5AumSjroWZ4SDntcmMBc1STE9z4wE3SeYg=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:Content-Language: To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=qk2dzEWg0c/8q8fVTmZW1MA7xld5RA19fVRM2Bh3bmFVNIHM/527sMxNGAVOOq6JXL7x+3K3z+/guEfPtxEQ7VjS6uFKoZ7UvkCbdw4ar/Ffe9Ax9yAdpDhD2Xh2lqDC/25icQuJoWVaUM8EbyeJx4/NLtnNB756kaXB0Vzb7gI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ej/9Pa+5; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-55a45a453eeso415643a12.0; Thu, 18 Jan 2024 08:37:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705595863; x=1706200663; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KVFO3/auyr2zJ09RykGkElEusljuvXTip3QuV7SQMtI=; b=ej/9Pa+55AwBGTrla1o342fmjOBrAsqQMzdfhqHB1Q1J7NYhInVqBt0k6p3vxszsLt Nan+5sYfzxphHCAiey407PAKfuZTD6h62Bk/J3ntHi2+bWjAUQBaq6ujrh0zgoYqTKlV bgaYSqo6cPoWShNrxhKn1XxpuzAnjEA2mqotnolLFckvzr+ux+tMWFk8k8hsN3wiAoam hCXJHo9MgP9rJpksJBDizeqmkQTw3zxoanUHkTTxFXI74kmFvIsEwRJOyafkrpiRWi74 ilWqR61qDUO8Kwjp+ovfcbJ26jsqM5u1wQ9wVqwPzZzXN3Kwrl9mJFOh1vS84hV9z4yg 0H5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705595863; x=1706200663; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KVFO3/auyr2zJ09RykGkElEusljuvXTip3QuV7SQMtI=; b=hnFp8foAgpGDhWxDyXxb0Xjl0RqaoNtb3qls0UlmP6V3zMRT+kCTNVaZBJRkvvIF2o cx5KL09IAR0WyfT5ZoFb4lBq65VXunMa8/fXIn7Yv5BWV7CDqiLbF/4CpYbO25PN7yK5 /Aar0j0ic1WTGC9H4994S4upht6Z8Efr+FeXpAmaL+KhTYFVshmzh8a+Usr96EvkA1fj Nvd+WzTlYEMpnTmMPXUhUhSqYWM1WJ1XvUjrKzNU+yzQNoB6anaU/G+8dnZKG73mfzlg xIwyK6NGf0mUTRpqjkGa068nJWA63AEd0fRaNqZypXD0O39YQVHKGPWvpDEERpcEngNx sIOQ== X-Gm-Message-State: AOJu0YxuoKFGXsiW/t+tbV+ijeI4wFmV8mmKzniQs3xVjIZyEWfYdyPJ Cj0GW5HtUKIX7cr6RG+dthji1jU/CaSIA3zv+EOJXR8aKv+9+XiL X-Received: by 2002:aa7:cd64:0:b0:55a:380a:fbca with SMTP id ca4-20020aa7cd64000000b0055a380afbcamr464232edb.20.1705595862786; Thu, 18 Jan 2024 08:37:42 -0800 (PST) Received: from [192.168.100.74] (91-118-163-37.static.upcbusiness.at. [91.118.163.37]) by smtp.gmail.com with ESMTPSA id a14-20020a05640213ce00b00559ba291d82sm3322508edx.82.2024.01.18.08.37.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jan 2024 08:37:42 -0800 (PST) Message-ID: <6a823a1d-262a-4c59-8144-7283dcb5172b@gmail.com> Date: Thu, 18 Jan 2024 17:37:40 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/5] hwmon: Add support for Amphenol ChipCap 2 Content-Language: en-US To: Mark Brown Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jean Delvare , Guenter Roeck , Jonathan Corbet , Liam Girdwood , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org References: <20240115-topic-chipcap2-v5-0-0cc7a15aeece@gmail.com> <20240115-topic-chipcap2-v5-5-0cc7a15aeece@gmail.com> <226d3abd-e372-4c66-b2b0-cc86e6a4bb27@sirena.org.uk> <30b9ab0c-f3cb-4b5a-a726-de9f7c61769b@gmail.com> From: Javier Carrasco In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 18.01.24 17:04, Mark Brown wrote: > On Thu, Jan 18, 2024 at 04:30:37PM +0100, Javier Carrasco wrote: >> On 18.01.24 14:49, Mark Brown wrote: >>> On Mon, Jan 15, 2024 at 09:02:25PM +0100, Javier Carrasco wrote: > >>>> +static int cc2_enable(struct cc2_data *data) >>>> +{ >>>> + int ret; > >>>> + if (regulator_is_enabled(data->regulator)) >>>> + return 0; > >>> This is generally a sign that the regulator API usage is not good, the >>> driver should not rely on references to the regulator held by anything >>> else since whatever else is holding the regulator on could turn it off >>> at any time. If the driver did the enable itself then it should know >>> that it did so and not need to query. > >> The driver handles a dedicated regulator, but I wanted to account for >> the cases where the attempts to enable and disable the regulator fail >> and keep parity. If the disabling attempt fails, will the regulator not >> stay enabled? In that case, an additional call to regulator_enable would >> not be required, right? >> That is the only reason I am using regulator_is_enabled(), but maybe >> things don't work like that. > > With exclusive use you can get away with this, you should have a comment > for that case though. > I will add a comment to clarify it. >>>> + ret = regulator_enable(data->regulator); >>>> + if (ret < 0) >>>> + return ret; >>>> + >>>> + /* >>>> + * TODO: the startup-delay-us property of the regulator might be >>>> + * added to the delay (if provided). >>>> + * Currently there is no interface to read its value apart from >>>> + * a direct access to regulator->rdev->constraints->enable_time, >>>> + * which is discouraged like any direct access to the regulator_dev >>>> + * structure. This would be relevant in cases where the startup delay >>>> + * is in the range of milliseconds. >>>> + */ >>>> + usleep_range(CC2_STARTUP_TIME_US, CC2_STARTUP_TIME_US + 125); > >>> Note that the regulator startup delay is the time taken for the >>> regulator to power up so if the device needs additional delay then that >>> will always need to be in addition to whatever the regulator is doing. > >> What I mean by that is that the device cannot be ready until the >> regulator powers it up (obvious) plus the start up time of the device >> itself once it gets powered up. So if a regulator takes for example 1 ms >> to power up, the sleep function could (and should) wait for 1 ms longer. > > No, the sleep function should do nothing of the sort - if any delay is > neeeded for the regulator it will be handled as part of enabling the > regulator. This is not exposed to client drivers because it is > transparent to them. That sounds great. Then there is no need for the comment altogether and the TODO will go away. Thank you again and best regards, Javier Carrrasco