linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/26] media: Fix coccinelle warning/errors
@ 2024-04-29 15:04 Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources Ricardo Ribalda
                   ` (25 more replies)
  0 siblings, 26 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda, Sergey Senozhatsky,
	Kieran Bingham, Dan Carpenter

After this set is applied, these are the only warnings left:
drivers/media/pci/ivtv/ivtv-fileops.c:223:4-10: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:230:3-9: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:236:4-10: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:245:3-9: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:251:3-9: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:257:3-9: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:272:3-9: preceding lock on line 267
drivers/media/pci/ivtv/ivtv-fileops.c:598:4-10: preceding lock on line 627
drivers/media/pci/ivtv/ivtv-fileops.c:598:4-10: preceding lock on line 689
drivers/media/pci/ivtv/ivtv-fileops.c:606:3-9: preceding lock on line 627
drivers/media/pci/ivtv/ivtv-fileops.c:606:3-9: preceding lock on line 689
drivers/media/pci/ivtv/ivtv-fileops.c:648:3-9: preceding lock on line 627
drivers/media/pci/ivtv/ivtv-fileops.c:648:3-9: preceding lock on line 689
drivers/media/pci/ivtv/ivtv-fileops.c:692:4-10: preceding lock on line 689
drivers/media/dvb-core/dvb_frontend.c:2897:1-7: preceding lock on line 2776
drivers/media/dvb-core/dvb_frontend.c:2897:1-7: preceding lock on line 2786
drivers/media/dvb-core/dvb_frontend.c:2897:1-7: preceding lock on line 2809
drivers/media/dvb-frontends/stv090x.c:799:1-7: preceding lock on line 768
drivers/media/usb/go7007/go7007-i2c.c:125:1-7: preceding lock on line 61
drivers/media/rc/imon.c:1167:1-7: preceding lock on line 1153
drivers/media/pci/cx18/cx18-scb.h:261:22-29: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:77:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:85:5-16: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:154:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:171:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:180:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:189:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:201:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:220:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:230:5-16: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:764:5-15: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1008:43-60: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1014:36-46: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1041:5-15: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1088:39-51: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1093:5-22: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1144:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1239:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1267:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1272:4-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/common/siano/smscoreapi.h:619:5-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/common/siano/smscoreapi.h:669:6-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/common/siano/smscoreapi.h:1049:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/common/siano/smscoreapi.h:1055:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/dvb-frontends/mxl5xx_defs.h:171:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/dvb-frontends/mxl5xx_defs.h:182:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/allegro-dvt/nal-hevc.h:102:14-22: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/xilinx/xilinx-dma.h:100:19-22: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/staging/media/atomisp/pci/atomisp_tpg.h:30:18-22: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

CI tested:
https://gitlab.freedesktop.org/linux-media/media-staging/-/commit/055b5211c68e721c3a7090be5373cf44859da1a7/pipelines?ref=ribalda%2Ftest-cocci

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Changes in v3: Thanks Bryan, Dan, Markus, Sakary and Hans
- Improve commit messages.
- Use div64_u64 when possible
- Link to v2: https://lore.kernel.org/r/20240419-fix-cocci-v2-0-2119e692309c@chromium.org

Changes in v2:
- Remove all the min() retval, and send a patch for cocci:  https://lore.kernel.org/lkml/20240415-minimax-v1-1-5feb20d66a79@chromium.org/T/#u
- platform_get_irq() cannot return 0, fix that (Thanks Dan).
- Fix stb0800 patch. chip_id can be 0 (Thanks Dan).
- Use runtime (IS_ENABLED), code looks nicer. (Thanks Dan).
- Do not replace do_div for venus (Thanks Dan).
- Do not replace do_div for tda10048 (Thanks Dan).
- Link to v1: https://lore.kernel.org/r/20240415-fix-cocci-v1-0-477afb23728b@chromium.org

---
Ricardo Ribalda (26):
      media: pci: mgb4: Refactor struct resources
      media: stb0899: Simplify check
      media: uvcvideo: Refactor iterators
      media: uvcvideo: Use max() macro
      media: go7007: Use min and max macros
      media: stm32-dcmipp: Remove redundant printk
      media: staging: sun6i-isp: Remove redundant printk
      media: dvb-frontends: tda18271c2dd: Remove casting during div
      media: v4l: async: refactor v4l2_async_create_ancillary_links
      staging: media: tegra-video: Use swap macro
      media: s2255: Use refcount_t instead of atomic_t for num_channels
      media: platform: mtk-mdp3: Use refcount_t for job_count
      media: common: saa7146: Use min macro
      media: dvb-frontends: drx39xyj: Use min macro
      media: netup_unidvb: Use min macro
      media: au0828: Use umin macro
      media: flexcop-usb: Use min macro
      media: gspca: cpia1: Use min macro
      media: stk1160: Use min macro
      media: tegra-vde: Refactor timeout handling
      media: i2c: st-mipid02: Use the correct div function
      media: tc358746: Use the correct div_ function
      media: venus: vdec: Make the range of us_per_frame explicit
      media: venus: venc: Make the range of us_per_frame explicit
      media: dvb-frontends: tda10048: Fix integer overflow
      media: dvb-frontends: tda10048: Make the range of z explicit.

 drivers/media/common/saa7146/saa7146_hlp.c         |  8 +++----
 drivers/media/dvb-frontends/drx39xyj/drxj.c        |  9 +++-----
 drivers/media/dvb-frontends/stb0899_drv.c          |  2 +-
 drivers/media/dvb-frontends/tda10048.c             | 13 +++++++----
 drivers/media/dvb-frontends/tda18271c2dd.c         |  4 ++--
 drivers/media/i2c/st-mipid02.c                     |  2 +-
 drivers/media/i2c/tc358746.c                       |  3 +--
 drivers/media/pci/mgb4/mgb4_core.c                 |  4 ++--
 drivers/media/pci/mgb4/mgb4_regs.c                 |  2 +-
 drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c  |  2 +-
 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   | 10 ++++-----
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.c   |  6 ++---
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   |  2 +-
 .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c    |  6 ++---
 drivers/media/platform/nvidia/tegra-vde/h264.c     |  6 ++---
 drivers/media/platform/qcom/venus/vdec.c           |  7 ++----
 drivers/media/platform/qcom/venus/venc.c           |  7 ++----
 .../platform/st/stm32/stm32-dcmipp/dcmipp-core.c   |  7 ++----
 drivers/media/usb/au0828/au0828-video.c            |  5 +----
 drivers/media/usb/b2c2/flexcop-usb.c               |  5 +----
 drivers/media/usb/go7007/go7007-fw.c               |  4 ++--
 drivers/media/usb/gspca/cpia1.c                    |  6 ++---
 drivers/media/usb/s2255/s2255drv.c                 | 20 ++++++++---------
 drivers/media/usb/stk1160/stk1160-video.c          | 10 ++-------
 drivers/media/usb/uvc/uvc_ctrl.c                   | 26 ++++++++++++----------
 drivers/media/v4l2-core/v4l2-async.c               |  7 +++---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c  |  3 +--
 drivers/staging/media/tegra-video/tegra20.c        |  9 ++------
 28 files changed, 84 insertions(+), 111 deletions(-)
---
base-commit: cefc10d0d9164eb2f62e789b69dc658dc851eb58
change-id: 20240415-fix-cocci-2df3ef22a6f7

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 02/26] media: stb0899: Simplify check Ricardo Ribalda
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

The struct resource end field signifies the end address not the
relative offset from the start field i.e size == (end - start) + 1.

Amend the .end field to specify the end address not the relative size
from the offset as is currently given.

Fixes cocci check:
drivers/media/pci/mgb4/mgb4_regs.c:13:22-25: WARNING: Suspicious code. resource_size is maybe missing with res

Reviewed-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/pci/mgb4/mgb4_core.c | 4 ++--
 drivers/media/pci/mgb4/mgb4_regs.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/mgb4/mgb4_core.c b/drivers/media/pci/mgb4/mgb4_core.c
index 9bcf10a77fd3..60498a5abebf 100644
--- a/drivers/media/pci/mgb4/mgb4_core.c
+++ b/drivers/media/pci/mgb4/mgb4_core.c
@@ -493,13 +493,13 @@ static int mgb4_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct mgb4_dev *mgbdev;
 	struct resource video = {
 		.start	= 0x0,
-		.end	= 0x100,
+		.end	= 0xff,
 		.flags	= IORESOURCE_MEM,
 		.name	= "mgb4-video",
 	};
 	struct resource cmt = {
 		.start	= 0x1000,
-		.end	= 0x1800,
+		.end	= 0x17ff,
 		.flags	= IORESOURCE_MEM,
 		.name	= "mgb4-cmt",
 	};
diff --git a/drivers/media/pci/mgb4/mgb4_regs.c b/drivers/media/pci/mgb4/mgb4_regs.c
index 53d4e4503a74..31befd722d72 100644
--- a/drivers/media/pci/mgb4/mgb4_regs.c
+++ b/drivers/media/pci/mgb4/mgb4_regs.c
@@ -10,7 +10,7 @@
 int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs)
 {
 	regs->mapbase = res->start;
-	regs->mapsize = res->end - res->start;
+	regs->mapsize = resource_size(res);
 
 	if (!request_mem_region(regs->mapbase, regs->mapsize, res->name))
 		return -EINVAL;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 02/26] media: stb0899: Simplify check
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 03/26] media: uvcvideo: Refactor iterators Ricardo Ribalda
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

chip_id is an unsigned number, it can never be < 0

Fixes cocci check:
drivers/media/dvb-frontends/stb0899_drv.c:1280:8-15: WARNING: Unsigned expression compared with zero: chip_id > 0

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/dvb-frontends/stb0899_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c
index 2f4d8fb400cd..35634f9a8ab5 100644
--- a/drivers/media/dvb-frontends/stb0899_drv.c
+++ b/drivers/media/dvb-frontends/stb0899_drv.c
@@ -1277,7 +1277,7 @@ static int stb0899_get_dev_id(struct stb0899_state *state)
 	dprintk(state->verbose, FE_ERROR, 1, "Demodulator Core ID=[%s], Version=[%d]", (char *) &demod_str, demod_ver);
 	CONVERT32(STB0899_READ_S2REG(STB0899_S2FEC, FEC_CORE_ID_REG), (char *)&fec_str);
 	fec_ver = STB0899_READ_S2REG(STB0899_S2FEC, FEC_VER_ID_REG);
-	if (! (chip_id > 0)) {
+	if (!chip_id) {
 		dprintk(state->verbose, FE_ERROR, 1, "couldn't find a STB 0899");
 
 		return -ENODEV;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 03/26] media: uvcvideo: Refactor iterators
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 02/26] media: stb0899: Simplify check Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 04/26] media: uvcvideo: Use max() macro Ricardo Ribalda
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda, Sergey Senozhatsky

Avoid using the iterators after the list_for_each() constructs.
This patch should be a NOP, but makes cocci, happier:

drivers/media/usb/uvc/uvc_ctrl.c:1861:44-50: ERROR: invalid reference to the index variable of the iterator on line 1850
drivers/media/usb/uvc/uvc_ctrl.c:2195:17-23: ERROR: invalid reference to the index variable of the iterator on line 2179

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index e59a463c2761..a4a987913430 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1850,16 +1850,18 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
 	list_for_each_entry(entity, &chain->entities, chain) {
 		ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
 					     &err_ctrl);
-		if (ret < 0)
+		if (ret < 0) {
+			if (ctrls)
+				ctrls->error_idx =
+					uvc_ctrl_find_ctrl_idx(entity, ctrls,
+							       err_ctrl);
 			goto done;
+		}
 	}
 
 	if (!rollback)
 		uvc_ctrl_send_events(handle, ctrls->controls, ctrls->count);
 done:
-	if (ret < 0 && ctrls)
-		ctrls->error_idx = uvc_ctrl_find_ctrl_idx(entity, ctrls,
-							  err_ctrl);
 	mutex_unlock(&chain->ctrl_mutex);
 	return ret;
 }
@@ -2165,7 +2167,7 @@ static int uvc_ctrl_init_xu_ctrl(struct uvc_device *dev,
 int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
 	struct uvc_xu_control_query *xqry)
 {
-	struct uvc_entity *entity;
+	struct uvc_entity *entity, *iter;
 	struct uvc_control *ctrl;
 	unsigned int i;
 	bool found;
@@ -2175,16 +2177,16 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
 	int ret;
 
 	/* Find the extension unit. */
-	found = false;
-	list_for_each_entry(entity, &chain->entities, chain) {
-		if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT &&
-		    entity->id == xqry->unit) {
-			found = true;
+	entity = NULL;
+	list_for_each_entry(iter, &chain->entities, chain) {
+		if (UVC_ENTITY_TYPE(iter) == UVC_VC_EXTENSION_UNIT &&
+		    iter->id == xqry->unit) {
+			entity = iter;
 			break;
 		}
 	}
 
-	if (!found) {
+	if (!entity) {
 		uvc_dbg(chain->dev, CONTROL, "Extension unit %u not found\n",
 			xqry->unit);
 		return -ENOENT;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 04/26] media: uvcvideo: Use max() macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (2 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 03/26] media: uvcvideo: Refactor iterators Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 05/26] media: go7007: Use min and max macros Ricardo Ribalda
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda, Sergey Senozhatsky,
	Kieran Bingham

It makes the code slightly more clear and makes cocci incredibly happy:

drivers/media/usb/uvc/uvc_ctrl.c:839:22-23: WARNING opportunity for max()

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index a4a987913430..4b685f883e4d 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -836,7 +836,7 @@ static s32 uvc_get_le_value(struct uvc_control_mapping *mapping,
 	while (1) {
 		u8 byte = *data & mask;
 		value |= offset > 0 ? (byte >> offset) : (byte << (-offset));
-		bits -= 8 - (offset > 0 ? offset : 0);
+		bits -= 8 - max(offset, 0);
 		if (bits <= 0)
 			break;
 

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 05/26] media: go7007: Use min and max macros
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (3 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 04/26] media: uvcvideo: Use max() macro Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 06/26] media: stm32-dcmipp: Remove redundant printk Ricardo Ribalda
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Replace ternary inline selection of f1 and f2 min max values with min()
and max() helper functions for the sake of readability and to make
coccinelle happier

drivers/media/usb/go7007/go7007-fw.c:1292:14-15: WARNING opportunity for max()
drivers/media/usb/go7007/go7007-fw.c:1293:14-15: WARNING opportunity for min()

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/go7007/go7007-fw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c
index 018019ba47d4..86ce593e0c54 100644
--- a/drivers/media/usb/go7007/go7007-fw.c
+++ b/drivers/media/usb/go7007/go7007-fw.c
@@ -1289,8 +1289,8 @@ static int avsync_to_package(struct go7007 *go, __le16 *code, int space)
 		0xbf99,		(u16)((-adjratio) >> 16),
 		0xbf92,		0,
 		0xbf93,		0,
-		0xbff4,		f1 > f2 ? f1 : f2,
-		0xbff5,		f1 < f2 ? f1 : f2,
+		0xbff4,		max(f1, f2),
+		0xbff5,		min(f1, f2),
 		0xbff6,		f1 < f2 ? ratio : ratio + 1,
 		0xbff7,		f1 > f2 ? ratio : ratio + 1,
 		0xbff8,		0,

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 06/26] media: stm32-dcmipp: Remove redundant printk
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (4 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 05/26] media: go7007: Use min and max macros Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 07/26] media: staging: sun6i-isp: " Ricardo Ribalda
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

platform_get_irq() already prints an error message.

Also platform_get_irq() can never return 0, so lets fix the condition
now that we are at it.

Found by cocci:
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c:444:3-10: line 444 is redundant because platform_get_irq() already prints an error

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
index bce821eb71ce..4acc3b90d03a 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
@@ -439,11 +439,8 @@ static int dcmipp_probe(struct platform_device *pdev)
 				     "Could not get reset control\n");
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq <= 0) {
-		if (irq != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Could not get irq\n");
-		return irq ? irq : -ENXIO;
-	}
+	if (irq < 0)
+		return irq;
 
 	dcmipp->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
 	if (IS_ERR(dcmipp->regs)) {

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 07/26] media: staging: sun6i-isp: Remove redundant printk
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (5 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 06/26] media: stm32-dcmipp: Remove redundant printk Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div Ricardo Ribalda
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

platform_get_irq() already prints an error for us.

Found by cocci:
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c:389:2-9: line 389 is redundant because platform_get_irq() already prints an error

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c
index 5c0a45394cba..58f8ae92320d 100644
--- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c
+++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c
@@ -386,8 +386,7 @@ static int sun6i_isp_resources_setup(struct sun6i_isp_device *isp_dev,
 
 	irq = platform_get_irq(platform_dev, 0);
 	if (irq < 0) {
-		dev_err(dev, "failed to get interrupt\n");
-		ret = -ENXIO;
+		ret = irq;
 		goto error_clock_rate_exclusive;
 	}
 

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (6 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 07/26] media: staging: sun6i-isp: " Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links Ricardo Ribalda
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

do_div() divides 64 bits by 32. We were adding a casting to the divider
to 64 bits, for a number that fits perfectly in 32 bits. Remove it.

Found by cocci:
drivers/media/dvb-frontends/tda18271c2dd.c:355:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
drivers/media/dvb-frontends/tda18271c2dd.c:331:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/dvb-frontends/tda18271c2dd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
index a34834487943..fd928787207e 100644
--- a/drivers/media/dvb-frontends/tda18271c2dd.c
+++ b/drivers/media/dvb-frontends/tda18271c2dd.c
@@ -328,7 +328,7 @@ static int CalcMainPLL(struct tda_state *state, u32 freq)
 
 	OscFreq = (u64) freq * (u64) Div;
 	OscFreq *= (u64) 16384;
-	do_div(OscFreq, (u64)16000000);
+	do_div(OscFreq, 16000000);
 	MainDiv = OscFreq;
 
 	state->m_Regs[MPD] = PostDiv & 0x77;
@@ -352,7 +352,7 @@ static int CalcCalPLL(struct tda_state *state, u32 freq)
 	OscFreq = (u64)freq * (u64)Div;
 	/* CalDiv = u32( OscFreq * 16384 / 16000000 ); */
 	OscFreq *= (u64)16384;
-	do_div(OscFreq, (u64)16000000);
+	do_div(OscFreq, 16000000);
 	CalDiv = OscFreq;
 
 	state->m_Regs[CPD] = PostDiv;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (7 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 10/26] staging: media: tegra-video: Use swap macro Ricardo Ribalda
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Return 0 without checking IS_ERR or PTR_ERR if CONFIG_MEDIA_CONTROLLER
is not enabled.

This makes cocci happier:

drivers/media/v4l2-core/v4l2-async.c:331:23-30: ERROR: PTR_ERR applied after initialization to constant on line 319

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/v4l2-core/v4l2-async.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 3a22da443a22..421b2b96bc8a 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -316,9 +316,10 @@ v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier);
 static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n,
 					     struct v4l2_subdev *sd)
 {
-	struct media_link *link = NULL;
+	struct media_link *link;
 
-#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
+	if (!IS_ENABLED(CONFIG_MEDIA_CONTROLLER))
+		return 0;
 
 	if (sd->entity.function != MEDIA_ENT_F_LENS &&
 	    sd->entity.function != MEDIA_ENT_F_FLASH)
@@ -326,8 +327,6 @@ static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n,
 
 	link = media_create_ancillary_link(&n->sd->entity, &sd->entity);
 
-#endif
-
 	return IS_ERR(link) ? PTR_ERR(link) : 0;
 }
 

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 10/26] staging: media: tegra-video: Use swap macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (8 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels Ricardo Ribalda
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Makes the code simpler and cocci happier:

drivers/staging/media/tegra-video/tegra20.c:324:44-45: WARNING opportunity for swap()

Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/staging/media/tegra-video/tegra20.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c
index 630e2ff987a3..7b8f8f810b35 100644
--- a/drivers/staging/media/tegra-video/tegra20.c
+++ b/drivers/staging/media/tegra-video/tegra20.c
@@ -317,13 +317,8 @@ static void tegra20_channel_queue_setup(struct tegra_vi_channel *chan)
 		chan->addr_offset_v = chan->addr_offset_u + stride * height / 4;
 
 		/* For YVU420, we swap the locations of the U and V planes. */
-		if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) {
-			unsigned long temp;
-
-			temp = chan->addr_offset_u;
-			chan->addr_offset_u = chan->addr_offset_v;
-			chan->addr_offset_v = temp;
-		}
+		if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420)
+			swap(chan->addr_offset_u, chan->addr_offset_v);
 
 		chan->start_offset_u = chan->addr_offset_u;
 		chan->start_offset_v = chan->addr_offset_v;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (9 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 10/26] staging: media: tegra-video: Use swap macro Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count Ricardo Ribalda
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Use an API that resembles more the actual use of num_channels.

Found by cocci:
drivers/media/usb/s2255/s2255drv.c:2362:5-24: WARNING: atomic_dec_and_test variation before object free at line 2363.
drivers/media/usb/s2255/s2255drv.c:1557:5-24: WARNING: atomic_dec_and_test variation before object free at line 1558.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/s2255/s2255drv.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 8e1de1e8bd12..a6e450181fd0 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -247,7 +247,7 @@ struct s2255_vc {
 struct s2255_dev {
 	struct s2255_vc         vc[MAX_CHANNELS];
 	struct v4l2_device      v4l2_dev;
-	atomic_t                num_channels;
+	refcount_t		num_channels;
 	int			frames;
 	struct mutex		lock;	/* channels[].vdev.lock */
 	struct mutex		cmdlock; /* protects cmdbuf */
@@ -1550,11 +1550,11 @@ static void s2255_video_device_release(struct video_device *vdev)
 		container_of(vdev, struct s2255_vc, vdev);
 
 	dprintk(dev, 4, "%s, chnls: %d\n", __func__,
-		atomic_read(&dev->num_channels));
+		refcount_read(&dev->num_channels));
 
 	v4l2_ctrl_handler_free(&vc->hdl);
 
-	if (atomic_dec_and_test(&dev->num_channels))
+	if (refcount_dec_and_test(&dev->num_channels))
 		s2255_destroy(dev);
 	return;
 }
@@ -1659,7 +1659,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
 				"failed to register video device!\n");
 			break;
 		}
-		atomic_inc(&dev->num_channels);
+		refcount_inc(&dev->num_channels);
 		v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
 			  video_device_node_name(&vc->vdev));
 
@@ -1667,11 +1667,11 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
 	pr_info("Sensoray 2255 V4L driver Revision: %s\n",
 		S2255_VERSION);
 	/* if no channels registered, return error and probe will fail*/
-	if (atomic_read(&dev->num_channels) == 0) {
+	if (refcount_read(&dev->num_channels) == 0) {
 		v4l2_device_unregister(&dev->v4l2_dev);
 		return ret;
 	}
-	if (atomic_read(&dev->num_channels) != MAX_CHANNELS)
+	if (refcount_read(&dev->num_channels) != MAX_CHANNELS)
 		pr_warn("s2255: Not all channels available.\n");
 	return 0;
 }
@@ -2221,7 +2221,7 @@ static int s2255_probe(struct usb_interface *interface,
 		goto errorFWDATA1;
 	}
 
-	atomic_set(&dev->num_channels, 0);
+	refcount_set(&dev->num_channels, 0);
 	dev->pid = id->idProduct;
 	dev->fw_data = kzalloc(sizeof(struct s2255_fw), GFP_KERNEL);
 	if (!dev->fw_data)
@@ -2341,12 +2341,12 @@ static void s2255_disconnect(struct usb_interface *interface)
 {
 	struct s2255_dev *dev = to_s2255_dev(usb_get_intfdata(interface));
 	int i;
-	int channels = atomic_read(&dev->num_channels);
+	int channels = refcount_read(&dev->num_channels);
 	mutex_lock(&dev->lock);
 	v4l2_device_disconnect(&dev->v4l2_dev);
 	mutex_unlock(&dev->lock);
 	/*see comments in the uvc_driver.c usb disconnect function */
-	atomic_inc(&dev->num_channels);
+	refcount_inc(&dev->num_channels);
 	/* unregister each video device. */
 	for (i = 0; i < channels; i++)
 		video_unregister_device(&dev->vc[i].vdev);
@@ -2359,7 +2359,7 @@ static void s2255_disconnect(struct usb_interface *interface)
 		dev->vc[i].vidstatus_ready = 1;
 		wake_up(&dev->vc[i].wait_vidstatus);
 	}
-	if (atomic_dec_and_test(&dev->num_channels))
+	if (refcount_dec_and_test(&dev->num_channels))
 		s2255_destroy(dev);
 	dev_info(&interface->dev, "%s\n", __func__);
 }

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (10 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 13/26] media: common: saa7146: Use min macro Ricardo Ribalda
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Use an API that resembles more the actual use of job_count.

Found by cocci:
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:527:5-24: WARNING: atomic_dec_and_test variation before object free at line 541.
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:578:6-25: WARNING: atomic_dec_and_test variation before object free at line 581.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 10 +++++-----
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c |  6 +++---
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h |  2 +-
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c  |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 1d64bac34b90..ea2ea119dd2a 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -524,7 +524,7 @@ static void mdp_auto_release_work(struct work_struct *work)
 	mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps,
 			    cmd->num_comps);
 
-	if (atomic_dec_and_test(&mdp->job_count)) {
+	if (refcount_dec_and_test(&mdp->job_count)) {
 		if (cmd->mdp_ctx)
 			mdp_m2m_job_finish(cmd->mdp_ctx);
 
@@ -575,7 +575,7 @@ static void mdp_handle_cmdq_callback(struct mbox_client *cl, void *mssg)
 		mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps,
 				    cmd->num_comps);
 
-		if (atomic_dec_and_test(&mdp->job_count))
+		if (refcount_dec_and_test(&mdp->job_count))
 			wake_up(&mdp->callback_wq);
 
 		mdp_cmdq_pkt_destroy(&cmd->pkt);
@@ -724,9 +724,9 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
 	int i, ret;
 	u8 pp_used = __get_pp_num(param->param->type);
 
-	atomic_set(&mdp->job_count, pp_used);
+	refcount_set(&mdp->job_count, pp_used);
 	if (atomic_read(&mdp->suspended)) {
-		atomic_set(&mdp->job_count, 0);
+		refcount_set(&mdp->job_count, 0);
 		return -ECANCELED;
 	}
 
@@ -764,7 +764,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
 		mdp_comp_clocks_off(&mdp->pdev->dev, cmd[i]->comps,
 				    cmd[i]->num_comps);
 err_cancel_job:
-	atomic_set(&mdp->job_count, 0);
+	refcount_set(&mdp->job_count, 0);
 
 	return ret;
 }
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
index 5209f531ef8d..c1f3bf98120a 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
@@ -380,14 +380,14 @@ static int __maybe_unused mdp_suspend(struct device *dev)
 
 	atomic_set(&mdp->suspended, 1);
 
-	if (atomic_read(&mdp->job_count)) {
+	if (refcount_read(&mdp->job_count)) {
 		ret = wait_event_timeout(mdp->callback_wq,
-					 !atomic_read(&mdp->job_count),
+					 !refcount_read(&mdp->job_count),
 					 2 * HZ);
 		if (ret == 0) {
 			dev_err(dev,
 				"%s:flushed cmdq task incomplete, count=%d\n",
-				__func__, atomic_read(&mdp->job_count));
+				__func__, refcount_read(&mdp->job_count));
 			return -EBUSY;
 		}
 	}
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
index 8c09e984fd01..430251f63754 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
@@ -134,7 +134,7 @@ struct mdp_dev {
 	/* synchronization protect for m2m device operation */
 	struct mutex				m2m_lock;
 	atomic_t				suspended;
-	atomic_t				job_count;
+	refcount_t				job_count;
 };
 
 struct mdp_pipe_info {
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
index 35a8b059bde5..0e69128a3772 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
@@ -104,14 +104,14 @@ static void mdp_m2m_device_run(void *priv)
 	task.cb_data = NULL;
 	task.mdp_ctx = ctx;
 
-	if (atomic_read(&ctx->mdp_dev->job_count)) {
+	if (refcount_read(&ctx->mdp_dev->job_count)) {
 		ret = wait_event_timeout(ctx->mdp_dev->callback_wq,
-					 !atomic_read(&ctx->mdp_dev->job_count),
+					 !refcount_read(&ctx->mdp_dev->job_count),
 					 2 * HZ);
 		if (ret == 0) {
 			dev_err(&ctx->mdp_dev->pdev->dev,
 				"%d jobs not yet done\n",
-				atomic_read(&ctx->mdp_dev->job_count));
+				refcount_read(&ctx->mdp_dev->job_count));
 			goto worker_end;
 		}
 	}

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 13/26] media: common: saa7146: Use min macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (11 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 14/26] media: dvb-frontends: drx39xyj: " Ricardo Ribalda
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Simplifies the code. Found by cocci:

drivers/media/common/saa7146/saa7146_hlp.c:125:36-37: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:154:41-42: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:286:35-36: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:289:35-36: WARNING opportunity for min()

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/common/saa7146/saa7146_hlp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_hlp.c b/drivers/media/common/saa7146/saa7146_hlp.c
index 7569d8cdd4d8..fe3348af543e 100644
--- a/drivers/media/common/saa7146/saa7146_hlp.c
+++ b/drivers/media/common/saa7146/saa7146_hlp.c
@@ -122,7 +122,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev,
 	xacm = 0;
 
 	/* set horizontal filter parameters (CXY = CXUV) */
-	cxy = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].hps_coeff;
+	cxy = hps_h_coeff_tab[min(xpsc - 1, 63)].hps_coeff;
 	cxuv = cxy;
 
 	/* calculate and set horizontal fine scale (xsci) */
@@ -151,7 +151,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev,
 		xacm = 0;
 		/* get best match in the table of attenuations
 		   for horizontal scaling */
-		h_atten = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].weight_sum;
+		h_atten = hps_h_coeff_tab[min(xpsc - 1, 63)].weight_sum;
 
 		for (i = 0; h_attenuation[i] != 0; i++) {
 			if (h_attenuation[i] >= h_atten)
@@ -283,10 +283,10 @@ static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field
 		}
 
 		/* get filter coefficients for cya, cyb from table hps_v_coeff_tab */
-		cya_cyb = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].hps_coeff;
+		cya_cyb = hps_v_coeff_tab[min(yacl, 63)].hps_coeff;
 
 		/* get best match in the table of attenuations for vertical scaling */
-		v_atten = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].weight_sum;
+		v_atten = hps_v_coeff_tab[min(yacl, 63)].weight_sum;
 
 		for (i = 0; v_attenuation[i] != 0; i++) {
 			if (v_attenuation[i] >= v_atten)

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 14/26] media: dvb-frontends: drx39xyj: Use min macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (12 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 13/26] media: common: saa7146: Use min macro Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 15/26] media: netup_unidvb: " Ricardo Ribalda
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Replace ternary assignments with min() to simplify and make the code
more readable.

Found by cocci:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1447:23-24: WARNING opportunity for min()
drivers/media/dvb-frontends/drx39xyj/drxj.c:1662:21-22: WARNING opportunity for min()
drivers/media/dvb-frontends/drx39xyj/drxj.c:1685:24-25: WARNING opportunity for min()

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 1ef53754bc03..6fcaf07e1b82 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -1445,8 +1445,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
 
 	/* Read block from I2C **************************************************** */
 	do {
-		u16 todo = (datasize < DRXDAP_MAX_RCHUNKSIZE ?
-			      datasize : DRXDAP_MAX_RCHUNKSIZE);
+		u16 todo = min(datasize, DRXDAP_MAX_RCHUNKSIZE);
 
 		bufx = 0;
 
@@ -1660,7 +1659,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
 		   Address must be rewritten because HI is reset after data transport and
 		   expects an address.
 		 */
-		todo = (block_size < datasize ? block_size : datasize);
+		todo = min(block_size, datasize);
 		if (todo == 0) {
 			u16 overhead_size_i2c_addr = 0;
 			u16 data_block_size = 0;
@@ -1682,9 +1681,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
 				first_err = st;
 			}
 			bufx = 0;
-			todo =
-			    (data_block_size <
-			     datasize ? data_block_size : datasize);
+			todo = min(data_block_size, datasize);
 		}
 		memcpy(&buf[bufx], data, todo);
 		/* write (address if can do and) data */

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 15/26] media: netup_unidvb: Use min macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (13 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 14/26] media: dvb-frontends: drx39xyj: " Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 16/26] media: au0828: Use umin macro Ricardo Ribalda
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Simplify the code.

Found by cocci:
drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c:138:26-27: WARNING opportunity for min()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c
index 46676f2c89c7..1c885d620b75 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c
@@ -135,7 +135,7 @@ static void netup_i2c_fifo_tx(struct netup_i2c *i2c)
 		(readw(&i2c->regs->tx_fifo.stat_ctrl) & 0x3f);
 	u32 msg_length = i2c->msg->len - i2c->xmit_size;
 
-	msg_length = (msg_length < fifo_space ? msg_length : fifo_space);
+	msg_length = min(msg_length, fifo_space);
 	while (msg_length--) {
 		data = i2c->msg->buf[i2c->xmit_size++];
 		writeb(data, &i2c->regs->tx_fifo.data8);

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 16/26] media: au0828: Use umin macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (14 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 15/26] media: netup_unidvb: " Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 17/26] media: flexcop-usb: Use min macro Ricardo Ribalda
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Simplifies the code.

Found by cocci:
drivers/media/usb/au0828/au0828-video.c:605:11-12: WARNING opportunity for min()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/au0828/au0828-video.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index fd9fc43d47e0..2ec49ea479d5 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -602,10 +602,7 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
 		vbi_field_size = dev->vbi_width * dev->vbi_height * 2;
 		if (dev->vbi_read < vbi_field_size) {
 			remain  = vbi_field_size - dev->vbi_read;
-			if (len < remain)
-				lencopy = len;
-			else
-				lencopy = remain;
+			lencopy = umin(len, remain);
 
 			if (vbi_buf != NULL)
 				au0828_copy_vbi(dev, vbi_dma_q, vbi_buf, p,

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 17/26] media: flexcop-usb: Use min macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (15 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 16/26] media: au0828: Use umin macro Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 18/26] media: gspca: cpia1: " Ricardo Ribalda
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Simplifies the code.

Found by cocci:
drivers/media/usb/b2c2/flexcop-usb.c:201:8-9: WARNING opportunity for min()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/b2c2/flexcop-usb.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
index 43dd3c932a85..90f1aea99dac 100644
--- a/drivers/media/usb/b2c2/flexcop-usb.c
+++ b/drivers/media/usb/b2c2/flexcop-usb.c
@@ -197,10 +197,7 @@ static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb,
 		return -EINVAL;
 	}
 	for (i = 0; i < len;) {
-		pagechunk =
-			wMax < bytes_left_to_read_on_page(addr, len) ?
-				wMax :
-				bytes_left_to_read_on_page(addr, len);
+		pagechunk = min(wMax, bytes_left_to_read_on_page(addr, len));
 		deb_info("%x\n",
 			(addr & V8_MEMORY_PAGE_MASK) |
 				(V8_MEMORY_EXTENDED*extended));

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 18/26] media: gspca: cpia1: Use min macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (16 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 17/26] media: flexcop-usb: Use min macro Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 19/26] media: stk1160: " Ricardo Ribalda
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Simplifies the code.

Found by cocci:
drivers/media/usb/gspca/cpia1.c:607:30-31: WARNING opportunity for min()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/gspca/cpia1.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
index 5f5fa851ca64..14aaf36cde6e 100644
--- a/drivers/media/usb/gspca/cpia1.c
+++ b/drivers/media/usb/gspca/cpia1.c
@@ -604,10 +604,8 @@ static int find_over_exposure(int brightness)
 	MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness -
 				   FLICKER_BRIGHTNESS_CONSTANT;
 
-	if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE)
-		OverExposure = MaxAllowableOverExposure;
-	else
-		OverExposure = FLICKER_ALLOWABLE_OVER_EXPOSURE;
+	OverExposure = min(MaxAllowableOverExposure,
+			   FLICKER_ALLOWABLE_OVER_EXPOSURE);
 
 	return OverExposure;
 }

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 19/26] media: stk1160: Use min macro
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (17 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 18/26] media: gspca: cpia1: " Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:04 ` [PATCH v3 20/26] media: tegra-vde: Refactor timeout handling Ricardo Ribalda
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Instead of a custom min() implementation, use the real macro.

