Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp63783rdb; Tue, 19 Dec 2023 09:22:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFc678P6g576usxqCGmfQeQsDETPHzARYdSCC3hv5nj7T5+mD3r4RUG9hclw/HKxLb9aHI X-Received: by 2002:a50:d79b:0:b0:553:102e:c7c0 with SMTP id w27-20020a50d79b000000b00553102ec7c0mr2520021edi.56.1703006579838; Tue, 19 Dec 2023 09:22:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703006579; cv=none; d=google.com; s=arc-20160816; b=p6P78DwHou8xEsdfoPjUtXe2gHE2Tjt8VCTofY+rw2kTyqu7ItFSdhp3/46rnFOb3/ 06Tqsy/ecN9tNVBTgXSgF1tn5mRSwVZJS/uTHJv6sReDFj6J1Q3F2k6g7dZLa9fpcqbE /DdAxngcnuFky1vFAT41Lr/ZOXx6rBQk51HoJuDAofy1cH0IKi8hgv/AbdtN4GbyxMzj buKuIu6tTY5LQmX/HrJeIj6NyFs2Y8Cbx99d3rJy3+fZ1XYRtHx5OT0Fb8+PRUWF1WKC +x2SgK3p81i2ArdXkn9Kr6ucCKOT1tduD1jSeIF0GuDLGBM29v5jOIhI6oZ71W3qRMsq BnTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:cc:to:from:dkim-signature; bh=eAovb+UcCr8c4+yXpiGUDUECK8pQrI3Ofw2ziL8xaHg=; fh=XmY8az1z5a+LjrZQ1DQahIeB3Uro2SuOHb+6mIYcxXo=; b=Yq1f+vQPPTTB94m7QumijkDrQaqQ7tQEPJ/a1QpYPybwCHdrUlQJojplh5FgPlob1E CBqS7rVD6iPrV6Rv+nr9GOw++REYaXHG3SoX0JD/yxntSdREAdo66D6NjnGhbxI5yxuI MX3Q7B4bQdjEwq48S6A5yp1R2s27kVgGTO4yjf1zQh+ea+bNhUbQaqpFIIvobScjbJeD kClEXTAA1R6nEic80AS72QGatdmXmzmutKF5j/1jrmIuOzWpX3n/qvmuYNQfMZXQqsmW Ry14IzSaoce6ump4WIAx5xlK4lTgycwlguZGeSp3Y+GawW2TjBgkPWyPIiAHnS2AuLak yS6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=xb4NbYgN; spf=pass (google.com: domain of linux-kernel+bounces-5682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5682-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s13-20020a056402520d00b0054cc404ce3csi11644557edd.396.2023.12.19.09.22.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:22:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=xb4NbYgN; spf=pass (google.com: domain of linux-kernel+bounces-5682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5682-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 011C41F260DE for ; Tue, 19 Dec 2023 17:22:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E36E3A1BC; Tue, 19 Dec 2023 17:19:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="xb4NbYgN" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E97B71CA89; Tue, 19 Dec 2023 17:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=eAovb+UcCr8c4+yXpiGUDUECK8pQrI3Ofw2ziL8xaHg=; b=xb4NbYgNCU3y5gAWSAmZIKnYEA mxGt9n6Mq740/FU1jviVnXzo7T+ziUKk9/z07smCh+nR9TaaLoZGGv3UE5jHqPpkhBhQk7K8Gc3Zj 2+IGINBIdLTNN0FmjmOnbkUZfHVO207RCm3g7ws2TgkSFNqB3wPLcdDZTStMp/uGcw0s=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:40128 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rFdkV-0007Ao-SB; Tue, 19 Dec 2023 12:19:20 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org, jringle@gridpoint.com, kubakici@wp.pl, phil@raspberrypi.org, bo.svangard@embeddedart.se Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve , Andy Shevchenko Date: Tue, 19 Dec 2023 12:18:57 -0500 Message-Id: <20231219171903.3530985-14-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219171903.3530985-1-hugo@hugovil.com> References: <20231219171903.3530985-1-hugo@hugovil.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 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. Subject: [PATCH 13/18] serial: sc16is7xx: use in_range() for DT properties bound checks X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) From: Hugo Villeneuve Improve code readability and efficiency by using in_range() when checking device tree properties bound. Suggested-by: Andy Shevchenko Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 133538f91390..29089b11f6f1 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1398,7 +1399,7 @@ static void sc16is7xx_setup_irda_ports(struct sc16is7xx_port *s) struct device *dev = s->p[0].port.dev; count = device_property_count_u32(dev, "irda-mode-ports"); - if (count < 0 || count > SC16IS7XX_MAX_PORTS) + if (!in_range(count, 0, SC16IS7XX_MAX_PORTS + 1)) return; ret = device_property_read_u32_array(dev, "irda-mode-ports", @@ -1425,7 +1426,7 @@ static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s, struct device *dev = s->p[0].port.dev; count = device_property_count_u32(dev, "nxp,modem-control-line-ports"); - if (count < 0 || count > SC16IS7XX_MAX_PORTS) + if (!in_range(count, 0, SC16IS7XX_MAX_PORTS + 1)) return 0; ret = device_property_read_u32_array(dev, "nxp,modem-control-line-ports", -- 2.39.2