llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/20] Solve the remaining issues with clang and W=1 on media
@ 2021-11-24 19:13 Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 01/20] media: adv7842: get rid of two unused functions Mauro Carvalho Chehab
                   ` (13 more replies)
  0 siblings, 14 replies; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Lad, Prabhakar,
	Andy Gross, Antti Palosaari, Bjorn Andersson, Hans Verkuil,
	Malcolm Priestley, Manivannan Sadhasivam, Matthias Brugger,
	Mauro Carvalho Chehab, Robert Foss, Todor Tomov,
	linux-arm-kernel, linux-arm-msm, linux-kernel, linux-media,
	linux-mediatek, llvm

Currently, using clang with W=1 and CONFIG_WERROR causes media to break.
This is reported by builder.linuxtv.org.

This series solve the remaining issues.

Mauro Carvalho Chehab (20):
  media: adv7842: get rid of two unused functions
  media: saa7134-go7007: get rid of to_state() function
  media: davinci: get rid of an unused function
  media: drxd: drop offset var from DownloadMicrocode()
  media: drxk: drop operation_mode from set_dvbt()
  media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk()
  media: si21xx: report eventual errors at set_frontend
  media: solo6x10: add _maybe_unused to currently unused functions
  media: si470x: fix printk warnings with clang
  media: radio-si476x: drop a container_of() abstraction macro
  media: lmedm04: don't ignore errors when setting a filter
  media: au0828-i2c: drop a duplicated function
  media: adv7604 add _maybe_unused to currently unused functions
  media: adv7511: drop unused functions
  media: imx290: mark read reg function as __maybe_unused
  media: davinci: vpbe_osd: mark read reg function as __maybe_unused
  media: qcom: camss: mark read reg function as  __maybe_unused
  media: mtk-mdp: address a clang warning
  media: cobalt: drop an unused variable
  media: mxl5005s: drop some dead code

 drivers/media/dvb-frontends/drxd_hard.c       |  8 -------
 drivers/media/dvb-frontends/drxk_hard.c       |  6 -----
 drivers/media/dvb-frontends/m88ds3103.c       |  6 +----
 drivers/media/dvb-frontends/si21xx.c          |  7 +++---
 drivers/media/i2c/adv7511-v4l2.c              | 22 -------------------
 drivers/media/i2c/adv7604.c                   | 18 +++++++--------
 drivers/media/i2c/adv7842.c                   | 10 ---------
 drivers/media/i2c/imx290.c                    |  2 +-
 drivers/media/pci/cobalt/cobalt-cpld.c        |  5 +----
 drivers/media/pci/saa7134/saa7134-go7007.c    |  7 +-----
 .../media/pci/solo6x10/solo6x10-v4l2-enc.c    | 12 +++++-----
 drivers/media/platform/davinci/vpbe_osd.c     |  2 +-
 drivers/media/platform/davinci/vpif_capture.c | 11 ----------
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  2 +-
 .../media/platform/qcom/camss/camss-vfe-170.c |  2 +-
 drivers/media/radio/radio-si476x.c            |  6 -----
 drivers/media/radio/si470x/radio-si470x-i2c.c |  4 ++--
 drivers/media/radio/si470x/radio-si470x-usb.c |  8 +++----
 drivers/media/tuners/mxl5005s.c               | 14 +-----------
 drivers/media/usb/au0828/au0828-i2c.c         |  7 ------
 drivers/media/usb/dvb-usb-v2/lmedm04.c        |  3 +++
 21 files changed, 36 insertions(+), 126 deletions(-)

-- 
2.33.1



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

* [PATCH 01/20] media: adv7842: get rid of two unused functions
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 18:54   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 02/20] media: saa7134-go7007: get rid of to_state() function Mauro Carvalho Chehab
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

Those functions just call a V4L2 core macro, and aren't used
anywhere. Get rid of them, in order to avoid clang warnings with
W=1.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/i2c/adv7842.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 7f8acbdf0db4..9d6eed0f8281 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -256,21 +256,11 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
 	return &container_of(ctrl->handler, struct adv7842_state, hdl)->sd;
 }
 
-static inline unsigned hblanking(const struct v4l2_bt_timings *t)
-{
-	return V4L2_DV_BT_BLANKING_WIDTH(t);
-}
-
 static inline unsigned htotal(const struct v4l2_bt_timings *t)
 {
 	return V4L2_DV_BT_FRAME_WIDTH(t);
 }
 
-static inline unsigned vblanking(const struct v4l2_bt_timings *t)
-{
-	return V4L2_DV_BT_BLANKING_HEIGHT(t);
-}
-
 static inline unsigned vtotal(const struct v4l2_bt_timings *t)
 {
 	return V4L2_DV_BT_FRAME_HEIGHT(t);
-- 
2.33.1


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

* [PATCH 02/20] media: saa7134-go7007: get rid of to_state() function
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 01/20] media: adv7842: get rid of two unused functions Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 18:55   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 04/20] media: drxd: drop offset var from DownloadMicrocode() Mauro Carvalho Chehab
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

This is just an alias for container_of() and it is used only
on a commented code. The commented code actually is an issue that
require fixes, so, move the container_of() call to the commented
code, and drop the unused function.

This way, a fix for the function could be added later without
needing to re-add to_state() function.

This fixes a clang W=1 warning.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/pci/saa7134/saa7134-go7007.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c
index f319edb39c0e..da83893ffee9 100644
--- a/drivers/media/pci/saa7134/saa7134-go7007.c
+++ b/drivers/media/pci/saa7134/saa7134-go7007.c
@@ -56,11 +56,6 @@ struct saa7134_go7007 {
 	dma_addr_t bottom_dma;
 };
 
-static inline struct saa7134_go7007 *to_state(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct saa7134_go7007, sd);
-}
-
 static const struct go7007_board_info board_voyager = {
 	.flags		 = 0,
 	.sensor_flags	 = GO7007_SENSOR_656 |
@@ -385,7 +380,7 @@ MODULE_FIRMWARE("go7007/go7007tv.bin");
 static int saa7134_go7007_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
 {
 #if 0
-	struct saa7134_go7007 *saa = to_state(sd);
+	struct saa7134_go7007 *saa = container_of(sd, struct saa7134_go7007, sd);
 	struct saa7134_dev *dev = saa->dev;
 
 	return saa7134_s_std_internal(dev, NULL, norm);
-- 
2.33.1


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

* [PATCH 04/20] media: drxd: drop offset var from DownloadMicrocode()
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 01/20] media: adv7842: get rid of two unused functions Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 02/20] media: saa7134-go7007: get rid of to_state() function Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 18:57   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 06/20] media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk() Mauro Carvalho Chehab
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

The offset is not needed, and it is never used, as the pointer
itself is already incremented.

So, drop it, in order to solve a W=1 clang warning.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/dvb-frontends/drxd_hard.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
index a7eb81df88c2..9860cae65f1c 100644
--- a/drivers/media/dvb-frontends/drxd_hard.c
+++ b/drivers/media/dvb-frontends/drxd_hard.c
@@ -914,44 +914,36 @@ static int DownloadMicrocode(struct drxd_state *state,
 	u32 Address;
 	u16 nBlocks;
 	u16 BlockSize;
-	u32 offset = 0;
 	int i, status = 0;
 
 	pSrc = (u8 *) pMCImage;
 	/* We're not using Flags */
 	/* Flags = (pSrc[0] << 8) | pSrc[1]; */
 	pSrc += sizeof(u16);
-	offset += sizeof(u16);
 	nBlocks = (pSrc[0] << 8) | pSrc[1];
 	pSrc += sizeof(u16);
-	offset += sizeof(u16);
 
 	for (i = 0; i < nBlocks; i++) {
 		Address = (pSrc[0] << 24) | (pSrc[1] << 16) |
 		    (pSrc[2] << 8) | pSrc[3];
 		pSrc += sizeof(u32);
-		offset += sizeof(u32);
 
 		BlockSize = ((pSrc[0] << 8) | pSrc[1]) * sizeof(u16);
 		pSrc += sizeof(u16);
-		offset += sizeof(u16);
 
 		/* We're not using Flags */
 		/* u16 Flags = (pSrc[0] << 8) | pSrc[1]; */
 		pSrc += sizeof(u16);
-		offset += sizeof(u16);
 
 		/* We're not using BlockCRC */
 		/* u16 BlockCRC = (pSrc[0] << 8) | pSrc[1]; */
 		pSrc += sizeof(u16);
-		offset += sizeof(u16);
 
 		status = WriteBlock(state, Address, BlockSize,
 				    pSrc, DRX_I2C_CLEARCRC);
 		if (status < 0)
 			break;
 		pSrc += BlockSize;
-		offset += BlockSize;
 	}
 
 	return status;
-- 
2.33.1


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

* [PATCH 06/20] media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk()
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 04/20] media: drxd: drop offset var from DownloadMicrocode() Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 19:40   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions Mauro Carvalho Chehab
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Antti Palosaari,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

This vaklue is never used at the code. So, drop it.

Solves a W=1 clang warning.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/dvb-frontends/m88ds3103.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index 02e8aa11e36e..bce0f42f3d19 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -451,7 +451,7 @@ static int m88ds3103b_select_mclk(struct m88ds3103_dev *dev)
 
 static int m88ds3103b_set_mclk(struct m88ds3103_dev *dev, u32 mclk_khz)
 {
-	u8 reg11 = 0x0A, reg15, reg16, reg1D, reg1E, reg1F, tmp;
+	u8 reg15, reg16, reg1D, reg1E, reg1F, tmp;
 	u8 sm, f0 = 0, f1 = 0, f2 = 0, f3 = 0;
 	u16 pll_div_fb, N;
 	u32 div;
@@ -480,8 +480,6 @@ static int m88ds3103b_set_mclk(struct m88ds3103_dev *dev, u32 mclk_khz)
 	div /= mclk_khz;
 
 	if (dev->cfg->ts_mode == M88DS3103_TS_SERIAL) {
-		reg11 |= 0x02;
-
 		if (div <= 32) {
 			N = 2;
 
@@ -532,8 +530,6 @@ static int m88ds3103b_set_mclk(struct m88ds3103_dev *dev, u32 mclk_khz)
 		else if ((f3 < 8) && (f3 != 0))
 			f3 = 8;
 	} else {
-		reg11 &= ~0x02;
-
 		if (div <= 32) {
 			N = 2;
 
-- 
2.33.1


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

* [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 06/20] media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk() Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-25 21:18   ` Ismael Luceno
  2021-11-26 19:58   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 09/20] media: si470x: fix printk warnings with clang Mauro Carvalho Chehab
                   ` (8 subsequent siblings)
  13 siblings, 2 replies; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andrey Utkin,
	Anton Sviridenko, Bluecherry Maintainers, Ismael Luceno,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

There are several unused helper macros there, meant to parse some
fields.

While there's not wrong with that, it generates clang warnings
with W=1, causing build to break with CONFIG_WERROR.

So, add __maybe_unused to fix such warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
index 0abcad4e84fa..85eaf5d00e9b 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
@@ -391,12 +391,12 @@ static int solo_send_desc(struct solo_enc_dev *solo_enc, int skip,
 }
 
 /* Extract values from VOP header - VE_STATUSxx */
-static inline int vop_interlaced(const vop_header *vh)
+static inline __maybe_unused int vop_interlaced(const vop_header *vh)
 {
 	return (__le32_to_cpu((*vh)[0]) >> 30) & 1;
 }
 
-static inline u8 vop_channel(const vop_header *vh)
+static inline __maybe_unused u8 vop_channel(const vop_header *vh)
 {
 	return (__le32_to_cpu((*vh)[0]) >> 24) & 0x1F;
 }
@@ -411,12 +411,12 @@ static inline u32 vop_mpeg_size(const vop_header *vh)
 	return __le32_to_cpu((*vh)[0]) & 0xFFFFF;
 }
 
-static inline u8 vop_hsize(const vop_header *vh)
+static inline u8 __maybe_unused vop_hsize(const vop_header *vh)
 {
 	return (__le32_to_cpu((*vh)[1]) >> 8) & 0xFF;
 }
 
-static inline u8 vop_vsize(const vop_header *vh)
+static inline u8 __maybe_unused vop_vsize(const vop_header *vh)
 {
 	return __le32_to_cpu((*vh)[1]) & 0xFF;
 }
@@ -436,12 +436,12 @@ static inline u32 vop_jpeg_size(const vop_header *vh)
 	return __le32_to_cpu((*vh)[4]) & 0xFFFFF;
 }
 
-static inline u32 vop_sec(const vop_header *vh)
+static inline u32 __maybe_unused vop_sec(const vop_header *vh)
 {
 	return __le32_to_cpu((*vh)[5]);
 }
 
-static inline u32 vop_usec(const vop_header *vh)
+static inline __maybe_unused u32 vop_usec(const vop_header *vh)
 {
 	return __le32_to_cpu((*vh)[6]);
 }
-- 
2.33.1


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

* [PATCH 09/20] media: si470x: fix printk warnings with clang
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 20:13   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 11/20] media: lmedm04: don't ignore errors when setting a filter Mauro Carvalho Chehab
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Kees Cook, Mauro Carvalho Chehab, Nathan Chancellor,
	Nick Desaulniers, linux-kernel, linux-media, llvm

Clang doesn't like "%hu" on macros:

	drivers/media/radio/si470x/radio-si470x-i2c.c:414:4: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
	drivers/media/radio/si470x/radio-si470x-i2c.c:417:4: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]

So, just replace them with "%u".

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/radio/si470x/radio-si470x-i2c.c | 4 ++--
 drivers/media/radio/si470x/radio-si470x-usb.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
index a972c0705ac7..7ea7c6326f53 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -410,10 +410,10 @@ static int si470x_i2c_probe(struct i2c_client *client)
 			radio->registers[DEVICEID], radio->registers[SI_CHIPID]);
 	if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
 		dev_warn(&client->dev,
-			"This driver is known to work with firmware version %hu,\n",
+			"This driver is known to work with firmware version %u,\n",
 			RADIO_FW_VERSION);
 		dev_warn(&client->dev,
-			"but the device has firmware version %hu.\n",
+			"but the device has firmware version %u.\n",
 			radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
 		version_warning = 1;
 	}
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 3f8634a46573..1e70e6971fe4 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -681,10 +681,10 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
 			radio->registers[DEVICEID], radio->registers[SI_CHIPID]);
 	if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
 		dev_warn(&intf->dev,
-			"This driver is known to work with firmware version %hu,\n",
+			"This driver is known to work with firmware version %u,\n",
 			RADIO_FW_VERSION);
 		dev_warn(&intf->dev,
-			"but the device has firmware version %hu.\n",
+			"but the device has firmware version %u.\n",
 			radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
 		version_warning = 1;
 	}
@@ -698,10 +698,10 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
 			radio->software_version, radio->hardware_version);
 	if (radio->hardware_version < RADIO_HW_VERSION) {
 		dev_warn(&intf->dev,
-			"This driver is known to work with hardware version %hu,\n",
+			"This driver is known to work with hardware version %u,\n",
 			RADIO_HW_VERSION);
 		dev_warn(&intf->dev,
-			"but the device has hardware version %hu.\n",
+			"but the device has hardware version %u.\n",
 			radio->hardware_version);
 		version_warning = 1;
 	}
-- 
2.33.1


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

* [PATCH 11/20] media: lmedm04: don't ignore errors when setting a filter
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 09/20] media: si470x: fix printk warnings with clang Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 20:16   ` Nathan Chancellor
  2021-11-24 19:13 ` [PATCH 13/20] media: adv7604 add _maybe_unused to currently unused functions Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Malcolm Priestley,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

Solves a clang warning

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/usb/dvb-usb-v2/lmedm04.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index fe4d886442a4..8a34e6c0d6a6 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -423,6 +423,9 @@ static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
 
 	mutex_unlock(&d->i2c_mutex);
 
+	if (ret)
+		return -EREMOTEIO;
+
 	return 0;
 }
 
-- 
2.33.1


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

* [PATCH 13/20] media: adv7604 add _maybe_unused to currently unused functions
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 11/20] media: lmedm04: don't ignore errors when setting a filter Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 15/20] media: imx290: mark read reg function as __maybe_unused Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

There are several unused helper macros there, meant to parse some
fields.

While there's not wrong with that, it generates clang warnings
with W=1, causing build to break with CONFIG_WERROR.

So, add __maybe_unused to fix such warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/i2c/adv7604.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 44768b59a6ff..be95b2264221 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -398,14 +398,14 @@ static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask,
 	return io_write(sd, reg, (io_read(sd, reg) & ~mask) | val);
 }
 
-static inline int avlink_read(struct v4l2_subdev *sd, u8 reg)
+static inline int __maybe_unused avlink_read(struct v4l2_subdev *sd, u8 reg)
 {
 	struct adv76xx_state *state = to_state(sd);
 
 	return adv76xx_read_check(state, ADV7604_PAGE_AVLINK, reg);
 }
 
-static inline int avlink_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+static inline int __maybe_unused avlink_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
 	struct adv76xx_state *state = to_state(sd);
 
@@ -439,14 +439,14 @@ static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg)
 	return adv76xx_read_check(state, ADV76XX_PAGE_INFOFRAME, reg);
 }
 
-static inline int infoframe_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+static inline int __maybe_unused infoframe_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
 	struct adv76xx_state *state = to_state(sd);
 
 	return regmap_write(state->regmap[ADV76XX_PAGE_INFOFRAME], reg, val);
 }
 
-static inline int afe_read(struct v4l2_subdev *sd, u8 reg)
+static inline int __maybe_unused afe_read(struct v4l2_subdev *sd, u8 reg)
 {
 	struct adv76xx_state *state = to_state(sd);
 
@@ -479,14 +479,14 @@ static inline int rep_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8
 	return rep_write(sd, reg, (rep_read(sd, reg) & ~mask) | val);
 }
 
-static inline int edid_read(struct v4l2_subdev *sd, u8 reg)
+static inline int __maybe_unused edid_read(struct v4l2_subdev *sd, u8 reg)
 {
 	struct adv76xx_state *state = to_state(sd);
 
 	return adv76xx_read_check(state, ADV76XX_PAGE_EDID, reg);
 }
 
-static inline int edid_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+static inline int __maybe_unused edid_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
 	struct adv76xx_state *state = to_state(sd);
 
@@ -570,7 +570,7 @@ static inline int hdmi_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8
 	return hdmi_write(sd, reg, (hdmi_read(sd, reg) & ~mask) | val);
 }
 
-static inline int test_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+static inline int __maybe_unused test_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
 	struct adv76xx_state *state = to_state(sd);
 
@@ -601,14 +601,14 @@ static inline int cp_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 v
 	return cp_write(sd, reg, (cp_read(sd, reg) & ~mask) | val);
 }
 
-static inline int vdp_read(struct v4l2_subdev *sd, u8 reg)
+static inline int __maybe_unused vdp_read(struct v4l2_subdev *sd, u8 reg)
 {
 	struct adv76xx_state *state = to_state(sd);
 
 	return adv76xx_read_check(state, ADV7604_PAGE_VDP, reg);
 }
 
-static inline int vdp_write(struct v4l2_subdev *sd, u8 reg, u8 val)
+static inline int __maybe_unused vdp_write(struct v4l2_subdev *sd, u8 reg, u8 val)
 {
 	struct adv76xx_state *state = to_state(sd);
 
-- 
2.33.1


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

* [PATCH 15/20] media: imx290: mark read reg function as __maybe_unused
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (7 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 13/20] media: adv7604 add _maybe_unused to currently unused functions Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 16/20] media: davinci: vpbe_osd: " Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Manivannan Sadhasivam, Mauro Carvalho Chehab, Nathan Chancellor,
	Nick Desaulniers, linux-kernel, linux-media, llvm

Such function is currently unused, but could be needed in the
future. So, keep it, marking it as __maybe_unused, in order to
avoid a clang W=1 error.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/i2c/imx290.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index bf7a6c37ca5d..caab830f8c72 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -363,7 +363,7 @@ static inline struct imx290 *to_imx290(struct v4l2_subdev *_sd)
 	return container_of(_sd, struct imx290, sd);
 }
 
-static inline int imx290_read_reg(struct imx290 *imx290, u16 addr, u8 *value)
+static inline int __maybe_unused imx290_read_reg(struct imx290 *imx290, u16 addr, u8 *value)
 {
 	unsigned int regval;
 	int ret;
-- 
2.33.1


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

* [PATCH 16/20] media: davinci: vpbe_osd: mark read reg function as __maybe_unused
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (8 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 15/20] media: imx290: mark read reg function as __maybe_unused Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-24 19:13 ` [PATCH 17/20] media: qcom: camss: " Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Lad, Prabhakar,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

