diff options
author | Mariusz Kozlowski <m.kozlowski@tuxland.pl> | 2007-08-10 17:50:50 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-10-12 14:47:10 -0400 |
commit | d7383a234626b58dc6bc210ed806a6911c1f44e1 (patch) | |
tree | 82e2f35be691a980a88d6fe20f285811bd8d3eb7 /drivers/message | |
parent | 1d9a3d06511751f02d9767de3e4d28d4dafc63b3 (diff) |
[SCSI] mpt fusion: mostly kmalloc + memset conversion to kzalloc
This patch does kmalloc + memset conversion to kzalloc anSigned-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
d simplifies mptctl_probe().
drivers/message/fusion/mptctl.c | 82092 -> 81884 (-208 bytes)
drivers/message/fusion/mptctl.o | 201784 -> 200648 (-1136 bytes)
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Acked-by: "Moore, Eric Dean" <Eric.Moore@lsil.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/message')
-rw-r--r-- | drivers/message/fusion/mptctl.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index b9618f4e3ab6..12dfa2e84f0f 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -977,10 +977,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
977 | * structures for the SG elements. | 977 | * structures for the SG elements. |
978 | */ | 978 | */ |
979 | i = MAX_SGL_BYTES / 8; | 979 | i = MAX_SGL_BYTES / 8; |
980 | buflist = kmalloc(i, GFP_USER); | 980 | buflist = kzalloc(i, GFP_USER); |
981 | if (buflist == NULL) | 981 | if (!buflist) |
982 | return NULL; | 982 | return NULL; |
983 | memset(buflist, 0, i); | ||
984 | buflist_ent = 0; | 983 | buflist_ent = 0; |
985 | 984 | ||
986 | /* Allocate a single block of memory to store the sg elements and | 985 | /* Allocate a single block of memory to store the sg elements and |
@@ -1379,13 +1378,12 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1379 | * 15- 8: Bus Number | 1378 | * 15- 8: Bus Number |
1380 | * 7- 0: Target ID | 1379 | * 7- 0: Target ID |
1381 | */ | 1380 | */ |
1382 | pmem = kmalloc(numBytes, GFP_KERNEL); | 1381 | pmem = kzalloc(numBytes, GFP_KERNEL); |
1383 | if (pmem == NULL) { | 1382 | if (!pmem) { |
1384 | printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", | 1383 | printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", |
1385 | __FILE__, __LINE__); | 1384 | __FILE__, __LINE__); |
1386 | return -ENOMEM; | 1385 | return -ENOMEM; |
1387 | } | 1386 | } |
1388 | memset(pmem, 0, numBytes); | ||
1389 | pdata = (int *) pmem; | 1387 | pdata = (int *) pmem; |
1390 | 1388 | ||
1391 | /* Get number of devices | 1389 | /* Get number of devices |
@@ -1570,12 +1568,11 @@ mptctl_eventenable (unsigned long arg) | |||
1570 | /* Have not yet allocated memory - do so now. | 1568 | /* Have not yet allocated memory - do so now. |
1571 | */ | 1569 | */ |
1572 | int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); | 1570 | int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); |
1573 | ioc->events = kmalloc(sz, GFP_KERNEL); | 1571 | ioc->events = kzalloc(sz, GFP_KERNEL); |
1574 | if (ioc->events == NULL) { | 1572 | if (!ioc->events) { |
1575 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); | 1573 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); |
1576 | return -ENOMEM; | 1574 | return -ENOMEM; |
1577 | } | 1575 | } |
1578 | memset(ioc->events, 0, sz); | ||
1579 | ioc->alloc_total += sz; | 1576 | ioc->alloc_total += sz; |
1580 | 1577 | ||
1581 | ioc->eventContext = 0; | 1578 | ioc->eventContext = 0; |
@@ -2865,31 +2862,22 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
2865 | static int | 2862 | static int |
2866 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 2863 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2867 | { | 2864 | { |
2868 | int err; | 2865 | MPT_IOCTL *mem; |
2869 | int sz; | ||
2870 | u8 *mem; | ||
2871 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 2866 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
2872 | 2867 | ||
2873 | /* | 2868 | /* |
2874 | * Allocate and inite a MPT_IOCTL structure | 2869 | * Allocate and inite a MPT_IOCTL structure |
2875 | */ | 2870 | */ |
2876 | sz = sizeof (MPT_IOCTL); | 2871 | mem = kzalloc(sizeof(MPT_IOCTL), GFP_KERNEL); |
2877 | mem = kmalloc(sz, GFP_KERNEL); | 2872 | if (!mem) { |
2878 | if (mem == NULL) { | 2873 | mptctl_remove(pdev); |
2879 | err = -ENOMEM; | 2874 | return -ENOMEM; |
2880 | goto out_fail; | ||
2881 | } | 2875 | } |
2882 | 2876 | ||
2883 | memset(mem, 0, sz); | 2877 | ioc->ioctl = mem; |
2884 | ioc->ioctl = (MPT_IOCTL *) mem; | ||
2885 | ioc->ioctl->ioc = ioc; | 2878 | ioc->ioctl->ioc = ioc; |
2886 | mutex_init(&ioc->ioctl->ioctl_mutex); | 2879 | mutex_init(&ioc->ioctl->ioctl_mutex); |
2887 | return 0; | 2880 | return 0; |
2888 | |||
2889 | out_fail: | ||
2890 | |||
2891 | mptctl_remove(pdev); | ||
2892 | return err; | ||
2893 | } | 2881 | } |
2894 | 2882 | ||
2895 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2883 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |