linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: "Amaury Decrême"
	<amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: nelson-bExrPSV3DA0@public.gmane.org,
	mhoffman-xQSgfq/1h4JiLUuM0BA3LQ@public.gmane.org,
	amalysh-S0/GAf8tV78@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 5/6] Misc: display unsigned hex
Date: Mon, 28 Jan 2013 19:33:04 +0100	[thread overview]
Message-ID: <20130128193304.657b869f@endymion.delvare> (raw)
In-Reply-To: <1357305215-17643-6-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  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

  parent reply	other threads:[~2013-01-28 18:33 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1346204115-30293-1-git-send-email-amaury.decreme@gmail.com>
     [not found] ` <1346204115-30293-2-git-send-email-amaury.decreme@gmail.com>
     [not found]   ` <1346204115-30293-2-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-04 12:57     ` [PATCH resend 1/2] I2C: sis630: sis964 bus Jean Delvare
     [not found]       ` <20121004145702.2be5b612-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-04 11:33         ` Amaury Decrême
     [not found] ` <1346204115-30293-3-git-send-email-amaury.decreme@gmail.com>
     [not found]   ` <1346204115-30293-3-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-04 15:29     ` [PATCH resend 2/2] I2C: sis630: Cleaning and cosmetics Jean Delvare
     [not found]       ` <20121004172939.387eb8d1-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-04 11:44         ` Amaury Decrême
2013-01-04 12:53           ` Jean Delvare
     [not found] ` <1346204115-30293-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-18 11:51   ` [PATCH resend 0/2] I2C: sis630: add sis964 support Jean Delvare
     [not found]     ` <20121218125105.25c2cbb6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-12-28 19:24       ` Amaury Decrême
2013-01-04  9:39         ` Jean Delvare
2013-01-04 13:13   ` [PATCH v2 0/6] " Amaury Decrême
     [not found]     ` <1357305215-17643-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-04 13:13       ` [PATCH v2 1/6] Add SIS964 bus support to i2c-sis630 Amaury Decrême
     [not found]         ` <1357305215-17643-2-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 16:28           ` Jean Delvare
2013-01-04 13:13       ` [PATCH v2 2/6] Bugfix: clear sticky bits Amaury Decrême
     [not found]         ` <1357305215-17643-3-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 16:34           ` Jean Delvare
2013-01-04 13:13       ` [PATCH v2 3/6] Bugfix: behavior after collision Amaury Decrême
     [not found]         ` <1357305215-17643-4-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 16:38           ` Jean Delvare
2013-01-04 13:13       ` [PATCH v2 4/6] Cosmetics: hex to constants for SMBus commands Amaury Decrême
     [not found]         ` <1357305215-17643-5-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 17:42           ` Jean Delvare
     [not found]             ` <20130128184233.48b19a04-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 20:58               ` Amaury Decrême
2013-01-04 13:13       ` [PATCH v2 5/6] Misc: display unsigned hex Amaury Decrême
     [not found]         ` <1357305215-17643-6-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 18:33           ` Jean Delvare [this message]
     [not found]             ` <20130128193304.657b869f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 21:00               ` Amaury Decrême
2013-01-04 13:13       ` [PATCH v2 6/6] Cleanup Amaury Decrême
     [not found]         ` <1357305215-17643-7-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 18:40           ` Jean Delvare
     [not found]             ` <20130128194007.3d3c0d4d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 21:10               ` Amaury Decrême
2013-01-24  7:28       ` [PATCH v2 0/6] I2C: sis630: add sis964 support Wolfram Sang
     [not found]         ` <20130124072818.GM8364-8EAEigeeuNG034pCzgS/Qg7AFbiQbgqx@public.gmane.org>
2013-01-24  7:30           ` Jean Delvare
     [not found]             ` <20130124083043.57f91a3d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 21:21               ` [PATCH v3 " Amaury Decrême
     [not found]                 ` <1359408070-31832-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 21:21                   ` [PATCH v3 1/6] Add SIS964 bus support to i2c-sis630 Amaury Decrême
2013-01-28 21:21                   ` [PATCH v3 2/6] Bugfix: clear sticky bits Amaury Decrême
2013-01-28 21:21                   ` [PATCH v3 3/6] Bugfix: behavior after collision Amaury Decrême
2013-01-28 21:21                   ` [PATCH v3 4/6] Cosmetics: hex to constants for SMBus commands Amaury Decrême
     [not found]                     ` <1359408070-31832-5-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-29  9:13                       ` Jean Delvare
2013-01-28 21:21                   ` [PATCH v3 5/6] Misc: display unsigned hex Amaury Decrême
     [not found]                     ` <1359408070-31832-6-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-29  9:19                       ` Jean Delvare
2013-01-28 21:21                   ` [PATCH v3 6/6] Cleanup Amaury Decrême
     [not found]                     ` <1359408070-31832-7-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-29  9:31                       ` Jean Delvare
     [not found]                         ` <20130129103151.21262d1d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-29 20:22                           ` [PATCH v4] Cleanup Amaury Decrême
     [not found]                             ` <1359490946-24005-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-30  9:06                               ` Jean Delvare
     [not found]                                 ` <20130130100638.43422a3e-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-30 22:16                                   ` Amaury Decrême

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130128193304.657b869f@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=amalysh-S0/GAf8tV78@public.gmane.org \
    --cc=amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mhoffman-xQSgfq/1h4JiLUuM0BA3LQ@public.gmane.org \
    --cc=nelson-bExrPSV3DA0@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).