Such function is currently unused, but could be needed in the
future. So, keep it, marking it as __maybe_unused, in order to
avoid a clang W=1 error.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/platform/davinci/vpbe_osd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c
index 91b571a0ac2c..6b36cae5e6c1 100644
--- a/drivers/media/platform/davinci/vpbe_osd.c
+++ b/drivers/media/platform/davinci/vpbe_osd.c
@@ -45,7 +45,7 @@ static const struct platform_device_id vpbe_osd_devtype[] = {
 MODULE_DEVICE_TABLE(platform, vpbe_osd_devtype);
 
 /* register access routines */
-static inline u32 osd_read(struct osd_state *sd, u32 offset)
+static inline u32 __maybe_unused osd_read(struct osd_state *sd, u32 offset)
 {
 	struct osd_state *osd = sd;
 
-- 
2.33.1


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

* [PATCH 17/20] media: qcom: camss: mark read reg function as  __maybe_unused
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (9 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 16/20] media: davinci: vpbe_osd: " Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-25 10:58   ` Robert Foss
  2021-11-24 19:13 ` [PATCH 18/20] media: mtk-mdp: address a clang warning Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andy Gross,
	Bjorn Andersson, Mauro Carvalho Chehab, Nathan Chancellor,
	Nick Desaulniers, Robert Foss, Todor Tomov, linux-arm-msm,
	linux-kernel, linux-media, llvm

Such function is currently unused, but could be needed in the
future. So, keep it, marking it as __maybe_unused, in order to
avoid a clang W=1 error.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/platform/qcom/camss/camss-vfe-170.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c
index 5c083d70d495..455ae1a819e6 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-170.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c
@@ -191,7 +191,7 @@ static u32 vfe_hw_version(struct vfe_device *vfe)
 	return hw_version;
 }
 
-static inline void vfe_reg_clr(struct vfe_device *vfe, u32 reg, u32 clr_bits)
+static inline void __maybe_unused vfe_reg_clr(struct vfe_device *vfe, u32 reg, u32 clr_bits)
 {
 	u32 bits = readl_relaxed(vfe->base + reg);
 
-- 
2.33.1


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

* [PATCH 18/20] media: mtk-mdp: address a clang warning
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (10 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 17/20] media: qcom: camss: " Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-24 19:21   ` Arnd Bergmann
  2021-11-24 19:13 ` [PATCH 20/20] media: mxl5005s: drop some dead code Mauro Carvalho Chehab
  2021-11-24 19:23 ` [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Arnd Bergmann
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andrew-CT Chen,
	Houlong Wei, Matthias Brugger, Mauro Carvalho Chehab,
	Minghsiu Tsai, Nathan Chancellor, Nick Desaulniers,
	linux-arm-kernel, linux-kernel, linux-media, linux-mediatek,
	llvm

The typecasts at the dvb-core generate clang warnings when W=1
is enabled.

Such warning is harmless, but it causes the build to break with
CONFIG_WERROR and W=1 with clang, so do the cast on a way that
it won't produce warnings anymore.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index 976aa1f4829b..11285717577f 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -148,7 +148,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
 			continue;
 		}
 
-		comp_type = (enum mtk_mdp_comp_type)of_id->data;
+		comp_type = (long)of_id->data;
 
 		comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL);
 		if (!comp) {
-- 
2.33.1


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

* [PATCH 20/20] media: mxl5005s: drop some dead code
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (11 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 18/20] media: mtk-mdp: address a clang warning Mauro Carvalho Chehab
@ 2021-11-24 19:13 ` Mauro Carvalho Chehab
  2021-11-26 20:30   ` Nathan Chancellor
  2021-11-24 19:23 ` [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Arnd Bergmann
  13 siblings, 1 reply; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-24 19:13 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bixuan Cui,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	linux-kernel, linux-media, llvm

As reported by clang (with W=1), the ctrlVal var is never used.

Yet, there are even some loops to estimate it. As this is dead
code, remove it. If ever needed, someone could revert this
patch.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/

 drivers/media/tuners/mxl5005s.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/media/tuners/mxl5005s.c b/drivers/media/tuners/mxl5005s.c
index f6e82a8e7d37..ab4c43df9d18 100644
--- a/drivers/media/tuners/mxl5005s.c
+++ b/drivers/media/tuners/mxl5005s.c
@@ -3414,9 +3414,8 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
 	u32 value, u16 controlGroup)
 {
 	struct mxl5005s_state *state = fe->tuner_priv;
-	u16 i, j, k;
+	u16 i, j;
 	u32 highLimit;
-	u32 ctrlVal;
 
 	if (controlGroup == 1) /* Initial Control */ {
 
@@ -3432,9 +3431,6 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
 							(u8)(state->Init_Ctrl[i].bit[j]),
 							(u8)((value>>j) & 0x01));
 					}
-					ctrlVal = 0;
-					for (k = 0; k < state->Init_Ctrl[i].size; k++)
-						ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
 				} else
 					return -1;
 			}
@@ -3454,9 +3450,6 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
 							(u8)(state->CH_Ctrl[i].bit[j]),
 							(u8)((value>>j) & 0x01));
 					}
-					ctrlVal = 0;
-					for (k = 0; k < state->CH_Ctrl[i].size; k++)
-						ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
 				} else
 					return -1;
 			}
@@ -3477,11 +3470,6 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
 							(u8)(state->MXL_Ctrl[i].bit[j]),
 							(u8)((value>>j) & 0x01));
 					}
-					ctrlVal = 0;
-					for (k = 0; k < state->MXL_Ctrl[i].size; k++)
-						ctrlVal += state->
-							MXL_Ctrl[i].val[k] *
-							(1 << k);
 				} else
 					return -1;
 			}
-- 
2.33.1


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

* Re: [PATCH 18/20] media: mtk-mdp: address a clang warning
  2021-11-24 19:13 ` [PATCH 18/20] media: mtk-mdp: address a clang warning Mauro Carvalho Chehab
@ 2021-11-24 19:21   ` Arnd Bergmann
  0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2021-11-24 19:21 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linuxarm, Mauro Carvalho Chehab, Andrew-CT Chen, Houlong Wei,
	Matthias Brugger, Mauro Carvalho Chehab, Minghsiu Tsai,
	Nathan Chancellor, Nick Desaulniers, Linux ARM,
	Linux Kernel Mailing List, Linux Media Mailing List,
	moderated list:ARM/Mediatek SoC...,
	llvm

On Wed, Nov 24, 2021 at 8:13 PM Mauro Carvalho Chehab
<mchehab+huawei@kernel.org> wrote:
>
> The typecasts at the dvb-core generate clang warnings when W=1
> is enabled.
>
> Such warning is harmless, but it causes the build to break with
> CONFIG_WERROR and W=1 with clang, so do the cast on a way that
> it won't produce warnings anymore.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

>
> -               comp_type = (enum mtk_mdp_comp_type)of_id->data;
> +               comp_type = (long)of_id->data;

I would generally use (uintptr_t) for this purpose, but the effect is the same.

        Arnd

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

* Re: [PATCH 00/20] Solve the remaining issues with clang and W=1 on media
  2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
                   ` (12 preceding siblings ...)
  2021-11-24 19:13 ` [PATCH 20/20] media: mxl5005s: drop some dead code Mauro Carvalho Chehab
@ 2021-11-24 19:23 ` Arnd Bergmann
  13 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2021-11-24 19:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linuxarm, Mauro Carvalho Chehab, Lad, Prabhakar, Andy Gross,
	Antti Palosaari, Bjorn Andersson, Hans Verkuil,
	Malcolm Priestley, Manivannan Sadhasivam, Matthias Brugger,
	Mauro Carvalho Chehab, Robert Foss, Todor Tomov, Linux ARM,
	linux-arm-msm, Linux Kernel Mailing List,
	Linux Media Mailing List, moderated list:ARM/Mediatek SoC...,
	llvm

On Wed, Nov 24, 2021 at 8:13 PM Mauro Carvalho Chehab
<mchehab+huawei@kernel.org> wrote:
>
> Currently, using clang with W=1 and CONFIG_WERROR causes media to break.
> This is reported by builder.linuxtv.org.
>
> This series solve the remaining issues.

I looked through my randconfig tree and found one more that I had
initially not sent
as I wasn't sure whether we want to fix
-Wtautological-constant-out-of-range-compare
warnings. I'll send it now, as all warnings of that type in other
drivers have been addressed.

        Arnd

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

* Re: [PATCH 17/20] media: qcom: camss: mark read reg function as __maybe_unused
  2021-11-24 19:13 ` [PATCH 17/20] media: qcom: camss: " Mauro Carvalho Chehab
@ 2021-11-25 10:58   ` Robert Foss
  0 siblings, 0 replies; 27+ messages in thread
From: Robert Foss @ 2021-11-25 10:58 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, Nathan Chancellor, Nick Desaulniers,
	Todor Tomov, linux-arm-msm, linux-kernel, linux-media, llvm

Thanks for submitting this Mauro.

On Wed, 24 Nov 2021 at 20:13, Mauro Carvalho Chehab
<mchehab+huawei@kernel.org> wrote:
>
> Such function is currently unused, but could be needed in the
> future. So, keep it, marking it as __maybe_unused, in order to
> avoid a clang W=1 error.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
>
>  drivers/media/platform/qcom/camss/camss-vfe-170.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c
> index 5c083d70d495..455ae1a819e6 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c
> @@ -191,7 +191,7 @@ static u32 vfe_hw_version(struct vfe_device *vfe)
>         return hw_version;
>  }
>
> -static inline void vfe_reg_clr(struct vfe_device *vfe, u32 reg, u32 clr_bits)
> +static inline void __maybe_unused vfe_reg_clr(struct vfe_device *vfe, u32 reg, u32 clr_bits)
>  {
>         u32 bits = readl_relaxed(vfe->base + reg);
>
> --
> 2.33.1
>

I've submitted a patch[1] for removing this function, with that patch
applied, this patch is no longer needed.

[1] https://lore.kernel.org/all/20211011121301.421410-1-robert.foss@linaro.org/

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

* Re: [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions
  2021-11-24 19:13 ` [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions Mauro Carvalho Chehab
@ 2021-11-25 21:18   ` Ismael Luceno
  2021-11-26 19:58   ` Nathan Chancellor
  1 sibling, 0 replies; 27+ messages in thread
From: Ismael Luceno @ 2021-11-25 21:18 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andrey Utkin, Anton Sviridenko,
	Bluecherry Maintainers, Mauro Carvalho Chehab, Nathan Chancellor,
	Nick Desaulniers, linux-kernel, linux-media, llvm

On 24/Nov/2021 20:13, Mauro Carvalho Chehab wrote:
> There are several unused helper macros there, meant to parse some
> fields.
> 
> While there's not wrong with that, it generates clang warnings
> with W=1, causing build to break with CONFIG_WERROR.
> 
> So, add __maybe_unused to fix such warnings.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> index 0abcad4e84fa..85eaf5d00e9b 100644
> --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> @@ -391,12 +391,12 @@ static int solo_send_desc(struct solo_enc_dev *solo_enc, int skip,
>  }
>  
>  /* Extract values from VOP header - VE_STATUSxx */
> -static inline int vop_interlaced(const vop_header *vh)
> +static inline __maybe_unused int vop_interlaced(const vop_header *vh)
>  {
>  	return (__le32_to_cpu((*vh)[0]) >> 30) & 1;
>  }
>  
> -static inline u8 vop_channel(const vop_header *vh)
> +static inline __maybe_unused u8 vop_channel(const vop_header *vh)
>  {
>  	return (__le32_to_cpu((*vh)[0]) >> 24) & 0x1F;
>  }
> @@ -411,12 +411,12 @@ static inline u32 vop_mpeg_size(const vop_header *vh)
>  	return __le32_to_cpu((*vh)[0]) & 0xFFFFF;
>  }
>  
> -static inline u8 vop_hsize(const vop_header *vh)
> +static inline u8 __maybe_unused vop_hsize(const vop_header *vh)
>  {
>  	return (__le32_to_cpu((*vh)[1]) >> 8) & 0xFF;
>  }
>  
> -static inline u8 vop_vsize(const vop_header *vh)
> +static inline u8 __maybe_unused vop_vsize(const vop_header *vh)
>  {
>  	return __le32_to_cpu((*vh)[1]) & 0xFF;
>  }
> @@ -436,12 +436,12 @@ static inline u32 vop_jpeg_size(const vop_header *vh)
>  	return __le32_to_cpu((*vh)[4]) & 0xFFFFF;
>  }
>  
> -static inline u32 vop_sec(const vop_header *vh)
> +static inline u32 __maybe_unused vop_sec(const vop_header *vh)
>  {
>  	return __le32_to_cpu((*vh)[5]);
>  }
>  
> -static inline u32 vop_usec(const vop_header *vh)
> +static inline __maybe_unused u32 vop_usec(const vop_header *vh)
>  {
>  	return __le32_to_cpu((*vh)[6]);
>  }
> -- 
> 2.33.1
> 

Acked-by: Ismael Luceno <ismael@iodev.co.uk>

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

* Re: [PATCH 01/20] media: adv7842: get rid of two unused functions
  2021-11-24 19:13 ` [PATCH 01/20] media: adv7842: get rid of two unused functions Mauro Carvalho Chehab
@ 2021-11-26 18:54   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 18:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Hans Verkuil, Mauro Carvalho Chehab,
	Nick Desaulniers, linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:04PM +0100, Mauro Carvalho Chehab wrote:
> Those functions just call a V4L2 core macro, and aren't used
> anywhere. Get rid of them, in order to avoid clang warnings with
> W=1.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/i2c/adv7842.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
> index 7f8acbdf0db4..9d6eed0f8281 100644
> --- a/drivers/media/i2c/adv7842.c
> +++ b/drivers/media/i2c/adv7842.c
> @@ -256,21 +256,11 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
>  	return &container_of(ctrl->handler, struct adv7842_state, hdl)->sd;
>  }
>  
> -static inline unsigned hblanking(const struct v4l2_bt_timings *t)
> -{
> -	return V4L2_DV_BT_BLANKING_WIDTH(t);
> -}
> -
>  static inline unsigned htotal(const struct v4l2_bt_timings *t)
>  {
>  	return V4L2_DV_BT_FRAME_WIDTH(t);
>  }
>  
> -static inline unsigned vblanking(const struct v4l2_bt_timings *t)
> -{
> -	return V4L2_DV_BT_BLANKING_HEIGHT(t);
> -}
> -
>  static inline unsigned vtotal(const struct v4l2_bt_timings *t)
>  {
>  	return V4L2_DV_BT_FRAME_HEIGHT(t);
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 02/20] media: saa7134-go7007: get rid of to_state() function
  2021-11-24 19:13 ` [PATCH 02/20] media: saa7134-go7007: get rid of to_state() function Mauro Carvalho Chehab
@ 2021-11-26 18:55   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 18:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Nick Desaulniers,
	linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:05PM +0100, Mauro Carvalho Chehab wrote:
> This is just an alias for container_of() and it is used only
> on a commented code. The commented code actually is an issue that
> require fixes, so, move the container_of() call to the commented
> code, and drop the unused function.
> 
> This way, a fix for the function could be added later without
> needing to re-add to_state() function.
> 
> This fixes a clang W=1 warning.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/pci/saa7134/saa7134-go7007.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c
> index f319edb39c0e..da83893ffee9 100644
> --- a/drivers/media/pci/saa7134/saa7134-go7007.c
> +++ b/drivers/media/pci/saa7134/saa7134-go7007.c
> @@ -56,11 +56,6 @@ struct saa7134_go7007 {
>  	dma_addr_t bottom_dma;
>  };
>  
> -static inline struct saa7134_go7007 *to_state(struct v4l2_subdev *sd)
> -{
> -	return container_of(sd, struct saa7134_go7007, sd);
> -}
> -
>  static const struct go7007_board_info board_voyager = {
>  	.flags		 = 0,
>  	.sensor_flags	 = GO7007_SENSOR_656 |
> @@ -385,7 +380,7 @@ MODULE_FIRMWARE("go7007/go7007tv.bin");
>  static int saa7134_go7007_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
>  {
>  #if 0
> -	struct saa7134_go7007 *saa = to_state(sd);
> +	struct saa7134_go7007 *saa = container_of(sd, struct saa7134_go7007, sd);
>  	struct saa7134_dev *dev = saa->dev;
>  
>  	return saa7134_s_std_internal(dev, NULL, norm);
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 04/20] media: drxd: drop offset var from DownloadMicrocode()
  2021-11-24 19:13 ` [PATCH 04/20] media: drxd: drop offset var from DownloadMicrocode() Mauro Carvalho Chehab
@ 2021-11-26 18:57   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 18:57 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Nick Desaulniers,
	linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:07PM +0100, Mauro Carvalho Chehab wrote:
> The offset is not needed, and it is never used, as the pointer
> itself is already incremented.
> 
> So, drop it, in order to solve a W=1 clang warning.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

I would expect GCC to warn about this as well.

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/dvb-frontends/drxd_hard.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
> index a7eb81df88c2..9860cae65f1c 100644
> --- a/drivers/media/dvb-frontends/drxd_hard.c
> +++ b/drivers/media/dvb-frontends/drxd_hard.c
> @@ -914,44 +914,36 @@ static int DownloadMicrocode(struct drxd_state *state,
>  	u32 Address;
>  	u16 nBlocks;
>  	u16 BlockSize;
> -	u32 offset = 0;
>  	int i, status = 0;
>  
>  	pSrc = (u8 *) pMCImage;
>  	/* We're not using Flags */
>  	/* Flags = (pSrc[0] << 8) | pSrc[1]; */
>  	pSrc += sizeof(u16);
> -	offset += sizeof(u16);
>  	nBlocks = (pSrc[0] << 8) | pSrc[1];
>  	pSrc += sizeof(u16);
> -	offset += sizeof(u16);
>  
>  	for (i = 0; i < nBlocks; i++) {
>  		Address = (pSrc[0] << 24) | (pSrc[1] << 16) |
>  		    (pSrc[2] << 8) | pSrc[3];
>  		pSrc += sizeof(u32);
> -		offset += sizeof(u32);
>  
>  		BlockSize = ((pSrc[0] << 8) | pSrc[1]) * sizeof(u16);
>  		pSrc += sizeof(u16);
> -		offset += sizeof(u16);
>  
>  		/* We're not using Flags */
>  		/* u16 Flags = (pSrc[0] << 8) | pSrc[1]; */
>  		pSrc += sizeof(u16);
> -		offset += sizeof(u16);
>  
>  		/* We're not using BlockCRC */
>  		/* u16 BlockCRC = (pSrc[0] << 8) | pSrc[1]; */
>  		pSrc += sizeof(u16);
> -		offset += sizeof(u16);
>  
>  		status = WriteBlock(state, Address, BlockSize,
>  				    pSrc, DRX_I2C_CLEARCRC);
>  		if (status < 0)
>  			break;
>  		pSrc += BlockSize;
> -		offset += BlockSize;
>  	}
>  
>  	return status;
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 06/20] media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk()
  2021-11-24 19:13 ` [PATCH 06/20] media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk() Mauro Carvalho Chehab
@ 2021-11-26 19:40   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 19:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Antti Palosaari, Mauro Carvalho Chehab,
	Nick Desaulniers, linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:09PM +0100, Mauro Carvalho Chehab wrote:
> This vaklue is never used at the code. So, drop it.

       ^ value

> Solves a W=1 clang warning.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

I would expect GCC to warn about this as well.

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/dvb-frontends/m88ds3103.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
> index 02e8aa11e36e..bce0f42f3d19 100644
> --- a/drivers/media/dvb-frontends/m88ds3103.c
> +++ b/drivers/media/dvb-frontends/m88ds3103.c
> @@ -451,7 +451,7 @@ static int m88ds3103b_select_mclk(struct m88ds3103_dev *dev)
>  
>  static int m88ds3103b_set_mclk(struct m88ds3103_dev *dev, u32 mclk_khz)
>  {
> -	u8 reg11 = 0x0A, reg15, reg16, reg1D, reg1E, reg1F, tmp;
> +	u8 reg15, reg16, reg1D, reg1E, reg1F, tmp;
>  	u8 sm, f0 = 0, f1 = 0, f2 = 0, f3 = 0;
>  	u16 pll_div_fb, N;
>  	u32 div;
> @@ -480,8 +480,6 @@ static int m88ds3103b_set_mclk(struct m88ds3103_dev *dev, u32 mclk_khz)
>  	div /= mclk_khz;
>  
>  	if (dev->cfg->ts_mode == M88DS3103_TS_SERIAL) {
> -		reg11 |= 0x02;
> -
>  		if (div <= 32) {
>  			N = 2;
>  
> @@ -532,8 +530,6 @@ static int m88ds3103b_set_mclk(struct m88ds3103_dev *dev, u32 mclk_khz)
>  		else if ((f3 < 8) && (f3 != 0))
>  			f3 = 8;
>  	} else {
> -		reg11 &= ~0x02;
> -
>  		if (div <= 32) {
>  			N = 2;
>  
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions
  2021-11-24 19:13 ` [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions Mauro Carvalho Chehab
  2021-11-25 21:18   ` Ismael Luceno
@ 2021-11-26 19:58   ` Nathan Chancellor
  2021-11-29  8:44     ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 19:58 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andrey Utkin, Anton Sviridenko,
	Bluecherry Maintainers, Ismael Luceno, Mauro Carvalho Chehab,
	Nick Desaulniers, linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:11PM +0100, Mauro Carvalho Chehab wrote:
> There are several unused helper macros there, meant to parse some
> fields.
> 
> While there's not wrong with that, it generates clang warnings
> with W=1, causing build to break with CONFIG_WERROR.
> 
> So, add __maybe_unused to fix such warnings.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

I'll comment on this one patch but my opinion applies for all the
patches adding '__maybe_unused' to truly unused functions.

I agree with Laurent's comment [1]: unless this code is going to be used
soon, it should be deleted and resurrected when it is actually needed.
We have git for a reason and by adding this attribute, you are making it
harder to catch and eliminate unused functions, as no compiler will
catch them with an unused attribute (it is possible other static
analysis tools will but I doubt those are run as frequently as compilers
with W=1).

However, you are the maintainer so if you really want to keep these
around, I would recommend adding '__always_unused' instead of
'__maybe_unused' for documentation and auditing purposes, even though
they evaluate to the same thing:

$ rg __always_unused | wc -l
337

$ rg __maybe_unused | wc -l
4335

[1]: https://lore.kernel.org/r/YZtpnjPcGxVwhe61@pendragon.ideasonboard.com/

Cheers,
Nathan

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> index 0abcad4e84fa..85eaf5d00e9b 100644
> --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> @@ -391,12 +391,12 @@ static int solo_send_desc(struct solo_enc_dev *solo_enc, int skip,
>  }
>  
>  /* Extract values from VOP header - VE_STATUSxx */
> -static inline int vop_interlaced(const vop_header *vh)
> +static inline __maybe_unused int vop_interlaced(const vop_header *vh)
>  {
>  	return (__le32_to_cpu((*vh)[0]) >> 30) & 1;
>  }
>  
> -static inline u8 vop_channel(const vop_header *vh)
> +static inline __maybe_unused u8 vop_channel(const vop_header *vh)
>  {
>  	return (__le32_to_cpu((*vh)[0]) >> 24) & 0x1F;
>  }
> @@ -411,12 +411,12 @@ static inline u32 vop_mpeg_size(const vop_header *vh)
>  	return __le32_to_cpu((*vh)[0]) & 0xFFFFF;
>  }
>  
> -static inline u8 vop_hsize(const vop_header *vh)
> +static inline u8 __maybe_unused vop_hsize(const vop_header *vh)
>  {
>  	return (__le32_to_cpu((*vh)[1]) >> 8) & 0xFF;
>  }
>  
> -static inline u8 vop_vsize(const vop_header *vh)
> +static inline u8 __maybe_unused vop_vsize(const vop_header *vh)
>  {
>  	return __le32_to_cpu((*vh)[1]) & 0xFF;
>  }
> @@ -436,12 +436,12 @@ static inline u32 vop_jpeg_size(const vop_header *vh)
>  	return __le32_to_cpu((*vh)[4]) & 0xFFFFF;
>  }
>  
> -static inline u32 vop_sec(const vop_header *vh)
> +static inline u32 __maybe_unused vop_sec(const vop_header *vh)
>  {
>  	return __le32_to_cpu((*vh)[5]);
>  }
>  
> -static inline u32 vop_usec(const vop_header *vh)
> +static inline __maybe_unused u32 vop_usec(const vop_header *vh)
>  {
>  	return __le32_to_cpu((*vh)[6]);
>  }
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 09/20] media: si470x: fix printk warnings with clang
  2021-11-24 19:13 ` [PATCH 09/20] media: si470x: fix printk warnings with clang Mauro Carvalho Chehab
@ 2021-11-26 20:13   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 20:13 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Hans Verkuil, Kees Cook,
	Mauro Carvalho Chehab, Nick Desaulniers, linux-kernel,
	linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:12PM +0100, Mauro Carvalho Chehab wrote:
> Clang doesn't like "%hu" on macros:
> 
> 	drivers/media/radio/si470x/radio-si470x-i2c.c:414:4: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
> 	drivers/media/radio/si470x/radio-si470x-i2c.c:417:4: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
> 
> So, just replace them with "%u".
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Maybe worth mentioning commit cbacb5ab0aa0 ("docs: printk-formats: Stop
encouraging use of unnecessary %h[xudi] and %hh[xudi]")?

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/radio/si470x/radio-si470x-i2c.c | 4 ++--
>  drivers/media/radio/si470x/radio-si470x-usb.c | 8 ++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
> index a972c0705ac7..7ea7c6326f53 100644
> --- a/drivers/media/radio/si470x/radio-si470x-i2c.c
> +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
> @@ -410,10 +410,10 @@ static int si470x_i2c_probe(struct i2c_client *client)
>  			radio->registers[DEVICEID], radio->registers[SI_CHIPID]);
>  	if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
>  		dev_warn(&client->dev,
> -			"This driver is known to work with firmware version %hu,\n",
> +			"This driver is known to work with firmware version %u,\n",
>  			RADIO_FW_VERSION);
>  		dev_warn(&client->dev,
> -			"but the device has firmware version %hu.\n",
> +			"but the device has firmware version %u.\n",
>  			radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
>  		version_warning = 1;
>  	}
> diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
> index 3f8634a46573..1e70e6971fe4 100644
> --- a/drivers/media/radio/si470x/radio-si470x-usb.c
> +++ b/drivers/media/radio/si470x/radio-si470x-usb.c
> @@ -681,10 +681,10 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
>  			radio->registers[DEVICEID], radio->registers[SI_CHIPID]);
>  	if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
>  		dev_warn(&intf->dev,
> -			"This driver is known to work with firmware version %hu,\n",
> +			"This driver is known to work with firmware version %u,\n",
>  			RADIO_FW_VERSION);
>  		dev_warn(&intf->dev,
> -			"but the device has firmware version %hu.\n",
> +			"but the device has firmware version %u.\n",
>  			radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
>  		version_warning = 1;
>  	}
> @@ -698,10 +698,10 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
>  			radio->software_version, radio->hardware_version);
>  	if (radio->hardware_version < RADIO_HW_VERSION) {
>  		dev_warn(&intf->dev,
> -			"This driver is known to work with hardware version %hu,\n",
> +			"This driver is known to work with hardware version %u,\n",
>  			RADIO_HW_VERSION);
>  		dev_warn(&intf->dev,
> -			"but the device has hardware version %hu.\n",
> +			"but the device has hardware version %u.\n",
>  			radio->hardware_version);
>  		version_warning = 1;
>  	}
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 11/20] media: lmedm04: don't ignore errors when setting a filter
  2021-11-24 19:13 ` [PATCH 11/20] media: lmedm04: don't ignore errors when setting a filter Mauro Carvalho Chehab
