From nobody Thu Apr 2 15:41:20 2026 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 F405586352 for ; Wed, 11 Feb 2026 00:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770770920; cv=none; b=uHendL39v9qP6e4448fBukXNcv6Bs/gwp0jCFJYQ0XQpeQsKe4EkvgupnRMVAcAmdLdoQFIRW+UYLnR2tWrP6+r2JG6yJRDJgs1WkOOaEvl6mBPxjrQac3ihAjOO/v3NPSubDDLA5U6PCfDR/Ty+JVvtoC8cHeEH0eIrat3uzww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770770920; c=relaxed/simple; bh=hQHDuAeVIShrqRfwzEWpPeww2JVwqe01MpL3Pgiu9CA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Cilyke6XrQM8LmM9J/PuXsAeFRFPWszHzErtL76JJLNAA3M/rvArq1CO4KYywr7K0m2HJHY2wKawqzhmGMwkerGuffjTpo7llt8A0yCDrpFo2EcPyRXXsOcFJ315Rfb/D8LkoQzIVnXgEnjo2dLKmh6vO0Qfja1cKAl+09X2FIg= 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=QiU+b/4t; arc=none smtp.client-ip=209.85.128.181 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.b="QiU+b/4t" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-79273a294edso13814047b3.3 for ; Tue, 10 Feb 2026 16:48:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770770918; x=1771375718; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2Kc1awYXd/il/iM2fPxtQGgTUyWwIhmO+WdWac4gmq0=; b=QiU+b/4txx145fyeesU0vBqNuoDfPJMT7cmWP0/BEHp9viM+VIYhdtkrk/Q464sKj9 H8AbH7SX6JRAZJf0btfSj4BhbGR3n9UgVNDXhooqS5kkT8IXNE+oLqjvd/rM7EyJhcM8 kTBrazA92pPfX57XLWQx3tZKTpcwPCNVxgzvqoRH8GnrO5UB0LS45ktbeeulHWsA56jL O0Pf6O0Bc0pRSTGl6fG+D2z7iZKJwg0Q4UO8ySOekBRgcZ6nYUCuhSYCJXHwB/pkyAXo /0vruQUgfc+c5iFnoN8hHGdqYNj+/7DPK/22VKKvxsjhBz20c6Q9NNscbWdXj7RAyFbs 0qvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770770918; x=1771375718; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2Kc1awYXd/il/iM2fPxtQGgTUyWwIhmO+WdWac4gmq0=; b=hMVj8CLraq0HjmMZDlgABq7B5fCK4OBLDP0sH58ANHphQhH1djUbj6ZQixEwDE4yB8 T8eyD2swYptLYTa1XxfUvrcJaAq0YzdmLTUPKWIqy5Qf7Rd7q+oi9exe1QcOHuVBD3ep ypiptgNs8CeaWRXOnOqJTcqgPgequ/gFh3v2iW4/8GdpoPctMbXDFliZAvVpkuD1xnUw tEdhHh9oz8FOxqkMmiXSbqSUHv5NZ6IZ4cCOumYspD29kB8S5QDQUCHt+CkPVe6A4o6z M/SqDtJa3TqAKyVJYEjr9M/+RU6CLfUawkYRCkubhDjqqy6qYydIYQbWxBcnjZ6Uq6Kj EKWA== X-Forwarded-Encrypted: i=1; AJvYcCVRjVQH4Ibg56QpsqsGDqcPna5HAWDn6aBaScYniPTPm3CWuTXMLEWCTgzHiQyIq8vW+RROYBe0ZtcJVZE=@vger.kernel.org X-Gm-Message-State: AOJu0YwIt8XfXfcQ84Pjf1Jm8rEZRBtt+JdbRW/j0uoQgm1fF/sAc9zx 2Lwb/Wyp8N/1Mepjb4XCSPpOP3gz7fxcnMrSrNT/hU93mpHTQOocm/oN X-Gm-Gg: AZuq6aKDP4gEcC9uPiti80B553ATkuEVB6MwjTZK8bJFaZZ6ndFWPpeU8M9T3VCz1wf tasDnyIXgI6m+KBBuNGpdldAuTJSVsxIJpIohURTPZ/V2vFCXTva5wBHWTKVI1h0U6e5WzEhgD5 yVfTAHM/HSgk5IehHMTsin0Ixh/97vmguZ4zlOti4jpL2tIfl6lPSJjWe7kkZ9aMphGSjCVGy8C sUe5nzL4WttRUnW8ajiKzczLOyKYQ6YQicUB64dQePvLKjJ0b8pSzQRn8+ngfaAN9p5SJcySEcf uuQSwvtleId1Twiya4OO08t0FIepeCfRDOdEJN9ivu7PSB6yG4F/UMwZyw682nEFs3bei/ZfT7E fF8cbS3PM6QzcBWCs/m3ML9VYMs9auws3QXkbZ2Z5Z21xqhNL7ILLv0xppFrxVklihXILpfC2Ko F3vXNZq9C4avpkMZZLYr1YrIoaNXCznRwLhDDbr/KP9UsJWeIcm15G8ZIAB30uGf/q/CKkY9RKx GeZHNiSrbn0oT3blD7HxBgI X-Received: by 2002:a05:690c:288:b0:794:e634:edea with SMTP id 00721157ae682-7952aa37b20mr162380167b3.14.1770770917963; Tue, 10 Feb 2026 16:48:37 -0800 (PST) Received: from tux ([2601:7c0:c37c:4c00::9944]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7966c254dc8sm2296417b3.38.2026.02.10.16.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 16:48:37 -0800 (PST) From: Ethan Tidmore To: Jonathan Cameron Cc: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ethan Tidmore Subject: [PATCH] iio: light: gp2ap020a00f: Correct return type to int Date: Tue, 10 Feb 2026 18:48:19 -0600 Message-ID: <20260211004819.854169-1-ethantidmore06@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function gp2ap020a00f_get_thresh_reg() can return type -EINVAL in its error path. Yet, the function has return type of u8. Added error checking for gp2ap020a00f_get_thresh_reg() return's value. Fixes: 5d6a25bad035 ("iio:gp2ap020a00f: Switch to new event config interfac= e") Signed-off-by: Ethan Tidmore --- drivers/iio/light/gp2ap020a00f.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a= 00f.c index c7df4b258e2c..492d1a029f77 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -992,7 +992,7 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq= , void *data) return IRQ_HANDLED; } =20 -static u8 gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, +static int gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, enum iio_event_direction event_dir) { switch (chan->type) { @@ -1023,12 +1023,18 @@ static int gp2ap020a00f_write_event_val(struct iio_= dev *indio_dev, struct gp2ap020a00f_data *data =3D iio_priv(indio_dev); bool event_en =3D false; u8 thresh_val_id; - u8 thresh_reg_l; + int thresh_reg_l; int err =3D 0; =20 mutex_lock(&data->lock); =20 thresh_reg_l =3D gp2ap020a00f_get_thresh_reg(chan, dir); + + if (thresh_reg_l < 0) { + err =3D thresh_reg_l; + goto error_unlock; + } + thresh_val_id =3D GP2AP020A00F_THRESH_VAL_ID(thresh_reg_l); =20 if (thresh_val_id > GP2AP020A00F_THRESH_PH) { @@ -1080,13 +1086,18 @@ static int gp2ap020a00f_read_event_val(struct iio_d= ev *indio_dev, int *val, int *val2) { struct gp2ap020a00f_data *data =3D iio_priv(indio_dev); - u8 thresh_reg_l; + int thresh_reg_l; int err =3D IIO_VAL_INT; =20 mutex_lock(&data->lock); =20 thresh_reg_l =3D gp2ap020a00f_get_thresh_reg(chan, dir); =20 + if (thresh_reg_l < 0) { + err =3D thresh_reg_l; + goto error_unlock; + } + if (thresh_reg_l > GP2AP020A00F_PH_L_REG) { err =3D -EINVAL; goto error_unlock; --=20 2.53.0