From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 A73512877CB for ; Fri, 6 Feb 2026 15:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770391929; cv=none; b=TPx7TLs8QGs131CbgscdAJEnKLX0sKEr9I2wZ4URYjD33yZZVsQnDw0Xp8lsE5ee1O1rSGL4B86ZVjxkynoP3j8k4FopgsssUQzPX4DCR7sHXxXtYVwYNwhFtcijOUZcL3rpaNRWvHAOy9zZUQV5V3DO2ke/xnIQZ+eEZnMYuyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770391929; c=relaxed/simple; bh=GJUsbEyjYgYAMBqZiUQC4tN0BJBESTzqUrOQsHwFNsE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CxnQaCpH+qdqa9XBkK753jnr4scJX1O9smbRH+ldl1QkPAjCpzOFsy5AR5ClDcStXb6giFB25mE+WUDbSHOS9qAeDQQQTHG0iy23uOyl2eQQSizsYfVXGCxfmVV/0PMkbQZJuyquuMEYUztV8kyUtKCHcT36G2+mVZYV6qLHou8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jpdgj8Ps; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jpdgj8Ps" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-47ee76e8656so34291945e9.0 for ; Fri, 06 Feb 2026 07:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1770391927; x=1770996727; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=i6Iwe5lFaK8wO5ecGyqSF9mV2cSHfdgCj+i6cKd1quw=; b=jpdgj8PsJA9/ng3y/rBQxe1a7F8VW1rfDZdf5Zab3qKRsJ2Jf5EScoL9jRcqKNhDfl yGv7jPK/bQYg5X7+03ywMLr7Dd2DvK+AIaXvFKSrMUSz0Bp7qTZPfgafIudP+i7XlRSN uas3wI05nni6K7T4tilqL0CXhMVGcBfsjbepi6mb0qgWqmIJVL76Fov0olg5YTMnriJE OFJaCT151sa8wX6wzDtVMALPTFVqNr0lW/RqHstWgO2vVFbzl5dXa+Qfyj6GiojWTFKh w2K5EXoiexCREj3Pu6m/loID0WwIpCAcURUD60Txu5fwUxGerUj0POX292ic17TAbVkQ 6xHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770391927; x=1770996727; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i6Iwe5lFaK8wO5ecGyqSF9mV2cSHfdgCj+i6cKd1quw=; b=EYSsljQUCLL1Jg1MDY0kpaT1WBNRMhsnvUPaQyXOjFKtV8LbAXDGwabpSntY9gReIt nlJaYaJjQ9Ghm6m/IDFNPnCYW74qtM5CbrTYpu9VmynuYAVQre9MyZ83GNE7PBsMHjfv XCcFGB9XIMN0MhKdShvR1RVx4HVm/MqOzZcrxC49VDvwqBCnyljXBabknWOclee1izHX FaNhMDeZUGE9DfCG5SeWkdJmVb3jIk2YwPSF9UYLNu7Fb2k5i60XAHrTUqC6afDxAmEl 0+IvJdbY7P3DGlNgHcfmCkRpENv4uCgCzS3XQSOoOJjaRA0RE9G3+C6fsrBhqJkAYOu4 5V5g== X-Forwarded-Encrypted: i=1; AJvYcCUffdA5hg2srj+d+VgQCX5SXP/wgPWfUUSffMuBKB5AJV5B3j24Xb26MERqvgGMCqURMaWotWpYVgYR2qQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxLjRyZaeMfAHiepd7deNoBeZi67nCC/yztUXve84Cs8cxyWvbK G0tkWJxLPr+u4EbRTr6HO5fYOzwMTCkEUN9bJjO3PD0RZYxzr+9Ba0Fxk+2hxbu9SH0= X-Gm-Gg: AZuq6aJMjHP7cd/GLRdrSh1QElfGzb6jmeKTsE9/k2OUxnG2ucEvPjf8acHb01CSEyi ELzuL/ZdA159Ym3eqdLHstC1s9O8KLT4HPuT0rNypCKYU55EGt2xCNLpmluBeAYZ1/XzJ3TI98h STkiSZd4HOmukyF/zs++lBM8vkqVbZtx/VhgjfatS7RXWgmcMDrVCVmqoLuGyMopE29TwaRaL6R ZXXAx8WMfn0u3q14Zrw+94ykQk2SKz7cc3MHTw/4BbnTPQC+/PTsZ06hjD2e1/N8Ple8elgfjCl qb7XfUlKDPxdkLDo7sESvINAH7KN3SGZA69/ZcgODhr+oDM8NzEd5AecoY3bpS2r0awo2Kql1PA JPLsXO8KKcZJSSmddjTI7y1oqp4QfVRlp5itHGHyAF/N1mrMoabNuotfILvL2iw8rKyKBoI9Eob HgN8Jpbl0pusrAHMzc X-Received: by 2002:a05:600c:3b20:b0:47a:9560:ec28 with SMTP id 5b1f17b1804b1-4832020df6amr43330755e9.13.1770391926971; Fri, 06 Feb 2026 07:32:06 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-436296b20fasm7140617f8f.6.2026.02.06.07.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 07:32:06 -0800 (PST) Date: Fri, 6 Feb 2026 18:32:03 +0300 From: Dan Carpenter To: Andy Shevchenko Cc: Ariana Lazar , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel Subject: Re: [bug report] iio: dac: adding support for Microchip MCP47FEB02 Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Feb 06, 2026 at 05:14:53PM +0200, Andy Shevchenko wrote: > On Fri, Feb 06, 2026 at 05:33:26PM +0300, Dan Carpenter wrote: > > On Fri, Feb 06, 2026 at 04:04:07PM +0200, Andy Shevchenko wrote: > > > > drivers/iio/dac/mcp47feb02.c > > > > 712 static int mcp47feb02_init_scales_avail(struct mcp47feb02_data *data, int vdd_mV, > > > > 713 int vref_mV, int vref1_mV) > > > > 714 { > > > > 715 struct device *dev = regmap_get_device(data->regmap); > > > > 716 int tmp_vref; > > > > 717 > > > > 718 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_mV, data->scale); > > > > 719 > > > > 720 if (data->use_vref) > > > > 721 tmp_vref = vref_mV; > > > > 722 else > > > > 723 tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV; > > > > 724 > > > > 725 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X1, tmp_vref, data->scale); > > > > 726 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X2, tmp_vref * 2, data->scale); > > > > 727 > > > > 728 if (data->phys_channels >= 4) { > > > > 729 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_mV, data->scale_1); > > > > 730 > > > > 731 if (data->use_vref1 && vref1_mV <= 0) > > > > --> 732 return dev_err_probe(dev, vref1_mV, "Invalid voltage for Vref1\n"); > > > > ^^^^^^^^ > > > > vref1_mV is not a valid error code. > > > > > > Why not? When it's negative I believe the above statement is not true. > > > > I saw this as just sanity checking the input. vref1_mV is never > > actually negative. I don't know if devm_regulator_get_enable_read_voltage() > > can return less than one millivolt. > > * In cases where the supply is not strictly required, callers can check for > * -ENODEV error and handle it accordingly. > * > * Returns: voltage in microvolts on success, or an negative error number on failure. > > What did I miss? > drivers/iio/dac/mcp47feb02.c 1157 if (chip_features->have_ext_vref1) { 1158 ret = devm_regulator_get_enable_read_voltage(dev, "vref1"); 1159 if (ret > 0) { 1160 vref1_mV = ret / MILLI; Potentially, if ret is in the 1-999 range then vref1_mV could be zero, but it can't be negative. 1161 data->use_vref1 = true; 1162 } else { 1163 dev_dbg(dev, "using internal band gap as voltage reference 1.\n"); 1164 dev_dbg(dev, "Vref1 is unavailable.\n"); 1165 } 1166 } 1167 1168 ret = mcp47feb02_init_ctrl_regs(data); 1169 if (ret) 1170 return dev_err_probe(dev, ret, "Error initialising vref register\n"); 1171 1172 ret = mcp47feb02_init_ch_scales(data, vdd_mV, vref_mV, vref1_mV); ^^^^^^^^ 1173 if (ret) 1174 return ret; regards, dan carpenter