Re: [PATCH v2 5/6] Misc: display unsigned hex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri,  4 Jan 2013 14:13:34 +0100, Amaury Decrême wrote:
> This patch corrects the display of unsigned hex values.
> 
> Signed-off-by: Amaury Decrême <amaury.decreme@xxxxxxxxx>
> ---
>  drivers/i2c/busses/i2c-sis630.c |   25 ++++++++++++++-----------
>  1 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
> index 792bb79..4bc970d 100644
> --- a/drivers/i2c/busses/i2c-sis630.c
> +++ b/drivers/i2c/busses/i2c-sis630.c
> @@ -152,18 +152,18 @@ static inline void sis630_write(u8 reg, u8 data)
>  
>  static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldclock)
>  {
> -        int temp;
> +	u8 temp;
>  
>  	/* Make sure the SMBus host is ready to start transmitting. */
>  	temp = sis630_read(SMB_CNT);
>  	if ((temp & (SMB_PROBE | SMB_HOSTBUSY)) != 0x00) {
> -		dev_dbg(&adap->dev, "SMBus busy (%02x). Resetting...\n", temp);
> +		dev_dbg(&adap->dev, "SMBus busy (%02hx). Resetting...\n", temp);

%hx is for shorts, not bytes. There is no format specifier for shorts,
so a cast is always needed for these if you want to be strictly
compliant. In practice gcc is smart enough to do the cast
automatically. Same for most cases below.

My suggestion to use %hx was really only for the cases where the
variable is an unsigned short or u16, you can leave all the rest as is.

>  		/* kill smbus transaction */
>  		sis630_write(SMBHOST_CNT, SMB_KILL);
>  
>  		temp = sis630_read(SMB_CNT);
>  		if (temp & (SMB_PROBE | SMB_HOSTBUSY)) {
> -			dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
> +			dev_dbg(&adap->dev, "Failed! (%02hx)\n", temp);
>  			return -EBUSY;
>                  } else {
>  			dev_dbg(&adap->dev, "Successful!\n");
> @@ -173,7 +173,7 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc
>  	/* save old clock, so we can prevent machine for hung */
>  	*oldclock = sis630_read(SMB_CNT);
>  
> -	dev_dbg(&adap->dev, "saved clock 0x%02x\n", *oldclock);
> +	dev_dbg(&adap->dev, "saved clock 0x%02hx\n", *oldclock);
>  
>  	/* disable timeout interrupt , set Host Master Clock to 56KHz if requested */
>  	if (high_clock)
> @@ -193,7 +193,8 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc
>  
>  static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
>  {
> -	int temp, result = 0, timeout = 0;
> +	u8 temp;
> +	int result = 0, timeout = 0;
>  
>  	/* We will always wait for a fraction of a second! */
>  	do {
> @@ -228,7 +229,8 @@ static void sis630_transaction_end(struct i2c_adapter *adap, u8 oldclock)
>  	/* clear all status "sticky" bits */
>  	sis630_write(SMB_STS, 0xFF);
>  
> -	dev_dbg(&adap->dev, "SMB_CNT before clock restore 0x%02x\n", sis630_read(SMB_CNT));
> +	dev_dbg(&adap->dev, "SMB_CNT before clock restore 0x%02hx\n",
> +		sis630_read(SMB_CNT));
>  
>  	/*
>  	 * restore old Host Master Clock if high_clock is set
> @@ -237,7 +239,8 @@ static void sis630_transaction_end(struct i2c_adapter *adap, u8 oldclock)
>  	if (high_clock && !(oldclock & SMBCLK_SEL))
>  		sis630_write(SMB_CNT, sis630_read(SMB_CNT) & ~SMBCLK_SEL);
>  
> -	dev_dbg(&adap->dev, "SMB_CNT after clock restore 0x%02x\n", sis630_read(SMB_CNT));
> +	dev_dbg(&adap->dev, "SMB_CNT after clock restore 0x%02hx\n",
> +		sis630_read(SMB_CNT));
>  }
>  
>  static int sis630_transaction(struct i2c_adapter *adap, int size)
> @@ -266,8 +269,8 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
>  		else if (len > 32)
>  			len = 32;
>  		sis630_write(SMB_COUNT, len);
> -		for (i=1; i <= len; i++) {
> -			dev_dbg(&adap->dev, "set data 0x%02x\n", data->block[i]);
> +		for (i = 1; i <= len; i++) {
> +			dev_dbg(&adap->dev, "set data 0x%02hx\n", data->block[i]);
>  			/* set data */
>  			sis630_write(SMB_BYTE+(i-1)%8, data->block[i]);
>  			if (i==8 || (len<8 && i==len)) {
> @@ -319,7 +322,7 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
>  			if (data->block[0] > 32)
>  				data->block[0] = 32;
>  
> -			dev_dbg(&adap->dev, "block data read len=0x%x\n", data->block[0]);
> +			dev_dbg(&adap->dev, "block data read len=0x%hx\n", data->block[0]);
>  
>  			for (i=0; i < 8 && len < data->block[0]; i++,len++) {
>  				dev_dbg(&adap->dev, "read i=%d len=%d\n", i, len);
> @@ -463,7 +466,7 @@ static int sis630_setup(struct pci_dev *sis630_dev)
>  		goto exit;
>  	}
>  
> -	dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base);
> +	dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04hx\n", acpi_base);
>  
>  	if (supported[i] == PCI_DEVICE_ID_SI_760)
>  		smbus_base = acpi_base + 0xE0;


-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux