[git:dtv-scan-tables/master] dvb-t/at-All: add Salzburg/Gaisberg dvb-t2 transponders

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: dvb-t/at-All: add Salzburg/Gaisberg dvb-t2 transponders
Author:  Yarny 
Date:Sun Mar 24 10:39:56 2024 +

Adds a missing dvb-t2 transmitting station from Austria.

Link: 
https://lore.kernel.org/linux-media/75149976-693b-444e-b4cc-dd2dd86ea...@public-files.de
Signed-off-by: Mauro Carvalho Chehab 

 dvb-t/at-All | 64 
 1 file changed, 64 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=7098bdd27548eaf3e5d9485fc68575f88e362daf
diff --git a/dvb-t/at-All b/dvb-t/at-All
index b83363d105ac..ace9e36153b5 100644
--- a/dvb-t/at-All
+++ b/dvb-t/at-All
@@ -76,3 +76,67 @@
INVERSION = AUTO
STREAM_ID = 1
 
+[Gaisberg-MUXA-K32]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 56200
+   BANDWIDTH_HZ = 800
+   CODE_RATE_HP = AUTO
+   CODE_RATE_LP = AUTO
+   MODULATION = QAM/AUTO
+   TRANSMISSION_MODE = AUTO
+   GUARD_INTERVAL = AUTO
+   HIERARCHY = AUTO
+   INVERSION = AUTO
+   STREAM_ID = 1
+
+[Gaisberg-MUXB-K29]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 53800
+   BANDWIDTH_HZ = 800
+   CODE_RATE_HP = AUTO
+   CODE_RATE_LP = AUTO
+   MODULATION = QAM/AUTO
+   TRANSMISSION_MODE = AUTO
+   GUARD_INTERVAL = AUTO
+   HIERARCHY = AUTO
+   INVERSION = AUTO
+   STREAM_ID = 1
+
+[Gaisberg-MUXD-K47]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 68200
+   BANDWIDTH_HZ = 800
+   CODE_RATE_HP = AUTO
+   CODE_RATE_LP = AUTO
+   MODULATION = QAM/AUTO
+   TRANSMISSION_MODE = AUTO
+   GUARD_INTERVAL = AUTO
+   HIERARCHY = AUTO
+   INVERSION = AUTO
+   STREAM_ID = 1
+
+[Gaisberg-MUXE-K38]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 61000
+   BANDWIDTH_HZ = 800
+   CODE_RATE_HP = AUTO
+   CODE_RATE_LP = AUTO
+   MODULATION = QAM/AUTO
+   TRANSMISSION_MODE = AUTO
+   GUARD_INTERVAL = AUTO
+   HIERARCHY = AUTO
+   INVERSION = AUTO
+   STREAM_ID = 1
+
+[Gaisberg-MUXF-K42]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 64200
+   BANDWIDTH_HZ = 800
+   CODE_RATE_HP = AUTO
+   CODE_RATE_LP = AUTO
+   MODULATION = QAM/AUTO
+   TRANSMISSION_MODE = AUTO
+   GUARD_INTERVAL = AUTO
+   HIERARCHY = AUTO
+   INVERSION = AUTO
+   STREAM_ID = 1


[git:media_stage/master] media: intel/ipu6: Don't re-allocate memory for firmware

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: intel/ipu6: Don't re-allocate memory for firmware
Author:  Sakari Ailus 
Date:Thu May 2 16:49:50 2024 +0100

The ipu6 driver allocated vmalloc memory for the firmware if
request_firmware() somehow managed not to use vmalloc to allocate it.

Still how the memory is allocated by request_firmware() is not specified
in its API, so be prepared for kmalloc-allocated firmware, too. Instead of
allocating new vmalloc-backed buffer for the firmware, obtain the pages
from virtual addresses instead.

Link: 
https://lore.kernel.org/linux-media/20240502154950.549015-1-sakari.ai...@linux.intel.com
Reported-by: Stephen Rothwell 
Closes: https://lore.kernel.org/all/20240501102236.3b258...@canb.auug.org.au/
Fixes: 25fedc021985 ("media: intel/ipu6: add Intel IPU6 PCI device driver")
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/pci/intel/ipu6/ipu6-buttress.c |  7 -
 drivers/media/pci/intel/ipu6/ipu6.c  | 41 +---
 2 files changed, 7 insertions(+), 41 deletions(-)

---

diff --git a/drivers/media/pci/intel/ipu6/ipu6-buttress.c 
b/drivers/media/pci/intel/ipu6/ipu6-buttress.c
index dbcf1aa87872..23c537e7ce1e 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-buttress.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.c
@@ -552,12 +552,16 @@ int ipu6_buttress_reset_authentication(struct ipu6_device 
*isp)
 int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
   const struct firmware *fw, struct sg_table *sgt)
 {
+   bool is_vmalloc = is_vmalloc_addr(fw->data);
struct page **pages;
const void *addr;
unsigned long n_pages;
unsigned int i;
int ret;
 
+   if (!is_vmalloc && !virt_addr_valid(fw->data))
+   return -EDOM;
+
n_pages = PHYS_PFN(PAGE_ALIGN(fw->size));
 
pages = kmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
@@ -566,7 +570,8 @@ int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
 
addr = fw->data;
for (i = 0; i < n_pages; i++) {
-   struct page *p = vmalloc_to_page(addr);
+   struct page *p = is_vmalloc ?
+   vmalloc_to_page(addr) : virt_to_page(addr);
 
if (!p) {
ret = -ENOMEM;
diff --git a/drivers/media/pci/intel/ipu6/ipu6.c 
b/drivers/media/pci/intel/ipu6/ipu6.c
index 7bcd9c5a381a..2cf04251c9e7 100644
--- a/drivers/media/pci/intel/ipu6/ipu6.c
+++ b/drivers/media/pci/intel/ipu6/ipu6.c
@@ -503,45 +503,6 @@ static void ipu6_configure_vc_mechanism(struct ipu6_device 
*isp)
writel(val, isp->base + BUTTRESS_REG_BTRS_CTRL);
 }
 
-static int request_cpd_fw(const struct firmware **firmware_p, const char *name,
- struct device *device)
-{
-   const struct firmware *fw;
-   struct firmware *dst;
-   int ret = 0;
-
-   ret = request_firmware(, name, device);
-   if (ret)
-   return ret;
-
-   if (is_vmalloc_addr(fw->data)) {
-   *firmware_p = fw;
-   return 0;
-   }
-
-   dst = kzalloc(sizeof(*dst), GFP_KERNEL);
-   if (!dst) {
-   ret = -ENOMEM;
-   goto release_firmware;
-   }
-
-   dst->size = fw->size;
-   dst->data = vmalloc(fw->size);
-   if (!dst->data) {
-   kfree(dst);
-   ret = -ENOMEM;
-   goto release_firmware;
-   }
-
-   memcpy((void *)dst->data, fw->data, fw->size);
-   *firmware_p = dst;
-
-release_firmware:
-   release_firmware(fw);
-
-   return ret;
-}
-
 static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
struct ipu6_buttress_ctrl *isys_ctrl = NULL, *psys_ctrl = NULL;
@@ -627,7 +588,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
if (ret)
return ret;
 
-   ret = request_cpd_fw(>cpd_fw, isp->cpd_fw_name, dev);
+   ret = request_firmware(>cpd_fw, isp->cpd_fw_name, dev);
if (ret) {
dev_err_probe(>pdev->dev, ret,
  "Requesting signed firmware %s failed\n",


[git:media_stage/master] media: stb0899: Simplify check

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: stb0899: Simplify check
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:41 2024 +0100

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-2-3c4865f5a...@chromium.org
Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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 *) _str, demod_ver);
CONVERT32(STB0899_READ_S2REG(STB0899_S2FEC, FEC_CORE_ID_REG), (char 
*)_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;


[git:media_stage/master] media: pci: mgb4: Refactor struct resources

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: pci: mgb4: Refactor struct resources
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:40 2024 +0100

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-1-3c4865f5a...@chromium.org
Reviewed-by: Martin Tůma 
Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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;


[git:media_stage/master] media: staging: media: starfive: Clean pad selection in isp_try_format()

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: staging: media: starfive: Clean pad selection in 
isp_try_format()
Author:  Changhuang Liang 
Date:Tue Mar 12 02:45:20 2024 +

The code to select isp_dev->formats[] is overly complicated.  We can
just use the "pad" as the index.  This will making adding new pads
easier in future patches.  No functional change.

Link: 
https://lore.kernel.org/linux-media/20240312024520.11022-1-changhuang.li...@starfivetech.com
Signed-off-by: Changhuang Liang 
Reviewed-by: Dan Carpenter 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/starfive/camss/stf-isp.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

---

diff --git a/drivers/staging/media/starfive/camss/stf-isp.c 
b/drivers/staging/media/starfive/camss/stf-isp.c
index d50616ef351e..4e6e26736852 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.c
+++ b/drivers/staging/media/starfive/camss/stf-isp.c
@@ -10,9 +10,6 @@
 
 #include "stf-camss.h"
 
-#define SINK_FORMATS_INDEX 0
-#define SOURCE_FORMATS_INDEX   1
-
 static int isp_set_selection(struct v4l2_subdev *sd,
 struct v4l2_subdev_state *state,
 struct v4l2_subdev_selection *sel);
@@ -94,10 +91,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
return;
}
 
-   if (pad == STF_ISP_PAD_SINK)
-   formats = _dev->formats[SINK_FORMATS_INDEX];
-   else if (pad == STF_ISP_PAD_SRC)
-   formats = _dev->formats[SOURCE_FORMATS_INDEX];
+   formats = _dev->formats[pad];
 
fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
 STFCAMSS_FRAME_MAX_WIDTH);
@@ -123,7 +117,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
if (code->index >= ARRAY_SIZE(isp_formats_sink))
return -EINVAL;
 
-   formats = _dev->formats[SINK_FORMATS_INDEX];
+   formats = _dev->formats[code->pad];
code->code = formats->fmts[code->index].code;
} else {
struct v4l2_mbus_framefmt *sink_fmt;


[git:media_stage/master] media: uvcvideo: Use max() macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: uvcvideo: Use max() macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:43 2024 +0100

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()

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-4-3c4865f5a...@chromium.org
Reviewed-by: Sergey Senozhatsky 
Reviewed-by: Kieran Bingham 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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 e59a463c2761..f8ae14b8b426 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;
 


[git:media_stage/master] media: go7007: Use min and max macros

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: go7007: Use min and max macros
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:44 2024 +0100

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()

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-5-3c4865f5a...@chromium.org
Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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,


[git:media_stage/master] media: staging: sun6i-isp: Remove redundant printk

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: staging: sun6i-isp: Remove redundant printk
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:46 2024 +0100

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-7-3c4865f5a...@chromium.org
Acked-by: Jernej Skrabec 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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;
}
 


