Skip to content

Commit 40953ed

Browse files
Jes SorensenLinus Torvalds
authored andcommitted
[PATCH] snsc kmalloc2kzalloc
Change driver to use kzalloc rather than kmalloc+memset Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 6b9438e commit 40953ed

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

‎drivers/char/snsc.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* License. See the file "COPYING" in the main directory of this archive
66
* for more details.
77
*
8-
* Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
8+
* Copyright (C) 2004, 2006 Silicon Graphics, Inc. All rights reserved.
99
*/
1010

1111
/*
@@ -77,15 +77,14 @@ scdrv_open(struct inode *inode, struct file *file)
7777
scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev);
7878

7979
/* allocate memory for subchannel data */
80-
sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL);
80+
sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
8181
if (sd == NULL) {
8282
printk("%s: couldn't allocate subchannel data\n",
8383
__FUNCTION__);
8484
return -ENOMEM;
8585
}
8686

8787
/* initialize subch_data_s fields */
88-
memset(sd, 0, sizeof (struct subch_data_s));
8988
sd->sd_nasid = scd->scd_nasid;
9089
sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid);
9190

@@ -394,15 +393,14 @@ scdrv_init(void)
394393
sprintf(devnamep, "#%d", geo_slab(geoid));
395394

396395
/* allocate sysctl device data */
397-
scd = kmalloc(sizeof (struct sysctl_data_s),
396+
scd = kzalloc(sizeof (struct sysctl_data_s),
398397
GFP_KERNEL);
399398
if (!scd) {
400399
printk("%s: failed to allocate device info"
401400
"for %s/%s\n", __FUNCTION__,
402401
SYSCTL_BASENAME, devname);
403402
continue;
404403
}
405-
memset(scd, 0, sizeof (struct sysctl_data_s));
406404

407405
/* initialize sysctl device data fields */
408406
scd->scd_nasid = cnodeid_to_nasid(cnode);

‎drivers/char/snsc_event.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,14 @@ scdrv_event_init(struct sysctl_data_s *scd)
287287
{
288288
int rv;
289289

290-
event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL);
290+
event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
291291
if (event_sd == NULL) {
292292
printk(KERN_WARNING "%s: couldn't allocate subchannel info"
293293
" for event monitoring\n", __FUNCTION__);
294294
return;
295295
}
296296

297297
/* initialize subch_data_s fields */
298-
memset(event_sd, 0, sizeof (struct subch_data_s));
299298
event_sd->sd_nasid = scd->scd_nasid;
300299
spin_lock_init(&event_sd->sd_rlock);
301300

@@ -321,5 +320,3 @@ scdrv_event_init(struct sysctl_data_s *scd)
321320
return;
322321
}
323322
}
324-
325-

0 commit comments

Comments
 (0)