public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Andy Shevchenko <andy@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tiffany Lin <tiffany.lin@mediatek.com>,
	Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
	Yunfei Dong <yunfei.dong@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, linux-staging@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 1/3] media: cx231xx: Convert enum into a define
Date: Tue, 3 Dec 2024 09:31:20 +0100	[thread overview]
Message-ID: <20241203093114.0ca49c01@foz.lan> (raw)
In-Reply-To: <20241202-fix-llvm9-v1-1-2a50f5acfd0b@chromium.org>

Em Mon, 02 Dec 2024 15:47:15 +0000
Ricardo Ribalda <ribalda@chromium.org> escreveu:

> The code is running arithmentics with the enum, which when not done with
> care makes the compiler a bit nervous.
> 
> Because those enums are only used as defines (no argument or variable
> from that enumeration type), convert it into a define and move on.
> 
> It is required to build with llvm 9 without these warnings:
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:673:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:680:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:687:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:702:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:709:21: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:718:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:727:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:737:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]
> drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:749:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h
> index 5bc44f194d0a..62ffa16bb82c 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h
> +++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h
> @@ -57,19 +57,17 @@ enum USB_SPEED{
>  };
>  
>  #define TS_MASK         0x6
> -enum TS_PORT{
> -	NO_TS_PORT = 0x0,	/* 2'b00: Neither port used. PCB not a Hybrid,
> +#define NO_TS_PORT	0x0	/* 2'b00: Neither port used. PCB not a Hybrid,
>  				   only offers Analog TV or Video */
> -	TS1_PORT = 0x4,		/* 2'b10: TS1 Input (Hybrid mode :
> +#define TS1_PORT	0x4	/* 2'b10: TS1 Input (Hybrid mode :
>  				Digital or External Analog/Compressed source) */
> -	TS1_TS2_PORT = 0x6,	/* 2'b11: TS1 & TS2 Inputs
> +#define TS1_TS2_PORT	0x6	/* 2'b11: TS1 & TS2 Inputs
>  				(Dual inputs from Digital and/or
>  				External Analog/Compressed sources) */
> -	TS1_EXT_CLOCK = 0x6,	/* 2'b11: TS1 & TS2 as selector
> +#define TS1_EXT_CLOCK	0x6	/* 2'b11: TS1 & TS2 as selector
>  						to external clock */
> -	TS1VIP_TS2_PORT = 0x2	/* 2'b01: TS1 used as 656/VIP Output,
> +#define TS1VIP_TS2_PORT 0x2	/* 2'b01: TS1 used as 656/VIP Output,
>  				   TS2 Input (from Compressor) */
> -};
>  
>  #define EAVP_MASK       0x8
>  enum EAV_PRESENT{
> @@ -89,10 +87,8 @@ enum AT_MODE{
>  };
>  
>  #define PWR_SEL_MASK    0x40
> -enum POWE_TYPE{
> -	SELF_POWER = 0x0,	/* 0: self power */
> -	BUS_POWER = 0x40	/* 1: bus power */
> -};
> +#define SELF_POWER	0x0	/* 0: self power */
> +#define BUS_POWER	0x40	/* 1: bus power */
>  
>  enum USB_POWE_TYPE{
>  	USB_SELF_POWER = 0,
> 

IMO keeping them into enums are a lot better than defines.

Perhaps the right thing would be to join both enums here.


Thanks,
Mauro

  reply	other threads:[~2024-12-03  8:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 15:47 [PATCH 0/3] media: Fix warnings with llvm9 Ricardo Ribalda
2024-12-02 15:47 ` [PATCH 1/3] media: cx231xx: Convert enum into a define Ricardo Ribalda
2024-12-03  8:31   ` Mauro Carvalho Chehab [this message]
2025-02-20 13:55     ` Hans Verkuil
2025-02-20 14:06       ` Andy Shevchenko
2025-02-20 15:12         ` Hans Verkuil
2025-02-20 15:25           ` Andy Shevchenko
2024-12-02 15:47 ` [PATCH 2/3] media: atomisp: Use the actual value of the enum instead of the enum Ricardo Ribalda
2024-12-02 16:14   ` Andy Shevchenko
2024-12-02 15:47 ` [PATCH 3/3] media: mediatek: vcodec: Workaround a compiler warning Ricardo Ribalda
2024-12-02 16:24   ` Nathan Chancellor
2024-12-02 17:26     ` Ricardo Ribalda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241203093114.0ca49c01@foz.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=andy@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=justinstitt@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=llvm@lists.linux.dev \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=ribalda@chromium.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tiffany.lin@mediatek.com \
    --cc=yunfei.dong@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox