From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796416101; b=GJ+2X1cuedn6Zo/RiVZB3+DYd8I7P9N0evdqpNpt9QATM1WzZWPuK9o0252NdY364NOu 5eg82CxLu42cAMKlEZgWFGzCWCDrYUkMym1eCxG8jb07MStghOPGfcm+Mp0CLNBQ7G5pr xc6STi8hWvAPSM7guQxh+KqHvA76/d2hYqkN5NaoKSbzWg1oHGT6HnZgkUHPsm9ViRDdL xHrEM/6EmJgrsZ2J2HFTjXckiyFdv4SoQmCVMQ9RLgR2/1b75L6Jep7+yXwBdkTQ5nwQF LaMyIiuykO8q2nFBJm4E16wPbxn/h1/Z/j36ZgfMNicWwOOCuVGQbU1bi3wBvswew9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796416101; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=FYGS4i2zjI/KCejQDXtBI/UuyjUEtxPinfJnXpKTeO8=; b=rTOnZTOoHEEoj2azN2Y1NO8JN/hPxpGVIV5K5Kb3jhricpK7ctQ8sLlI42dSsctjdQ1a uBsbDyXWFIya0b6CBbYkhj9DeL5H7Mo4XjmKfxe0kaCfhYUeeH1YRBw38RBJrbPCYOZar 5ixiPI65fChCfU+tqupbQfQ4LawIoViLlwrPl2LSwp737aLGELSkBVkPSJuDyhJwGSj0P bdhamlKqlbsp5R+SjvXmaeGWTDbTORClE/FCSejDCHC7cxu0ZOJbi62jBmuJMFFYNNwRk TWehhQlNnxrEhDnRDF5A0z6zNqUqWdXvtSKz8hir9w//epr5e/blpM7D2NsfQObGmog== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VoPEmjRe; arc=none smtp.remote-ip=74.125.82.171 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 213A7606A322 for ; Fri, 4 Dec 2026 20:28:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 213A7606A322 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VoPEmjRe Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-387486ad5abso2063959eec.0 for ; Fri, 04 Dec 2026 12:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796416100; x=1797020900; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FYGS4i2zjI/KCejQDXtBI/UuyjUEtxPinfJnXpKTeO8=; b=VoPEmjReKnvS/WhiU0CMpHQMj6Jn8bpu6li6shWe0FgtdaO9nOHpAAzx0h/8kpiAYG Ie+5hMKSqJzztHseyf2EpGqP/ssMp2T4TZGieLrXr83pqM6Ym0Sq3kY0ueyyCUJQnF3a mt7Sbu0Hgv0L1V41UWaa/jFQpxXGiZOYiRK7EBhoMkBH5CfIz8suF5A6aUYYw6eE+F3M qfvsUMp9vSgkxfsX2R+tXM7v7uU6OHSDiZw/SFXroYgpuT1KHuaBM7Tgid80FkgrhTWQ NeNGFkO5HLxR9+v2l+aKy6LcRzt55V4RrIEMXjJGc8wYnSGxBDPUYc5vEgi7F/6euFxb T/xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796416100; x=1797020900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=FYGS4i2zjI/KCejQDXtBI/UuyjUEtxPinfJnXpKTeO8=; b=PK8VSnNhiLdiLv+mtmyvesu4l2QsFipGUekFc5ZpXKO3vl4YeGbdhqNgXuqiyG5ys7 6of9oB5pkQHgCKWVhv+Bhde+3JSHxMudRFKmKiWo21qIwBjQb8qjF/pdwOIxylNeKGxE QwC62/jWS2XA2UkHTJ5xjHa00p4xuBZ/pYdKeyMfm8dhenOJ6PnhT3dE1mFER1dk6P5Q kyDjj2ZUJh7TMPNlA7QkEukAvEYu+tvOJ7alZt43NVUYLPWL4AsQi6WR1QMdQxALss3S J04qrRcYg2+ofbBSVG4Pep0UlRYOj+8wRVgA/HmqJBEu3d+2n5sFXZu46AAfh+D79GqH TX+Q== X-Forwarded-Encrypted: i=1; AL+hErEuQcEyWsoaa/z3YEDbV5kRXiuAz8xDcqSAHLNCZ0r3Bweo8mHnhZNHQ5iEmwNraKb+QJ9lq0FyZgvwLyg=@vger.kernel.org X-Gm-Message-State: AB4q+uG/xAtzB5o5A9VL43tP9gd7wKiYNgfM30Jx7Loo58Eg9L9lab22 3R5KKmbES3piOVh2MEYi02qr6Y6oGntrSqih5TbGcgMM/1UCS4/Rmv7xP58Gs154HGW1zg== X-Gm-Gg: AZFdTZfQ2K6ylHlJeuRxUfz+RZTsdh/kBz1de1OSobnrZyq9oSgTFeR49J8FejAPdwD rEnJm0fSIVNmp7WX8Oa57ZG4E37DKcdGc13KWo35bvWxmZhzCcPHPStmlHTUm2gJK5rsr1VC6S5 QXBgo0e+jBq1floBwnkIM/QHZ7ehM777Nswd/bDWhR1vMz0vKn8QjPI0+GkY2hIRHVePvVU5q8u 5eGgI6cSSTlGTuuSlUijM5xiuBx16xW/q4yFRTOYJ2N8FnPsXtkeYDt1XnOESVPY6wAPRRjvjbL YxM4b9EZOnLLEp7v7QWtGPqekmjiaO654xAckCw2C2NOu9edRZj8XMdkU5bbFYxOT+Xl2uILBSK rY+/2lW+ZP7bHSnTYLHbjmo/TCp+OE5yAYfBMqfCEB0FjEkzEbCQO+pJ2rFM5pJWc8XqIekqS9x Xv+8wXJHbs/Az1zpMGuwVcYKXCSmE2KZSJZfURpWK618AxM1Xe30ExZ4/AUwFi92Vl2P/LFoqPM cJF1pKf4qEB4FryoQ4cmMBxTSNX5qnjlcCKUKJuZnTi2MbptOfbH9iMsT8EvmbH0YqsmB/QklGQ b4tuRUQnZfbxV73mMhc6yziYUeftIYWuHYdGjmdr0cEq6aMUFHNyxV+yXWB5+FJ6lx10RY+p2hk tDh010Ztp97VE4U2oi3E/xtrhJR3+hNUPIsD971DFFot/S5HgiNqezluWJz+UjfhWc9aS2P77Xq n7waZUgXHqHUi+WVJMIWDTSG+3JZyGV/ycXqNNMRarAw== X-Received: by 2002:a05:7300:6d2c:b0:386:aff0:6109 with SMTP id 5a478bee46e88-38751fe24b0mr3927116eec.2.1796416100048; Fri, 04 Dec 2026 12:28:20 -0800 (PST) Received: from kapoor.iiserb.ac.in ([203.18.51.239]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521e5e7dsm11312791eec.19.2026.12.04.12.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:28:19 -0800 (PST) From: Arnav Kapoor To: akshatrawat095@gmail.com Cc: Arnav Kapoor , Jonathan Cameron , David Lechner , Nuno Sa , Andy Shevchenko , Heiko Stuebner , linux-iio@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure Date: Sat, 5 Dec 2026 01:58:07 +0530 Message-ID: <20261204202812.1049983-1-kapoorarnav43@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204111238.425-1-akshatrawat095@gmail.com> References: <20261204111238.425-1-akshatrawat095@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, Dec 04, 2026 at 11:12:37AM +0000, Akshat Rawat wrote: > In rockchip_saradc_resume(), info->vref is enabled before preparing and > enabling info->pclk and info->clk. If enabling either clock fails, the > error paths return without disabling info->vref, leaving its enable > count unbalanced. I'm not sure the count is unbalanced today. probe() doesn't release vref or the clocks in a remove() callback; it hands them to devm: vref to devm_add_action_or_reset(rockchip_saradc_regulator_disable) and the clocks to devm_clk_get_enabled(). So with the current code, after a failed resume: probe: vref enabled (1) suspend: vref disabled (0) resume: vref enabled (1), pclk fails, return unbind (devm): regulator_disable() -> 0, balanced With this patch the error path drops vref to 0, and the devm action then disables it a second time on unbind, which the regulator core warns about as an unbalanced disable. pclk already behaves like this since 560c6b914c6e ("iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume"), which predates the devm_clk_get_enabled() conversion. A following suspend would likewise disable all three again. So whether resume should unwind at all here seems to be a question of what state the driver assumes after a failed resume. Jonathan, do you have a preference? If unwinding is wanted, I think the commit message should say that it trades the leftover enable for a double disable at unbind (or the devm teardown would need to know resume failed).