@ 2021-11-26 20:16   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 20:16 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Malcolm Priestley, Mauro Carvalho Chehab,
	Nick Desaulniers, linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:14PM +0100, Mauro Carvalho Chehab wrote:
> Solves a clang warning
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/usb/dvb-usb-v2/lmedm04.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
> index fe4d886442a4..8a34e6c0d6a6 100644
> --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
> +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
> @@ -423,6 +423,9 @@ static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
>  
>  	mutex_unlock(&d->i2c_mutex);
>  
> +	if (ret)
> +		return -EREMOTEIO;
> +
>  	return 0;
>  }
>  
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 20/20] media: mxl5005s: drop some dead code
  2021-11-24 19:13 ` [PATCH 20/20] media: mxl5005s: drop some dead code Mauro Carvalho Chehab
@ 2021-11-26 20:30   ` Nathan Chancellor
  0 siblings, 0 replies; 27+ messages in thread
From: Nathan Chancellor @ 2021-11-26 20:30 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Bixuan Cui, Mauro Carvalho Chehab,
	Nick Desaulniers, linux-kernel, linux-media, llvm

On Wed, Nov 24, 2021 at 08:13:23PM +0100, Mauro Carvalho Chehab wrote:
> As reported by clang (with W=1), the ctrlVal var is never used.
> 
> Yet, there are even some loops to estimate it. As this is dead
> code, remove it. If ever needed, someone could revert this
> patch.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> 
>  drivers/media/tuners/mxl5005s.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/drivers/media/tuners/mxl5005s.c b/drivers/media/tuners/mxl5005s.c
> index f6e82a8e7d37..ab4c43df9d18 100644
> --- a/drivers/media/tuners/mxl5005s.c
> +++ b/drivers/media/tuners/mxl5005s.c
> @@ -3414,9 +3414,8 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
>  	u32 value, u16 controlGroup)
>  {
>  	struct mxl5005s_state *state = fe->tuner_priv;
> -	u16 i, j, k;
> +	u16 i, j;
>  	u32 highLimit;
> -	u32 ctrlVal;
>  
>  	if (controlGroup == 1) /* Initial Control */ {
>  
> @@ -3432,9 +3431,6 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
>  							(u8)(state->Init_Ctrl[i].bit[j]),
>  							(u8)((value>>j) & 0x01));
>  					}
> -					ctrlVal = 0;
> -					for (k = 0; k < state->Init_Ctrl[i].size; k++)
> -						ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
>  				} else
>  					return -1;
>  			}
> @@ -3454,9 +3450,6 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
>  							(u8)(state->CH_Ctrl[i].bit[j]),
>  							(u8)((value>>j) & 0x01));
>  					}
> -					ctrlVal = 0;
> -					for (k = 0; k < state->CH_Ctrl[i].size; k++)
> -						ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
>  				} else
>  					return -1;
>  			}
> @@ -3477,11 +3470,6 @@ static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
>  							(u8)(state->MXL_Ctrl[i].bit[j]),
>  							(u8)((value>>j) & 0x01));
>  					}
> -					ctrlVal = 0;
> -					for (k = 0; k < state->MXL_Ctrl[i].size; k++)
> -						ctrlVal += state->
> -							MXL_Ctrl[i].val[k] *
> -							(1 << k);
>  				} else
>  					return -1;
>  			}
> -- 
> 2.33.1
> 
> 

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

