[i2c] [patch 2.6.20-rc1 2/6] I2C adapters (mostly) stop using i2c_adapter.dev

Jean Delvare khali at linux-fr.org
Wed Jan 3 15:04:57 CET 2007


On Mon, 18 Dec 2006 13:19:27 -0800, David Brownell wrote:
> This updates I2C adapter drivers to stop using i2c_adapter.dev,
> using i2c_adapter.class_dev instead.  At least for diagnostics;
> other uses will be cleaned up as part of the patch which removes
> that field entirely.
> 
> Signed-off-by: David Brownell <dbrownell at users.sourceforge.net>
> 
> ---
> Updated per minor feedback from Jean; the most significant update
> was moving some i2c-isa tweaks back to the patch r

Soemthing's missing here?

> Index: g26/drivers/i2c/busses/i2c-pnx.c
> ===================================================================
> --- g26.orig/drivers/i2c/busses/i2c-pnx.c	2006-12-18 11:45:46.000000000 -0800
> +++ g26/drivers/i2c/busses/i2c-pnx.c	2006-12-18 11:52:25.000000000 -0800
> @@ -56,7 +56,7 @@ static inline void i2c_pnx_arm_timer(str
>  
>  	del_timer_sync(timer);
>  
> -	dev_dbg(&adap->dev, "Timer armed at %lu plus %u jiffies.\n",
> +	dev_dbg(adap->class_dev.dev, "Timer armed at %lu plus %u jiffies.\n",
>  		jiffies, expires);
>  
>  	timer->expires = jiffies + expires;
> @@ -76,12 +76,12 @@ static int i2c_pnx_start(unsigned char s
>  {
>  	struct i2c_pnx_algo_data *alg_data = adap->algo_data;
>  
> -	dev_dbg(&adap->dev, "%s(): addr 0x%x mode %d\n", __FUNCTION__,
> +	dev_dbg(adap->class_dev.dev, "%s(): addr 0x%x mode %d\n", __FUNCTION__,
>  		slave_addr, alg_data->mif.mode);
>  
>  	/* Check for 7 bit slave addresses only */
>  	if (slave_addr & ~0x7f) {
> -		dev_err(&adap->dev, "%s: Invalid slave address %x. "
> +		dev_err(adap->class_dev.dev, "%s: Invalid slave address %x. "
>  		       "Only 7-bit addresses are supported\n",
>  		       adap->name, slave_addr);
>  		return -EINVAL;
> @@ -90,7 +90,7 @@ static int i2c_pnx_start(unsigned char s
>  	/* First, make sure bus is idle */
>  	if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
>  		/* Somebody else is monopolizing the bus */
> -		dev_err(&adap->dev, "%s: Bus busy. Slave addr = %02x, "
> +		dev_err(adap->class_dev.dev, "%s: Bus busy. Slave addr = %02x, "
>  		       "cntrl = %x, stat = %x\n",
>  		       adap->name, slave_addr,
>  		       ioread32(I2C_REG_CTL(alg_data)),
> @@ -98,7 +98,7 @@ static int i2c_pnx_start(unsigned char s
>  		return -EBUSY;
>  	} else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
>  		/* Sorry, we lost the bus */
> -		dev_err(&adap->dev, "%s: Arbitration failure. "
> +		dev_err(adap->class_dev.dev, "%s: Arbitration failure. "
>  		       "Slave addr = %02x\n", adap->name, slave_addr);
>  		return -EIO;
>  	}
> @@ -110,14 +110,14 @@ static int i2c_pnx_start(unsigned char s
>  	iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi,
>  		  I2C_REG_STS(alg_data));
>  
> -	dev_dbg(&adap->dev, "%s(): sending %#x\n", __FUNCTION__,
> +	dev_dbg(adap->class_dev.dev, "%s(): sending %#x\n", __FUNCTION__,
>  		(slave_addr << 1) | start_bit | alg_data->mif.mode);
>  
>  	/* Write the slave address, START bit and R/W bit */
>  	iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode,
>  		  I2C_REG_TX(alg_data));
>  
> -	dev_dbg(&adap->dev, "%s(): exit\n", __FUNCTION__);
> +	dev_dbg(adap->class_dev.dev, "%s(): exit\n", __FUNCTION__);
>  
>  	return 0;
>  }
> @@ -134,7 +134,7 @@ static void i2c_pnx_stop(struct i2c_adap
>  	/* Only 1 msec max timeout due to interrupt context */
>  	long timeout = 1000;
>  
> -	dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): entering: stat = %04x.\n",
>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  
>  	/* Write a STOP bit to TX FIFO */
> @@ -148,7 +148,7 @@ static void i2c_pnx_stop(struct i2c_adap
>  		timeout--;
>  	}
>  
> -	dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): exiting: stat = %04x.\n",
>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  }
>  
> @@ -163,7 +163,7 @@ static int i2c_pnx_master_xmit(struct i2
>  	struct i2c_pnx_algo_data *alg_data = adap->algo_data;
>  	u32 val;
>  
> -	dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): entering: stat = %04x.\n",
>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  
>  	if (alg_data->mif.len > 0) {
> @@ -179,14 +179,15 @@ static int i2c_pnx_master_xmit(struct i2
>  		alg_data->mif.len--;
>  		iowrite32(val, I2C_REG_TX(alg_data));
>  
> -		dev_dbg(&adap->dev, "%s(): xmit %#x [%d]\n", __FUNCTION__,
> -			val, alg_data->mif.len + 1);
> +		dev_dbg(adap->class_dev.dev, "%s(): xmit %#x [%d]\n",
> +			__FUNCTION__, val, alg_data->mif.len + 1);
>  
>  		if (alg_data->mif.len == 0) {
>  			if (alg_data->last) {
>  				/* Wait until the STOP is seen. */
>  				if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
> -					dev_err(&adap->dev, "The bus is still "
> +					dev_err(adap->class_dev.dev,
> +						"The bus is still "
>  						"active after timeout\n");
>  			}
>  			/* Disable master interrupts */
> @@ -196,7 +197,8 @@ static int i2c_pnx_master_xmit(struct i2
>  
>  			del_timer_sync(&alg_data->mif.timer);
>  
> -			dev_dbg(&adap->dev, "%s(): Waking up xfer routine.\n",
> +			dev_dbg(adap->class_dev.dev,
> +				"%s(): Waking up xfer routine.\n",
>  				__FUNCTION__);
>  
>  			complete(&alg_data->mif.complete);
> @@ -212,13 +214,14 @@ static int i2c_pnx_master_xmit(struct i2
>  
>  		/* Stop timer. */
>  		del_timer_sync(&alg_data->mif.timer);
> -		dev_dbg(&adap->dev, "%s(): Waking up xfer routine after "
> +		dev_dbg(adap->class_dev.dev,
> +			"%s(): Waking up xfer routine after "
>  			"zero-xfer.\n", __FUNCTION__);
>  
>  		complete(&alg_data->mif.complete);
>  	}
>  
> -	dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): exiting: stat = %04x.\n",
>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  
>  	return 0;
> @@ -236,14 +239,14 @@ static int i2c_pnx_master_rcv(struct i2c
>  	unsigned int val = 0;
>  	u32 ctl = 0;
>  
> -	dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): entering: stat = %04x.\n",
>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  
>  	/* Check, whether there is already data,
>  	 * or we didn't 'ask' for it yet.
>  	 */
>  	if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
> -		dev_dbg(&adap->dev, "%s(): Write dummy data to fill "
> +		dev_dbg(adap->class_dev.dev, "%s(): Write dummy data to fill "
>  			"Rx-fifo...\n", __FUNCTION__);
>  
>  		if (alg_data->mif.len == 1) {
> @@ -276,15 +279,16 @@ static int i2c_pnx_master_rcv(struct i2c
>  	if (alg_data->mif.len > 0) {
>  		val = ioread32(I2C_REG_RX(alg_data));
>  		*alg_data->mif.buf++ = (u8) (val & 0xff);
> -		dev_dbg(&adap->dev, "%s(): rcv 0x%x [%d]\n", __FUNCTION__, val,
> -			alg_data->mif.len);
> +		dev_dbg(adap->class_dev.dev, "%s(): rcv 0x%x [%d]\n",
> +			__FUNCTION__, val, alg_data->mif.len);
>  
>  		alg_data->mif.len--;
>  		if (alg_data->mif.len == 0) {
>  			if (alg_data->last)
>  				/* Wait until the STOP is seen. */
>  				if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
> -					dev_err(&adap->dev, "The bus is still "
> +					dev_err(adap->class_dev.dev,
> +						"The bus is still "
>  						"active after timeout\n");
>  
>  			/* Disable master interrupts */
> @@ -299,7 +303,7 @@ static int i2c_pnx_master_rcv(struct i2c
>  		}
>  	}
>  
> -	dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): exiting: stat = %04x.\n",
>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  
>  	return 0;
> @@ -312,7 +316,8 @@ i2c_pnx_interrupt(int irq, void *dev_id,
>  	struct i2c_adapter *adap = dev_id;
>  	struct i2c_pnx_algo_data *alg_data = adap->algo_data;
>  
> -	dev_dbg(&adap->dev, "%s(): mstat = %x mctrl = %x, mode = %d\n",
> +	dev_dbg(adap->class_dev.dev,
> +		"%s(): mstat = %x mctrl = %x, mode = %d\n",
>  		__FUNCTION__,
>  		ioread32(I2C_REG_STS(alg_data)),
>  		ioread32(I2C_REG_CTL(alg_data)),
> @@ -335,7 +340,7 @@ i2c_pnx_interrupt(int irq, void *dev_id,
>  		complete(&alg_data->mif.complete);
>  	} else if (stat & mstatus_nai) {
>  		/* Slave did not acknowledge, generate a STOP */
> -		dev_dbg(&adap->dev, "%s(): "
> +		dev_dbg(adap->class_dev.dev, "%s(): "
>  			"Slave did not acknowledge, generating a STOP.\n",
>  			__FUNCTION__);
>  		i2c_pnx_stop(adap);
> @@ -375,7 +380,7 @@ i2c_pnx_interrupt(int irq, void *dev_id,
>  	stat = ioread32(I2C_REG_STS(alg_data));
>  	iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
>  
> -	dev_dbg(&adap->dev, "%s(): exiting, stat = %x ctrl = %x.\n",
> +	dev_dbg(adap->class_dev.dev, "%s(): exiting, stat = %x ctrl = %x.\n",
>  		 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)),
>  		 ioread32(I2C_REG_CTL(alg_data)));
>  
> @@ -388,7 +393,8 @@ static void i2c_pnx_timeout(unsigned lon
>  	struct i2c_pnx_algo_data *alg_data = adap->algo_data;
>  	u32 ctl;
>  
> -	dev_err(&adap->dev, "Master timed out. stat = %04x, cntrl = %04x. "
> +	dev_err(adap->class_dev.dev,
> +		"Master timed out. stat = %04x, cntrl = %04x. "
>  	       "Resetting master...\n",
>  	       ioread32(I2C_REG_STS(alg_data)),
>  	       ioread32(I2C_REG_CTL(alg_data)));
> @@ -411,7 +417,7 @@ static inline void bus_reset_if_active(s
>  	u32 stat;
>  
>  	if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
> -		dev_err(&adap->dev,
> +		dev_err(adap->class_dev.dev,
>  			"%s: Bus is still active after xfer. Reset it...\n",
>  		       adap->name);
>  		iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
> @@ -447,7 +453,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, s
>  	struct i2c_pnx_algo_data *alg_data = adap->algo_data;
>  	u32 stat = ioread32(I2C_REG_STS(alg_data));
>  
> -	dev_dbg(&adap->dev, "%s(): entering: %d messages, stat = %04x.\n",
> +	dev_dbg(adap->class_dev.dev,
> +		"%s(): entering: %d messages, stat = %04x.\n",
>  		__FUNCTION__, num, ioread32(I2C_REG_STS(alg_data)));
>  
>  	bus_reset_if_active(adap);
> @@ -460,7 +467,7 @@ i2c_pnx_xfer(struct i2c_adapter *adap, s
>  		addr = pmsg->addr;
>  
>  		if (pmsg->flags & I2C_M_TEN) {
> -			dev_err(&adap->dev,
> +			dev_err(adap->class_dev.dev,
>  				"%s: 10 bits addr not supported!\n",
>  				adap->name);
>  			rc = -EINVAL;
> @@ -474,7 +481,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, s
>  		alg_data->mif.ret = 0;
>  		alg_data->last = (i == num - 1);
>  
> -		dev_dbg(&adap->dev, "%s(): mode %d, %d bytes\n", __FUNCTION__,
> +		dev_dbg(adap->class_dev.dev,
> +			"%s(): mode %d, %d bytes\n", __FUNCTION__,
>  			alg_data->mif.mode,
>  			alg_data->mif.len);
>  
> @@ -498,18 +506,19 @@ i2c_pnx_xfer(struct i2c_adapter *adap, s
>  
>  		if (!(rc = alg_data->mif.ret))
>  			completed++;
> -		dev_dbg(&adap->dev, "%s(): Complete, return code = %d.\n",
> +		dev_dbg(adap->class_dev.dev,
> +			"%s(): Complete, return code = %d.\n",
>  			__FUNCTION__, rc);
>  
>  		/* Clear TDI and AFI bits in case they are set. */
>  		if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) {
> -			dev_dbg(&adap->dev,
> +			dev_dbg(adap->class_dev.dev,
>  				"%s: TDI still set... clearing now.\n",
>  			       adap->name);
>  			iowrite32(stat, I2C_REG_STS(alg_data));
>  		}
>  		if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) {
> -			dev_dbg(&adap->dev,
> +			dev_dbg(&adap->class_dev.dev,

Bug here, the "&" shouldn't be there.

>  				"%s: AFI still set... clearing now.\n",
>  			       adap->name);
>  			iowrite32(stat, I2C_REG_STS(alg_data));
> @@ -522,7 +531,7 @@ i2c_pnx_xfer(struct i2c_adapter *adap, s
>  	alg_data->mif.buf = NULL;
>  	alg_data->mif.len = 0;
>  
> -	dev_dbg(&adap->dev, "%s(): exiting, stat = %x\n",
> +	dev_dbg(&adap->class_dev.dev, "%s(): exiting, stat = %x\n",

Same here. Both fixed.

>  		__FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
>  
>  	if (completed != num)

Thanks,
-- 
Jean Delvare



More information about the i2c mailing list