[i2c] [patch 2.6.21-rc2-git +i2c-patches] shrink i2c_client

David Brownell david-b at pacbell.net
Tue Mar 6 19:30:56 CET 2007


On Tuesday 06 March 2007 9:35 am, Jean Delvare wrote:

> 
> Applied, thanks. Two questions:
> 
> ...
>
> >  struct i2c_client {
> > -	unsigned int flags;		/* div., see below		*/
> > +	unsigned short flags;		/* div., see below		*/
> >  	unsigned short addr;		/* chip address - NOTE: 7bit	*/
> >  					/* addresses are stored in the	*/
> >  					/* _LOWER_ 7 bits		*/
> > +	char name[I2C_NAME_SIZE];
> >  	struct i2c_adapter *adapter;	/* the adapter we sit on	*/
> >  	struct i2c_driver *driver;	/* and our access routines	*/
> >  	int usage_count;		/* How many accesses currently  */
> >  					/* to the client		*/
> >  	struct device dev;		/* the device structure		*/
> >  	struct list_head list;
> > -	char name[I2C_NAME_SIZE];
> 
> Do we actually spare padding by moving name? If not I'd rather leave it
> where it was.

Yes.  NAME_SIZE was previously 50 bytes = (8 * 6) + 2 leaving 2 pad bytes,
or maybe 6 on 64bit systems, in addition to the ones up front after "addr".

 
> >  	struct completion released;
> >  };
> >  #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
> > @@ -230,7 +235,7 @@ struct i2c_adapter {
> >  	int nr;
> >  	struct list_head clients;
> >  	struct list_head list;
> > -	char name[I2C_NAME_SIZE];
> > +	char name[50];
> >  	struct completion dev_released;
> >  };
> 
> Don't we want to make it 48 chars instead of 50 while we're here? A
> multiple of 8 would avoid wasting space in padding, and 48 chars should
> still be enough for everyone.

Feel free to change it.  I tend to agree that 48 is enough, even though
your phrasing calls to mind the infamous "640KB is enough for everyone"
quote from the early x86-PC days ... :)

- Dave



More information about the i2c mailing list