[git:media_stage/master] media: staging: media: tegra-video: Use swap macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: staging: media: tegra-video: Use swap macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:49 2024 +0100

Makes the code simpler and cocci happier:

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-10-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Reviewed-by: Luca Ceresoli 
Signed-off-by: Mauro Carvalho Chehab 

 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;


[git:media_stage/master] media: stm32-dcmipp: Remove redundant printk

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: stm32-dcmipp: Remove redundant printk
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:45 2024 +0100

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-6-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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(>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)) {


[git:media_stage/master] media: dvb-frontends: tda18271c2dd: Remove casting during div

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: dvb-frontends: tda18271c2dd: Remove casting during div
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:47 2024 +0100

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.

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-8-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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)1600);
+   do_div(OscFreq, 1600);
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 / 1600 ); */
OscFreq *= (u64)16384;
-   do_div(OscFreq, (u64)1600);
+   do_div(OscFreq, 1600);
CalDiv = OscFreq;
 
state->m_Regs[CPD] = PostDiv;


[git:media_stage/master] media: s2255: Use refcount_t instead of atomic_t for num_channels

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s2255: Use refcount_t instead of atomic_t for num_channels
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:50 2024 +0100

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.

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-11-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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_tnum_channels;
+   refcount_t  num_channels;
int frames;
struct mutexlock;   /* channels[].vdev.lock */
struct mutexcmdlock; /* 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(>num_channels));
+   refcount_read(>num_channels));
 
v4l2_ctrl_handler_free(>hdl);
 
-   if (atomic_dec_and_test(>num_channels))
+   if (refcount_dec_and_test(>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(>num_channels);
+   refcount_inc(>num_channels);
v4l2_info(>v4l2_dev, "V4L2 device registered as %s\n",
  video_device_node_name(>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(>num_channels) == 0) {
+   if (refcount_read(>num_channels) == 0) {
v4l2_device_unregister(>v4l2_dev);
return ret;
}
-   if (atomic_read(>num_channels) != MAX_CHANNELS)
+   if (refcount_read(>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(>num_channels, 0);
+   refcount_set(>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(>num_channels);
+   int channels = refcount_read(>num_channels);
mutex_lock(>lock);
v4l2_device_disconnect(>v4l2_dev);
mutex_unlock(>lock);
/*see comments in the uvc_driver.c usb disconnect function */
-   atomic_inc(>num_channels);
+   refcount_inc(>num_channels);
/* unregister each video device. */
for (i = 0; i < channels; i++)
video_unregister_device(>vc[i].vdev);
@@ -2359,7 +2359,7 @@ static void s2255_disconnect(struct usb_interface 
*interface)
dev->vc[i].vidstatus_ready = 1;
wake_up(>vc[i].wait_vidstatus);
}
-   if (atomic_dec_and_test(>num_channels))
+   if (refcount_dec_and_test(>num_channels))
s2255_destroy(dev);
dev_info(>dev, "%s\n", __func__);
 }


