[Cbe-oss-dev] [patch 12/16] powerpc and x86_64: Initial port of PCIe endpoint device driver for Axon

Arnd Bergmann arnd at arndb.de
Thu Mar 13 16:46:12 EST 2008


On Saturday 08 March 2008, Murali Iyer wrote:
> Subject: [patch 12/16] axon driver, general utility functions
> 
> Description:
> 	This patch provides driver utilities ( such as
> 	inter-driver communcation via the d2d msg queue) and
> 	diagnostics.

These "utility" files tend to collect all the stuff you don't want
to have in the driver, better try to get rid of it by moving the
functions closer to where they are actually used, or finding
a standard helper to do the same.

All the debugging print code should probably just go away on
the way into the mainline kernel, once the driver is debugged.


> +extern const char *axon_name;
> +extern int axon_major;
> +extern const struct file_operations axon_fops;

Move to some header or kill.

> +/*
> + * axon_init_instance
> + * @axon_priv - device instance
> + * @dev - device information
> + */
> +void axon_init_instance( struct axon *axon_priv)
> +{
> +	int i;
> +	struct axon_dataq *rq;
> +
> +	/* force to zero */
> +	axon_priv->irq	   = 0;
> +
> +	axon_priv->id	   = 0x0101;
> +	axon_priv->ver	   = 0x00010001;
> +
> +	axon_priv->mmio_base  = NULL;
> +	axon_priv->scratchpad = NULL;

Most of this function will not be needed if you just allocate
the data structure with kzalloc.

> +/**
> + * axon_setup_cdev
> + * @axon_priv: device instance
> + */
> +int   __devinit axon_setup_cdev( struct axon	 *axon_priv)
> +{
> +	int err;
> +
> +	axon_priv->dev_id = MKDEV( axon_major, axon_priv->index);
> +
> +
> +	cdev_init(  &(axon_priv->cdev), &axon_fops);
> +	axon_priv->cdev.owner = THIS_MODULE;
> +
> +	err = cdev_add( &axon_priv->cdev, axon_priv->dev_id, 1);
> +	if ( err ) {
> +		printk(KERN_ERR "Error %d adding axon%d",
> +			err, axon_priv->index);
> +	}
> +
> +	return err;
> +}

This should go to the frontend driver.

> +/**
> + * axon_init_d2d - initialize the driver-to-driver msg queue
> + * @d2dp: pointer to d2d msg queue
> + */
> +void axon_init_d2d(struct axon_d2d *d2dp)
> +{
> +	int i;
> +	d2dp->msg_head = offsetof(struct axon_d2d, msg_buffer);
> +	d2dp->msg_tail = offsetof(struct axon_d2d, msg_buffer);
> +	for (i = 0; i < 4; i++) {
> +		d2dp->dma_interrupt_values[i] = 0;
> +	}
> +	for (i = 0; i < 2; i++) {
> +		d2dp->dma_channel_seq_issued[i] = 0;
> +		d2dp->dma_channel_seq_complete[i] =0;
> +	}
> +}

This and others can become a file by themselves for all the d2d stuff.

	Arnd <><



More information about the cbe-oss-dev mailing list