RFC: Block device driver API change

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Sep 22 11:58:32 UTC 2009


Hi,

currently block device drivers register them self via

/**
 * Creates a physical disk with device identifier @a dev.
 *
 * The block size @a block_size must be a power of two.  The disk size @a
 * disk_size is the number of blocks provided by this disk.  The block index
 * starts with zero.  The associated disk device driver will be invoked via the
 * IO control handler @a handler.  A device node will be registered in the file
 * system with absolute path @a name.  This function is usually invoked from a
 * block device driver during initialization when a physical device is detected
 * in the system.  The device driver provides an IO control handler to allow
 * block device operations.
 */
rtems_status_code rtems_disk_create_phys(
  dev_t dev,
  uint32_t block_size,
  rtems_blkdev_bnum disk_size,
  rtems_block_device_ioctl handler,
  const char *name
);

/**
 * Block device IO control handler type.
 */
typedef int (*rtems_block_device_ioctl)(dev_t dev, uint32_t req, void *argp);

The block device driver has to obtain its private data via the device number
parameter.  This leads to various lookup tables of the forms

private_data = data_table [major] [minor]
private_data = data_table [minor]

For drivers which can cope with multiple major numbers this is especially
cumbersome.

Since the block device library invokes the driver ioctl function already via
the disk device entry it is possible to add an additional field for private
driver data:

typedef struct rtems_disk_device {
  [...]

  rtems_block_device_ioctl ioctl;

  void *driver_data;
} rtems_disk_device;

rtems_status_code rtems_disk_create_phys(
  dev_t dev,
  uint32_t block_size,
  rtems_blkdev_bnum disk_size,
  rtems_block_device_ioctl handler,
  void *driver_data,
  const char *name
);

typedef int (*rtems_block_device_ioctl)(
  dev_t dev,
  void *driver_data,
  uint32_t req,
  void *argp
);

This would eliminate the need to lookup the driver data via the device number.
How do you think about this?

Have a nice day!

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list