Mitigates the following cocci WARNINGs:
drivers/media/usb/stk1160/stk1160-video.c:133:12-13: WARNING opportunity for min()
drivers/media/usb/stk1160/stk1160-video.c:176:13-14: WARNING opportunity for min()

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/stk1160/stk1160-video.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c
index e79c45db60ab..9cbd957ecc90 100644
--- a/drivers/media/usb/stk1160/stk1160-video.c
+++ b/drivers/media/usb/stk1160/stk1160-video.c
@@ -130,10 +130,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len)
 	dst += linesdone * bytesperline * 2 + lineoff;
 
 	/* Copy the remaining of current line */
-	if (remain < (bytesperline - lineoff))
-		lencopy = remain;
-	else
-		lencopy = bytesperline - lineoff;
+	lencopy = min(remain, bytesperline - lineoff);
 
 	/*
 	 * Check if we have enough space left in the buffer.
@@ -178,10 +175,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len)
 		src += lencopy;
 
 		/* Copy one line at a time */
-		if (remain < bytesperline)
-			lencopy = remain;
-		else
-			lencopy = bytesperline;
+		lencopy = min(remain, bytesperline);
 
 		/*
 		 * Check if we have enough space left in the buffer.

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 20/26] media: tegra-vde: Refactor timeout handling
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (18 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 19/26] media: stk1160: " Ricardo Ribalda
@ 2024-04-29 15:04 ` Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 21/26] media: i2c: st-mipid02: Use the correct div function Ricardo Ribalda
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:04 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Reorder the branches a bit, so cocci stops complaining about the code.

drivers/media/platform/nvidia/tegra-vde/h264.c:645:20-21: WARNING opportunity for min()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/nvidia/tegra-vde/h264.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/nvidia/tegra-vde/h264.c b/drivers/media/platform/nvidia/tegra-vde/h264.c
index 204e474d57f7..cfea5572a1b8 100644
--- a/drivers/media/platform/nvidia/tegra-vde/h264.c
+++ b/drivers/media/platform/nvidia/tegra-vde/h264.c
@@ -633,7 +633,9 @@ static int tegra_vde_decode_end(struct tegra_vde *vde)
 
 	timeout = wait_for_completion_interruptible_timeout(
 			&vde->decode_completion, msecs_to_jiffies(1000));
-	if (timeout == 0) {
+	if (timeout < 0) {
+		ret = timeout;
+	} else if (timeout == 0) {
 		bsev_ptr = tegra_vde_readl(vde, vde->bsev, 0x10);
 		macroblocks_nb = tegra_vde_readl(vde, vde->sxe, 0xC8) & 0x1FFF;
 		read_bytes = bsev_ptr ? bsev_ptr - vde->bitstream_data_addr : 0;
@@ -642,8 +644,6 @@ static int tegra_vde_decode_end(struct tegra_vde *vde)
 			read_bytes, macroblocks_nb);
 
 		ret = -EIO;
-	} else if (timeout < 0) {
-		ret = timeout;
 	} else {
 		ret = 0;
 	}

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 21/26] media: i2c: st-mipid02: Use the correct div function
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (19 preceding siblings ...)
  2024-04-29 15:04 ` [PATCH v3 20/26] media: tegra-vde: Refactor timeout handling Ricardo Ribalda
@ 2024-04-29 15:05 ` Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 22/26] media: tc358746: Use the correct div_ function Ricardo Ribalda
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:05 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

link_freq does not fit in 32 bits.

Found by cocci:
drivers/media/i2c/st-mipid02.c:329:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_s64 instead.

Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/i2c/st-mipid02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
index f250640729ca..b947a55281f0 100644
--- a/drivers/media/i2c/st-mipid02.c
+++ b/drivers/media/i2c/st-mipid02.c
@@ -326,7 +326,7 @@ static int mipid02_configure_from_rx_speed(struct mipid02_dev *bridge,
 	}
 
 	dev_dbg(&client->dev, "detect link_freq = %lld Hz", link_freq);
-	do_div(ui_4, link_freq);
+	ui_4 = div64_u64(ui_4, link_freq);
 	bridge->r.clk_lane_reg1 |= ui_4 << 2;
 
 	return 0;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 22/26] media: tc358746: Use the correct div_ function
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (20 preceding siblings ...)
  2024-04-29 15:05 ` [PATCH v3 21/26] media: i2c: st-mipid02: Use the correct div function Ricardo Ribalda
@ 2024-04-29 15:05 ` Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit Ricardo Ribalda
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:05 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

fin does not fit in 32 bits in some arches.

Found by cocci:
drivers/media/i2c/tc358746.c:847:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/i2c/tc358746.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c
index d676adc4401b..edf79107adc5 100644
--- a/drivers/media/i2c/tc358746.c
+++ b/drivers/media/i2c/tc358746.c
@@ -844,8 +844,7 @@ static unsigned long tc358746_find_pll_settings(struct tc358746 *tc358746,
 			continue;
 
 		tmp = fout * postdiv;
-		do_div(tmp, fin);
-		mul = tmp;
+		mul = div64_ul(tmp, fin);
 		if (mul > 511)
 			continue;
 

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (21 preceding siblings ...)
  2024-04-29 15:05 ` [PATCH v3 22/26] media: tc358746: Use the correct div_ function Ricardo Ribalda
@ 2024-04-29 15:05 ` Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 24/26] media: venus: venc: " Ricardo Ribalda
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:05 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit
number. Make that explicit.

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 <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 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 29130a9441e7..2b2874aedb2d 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)
@@ -484,10 +484,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
 	if (!us_per_frame)
 		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;
 	inst->timeperframe = *timeperframe;
 
 	return 0;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 24/26] media: venus: venc: Make the range of us_per_frame explicit
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (22 preceding siblings ...)
  2024-04-29 15:05 ` [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit Ricardo Ribalda
@ 2024-04-29 15:05 ` Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit Ricardo Ribalda
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:05 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit
number. Make that explicit.

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 <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/qcom/venus/venc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 3ec2fb8d9fab..f87e33a34610 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -393,7 +393,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
 	struct venus_inst *inst = to_inst(file);
 	struct v4l2_outputparm *out = &a->parm.output;
 	struct v4l2_fract *timeperframe = &out->timeperframe;
-	u64 us_per_frame, fps;
+	u64 us_per_frame;
 
 	if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
 	    a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -414,11 +414,8 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
 	if (!us_per_frame)
 		return -EINVAL;
 
-	fps = (u64)USEC_PER_SEC;
-	do_div(fps, us_per_frame);
-
+	inst->fps = USEC_PER_SEC / (u32)us_per_frame;
 	inst->timeperframe = *timeperframe;
-	inst->fps = fps;
 
 	return 0;
 }

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (23 preceding siblings ...)
  2024-04-29 15:05 ` [PATCH v3 24/26] media: venus: venc: " Ricardo Ribalda
@ 2024-04-29 15:05 ` Ricardo Ribalda
  2024-04-29 15:05 ` [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit Ricardo Ribalda
  25 siblings, 0 replies; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:05 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda, Dan Carpenter

state->xtal_hz can be up to 16M, so it can overflow a 32 bit integer
when multiplied by pll_mfactor.

Create a new 64 bit variable to hold the calculations.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/dvb-frontends/tda10048.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c
index 5d5e4e9e4422..3e725cdcc66b 100644
--- a/drivers/media/dvb-frontends/tda10048.c
+++ b/drivers/media/dvb-frontends/tda10048.c
@@ -410,6 +410,7 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw)
 	struct tda10048_config *config = &state->config;
 	int i;
 	u32 if_freq_khz;
+	u64 sample_freq;
 
 	dprintk(1, "%s(bw = %d)\n", __func__, bw);
 
@@ -451,9 +452,11 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw)
 	dprintk(1, "- pll_pfactor = %d\n", state->pll_pfactor);
 
 	/* Calculate the sample frequency */
