The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Corey Minyard <minyard@acm.org>
Cc: Andrew Morton <akpm@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] I2C patch 2 - break up the SMBus formatting
Date: Fri, 25 Feb 2005 13:44:39 -0800	[thread overview]
Message-ID: <20050225214439.GC27270@kroah.com> (raw)
In-Reply-To: <421E62DD.5030608@acm.org>

On Thu, Feb 24, 2005 at 05:27:25PM -0600, Corey Minyard wrote:
> +/*
> + * Hold a queue of I2C operations to perform, and used to pass data
> + * around.
> + */
> +typedef void (*i2c_op_done_cb)(struct i2c_op_q_entry *entry);
> +
> +#define I2C_OP_I2C	0
> +#define I2C_OP_SMBUS	1
> +struct i2c_op_q_entry {
> +	/* The result will be set to the result of the operation when
> +	   it completes. */
> +	s32 result;
> +
> +	/**************************************************************/
> +	/* Public interface.  The user should set these up (and the
> +	   proper structure below). */
> +	int            xfer_type;
> +
> +	/* Handler may be called from interrupt context, so be
> +	   careful. */
> +	i2c_op_done_cb handler;
> +	void           *handler_data;
> +
> +	/* Note that this is not a union because an smbus operation
> +	   may be converted into an i2c operation (thus both
> +	   structures will be used).  The data in these may be changd
> +	   by the driver. */
> +	struct {
> +		struct i2c_msg *msgs;
> +		int num;
> +	} i2c;
> +	struct {
> +		/* Addr and flags are filled in by the non-blocking
> +		   send routine that takes a client. */
> +		u16 addr;
> +		unsigned short flags;
> +
> +		char read_write;
> +		u8 command;
> +
> +		/* Note that the size is *not* the length of the data.
> +		   It is the transaction type, like I2C_SMBUS_QUICK
> +		   and the ones after that below.  If this is a block
> +		   transaction, the length of the rest of the data is
> +		   in the first byte of the data, for both transmit
> +		   and receive. */
> +		int size;
> +		union i2c_smbus_data *data;
> +	} smbus;
> +
> +	/**************************************************************/
> +	/* For use by the bus interface.  The bus interface sets the
> +	   timeout in microseconds until the next poll operation.
> +	   This *must* be set in the start operation.  The time_left
> +	   and data can be used for anything the bus interface likes.
> +	   data will be set to NULL before being started so the bus
> +	   interface can use that to tell if it has been set up
> +	   yet. */
> +	unsigned int call_again_us;
> +	long         time_left;
> +	void         *data;
> +
> +	/**************************************************************/
> +	/* Internals */
> +	struct list_head  link;
> +	struct completion *start;
> +	atomic_t          completed;
> +	unsigned int      started : 1;
> +	unsigned int      use_timer : 1;
> +	u8                swpec;
> +	u8                partial;
> +	void (*complete)(struct i2c_adapter    *adap,
> +			 struct i2c_op_q_entry *entry);
> +
> +	/* It's wierd, but we use a usecount to track if an q entry is
> +	   in use and when it should be reported back to the user. */
> +	atomic_t usecount;

Please use a kref here instead of rolling your own.

Oh, and can you cc: your patches to the sensors mailing list so the
other i2c developers are aware of them and can comment?  I'll stick with
just applying your first patch for now.

thanks,

greg k-h

  parent reply	other threads:[~2005-02-25 21:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-24 23:27 [PATCH] I2C patch 2 - break up the SMBus formatting Corey Minyard
2005-02-25 21:41 ` Greg KH
2005-02-25 21:44 ` Greg KH [this message]
2005-02-25 22:46   ` Corey Minyard
2005-02-25 23:00     ` Greg KH

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=20050225214439.GC27270@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.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