X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fblock%2Fcpqarray.c;h=fe7b2a77dd48c5915805e5d1835076518337ad52;hb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;hp=a231daff0025081e00969276ebfb44bb1718815c;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index a231daff0..fe7b2a77d 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -19,7 +19,6 @@ * Questions/Comments/Bugfixes to iss_storagedev@hp.com * */ -#include /* CONFIG_PROC_FS */ #include #include #include @@ -33,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -52,6 +50,7 @@ /* Original author Chris Frantz - Compaq Computer Corporation */ MODULE_AUTHOR("Compaq Computer Corporation"); MODULE_DESCRIPTION("Driver for Compaq Smart2 Array Controllers version 2.6.0"); +MODULE_VERSION("2.6.0"); MODULE_LICENSE("GPL"); #include "cpqarray.h" @@ -72,11 +71,11 @@ static ctlr_info_t *hba[MAX_CTLR]; static int eisa[8]; -#define NR_PRODUCTS (sizeof(products)/sizeof(struct board_type)) +#define NR_PRODUCTS ARRAY_SIZE(products) /* board_id = Subsystem Device ID & Vendor ID * product = Marketing Name for the board - * access = Address of the struct of function pointers + * access = Address of the struct of function pointers */ static struct board_type products[] = { { 0x0040110E, "IDA", &smart1_access }, @@ -97,7 +96,7 @@ static struct board_type products[] = { }; /* define the PCI info for the PCI cards this driver can control */ -const struct pci_device_id cpqarray_pci_device_id[] = +static const struct pci_device_id cpqarray_pci_device_id[] = { { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_COMPAQ_42XX, 0x0E11, 0x4058, 0, 0, 0}, /* SA431 */ @@ -135,7 +134,6 @@ static struct gendisk *ida_gendisk[MAX_CTLR][NWD]; /* Debug Extra Paranoid... */ #define DBGPX(s) do { } while(0) -int cpqarray_init_step2(void); static int cpqarray_pci_init(ctlr_info_t *c, struct pci_dev *pdev); static void __iomem *remap_pci_mem(ulong base, ulong size); static int cpqarray_eisa_detect(void); @@ -161,6 +159,7 @@ static int sendcmd( static int ida_open(struct inode *inode, struct file *filep); static int ida_release(struct inode *inode, struct file *filep); static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); +static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); static void do_ida_request(request_queue_t *q); @@ -200,6 +199,7 @@ static struct block_device_operations ida_fops = { .open = ida_open, .release = ida_release, .ioctl = ida_ioctl, + .getgeo = ida_getgeo, .revalidate_disk= ida_revalidate, }; @@ -312,14 +312,6 @@ static int ida_proc_get_info(char *buffer, char **start, off_t offset, int lengt module_param_array(eisa, int, NULL, 0); -/* This is a bit of a hack, - * necessary to support both eisa and pci - */ -int __init cpqarray_init(void) -{ - return (cpqarray_init_step2()); -} - static void release_io_mem(ctlr_info_t *c) { /* if IO mem was not protected do nothing */ @@ -355,7 +347,6 @@ static void __devexit cpqarray_remove_one(int i) for(j = 0; j < NWD; j++) { if (ida_gendisk[i][j]->flags & GENHD_FL_UP) del_gendisk(ida_gendisk[i][j]); - devfs_remove("ida/c%dd%d",i,j); put_disk(ida_gendisk[i][j]); } blk_cleanup_queue(hba[i]->queue); @@ -399,7 +390,7 @@ static void __devexit cpqarray_remove_one_eisa (int i) } /* pdev is NULL for eisa */ -static int cpqarray_register_ctlr( int i, struct pci_dev *pdev) +static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) { request_queue_t *q; int j; @@ -417,8 +408,7 @@ static int cpqarray_register_ctlr( int i, struct pci_dev *pdev) } hba[i]->access.set_intr_mask(hba[i], 0); if (request_irq(hba[i]->intr, do_ida_intr, - SA_INTERRUPT|SA_SHIRQ|SA_SAMPLE_RANDOM, - hba[i]->devname, hba[i])) + IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i])) { printk(KERN_ERR "cpqarray: Unable to get irq %d for %s\n", hba[i]->intr, hba[i]->devname); @@ -560,7 +550,7 @@ static struct pci_driver cpqarray_pci_driver = { * This is it. Find all the controllers and register them. * returns the number of block devices registered. */ -int __init cpqarray_init_step2(void) +static int __init cpqarray_init(void) { int num_cntlrs_reg = 0; int i; @@ -624,6 +614,7 @@ static int cpqarray_pci_init(ctlr_info_t *c, struct pci_dev *pdev) int i; c->pci_dev = pdev; + pci_set_master(pdev); if (pci_enable_device(pdev)) { printk(KERN_ERR "cpqarray: Unable to Enable PCI device\n"); return -1; @@ -752,7 +743,7 @@ __setup("smart2=", cpqarray_setup); /* * Find an EISA controller's signature. Set up an hba if we find it. */ -static int cpqarray_eisa_detect(void) +static int __init cpqarray_eisa_detect(void) { int i=0, j; __u32 board_id; @@ -913,8 +904,7 @@ queue_next: if (!creq) goto startio; - if (creq->nr_phys_segments > SG_MAX) - BUG(); + BUG_ON(creq->nr_phys_segments > SG_MAX); if ((c = cmd_alloc(h,1)) == NULL) goto startio; @@ -1044,8 +1034,10 @@ static inline void complete_command(cmdlist_t *cmd, int timeout) complete_buffers(cmd->rq->bio, ok); + add_disk_randomness(cmd->rq->rq_disk); + DBGPX(printk("Done with %p\n", cmd->rq);); - end_that_request_last(cmd->rq); + end_that_request_last(cmd->rq, ok ? 1 : -EIO); } /* @@ -1133,6 +1125,23 @@ static void ida_timer(unsigned long tdata) h->misc_tflags = 0; } +static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + drv_info_t *drv = get_drv(bdev->bd_disk); + + if (drv->cylinders) { + geo->heads = drv->heads; + geo->sectors = drv->sectors; + geo->cylinders = drv->cylinders; + } else { + geo->heads = 0xff; + geo->sectors = 0x3f; + geo->cylinders = drv->nr_blks / (0xff*0x3f); + } + + return 0; +} + /* * ida_ioctl does some miscellaneous stuff like reporting drive geometry, * setting readahead and submitting commands from userspace to the controller. @@ -1142,27 +1151,10 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); int error; - int diskinfo[4]; - struct hd_geometry __user *geo = (struct hd_geometry __user *)arg; ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg; ida_ioctl_t *my_io; switch(cmd) { - case HDIO_GETGEO: - if (drv->cylinders) { - diskinfo[0] = drv->heads; - diskinfo[1] = drv->sectors; - diskinfo[2] = drv->cylinders; - } else { - diskinfo[0] = 0xff; - diskinfo[1] = 0x3f; - diskinfo[2] = drv->nr_blks / (0xff*0x3f); - } - put_user(diskinfo[0], &geo->heads); - put_user(diskinfo[1], &geo->sectors); - put_user(diskinfo[2], &geo->cylinders); - put_user(get_start_sect(inode->i_bdev), &geo->start); - return 0; case IDAGETDRVINFO: if (copy_to_user(&io->c.drv, drv, sizeof(drv_info_t))) return -EFAULT; @@ -1748,8 +1740,6 @@ static void getgeometry(int ctlr) (log_index < id_ctlr_buf->nr_drvs) && (log_unit < NWD); log_unit++) { - struct gendisk *disk = ida_gendisk[ctlr][log_unit]; - size = sizeof(sense_log_drv_stat_t); /* @@ -1814,8 +1804,6 @@ static void getgeometry(int ctlr) } - sprintf(disk->devfs_name, "ida/c%dd%d", ctlr, log_unit); - info_p->phys_drives = sense_config_buf->ctlr_phys_drv; info_p->drv_assign_map @@ -1851,7 +1839,6 @@ static void __exit cpqarray_exit(void) } } - devfs_remove("ida"); remove_proc_entry("cpqarray", proc_root_driver); }