misc: eeprom/idt_89hpesx: Convert data structures to LE explicitly

Message ID 20240130040632.3039911-1-dawei.li@shingroup.cn
State New
Headers
Series misc: eeprom/idt_89hpesx: Convert data structures to LE explicitly |

Commit Message

Dawei Li Jan. 30, 2024, 4:06 a.m. UTC
  For data structures needs cpu_to_le* conversion, its prototype needs to
be declared with __le* explicitly.

Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
Cc: <stable@vger.kernel.org>
---
 drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Serge Semin Jan. 30, 2024, 9:54 a.m. UTC | #1
On Tue, Jan 30, 2024 at 12:06:32PM +0800, Dawei Li wrote:
> For data structures needs cpu_to_le* conversion, its prototype needs to
> be declared with __le* explicitly.
> 
> Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> Cc: <stable@vger.kernel.org>

Awesome! Thanks for the patch. Definitely

Reviewed-by: Serge Semin <fancer.lancer@gmail.com>

-Serge(y)

> ---
>  drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
> index d807d08e2614..327afb866b21 100644
> --- a/drivers/misc/eeprom/idt_89hpesx.c
> +++ b/drivers/misc/eeprom/idt_89hpesx.c
> @@ -129,7 +129,7 @@ struct idt_smb_seq {
>  struct idt_eeprom_seq {
>  	u8 cmd;
>  	u8 eeaddr;
> -	u16 memaddr;
> +	__le16 memaddr;
>  	u8 data;
>  } __packed;
>  
> @@ -141,8 +141,8 @@ struct idt_eeprom_seq {
>   */
>  struct idt_csr_seq {
>  	u8 cmd;
> -	u16 csraddr;
> -	u32 data;
> +	__le16 csraddr;
> +	__le32 data;
>  } __packed;
>  
>  /*
> -- 
> 2.27.0
>
  
Greg KH Jan. 30, 2024, 2:04 p.m. UTC | #2
On Tue, Jan 30, 2024 at 12:06:32PM +0800, Dawei Li wrote:
> For data structures needs cpu_to_le* conversion, its prototype needs to
> be declared with __le* explicitly.
> 
> Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> Cc: <stable@vger.kernel.org>
> ---
>  drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
> index d807d08e2614..327afb866b21 100644
> --- a/drivers/misc/eeprom/idt_89hpesx.c
> +++ b/drivers/misc/eeprom/idt_89hpesx.c
> @@ -129,7 +129,7 @@ struct idt_smb_seq {
>  struct idt_eeprom_seq {
>  	u8 cmd;
>  	u8 eeaddr;
> -	u16 memaddr;
> +	__le16 memaddr;
>  	u8 data;
>  } __packed;
>  
> @@ -141,8 +141,8 @@ struct idt_eeprom_seq {
>   */
>  struct idt_csr_seq {
>  	u8 cmd;
> -	u16 csraddr;
> -	u32 data;
> +	__le16 csraddr;
> +	__le32 data;
>  } __packed;
>  
>  /*

Declaring them this way is nice, but this doesn't actually "fix"
anything at all as no code is actually changed.

So how is ths a bugfix?  How does this patch do anything?

confused,

greg k-h
  
Dawei Li Jan. 31, 2024, 1:34 a.m. UTC | #3
Hi Greg,

Thanks for reviewing.

On Tue, Jan 30, 2024 at 06:04:17AM -0800, Greg KH wrote:
> On Tue, Jan 30, 2024 at 12:06:32PM +0800, Dawei Li wrote:
> > For data structures needs cpu_to_le* conversion, its prototype needs to
> > be declared with __le* explicitly.
> > 
> > Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
> > Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> > Cc: <stable@vger.kernel.org>
> > ---
> >  drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
> > index d807d08e2614..327afb866b21 100644
> > --- a/drivers/misc/eeprom/idt_89hpesx.c
> > +++ b/drivers/misc/eeprom/idt_89hpesx.c
> > @@ -129,7 +129,7 @@ struct idt_smb_seq {
> >  struct idt_eeprom_seq {
> >  	u8 cmd;
> >  	u8 eeaddr;
> > -	u16 memaddr;
> > +	__le16 memaddr;
> >  	u8 data;
> >  } __packed;
> >  
> > @@ -141,8 +141,8 @@ struct idt_eeprom_seq {
> >   */
> >  struct idt_csr_seq {
> >  	u8 cmd;
> > -	u16 csraddr;
> > -	u32 data;
> > +	__le16 csraddr;
> > +	__le32 data;
> >  } __packed;
> >  
> >  /*
> 
> Declaring them this way is nice, but this doesn't actually "fix"
> anything at all as no code is actually changed.
> 
> So how is ths a bugfix?  How does this patch do anything?
> 
> confused,

Sorry for the confuson.

This commit is to address the issue reported by kernel test rebot[1].

Partially quoted from it:

sparse warnings: (new ones prefixed by >>)
>> drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] memaddr @@     got restricted __le16 [usertype] @@
   drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:     expected unsigned short [addressable] [assigned] [usertype] memaddr
   drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:     got restricted __le16 [usertype]
   drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] memaddr @@     got restricted __le16 [usertype] @@
   drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse:     expected unsigned short [addressable] [assigned] [usertype] memaddr
   drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse:     got restricted __le16 [usertype]
>> drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] csraddr @@     got restricted __le16 [usertype] @@
   drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse:     expected unsigned short [addressable] [assigned] [usertype] csraddr
   drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse:     got restricted __le16 [usertype]
>> drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [addressable] [assigned] [usertype] data @@     got restricted __le32 [usertype] @@
   drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse:     expected unsigned int [addressable] [assigned] [usertype] data
   drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse:     got restricted __le32 [usertype]
   drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] csraddr @@     got restricted __le16 [usertype] @@
   drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse:     expected unsigned short [addressable] [assigned] [usertype] csraddr
   drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse:     got restricted __le16 [usertype]
>> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
>> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
>> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
>> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
>> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
>> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32

[1] https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/

Thanks,

    Dawei

> 
> greg k-h
>
  
Greg KH Jan. 31, 2024, 2:07 a.m. UTC | #4
On Wed, Jan 31, 2024 at 09:34:52AM +0800, Dawei Li wrote:
> Hi Greg,
> 
> Thanks for reviewing.
> 
> On Tue, Jan 30, 2024 at 06:04:17AM -0800, Greg KH wrote:
> > On Tue, Jan 30, 2024 at 12:06:32PM +0800, Dawei Li wrote:
> > > For data structures needs cpu_to_le* conversion, its prototype needs to
> > > be declared with __le* explicitly.
> > > 
> > > Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
> > > Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> > > Cc: <stable@vger.kernel.org>
> > > ---
> > >  drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
> > > index d807d08e2614..327afb866b21 100644
> > > --- a/drivers/misc/eeprom/idt_89hpesx.c
> > > +++ b/drivers/misc/eeprom/idt_89hpesx.c
> > > @@ -129,7 +129,7 @@ struct idt_smb_seq {
> > >  struct idt_eeprom_seq {
> > >  	u8 cmd;
> > >  	u8 eeaddr;
> > > -	u16 memaddr;
> > > +	__le16 memaddr;
> > >  	u8 data;
> > >  } __packed;
> > >  
> > > @@ -141,8 +141,8 @@ struct idt_eeprom_seq {
> > >   */
> > >  struct idt_csr_seq {
> > >  	u8 cmd;
> > > -	u16 csraddr;
> > > -	u32 data;
> > > +	__le16 csraddr;
> > > +	__le32 data;
> > >  } __packed;
> > >  
> > >  /*
> > 
> > Declaring them this way is nice, but this doesn't actually "fix"
> > anything at all as no code is actually changed.
> > 
> > So how is ths a bugfix?  How does this patch do anything?
> > 
> > confused,
> 
> Sorry for the confuson.
> 
> This commit is to address the issue reported by kernel test rebot[1].
> 
> Partially quoted from it:
> 
> sparse warnings: (new ones prefixed by >>)
> >> drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] memaddr @@     got restricted __le16 [usertype] @@
>    drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:     expected unsigned short [addressable] [assigned] [usertype] memaddr
>    drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:     got restricted __le16 [usertype]
>    drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] memaddr @@     got restricted __le16 [usertype] @@
>    drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse:     expected unsigned short [addressable] [assigned] [usertype] memaddr
>    drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse:     got restricted __le16 [usertype]
> >> drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] csraddr @@     got restricted __le16 [usertype] @@
>    drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse:     expected unsigned short [addressable] [assigned] [usertype] csraddr
>    drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse:     got restricted __le16 [usertype]
> >> drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [addressable] [assigned] [usertype] data @@     got restricted __le32 [usertype] @@
>    drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse:     expected unsigned int [addressable] [assigned] [usertype] data
>    drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse:     got restricted __le32 [usertype]
>    drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] csraddr @@     got restricted __le16 [usertype] @@
>    drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse:     expected unsigned short [addressable] [assigned] [usertype] csraddr
>    drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse:     got restricted __le16 [usertype]
> >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> 
> [1] https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/

Ok, so this fixes a sparse issue, how is that needed for stable kernels?

Please be more explicit about what you are "fixing" in the changelog
please, as-is this didn't make any sense to me.

Please fix up and send a v2.

thanks,

greg k-h
  
Dawei Li Jan. 31, 2024, 2:19 a.m. UTC | #5
Hi Greg,

On Tue, Jan 30, 2024 at 06:07:18PM -0800, Greg KH wrote:
> On Wed, Jan 31, 2024 at 09:34:52AM +0800, Dawei Li wrote:
> > Hi Greg,
> > 
> > Thanks for reviewing.
> > 
> > On Tue, Jan 30, 2024 at 06:04:17AM -0800, Greg KH wrote:
> > > On Tue, Jan 30, 2024 at 12:06:32PM +0800, Dawei Li wrote:
> > > > For data structures needs cpu_to_le* conversion, its prototype needs to
> > > > be declared with __le* explicitly.
> > > > 
> > > > Fixes: cfad6425382e ("eeprom: Add IDT 89HPESx EEPROM/CSR driver")
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Closes: https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
> > > > Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> > > > Cc: <stable@vger.kernel.org>
> > > > ---
> > > >  drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
> > > > index d807d08e2614..327afb866b21 100644
> > > > --- a/drivers/misc/eeprom/idt_89hpesx.c
> > > > +++ b/drivers/misc/eeprom/idt_89hpesx.c
> > > > @@ -129,7 +129,7 @@ struct idt_smb_seq {
> > > >  struct idt_eeprom_seq {
> > > >  	u8 cmd;
> > > >  	u8 eeaddr;
> > > > -	u16 memaddr;
> > > > +	__le16 memaddr;
> > > >  	u8 data;
> > > >  } __packed;
> > > >  
> > > > @@ -141,8 +141,8 @@ struct idt_eeprom_seq {
> > > >   */
> > > >  struct idt_csr_seq {
> > > >  	u8 cmd;
> > > > -	u16 csraddr;
> > > > -	u32 data;
> > > > +	__le16 csraddr;
> > > > +	__le32 data;
> > > >  } __packed;
> > > >  
> > > >  /*
> > > 
> > > Declaring them this way is nice, but this doesn't actually "fix"
> > > anything at all as no code is actually changed.
> > > 
> > > So how is ths a bugfix?  How does this patch do anything?
> > > 
> > > confused,
> > 
> > Sorry for the confuson.
> > 
> > This commit is to address the issue reported by kernel test rebot[1].
> > 
> > Partially quoted from it:
> > 
> > sparse warnings: (new ones prefixed by >>)
> > >> drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] memaddr @@     got restricted __le16 [usertype] @@
> >    drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:     expected unsigned short [addressable] [assigned] [usertype] memaddr
> >    drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:     got restricted __le16 [usertype]
> >    drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] memaddr @@     got restricted __le16 [usertype] @@
> >    drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse:     expected unsigned short [addressable] [assigned] [usertype] memaddr
> >    drivers/misc/eeprom/idt_89hpesx.c:671:31: sparse:     got restricted __le16 [usertype]
> > >> drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] csraddr @@     got restricted __le16 [usertype] @@
> >    drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse:     expected unsigned short [addressable] [assigned] [usertype] csraddr
> >    drivers/misc/eeprom/idt_89hpesx.c:769:24: sparse:     got restricted __le16 [usertype]
> > >> drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [addressable] [assigned] [usertype] data @@     got restricted __le32 [usertype] @@
> >    drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse:     expected unsigned int [addressable] [assigned] [usertype] data
> >    drivers/misc/eeprom/idt_89hpesx.c:770:21: sparse:     got restricted __le32 [usertype]
> >    drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short [addressable] [assigned] [usertype] csraddr @@     got restricted __le16 [usertype] @@
> >    drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse:     expected unsigned short [addressable] [assigned] [usertype] csraddr
> >    drivers/misc/eeprom/idt_89hpesx.c:834:24: sparse:     got restricted __le16 [usertype]
> > >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> > >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> > >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> > >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> > >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> > >> drivers/misc/eeprom/idt_89hpesx.c:859:17: sparse: sparse: cast to restricted __le32
> > 
> > [1] https://lore.kernel.org/oe-kbuild-all/202401261250.b07Yt30Z-lkp@intel.com/
> 
> Ok, so this fixes a sparse issue, how is that needed for stable kernels?
> 
> Please be more explicit about what you are "fixing" in the changelog
> please, as-is this didn't make any sense to me.

Yes, it's my fault not making it clear in commit message. Sorry for
that.

> 
> Please fix up and send a v2.

Will do that.

> 
> thanks,
> 
> greg k-h
> 

Thanks,

    Dawei
  

Patch

diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
index d807d08e2614..327afb866b21 100644
--- a/drivers/misc/eeprom/idt_89hpesx.c
+++ b/drivers/misc/eeprom/idt_89hpesx.c
@@ -129,7 +129,7 @@  struct idt_smb_seq {
 struct idt_eeprom_seq {
 	u8 cmd;
 	u8 eeaddr;
-	u16 memaddr;
+	__le16 memaddr;
 	u8 data;
 } __packed;
 
@@ -141,8 +141,8 @@  struct idt_eeprom_seq {
  */
 struct idt_csr_seq {
 	u8 cmd;
-	u16 csraddr;
-	u32 data;
+	__le16 csraddr;
+	__le32 data;
 } __packed;
 
 /*