From nobody Mon May 25 06:40:19 2026 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) (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 DCFF23BAD9B for ; Sun, 17 May 2026 17:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779038291; cv=none; b=LFSrYqlghC7yNMkg20qdEJXVsxqpdk9BfOyCZHSOCfayKyDCR0rDjOn9MbIGE4d3jwvvb6fqT5wYYm/0eamLSCtKNWwnsnU/DPEtHPfaOt6zA3/RJcAL6loEfrrBXku3VdLl8JJZ/GZN5+Lutu9otgGEYfsC2CTICvPc7JCsb0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779038291; c=relaxed/simple; bh=Pbcjmu2neKpIq11ZvX2Vs0VZuTzrW7nh1KKeegZow3A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K39m8mSCAGV8z1Qa8zWAoQV4gSZH1wo7avZaQxy2oPuB6xfZijQM5d7PvSbUcIKShAx+AR+tbL0aafYo4novkf/nBIlz9Zz4ALz6R2mVqSsbwzgafYvUnKaAJaSFpD/9ubxP8GjMmIFUxhLa0MfRQRzHWtbYRHdRKKgb5fpMuAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=unGaLiBa; arc=none smtp.client-ip=95.215.58.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="unGaLiBa" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779038278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dMrIRzmDFzvbvvNy8Qjd2QGwDALwWuRi1tolJDbELPA=; b=unGaLiBa/gE+JfzUjnx2o//hKQQtglsdj2wbBP58QwFcvDXkN5lW3/g0eLPv7fK2VfbaUg Gd5zStT+EaZbWfhgnpVXs6/UqeRCKH9KM6qACXEdfAk3a3mYtvNZONw+P8KHfd/Cz7iAzh /l9cQPz0cYeXMksJnIIcjJiGI+1rMCw= From: Thorsten Blum To: Andy Walls , Mauro Carvalho Chehab Cc: Thorsten Blum , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND] media: ivtv: use clamp in ivtv_try_fmt_vid_{out,cap} Date: Sun, 17 May 2026 19:17:43 +0200 Message-ID: <20260517171743.2698-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1776; i=thorsten.blum@linux.dev; h=from:subject; bh=Pbcjmu2neKpIq11ZvX2Vs0VZuTzrW7nh1KKeegZow3A=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFmcP8x7qqynes1dPu3fsusfA9oKvx/vUOh43btc6Fl9t UNAwIplHaUsDGJcDLJiiiwPZv2Y4VtaU7nJJGInzBxWJpAhDFycAjCRS9kM/x038ayYuSDPeVb8 20ntDxWFHXids74etzz5bjFHEN9OoQJGhj4+zuagboGX1b9unp9Qr6bouUuh8JnpUXeT857dVxN 38QEA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace multiple min(), max() calls with clamp(). Signed-off-by: Thorsten Blum --- drivers/media/pci/ivtv/ivtv-ioctl.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/i= vtv-ioctl.c index 8d5ea3aec06f..fc95f0bf48d5 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c @@ -467,15 +467,13 @@ static int ivtv_try_fmt_vid_cap(struct file *file, vo= id *fh, struct v4l2_format int h =3D fmt->fmt.pix.height; int min_h =3D 2; =20 - w =3D min(w, 720); - w =3D max(w, 2); + w =3D clamp(w, 2, 720); if (id->type =3D=3D IVTV_ENC_STREAM_TYPE_YUV) { /* YUV height must be a multiple of 32 */ h &=3D ~0x1f; min_h =3D 32; } - h =3D min(h, itv->is_50hz ? 576 : 480); - h =3D max(h, min_h); + h =3D clamp(h, min_h, itv->is_50hz ? 576 : 480); ivtv_g_fmt_vid_cap(file, fh, fmt); fmt->fmt.pix.width =3D w; fmt->fmt.pix.height =3D h; @@ -516,8 +514,7 @@ static int ivtv_try_fmt_vid_out(struct file *file, void= *fh, struct v4l2_format int field =3D fmt->fmt.pix.field; int ret =3D ivtv_g_fmt_vid_out(file, fh, fmt); =20 - w =3D min(w, 720); - w =3D max(w, 2); + w =3D clamp(w, 2, 720); /* Why can the height be 576 even when the output is NTSC? =20 Internally the buffers of the PVR350 are always set to 720x576. The @@ -533,8 +530,7 @@ static int ivtv_try_fmt_vid_out(struct file *file, void= *fh, struct v4l2_format resolution is locked to the broadcast standard and not scaled. =20 Thanks to Ian Armstrong for this explanation. */ - h =3D min(h, 576); - h =3D max(h, 2); + h =3D clamp(h, 2, 576); if (id->type =3D=3D IVTV_DEC_STREAM_TYPE_YUV) fmt->fmt.pix.field =3D field; fmt->fmt.pix.width =3D w;