From nobody Fri Apr 3 07:42:51 2026 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 E22C62EB5AF for ; Wed, 18 Feb 2026 04:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771389471; cv=none; b=EPAVzjBn5tCZLT4HXhCSSbHkxGQW5kEncGt/8/XVd43V29AMoOccypLL5npdv7fiizmu54AcR8Cbrb+t8ddYci7IzOv6bYl4xgFtye+xDsDI5eV7RqlYFPiAOrewy5eN6KD6hE4fwrg6zXhptQs6LYlGdOz9ywH7H/XmYhPkwGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771389471; c=relaxed/simple; bh=pagHrvqBbwrKpiRdGecFFOqcw3gp13P/UHq0LoGCMuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxCVKdzcmjDo1oWcOH3+VXR1Ab1kcw8WsBzHEmEvQpPsC/pYx3pS9iZ9EfWkVfGzsibEKn04CVm7TqAram24c8/xO0VWo/oXFVYDRlsIfDwRfIY9ixbJ/z8apXY2uvhusL99ws2eDB2K+Pbwa0vDpCQZpjjbXJKW6fFw4tWpU94= 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=QdMZkTtl; arc=none smtp.client-ip=209.85.128.176 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="QdMZkTtl" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-794fe16d032so40776197b3.3 for ; Tue, 17 Feb 2026 20:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771389469; x=1771994269; 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; bh=wbfCSCPWbYKBtZ/X2FNoHWhz4WNydDjl7xPuqNagV4U=; b=QdMZkTtlTqwOTj87ABapGsm8sl47ti8IVF1b4LHt7uLoSmuMI76nTmpvOPoiP8Pkr4 q+2wFzswPmvmQUbgV5jsX9IJWi7M/PujvhkvzN2eEWCpnSd8ss5XCBB/f/UEvd0IYsr8 LecZhBkGSGxqQFR5PIvac+c5QPgV9YvmynlQ+Wf8+tFYT4sKS6XfKCe6zht5+aGfN7cK F3IsPl3AqEX/l9S3VxB6cV+r9Dx1pzglQCOpXLaWtxpbQeECnnAxks9TGHuQn1MueomQ zeY4sd8JsaL2Ks6ebZ5apz3hBD8M9SHA0ZK5R6Sg64g9yO/T8I0Aeiosc7r//vL/IRjr St/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771389469; x=1771994269; 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; bh=wbfCSCPWbYKBtZ/X2FNoHWhz4WNydDjl7xPuqNagV4U=; b=cDTKbOEl1lneSvcGUHlHUrKly1q9+z3oEfTXwzO9brVz4FOmIsrzxjb5w0ZGoRYeZa c4cJCDZhxryqInGVCnRER8n8ITsmwegIJq+RvnDc4uCxlsNBShonS5DQf0u6RbnEr3Sn q0XssovSd22Yo4PSb5+4vAOkb9VxNAmJihiPmcwpyHX5qdfJYPA8HsJn4erP9WPCSivh gOEglVX3DoC5uKzqU8XylTTOHg2VBrbfI6KexHTP1ae2fyszwKt4urREMBpRIZvp2eKg HmKkuFYSOWhcsimARBlos5rp8VdpHT6nlo2TCBybD7PAwmI1RilskaEO45DMOAfiCxvR F0TA== X-Forwarded-Encrypted: i=1; AJvYcCX7NypTKVhDhFDxLDCW/dQogbWDPI23JTo8jgV+41l3iZmvvbGX+j2dCLLreXlfT6W5sF62nXvS/3616R4=@vger.kernel.org X-Gm-Message-State: AOJu0YxiNmDRoJNvKgalZ+L8q4P+gQ9ow5D8qYX2bvWI0A+0dfi7ISof 7HmQ1mE/igfNWABiaYnr3H/i9LMtegdw6CjphhBxAbup7eQR5sLXRuf/ X-Gm-Gg: AZuq6aJaGlqS0ThIVCkygM+cpAdJLBebCSuFHTPNv2sRM/Wb0PR6GsSWHuiOaZ8UYbT 7+6BSmp4a3GgJrCv5swQv/1zYfwI/eIigEiJGD0ixcBQ9AGlD75y0Us834gOmexLceNgEBxjDCe dndHyTUj6bJljf4Yg3h7MCjOKLw0JiIqhOxm9Y39eHj1w0LBPMqnk4ewSdj6ARn+F9hSNsOjRrD VTsQVhlcm2dIYqZc73U7mxnykKRl6A98ynZ5VG+1QnpXV0gT03WpWGcFrEk4Ll7MGyYdB6D/HYD ukptwYlpr6OyuruSWkkkTabXsdZcQbGklBRJJVIjrphaquYOPrdFn5gaGdUvpyDgI4q4s20yCSU IxaLIdOpnLGRrwtcfzy9BXr8pijCOE+EDmfEHa5W026fQ9DNKJ1kTkyq9lVeQY/3cMtyiOOYPUb z5m5m3xXxCY54lESqgjkdae1/Dh/t7qitZg6g5VVOiodYwIgfnwDONQNUblf0PIOtcA2egB+Vsv 9UY3lh2rmNxu7mmTnvFiB0qv6VuhsD2YAvY3JMmadw= X-Received: by 2002:a05:690c:2607:b0:797:e0ec:b8df with SMTP id 00721157ae682-797f71c12a3mr4865877b3.18.1771389469023; Tue, 17 Feb 2026 20:37:49 -0800 (PST) Received: from tux ([2601:7c0:c37c:4c00:e3a8:26f7:7e08:88e1]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7966c23e4bdsm119850617b3.32.2026.02.17.20.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Feb 2026 20:37:48 -0800 (PST) From: Ethan Tidmore To: jic23@kernel.org, andy@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ethan Tidmore , Andy Shevchenko Subject: [PATCH v4 2/9] iio: light: gp2ap020a00f: correct return type to int Date: Tue, 17 Feb 2026 22:37:21 -0600 Message-ID: <20260218043728.609659-3-ethantidmore06@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260218043728.609659-1-ethantidmore06@gmail.com> References: <20260218043728.609659-1-ethantidmore06@gmail.com> 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 -EINVAL in its error path. Yet, the function has return type of u8. Added error checking for gp2ap020a00f_get_thresh_reg() return value. Detected by Smatch: drivers/iio/light/gp2ap020a00f.c:1013 gp2ap020a00f_get_thresh_reg() warn: signedness bug returning '(-22)' Reviewed-by: Andy Shevchenko Signed-off-by: Ethan Tidmore --- v4: - Added Reviewed-by: tag from Andy Shevchenko. v3: - Remove Fixes: tag. - Added Smatch warning. v2: - Fixed gp2ap020a00f_get_thresh_reg() parameter alignment. - Removed unneeded whitespace between assignment and check. drivers/iio/light/gp2ap020a00f.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a= 00f.c index 91fdcb980111..deca9fd77fdd 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -993,8 +993,8 @@ 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, - enum iio_event_direction event_dir) +static int gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, + enum iio_event_direction event_dir) { switch (chan->type) { case IIO_PROXIMITY: @@ -1024,11 +1024,14 @@ 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; =20 guard(mutex)(&data->lock); =20 thresh_reg_l =3D gp2ap020a00f_get_thresh_reg(chan, dir); + if (thresh_reg_l < 0) + return thresh_reg_l; + thresh_val_id =3D GP2AP020A00F_THRESH_VAL_ID(thresh_reg_l); if (thresh_val_id > GP2AP020A00F_THRESH_PH) return -EINVAL; @@ -1070,11 +1073,13 @@ 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; =20 guard(mutex)(&data->lock); =20 thresh_reg_l =3D gp2ap020a00f_get_thresh_reg(chan, dir); + if (thresh_reg_l < 0) + return thresh_reg_l; if (thresh_reg_l > GP2AP020A00F_PH_L_REG) return -EINVAL; =20 --=20 2.53.0