* Re: [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions
  2021-11-26 19:58   ` Nathan Chancellor
@ 2021-11-29  8:44     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 27+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-29  8:44 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: linuxarm, mauro.chehab, Andrey Utkin, Anton Sviridenko,
	Bluecherry Maintainers, Ismael Luceno, Mauro Carvalho Chehab,
	Nick Desaulniers, linux-kernel, linux-media, llvm

Em Fri, 26 Nov 2021 12:58:33 -0700
Nathan Chancellor <nathan@kernel.org> escreveu:

> On Wed, Nov 24, 2021 at 08:13:11PM +0100, Mauro Carvalho Chehab wrote:
> > There are several unused helper macros there, meant to parse some
> > fields.
> > 
> > While there's not wrong with that, it generates clang warnings
> > with W=1, causing build to break with CONFIG_WERROR.
> > 
> > So, add __maybe_unused to fix such warnings.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>  
> 
> I'll comment on this one patch but my opinion applies for all the
> patches adding '__maybe_unused' to truly unused functions.
> 
> I agree with Laurent's comment [1]: unless this code is going to be used
> soon, it should be deleted and resurrected when it is actually needed.
> We have git for a reason and by adding this attribute, you are making it
> harder to catch and eliminate unused functions, as no compiler will
> catch them with an unused attribute (it is possible other static
> analysis tools will but I doubt those are run as frequently as compilers
> with W=1).

In this specific case (and on a few other patches on this series), those
macros are used to document a field. That's why I opted to keep it.

> 
> However, you are the maintainer so if you really want to keep these
> around, I would recommend adding '__always_unused' instead of
> '__maybe_unused' for documentation and auditing purposes, even though
> they evaluate to the same thing:
> 
> $ rg __always_unused | wc -l
> 337
> 
> $ rg __maybe_unused | wc -l
> 4335

Good point. I'll use __always_unused on such patches.

> 
> [1]: https://lore.kernel.org/r/YZtpnjPcGxVwhe61@pendragon.ideasonboard.com/
> 
> Cheers,
> Nathan
> 
> > ---
> > 
> > To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> > See [PATCH 00/20] at: https://lore.kernel.org/all/cover.1637781097.git.mchehab+huawei@kernel.org/
> > 
> >  drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> > index 0abcad4e84fa..85eaf5d00e9b 100644
> > --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> > +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> > @@ -391,12 +391,12 @@ static int solo_send_desc(struct solo_enc_dev *solo_enc, int skip,
> >  }
> >  
> >  /* Extract values from VOP header - VE_STATUSxx */
> > -static inline int vop_interlaced(const vop_header *vh)
> > +static inline __maybe_unused int vop_interlaced(const vop_header *vh)
> >  {
> >  	return (__le32_to_cpu((*vh)[0]) >> 30) & 1;
> >  }
> >  
> > -static inline u8 vop_channel(const vop_header *vh)
> > +static inline __maybe_unused u8 vop_channel(const vop_header *vh)
> >  {
> >  	return (__le32_to_cpu((*vh)[0]) >> 24) & 0x1F;
> >  }
> > @@ -411,12 +411,12 @@ static inline u32 vop_mpeg_size(const vop_header *vh)
> >  	return __le32_to_cpu((*vh)[0]) & 0xFFFFF;
> >  }
> >  
> > -static inline u8 vop_hsize(const vop_header *vh)
> > +static inline u8 __maybe_unused vop_hsize(const vop_header *vh)
> >  {
> >  	return (__le32_to_cpu((*vh)[1]) >> 8) & 0xFF;
> >  }
> >  
> > -static inline u8 vop_vsize(const vop_header *vh)
> > +static inline u8 __maybe_unused vop_vsize(const vop_header *vh)
> >  {
> >  	return __le32_to_cpu((*vh)[1]) & 0xFF;
> >  }
> > @@ -436,12 +436,12 @@ static inline u32 vop_jpeg_size(const vop_header *vh)
> >  	return __le32_to_cpu((*vh)[4]) & 0xFFFFF;
> >  }
> >  
> > -static inline u32 vop_sec(const vop_header *vh)
> > +static inline u32 __maybe_unused vop_sec(const vop_header *vh)
> >  {
> >  	return __le32_to_cpu((*vh)[5]);
> >  }
> >  
> > -static inline u32 vop_usec(const vop_header *vh)
> > +static inline __maybe_unused u32 vop_usec(const vop_header *vh)
> >  {
> >  	return __le32_to_cpu((*vh)[6]);
> >  }
> > -- 
> > 2.33.1
> > 
> >   



Thanks,
Mauro

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

end of thread, other threads:[~2021-11-29  8:44 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 19:13 [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Mauro Carvalho Chehab
2021-11-24 19:13 ` [PATCH 01/20] media: adv7842: get rid of two unused functions Mauro Carvalho Chehab
2021-11-26 18:54   ` Nathan Chancellor
2021-11-24 19:13 ` [PATCH 02/20] media: saa7134-go7007: get rid of to_state() function Mauro Carvalho Chehab
2021-11-26 18:55   ` Nathan Chancellor
2021-11-24 19:13 ` [PATCH 04/20] media: drxd: drop offset var from DownloadMicrocode() Mauro Carvalho Chehab
2021-11-26 18:57   ` Nathan Chancellor
2021-11-24 19:13 ` [PATCH 06/20] media: m88ds3103: drop reg11 calculus from m88ds3103b_select_mclk() Mauro Carvalho Chehab
2021-11-26 19:40   ` Nathan Chancellor
2021-11-24 19:13 ` [PATCH 08/20] media: solo6x10: add _maybe_unused to currently unused functions Mauro Carvalho Chehab
2021-11-25 21:18   ` Ismael Luceno
2021-11-26 19:58   ` Nathan Chancellor
2021-11-29  8:44     ` Mauro Carvalho Chehab
2021-11-24 19:13 ` [PATCH 09/20] media: si470x: fix printk warnings with clang Mauro Carvalho Chehab
2021-11-26 20:13   ` Nathan Chancellor
2021-11-24 19:13 ` [PATCH 11/20] media: lmedm04: don't ignore errors when setting a filter Mauro Carvalho Chehab
2021-11-26 20:16   ` Nathan Chancellor
2021-11-24 19:13 ` [PATCH 13/20] media: adv7604 add _maybe_unused to currently unused functions Mauro Carvalho Chehab
2021-11-24 19:13 ` [PATCH 15/20] media: imx290: mark read reg function as __maybe_unused Mauro Carvalho Chehab
2021-11-24 19:13 ` [PATCH 16/20] media: davinci: vpbe_osd: " Mauro Carvalho Chehab
2021-11-24 19:13 ` [PATCH 17/20] media: qcom: camss: " Mauro Carvalho Chehab
2021-11-25 10:58   ` Robert Foss
2021-11-24 19:13 ` [PATCH 18/20] media: mtk-mdp: address a clang warning Mauro Carvalho Chehab
2021-11-24 19:21   ` Arnd Bergmann
2021-11-24 19:13 ` [PATCH 20/20] media: mxl5005s: drop some dead code Mauro Carvalho Chehab
2021-11-26 20:30   ` Nathan Chancellor
2021-11-24 19:23 ` [PATCH 00/20] Solve the remaining issues with clang and W=1 on media Arnd Bergmann

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