From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 2DC94343D60 for ; Mon, 23 Feb 2026 03:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771818043; cv=none; b=c12OJW2rHrHIPS8wtYLXHeedGsrFkE8t2sMbLqJzghilKpafh+bOkBMb48/tST3CDsesqYhGO2FJwcRiBBQFYWI/a85ysFlFNInBwC3O9h9yYisUb65bggaZcYtUxaWvLDSquKhGw6vWVubul45Jt/JXOcfaATk9tX3YRQ10hu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771818043; c=relaxed/simple; bh=MHTAdA0p3yx096g9IicyqQnRBWRyNknXQhvTuGz80UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fZV2jcRS7uxLRiPfusOkcebRdQpTJlI1DFaN8sSpZd4qtT0TC7f4TmgzifyeRMGba1jfKsZc5X/87Pqpdhge1wtDEXxXkmPKiQEKfevT7c2ilVSAXWhD+KtB9fvgzPsd+4KcfIQXzopZ6mhlgCmjxEXbtn9r9Mo5WiNQMis0KhM= 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=IFd7Upvl; arc=none smtp.client-ip=209.85.128.169 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="IFd7Upvl" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-79430ef54c3so32626437b3.2 for ; Sun, 22 Feb 2026 19:40:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771818041; x=1772422841; 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=QkUJsJ1p8D5fQxyBrpC9/cW9Unihi8QuVXvCcGPqhEk=; b=IFd7UpvlyUHKjivxiMrCBIX6IhI0Hb0NN1h61dpTvCdMF84n7qhdJ9qud98I7nh+dQ O/pepywlFa0h00wwcWgCUWnydX6daFetRSZgIoOeWmIOHciw5ru7N5H77McxbLR+l2w8 0ZXHzKQ1kK5EzILzAIieT9sd/+Mg+nAcI8TlwdIUlW0eVjrCZb/p4dYAfn4T4sZ/4M8w UoNowWi4hpMa/Z7CCWcKK9cINT3OZWCqG/pq48oRjoX+6+rcLHkuN9Wlny2+fSMBT2Pj T6tfQM1trEX/e7mIm9NHj5RfEkolyczZTMIm8olduhYKE2tl3htSKBPdXjMRkdImmCNA e28A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771818041; x=1772422841; 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=QkUJsJ1p8D5fQxyBrpC9/cW9Unihi8QuVXvCcGPqhEk=; b=CdaWGCXk+EP7+Sql4UtTAn190QZvldmRU6EU94Bc6ppVFpXQlh7M3d1Zo3EYN2eh9O HurpVaXnTjxCMhnyynGd5qwH4sh1ZV13mIsLIgOQaGB/9sD17Bn8DWoLVLleKt3F8TvO BAyO4F3JLr2haDSidMG411DvNmqX49BfCcGevEnlq6lDHj/eReTI8kG2WX4FljZwREB/ wXOXe1fdyQJnvbYLfBxF+2naBZJrls1KanZOwpfzhEAJfnKMPLDio7Wnvupx2aI54twK FuvEnNA4pb21neqjTXMwqJXOCvBVUKpOZmR/ATseptNW7MBb12jCP8/llnGp4wzNRiv7 G6pQ== X-Forwarded-Encrypted: i=1; AJvYcCWFW9xlaitWP+JSM+ETz3tgkbobrUV7Stb7PppnRAZjcQSzqNjTvZB2NhXpNwAuzlHmwvu7Ht2rL1Hyqgs=@vger.kernel.org X-Gm-Message-State: AOJu0YxgUfNEBnXQ+6bkoyfsSXpP64+hs5Na3DIM4BCWwlag4u5PtqB6 szUZFXv4ASTVbqZP1haFQd0bSvEFZDSiQCwtPs4260buHNDHtEHPOzir X-Gm-Gg: ATEYQzyPl2hSBrxy8wmuEIWb/D8VO7Nyq86pD5z9sFDzlEQsUGKWvfkIrXDWXuUd2la LNqhO0VM0zQA/bF7Mfqmu/L0nD8NPbkDXTJtc5W6+B0ANvojh5wrvN/sZNTz9ze/HAJwd+3PLTC kSAa0K12qYOIhaxH3M0kzOMs3YZmiZhGtwGQqf6AMq9koCWhWNtkIt1UxMNayl7e+6z3cdbi+oN e9y8J9ZCCvH5M1cyadlsSQ5j6O7Z5BRnWodZ7d9g3PNXdwoN/8RwX00faNI1JIqLWHg51pCubTT PfFcqmXiNPEXzcbjuyeetrzgEWdnEw0WCSmy1FjBZkzNU8LiHzdFEaJkPd7ZHwZmRwQV35g5TPH oppIzSl9I8ZyKkUd12MD5TeXQPV+Z4/105YsCKS5Lp0V5Vg3wQrRgSJbszLwN16eM+bPEwW/noK jdKZnawaekWHVtRfWHw3a0ttCkBrnNOaKXX/eUP9zLmwitE01bZjLOmuWG8eLTiuJR2Kis49N/T s/Qq6VcMFzT/YhVZQbkNhnv X-Received: by 2002:a05:690c:ed6:b0:794:d80f:d035 with SMTP id 00721157ae682-798290489e0mr60364847b3.49.1771818041119; Sun, 22 Feb 2026 19:40:41 -0800 (PST) Received: from tux ([2601:7c0:c37c:4c00::5c0b]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7982dbd5939sm27285237b3.15.2026.02.22.19.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 19:40:40 -0800 (PST) From: Ethan Tidmore To: Jonathan Cameron , Andy Shevchenko Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ethan Tidmore , Andy Shevchenko Subject: [PATCH v5 02/10] iio: light: gp2ap020a00f: correct return type to int Date: Sun, 22 Feb 2026 21:40:12 -0600 Message-ID: <20260223034020.27625-3-ethantidmore06@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260223034020.27625-1-ethantidmore06@gmail.com> References: <20260223034020.27625-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: 8bit 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 --- v5: - No change. 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/gp2ap020a00f.c index 7cee15db3a1a..6fe4486101b8 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; } -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 = iio_priv(indio_dev); bool event_en = false; u8 thresh_val_id; - u8 thresh_reg_l; + int thresh_reg_l; guard(mutex)(&data->lock); thresh_reg_l = gp2ap020a00f_get_thresh_reg(chan, dir); + if (thresh_reg_l < 0) + return thresh_reg_l; + thresh_val_id = 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_dev *indio_dev, int *val, int *val2) { struct gp2ap020a00f_data *data = iio_priv(indio_dev); - u8 thresh_reg_l; + int thresh_reg_l; guard(mutex)(&data->lock); thresh_reg_l = 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; -- 2.53.0