Message ID | 20220210114218.632725-9-damien.lemoal@opensource.wdc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | libsas and pm8001 fixes | expand |
On 10/02/2022 11:42, Damien Le Moal wrote: > Declare the local variable destination1 as a pointer to a __le32 value > rather than a u32. This suppresses the sparse warning: > > warning: incorrect type in assignment (different base types) > expected unsigned int [usertype] > got restricted __le32 [usertype] > > Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: John Garry <john.garry@huawei.com> > --- > drivers/scsi/pm8001/pm80xx_hwi.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c > index ec6b970e05a1..37ede7c79e85 100644 > --- a/drivers/scsi/pm8001/pm80xx_hwi.c > +++ b/drivers/scsi/pm8001/pm80xx_hwi.c > @@ -71,14 +71,13 @@ static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, > u32 dw_count, u32 bus_base_number) > { > u32 index, value, offset; > - u32 *destination1; > - destination1 = (u32 *)destination; > + __le32 *destination1 = (__le32 *)destination; > > for (index = 0; index < dw_count; index += 4, destination1++) { > offset = (soffset + index); > if (offset < (64 * 1024)) { > value = pm8001_cr32(pm8001_ha, bus_base_number, offset); > - *destination1 = cpu_to_le32(value); > + *destination1 = cpu_to_le32(value); I can't help but wonder if there is already something to do this, like memcpy_fromio() > } > } > return;
On Thu, Feb 10, 2022 at 08:42:06PM +0900, Damien Le Moal wrote: > +++ b/drivers/scsi/pm8001/pm80xx_hwi.c > @@ -71,14 +71,13 @@ static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, > u32 dw_count, u32 bus_base_number) > { > u32 index, value, offset; > - u32 *destination1; > - destination1 = (u32 *)destination; > + __le32 *destination1 = (__le32 *)destination; I think the right fix here is to declare the destination argument as a le32 pointer without the incorrect const attribute.
On 2/11/22 15:14, Christoph Hellwig wrote: > On Thu, Feb 10, 2022 at 08:42:06PM +0900, Damien Le Moal wrote: >> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c >> @@ -71,14 +71,13 @@ static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, >> u32 dw_count, u32 bus_base_number) >> { >> u32 index, value, offset; >> - u32 *destination1; >> - destination1 = (u32 *)destination; >> + __le32 *destination1 = (__le32 *)destination; > > I think the right fix here is to declare the destination argument as a > le32 pointer without the incorrect const attribute. Yes. Much cleaner :)
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ec6b970e05a1..37ede7c79e85 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -71,14 +71,13 @@ static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, u32 dw_count, u32 bus_base_number) { u32 index, value, offset; - u32 *destination1; - destination1 = (u32 *)destination; + __le32 *destination1 = (__le32 *)destination; for (index = 0; index < dw_count; index += 4, destination1++) { offset = (soffset + index); if (offset < (64 * 1024)) { value = pm8001_cr32(pm8001_ha, bus_base_number, offset); - *destination1 = cpu_to_le32(value); + *destination1 = cpu_to_le32(value); } } return;
Declare the local variable destination1 as a pointer to a __le32 value rather than a u32. This suppresses the sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] got restricted __le32 [usertype] Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> --- drivers/scsi/pm8001/pm80xx_hwi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)