From 06ff37ffb4ba8bcbda0e9d19c712c954ef7b8a0a Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Wed, 8 Mar 2006 11:21:52 +0100 Subject: [PATCH] kzalloc() conversion in drivers/block this patch converts drivers/block to kzalloc usage. Compile tested with allyesconfig. Signed-off-by: Eric Sesterhenn Signed-off-by: Jens Axboe --- drivers/block/DAC960.c | 7 ++----- drivers/block/cciss.c | 10 +++------- drivers/block/cciss_scsi.c | 3 +-- drivers/block/paride/bpck6.c | 3 +-- 4 files changed, 7 insertions(+), 16 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 9bdea2a5cf0..49c7cd558dd 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -311,11 +311,10 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller) CommandsRemaining = CommandAllocationGroupSize; CommandGroupByteCount = CommandsRemaining * CommandAllocationLength; - AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC); + AllocationPointer = kzalloc(CommandGroupByteCount, GFP_ATOMIC); if (AllocationPointer == NULL) return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION"); - memset(AllocationPointer, 0, CommandGroupByteCount); } Command = (DAC960_Command_T *) AllocationPointer; AllocationPointer += CommandAllocationLength; @@ -2709,14 +2708,12 @@ DAC960_DetectController(struct pci_dev *PCI_Device, void __iomem *BaseAddress; int i; - Controller = (DAC960_Controller_T *) - kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC); + Controller = kzalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC); if (Controller == NULL) { DAC960_Error("Unable to allocate Controller structure for " "Controller at\n", NULL); return NULL; } - memset(Controller, 0, sizeof(DAC960_Controller_T)); Controller->ControllerNumber = DAC960_ControllerCount; DAC960_Controllers[DAC960_ControllerCount++] = Controller; Controller->Bus = PCI_Device->bus->number; diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 71ec9e66438..168da0c9ed3 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -996,13 +996,11 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, status = -EINVAL; goto cleanup1; } - buff = (unsigned char **) kmalloc(MAXSGENTRIES * - sizeof(char *), GFP_KERNEL); + buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL); if (!buff) { status = -ENOMEM; goto cleanup1; } - memset(buff, 0, MAXSGENTRIES); buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL); if (!buff_size) { @@ -2940,13 +2938,12 @@ static void cciss_getgeometry(int cntl_num) int block_size; int total_size; - ld_buff = kmalloc(sizeof(ReportLunData_struct), GFP_KERNEL); + ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); if (ld_buff == NULL) { printk(KERN_ERR "cciss: out of memory\n"); return; } - memset(ld_buff, 0, sizeof(ReportLunData_struct)); size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); if (size_buff == NULL) { @@ -3060,10 +3057,9 @@ static int alloc_cciss_hba(void) for(i=0; i< MAX_CTLR; i++) { if (!hba[i]) { ctlr_info_t *p; - p = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL); + p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); if (!p) goto Enomem; - memset(p, 0, sizeof(ctlr_info_t)); for (n = 0; n < NWD; n++) p->gendisk[n] = disk[n]; hba[i] = p; diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 0e66e904bd8..597c007fe81 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -1027,12 +1027,11 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) int i; c = (ctlr_info_t *) hba[cntl_num]; - ld_buff = kmalloc(reportlunsize, GFP_KERNEL); + ld_buff = kzalloc(reportlunsize, GFP_KERNEL); if (ld_buff == NULL) { printk(KERN_ERR "cciss: out of memory\n"); return; } - memset(ld_buff, 0, reportlunsize); inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); if (inq_buff == NULL) { printk(KERN_ERR "cciss: out of memory\n"); diff --git a/drivers/block/paride/bpck6.c b/drivers/block/paride/bpck6.c index 08d858ad64d..41a237c5957 100644 --- a/drivers/block/paride/bpck6.c +++ b/drivers/block/paride/bpck6.c @@ -224,10 +224,9 @@ static void bpck6_log_adapter( PIA *pi, char * scratch, int verbose ) static int bpck6_init_proto(PIA *pi) { - Interface *p = kmalloc(sizeof(Interface), GFP_KERNEL); + Interface *p = kzalloc(sizeof(Interface), GFP_KERNEL); if (p) { - memset(p, 0, sizeof(Interface)); pi->private = (unsigned long)p; return 0; } -- cgit v1.2.3 From 89a7689e5c039090d99cbdc3625252c3dee50f7f Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Fri, 24 Mar 2006 10:00:57 +0100 Subject: [PATCH] unused label in drivers/block/cciss. this patch removes a warning about an unused label, by moving the label into the ifdef. Signed-off-by: Eric Sesterhenn Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 168da0c9ed3..1b0fd31c57c 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -2727,9 +2727,9 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c, struct pci_dev *pdev, return; } } +default_int_mode: #endif /* CONFIG_PCI_MSI */ /* if we get here we're going to use the default interrupt mode */ -default_int_mode: c->intr[SIMPLE_MODE_INT] = pdev->irq; return; } -- cgit v1.2.3 From a687fb18cbd061de2092632cf77e6b9dc93cf7cd Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 28 Mar 2006 01:56:17 -0800 Subject: [PATCH] let BLK_DEV_RAM_COUNT depend on BLK_DEV_RAM It's purely cosmetic, but with the patch there's no longer a BLK_DEV_RAM_COUNT setting in the .config if BLK_DEV_RAM=n. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 875ae769902..ae0949b3394 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -383,8 +383,9 @@ config BLK_DEV_RAM thus say N here. config BLK_DEV_RAM_COUNT - int "Default number of RAM disks" if BLK_DEV_RAM + int "Default number of RAM disks" default "16" + depends on BLK_DEV_RAM help The default value is 16 RAM disks. Change this if you know what are doing. If you boot from a filesystem that needs to be extracted -- cgit v1.2.3 From 8637980bab3f09157eef20cc65d2eb7393c770fd Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 28 Mar 2006 01:56:18 -0800 Subject: [PATCH] paride: register_chrdev fix If the user specified `major=0' (odd thing to do), pg.c will use dynamic allocation. We need to pick up that major for subsequent unregister_chrdev(). Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/paride/pg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c index 6f5df0fad70..79b86825403 100644 --- a/drivers/block/paride/pg.c +++ b/drivers/block/paride/pg.c @@ -643,7 +643,8 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t static int __init pg_init(void) { - int unit, err = 0; + int unit; + int err; if (disable){ err = -1; @@ -657,16 +658,17 @@ static int __init pg_init(void) goto out; } - if (register_chrdev(major, name, &pg_fops)) { + err = register_chrdev(major, name, &pg_fops); + if (err < 0) { printk("pg_init: unable to get major number %d\n", major); for (unit = 0; unit < PG_UNITS; unit++) { struct pg *dev = &devices[unit]; if (dev->present) pi_release(dev->pi); } - err = -1; goto out; } + major = err; /* In case the user specified `major=0' (dynamic) */ pg_class = class_create(THIS_MODULE, "pg"); if (IS_ERR(pg_class)) { err = PTR_ERR(pg_class); -- cgit v1.2.3 From 829d5f68ec59ff7c0fdd472132680df8e4b64f3e Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 28 Mar 2006 01:56:18 -0800 Subject: [PATCH] paride-pt: register_chrdev fix If the user specified `major=0' (odd thing to do), pt.c will use dynamic allocation. We need to pick up that major for subsequent unregister_chrdev(). Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/paride/pt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 715ae5dc88f..d2013d36240 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -943,7 +943,8 @@ static ssize_t pt_write(struct file *filp, const char __user *buf, size_t count, static int __init pt_init(void) { - int unit, err = 0; + int unit; + int err; if (disable) { err = -1; @@ -955,14 +956,15 @@ static int __init pt_init(void) goto out; } - if (register_chrdev(major, name, &pt_fops)) { + err = register_chrdev(major, name, &pt_fops); + if (err < 0) { printk("pt_init: unable to get major number %d\n", major); for (unit = 0; unit < PT_UNITS; unit++) if (pt[unit].present) pi_release(pt[unit].pi); - err = -1; goto out; } + major = err; pt_class = class_create(THIS_MODULE, "pt"); if (IS_ERR(pt_class)) { err = PTR_ERR(pt_class); -- cgit v1.2.3 From 3b71797eff4352b4295919efc52de84f84d33d94 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 28 Mar 2006 01:56:25 -0800 Subject: [PATCH] drivers/block/paride/pd.c: fix an off-by-one error The Coverity checker found this off-by-one error. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/paride/pd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 62d2464c12f..2403721f9db 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -151,6 +151,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV}; #include /* for the eject ioctl */ #include #include +#include #include #include #include @@ -275,7 +276,7 @@ static void pd_print_error(struct pd_unit *disk, char *msg, int status) int i; printk("%s: %s: status = 0x%x =", disk->name, msg, status); - for (i = 0; i < 18; i++) + for (i = 0; i < ARRAY_SIZE(pd_errs); i++) if (status & (1 << i)) printk(" %s", pd_errs[i]); printk("\n"); -- cgit v1.2.3 From fa8f399a2bc36c1329672400857757e0982babf3 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Tue, 28 Mar 2006 01:56:28 -0800 Subject: [PATCH] drivers/block/acsi_slm.c: size_t can't be < 0 A size_t can't be < 0. (akpm: and rw_verify_area() already did that check) Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/acsi_slm.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c index a5c1c8e871e..4cb9c133628 100644 --- a/drivers/block/acsi_slm.c +++ b/drivers/block/acsi_slm.c @@ -369,8 +369,6 @@ static ssize_t slm_read( struct file *file, char *buf, size_t count, int length; int end; - if (count < 0) - return( -EINVAL ); if (!(page = __get_free_page( GFP_KERNEL ))) return( -ENOMEM ); -- cgit v1.2.3 From 50297cbf07427b47f0fff5ade8e21cdabf860249 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Tue, 28 Mar 2006 01:56:44 -0800 Subject: [PATCH] drivers/block/*: use time_after() and friends They deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Alexey Dobriyan Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/DAC960.c | 17 +++++++++-------- drivers/block/floppy.c | 9 +++++---- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 49c7cd558dd..45bcda54488 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -3654,8 +3655,8 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command) (NewEnquiry->EventLogSequenceNumber != OldEnquiry->EventLogSequenceNumber) || Controller->MonitoringTimerCount == 0 || - (jiffies - Controller->SecondaryMonitoringTime - >= DAC960_SecondaryMonitoringInterval)) + time_after_eq(jiffies, Controller->SecondaryMonitoringTime + + DAC960_SecondaryMonitoringInterval)) { Controller->V1.NeedLogicalDriveInformation = true; Controller->V1.NewEventLogSequenceNumber = @@ -5640,8 +5641,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData) unsigned int StatusChangeCounter = Controller->V2.HealthStatusBuffer->StatusChangeCounter; boolean ForceMonitoringCommand = false; - if (jiffies - Controller->SecondaryMonitoringTime - > DAC960_SecondaryMonitoringInterval) + if (time_after(jiffies, Controller->SecondaryMonitoringTime + + DAC960_SecondaryMonitoringInterval)) { int LogicalDriveNumber; for (LogicalDriveNumber = 0; @@ -5669,8 +5670,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData) ControllerInfo->ConsistencyChecksActive + ControllerInfo->RebuildsActive + ControllerInfo->OnlineExpansionsActive == 0 || - jiffies - Controller->PrimaryMonitoringTime - < DAC960_MonitoringTimerInterval) && + time_before(jiffies, Controller->PrimaryMonitoringTime + + DAC960_MonitoringTimerInterval)) && !ForceMonitoringCommand) { Controller->MonitoringTimer.expires = @@ -5807,8 +5808,8 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel, Controller->ProgressBufferLength = Length; if (Controller->EphemeralProgressMessage) { - if (jiffies - Controller->LastProgressReportTime - >= DAC960_ProgressReportingInterval) + if (time_after_eq(jiffies, Controller->LastProgressReportTime + + DAC960_ProgressReportingInterval)) { printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel], Controller->ControllerNumber, Buffer); diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index d3ad9081697..bedb689b051 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -170,6 +170,7 @@ static int print_unex = 1; #include #include #include +#include #include #include #include /* CMOS defines */ @@ -747,7 +748,7 @@ static int disk_change(int drive) { int fdc = FDC(drive); #ifdef FLOPPY_SANITY_CHECK - if (jiffies - UDRS->select_date < UDP->select_delay) + if (time_before(jiffies, UDRS->select_date + UDP->select_delay)) DPRINT("WARNING disk change called early\n"); if (!(FDCS->dor & (0x10 << UNIT(drive))) || (FDCS->dor & 3) != UNIT(drive) || fdc != FDC(drive)) { @@ -1075,7 +1076,7 @@ static int fd_wait_for_completion(unsigned long delay, timeout_fn function) return 1; } - if ((signed)(jiffies - delay) < 0) { + if (time_before(jiffies, delay)) { del_timer(&fd_timer); fd_timer.function = function; fd_timer.expires = delay; @@ -1535,7 +1536,7 @@ static void setup_rw_floppy(void) * again just before spinup completion. Beware that * after scandrives, we must again wait for selection. */ - if ((signed)(ready_date - jiffies) > DP->select_delay) { + if (time_after(ready_date, jiffies + DP->select_delay)) { ready_date -= DP->select_delay; function = (timeout_fn) floppy_start; } else @@ -3823,7 +3824,7 @@ static int check_floppy_change(struct gendisk *disk) if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY)) return 1; - if (UDP->checkfreq < (int)(jiffies - UDRS->last_checked)) { + if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { if (floppy_grab_irq_and_dma()) { return 1; } -- cgit v1.2.3 From 910638ae7ed4be27d6af55f6c9b5bf54b838e78b Mon Sep 17 00:00:00 2001 From: Matthias Gehre Date: Tue, 28 Mar 2006 01:56:48 -0800 Subject: [PATCH] Replace 0xff.. with correct DMA_xBIT_MASK Replace all occurences of 0xff.. in calls to function pci_set_dma_mask() and pci_set_consistant_dma_mask() with the corresponding DMA_xBIT_MASK from linux/dma-mapping.h. Signed-off-by: Matthias Gehre Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/umem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/umem.c b/drivers/block/umem.c index c16e66b9c7a..f7d4c65a7b8 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -50,6 +50,7 @@ #include #include #include +#include #include /* O_ACCMODE */ #include /* HDIO_GETGEO */ @@ -881,8 +882,8 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i printk(KERN_INFO "Micro Memory(tm) controller #%d found at %02x:%02x (PCI Mem Module (Battery Backup))\n", card->card_number, dev->bus->number, dev->devfn); - if (pci_set_dma_mask(dev, 0xffffffffffffffffLL) && - pci_set_dma_mask(dev, 0xffffffffLL)) { + if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && + pci_set_dma_mask(dev, DMA_32BIT_MASK)) { printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards); return -ENOMEM; } -- cgit v1.2.3