diff mbox

[scsi,3/4] scsi: ufs: ufshcd_get_max_icc_level fix endianity handling

Message ID 1483605912-15041-3-git-send-email-tomas.winkler@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Winkler, Tomas Jan. 5, 2017, 8:45 a.m. UTC
Reading big endian value from a buffer requires explicit cast.
Fix sparse warning:
drivers/scsi/ufs/ufshcd.c:4825:24: warning: cast to restricted __be16

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

subhashj@codeaurora.org Jan. 11, 2017, 12:59 a.m. UTC | #1
On 2017-01-05 00:45, Tomas Winkler wrote:
> Reading big endian value from a buffer requires explicit cast.
> Fix sparse warning:
> drivers/scsi/ufs/ufshcd.c:4825:24: warning: cast to restricted __be16
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
>  drivers/scsi/ufs/ufshcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 63d7ae2c3be9..fdea08f79b7d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4822,7 +4822,7 @@ static u32 ufshcd_get_max_icc_level(int
> sup_curr_uA, u32 start_scan, char *buff)
>  	u16 unit;
> 
>  	for (i = start_scan; i >= 0; i--) {
> -		data = be16_to_cpu(*((u16 *)(buff + 2*i)));
> +		data = be16_to_cpup((__be16 *)&buff[2 * i]);
>  		unit = (data & ATTR_ICC_LVL_UNIT_MASK) >>
>  						ATTR_ICC_LVL_UNIT_OFFSET;
>  		curr_uA = data & ATTR_ICC_LVL_VALUE_MASK;


Looks good to me.
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
diff mbox

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 63d7ae2c3be9..fdea08f79b7d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4822,7 +4822,7 @@  static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, char *buff)
 	u16 unit;
 
 	for (i = start_scan; i >= 0; i--) {
-		data = be16_to_cpu(*((u16 *)(buff + 2*i)));
+		data = be16_to_cpup((__be16 *)&buff[2 * i]);
 		unit = (data & ATTR_ICC_LVL_UNIT_MASK) >>
 						ATTR_ICC_LVL_UNIT_OFFSET;
 		curr_uA = data & ATTR_ICC_LVL_VALUE_MASK;