diff mbox series

[v4,02/31] scsi: pm8001: Fix __iomem pointer use in pm8001_phy_control()

Message ID 20220217132956.484818-3-damien.lemoal@opensource.wdc.com (mailing list archive)
State Superseded
Headers show
Series libsas and pm8001 fixes | expand

Commit Message

Damien Le Moal Feb. 17, 2022, 1:29 p.m. UTC
Avoid the sparse warning "warning: cast removes address space '__iomem'
of expression" by declaring the qp pointer as "u32 __iomem *".
Accordingly, change the accesses to the qp array to use readl().

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/scsi/pm8001/pm8001_sas.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

Jinpu Wang Feb. 17, 2022, 7:01 p.m. UTC | #1
On Thu, Feb 17, 2022 at 2:30 PM Damien Le Moal
<damien.lemoal@opensource.wdc.com> wrote:
>
> Avoid the sparse warning "warning: cast removes address space '__iomem'
> of expression" by declaring the qp pointer as "u32 __iomem *".
> Accordingly, change the accesses to the qp array to use readl().
>
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
looks good to me.
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
thx!
> ---
>  drivers/scsi/pm8001/pm8001_sas.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index 8c12fbb9c476..4ab0ea9483f2 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -234,14 +234,13 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>                 }
>                 {
>                         struct sas_phy *phy = sas_phy->phy;
> -                       uint32_t *qp = (uint32_t *)(((char *)
> -                               pm8001_ha->io_mem[2].memvirtaddr)
> -                               + 0x1034 + (0x4000 * (phy_id & 3)));
> -
> -                       phy->invalid_dword_count = qp[0];
> -                       phy->running_disparity_error_count = qp[1];
> -                       phy->loss_of_dword_sync_count = qp[3];
> -                       phy->phy_reset_problem_count = qp[4];
> +                       u32 __iomem *qp = pm8001_ha->io_mem[2].memvirtaddr
> +                               + 0x1034 + (0x4000 * (phy_id & 3));
> +
> +                       phy->invalid_dword_count = readl(qp);
> +                       phy->running_disparity_error_count = readl(&qp[1]);
> +                       phy->loss_of_dword_sync_count = readl(&qp[3]);
> +                       phy->phy_reset_problem_count = readl(&qp[4]);
>                 }
>                 if (pm8001_ha->chip_id == chip_8001)
>                         pm8001_bar4_shift(pm8001_ha, 0);
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 8c12fbb9c476..4ab0ea9483f2 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -234,14 +234,13 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 		}
 		{
 			struct sas_phy *phy = sas_phy->phy;
-			uint32_t *qp = (uint32_t *)(((char *)
-				pm8001_ha->io_mem[2].memvirtaddr)
-				+ 0x1034 + (0x4000 * (phy_id & 3)));
-
-			phy->invalid_dword_count = qp[0];
-			phy->running_disparity_error_count = qp[1];
-			phy->loss_of_dword_sync_count = qp[3];
-			phy->phy_reset_problem_count = qp[4];
+			u32 __iomem *qp = pm8001_ha->io_mem[2].memvirtaddr
+				+ 0x1034 + (0x4000 * (phy_id & 3));
+
+			phy->invalid_dword_count = readl(qp);
+			phy->running_disparity_error_count = readl(&qp[1]);
+			phy->loss_of_dword_sync_count = readl(&qp[3]);
+			phy->phy_reset_problem_count = readl(&qp[4]);
 		}
 		if (pm8001_ha->chip_id == chip_8001)
 			pm8001_bar4_shift(pm8001_ha, 0);