From patchwork Sat Jan 11 09:55:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 856669 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (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 5B78A18E03A for ; Sat, 11 Jan 2025 09:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589326; cv=none; b=PdfhqzDo1xHBdFFOOk31W1+wYRE/rVvlRrIcUu5ps+cv3b5WxuidSQIuSxIkYQPncYlYJpCsVqbl0B8+4RSIzJ7CgS/m3saqsAdRMlN80XULDsN8bjVW1p3i2D8XaviGCUryn863AcQV1UkFmcl3gxGei6N0onJ/QKHaCTTTMlQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589326; c=relaxed/simple; bh=cJ3Ao2R6zgoGJgyibADb5EAE6IKBeo/pElOZjlQDp0Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FclKEBgsWfd+yPd6h46IdyPf0ce4X9w0v5AYWEojp144qWjJfTyOsvuYOTNdQObFf2nnRO/3dFVFVVdDVzbOWJue1oYz5o+AtljrWS/EYCAxppm0MDqb8K4R+10JDpjUpuqmJAj7fFqn3BzAxBmxus6jcjVeAIwRJQMU7Tjr5sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=OuMYyroZ; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="OuMYyroZ" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6dfbc45355bso2023126d6.2 for ; Sat, 11 Jan 2025 01:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589324; x=1737194124; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=52iWgPg8zx+q33hKer1CkCPQAZHddOV8vj+q0ZyeQAY=; b=OuMYyroZ54iH3H6THbYRxENeEoSEm6U9dF9xpWxmLlRUSPh2Ze2UF+ZOeCuX+s/OKM wnDnthyOIuTqks1c+0lB8q7kVXqGtBxV2xi8rJMwDWMTZd+T9KBlxHodSFZuIlK+g83u A1KZ1Mz1rf1NnH+dkinadBwAmyVmx7LRXFlbg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589324; x=1737194124; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=52iWgPg8zx+q33hKer1CkCPQAZHddOV8vj+q0ZyeQAY=; b=N4gp7O8//6JXc50tOYA1nAXxJNrn6XELbqBVU32Rua/w+ScDM9HN21QfrgFtmt5ASZ B5II8h0JFwRGpCR+wCY9WlWfKgbHhvsWmUt3LdAryMrRfvZ8lY3tkpqhJWzCG+GL/Ie7 ZniNM31uqLK9hhPCUmAlX6yxBOA0Gzfr8Ikq2dhCOyWFtfSTp039SC4k0pRvZ6tIG70u PYOdLoX9mLpUe5Qb/MmheGMS7PMEms2QFbKCkVzPQC7VqH8KTFNeP0Z3qshRvTa09u/y bhRC3mz9FeUlexMDKfWUuMgrOVjvDtMq/p4lXqbbs/ll81n2/5gHTVPmq/8zIY0YCRtj 8acA== X-Gm-Message-State: AOJu0YzA2NaCo+k2/bsDwnF1wW7vFawJfyDkWauMRwHMFlIAxWYT0GTT NGy9ByKroFEDYparY0AMFrAV6+XLRheWedq/mfwasncyKiiRk0FgH8rhHzsnfDwxg8rJDpbTrG0 QaA== X-Gm-Gg: ASbGnctmTYa4Oi4vtYpoafxVoiFCBx9SG4STubOIq928EH03m13IzloJewUBrfFMRSC PrZ5TacgeftHMGe415hTtvNTCCP64JMMB46GeeVERJUKhduUIhUldggxrkUVYFfmDv9eOJNF9E/ LY1Chkt5XJAHKgWknFoQSHLkcqlAEs/7bhe8cwLNCSdNAcdYFWeifIzYxge9hWyfsh3grizW3SG +siLj3x0/9E2Avt4/0yv6x9XSDGxlys/HAjv/sf9V+4W8ccqsg6SzumdrNl3eVFAAxvOORB8sS0 4/yUchkYY2Ize+dQYhckrh2ji72T8ykeDw74 X-Google-Smtp-Source: AGHT+IFqiGK2VIMRcFvBZ2YyjvHmdtNauhF62df7aKlMfYRbakz7XnEj9n0FSoSywyG9ImyL+3sm3w== X-Received: by 2002:a05:6214:2a8f:b0:6d8:8e16:7c29 with SMTP id 6a1803df08f44-6df9b2383f5mr216932866d6.14.1736589324231; Sat, 11 Jan 2025 01:55:24 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:23 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:14 +0000 Subject: [PATCH v6 1/6] media: dvb-frontends: tda10048: Make the range of z explicit. Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250111-fix-cocci-v6-1-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Kosta Stefanov , Ricardo Ribalda X-Mailer: b4 0.13.0 The datasheet recommends 55MHz frequency sampling, with a max of 69 MHz. (Kudos to Kosta Stefanov for the calculations). Replace z with a 32 bit uint, and make the range of the variable explicit. Found by cocci: drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Kosta Stefanov Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1f87eb0dcf2a 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, u32 bw) { struct tda10048_state *state = fe->demodulator_priv; - u64 t, z; + u64 t; + u32 z; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,11 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, /* t *= 2147483648 on 32bit platforms */ t *= (2048 * 1024); t *= 1024; + + /* + * Sample frequency is typically 55 MHz, with a theoretical maximum of + * 69 MHz. With a 32 bit z we have enough accuracy for up to 613 MHz. + */ z = 7 * sample_freq_hz; do_div(t, z); t += 5; From patchwork Sat Jan 11 09:55:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 856668 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 9A1C41917FB for ; Sat, 11 Jan 2025 09:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589331; cv=none; b=tm7MtdlUzqNyxCtRR3FuPK2Xj1i6ycfpLnX8AU4RF82/hblqKArWg6G/fbuL7Uv1K7vv/XLdBhIFek1wKzgj7KhI+zmgVHXzwfb+Jp7pm/A/dJ9DGDT2vS9niYD+GPzNJIQM5tEauv9GAjS0gz7yznz4XgEclAsXGHiVXmpPEfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589331; c=relaxed/simple; bh=+5gKBR6lmCbLgDxwlcOKTLF2APbAil9sB0eDtQkBz/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZvXiVAPiCqKfIIN4+2yqRTLQFAflD9kDxPoJZ3hESdelDm4271ifPuKzH45WzZOZt4WsuYcC1+G36nlsgykF+feIyDQ0HHI/P+uuqUX5vedjC5U6V6jbBDAXsKD8/ojfcLYT/5/rw1X2GXqv5WrGNXUutfakkcMtFuGQBrG70ds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=C96bSz6T; arc=none smtp.client-ip=209.85.222.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="C96bSz6T" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7b70e78351aso236813185a.0 for ; Sat, 11 Jan 2025 01:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589328; x=1737194128; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oGXizJerOok0lDZxPeMPfVFSvShgmDlyLJgvxCS81kE=; b=C96bSz6TaoQXqnsfWjFREu7KcD0EjOj6CbbnAHPSV2wqMTwI6pYbppEnh56C8ciRLt H/6p4gZMwGnmmDFNwcYC9KGNozEAzwSgg1WjdQioFifHmeBNay88+Q2Nqm16gdQZszcM ZX50gFtVpauN4oFNajPz3VpJMepN/dQNUDEQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589328; x=1737194128; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oGXizJerOok0lDZxPeMPfVFSvShgmDlyLJgvxCS81kE=; b=u58iY3OI0bRWGxIoQYJlJitmUXcPZkJ/ZKxerDYVxyu5X1DcUHTRS1wwQpkaA+AjFk xCmyLmWptgRaQo/Fw//x2EkwQOX95Dl+SCIw0IDoZXl1vIOSrr3KgPbu/Si0ZAim4oFm nQx6Cht5Hft64H8f6CsZijCFGpvIWgnwsY52DcfBQVkammEv2EnUYYweHsBo0EpN0xCh mMaWweMT6KnLek+M2H2AyNA554ervclzO8BH1GDz3QapSW28QTS+E5Vyd4h5XMF3IVl3 veNVprWNsiyXb9p/Cfap4riU17WcNNPn4MlmM6gPnCYxo6gAE46k1Q2oix5KdUmD3n2O P4lw== X-Gm-Message-State: AOJu0YxDIThtmPzlcoplXUK0oHPqBZ34kGhTzPWR7cLo5/H75DVx8gEF mS23fvjbXa3+yie25EA8LHa1M53IDA6QmM37USKLkfzcFgjXWtkVPq3N7KRP1A== X-Gm-Gg: ASbGncv8xw+Wz+2mSDPsM//lRgX+UfbsOtgRFPIPZ8QttXHdg4RkMSdo1ILFs5RuD5u XWXm17kKKJEJNMvrqOs00XebBMJRSOQTN5zfnYiFXVHZTZiHp8XxJkONNAuRi+e1zHn6YDrqDLQ 4CWaI0Mc16T5zQ2XltG4QOXLLrzkUCw0Q/cytk1OJQOMIAd3+kev5A3KsE/96/z7ZxdZ1X5ZAek 6bvSY8+rwrgW9AucaBBdzvzKV0G64cCk8T0Hyf567ip4+YGamTBPbgIAZ7UOUoQ8KjLCmA7SOfG EpOz5GYYtJg6bhhEJ9il2CyNuJ6+fl+GyY/b X-Google-Smtp-Source: AGHT+IEpVR9I5biYuCr+SXV0UBeBGfKSe31bfLKgP7VOr+BuuQiGS7W1xlNlsmHP///j6pnH4LIVBQ== X-Received: by 2002:a05:620a:462b:b0:7b6:c540:9531 with SMTP id af79cd13be357-7bcd974a281mr2043337685a.18.1736589328570; Sat, 11 Jan 2025 01:55:28 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:27 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:16 +0000 Subject: [PATCH v6 3/6] media: venus: venc: Clamp parm smaller than 1fps and bigger than 240 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250111-fix-cocci-v6-3-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 The driver uses "whole" fps in all its calculations (e.g. in load_per_instance()). Those calculation expect an fps bigger than 1, and not big enough to overflow. Clamp the parm if the user provides a value that will result in an invalid fps. Reported-by: Hans Verkuil Closes: https://lore.kernel.org/linux-media/f11653a7-bc49-48cd-9cdb-1659147453e4@xs4all.nl/T/#m91cd962ac942834654f94c92206e2f85ff7d97f0 Fixes: aaaa93eda64b ("[media] media: venus: venc: add video encoder files") Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/venc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index c1c543535aaf..943d432b6568 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -411,11 +411,10 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC; do_div(us_per_frame, timeperframe->denominator); - if (!us_per_frame) - return -EINVAL; - + us_per_frame = max(USEC_PER_SEC, us_per_frame); fps = (u64)USEC_PER_SEC; do_div(fps, us_per_frame); + fps = min(VENUS_MAX_FPS, fps); inst->timeperframe = *timeperframe; inst->fps = fps; From patchwork Sat Jan 11 09:55:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 856667 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.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 BE041193409 for ; Sat, 11 Jan 2025 09:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589335; cv=none; b=MXLM5US7VCT3IaEbQhcv4ReNQdvJbbMZZ4jtMFPTIsWIR6mC82ONz5GzT7xUqUtiZB7YTHC4pTtwBDD+7mergqslZ5uklJ4z+rOdLwikIlQ4RQhws+JkCMWNsiaTwum28eKw+dY95POui5ybVUm5VotDtMV81WJTrvoKYqSJeXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736589335; c=relaxed/simple; bh=jFMkE+aUW4A2Tjf06APpBG1sAvp2ejflRJ8B5s0jBLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EvMylIobWCAbmJALgwYgx9hO65y7bFCdE8WSqM76rx6hs/wzGKEreoa2nLhjc9BkYVrMF7Yfgwxhc7RhCRCz6fzotun4c61ENoRsEb1JGwDaqWUsBCdzKjMb9ga28HAOUD4dqQwiJUSqHRE2ASgAkDAspbnURG99s5uW3Yp85zU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=bbKyHPHV; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bbKyHPHV" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7b85d5cc39eso299299585a.3 for ; Sat, 11 Jan 2025 01:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736589333; x=1737194133; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=f3BoX2c5ZbHlzZ/xObQ8c1PFxHvs7MLN/22FFGinwVE=; b=bbKyHPHV+azn/fU4OTZ4UULuoo/8Wyomc7g3GS2WVI+rKoWrBv+wlq7KOXkn29VjqO IJEhnJ7jdxGh528esEr9B9DJsCQ3ro+yc5PLBqB5luxbq138kyLtWM+xFCrm954vwTmh tVQ66Er2TUZsKHcD7rKrUG6k1A18u9QTpPy4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736589333; x=1737194133; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f3BoX2c5ZbHlzZ/xObQ8c1PFxHvs7MLN/22FFGinwVE=; b=pPlXV9fqlAvC0raBEJ5M0FAczhvS2J0m79f8d8dK4dngnlaB2nCxYt8yrIqKZ4HsyO c28UKOcRPIHHjrXmKN2tpXZCB5ODWei8FsXQqquytO+3hxqlTL+XwrG7OFSvKGtPjOjo E7WaRfckmelTUS9j2LA/LxiD3v+nAZXhcK4xN4RpYsD8SAr7QMv1z3O9PB3v0okKkNwh Iqz6ZQIl/ANk1bWmCGB91mI0kaH6oXfgLvkA+2Wrr2jPjPMlT3qoNozOTv30SHAyafUN 0baHbZYdAQ3jTXgNe4rapdJsMlWTn38XL6jNKt49ywgbg5Zd1sLBvsfWHGHzkRYcuWP0 yf8g== X-Gm-Message-State: AOJu0Yyr74lQz7niOQBJhkdAIvspWcbvGuvWzFapN2/ITmpVKZM6TjLh wTWYWk0DS4jT1TGSE3LA3QqT8OqVtnwxdkZeV6txlGuwIfJUJZ2WKtS/sr75Lg== X-Gm-Gg: ASbGncvBkDVVpf0gw5LWRZNkmRxNaqpgBPOgCMjJ0T9B/H3fjUMVbGzah/q5Fs0e/bt UqlYqf/rpizqG+zJwFr7OLeloMjlQW5FC2bMr4kXyH3yJ/wZuc6Qwpgak7jqQtB3SkrjOkbenWD H/Xwo6Q4xGo9Lu3EHvV/iNgmUgNJNydrzGGyNQGdxEU/P86L1d+Sivx6XGv1pXrR+Sj+oFerewB c9RyMGCM3jCz9CxZsVmpFhDyBwX9bV4mACyzTGqLEhW7MEpr6dVb+r0BbM3dJMH2aIDMJljzDNL Xyg99x34Nix8tpQcQd1LqdbkCgS9EzmuNvCO X-Google-Smtp-Source: AGHT+IHlflZapXB2U5EwdDsff9V9lka7ZWi7FvO7mOnx6N5gTF17d6mrdBuskWw0aArQ5dE890/KbQ== X-Received: by 2002:a05:620a:2481:b0:7b6:ece3:825d with SMTP id af79cd13be357-7bcd9726520mr1906864685a.12.1736589332721; Sat, 11 Jan 2025 01:55:32 -0800 (PST) Received: from denia.c.googlers.com (172.174.245.35.bc.googleusercontent.com. [35.245.174.172]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce327b8besm267096785a.59.2025.01.11.01.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jan 2025 01:55:31 -0800 (PST) From: Ricardo Ribalda Date: Sat, 11 Jan 2025 09:55:18 +0000 Subject: [PATCH v6 5/6] media: venus: venc: Make the range of us_per_frame explicit Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250111-fix-cocci-v6-5-1aa7842006cc@chromium.org> References: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> In-Reply-To: <20250111-fix-cocci-v6-0-1aa7842006cc@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Fps bigger than 0.000232829 fps, this fits in a 32 bit us_per_frame. There is no need to do a 64 bit division here. Also, the driver only works with whole fps. Found with cocci: drivers/media/platform/qcom/venus/venc.c:418:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/venc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 17bec44c9825..2c1836712362 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -412,8 +412,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) do_div(us_per_frame, timeperframe->denominator); us_per_frame = max(USEC_PER_SEC, us_per_frame); - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); + fps = USEC_PER_SEC / (u32)us_per_frame; fps = min(VENUS_MAX_FPS, fps); inst->fps = fps;