[git:media_stage/master] media: dvb-frontends: tda10048: Fix integer overflow

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: dvb-frontends: tda10048: Fix integer overflow
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:05:04 2024 +0100

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.

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-25-3c4865f5a...@chromium.org
Reported-by: Dan Carpenter 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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 = >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 */


[git:media_stage/master] media: platform: mtk-mdp3: Use refcount_t for job_count

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: platform: mtk-mdp3: Use refcount_t for job_count
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:51 2024 +0100

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.

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-12-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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(>pdev->dev, cmd->comps,
cmd->num_comps);
 
-   if (atomic_dec_and_test(>job_count)) {
+   if (refcount_dec_and_test(>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(>pdev->dev, cmd->comps,
cmd->num_comps);
 
-   if (atomic_dec_and_test(>job_count))
+   if (refcount_dec_and_test(>job_count))
wake_up(>callback_wq);
 
mdp_cmdq_pkt_destroy(>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(>job_count, pp_used);
+   refcount_set(>job_count, pp_used);
if (atomic_read(>suspended)) {
-   atomic_set(>job_count, 0);
+   refcount_set(>job_count, 0);
return -ECANCELED;
}
 
@@ -764,7 +764,7 @@ err_clock_off:
mdp_comp_clocks_off(>pdev->dev, cmd[i]->comps,
cmd[i]->num_comps);
 err_cancel_job:
-   atomic_set(>job_count, 0);
+   refcount_set(>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(>suspended, 1);
 
-   if (atomic_read(>job_count)) {
+   if (refcount_read(>job_count)) {
ret = wait_event_timeout(mdp->callback_wq,
-!atomic_read(>job_count),
+!refcount_read(>job_count),
 2 * HZ);
if (ret == 0) {
dev_err(dev,
"%s:flushed cmdq task incomplete, count=%d\n",
-   __func__, atomic_read(>job_count));
+   __func__, refcount_read(>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 mutexm2m_lock;
atomic_tsuspended;
-   atomic_tjob_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(>mdp_dev->job_count)) {
+   if 

[git:media_stage/master] media: common: saa7146: Use min macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: common: saa7146: Use min macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:52 2024 +0100

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()

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-13-3c4865f5a...@chromium.org
Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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)


[git:media_stage/master] media: netup_unidvb: Use min macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: netup_unidvb: Use min macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:54 2024 +0100

Simplify the code.

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-15-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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(>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, >regs->tx_fifo.data8);


[git:media_stage/master] media: dvb-frontends: drx39xyj: Use min macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: dvb-frontends: drx39xyj: Use min macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:53 2024 +0100

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()

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-14-3c4865f5a...@chromium.org
Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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([bufx], data, todo);
/* write (address if can do and) data */


[git:media_stage/master] media: au0828: Use umin macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: au0828: Use umin macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:55 2024 +0100

Simplifies the code.

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-16-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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,


[git:media_stage/master] media: flexcop-usb: Use min macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: flexcop-usb: Use min macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:56 2024 +0100

Simplifies the code.

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-17-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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));


[git:media_stage/master] media: i2c: st-mipid02: Use the correct div function

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: st-mipid02: Use the correct div function
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:05:00 2024 +0100

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.

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-21-3c4865f5a...@chromium.org
Reviewed-by: Benjamin Mugnier 
Reviewed-by: Sakari Ailus 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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(>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;


[git:media_stage/master] media: tegra-vde: Refactor timeout handling

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: tegra-vde: Refactor timeout handling
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:59 2024 +0100

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()

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-20-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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(
>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;
}


[git:media_stage/master] media: stk1160: Use min macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: stk1160: Use min macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:58 2024 +0100

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()

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-19-3c4865f5a...@chromium.org
Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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.


[git:media_stage/master] media: gspca: cpia1: Use min macro

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: gspca: cpia1: Use min macro
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:04:57 2024 +0100

Simplifies the code.

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

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-18-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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;
 }


[git:media_stage/master] media: tc358746: Use the correct div_ function

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: tc358746: Use the correct div_ function
Author:  Ricardo Ribalda 
Date:Mon Apr 29 16:05:01 2024 +0100

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.

Link: 
https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-22-3c4865f5a...@chromium.org
Signed-off-by: Ricardo Ribalda 
Signed-off-by: Mauro Carvalho Chehab 

 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;
 


[git:media_stage/master] media: mtk-vcodec: potential null pointer deference in SCP

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mtk-vcodec: potential null pointer deference in SCP
Author:  Fullway Wang 
Date:Thu Jan 18 02:35:06 2024 +

The return value of devm_kzalloc() needs to be checked to avoid
NULL pointer deference. This is similar to CVE-2022-3113.

Link: 
https://lore.kernel.org/linux-media/ph7pr20mb5925094dae3fd750c7e39e01bf...@ph7pr20mb5925.namprd20.prod.outlook.com
Signed-off-by: Fullway Wang 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c | 2 ++
 1 file changed, 2 insertions(+)

---

diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c 
b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c
index 6bbe55de6ce9..ff23b225db70 100644
--- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c
+++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c
@@ -79,6 +79,8 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum 
mtk_vcodec_fw_use
}
 
fw = devm_kzalloc(_dev->dev, sizeof(*fw), GFP_KERNEL);
+   if (!fw)
+   return ERR_PTR(-ENOMEM);
fw->type = SCP;
fw->ops = _vcodec_rproc_msg;
fw->scp = scp;


[git:media_stage/master] media: mxl5xx: Move xpt structures off stack

2024-05-03 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mxl5xx: Move xpt structures off stack
Author:  Nathan Chancellor 
Date:Fri Jan 12 00:40:36 2024 +

When building for LoongArch with clang 18.0.0, the stack usage of
probe() is larger than the allowed 2048 bytes:

  drivers/media/dvb-frontends/mxl5xx.c:1698:12: warning: stack frame size 
(2368) exceeds limit (2048) in 'probe' [-Wframe-larger-than]
   1698 | static int probe(struct mxl *state, struct mxl5xx_cfg *cfg)
|^
  1 warning generated.

This is the result of the linked LLVM commit, which changes how the
arrays of structures in config_ts() get handled with
CONFIG_INIT_STACK_ZERO and CONFIG_INIT_STACK_PATTERN, which causes the
above warning in combination with inlining, as config_ts() gets inlined
into probe().

This warning can be easily fixed by moving the array of structures off
of the stackvia 'static const', which is a better location for these
variables anyways because they are static data that is only ever read
from, never modified, so allocating the stack space is wasteful.

This drops the stack usage from 2368 bytes to 256 bytes with the same
compiler and configuration.

Link: 
https://lore.kernel.org/linux-media/20240111-dvb-mxl5xx-move-structs-off-stack-v1-1-ca4230e67...@kernel.org
Cc: sta...@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/1977
Link: 
https://github.com/llvm/llvm-project/commit/afe8b93ffdfef5d8879e1894b9d7dda40dee2b8d
Signed-off-by: Nathan Chancellor 
Reviewed-by: Miguel Ojeda 
Tested-by: Miguel Ojeda 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/dvb-frontends/mxl5xx.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

---

diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 4ebbcf05cc09..91e9c378397c 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -1381,57 +1381,57 @@ static int config_ts(struct mxl *state, enum 
MXL_HYDRA_DEMOD_ID_E demod_id,
u32 nco_count_min = 0;
u32 clk_type = 0;
 
-   struct MXL_REG_FIELD_T xpt_sync_polarity[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T 
xpt_sync_polarity[MXL_HYDRA_DEMOD_MAX] = {
{0x90700010, 8, 1}, {0x90700010, 9, 1},
{0x90700010, 10, 1}, {0x90700010, 11, 1},
{0x90700010, 12, 1}, {0x90700010, 13, 1},
{0x90700010, 14, 1}, {0x90700010, 15, 1} };
-   struct MXL_REG_FIELD_T xpt_clock_polarity[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T 
xpt_clock_polarity[MXL_HYDRA_DEMOD_MAX] = {
{0x90700010, 16, 1}, {0x90700010, 17, 1},
{0x90700010, 18, 1}, {0x90700010, 19, 1},
{0x90700010, 20, 1}, {0x90700010, 21, 1},
{0x90700010, 22, 1}, {0x90700010, 23, 1} };
-   struct MXL_REG_FIELD_T xpt_valid_polarity[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T 
xpt_valid_polarity[MXL_HYDRA_DEMOD_MAX] = {
{0x90700014, 0, 1}, {0x90700014, 1, 1},
{0x90700014, 2, 1}, {0x90700014, 3, 1},
{0x90700014, 4, 1}, {0x90700014, 5, 1},
{0x90700014, 6, 1}, {0x90700014, 7, 1} };
-   struct MXL_REG_FIELD_T xpt_ts_clock_phase[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T 
xpt_ts_clock_phase[MXL_HYDRA_DEMOD_MAX] = {
{0x90700018, 0, 3}, {0x90700018, 4, 3},
{0x90700018, 8, 3}, {0x90700018, 12, 3},
{0x90700018, 16, 3}, {0x90700018, 20, 3},
{0x90700018, 24, 3}, {0x90700018, 28, 3} };
-   struct MXL_REG_FIELD_T xpt_lsb_first[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T xpt_lsb_first[MXL_HYDRA_DEMOD_MAX] 
= {
{0x907C, 16, 1}, {0x907C, 17, 1},
{0x907C, 18, 1}, {0x907C, 19, 1},
{0x907C, 20, 1}, {0x907C, 21, 1},
{0x907C, 22, 1}, {0x907C, 23, 1} };
-   struct MXL_REG_FIELD_T xpt_sync_byte[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T xpt_sync_byte[MXL_HYDRA_DEMOD_MAX] 
= {
{0x90700010, 0, 1}, {0x90700010, 1, 1},
{0x90700010, 2, 1}, {0x90700010, 3, 1},
{0x90700010, 4, 1}, {0x90700010, 5, 1},
{0x90700010, 6, 1}, {0x90700010, 7, 1} };
-   struct MXL_REG_FIELD_T xpt_enable_output[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct MXL_REG_FIELD_T 
xpt_enable_output[MXL_HYDRA_DEMOD_MAX] = {
{0x907C, 0, 1}, {0x907C, 1, 1},
{0x907C, 2, 1}, {0x907C, 3, 1},
{0x907C, 4, 1}, {0x907C, 5, 1},
{0x907C, 6, 1}, {0x907C, 7, 1} };
-   struct MXL_REG_FIELD_T xpt_err_replace_sync[MXL_HYDRA_DEMOD_MAX] = {
+   static const struct