-	state->sample_freq = state->xtal_hz * (state->pll_mfactor + 45);
-	state->sample_freq /= (state->pll_nfactor + 1);
-	state->sample_freq /= (state->pll_pfactor + 4);
+	sample_freq = state->xtal_hz;
+	sample_freq *= state->pll_mfactor + 45;
+	do_div(sample_freq, state->pll_nfactor + 1);
+	do_div(sample_freq, state->pll_pfactor + 4);
+	state->sample_freq = sample_freq;
 	dprintk(1, "- sample_freq = %d\n", state->sample_freq);
 
 	/* Update the I/F */

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
                   ` (24 preceding siblings ...)
  2024-04-29 15:05 ` [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow Ricardo Ribalda
@ 2024-04-29 15:05 ` Ricardo Ribalda
  2024-05-03 10:27   ` Mauro Carvalho Chehab
  25 siblings, 1 reply; 33+ messages in thread
From: Ricardo Ribalda @ 2024-04-29 15:05 UTC (permalink / raw)
  To: Martin Tuma, Mauro Carvalho Chehab, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio
  Cc: linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm, Ricardo Ribalda

We do not expect the sample_freq to be over 613MHz.

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 <ribalda@chromium.org>
---
 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;

-- 
2.44.0.769.g3c40516874-goog


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-04-29 15:05 ` [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit Ricardo Ribalda
@ 2024-05-03 10:27   ` Mauro Carvalho Chehab
  2024-05-03 11:55     ` Dan Carpenter
  0 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2024-05-03 10:27 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Martin Tuma, Laurent Pinchart, Hugues Fruchet, Alain Volmat,
	Maxime Coquelin, Alexandre Torgue, Paul Kocialkowski,
	Greg Kroah-Hartman, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	Sakari Ailus, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli, Matthias Brugger,
	AngeloGioacchino Del Regno, Hans Verkuil, Sergey Kozlov,
	Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko, Benjamin Mugnier,
	Sylvain Petinot, Stanimir Varbanov, Vikash Garodia,
	Bryan O'Donoghue, Bjorn Andersson, Konrad Dybcio,
	linux-media, linux-kernel, linux-stm32, linux-arm-kernel,
	linux-staging, linux-sunxi, linux-tegra, linux-mediatek,
	linux-arm-msm

Em Mon, 29 Apr 2024 15:05:05 +0000
Ricardo Ribalda <ribalda@chromium.org> escreveu:

> We do not expect the sample_freq to be over 613MHz.
> 
> 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 <ribalda@chromium.org>
> ---
>  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 */

Are you sure about that? Some DVB devices have very high frequency 
clocks, specially if they're also used for satellite, so I can't
be sure by just looking at the driver's code.

Also, we had already a bunch of regressions with "fixes" like this
that actually broke frontend drivers.

If you're sure, please add a note at the description mentioning 
on what part of the datasheet you got it.

Otherwise, let's stick with the current code and address cocci
warning on a different way.

Regards,
Mauro

PS.: I partially applied this patch series. I left a few
patches out of the merge to let other people review/comment
(and/or for me to take a deeper look later on).

Regards,
Mauro

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-05-03 10:27   ` Mauro Carvalho Chehab
@ 2024-05-03 11:55     ` Dan Carpenter
  2024-05-03 11:56       ` Ricardo Ribalda
  0 siblings, 1 reply; 33+ messages in thread
From: Dan Carpenter @ 2024-05-03 11:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Ricardo Ribalda, Martin Tuma, Laurent Pinchart, Hugues Fruchet,
	Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, linux-media, linux-kernel, linux-stm32,
	linux-arm-kernel, linux-staging, linux-sunxi, linux-tegra,
	linux-mediatek, linux-arm-msm

On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote:
> Em Mon, 29 Apr 2024 15:05:05 +0000
> Ricardo Ribalda <ribalda@chromium.org> escreveu:
> 
> > We do not expect the sample_freq to be over 613MHz.
> > 
> > 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 <ribalda@chromium.org>
> > ---
> >  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 */
> 
> Are you sure about that? Some DVB devices have very high frequency 
> clocks, specially if they're also used for satellite, so I can't
> be sure by just looking at the driver's code.
> 
> Also, we had already a bunch of regressions with "fixes" like this
> that actually broke frontend drivers.

This patch preserves the existing behavior. The sample_freq_hz variable
is a u32 so, in the original code, z couldn't have been more than
U32_MAX even though it was declared as a u64.

It's possible that the original code was wrong.  We have seen that in
other places in this patchset.  Adding a note about the datasheet is
also a good idea.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-05-03 11:55     ` Dan Carpenter
@ 2024-05-03 11:56       ` Ricardo Ribalda
  2024-05-03 14:08         ` Dragan Simic
  0 siblings, 1 reply; 33+ messages in thread
From: Ricardo Ribalda @ 2024-05-03 11:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mauro Carvalho Chehab, Martin Tuma, Laurent Pinchart,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Sakari Ailus, Thierry Reding,
	Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Sergey Kozlov, Abylay Ospan, Ezequiel Garcia, Dmitry Osipenko,
	Benjamin Mugnier, Sylvain Petinot, Stanimir Varbanov,
	Vikash Garodia, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, linux-media, linux-kernel, linux-stm32,
	linux-arm-kernel, linux-staging, linux-sunxi, linux-tegra,
	linux-mediatek, linux-arm-msm

I am trying to get the DS, but
https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a
dead links now.

Anyone have access to the datasheet?

Thanks!

On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote:
> > Em Mon, 29 Apr 2024 15:05:05 +0000
> > Ricardo Ribalda <ribalda@chromium.org> escreveu:
> >
> > > We do not expect the sample_freq to be over 613MHz.
> > >
> > > 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 <ribalda@chromium.org>
> > > ---
> > >  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 */
> >
> > Are you sure about that? Some DVB devices have very high frequency
> > clocks, specially if they're also used for satellite, so I can't
> > be sure by just looking at the driver's code.
> >
> > Also, we had already a bunch of regressions with "fixes" like this
> > that actually broke frontend drivers.
>
> This patch preserves the existing behavior. The sample_freq_hz variable
> is a u32 so, in the original code, z couldn't have been more than
> U32_MAX even though it was declared as a u64.
>
> It's possible that the original code was wrong.  We have seen that in
> other places in this patchset.  Adding a note about the datasheet is
> also a good idea.
>
> regards,
> dan carpenter
>


-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-05-03 11:56       ` Ricardo Ribalda
@ 2024-05-03 14:08         ` Dragan Simic
  2024-05-13 13:35           ` Ricardo Ribalda
  0 siblings, 1 reply; 33+ messages in thread
From: Dragan Simic @ 2024-05-03 14:08 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Dan Carpenter, Mauro Carvalho Chehab, Martin Tuma,
	Laurent Pinchart, Hugues Fruchet, Alain Volmat, Maxime Coquelin,
	Alexandre Torgue, Paul Kocialkowski, Greg Kroah-Hartman,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Sakari Ailus,
	Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Luca Ceresoli, Matthias Brugger, AngeloGioacchino Del Regno,
	Hans Verkuil, Sergey Kozlov, Abylay Ospan, Ezequiel Garcia,
	Dmitry Osipenko, Benjamin Mugnier, Sylvain Petinot,
	Stanimir Varbanov, Vikash Garodia, Bryan O'Donoghue,
	Bjorn Andersson, Konrad Dybcio, linux-media, linux-kernel,
	linux-stm32, linux-arm-kernel, linux-staging, linux-sunxi,
	linux-tegra, linux-mediatek, linux-arm-msm

Hello Ricardo,

On 2024-05-03 13:56, Ricardo Ribalda wrote:
> I am trying to get the DS, but
> https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a
> dead links now.
> 
> Anyone have access to the datasheet?

It's kind of available on the link below, but for some strange reason
the download fails after downloading the first 128 KB or so.

https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf


> On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> 
> wrote:
>> 
>> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote:
>> > Em Mon, 29 Apr 2024 15:05:05 +0000
>> > Ricardo Ribalda <ribalda@chromium.org> escreveu:
>> >
>> > > We do not expect the sample_freq to be over 613MHz.
>> > >
>> > > 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 <ribalda@chromium.org>
>> > > ---
>> > >  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 */
>> >
>> > Are you sure about that? Some DVB devices have very high frequency
>> > clocks, specially if they're also used for satellite, so I can't
>> > be sure by just looking at the driver's code.
>> >
>> > Also, we had already a bunch of regressions with "fixes" like this
>> > that actually broke frontend drivers.
>> 
>> This patch preserves the existing behavior. The sample_freq_hz 
>> variable
>> is a u32 so, in the original code, z couldn't have been more than
>> U32_MAX even though it was declared as a u64.
>> 
>> It's possible that the original code was wrong.  We have seen that in
>> other places in this patchset.  Adding a note about the datasheet is
>> also a good idea.
>> 
>> regards,
>> dan carpenter
>> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-05-03 14:08         ` Dragan Simic
@ 2024-05-13 13:35           ` Ricardo Ribalda
  2024-05-13 14:25             ` Michael Ira Krufky
  0 siblings, 1 reply; 33+ messages in thread
From: Ricardo Ribalda @ 2024-05-13 13:35 UTC (permalink / raw)
  To: Dragan Simic, Michael Krufky
  Cc: Dan Carpenter, Mauro Carvalho Chehab, Martin Tuma,
	Laurent Pinchart, Hugues Fruchet, Alain Volmat, Maxime Coquelin,
	Alexandre Torgue, Paul Kocialkowski, Greg Kroah-Hartman,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Sakari Ailus,
	Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Luca Ceresoli, Matthias Brugger, AngeloGioacchino Del Regno,
	Hans Verkuil, Sergey Kozlov, Abylay Ospan, Ezequiel Garcia,
	Dmitry Osipenko, Benjamin Mugnier, Sylvain Petinot,
	Stanimir Varbanov, Vikash Garodia, Bryan O'Donoghue,
	Bjorn Andersson, Konrad Dybcio, linux-media, linux-kernel,
	linux-stm32, linux-arm-kernel, linux-staging, linux-sunxi,
	linux-tegra, linux-mediatek, linux-arm-msm

On Fri, 3 May 2024 at 16:08, Dragan Simic <dsimic@manjaro.org> wrote:
>
> Hello Ricardo,
>
> On 2024-05-03 13:56, Ricardo Ribalda wrote:
> > I am trying to get the DS, but
> > https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a
> > dead links now.
> >
> > Anyone have access to the datasheet?
>
> It's kind of available on the link below, but for some strange reason
> the download fails after downloading the first 128 KB or so.
>
> https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf\

Mike, by any chance do you have a copy of the DS?


>
>
> > On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org>
> > wrote:
> >>
> >> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote:
> >> > Em Mon, 29 Apr 2024 15:05:05 +0000
> >> > Ricardo Ribalda <ribalda@chromium.org> escreveu:
> >> >
> >> > > We do not expect the sample_freq to be over 613MHz.
> >> > >
> >> > > 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 <ribalda@chromium.org>
> >> > > ---
> >> > >  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 */
> >> >
> >> > Are you sure about that? Some DVB devices have very high frequency
> >> > clocks, specially if they're also used for satellite, so I can't
> >> > be sure by just looking at the driver's code.
> >> >
> >> > Also, we had already a bunch of regressions with "fixes" like this
> >> > that actually broke frontend drivers.
> >>
> >> This patch preserves the existing behavior. The sample_freq_hz
> >> variable
> >> is a u32 so, in the original code, z couldn't have been more than
> >> U32_MAX even though it was declared as a u64.


I agree with Dan, we keep the existing behaviour. So it wont hurt to
merge the code...

All  that said, if someone has access to the DS, I do not mind reviewing it.


> >>
> >> It's possible that the original code was wrong.  We have seen that in
> >> other places in this patchset.  Adding a note about the datasheet is
> >> also a good idea.
> >>
> >> regards,
> >> dan carpenter
> >>



-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit.
  2024-05-13 13:35           ` Ricardo Ribalda
@ 2024-05-13 14:25             ` Michael Ira Krufky
  0 siblings, 0 replies; 33+ messages in thread
From: Michael Ira Krufky @ 2024-05-13 14:25 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Dragan Simic, Dan Carpenter, Mauro Carvalho Chehab, Martin Tuma,
	Laurent Pinchart, Hugues Fruchet, Alain Volmat, Maxime Coquelin,
	Alexandre Torgue, Paul Kocialkowski, Greg Kroah-Hartman,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Sakari Ailus,
	Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Luca Ceresoli, Matthias Brugger, AngeloGioacchino Del Regno,
	Hans Verkuil, Sergey Kozlov, Abylay Ospan, Ezequiel Garcia,
	Dmitry Osipenko, Benjamin Mugnier, Sylvain Petinot,
	Stanimir Varbanov, Vikash Garodia, Bryan O'Donoghue,
	Bjorn Andersson, Konrad Dybcio, linux-media, linux-kernel,
	linux-stm32, linux-arm-kernel, linux-staging, linux-sunxi,
	linux-tegra, linux-mediatek, linux-arm-msm

On Mon, May 13, 2024 at 9:38 AM Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> On Fri, 3 May 2024 at 16:08, Dragan Simic <dsimic@manjaro.org> wrote:
> >
> > Hello Ricardo,
> >
> > On 2024-05-03 13:56, Ricardo Ribalda wrote:
> > > I am trying to get the DS, but
> > > https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a
> > > dead links now.
> > >
> > > Anyone have access to the datasheet?
> >
> > It's kind of available on the link below, but for some strange reason
> > the download fails after downloading the first 128 KB or so.
> >
> > https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf\
>
> Mike, by any chance do you have a copy of the DS?
>
>
> >
> >
> > > On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org>
> > > wrote:
> > >>
> > >> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote:
> > >> > Em Mon, 29 Apr 2024 15:05:05 +0000
> > >> > Ricardo Ribalda <ribalda@chromium.org> escreveu:
> > >> >
> > >> > > We do not expect the sample_freq to be over 613MHz.
> > >> > >
> > >> > > 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 <ribalda@chromium.org>
> > >> > > ---
> > >> > >  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 */
> > >> >
> > >> > Are you sure about that? Some DVB devices have very high frequency
> > >> > clocks, specially if they're also used for satellite, so I can't
> > >> > be sure by just looking at the driver's code.
> > >> >
> > >> > Also, we had already a bunch of regressions with "fixes" like this
> > >> > that actually broke frontend drivers.
> > >>
> > >> This patch preserves the existing behavior. The sample_freq_hz
> > >> variable
> > >> is a u32 so, in the original code, z couldn't have been more than
> > >> U32_MAX even though it was declared as a u64.
>
>
> I agree with Dan, we keep the existing behaviour. So it wont hurt to
> merge the code...
>
> All  that said, if someone has access to the DS, I do not mind reviewing it.
>
>
> > >>
> > >> It's possible that the original code was wrong.  We have seen that in
> > >> other places in this patchset.  Adding a note about the datasheet is
> > >> also a good idea.
> > >>
> > >> regards,
> > >> dan carpenter
> > >>
>
>
>
> --
> Ricardo Ribalda
>

Nice to hear from you!  :-)

I believe that I may have a copy of it on an old "spinny" hard drive
somewhere in one of the ancient desktop computers I have lining my
basement walls, lol.  It will take me some time to locate it.  I hope
this isn't urgent o:-)

...It so happens that the dev box I used when I worked on that driver
is up right now, but the datasheet isn't in my home directory.  There
are two other drives in the chassis but not connected / powered - I'll
give these a look and let you know if I find anything.

Best,
Michael Krufky

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2024-05-13 14:25 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 02/26] media: stb0899: Simplify check Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 03/26] media: uvcvideo: Refactor iterators Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 04/26] media: uvcvideo: Use max() macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 05/26] media: go7007: Use min and max macros Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 06/26] media: stm32-dcmipp: Remove redundant printk Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 07/26] media: staging: sun6i-isp: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 10/26] staging: media: tegra-video: Use swap macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 13/26] media: common: saa7146: Use min macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 14/26] media: dvb-frontends: drx39xyj: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 15/26] media: netup_unidvb: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 16/26] media: au0828: Use umin macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 17/26] media: flexcop-usb: Use min macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 18/26] media: gspca: cpia1: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 19/26] media: stk1160: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 20/26] media: tegra-vde: Refactor timeout handling Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 21/26] media: i2c: st-mipid02: Use the correct div function Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 22/26] media: tc358746: Use the correct div_ function Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 24/26] media: venus: venc: " Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit Ricardo Ribalda
2024-05-03 10:27   ` Mauro Carvalho Chehab
2024-05-03 11:55     ` Dan Carpenter
2024-05-03 11:56       ` Ricardo Ribalda
2024-05-03 14:08         ` Dragan Simic
2024-05-13 13:35           ` Ricardo Ribalda
2024-05-13 14:25             ` Michael Ira Krufky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).