Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 2/2] block: sed-opal: fix sparse warning: convert __be64 data
@ 2019-10-03  2:23 Randy Dunlap
  2019-10-03 15:40 ` Scott Bauer
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2019-10-03  2:23 UTC (permalink / raw)
  To: linux-block, LKML, axboe; +Cc: Scott Bauer, Rafael Antognolli

From: Randy Dunlap <rdunlap@infradead.org>

sparse warns about incorrect type when using __be64 data.
It is not being converted to CPU-endian but it should be.

Fixes these sparse warnings:

../block/sed-opal.c:375:20: warning: incorrect type in assignment (different base types)
../block/sed-opal.c:375:20:    expected unsigned long long [usertype] align
../block/sed-opal.c:375:20:    got restricted __be64 const [usertype] alignment_granularity
../block/sed-opal.c:376:25: warning: incorrect type in assignment (different base types)
../block/sed-opal.c:376:25:    expected unsigned long long [usertype] lowest_lba
../block/sed-opal.c:376:25:    got restricted __be64 const [usertype] lowest_aligned_lba

Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Scott Bauer <scott.bauer@intel.com>
Cc: Rafael Antognolli <rafael.antognolli@intel.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
---
If this code is known to work as is, it would be nice to have an
explanation of it.  Oh: maybe it's just that these fields are not
used after they are saved/set.

 block/sed-opal.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- lnx-54-rc1.orig/block/sed-opal.c
+++ lnx-54-rc1/block/sed-opal.c
@@ -372,8 +372,8 @@ static void check_geometry(struct opal_d
 {
 	const struct d0_geometry_features *geo = data;
 
-	dev->align = geo->alignment_granularity;
-	dev->lowest_lba = geo->lowest_aligned_lba;
+	dev->align = be64_to_cpu(geo->alignment_granularity);
+	dev->lowest_lba = be64_to_cpu(geo->lowest_aligned_lba);
 }
 
 static int execute_step(struct opal_dev *dev,



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

* Re: [PATCH 2/2] block: sed-opal: fix sparse warning: convert __be64 data
  2019-10-03  2:23 [PATCH 2/2] block: sed-opal: fix sparse warning: convert __be64 data Randy Dunlap
@ 2019-10-03 15:40 ` Scott Bauer
  2019-10-03 17:06   ` Derrick, Jonathan
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Bauer @ 2019-10-03 15:40 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: linux-block, LKML, axboe, Scott Bauer, jonathan.derrick,
	revanth.rajashekar

On Wed, Oct 02, 2019 at 07:23:15PM -0700, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> sparse warns about incorrect type when using __be64 data.
> It is not being converted to CPU-endian but it should be.
> 
> Fixes these sparse warnings:
> 
> ../block/sed-opal.c:375:20: warning: incorrect type in assignment (different base types)
> ../block/sed-opal.c:375:20:    expected unsigned long long [usertype] align
> ../block/sed-opal.c:375:20:    got restricted __be64 const [usertype] alignment_granularity
> ../block/sed-opal.c:376:25: warning: incorrect type in assignment (different base types)
> ../block/sed-opal.c:376:25:    expected unsigned long long [usertype] lowest_lba
> ../block/sed-opal.c:376:25:    got restricted __be64 const [usertype] lowest_aligned_lba
> 
> Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Scott Bauer <scott.bauer@intel.com>
> Cc: Rafael Antognolli <rafael.antognolli@intel.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: linux-block@vger.kernel.org

+ Jon and Revanth,


These look fine. They're currently unused, but may be useful in the future for sysfs or what ever else we add in.

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

* Re: [PATCH 2/2] block: sed-opal: fix sparse warning: convert __be64 data
  2019-10-03 15:40 ` Scott Bauer
@ 2019-10-03 17:06   ` Derrick, Jonathan
  0 siblings, 0 replies; 3+ messages in thread
From: Derrick, Jonathan @ 2019-10-03 17:06 UTC (permalink / raw)
  To: rdunlap, sbauer; +Cc: linux-kernel, linux-block, Rajashekar, Revanth, axboe

On Thu, 2019-10-03 at 11:40 -0400, Scott Bauer wrote:
> On Wed, Oct 02, 2019 at 07:23:15PM -0700, Randy Dunlap wrote:
> > From: Randy Dunlap <rdunlap@infradead.org>
> > 
> > sparse warns about incorrect type when using __be64 data.
> > It is not being converted to CPU-endian but it should be.
> > 
> > Fixes these sparse warnings:
> > 
> > ../block/sed-opal.c:375:20: warning: incorrect type in assignment (different base types)
> > ../block/sed-opal.c:375:20:    expected unsigned long long [usertype] align
> > ../block/sed-opal.c:375:20:    got restricted __be64 const [usertype] alignment_granularity
> > ../block/sed-opal.c:376:25: warning: incorrect type in assignment (different base types)
> > ../block/sed-opal.c:376:25:    expected unsigned long long [usertype] lowest_lba
> > ../block/sed-opal.c:376:25:    got restricted __be64 const [usertype] lowest_aligned_lba
> > 
> > Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
> > Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> > Cc: Scott Bauer <scott.bauer@intel.com>
> > Cc: Rafael Antognolli <rafael.antognolli@intel.com>
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: linux-block@vger.kernel.org
> 
> + Jon and Revanth,
> 
> 
> These look fine. They're currently unused, but may be useful in the future for sysfs or what ever else we add in.

I imagine modern devices with logical/physical indirection would
probably report gran=1 and lowest=0 regardless.

Either way,
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03  2:23 [PATCH 2/2] block: sed-opal: fix sparse warning: convert __be64 data Randy Dunlap
2019-10-03 15:40 ` Scott Bauer
2019-10-03 17:06   ` Derrick, Jonathan

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git