From patchwork Mon Jan 6 13:40:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 855305 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 C49501DE2B7 for ; Mon, 6 Jan 2025 13:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170812; cv=none; b=SMg1CyXD2iRR9zUeMF0oQ4fdp0iRw6FcX6d419wJHVftAsHTmmbLEaOBAIWQbjC7LYLtV0Z7iUqktivpdLAHgmegdQDzSOfi08CdwcRXwfrHUxhBLt6pTOT6phj8lsBO2gCNGyojWJ4r7dFN4jIsxzjJDb0ewFnw9vQRBL2rso8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170812; c=relaxed/simple; bh=/HaOC0UQuUCRG7UtKoSrqnIxQLLgF8uNCr3tEiNAggM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m36XGjRwQcnLW69cwHfWWgvo+lCRL0W0U4vZhS8RIvF82CV2be6YF/nwj1e10rf2rtQMNqwJyXKrDQdZNvjEgy+B74RdDS3sH6UZO2wCAbNelzt9ujthoQQpRmiOAPGbk8YFJBBQa9y7TOE8BeOgjFvubaPtruUlRK7bSIgwQyM= 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=Akfrpqpq; arc=none smtp.client-ip=209.85.160.178 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="Akfrpqpq" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-4679fc9b5f1so109082941cf.1 for ; Mon, 06 Jan 2025 05:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170810; x=1736775610; 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=TwdwuAkwGCHw83yVS+OBZ5UTbtgtyF3XHLP2TniQ+hw=; b=AkfrpqpqFkO9oYZ8EYkAjIdvYTBAZS8RS6VjxAJV5+HAulLkuQM0eWq4+GwaEll40a AphnfeHRT52gMbNs2fGLn2YH2c+zJpGEiz7HEXDlBhKpfNPgFFn6KE9/Neyvyjj2GHry L3lLFHXzz/486wxAb9TzEqzQzovowwV9tsgtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170810; x=1736775610; 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=TwdwuAkwGCHw83yVS+OBZ5UTbtgtyF3XHLP2TniQ+hw=; b=H3cTkmLJk4lQEBaQqXI/9ZJoYKqOuAlVsz2v5f6v7QWf3kII0xieutAEO1hzPBI0+m Pv9e0TgOnw/nOYvjOCZU1FU4gb/lp0HJvy/l7TW14SoZY90PMo4DgcfExURzvRJCntTG ek2Z9KGIGFzWUfEZrt6T5NneP6CCH7F6Z/iE0MXNwoh4cPLVi+QWKtBHMR80uu4EFPWI inj3VuNl5k1H3YZcUB6VEF+wVGj6JmksJYCkh9q/hG0M1Pw4wbv4drrLCvhXDNmdJFHV JJPLBw9QvIkJKqPwfkfFX8jmDicaAMRaZbvx53TAiTm23HB5LwjWx74Qqdy5SB4x290V cJ8A== X-Forwarded-Encrypted: i=1; AJvYcCXBxDxfDlNAOk54b3pjgw6uv4isWwW8j5PXroc14ph8yIJs/wMMzbzMiCSPPshUFG28i7DuSjcdYQYA2AIX@vger.kernel.org X-Gm-Message-State: AOJu0Yy11D1DOO/Ho1+SMx/7/Ef8zMFagoFpnSKs5BwbhmcPGsFZLK8t 02VOxVzkY/nCcsk5IEv0y6nFJFZ5RjpUTKZAhTCt4dQljspWn6P6TFSVemLWKw== X-Gm-Gg: ASbGncsxML/ix+H0NXMt63GNvbRqz6oLSNYCLgVB5M0JKzLTXVrY9ecS2rQJrmJrhWA QgqTYX3b6b07cxZW5uzYC7ZFReATPbMhiD0nuMvdu7Y/oCcgbCfShjxMEUf717ihxPgKjXATgMW 75uqGQDbNZfP6RLdr0aH0Kymr00xkuY6rftCx7K5DyzQTP0mJaCzVNdx4PKRr8GxjUi5I5aneKG lRRsSvKlLoGSe+G5UYdXosokNBy7XiDKU/IA2S05Pfi7Eqy/j94HqX4IB2wws5VxlFlqWDtXNvw iJqTLqZG3HSGarHjn1K9n3dn1Y2VI/Kh++DF X-Google-Smtp-Source: AGHT+IEn5Ou8N6A5ZuxRVWPs80QvCQAMfXcoa0B7FLd71FuJaMTg55qppld2zbRIfvJF/yb+Z4SD8w== X-Received: by 2002:a05:622a:54e:b0:467:6941:4ecc with SMTP id d75a77b69052e-46a4a977daemr1272210731cf.39.1736170809768; Mon, 06 Jan 2025 05:40:09 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:09 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:07 +0000 Subject: [PATCH v4 1/6] media: dvb-frontends: tda10048: Make the range of z explicit. Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250106-fix-cocci-v4-1-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.13.0 We have not been able to find the relevant datahsheet, but it seems rare that the device will have a sampling frequency over 613MHz. Nonetheless, this patch does not introduce any change in behaviour, it just adds a comment to make explicit the current limit: div by 32 bits. 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. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1886f733dbbf 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; + u32 z; + u64 t; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,7 @@ 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 under 613MHz */ z = 7 * sample_freq_hz; do_div(t, z); t += 5; From patchwork Mon Jan 6 13:40:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 855304 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 407171DB34C for ; Mon, 6 Jan 2025 13:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170813; cv=none; b=PwVrowReuelxOfIGhcBYX4PqNGMuv+SV2Rq2PWYpwdoWsKQmW42Phq1v5djPZvu9kJmnGag/4BIGkWGGba8I3WCKx+dHgxHv9LL9tIU6J+Ie8MjDkuQh3cg1djitrIRrkIts3AMS8WK4fZ+7BkLc7NWBOS02ObNsQKhXRASX5t8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170813; c=relaxed/simple; bh=6S98sC9zb379SpXjPj44qvbnzAChVkkYXuoHqOebMyY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ADE5274KTueHQ/bG7Z0KkFzzEgHFWNOazIjuzdWOr4z6jGuDq/VTximvkNdFPiRnsaUbtqh858iDbkR5dKuKm33acVZHlIBCkiLi8WfDj93plxd2l1E3vUXyMEzeQrREd1AicjusUYKdksLlJypt6Y1aCkfBqwH++L9lhh83/W0= 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=kncgcZxE; arc=none smtp.client-ip=209.85.222.174 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="kncgcZxE" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b7041273ddso1006625385a.3 for ; Mon, 06 Jan 2025 05:40:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170811; x=1736775611; 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=1sua/H7q/HxBmtn5ehYvB6xIDSURBEgE+eseMuH9rt0=; b=kncgcZxE+nBN/bBF+yiZX3cdt+EhOgfulXyNO8OT6URRm2wHJFX5LnH/1LaVH81cxH wKO54jBDLv3VQ1vjsWJIb4f5SUHhVrmGISlKnT3S7TzbLB5FN8ocZkkLe5lHXmL1AGaC kCTFK4/URJCBqLYNKduqa16gpwyYMMUVyWyKs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170811; x=1736775611; 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=1sua/H7q/HxBmtn5ehYvB6xIDSURBEgE+eseMuH9rt0=; b=hucfpk6LGq2VpcxObJ9pn7hXOhf14hqn1JZThoXPpgCvkrLSGRuioPpoheBvehsqLQ U1CDSaEio9QAYl8xjsxHXbS17uYyXEAZHAvCTQjZBETz4bkMnFklnV9ztPv/zAnWxqLx SInYlPF0nEE87Egkdxx6Lzb+319Deh1yCJJ9KhWNAC1XnX87OXRmSuYn1vIqmedcddDm wT2H0W5QmjQkZg09Kr4i5E82QyyuSKeG+BSlvr12brUOAHiztZyoTCWLQQ0T7Zr/1JE8 qTAkWJLvXrCetJ7T9Jq10xAzjY7aX6oQMdmgu1Po4ZkDtY7AY4RXPAzx4jvuCVx3HsGW Cneg== X-Forwarded-Encrypted: i=1; AJvYcCV79chpjgfQp0lOkM/5NRJfYHa7mhkCn0UgsKuY5naRwryWUNcPIAPDAJULDsOUbYd3zdrim9LLTd+HPo/w@vger.kernel.org X-Gm-Message-State: AOJu0YyMIeB/HQ2wgXgdk8GctE3M6TfgZlutyzJk9We933of4AmapLEK 86EWKts30GQ2CHGsyexxJpdtFBgqeL9WEYMRn5uTPI3FXHNhcFE5MO0m+RrUVA== X-Gm-Gg: ASbGncut4EwDUP+KDI4KLaWNEEpcqvNPA4IerhvEe98IPewY9ERWpgmNbZgPA+FAz1e +exN4/9SOHtjK75iCOJI//KgkB77CCVCDRZK/h+J41RzG/gfFjqQhJ+46E31we0qHqQwhB8VZAe OFIttVGl2MplrcEBwsQnbzkEm9pRxs7Pa8X2EFbhfQFxcAKaVfiMFSwUmzlOuttTxKhyb846gzR hhbyKkFhJviE025NvKdyyDR//GGEb/mDmfI09z+W1+Rm3dcI1NlBDKEiAf4ry+RIHPh29YLeSbD vQw1Sb2+lY8eLXgqUnY62S8ZxiNP8TmtV973 X-Google-Smtp-Source: AGHT+IHL/i9PYol7/BeTRyIFkBBCg5WCtmISC7fUpGW6mAhMPY0gQu9kkKdiaUQVy0qOM3paHIXmwA== X-Received: by 2002:a05:620a:4410:b0:7b6:ea22:3069 with SMTP id af79cd13be357-7b9ba79c26fmr8894375485a.26.1736170811310; Mon, 06 Jan 2025 05:40:11 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:10 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:09 +0000 Subject: [PATCH v4 3/6] media: venus: venc: Ignore parm smaller than 1fps Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250106-fix-cocci-v4-3-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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()). Return -EINVAL if the user provides a parm that will result in 0 whole 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index c1c543535aaf..bd967d60c883 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -411,7 +411,7 @@ 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) + if (!us_per_frame || us_per_frame > USEC_PER_SEC) return -EINVAL; fps = (u64)USEC_PER_SEC; From patchwork Mon Jan 6 13:40:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 855303 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 411951DE8B6 for ; Mon, 6 Jan 2025 13:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170817; cv=none; b=icBypPM91n45jeyNDNwKJQ42+i+g9k81av3g8khPpbyMXxOeXvxmnXt+FWxeH/5BXoVoGM6yZLviNYgcyL8xlW89YdHW6tvy/Z4p6m/Ay6hx4GIvWTRwXEsJ/Y6akZi6KzGRrboeOhGFeoZYFZuiqJ2bJp6AldZsAz3trfB8wEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736170817; c=relaxed/simple; bh=/hPtkiqbMiSuYUABeLf0k0X64qWSBh2CcTj5F3/fdPI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f4ElprfIg6/WVvqwnToPhhq+TMgUR+jlNJFnRtQwdrv4bKnErWDdRZLjlR25Blf46uMj5XRSmRLTxJEfTjZU2w1Me/GXMEXwdMs51/gxyB87P+LdiH/Sz3fIiA9mSkfaiQN8gMWM6RJWPdv+8twPdsxoTDY2oHAd1TzrOUAzdJA= 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=PAQxFpv9; arc=none smtp.client-ip=209.85.222.174 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="PAQxFpv9" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7b9c6c2c44eso918866285a.1 for ; Mon, 06 Jan 2025 05:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736170814; x=1736775614; 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=OaluQD75i5WN0/M2E9V2xLSR9NLQRzro4V8nhNRsJEo=; b=PAQxFpv9MIGmrwTaRjVIdwABBj58hHScDnH38p+lDl4EVwNoyIoOrdWTWfvpi9x04D KhQCidNj7qaHL0gfXVUUQVleuywVolb9Jmbh4hgjbCrpwoXxgL28jr5b9EZpNulVa8Gy k2pNZmcNOjW1GJMxV+SE/kKt69WQ/iI8ChNFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736170814; x=1736775614; 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=OaluQD75i5WN0/M2E9V2xLSR9NLQRzro4V8nhNRsJEo=; b=RMvmzXgxc7ms0nxDkwMZhXkxhXQqDiVC2ne65oN8XHN20wcD9K1P3toqqefKvEormX 5WSGrK9OjtM29bIPUyN1kyG3QcBr5/qkI/ch2+SCmcjniZcvBE2GzCIHemL5GNrn5T69 wMexL9wXuwsng38mnjDsRU4GBnDJVG6tbiKoAYQrx6XJMJM+JJf1ngUvXPU34ZQdkREx +bUQLTJjALlx99omngydFMR3nBDyJxr3PQGOiDlMKy5DFK0Z18Fj0AWzTVk9T+oBCcJI EO+qeoViIWRemyngWva8IqI9ue9kiv66cJyu2J38TjcnpAXLjoG831zMn13LnDj7euc2 y8AQ== X-Forwarded-Encrypted: i=1; AJvYcCX73Mg6mUxQT3X6zbtHjcpDGQE7PWWICBB9MfW2cfY8iYGQ3k0NwKqNPcPZJ9nYFi3Px+v/rrlrV3wKl8x5@vger.kernel.org X-Gm-Message-State: AOJu0YyLlaYiOwtAM1PV5XHmdkz6kAE8/ILByJJC2UVvzI2FoaZ5Pe7I v+LFLKo8UKSeGW1Ku2VJvm5+82c0lwFcxr0hT/lDZGsTV2Au45vwL0mbNBHFNw== X-Gm-Gg: ASbGncvUFF65huU3HHEcI5MM3nE0ELyfnLuVvrWZyjpBtEnsW1CDMlh43yVgRVOItR9 ZE/Q4DRTPRswa+2J3AO1r40ALE0L9KsdoKrQ5mbuN3calYsYFb3YsP9KNpFBgCwSmibvxkd40/t 78DYcG+DonTA+rLp/7rAS0KplBJzvcfPyWG5JhaNEAe4v3ikzJtCGYXbUSk9nhRLOHggUnXgDPK UR+vgH7lI4MallRpdgdgOY3nHg1XzNYIpBGItQEQzFYXfWSzokes4sS+MZiefgXOYNcHbXKt19X 1aqzMYBNvzyfVZinlYYBkzKWnSt47dnOoyHl X-Google-Smtp-Source: AGHT+IHv1oIpl6WcfgN36jKDKAWdHfzzIkAbnj9H7EHr8HHbAWlAP6Mwo+/BVH3tIZ5MTc2nhgENBw== X-Received: by 2002:a05:620a:468f:b0:7b6:d050:720f with SMTP id af79cd13be357-7b9ba79ae8bmr10079146685a.22.1736170814275; Mon, 06 Jan 2025 05:40:14 -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-7b9ac478d35sm1501861085a.90.2025.01.06.05.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 05:40:13 -0800 (PST) From: Ricardo Ribalda Date: Mon, 06 Jan 2025 13:40:12 +0000 Subject: [PATCH v4 6/6] media: venus: vdec: Make the range of us_per_frame explicit Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250106-fix-cocci-v4-6-3c8eb97995ba@chromium.org> References: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> In-Reply-To: <20250106-fix-cocci-v4-0-3c8eb97995ba@chromium.org> To: Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Hans Verkuil , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , 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 by cocci: drivers/media/platform/qcom/venus/vdec.c:488: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/vdec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 6b8906ced6bc..88f6b5a3a4fe 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -464,7 +464,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) struct venus_inst *inst = to_inst(file); struct v4l2_captureparm *cap = &a->parm.capture; struct v4l2_fract *timeperframe = &cap->timeperframe; - u64 us_per_frame, fps; + u64 us_per_frame; if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -486,10 +486,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) if (!us_per_frame || us_per_frame > USEC_PER_SEC) return -EINVAL; - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); - - inst->fps = fps; + inst->fps = USEC_PER_SEC / (u32)us_per_frame; timeperframe->numerator = 1; timeperframe->denominator = inst->fps;