* [KJ] kmalloc to kzalloc patches for drivers/mfd
@ 2006-09-18 0:53 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:53 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Tested by compiling.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/mfd/mcp-core.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c
index 75f401d..b4ed57e 100644
--- a/drivers/mfd/mcp-core.c
+++ b/drivers/mfd/mcp-core.c
@@ -200,9 +200,8 @@ struct mcp *mcp_host_alloc(struct device
{
struct mcp *mcp;
- mcp = kmalloc(sizeof(struct mcp) + size, GFP_KERNEL);
+ mcp = kzalloc(sizeof(struct mcp) + size, GFP_KERNEL);
if (mcp) {
- memset(mcp, 0, sizeof(struct mcp) + size);
spin_lock_init(&mcp->lock);
mcp->attached_device.parent = parent;
mcp->attached_device.bus = &mcp_bus_type;
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* kmalloc to kzalloc patches for drivers/mfd
@ 2006-09-18 0:53 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:53 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Tested by compiling.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/mfd/mcp-core.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c
index 75f401d..b4ed57e 100644
--- a/drivers/mfd/mcp-core.c
+++ b/drivers/mfd/mcp-core.c
@@ -200,9 +200,8 @@ struct mcp *mcp_host_alloc(struct device
{
struct mcp *mcp;
- mcp = kmalloc(sizeof(struct mcp) + size, GFP_KERNEL);
+ mcp = kzalloc(sizeof(struct mcp) + size, GFP_KERNEL);
if (mcp) {
- memset(mcp, 0, sizeof(struct mcp) + size);
spin_lock_init(&mcp->lock);
mcp->attached_device.parent = parent;
mcp->attached_device.bus = &mcp_bus_type;
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [KJ] kmalloc to kzalloc patches for drivers/atm
@ 2006-09-18 0:53 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:53 UTC (permalink / raw)
To: linux-kernel, kernel-janitors, linux-atm-general
Tested by compiling.
I have not subscribed to ATM list. Please cc me any comments.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/atm/adummy.c | 4 +---
drivers/atm/atmtcp.c | 2 +-
drivers/atm/firestream.c | 13 +++----------
drivers/atm/he.c | 6 ++----
drivers/atm/horizon.c | 6 ++----
drivers/atm/idt77105.c | 2 +-
drivers/atm/idt77252.c | 21 ++++++---------------
drivers/atm/iphase.c | 22 ++++++++++------------
drivers/atm/lanai.c | 10 ++--------
drivers/atm/nicstar.c | 12 ++++++------
drivers/atm/suni.c | 2 +-
drivers/atm/uPD98402.c | 2 +-
drivers/atm/zatm.c | 12 +++++-------
13 files changed, 41 insertions(+), 73 deletions(-)
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6cc93de..a3c3f3b 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
- adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+ adummy_dev = (struct adummy_dev *) kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL);
if (!adummy_dev) {
printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
err = -ENOMEM;
goto out;
}
- memset(adummy_dev, 0, sizeof(struct adummy_dev));
-
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index fc518d8..35dedb5 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -361,7 +361,7 @@ static int atmtcp_create(int itf,int per
struct atmtcp_dev_data *dev_data;
struct atm_dev *dev;
- dev_data = kmalloc(sizeof(*dev_data),GFP_KERNEL);
+ dev_data = kzalloc(sizeof(*dev_data),GFP_KERNEL);
if (!dev_data)
return -ENOMEM;
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38fc054..fafcdb2 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS;
}
- dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
+ dev->atm_vccs = kzalloc (dev->nchannels * sizeof (struct atm_vcc *),
GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1794,7 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
-
- dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+ dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8);
@@ -1805,8 +1803,6 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1893,14 +1889,11 @@ static int __devinit firestream_init_one
if (pci_enable_device(pci_dev))
goto err_out;
- fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+ fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev));
if (!fs_dev)
goto err_out;
-
- memset (fs_dev, 0, sizeof (struct fs_dev));
-
atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev)
goto err_out_free_fs_dev;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index d369130..7e92a6f 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, con
}
pci_set_drvdata(pci_dev, atm_dev);
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+ he_dev = (struct he_dev *) kzalloc(sizeof(struct he_dev),
GFP_KERNEL);
if (!he_dev) {
err = -ENOMEM;
goto init_one_failure;
}
- memset(he_dev, 0, sizeof(struct he_dev));
-
he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev;
@@ -675,7 +673,7 @@ he_init_cs_block_rcm(struct he_dev *he_d
unsigned long long rate_cps;
int mult, buf, buf_limit = 4;
- rategrid = kmalloc( sizeof(unsigned) * 16 * 16, GFP_KERNEL);
+ rategrid = kzalloc( sizeof(unsigned) * 16 * 16, GFP_KERNEL);
if (!rategrid)
return -ENOMEM;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index d1113e8..e993a4f 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2457,7 +2457,7 @@ #endif
}
// get space for our vcc stuff and copy parameters into it
- vccp = kmalloc (sizeof(hrz_vcc), GFP_KERNEL);
+ vccp = kzalloc (sizeof(hrz_vcc), GFP_KERNEL);
if (!vccp) {
PRINTK (KERN_ERR, "out of memory!");
return -ENOMEM;
@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pc
goto out_disable;
}
- dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) {
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pc
goto out_release;
}
- memset(dev, 0, sizeof(hrz_dev));
-
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
index 325325a..44644df 100644
--- a/drivers/atm/idt77105.c
+++ b/drivers/atm/idt77105.c
@@ -262,7 +262,7 @@ static int idt77105_start(struct atm_dev
{
unsigned long flags;
- if (!(dev->dev_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
+ if (!(dev->dev_data = kzalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
return -ENOMEM;
PRIV(dev)->dev = dev;
spin_lock_irqsave(&idt77105_priv_lock, flags);
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b0369bb..d4c9ad2 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
{
struct scq_info *scq;
- scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+ scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq)
return NULL;
- memset(scq, 0, sizeof(struct scq_info));
-
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr);
if (scq->base = NULL) {
@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int
{
struct rate_estimator *est;
- est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+ est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est)
return NULL;
- memset(est, 0, sizeof(*est));
-
est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps;
est->avcps = est->cps << 5;
@@ -2451,7 +2447,7 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) {
- card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex);
@@ -2926,13 +2922,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci);
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
-
vc->index = index;
card->vcs[index] = vc;
@@ -2995,12 +2989,11 @@ open_card_ubr0(struct idt77252_dev *card
{
struct vc_map *vc;
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc;
vc->class = SCHED_UBR0;
@@ -3695,14 +3688,12 @@ idt77252_init_one(struct pci_dev *pcidev
goto err_out_disable_pdev;
}
- card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+ card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) {
printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM;
goto err_out_disable_pdev;
}
- memset(card, 0, sizeof(struct idt77252_dev));
-
card->revision = revision;
card->index = index;
card->pcidev = pcidev;
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index f20b0b2..a84e238 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -118,7 +118,7 @@ static void ia_enque_head_rtn_q (IARTN_Q
}
static int ia_enque_rtn_q (IARTN_Q *que, struct desc_tbl_t data) {
- IARTN_Q *entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+ IARTN_Q *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) return -1;
entry->data = data;
entry->next = NULL;
@@ -1601,14 +1601,13 @@ static int rx_init(struct atm_dev *dev)
skb_queue_head_init(&iadev->rx_dma_q);
iadev->rx_free_desc_qhead = NULL;
- iadev->rx_open = kmalloc(4*iadev->num_vc,GFP_KERNEL);
+ iadev->rx_open = kzalloc(4*iadev->num_vc,GFP_KERNEL);
if (!iadev->rx_open)
{
printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
dev->number);
goto err_free_dle;
}
- memset(iadev->rx_open, 0, 4*iadev->num_vc);
iadev->rxing = 1;
iadev->rx_pkt_cnt = 0;
/* Mode Register */
@@ -1959,7 +1958,7 @@ static int tx_init(struct atm_dev *dev)
buf_desc_ptr++;
tx_pkt_start += iadev->tx_buf_sz;
}
- iadev->tx_buf = kmalloc(iadev->num_tx_desc*sizeof(struct
cpcs_trailer_desc), GFP_KERNEL);
+ iadev->tx_buf = kzalloc(iadev->num_tx_desc*sizeof(struct
cpcs_trailer_desc), GFP_KERNEL);
if (!iadev->tx_buf) {
printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
goto err_free_dle;
@@ -1968,7 +1967,7 @@ static int tx_init(struct atm_dev *dev)
{
struct cpcs_trailer *cpcs;
- cpcs = kmalloc(sizeof(*cpcs), GFP_KERNEL|GFP_DMA);
+ cpcs = kzalloc(sizeof(*cpcs), GFP_KERNEL|GFP_DMA);
if(!cpcs) {
printk(KERN_ERR DEV_LABEL " couldn't get freepage\n");
goto err_free_tx_bufs;
@@ -1977,7 +1976,7 @@ static int tx_init(struct atm_dev *dev)
iadev->tx_buf[i].dma_addr = pci_map_single(iadev->pci,
cpcs, sizeof(*cpcs), PCI_DMA_TODEVICE);
}
- iadev->desc_tbl = kmalloc(iadev->num_tx_desc *
+ iadev->desc_tbl = kzalloc(iadev->num_tx_desc *
sizeof(struct desc_tbl_t), GFP_KERNEL);
if (!iadev->desc_tbl) {
printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
@@ -2106,7 +2105,7 @@ #endif
memset((caddr_t)(iadev->seg_ram+i), 0, iadev->num_vc*4);
vc = (struct main_vc *)iadev->MAIN_VC_TABLE_ADDR;
evc = (struct ext_vc *)iadev->EXT_VC_TABLE_ADDR;
- iadev->testTable = kmalloc(sizeof(long)*iadev->num_vc, GFP_KERNEL);
+ iadev->testTable = kzalloc(sizeof(long)*iadev->num_vc, GFP_KERNEL);
if (!iadev->testTable) {
printk("Get freepage failed\n");
goto err_free_desc_tbl;
@@ -2115,7 +2114,7 @@ #endif
{
memset((caddr_t)vc, 0, sizeof(*vc));
memset((caddr_t)evc, 0, sizeof(*evc));
- iadev->testTable[i] = kmalloc(sizeof(struct testTable_t),
+ iadev->testTable[i] = kzalloc(sizeof(struct testTable_t),
GFP_KERNEL);
if (!iadev->testTable[i])
goto err_free_test_tables;
@@ -2695,7 +2694,7 @@ static int ia_open(struct atm_vcc *vcc)
vcc->dev->number, vcc->vpi, vcc->vci);)
/* Device dependent initialization */
- ia_vcc = kmalloc(sizeof(*ia_vcc), GFP_KERNEL);
+ ia_vcc = kzalloc(sizeof(*ia_vcc), GFP_KERNEL);
if (!ia_vcc) return -ENOMEM;
vcc->dev_data = ia_vcc;
@@ -2784,7 +2783,7 @@ static int ia_ioctl(struct atm_dev *dev,
rfredn_t *rfL;
if (!capable(CAP_NET_ADMIN)) return -EPERM;
- regs_local = kmalloc(sizeof(*regs_local), GFP_KERNEL);
+ regs_local = kzalloc(sizeof(*regs_local), GFP_KERNEL);
if (!regs_local) return -ENOMEM;
ffL = ®s_local->ffredn;
rfL = ®s_local->rfredn;
@@ -3174,12 +3173,11 @@ static int __devinit ia_init_one(struct
unsigned long flags;
int ret;
- iadev = kmalloc(sizeof(*iadev), GFP_KERNEL);
+ iadev = kzalloc(sizeof(*iadev), GFP_KERNEL);
if (!iadev) {
ret = -ENOMEM;
goto err_out;
}
- memset(iadev, 0, sizeof(*iadev));
iadev->pci = pdev;
IF_INIT(printk("ia detected at bus:%d dev: %d function:%d\n",
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index fe60a59..4974b68 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1482,16 +1482,10 @@ #endif
static inline struct lanai_vcc *new_lanai_vcc(void)
{
struct lanai_vcc *lvcc;
- lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
+ lvcc = (struct lanai_vcc *) kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) {
- lvcc->vbase = NULL;
- lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
- lvcc->nref = 0;
- memset(&lvcc->stats, 0, sizeof lvcc->stats);
- lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG
- lvcc->tx.unqueue = NULL;
lvcc->vci = -1;
#endif
}
@@ -2610,7 +2604,7 @@ static int __devinit lanai_init_one(stru
struct atm_dev *atmdev;
int result;
- lanai = (struct lanai_dev *) kmalloc(sizeof(*lanai), GFP_KERNEL);
+ lanai = (struct lanai_dev *) kzalloc(sizeof(*lanai), GFP_KERNEL);
if (lanai = NULL) {
printk(KERN_ERR DEV_LABEL
": couldn't allocate dev_data structure!\n");
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index b803689..a4d1346 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -476,7 +476,7 @@ static int __devinit ns_init_card(int i,
return error;
}
- if ((card = kmalloc(sizeof(ns_dev), GFP_KERNEL)) = NULL)
+ if ((card = kzalloc(sizeof(ns_dev), GFP_KERNEL)) = NULL)
{
printk("nicstar%d: can't allocate memory for device structure.\n", i);
error = 2;
@@ -637,7 +637,7 @@ #endif
writel(0x00000000, card->membase + VPM);
/* Initialize TSQ */
- card->tsq.org = kmalloc(NS_TSQSIZE + NS_TSQ_ALIGNMENT, GFP_KERNEL);
+ card->tsq.org = kzalloc(NS_TSQSIZE + NS_TSQ_ALIGNMENT, GFP_KERNEL);
if (card->tsq.org = NULL)
{
printk("nicstar%d: can't allocate TSQ.\n", i);
@@ -656,7 +656,7 @@ #endif
(u32) virt_to_bus(card->tsq.base), readl(card->membase + TSQB));
/* Initialize RSQ */
- card->rsq.org = kmalloc(NS_RSQSIZE + NS_RSQ_ALIGNMENT, GFP_KERNEL);
+ card->rsq.org = kzalloc(NS_RSQSIZE + NS_RSQ_ALIGNMENT, GFP_KERNEL);
if (card->rsq.org = NULL)
{
printk("nicstar%d: can't allocate RSQ.\n", i);
@@ -997,16 +997,16 @@ static scq_info *get_scq(int size, u32 s
if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
return NULL;
- scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL);
+ scq = (scq_info *) kzalloc(sizeof(scq_info), GFP_KERNEL);
if (scq = NULL)
return NULL;
- scq->org = kmalloc(2 * size, GFP_KERNEL);
+ scq->org = kzalloc(2 * size, GFP_KERNEL);
if (scq->org = NULL)
{
kfree(scq);
return NULL;
}
- scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) *
+ scq->skb = (struct sk_buff **) kzalloc(sizeof(struct sk_buff *) *
(size / NS_SCQE_SIZE), GFP_KERNEL);
if (scq->skb = NULL)
{
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
index f04f39c..afbf0c6 100644
--- a/drivers/atm/suni.c
+++ b/drivers/atm/suni.c
@@ -229,7 +229,7 @@ static int suni_start(struct atm_dev *de
unsigned long flags;
int first;
- if (!(dev->phy_data = kmalloc(sizeof(struct suni_priv),GFP_KERNEL)))
+ if (!(dev->phy_data = kzalloc(sizeof(struct suni_priv),GFP_KERNEL)))
return -ENOMEM;
PRIV(dev)->dev = dev;
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
index 9504cce..862bd49 100644
--- a/drivers/atm/uPD98402.c
+++ b/drivers/atm/uPD98402.c
@@ -210,7 +210,7 @@ static void uPD98402_int(struct atm_dev
static int uPD98402_start(struct atm_dev *dev)
{
DPRINTK("phy_start\n");
- if (!(dev->dev_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
+ if (!(dev->dev_data = kzalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
return -ENOMEM;
spin_lock_init(&PRIV(dev)->lock);
memset(&PRIV(dev)->sonet_stats,0,sizeof(struct k_sonet_stats));
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2c65e82..5f83691 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = (struct atm_vcc **) kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
- memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */
@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc
skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */
- zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
+ zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM;
- memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0;
@@ -997,7 +995,7 @@ static int start_tx(struct atm_dev *dev)
DPRINTK("start_tx\n");
zatm_dev = ZATM_DEV(dev);
- zatm_dev->tx_map = (struct atm_vcc **) kmalloc(sizeof(struct atm_vcc *)*
+ zatm_dev->tx_map = (struct atm_vcc **) kzalloc(sizeof(struct atm_vcc *)*
zatm_dev->chans,GFP_KERNEL);
if (!zatm_dev->tx_map) return -ENOMEM;
zatm_dev->tx_bw = ATM_OC3_PCR;
@@ -1399,7 +1397,7 @@ static int zatm_open(struct atm_vcc *vcc
DPRINTK(DEV_LABEL "(itf %d): open %d.%d\n",vcc->dev->number,vcc->vpi,
vcc->vci);
if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) {
- zatm_vcc = kmalloc(sizeof(struct zatm_vcc),GFP_KERNEL);
+ zatm_vcc = kzalloc(sizeof(struct zatm_vcc),GFP_KERNEL);
if (!zatm_vcc) {
clear_bit(ATM_VF_ADDR,&vcc->flags);
return -ENOMEM;
@@ -1592,7 +1590,7 @@ static int __devinit zatm_init_one(struc
struct zatm_dev *zatm_dev;
int ret = -ENOMEM;
- zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL);
+ zatm_dev = (struct zatm_dev *) kzalloc(sizeof(*zatm_dev), GFP_KERNEL);
if (!zatm_dev) {
printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL);
goto out;
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* kmalloc to kzalloc patches for drivers/atm
@ 2006-09-18 0:53 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:53 UTC (permalink / raw)
To: linux-kernel, kernel-janitors, linux-atm-general
Tested by compiling.
I have not subscribed to ATM list. Please cc me any comments.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/atm/adummy.c | 4 +---
drivers/atm/atmtcp.c | 2 +-
drivers/atm/firestream.c | 13 +++----------
drivers/atm/he.c | 6 ++----
drivers/atm/horizon.c | 6 ++----
drivers/atm/idt77105.c | 2 +-
drivers/atm/idt77252.c | 21 ++++++---------------
drivers/atm/iphase.c | 22 ++++++++++------------
drivers/atm/lanai.c | 10 ++--------
drivers/atm/nicstar.c | 12 ++++++------
drivers/atm/suni.c | 2 +-
drivers/atm/uPD98402.c | 2 +-
drivers/atm/zatm.c | 12 +++++-------
13 files changed, 41 insertions(+), 73 deletions(-)
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6cc93de..a3c3f3b 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
- adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+ adummy_dev = (struct adummy_dev *) kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL);
if (!adummy_dev) {
printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
err = -ENOMEM;
goto out;
}
- memset(adummy_dev, 0, sizeof(struct adummy_dev));
-
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index fc518d8..35dedb5 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -361,7 +361,7 @@ static int atmtcp_create(int itf,int per
struct atmtcp_dev_data *dev_data;
struct atm_dev *dev;
- dev_data = kmalloc(sizeof(*dev_data),GFP_KERNEL);
+ dev_data = kzalloc(sizeof(*dev_data),GFP_KERNEL);
if (!dev_data)
return -ENOMEM;
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38fc054..fafcdb2 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS;
}
- dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
+ dev->atm_vccs = kzalloc (dev->nchannels * sizeof (struct atm_vcc *),
GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1794,7 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
-
- dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+ dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8);
@@ -1805,8 +1803,6 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1893,14 +1889,11 @@ static int __devinit firestream_init_one
if (pci_enable_device(pci_dev))
goto err_out;
- fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+ fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev));
if (!fs_dev)
goto err_out;
-
- memset (fs_dev, 0, sizeof (struct fs_dev));
-
atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev)
goto err_out_free_fs_dev;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index d369130..7e92a6f 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, con
}
pci_set_drvdata(pci_dev, atm_dev);
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+ he_dev = (struct he_dev *) kzalloc(sizeof(struct he_dev),
GFP_KERNEL);
if (!he_dev) {
err = -ENOMEM;
goto init_one_failure;
}
- memset(he_dev, 0, sizeof(struct he_dev));
-
he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev;
@@ -675,7 +673,7 @@ he_init_cs_block_rcm(struct he_dev *he_d
unsigned long long rate_cps;
int mult, buf, buf_limit = 4;
- rategrid = kmalloc( sizeof(unsigned) * 16 * 16, GFP_KERNEL);
+ rategrid = kzalloc( sizeof(unsigned) * 16 * 16, GFP_KERNEL);
if (!rategrid)
return -ENOMEM;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index d1113e8..e993a4f 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2457,7 +2457,7 @@ #endif
}
// get space for our vcc stuff and copy parameters into it
- vccp = kmalloc (sizeof(hrz_vcc), GFP_KERNEL);
+ vccp = kzalloc (sizeof(hrz_vcc), GFP_KERNEL);
if (!vccp) {
PRINTK (KERN_ERR, "out of memory!");
return -ENOMEM;
@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pc
goto out_disable;
}
- dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) {
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pc
goto out_release;
}
- memset(dev, 0, sizeof(hrz_dev));
-
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
index 325325a..44644df 100644
--- a/drivers/atm/idt77105.c
+++ b/drivers/atm/idt77105.c
@@ -262,7 +262,7 @@ static int idt77105_start(struct atm_dev
{
unsigned long flags;
- if (!(dev->dev_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
+ if (!(dev->dev_data = kzalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
return -ENOMEM;
PRIV(dev)->dev = dev;
spin_lock_irqsave(&idt77105_priv_lock, flags);
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b0369bb..d4c9ad2 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
{
struct scq_info *scq;
- scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+ scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq)
return NULL;
- memset(scq, 0, sizeof(struct scq_info));
-
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr);
if (scq->base == NULL) {
@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int
{
struct rate_estimator *est;
- est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+ est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est)
return NULL;
- memset(est, 0, sizeof(*est));
-
est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps;
est->avcps = est->cps << 5;
@@ -2451,7 +2447,7 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) {
- card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex);
@@ -2926,13 +2922,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci);
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
-
vc->index = index;
card->vcs[index] = vc;
@@ -2995,12 +2989,11 @@ open_card_ubr0(struct idt77252_dev *card
{
struct vc_map *vc;
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc;
vc->class = SCHED_UBR0;
@@ -3695,14 +3688,12 @@ idt77252_init_one(struct pci_dev *pcidev
goto err_out_disable_pdev;
}
- card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+ card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) {
printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM;
goto err_out_disable_pdev;
}
- memset(card, 0, sizeof(struct idt77252_dev));
-
card->revision = revision;
card->index = index;
card->pcidev = pcidev;
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index f20b0b2..a84e238 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -118,7 +118,7 @@ static void ia_enque_head_rtn_q (IARTN_Q
}
static int ia_enque_rtn_q (IARTN_Q *que, struct desc_tbl_t data) {
- IARTN_Q *entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+ IARTN_Q *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) return -1;
entry->data = data;
entry->next = NULL;
@@ -1601,14 +1601,13 @@ static int rx_init(struct atm_dev *dev)
skb_queue_head_init(&iadev->rx_dma_q);
iadev->rx_free_desc_qhead = NULL;
- iadev->rx_open = kmalloc(4*iadev->num_vc,GFP_KERNEL);
+ iadev->rx_open = kzalloc(4*iadev->num_vc,GFP_KERNEL);
if (!iadev->rx_open)
{
printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
dev->number);
goto err_free_dle;
}
- memset(iadev->rx_open, 0, 4*iadev->num_vc);
iadev->rxing = 1;
iadev->rx_pkt_cnt = 0;
/* Mode Register */
@@ -1959,7 +1958,7 @@ static int tx_init(struct atm_dev *dev)
buf_desc_ptr++;
tx_pkt_start += iadev->tx_buf_sz;
}
- iadev->tx_buf = kmalloc(iadev->num_tx_desc*sizeof(struct
cpcs_trailer_desc), GFP_KERNEL);
+ iadev->tx_buf = kzalloc(iadev->num_tx_desc*sizeof(struct
cpcs_trailer_desc), GFP_KERNEL);
if (!iadev->tx_buf) {
printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
goto err_free_dle;
@@ -1968,7 +1967,7 @@ static int tx_init(struct atm_dev *dev)
{
struct cpcs_trailer *cpcs;
- cpcs = kmalloc(sizeof(*cpcs), GFP_KERNEL|GFP_DMA);
+ cpcs = kzalloc(sizeof(*cpcs), GFP_KERNEL|GFP_DMA);
if(!cpcs) {
printk(KERN_ERR DEV_LABEL " couldn't get freepage\n");
goto err_free_tx_bufs;
@@ -1977,7 +1976,7 @@ static int tx_init(struct atm_dev *dev)
iadev->tx_buf[i].dma_addr = pci_map_single(iadev->pci,
cpcs, sizeof(*cpcs), PCI_DMA_TODEVICE);
}
- iadev->desc_tbl = kmalloc(iadev->num_tx_desc *
+ iadev->desc_tbl = kzalloc(iadev->num_tx_desc *
sizeof(struct desc_tbl_t), GFP_KERNEL);
if (!iadev->desc_tbl) {
printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
@@ -2106,7 +2105,7 @@ #endif
memset((caddr_t)(iadev->seg_ram+i), 0, iadev->num_vc*4);
vc = (struct main_vc *)iadev->MAIN_VC_TABLE_ADDR;
evc = (struct ext_vc *)iadev->EXT_VC_TABLE_ADDR;
- iadev->testTable = kmalloc(sizeof(long)*iadev->num_vc, GFP_KERNEL);
+ iadev->testTable = kzalloc(sizeof(long)*iadev->num_vc, GFP_KERNEL);
if (!iadev->testTable) {
printk("Get freepage failed\n");
goto err_free_desc_tbl;
@@ -2115,7 +2114,7 @@ #endif
{
memset((caddr_t)vc, 0, sizeof(*vc));
memset((caddr_t)evc, 0, sizeof(*evc));
- iadev->testTable[i] = kmalloc(sizeof(struct testTable_t),
+ iadev->testTable[i] = kzalloc(sizeof(struct testTable_t),
GFP_KERNEL);
if (!iadev->testTable[i])
goto err_free_test_tables;
@@ -2695,7 +2694,7 @@ static int ia_open(struct atm_vcc *vcc)
vcc->dev->number, vcc->vpi, vcc->vci);)
/* Device dependent initialization */
- ia_vcc = kmalloc(sizeof(*ia_vcc), GFP_KERNEL);
+ ia_vcc = kzalloc(sizeof(*ia_vcc), GFP_KERNEL);
if (!ia_vcc) return -ENOMEM;
vcc->dev_data = ia_vcc;
@@ -2784,7 +2783,7 @@ static int ia_ioctl(struct atm_dev *dev,
rfredn_t *rfL;
if (!capable(CAP_NET_ADMIN)) return -EPERM;
- regs_local = kmalloc(sizeof(*regs_local), GFP_KERNEL);
+ regs_local = kzalloc(sizeof(*regs_local), GFP_KERNEL);
if (!regs_local) return -ENOMEM;
ffL = ®s_local->ffredn;
rfL = ®s_local->rfredn;
@@ -3174,12 +3173,11 @@ static int __devinit ia_init_one(struct
unsigned long flags;
int ret;
- iadev = kmalloc(sizeof(*iadev), GFP_KERNEL);
+ iadev = kzalloc(sizeof(*iadev), GFP_KERNEL);
if (!iadev) {
ret = -ENOMEM;
goto err_out;
}
- memset(iadev, 0, sizeof(*iadev));
iadev->pci = pdev;
IF_INIT(printk("ia detected at bus:%d dev: %d function:%d\n",
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index fe60a59..4974b68 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1482,16 +1482,10 @@ #endif
static inline struct lanai_vcc *new_lanai_vcc(void)
{
struct lanai_vcc *lvcc;
- lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
+ lvcc = (struct lanai_vcc *) kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) {
- lvcc->vbase = NULL;
- lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
- lvcc->nref = 0;
- memset(&lvcc->stats, 0, sizeof lvcc->stats);
- lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG
- lvcc->tx.unqueue = NULL;
lvcc->vci = -1;
#endif
}
@@ -2610,7 +2604,7 @@ static int __devinit lanai_init_one(stru
struct atm_dev *atmdev;
int result;
- lanai = (struct lanai_dev *) kmalloc(sizeof(*lanai), GFP_KERNEL);
+ lanai = (struct lanai_dev *) kzalloc(sizeof(*lanai), GFP_KERNEL);
if (lanai == NULL) {
printk(KERN_ERR DEV_LABEL
": couldn't allocate dev_data structure!\n");
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index b803689..a4d1346 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -476,7 +476,7 @@ static int __devinit ns_init_card(int i,
return error;
}
- if ((card = kmalloc(sizeof(ns_dev), GFP_KERNEL)) == NULL)
+ if ((card = kzalloc(sizeof(ns_dev), GFP_KERNEL)) == NULL)
{
printk("nicstar%d: can't allocate memory for device structure.\n", i);
error = 2;
@@ -637,7 +637,7 @@ #endif
writel(0x00000000, card->membase + VPM);
/* Initialize TSQ */
- card->tsq.org = kmalloc(NS_TSQSIZE + NS_TSQ_ALIGNMENT, GFP_KERNEL);
+ card->tsq.org = kzalloc(NS_TSQSIZE + NS_TSQ_ALIGNMENT, GFP_KERNEL);
if (card->tsq.org == NULL)
{
printk("nicstar%d: can't allocate TSQ.\n", i);
@@ -656,7 +656,7 @@ #endif
(u32) virt_to_bus(card->tsq.base), readl(card->membase + TSQB));
/* Initialize RSQ */
- card->rsq.org = kmalloc(NS_RSQSIZE + NS_RSQ_ALIGNMENT, GFP_KERNEL);
+ card->rsq.org = kzalloc(NS_RSQSIZE + NS_RSQ_ALIGNMENT, GFP_KERNEL);
if (card->rsq.org == NULL)
{
printk("nicstar%d: can't allocate RSQ.\n", i);
@@ -997,16 +997,16 @@ static scq_info *get_scq(int size, u32 s
if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
return NULL;
- scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL);
+ scq = (scq_info *) kzalloc(sizeof(scq_info), GFP_KERNEL);
if (scq == NULL)
return NULL;
- scq->org = kmalloc(2 * size, GFP_KERNEL);
+ scq->org = kzalloc(2 * size, GFP_KERNEL);
if (scq->org == NULL)
{
kfree(scq);
return NULL;
}
- scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) *
+ scq->skb = (struct sk_buff **) kzalloc(sizeof(struct sk_buff *) *
(size / NS_SCQE_SIZE), GFP_KERNEL);
if (scq->skb == NULL)
{
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
index f04f39c..afbf0c6 100644
--- a/drivers/atm/suni.c
+++ b/drivers/atm/suni.c
@@ -229,7 +229,7 @@ static int suni_start(struct atm_dev *de
unsigned long flags;
int first;
- if (!(dev->phy_data = kmalloc(sizeof(struct suni_priv),GFP_KERNEL)))
+ if (!(dev->phy_data = kzalloc(sizeof(struct suni_priv),GFP_KERNEL)))
return -ENOMEM;
PRIV(dev)->dev = dev;
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
index 9504cce..862bd49 100644
--- a/drivers/atm/uPD98402.c
+++ b/drivers/atm/uPD98402.c
@@ -210,7 +210,7 @@ static void uPD98402_int(struct atm_dev
static int uPD98402_start(struct atm_dev *dev)
{
DPRINTK("phy_start\n");
- if (!(dev->dev_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
+ if (!(dev->dev_data = kzalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
return -ENOMEM;
spin_lock_init(&PRIV(dev)->lock);
memset(&PRIV(dev)->sonet_stats,0,sizeof(struct k_sonet_stats));
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2c65e82..5f83691 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = (struct atm_vcc **) kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
- memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */
@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc
skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */
- zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
+ zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM;
- memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0;
@@ -997,7 +995,7 @@ static int start_tx(struct atm_dev *dev)
DPRINTK("start_tx\n");
zatm_dev = ZATM_DEV(dev);
- zatm_dev->tx_map = (struct atm_vcc **) kmalloc(sizeof(struct atm_vcc *)*
+ zatm_dev->tx_map = (struct atm_vcc **) kzalloc(sizeof(struct atm_vcc *)*
zatm_dev->chans,GFP_KERNEL);
if (!zatm_dev->tx_map) return -ENOMEM;
zatm_dev->tx_bw = ATM_OC3_PCR;
@@ -1399,7 +1397,7 @@ static int zatm_open(struct atm_vcc *vcc
DPRINTK(DEV_LABEL "(itf %d): open %d.%d\n",vcc->dev->number,vcc->vpi,
vcc->vci);
if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) {
- zatm_vcc = kmalloc(sizeof(struct zatm_vcc),GFP_KERNEL);
+ zatm_vcc = kzalloc(sizeof(struct zatm_vcc),GFP_KERNEL);
if (!zatm_vcc) {
clear_bit(ATM_VF_ADDR,&vcc->flags);
return -ENOMEM;
@@ -1592,7 +1590,7 @@ static int __devinit zatm_init_one(struc
struct zatm_dev *zatm_dev;
int ret = -ENOMEM;
- zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL);
+ zatm_dev = (struct zatm_dev *) kzalloc(sizeof(*zatm_dev), GFP_KERNEL);
if (!zatm_dev) {
printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL);
goto out;
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [KJ] kmalloc to kzalloc patches for drivers/base
@ 2006-09-18 0:53 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:53 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Tested by compiling.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/base/class.c | 2 +-
drivers/base/dmapool.c | 4 ++--
drivers/base/firmware_class.c | 2 +-
drivers/base/map.c | 4 ++--
drivers/base/platform.c | 4 ++--
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index de89083..4858d3a 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -511,7 +511,7 @@ char *make_class_name(const char *name,
size = strlen(name) + strlen(kobject_name(kobj)) + 2;
- class_name = kmalloc(size, GFP_KERNEL);
+ class_name = kzalloc(size, GFP_KERNEL);
if (!class_name)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 33c5cce..a9558c3 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -126,7 +126,7 @@ dma_pool_create (const char *name, struc
} else if (allocation < size)
return NULL;
- if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL)))
+ if (!(retval = kzalloc (sizeof *retval, SLAB_KERNEL)))
return retval;
strlcpy (retval->name, name, sizeof retval->name);
@@ -164,7 +164,7 @@ pool_alloc_page (struct dma_pool *pool,
mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG;
mapsize *= sizeof (long);
- page = (struct dma_page *) kmalloc (mapsize + sizeof *page, mem_flags);
+ page = (struct dma_page *) kzalloc (mapsize + sizeof *page, mem_flags);
if (!page)
return NULL;
page->vaddr = dma_alloc_coherent (pool->dev,
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5d6c011..3b6348d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -546,7 +546,7 @@ request_firmware_nowait(
const char *name, struct device *device, void *context,
void (*cont)(const struct firmware *fw, void *context))
{
- struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work),
+ struct firmware_work *fw_work = kzalloc(sizeof (struct firmware_work),
GFP_ATOMIC);
int ret;
diff --git a/drivers/base/map.c b/drivers/base/map.c
index e87017f..4e389b2 100644
--- a/drivers/base/map.c
+++ b/drivers/base/map.c
@@ -41,7 +41,7 @@ int kobj_map(struct kobj_map *domain, de
if (n > 255)
n = 255;
- p = kmalloc(sizeof(struct probe) * n, GFP_KERNEL);
+ p = kzalloc(sizeof(struct probe) * n, GFP_KERNEL);
if (p = NULL)
return -ENOMEM;
@@ -135,7 +135,7 @@ retry:
struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct mutex *lock)
{
- struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL);
+ struct kobj_map *p = kzalloc(sizeof(struct kobj_map), GFP_KERNEL);
struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL);
int i;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 2b8755d..e08950b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -192,7 +192,7 @@ int platform_device_add_resources(struct
{
struct resource *r;
- r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
+ r = kzalloc(sizeof(struct resource) * num, GFP_KERNEL);
if (r) {
memcpy(r, res, sizeof(struct resource) * num);
pdev->resource = r;
@@ -216,7 +216,7 @@ int platform_device_add_data(struct plat
{
void *d;
- d = kmalloc(size, GFP_KERNEL);
+ d = kzalloc(size, GFP_KERNEL);
if (d) {
memcpy(d, data, size);
pdev->dev.platform_data = d;
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* kmalloc to kzalloc patches for drivers/base
@ 2006-09-18 0:53 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:53 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Tested by compiling.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/base/class.c | 2 +-
drivers/base/dmapool.c | 4 ++--
drivers/base/firmware_class.c | 2 +-
drivers/base/map.c | 4 ++--
drivers/base/platform.c | 4 ++--
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index de89083..4858d3a 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -511,7 +511,7 @@ char *make_class_name(const char *name,
size = strlen(name) + strlen(kobject_name(kobj)) + 2;
- class_name = kmalloc(size, GFP_KERNEL);
+ class_name = kzalloc(size, GFP_KERNEL);
if (!class_name)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 33c5cce..a9558c3 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -126,7 +126,7 @@ dma_pool_create (const char *name, struc
} else if (allocation < size)
return NULL;
- if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL)))
+ if (!(retval = kzalloc (sizeof *retval, SLAB_KERNEL)))
return retval;
strlcpy (retval->name, name, sizeof retval->name);
@@ -164,7 +164,7 @@ pool_alloc_page (struct dma_pool *pool,
mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG;
mapsize *= sizeof (long);
- page = (struct dma_page *) kmalloc (mapsize + sizeof *page, mem_flags);
+ page = (struct dma_page *) kzalloc (mapsize + sizeof *page, mem_flags);
if (!page)
return NULL;
page->vaddr = dma_alloc_coherent (pool->dev,
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5d6c011..3b6348d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -546,7 +546,7 @@ request_firmware_nowait(
const char *name, struct device *device, void *context,
void (*cont)(const struct firmware *fw, void *context))
{
- struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work),
+ struct firmware_work *fw_work = kzalloc(sizeof (struct firmware_work),
GFP_ATOMIC);
int ret;
diff --git a/drivers/base/map.c b/drivers/base/map.c
index e87017f..4e389b2 100644
--- a/drivers/base/map.c
+++ b/drivers/base/map.c
@@ -41,7 +41,7 @@ int kobj_map(struct kobj_map *domain, de
if (n > 255)
n = 255;
- p = kmalloc(sizeof(struct probe) * n, GFP_KERNEL);
+ p = kzalloc(sizeof(struct probe) * n, GFP_KERNEL);
if (p == NULL)
return -ENOMEM;
@@ -135,7 +135,7 @@ retry:
struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct mutex *lock)
{
- struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL);
+ struct kobj_map *p = kzalloc(sizeof(struct kobj_map), GFP_KERNEL);
struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL);
int i;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 2b8755d..e08950b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -192,7 +192,7 @@ int platform_device_add_resources(struct
{
struct resource *r;
- r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
+ r = kzalloc(sizeof(struct resource) * num, GFP_KERNEL);
if (r) {
memcpy(r, res, sizeof(struct resource) * num);
pdev->resource = r;
@@ -216,7 +216,7 @@ int platform_device_add_data(struct plat
{
void *d;
- d = kmalloc(size, GFP_KERNEL);
+ d = kzalloc(size, GFP_KERNEL);
if (d) {
memcpy(d, data, size);
pdev->dev.platform_data = d;
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [KJ] kmalloc to kzalloc patches for drivers/block
@ 2006-09-18 0:54 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:54 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Tested by compiling.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/block/DAC960.c | 16 ++++++++--------
drivers/block/amiflop.c | 2 +-
drivers/block/aoe/aoechr.c | 2 +-
drivers/block/cciss.c | 26 ++++++++++++--------------
drivers/block/cpqarray.c | 30 +++++++++++-------------------
drivers/block/loop.c | 6 ++----
drivers/block/paride/pg.c | 2 +-
drivers/block/paride/pt.c | 2 +-
drivers/block/pktcdvd.c | 2 +-
9 files changed, 38 insertions(+), 50 deletions(-)
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 4cd23c3..50621ad 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -1880,7 +1880,7 @@ static boolean DAC960_V2_ReadControllerC
DAC960_V2_LogicalDevice_Offline)
Controller->LogicalDriveInitiallyAccessible[LogicalDeviceNumber] = true;
LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
- kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
if (LogicalDeviceInfo = NULL)
return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] @@ -2114,7 +2114,7 @@ static boolean DAC960_V2_ReadDeviceConfi
break;
PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
- kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
if (PhysicalDeviceInfo = NULL)
return DAC960_Failure(Controller, "PHYSICAL DEVICE ALLOCATION");
Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex] @@ -2123,7 +2123,7 @@ static boolean DAC960_V2_ReadDeviceConfi
sizeof(DAC960_V2_PhysicalDeviceInfo_T));
InquiryUnitSerialNumber = (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
- kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
if (InquiryUnitSerialNumber = NULL) {
kfree(PhysicalDeviceInfo);
return DAC960_Failure(Controller, "SERIAL NUMBER ALLOCATION");
@@ -4780,9 +4780,9 @@ #endif
PhysicalDeviceInfo->LogicalUnit))
{
PhysicalDeviceInfo - kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
InquiryUnitSerialNumber - kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
+ kzalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
GFP_ATOMIC);
if (InquiryUnitSerialNumber = NULL ||
PhysicalDeviceInfo = NULL)
@@ -4951,7 +4951,7 @@ #endif
Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] PhysicalDevice;
LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
- kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] LogicalDeviceInfo;
DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
@@ -5718,13 +5718,13 @@ static boolean DAC960_CheckStatusBuffer(
while (NewStatusBufferLength < ByteCount)
NewStatusBufferLength *= 2;
Controller->CombinedStatusBuffer - (unsigned char *) kmalloc(NewStatusBufferLength, GFP_ATOMIC);
+ (unsigned char *) kzalloc(NewStatusBufferLength, GFP_ATOMIC);
if (Controller->CombinedStatusBuffer = NULL) return false;
Controller->CombinedStatusBufferLength = NewStatusBufferLength;
return true;
}
NewStatusBuffer = (unsigned char *)
- kmalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
+ kzalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
if (NewStatusBuffer = NULL)
{
DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 2641597..e903fcd 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1674,7 +1674,7 @@ static int __init fd_probe_drives(void)
}
unit[drive].gendisk = disk;
drives++;
- if ((unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512,
GFP_KERNEL)) = NULL) {
+ if ((unit[drive].trackbuf = kzalloc(FLOPPY_MAX_SECTORS * 512,
GFP_KERNEL)) = NULL) {
printk("no mem for ");
unit[drive].type = &drive_types[num_dr_types - 1]; /* FD_NODRIVE */
drives--;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 1bc1cf9..3491577 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -114,7 +114,7 @@ bail: spin_unlock_irqrestore(&emsgs_loc
return;
}
- mp = kmalloc(n, GFP_ATOMIC);
+ mp = kzalloc(n, GFP_ATOMIC);
if (mp = NULL) {
printk(KERN_CRIT "aoe: aoechr_error: allocation failure, len=%ld\n", n);
goto bail;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..dcf019a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
return -EINVAL;
#endif
if (iocommand.buf_size > 0) {
- buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+ buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
if (buff = NULL)
return -EFAULT;
}
@@ -911,8 +911,6 @@ #endif
kfree(buff);
return -EFAULT;
}
- } else {
- memset(buff, 0, iocommand.buf_size);
}
if ((c = cmd_alloc(host, 0)) = NULL) {
kfree(buff);
@@ -1007,7 +1005,7 @@ #endif
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
ioc = (BIG_IOCTL_Command_struct *)
- kmalloc(sizeof(*ioc), GFP_KERNEL);
+ kzalloc(sizeof(*ioc), GFP_KERNEL);
if (!ioc) {
status = -ENOMEM;
goto cleanup1;
@@ -1036,7 +1034,7 @@ #endif
status = -ENOMEM;
goto cleanup1;
}
- buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int),
+ buff_size = (int *)kzalloc(MAXSGENTRIES * sizeof(int),
GFP_KERNEL);
if (!buff_size) {
status = -ENOMEM;
@@ -1049,7 +1047,7 @@ #endif
ioc->malloc_size) ? ioc->
malloc_size : left;
buff_size[sg_used] = sz;
- buff[sg_used] = kmalloc(sz, GFP_KERNEL);
+ buff[sg_used] = kzalloc(sz, GFP_KERNEL);
if (buff[sg_used] = NULL) {
status = -ENOMEM;
goto cleanup1;
@@ -1348,10 +1346,10 @@ static void cciss_update_drive_info(int
return;
/* Get information about the disk and modify the driver structure */
- size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
+ size_buff = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
if (size_buff = NULL)
goto mem_msg;
- inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL);
+ inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
if (inq_buff = NULL)
goto mem_msg;
@@ -1990,12 +1988,12 @@ static int cciss_revalidate(struct gendi
if (!FOUND)
return 1;
- size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
+ size_buff = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
if (size_buff = NULL) {
printk(KERN_WARNING "cciss: out of memory\n");
return 1;
}
- inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL);
+ inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
if (inq_buff = NULL) {
printk(KERN_WARNING "cciss: out of memory\n");
kfree(size_buff);
@@ -2962,13 +2960,13 @@ static void cciss_getgeometry(int cntl_n
printk(KERN_ERR "cciss: out of memory\n");
return;
}
- size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
+ size_buff = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
if (size_buff = NULL) {
printk(KERN_ERR "cciss: out of memory\n");
kfree(ld_buff);
return;
}
- inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL);
+ inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
if (inq_buff = NULL) {
printk(KERN_ERR "cciss: out of memory\n");
kfree(ld_buff);
@@ -3176,7 +3174,7 @@ static int __devinit cciss_init_one(stru
hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
hba[i]->cmd_pool_bits - kmalloc(((NR_CMDS + BITS_PER_LONG -
+ kzalloc(((NR_CMDS + BITS_PER_LONG -
1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
hba[i]->cmd_pool = (CommandList_struct *)
pci_alloc_consistent(hba[i]->pdev,
@@ -3194,7 +3192,7 @@ static int __devinit cciss_init_one(stru
}
#ifdef CONFIG_CISS_SCSI_TAPE
hba[i]->scsi_rejects.complete - kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
+ kzalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
(NR_CMDS + 5), GFP_KERNEL);
if (hba[i]->scsi_rejects.complete = NULL) {
printk(KERN_ERR "cciss: out of memory");
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..4cace59 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
&(hba[i]->cmd_pool_dhandle));
- hba[i]->cmd_pool_bits = kmalloc(
+ hba[i]->cmd_pool_bits = kzalloc(
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
GFP_KERNEL);
@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
goto Enomem1;
memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
- memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
printk(KERN_INFO "cpqarray: Finding drives on %s",
hba[i]->devname);
@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
i = alloc_cpqarray_hba();
if( i < 0 )
return (-1);
- memset(hba[i], 0, sizeof(ctlr_info_t));
sprintf(hba[i]->devname, "ida%d", i);
hba[i]->ctlr = i;
/* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
for(i=0; i< MAX_CTLR; i++) {
if (hba[i] = NULL) {
- hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+ hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
if(hba[i]=NULL) {
printk(KERN_ERR "cpqarray: out of memory.\n");
return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
continue;
}
- memset(hba[ctlr], 0, sizeof(ctlr_info_t));
hba[ctlr]->io_mem_addr = eisa[i];
hba[ctlr]->io_mem_length = 0x7FF;
if(!request_region(hba[ctlr]->io_mem_addr,
@@ -1161,7 +1158,7 @@ static int ida_ioctl(struct inode *inode
case IDAPASSTHRU:
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
- my_io = kmalloc(sizeof(ida_ioctl_t), GFP_KERNEL);
+ my_io = kzalloc(sizeof(ida_ioctl_t), GFP_KERNEL);
if (!my_io)
return -ENOMEM;
error = -EFAULT;
@@ -1242,7 +1239,7 @@ static int ida_ctlr_ioctl(ctlr_info_t *h
/* Pre submit processing */
switch(io->cmd) {
case PASSTHRU_A:
- p = kmalloc(io->sg[0].size, GFP_KERNEL);
+ p = kzalloc(io->sg[0].size, GFP_KERNEL);
if (!p)
{
error = -ENOMEM;
@@ -1265,7 +1262,7 @@ static int ida_ctlr_ioctl(ctlr_info_t *h
case IDA_READ:
case READ_FLASH_ROM:
case SENSE_CONTROLLER_PERFORMANCE:
- p = kmalloc(io->sg[0].size, GFP_KERNEL);
+ p = kzalloc(io->sg[0].size, GFP_KERNEL);
if (!p)
{
error = -ENOMEM;
@@ -1283,7 +1280,7 @@ static int ida_ctlr_ioctl(ctlr_info_t *h
case DIAG_PASS_THRU:
case COLLECT_BUFFER:
case WRITE_FLASH_ROM:
- p = kmalloc(io->sg[0].size, GFP_KERNEL);
+ p = kzalloc(io->sg[0].size, GFP_KERNEL);
if (!p)
{
error = -ENOMEM;
@@ -1620,7 +1617,7 @@ static void start_fwbk(int ctlr)
" processing\n");
/* Command does not return anything, but idasend command needs a
buffer */
- id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
+ id_ctlr_buf = (id_ctlr_t *)kzalloc(sizeof(id_ctlr_t), GFP_KERNEL);
if(id_ctlr_buf=NULL)
{
printk(KERN_WARNING "cpqarray: Out of memory. "
@@ -1655,14 +1652,14 @@ static void getgeometry(int ctlr)
info_p->log_drv_map = 0;
- id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL);
+ id_ldrive = (id_log_drv_t *)kzalloc(sizeof(id_log_drv_t), GFP_KERNEL);
if(id_ldrive = NULL)
{
printk( KERN_ERR "cpqarray: out of memory.\n");
return;
}
- id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
+ id_ctlr_buf = (id_ctlr_t *)kzalloc(sizeof(id_ctlr_t), GFP_KERNEL);
if(id_ctlr_buf = NULL)
{
kfree(id_ldrive);
@@ -1670,7 +1667,7 @@ static void getgeometry(int ctlr)
return;
}
- id_lstatus_buf = (sense_log_drv_stat_t
*)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
+ id_lstatus_buf = (sense_log_drv_stat_t
*)kzalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
if(id_lstatus_buf = NULL)
{
kfree(id_ctlr_buf);
@@ -1679,7 +1676,7 @@ static void getgeometry(int ctlr)
return;
}
- sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL);
+ sense_config_buf = (config_t *)kzalloc(sizeof(config_t), GFP_KERNEL);
if(sense_config_buf = NULL)
{
kfree(id_lstatus_buf);
@@ -1689,11 +1686,6 @@ static void getgeometry(int ctlr)
return;
}
- memset(id_ldrive, 0, sizeof(id_log_drv_t));
- memset(id_ctlr_buf, 0, sizeof(id_ctlr_t));
- memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t));
- memset(sense_config_buf, 0, sizeof(config_t));
-
info_p->phys_drives = 0;
info_p->log_drv_map = 0;
info_p->drv_assign_map = 0;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..e6b83b8 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,12 +1260,10 @@ static int __init loop_init(void)
if (register_blkdev(LOOP_MAJOR, "loop"))
return -EIO;
- loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+ loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
if (!loop_dev)
goto out_mem1;
- memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
-
- disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
+ disks = kzalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
if (!disks)
goto out_mem2;
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 13f998a..1be6ff3 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -529,7 +529,7 @@ static int pg_open(struct inode *inode,
pg_identify(dev, (verbose > 1));
- dev->bufptr = kmalloc(PG_MAX_DATA, GFP_KERNEL);
+ dev->bufptr = kzalloc(PG_MAX_DATA, GFP_KERNEL);
if (dev->bufptr = NULL) {
clear_bit(0, &dev->access);
printk("%s: buffer allocation failed\n", dev->name);
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 35fb266..2ead336 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -671,7 +671,7 @@ static int pt_open(struct inode *inode,
tape->flags |= PT_REWIND;
err = -ENOMEM;
- tape->bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
+ tape->bufptr = kzalloc(PT_BUFSIZE, GFP_KERNEL);
if (tape->bufptr = NULL) {
printk("%s: buffer allocation failed\n", tape->name);
goto out;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 451b996..de21cfd 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -106,7 +106,7 @@ static struct bio *pkt_bio_alloc(int nr_
struct bio_vec *bvl = NULL;
struct bio *bio;
- bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
+ bio = kzalloc(sizeof(struct bio), GFP_KERNEL);
if (!bio)
goto no_bio;
bio_init(bio);
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* kmalloc to kzalloc patches for drivers/block
@ 2006-09-18 0:54 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 0:54 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Tested by compiling.
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/block/DAC960.c | 16 ++++++++--------
drivers/block/amiflop.c | 2 +-
drivers/block/aoe/aoechr.c | 2 +-
drivers/block/cciss.c | 26 ++++++++++++--------------
drivers/block/cpqarray.c | 30 +++++++++++-------------------
drivers/block/loop.c | 6 ++----
drivers/block/paride/pg.c | 2 +-
drivers/block/paride/pt.c | 2 +-
drivers/block/pktcdvd.c | 2 +-
9 files changed, 38 insertions(+), 50 deletions(-)
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 4cd23c3..50621ad 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -1880,7 +1880,7 @@ static boolean DAC960_V2_ReadControllerC
DAC960_V2_LogicalDevice_Offline)
Controller->LogicalDriveInitiallyAccessible[LogicalDeviceNumber] = true;
LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
- kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
if (LogicalDeviceInfo == NULL)
return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
@@ -2114,7 +2114,7 @@ static boolean DAC960_V2_ReadDeviceConfi
break;
PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
- kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
if (PhysicalDeviceInfo == NULL)
return DAC960_Failure(Controller, "PHYSICAL DEVICE ALLOCATION");
Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex] =
@@ -2123,7 +2123,7 @@ static boolean DAC960_V2_ReadDeviceConfi
sizeof(DAC960_V2_PhysicalDeviceInfo_T));
InquiryUnitSerialNumber = (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
- kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
if (InquiryUnitSerialNumber == NULL) {
kfree(PhysicalDeviceInfo);
return DAC960_Failure(Controller, "SERIAL NUMBER ALLOCATION");
@@ -4780,9 +4780,9 @@ #endif
PhysicalDeviceInfo->LogicalUnit))
{
PhysicalDeviceInfo =
- kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
InquiryUnitSerialNumber =
- kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
+ kzalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
GFP_ATOMIC);
if (InquiryUnitSerialNumber == NULL ||
PhysicalDeviceInfo == NULL)
@@ -4951,7 +4951,7 @@ #endif
Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
PhysicalDevice;
LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
- kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
+ kzalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
LogicalDeviceInfo;
DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
@@ -5718,13 +5718,13 @@ static boolean DAC960_CheckStatusBuffer(
while (NewStatusBufferLength < ByteCount)
NewStatusBufferLength *= 2;
Controller->CombinedStatusBuffer =
- (unsigned char *) kmalloc(NewStatusBufferLength, GFP_ATOMIC);
+ (unsigned char *) kzalloc(NewStatusBufferLength, GFP_ATOMIC);
if (Controller->CombinedStatusBuffer == NULL) return false;
Controller->CombinedStatusBufferLength = NewStatusBufferLength;
return true;
}
NewStatusBuffer = (unsigned char *)
- kmalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
+ kzalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
if (NewStatusBuffer == NULL)
{
DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 2641597..e903fcd 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1674,7 +1674,7 @@ static int __init fd_probe_drives(void)
}
unit[drive].gendisk = disk;
drives++;
- if ((unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512,
GFP_KERNEL)) == NULL) {
+ if ((unit[drive].trackbuf = kzalloc(FLOPPY_MAX_SECTORS * 512,
GFP_KERNEL)) == NULL) {
printk("no mem for ");
unit[drive].type = &drive_types[num_dr_types - 1]; /* FD_NODRIVE */
drives--;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 1bc1cf9..3491577 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -114,7 +114,7 @@ bail: spin_unlock_irqrestore(&emsgs_loc
return;
}
- mp = kmalloc(n, GFP_ATOMIC);
+ mp = kzalloc(n, GFP_ATOMIC);
if (mp == NULL) {
printk(KERN_CRIT "aoe: aoechr_error: allocation failure, len=%ld\n", n);
goto bail;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..dcf019a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
return -EINVAL;
#endif
if (iocommand.buf_size > 0) {
- buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+ buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
if (buff == NULL)
return -EFAULT;
}
@@ -911,8 +911,6 @@ #endif
kfree(buff);
return -EFAULT;
}
- } else {
- memset(buff, 0, iocommand.buf_size);
}
if ((c = cmd_alloc(host, 0)) == NULL) {
kfree(buff);
@@ -1007,7 +1005,7 @@ #endif
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
ioc = (BIG_IOCTL_Command_struct *)
- kmalloc(sizeof(*ioc), GFP_KERNEL);
+ kzalloc(sizeof(*ioc), GFP_KERNEL);
if (!ioc) {
status = -ENOMEM;
goto cleanup1;
@@ -1036,7 +1034,7 @@ #endif
status = -ENOMEM;
goto cleanup1;
}
- buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int),
+ buff_size = (int *)kzalloc(MAXSGENTRIES * sizeof(int),
GFP_KERNEL);
if (!buff_size) {
status = -ENOMEM;
@@ -1049,7 +1047,7 @@ #endif
ioc->malloc_size) ? ioc->
malloc_size : left;
buff_size[sg_used] = sz;
- buff[sg_used] = kmalloc(sz, GFP_KERNEL);
+ buff[sg_used] = kzalloc(sz, GFP_KERNEL);
if (buff[sg_used] == NULL) {
status = -ENOMEM;
goto cleanup1;
@@ -1348,10 +1346,10 @@ static void cciss_update_drive_info(int
return;
/* Get information about the disk and modify the driver structure */
- size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
+ size_buff = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
if (size_buff == NULL)
goto mem_msg;
- inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL);
+ inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
if (inq_buff == NULL)
goto mem_msg;
@@ -1990,12 +1988,12 @@ static int cciss_revalidate(struct gendi
if (!FOUND)
return 1;
- size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
+ size_buff = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
if (size_buff == NULL) {
printk(KERN_WARNING "cciss: out of memory\n");
return 1;
}
- inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL);
+ inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
if (inq_buff == NULL) {
printk(KERN_WARNING "cciss: out of memory\n");
kfree(size_buff);
@@ -2962,13 +2960,13 @@ static void cciss_getgeometry(int cntl_n
printk(KERN_ERR "cciss: out of memory\n");
return;
}
- size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
+ size_buff = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
if (size_buff == NULL) {
printk(KERN_ERR "cciss: out of memory\n");
kfree(ld_buff);
return;
}
- inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL);
+ inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
if (inq_buff == NULL) {
printk(KERN_ERR "cciss: out of memory\n");
kfree(ld_buff);
@@ -3176,7 +3174,7 @@ static int __devinit cciss_init_one(stru
hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
hba[i]->cmd_pool_bits =
- kmalloc(((NR_CMDS + BITS_PER_LONG -
+ kzalloc(((NR_CMDS + BITS_PER_LONG -
1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
hba[i]->cmd_pool = (CommandList_struct *)
pci_alloc_consistent(hba[i]->pdev,
@@ -3194,7 +3192,7 @@ static int __devinit cciss_init_one(stru
}
#ifdef CONFIG_CISS_SCSI_TAPE
hba[i]->scsi_rejects.complete =
- kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
+ kzalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
(NR_CMDS + 5), GFP_KERNEL);
if (hba[i]->scsi_rejects.complete == NULL) {
printk(KERN_ERR "cciss: out of memory");
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..4cace59 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
&(hba[i]->cmd_pool_dhandle));
- hba[i]->cmd_pool_bits = kmalloc(
+ hba[i]->cmd_pool_bits = kzalloc(
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
GFP_KERNEL);
@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
goto Enomem1;
memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
- memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
printk(KERN_INFO "cpqarray: Finding drives on %s",
hba[i]->devname);
@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
i = alloc_cpqarray_hba();
if( i < 0 )
return (-1);
- memset(hba[i], 0, sizeof(ctlr_info_t));
sprintf(hba[i]->devname, "ida%d", i);
hba[i]->ctlr = i;
/* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
for(i=0; i< MAX_CTLR; i++) {
if (hba[i] == NULL) {
- hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+ hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
if(hba[i]==NULL) {
printk(KERN_ERR "cpqarray: out of memory.\n");
return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
continue;
}
- memset(hba[ctlr], 0, sizeof(ctlr_info_t));
hba[ctlr]->io_mem_addr = eisa[i];
hba[ctlr]->io_mem_length = 0x7FF;
if(!request_region(hba[ctlr]->io_mem_addr,
@@ -1161,7 +1158,7 @@ static int ida_ioctl(struct inode *inode
case IDAPASSTHRU:
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
- my_io = kmalloc(sizeof(ida_ioctl_t), GFP_KERNEL);
+ my_io = kzalloc(sizeof(ida_ioctl_t), GFP_KERNEL);
if (!my_io)
return -ENOMEM;
error = -EFAULT;
@@ -1242,7 +1239,7 @@ static int ida_ctlr_ioctl(ctlr_info_t *h
/* Pre submit processing */
switch(io->cmd) {
case PASSTHRU_A:
- p = kmalloc(io->sg[0].size, GFP_KERNEL);
+ p = kzalloc(io->sg[0].size, GFP_KERNEL);
if (!p)
{
error = -ENOMEM;
@@ -1265,7 +1262,7 @@ static int ida_ctlr_ioctl(ctlr_info_t *h
case IDA_READ:
case READ_FLASH_ROM:
case SENSE_CONTROLLER_PERFORMANCE:
- p = kmalloc(io->sg[0].size, GFP_KERNEL);
+ p = kzalloc(io->sg[0].size, GFP_KERNEL);
if (!p)
{
error = -ENOMEM;
@@ -1283,7 +1280,7 @@ static int ida_ctlr_ioctl(ctlr_info_t *h
case DIAG_PASS_THRU:
case COLLECT_BUFFER:
case WRITE_FLASH_ROM:
- p = kmalloc(io->sg[0].size, GFP_KERNEL);
+ p = kzalloc(io->sg[0].size, GFP_KERNEL);
if (!p)
{
error = -ENOMEM;
@@ -1620,7 +1617,7 @@ static void start_fwbk(int ctlr)
" processing\n");
/* Command does not return anything, but idasend command needs a
buffer */
- id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
+ id_ctlr_buf = (id_ctlr_t *)kzalloc(sizeof(id_ctlr_t), GFP_KERNEL);
if(id_ctlr_buf==NULL)
{
printk(KERN_WARNING "cpqarray: Out of memory. "
@@ -1655,14 +1652,14 @@ static void getgeometry(int ctlr)
info_p->log_drv_map = 0;
- id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL);
+ id_ldrive = (id_log_drv_t *)kzalloc(sizeof(id_log_drv_t), GFP_KERNEL);
if(id_ldrive == NULL)
{
printk( KERN_ERR "cpqarray: out of memory.\n");
return;
}
- id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
+ id_ctlr_buf = (id_ctlr_t *)kzalloc(sizeof(id_ctlr_t), GFP_KERNEL);
if(id_ctlr_buf == NULL)
{
kfree(id_ldrive);
@@ -1670,7 +1667,7 @@ static void getgeometry(int ctlr)
return;
}
- id_lstatus_buf = (sense_log_drv_stat_t
*)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
+ id_lstatus_buf = (sense_log_drv_stat_t
*)kzalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
if(id_lstatus_buf == NULL)
{
kfree(id_ctlr_buf);
@@ -1679,7 +1676,7 @@ static void getgeometry(int ctlr)
return;
}
- sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL);
+ sense_config_buf = (config_t *)kzalloc(sizeof(config_t), GFP_KERNEL);
if(sense_config_buf == NULL)
{
kfree(id_lstatus_buf);
@@ -1689,11 +1686,6 @@ static void getgeometry(int ctlr)
return;
}
- memset(id_ldrive, 0, sizeof(id_log_drv_t));
- memset(id_ctlr_buf, 0, sizeof(id_ctlr_t));
- memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t));
- memset(sense_config_buf, 0, sizeof(config_t));
-
info_p->phys_drives = 0;
info_p->log_drv_map = 0;
info_p->drv_assign_map = 0;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..e6b83b8 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,12 +1260,10 @@ static int __init loop_init(void)
if (register_blkdev(LOOP_MAJOR, "loop"))
return -EIO;
- loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+ loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
if (!loop_dev)
goto out_mem1;
- memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
-
- disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
+ disks = kzalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
if (!disks)
goto out_mem2;
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 13f998a..1be6ff3 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -529,7 +529,7 @@ static int pg_open(struct inode *inode,
pg_identify(dev, (verbose > 1));
- dev->bufptr = kmalloc(PG_MAX_DATA, GFP_KERNEL);
+ dev->bufptr = kzalloc(PG_MAX_DATA, GFP_KERNEL);
if (dev->bufptr == NULL) {
clear_bit(0, &dev->access);
printk("%s: buffer allocation failed\n", dev->name);
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 35fb266..2ead336 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -671,7 +671,7 @@ static int pt_open(struct inode *inode,
tape->flags |= PT_REWIND;
err = -ENOMEM;
- tape->bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
+ tape->bufptr = kzalloc(PT_BUFSIZE, GFP_KERNEL);
if (tape->bufptr == NULL) {
printk("%s: buffer allocation failed\n", tape->name);
goto out;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 451b996..de21cfd 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -106,7 +106,7 @@ static struct bio *pkt_bio_alloc(int nr_
struct bio_vec *bvl = NULL;
struct bio *bio;
- bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
+ bio = kzalloc(sizeof(struct bio), GFP_KERNEL);
if (!bio)
goto no_bio;
bio_init(bio);
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/base
2006-09-18 0:53 ` Om Narasimhan
@ 2006-09-18 1:08 ` Dmitry Torokhov
-1 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-18 1:08 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
On Sunday 17 September 2006 20:53, Om Narasimhan wrote:
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 2b8755d..e08950b 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -192,7 +192,7 @@ int platform_device_add_resources(struct
> {
> struct resource *r;
>
> - r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
> + r = kzalloc(sizeof(struct resource) * num, GFP_KERNEL);
> if (r) {
> memcpy(r, res, sizeof(struct resource) * num);
> pdev->resource = r;
Just out of curiosity could you tell me what is the benefit of
zeroing allocated memory here?
> @@ -216,7 +216,7 @@ int platform_device_add_data(struct plat
> {
> void *d;
>
> - d = kmalloc(size, GFP_KERNEL);
> + d = kzalloc(size, GFP_KERNEL);
> if (d) {
> memcpy(d, data, size);
> pdev->dev.platform_data = d;
>
And here?
--
Dmitry
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/base
@ 2006-09-18 1:08 ` Dmitry Torokhov
0 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-18 1:08 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
On Sunday 17 September 2006 20:53, Om Narasimhan wrote:
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 2b8755d..e08950b 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -192,7 +192,7 @@ int platform_device_add_resources(struct
> {
> struct resource *r;
>
> - r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
> + r = kzalloc(sizeof(struct resource) * num, GFP_KERNEL);
> if (r) {
> memcpy(r, res, sizeof(struct resource) * num);
> pdev->resource = r;
Just out of curiosity could you tell me what is the benefit of
zeroing allocated memory here?
> @@ -216,7 +216,7 @@ int platform_device_add_data(struct plat
> {
> void *d;
>
> - d = kmalloc(size, GFP_KERNEL);
> + d = kzalloc(size, GFP_KERNEL);
> if (d) {
> memcpy(d, data, size);
> pdev->dev.platform_data = d;
>
And here?
--
Dmitry
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/atm
2006-09-18 0:53 ` Om Narasimhan
@ 2006-09-18 1:19 ` Dmitry Torokhov
-1 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-18 1:19 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors, linux-atm-general
On Sunday 17 September 2006 20:53, Om Narasimhan wrote:
> --- a/drivers/atm/firestream.c
> +++ b/drivers/atm/firestream.c
> @@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
> write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
> dev->nchannels = FS155_NR_CHANNELS;
> }
> - dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
> + dev->atm_vccs = kzalloc (dev->nchannels * sizeof (struct atm_vcc *),
> GFP_KERNEL);
> fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
> dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
>
kcalloc would be better here because you are allocating several objects
at once.
--
Dmitry
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/atm
@ 2006-09-18 1:19 ` Dmitry Torokhov
0 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-18 1:19 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors, linux-atm-general
On Sunday 17 September 2006 20:53, Om Narasimhan wrote:
> --- a/drivers/atm/firestream.c
> +++ b/drivers/atm/firestream.c
> @@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
> write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
> dev->nchannels = FS155_NR_CHANNELS;
> }
> - dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
> + dev->atm_vccs = kzalloc (dev->nchannels * sizeof (struct atm_vcc *),
> GFP_KERNEL);
> fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
> dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
>
kcalloc would be better here because you are allocating several objects
at once.
--
Dmitry
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/base
2006-09-18 1:08 ` Dmitry Torokhov
@ 2006-09-18 2:27 ` Om Narasimhan
-1 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 2:27 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel, kernel-janitors
On 9/17/06, Dmitry Torokhov <dtor@insightbb.com> wrote:
> On Sunday 17 September 2006 20:53, Om Narasimhan wrote:
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 2b8755d..e08950b 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -192,7 +192,7 @@ int platform_device_add_resources(struct
> > {
> > struct resource *r;
> >
> > -r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
> > +r = kzalloc(sizeof(struct resource) * num, GFP_KERNEL);
> > if (r) {
> > memcpy(r, res, sizeof(struct resource) * num);
> > pdev->resource = r;
>
> Just out of curiosity could you tell me what is the benefit of
> zeroing allocated memory here?
My mistake. :-D
>
> > @@ -216,7 +216,7 @@ int platform_device_add_data(struct plat
> > {
> > void *d;
> >
> > -d = kmalloc(size, GFP_KERNEL);
> > +d = kzalloc(size, GFP_KERNEL);
> > if (d) {
> > memcpy(d, data, size);
> > pdev->dev.platform_data = d;
> >
>
> And here?
Mea Culpa :-D
Thanks for the comment.
Regards,
Om.
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/base
@ 2006-09-18 2:27 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-18 2:27 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel, kernel-janitors
On 9/17/06, Dmitry Torokhov <dtor@insightbb.com> wrote:
> On Sunday 17 September 2006 20:53, Om Narasimhan wrote:
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 2b8755d..e08950b 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -192,7 +192,7 @@ int platform_device_add_resources(struct
> > {
> > struct resource *r;
> >
> > -r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL);
> > +r = kzalloc(sizeof(struct resource) * num, GFP_KERNEL);
> > if (r) {
> > memcpy(r, res, sizeof(struct resource) * num);
> > pdev->resource = r;
>
> Just out of curiosity could you tell me what is the benefit of
> zeroing allocated memory here?
My mistake. :-D
>
> > @@ -216,7 +216,7 @@ int platform_device_add_data(struct plat
> > {
> > void *d;
> >
> > -d = kmalloc(size, GFP_KERNEL);
> > +d = kzalloc(size, GFP_KERNEL);
> > if (d) {
> > memcpy(d, data, size);
> > pdev->dev.platform_data = d;
> >
>
> And here?
Mea Culpa :-D
Thanks for the comment.
Regards,
Om.
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/base
2006-09-18 0:53 ` Om Narasimhan
@ 2006-09-18 9:40 ` Alan Cox
-1 siblings, 0 replies; 55+ messages in thread
From: Alan Cox @ 2006-09-18 9:40 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
Ar Sul, 2006-09-17 am 17:53 -0700, ysgrifennodd Om Narasimhan:
> Tested by compiling.
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
> - if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL)))
> + if (!(retval = kzalloc (sizeof *retval, SLAB_KERNEL)))
> return retval;
NAK
Why slow all these allocations down when they don't zero the memory
anyway ?
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/base
@ 2006-09-18 9:40 ` Alan Cox
0 siblings, 0 replies; 55+ messages in thread
From: Alan Cox @ 2006-09-18 9:40 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
Ar Sul, 2006-09-17 am 17:53 -0700, ysgrifennodd Om Narasimhan:
> Tested by compiling.
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
> - if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL)))
> + if (!(retval = kzalloc (sizeof *retval, SLAB_KERNEL)))
> return retval;
NAK
Why slow all these allocations down when they don't zero the memory
anyway ?
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/atm
2006-09-18 0:53 ` Om Narasimhan
@ 2006-09-18 9:42 ` Alan Cox
-1 siblings, 0 replies; 55+ messages in thread
From: Alan Cox @ 2006-09-18 9:42 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors, linux-atm-general
Ar Sul, 2006-09-17 am 17:53 -0700, ysgrifennodd Om Narasimhan:
> Tested by compiling.
>
> I have not subscribed to ATM list. Please cc me any comments.
>
NAK - again changes some that don't need to clear the memory they
allocate
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/atm
@ 2006-09-18 9:42 ` Alan Cox
0 siblings, 0 replies; 55+ messages in thread
From: Alan Cox @ 2006-09-18 9:42 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors, linux-atm-general
Ar Sul, 2006-09-17 am 17:53 -0700, ysgrifennodd Om Narasimhan:
> Tested by compiling.
>
> I have not subscribed to ATM list. Please cc me any comments.
>
NAK - again changes some that don't need to clear the memory they
allocate
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/mfd
2006-09-18 0:53 ` Om Narasimhan
@ 2006-09-18 9:43 ` Alan Cox
-1 siblings, 0 replies; 55+ messages in thread
From: Alan Cox @ 2006-09-18 9:43 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
Ar Sul, 2006-09-17 am 17:53 -0700, ysgrifennodd Om Narasimhan:
> Tested by compiling.
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
>
Acked-by: Alan Cox <alan@redhat.com>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/mfd
@ 2006-09-18 9:43 ` Alan Cox
0 siblings, 0 replies; 55+ messages in thread
From: Alan Cox @ 2006-09-18 9:43 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
Ar Sul, 2006-09-17 am 17:53 -0700, ysgrifennodd Om Narasimhan:
> Tested by compiling.
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
>
Acked-by: Alan Cox <alan@redhat.com>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/atm
2006-09-18 9:42 ` Alan Cox
@ 2006-09-18 12:07 ` Pekka Enberg
-1 siblings, 0 replies; 55+ messages in thread
From: Pekka Enberg @ 2006-09-18 12:07 UTC (permalink / raw)
To: Alan Cox; +Cc: Om Narasimhan, linux-kernel, kernel-janitors, linux-atm-general
On 9/18/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> NAK - again changes some that don't need to clear the memory they
> allocate
Yeah, and you really should drop the redundant casts while you're there...
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/atm
@ 2006-09-18 12:07 ` Pekka Enberg
0 siblings, 0 replies; 55+ messages in thread
From: Pekka Enberg @ 2006-09-18 12:07 UTC (permalink / raw)
To: Alan Cox; +Cc: Om Narasimhan, linux-kernel, kernel-janitors, linux-atm-general
On 9/18/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> NAK - again changes some that don't need to clear the memory they
> allocate
Yeah, and you really should drop the redundant casts while you're there...
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/base
2006-09-18 0:53 ` Om Narasimhan
@ 2006-09-18 12:31 ` Greg KH
-1 siblings, 0 replies; 55+ messages in thread
From: Greg KH @ 2006-09-18 12:31 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
On Sun, Sep 17, 2006 at 05:53:58PM -0700, Om Narasimhan wrote:
> Tested by compiling.
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
>
>
> drivers/base/class.c | 2 +-
> drivers/base/dmapool.c | 4 ++--
> drivers/base/firmware_class.c | 2 +-
> drivers/base/map.c | 4 ++--
> drivers/base/platform.c | 4 ++--
> 5 files changed, 8 insertions(+), 8 deletions(-)
No, sorry, none of these changes are needed.
thanks,
greg k-h
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/base
@ 2006-09-18 12:31 ` Greg KH
0 siblings, 0 replies; 55+ messages in thread
From: Greg KH @ 2006-09-18 12:31 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
On Sun, Sep 17, 2006 at 05:53:58PM -0700, Om Narasimhan wrote:
> Tested by compiling.
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
>
>
> drivers/base/class.c | 2 +-
> drivers/base/dmapool.c | 4 ++--
> drivers/base/firmware_class.c | 2 +-
> drivers/base/map.c | 4 ++--
> drivers/base/platform.c | 4 ++--
> 5 files changed, 8 insertions(+), 8 deletions(-)
No, sorry, none of these changes are needed.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 55+ messages in thread
* [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-21 6:11 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-21 6:11 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
This patch changes the kmalloc() calls followed by memset(,0,) to kzalloc.
cciss.c : Changed the kmalloc/memset pair to kzalloc
cpqarray.c : km2zalloc conversion and code size reduction by
changing multiple cleanup calls and returns of the function
getgeometry() by adding a label.
loop.c : km2zalloc converion
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/block/cciss.c | 4 +--
drivers/block/cpqarray.c | 72 +++++++++++++++-------------------------------
drivers/block/loop.c | 4 +--
3 files changed, 25 insertions(+), 55 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..a800a69 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
return -EINVAL;
#endif
if (iocommand.buf_size > 0) {
- buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+ buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
if (buff = NULL)
return -EFAULT;
}
@@ -911,8 +911,6 @@ #endif
kfree(buff);
return -EFAULT;
}
- } else {
- memset(buff, 0, iocommand.buf_size);
}
if ((c = cmd_alloc(host, 0)) = NULL) {
kfree(buff);
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..8a697c7 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
&(hba[i]->cmd_pool_dhandle));
- hba[i]->cmd_pool_bits = kmalloc(
+ hba[i]->cmd_pool_bits = kzalloc(
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
GFP_KERNEL);
@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
goto Enomem1;
memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
- memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
printk(KERN_INFO "cpqarray: Finding drives on %s",
hba[i]->devname);
@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
i = alloc_cpqarray_hba();
if( i < 0 )
return (-1);
- memset(hba[i], 0, sizeof(ctlr_info_t));
sprintf(hba[i]->devname, "ida%d", i);
hba[i]->ctlr = i;
/* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
for(i=0; i< MAX_CTLR; i++) {
if (hba[i] = NULL) {
- hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+ hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
if(hba[i]=NULL) {
printk(KERN_ERR "cpqarray: out of memory.\n");
return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
continue;
}
- memset(hba[ctlr], 0, sizeof(ctlr_info_t));
hba[ctlr]->io_mem_addr = eisa[i];
hba[ctlr]->io_mem_length = 0x7FF;
if(!request_region(hba[ctlr]->io_mem_addr,
@@ -1642,58 +1639,46 @@ static void start_fwbk(int ctlr)
It is used only at init time.
*****************************************************************/
static void getgeometry(int ctlr)
-{
- id_log_drv_t *id_ldrive;
- id_ctlr_t *id_ctlr_buf;
- sense_log_drv_stat_t *id_lstatus_buf;
- config_t *sense_config_buf;
+{
+ id_log_drv_t *id_ldrive = NULL;
+ id_ctlr_t *id_ctlr_buf = NULL;
+ sense_log_drv_stat_t *id_lstatus_buf = NULL;
+ config_t *sense_config_buf = NULL;
unsigned int log_unit, log_index;
int ret_code, size;
- drv_info_t *drv;
+ drv_info_t *drv = NULL;
ctlr_info_t *info_p = hba[ctlr];
int i;
- info_p->log_drv_map = 0;
-
- id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL);
+ info_p->log_drv_map = 0;
+ id_ldrive = (id_log_drv_t *)kzalloc(sizeof(id_log_drv_t), GFP_KERNEL);
if(id_ldrive = NULL)
{
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
+ id_ctlr_buf = (id_ctlr_t *)kzalloc(sizeof(id_ctlr_t), GFP_KERNEL);
if(id_ctlr_buf = NULL)
{
- kfree(id_ldrive);
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- id_lstatus_buf = (sense_log_drv_stat_t
*)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
+ id_lstatus_buf = (sense_log_drv_stat_t
*)kzalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
if(id_lstatus_buf = NULL)
{
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL);
+ sense_config_buf = (config_t *)kzalloc(sizeof(config_t), GFP_KERNEL);
if(sense_config_buf = NULL)
{
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- memset(id_ldrive, 0, sizeof(id_log_drv_t));
- memset(id_ctlr_buf, 0, sizeof(id_ctlr_t));
- memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t));
- memset(sense_config_buf, 0, sizeof(config_t));
-
info_p->phys_drives = 0;
info_p->log_drv_map = 0;
info_p->drv_assign_map = 0;
@@ -1709,11 +1694,7 @@ static void getgeometry(int ctlr)
*/
/* Free all the buffers and return */
printk(KERN_ERR "cpqarray: error sending ID controller\n");
- kfree(sense_config_buf);
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
- return;
+ goto end;
}
info_p->log_drives = id_ctlr_buf->nr_drvs;
@@ -1760,11 +1741,7 @@ static void getgeometry(int ctlr)
"Access to this controller has been disabled\n",
ctlr, log_unit);
/* Free all the buffers and return */
- kfree(sense_config_buf);
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
- return;
+ goto end;
}
/*
Make sure the logical drive is configured
@@ -1795,11 +1772,7 @@ static void getgeometry(int ctlr)
info_p->log_drv_map = 0;
/* Free all the buffers and return */
printk(KERN_ERR "cpqarray: error sending sense config\n");
- kfree(sense_config_buf);
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
- return;
+ goto end;
}
@@ -1815,9 +1788,10 @@ static void getgeometry(int ctlr)
log_index = log_index + 1;
} /* end of if logical drive configured */
} /* end of for log_unit */
+end:
kfree(sense_config_buf);
- kfree(id_ldrive);
- kfree(id_lstatus_buf);
+ kfree(id_ldrive);
+ kfree(id_lstatus_buf);
kfree(id_ctlr_buf);
return;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..cc4785f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,11 +1260,9 @@ static int __init loop_init(void)
if (register_blkdev(LOOP_MAJOR, "loop"))
return -EIO;
- loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+ loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
if (!loop_dev)
goto out_mem1;
- memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
-
disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
if (!disks)
goto out_mem2;
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-21 6:11 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-21 6:11 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
This patch changes the kmalloc() calls followed by memset(,0,) to kzalloc.
cciss.c : Changed the kmalloc/memset pair to kzalloc
cpqarray.c : km2zalloc conversion and code size reduction by
changing multiple cleanup calls and returns of the function
getgeometry() by adding a label.
loop.c : km2zalloc converion
Signed off by Om Narasimhan <om.turyx@gmail.com>
drivers/block/cciss.c | 4 +--
drivers/block/cpqarray.c | 72 +++++++++++++++-------------------------------
drivers/block/loop.c | 4 +--
3 files changed, 25 insertions(+), 55 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..a800a69 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
return -EINVAL;
#endif
if (iocommand.buf_size > 0) {
- buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+ buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
if (buff == NULL)
return -EFAULT;
}
@@ -911,8 +911,6 @@ #endif
kfree(buff);
return -EFAULT;
}
- } else {
- memset(buff, 0, iocommand.buf_size);
}
if ((c = cmd_alloc(host, 0)) == NULL) {
kfree(buff);
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..8a697c7 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
&(hba[i]->cmd_pool_dhandle));
- hba[i]->cmd_pool_bits = kmalloc(
+ hba[i]->cmd_pool_bits = kzalloc(
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
GFP_KERNEL);
@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
goto Enomem1;
memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
- memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
printk(KERN_INFO "cpqarray: Finding drives on %s",
hba[i]->devname);
@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
i = alloc_cpqarray_hba();
if( i < 0 )
return (-1);
- memset(hba[i], 0, sizeof(ctlr_info_t));
sprintf(hba[i]->devname, "ida%d", i);
hba[i]->ctlr = i;
/* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
for(i=0; i< MAX_CTLR; i++) {
if (hba[i] == NULL) {
- hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+ hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
if(hba[i]==NULL) {
printk(KERN_ERR "cpqarray: out of memory.\n");
return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
continue;
}
- memset(hba[ctlr], 0, sizeof(ctlr_info_t));
hba[ctlr]->io_mem_addr = eisa[i];
hba[ctlr]->io_mem_length = 0x7FF;
if(!request_region(hba[ctlr]->io_mem_addr,
@@ -1642,58 +1639,46 @@ static void start_fwbk(int ctlr)
It is used only at init time.
*****************************************************************/
static void getgeometry(int ctlr)
-{
- id_log_drv_t *id_ldrive;
- id_ctlr_t *id_ctlr_buf;
- sense_log_drv_stat_t *id_lstatus_buf;
- config_t *sense_config_buf;
+{
+ id_log_drv_t *id_ldrive = NULL;
+ id_ctlr_t *id_ctlr_buf = NULL;
+ sense_log_drv_stat_t *id_lstatus_buf = NULL;
+ config_t *sense_config_buf = NULL;
unsigned int log_unit, log_index;
int ret_code, size;
- drv_info_t *drv;
+ drv_info_t *drv = NULL;
ctlr_info_t *info_p = hba[ctlr];
int i;
- info_p->log_drv_map = 0;
-
- id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL);
+ info_p->log_drv_map = 0;
+ id_ldrive = (id_log_drv_t *)kzalloc(sizeof(id_log_drv_t), GFP_KERNEL);
if(id_ldrive == NULL)
{
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL);
+ id_ctlr_buf = (id_ctlr_t *)kzalloc(sizeof(id_ctlr_t), GFP_KERNEL);
if(id_ctlr_buf == NULL)
{
- kfree(id_ldrive);
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- id_lstatus_buf = (sense_log_drv_stat_t
*)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
+ id_lstatus_buf = (sense_log_drv_stat_t
*)kzalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL);
if(id_lstatus_buf == NULL)
{
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL);
+ sense_config_buf = (config_t *)kzalloc(sizeof(config_t), GFP_KERNEL);
if(sense_config_buf == NULL)
{
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
printk( KERN_ERR "cpqarray: out of memory.\n");
- return;
+ goto end;
}
- memset(id_ldrive, 0, sizeof(id_log_drv_t));
- memset(id_ctlr_buf, 0, sizeof(id_ctlr_t));
- memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t));
- memset(sense_config_buf, 0, sizeof(config_t));
-
info_p->phys_drives = 0;
info_p->log_drv_map = 0;
info_p->drv_assign_map = 0;
@@ -1709,11 +1694,7 @@ static void getgeometry(int ctlr)
*/
/* Free all the buffers and return */
printk(KERN_ERR "cpqarray: error sending ID controller\n");
- kfree(sense_config_buf);
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
- return;
+ goto end;
}
info_p->log_drives = id_ctlr_buf->nr_drvs;
@@ -1760,11 +1741,7 @@ static void getgeometry(int ctlr)
"Access to this controller has been disabled\n",
ctlr, log_unit);
/* Free all the buffers and return */
- kfree(sense_config_buf);
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
- return;
+ goto end;
}
/*
Make sure the logical drive is configured
@@ -1795,11 +1772,7 @@ static void getgeometry(int ctlr)
info_p->log_drv_map = 0;
/* Free all the buffers and return */
printk(KERN_ERR "cpqarray: error sending sense config\n");
- kfree(sense_config_buf);
- kfree(id_lstatus_buf);
- kfree(id_ctlr_buf);
- kfree(id_ldrive);
- return;
+ goto end;
}
@@ -1815,9 +1788,10 @@ static void getgeometry(int ctlr)
log_index = log_index + 1;
} /* end of if logical drive configured */
} /* end of for log_unit */
+end:
kfree(sense_config_buf);
- kfree(id_ldrive);
- kfree(id_lstatus_buf);
+ kfree(id_ldrive);
+ kfree(id_lstatus_buf);
kfree(id_ctlr_buf);
return;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..cc4785f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,11 +1260,9 @@ static int __init loop_init(void)
if (register_blkdev(LOOP_MAJOR, "loop"))
return -EIO;
- loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+ loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
if (!loop_dev)
goto out_mem1;
- memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
-
disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
if (!disks)
goto out_mem2;
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [KJ] kmalloc to kzalloc patches for drivers/atm [sane version]
@ 2006-09-21 7:12 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-21 7:12 UTC (permalink / raw)
To: linux-kernel, kernel-janitors, linux-atm-general
Cleaned up patch, compile tested.
Replaces kmalloc()s succeeded by memset (,0,) with kzalloc()/kcalloc()
in the drivers/atm directory.
Signed off by Om Narasimhan <om.turyx@gmail.com>
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6cc93de..ac2c108 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
- adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+ adummy_dev = kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL);
if (!adummy_dev) {
- printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
+ printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
err = -ENOMEM;
goto out;
}
- memset(adummy_dev, 0, sizeof(struct adummy_dev));
-
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38fc054..30e2eb2 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS;
}
- dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
+ dev->atm_vccs = kcalloc (sizeof (struct atm_vcc *), dev->nchannels,
GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1794,7 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
-
- dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+ dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8);
@@ -1805,8 +1803,6 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1893,14 +1889,11 @@ static int __devinit firestream_init_one
if (pci_enable_device(pci_dev))
goto err_out;
- fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+ fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev));
if (!fs_dev)
goto err_out;
-
- memset (fs_dev, 0, sizeof (struct fs_dev));
-
atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev)
goto err_out_free_fs_dev;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index d369130..611a532 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, con
}
pci_set_drvdata(pci_dev, atm_dev);
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+ he_dev = kzalloc(sizeof(struct he_dev),
GFP_KERNEL);
if (!he_dev) {
err = -ENOMEM;
goto init_one_failure;
}
- memset(he_dev, 0, sizeof(struct he_dev));
-
he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index d1113e8..209dba1 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pc
goto out_disable;
}
- dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) {
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pc
goto out_release;
}
- memset(dev, 0, sizeof(hrz_dev));
-
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b0369bb..1bc3a31 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
{
struct scq_info *scq;
- scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+ scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq)
return NULL;
- memset(scq, 0, sizeof(struct scq_info));
-
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr);
if (scq->base = NULL) {
@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int
{
struct rate_estimator *est;
- est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+ est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est)
return NULL;
- memset(est, 0, sizeof(*est));
-
est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps;
est->avcps = est->cps << 5;
@@ -2451,14 +2447,12 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) {
- card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex);
return -ENOMEM;
}
- memset(card->vcs[index], 0, sizeof(struct vc_map));
-
card->vcs[index]->card = card;
card->vcs[index]->index = index;
@@ -2926,13 +2920,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci);
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
-
vc->index = index;
card->vcs[index] = vc;
@@ -2995,12 +2987,11 @@ open_card_ubr0(struct idt77252_dev *card
{
struct vc_map *vc;
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc;
vc->class = SCHED_UBR0;
@@ -3695,14 +3686,12 @@ idt77252_init_one(struct pci_dev *pcidev
goto err_out_disable_pdev;
}
- card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+ card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) {
printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM;
goto err_out_disable_pdev;
}
- memset(card, 0, sizeof(struct idt77252_dev));
-
card->revision = revision;
card->index = index;
card->pcidev = pcidev;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index fe60a59..b9568e1 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1482,16 +1482,10 @@ #endif
static inline struct lanai_vcc *new_lanai_vcc(void)
{
struct lanai_vcc *lvcc;
- lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
+ lvcc = kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) {
- lvcc->vbase = NULL;
- lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
- lvcc->nref = 0;
- memset(&lvcc->stats, 0, sizeof lvcc->stats);
- lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG
- lvcc->tx.unqueue = NULL;
lvcc->vci = -1;
#endif
}
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2c65e82..c491ec4 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
- memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */
@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc
skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */
- zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
+ zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM;
- memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0;
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* kmalloc to kzalloc patches for drivers/atm [sane version]
@ 2006-09-21 7:12 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-21 7:12 UTC (permalink / raw)
To: linux-kernel, kernel-janitors, linux-atm-general
Cleaned up patch, compile tested.
Replaces kmalloc()s succeeded by memset (,0,) with kzalloc()/kcalloc()
in the drivers/atm directory.
Signed off by Om Narasimhan <om.turyx@gmail.com>
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6cc93de..ac2c108 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
- adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+ adummy_dev = kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL);
if (!adummy_dev) {
- printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
+ printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
err = -ENOMEM;
goto out;
}
- memset(adummy_dev, 0, sizeof(struct adummy_dev));
-
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38fc054..30e2eb2 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS;
}
- dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
+ dev->atm_vccs = kcalloc (sizeof (struct atm_vcc *), dev->nchannels,
GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1794,7 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
-
- dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+ dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8);
@@ -1805,8 +1803,6 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1893,14 +1889,11 @@ static int __devinit firestream_init_one
if (pci_enable_device(pci_dev))
goto err_out;
- fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+ fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev));
if (!fs_dev)
goto err_out;
-
- memset (fs_dev, 0, sizeof (struct fs_dev));
-
atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev)
goto err_out_free_fs_dev;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index d369130..611a532 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, con
}
pci_set_drvdata(pci_dev, atm_dev);
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+ he_dev = kzalloc(sizeof(struct he_dev),
GFP_KERNEL);
if (!he_dev) {
err = -ENOMEM;
goto init_one_failure;
}
- memset(he_dev, 0, sizeof(struct he_dev));
-
he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index d1113e8..209dba1 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pc
goto out_disable;
}
- dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) {
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pc
goto out_release;
}
- memset(dev, 0, sizeof(hrz_dev));
-
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b0369bb..1bc3a31 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
{
struct scq_info *scq;
- scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+ scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq)
return NULL;
- memset(scq, 0, sizeof(struct scq_info));
-
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr);
if (scq->base == NULL) {
@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int
{
struct rate_estimator *est;
- est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+ est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est)
return NULL;
- memset(est, 0, sizeof(*est));
-
est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps;
est->avcps = est->cps << 5;
@@ -2451,14 +2447,12 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) {
- card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex);
return -ENOMEM;
}
- memset(card->vcs[index], 0, sizeof(struct vc_map));
-
card->vcs[index]->card = card;
card->vcs[index]->index = index;
@@ -2926,13 +2920,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci);
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
-
vc->index = index;
card->vcs[index] = vc;
@@ -2995,12 +2987,11 @@ open_card_ubr0(struct idt77252_dev *card
{
struct vc_map *vc;
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc;
vc->class = SCHED_UBR0;
@@ -3695,14 +3686,12 @@ idt77252_init_one(struct pci_dev *pcidev
goto err_out_disable_pdev;
}
- card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+ card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) {
printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM;
goto err_out_disable_pdev;
}
- memset(card, 0, sizeof(struct idt77252_dev));
-
card->revision = revision;
card->index = index;
card->pcidev = pcidev;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index fe60a59..b9568e1 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1482,16 +1482,10 @@ #endif
static inline struct lanai_vcc *new_lanai_vcc(void)
{
struct lanai_vcc *lvcc;
- lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
+ lvcc = kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) {
- lvcc->vbase = NULL;
- lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
- lvcc->nref = 0;
- memset(&lvcc->stats, 0, sizeof lvcc->stats);
- lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG
- lvcc->tx.unqueue = NULL;
lvcc->vci = -1;
#endif
}
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2c65e82..c491ec4 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
- memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */
@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc
skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */
- zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
+ zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM;
- memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0;
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-21 6:11 ` Om Narasimhan
@ 2006-09-21 7:20 ` Nishanth Aravamudan
-1 siblings, 0 replies; 55+ messages in thread
From: Nishanth Aravamudan @ 2006-09-21 7:20 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
On 20.09.2006 [23:11:25 -0700], Om Narasimhan wrote:
> This patch changes the kmalloc() calls followed by memset(,0,) to kzalloc.
>
> cciss.c : Changed the kmalloc/memset pair to kzalloc
> cpqarray.c : km2zalloc conversion and code size reduction by
> changing multiple cleanup calls and returns of the function
> getgeometry() by adding a label.
> loop.c : km2zalloc converion
>
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
This is not the canonical format, per SubmittingPatches. It should be:
Signed-off-by: Random J Developer <random@developer.example.org>
> drivers/block/cciss.c | 4 +--
> drivers/block/cpqarray.c | 72 +++++++++++++++-------------------------------
> drivers/block/loop.c | 4 +--
> 3 files changed, 25 insertions(+), 55 deletions(-)
Your diffstat should have indicated to you that this should be split up
better. Please (re-)read SubmittingPatches. *One* logical change per
patch, most importantly.
>
> diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> index 2cd3391..a800a69 100644
> --- a/drivers/block/cciss.c
> +++ b/drivers/block/cciss.c
> @@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
> return -EINVAL;
> #endif
> if (iocommand.buf_size > 0) {
> - buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
> + buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
> if (buff = NULL)
> return -EFAULT;
> }
> @@ -911,8 +911,6 @@ #endif
> kfree(buff);
> return -EFAULT;
> }
> - } else {
> - memset(buff, 0, iocommand.buf_size);
> }
> if ((c = cmd_alloc(host, 0)) = NULL) {
> kfree(buff);
This changes performance potentially, no? The memset before was
conditional upon (iocommand.Request.Type.Direction = XFER_WRITE) and
now the memory will always be zero'd.
> diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
> index 78082ed..8a697c7 100644
> --- a/drivers/block/cpqarray.c
> +++ b/drivers/block/cpqarray.c
> @@ -1642,58 +1639,46 @@ static void start_fwbk(int ctlr)
> It is used only at init time.
> *****************************************************************/
> static void getgeometry(int ctlr)
> -{
> - id_log_drv_t *id_ldrive;
> - id_ctlr_t *id_ctlr_buf;
> - sense_log_drv_stat_t *id_lstatus_buf;
> - config_t *sense_config_buf;
> +{
Unrelated whitespace change.
> + id_log_drv_t *id_ldrive = NULL;
> + id_ctlr_t *id_ctlr_buf = NULL;
> + sense_log_drv_stat_t *id_lstatus_buf = NULL;
> + config_t *sense_config_buf = NULL;
Why initialize if you're going to immediately assign the return of
kzalloc()?
> unsigned int log_unit, log_index;
> int ret_code, size;
> - drv_info_t *drv;
> + drv_info_t *drv = NULL;
What does this do? Seems unnecessary and unrelated.
<snip>
> - kfree(id_ctlr_buf);
> - kfree(id_ldrive);
> printk( KERN_ERR "cpqarray: out of memory.\n");
> - return;
> + goto end;
All of this rearrangement needs to be a separate patch.
Thanks,
Nish
--
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-21 7:20 ` Nishanth Aravamudan
0 siblings, 0 replies; 55+ messages in thread
From: Nishanth Aravamudan @ 2006-09-21 7:20 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
On 20.09.2006 [23:11:25 -0700], Om Narasimhan wrote:
> This patch changes the kmalloc() calls followed by memset(,0,) to kzalloc.
>
> cciss.c : Changed the kmalloc/memset pair to kzalloc
> cpqarray.c : km2zalloc conversion and code size reduction by
> changing multiple cleanup calls and returns of the function
> getgeometry() by adding a label.
> loop.c : km2zalloc converion
>
>
> Signed off by Om Narasimhan <om.turyx@gmail.com>
This is not the canonical format, per SubmittingPatches. It should be:
Signed-off-by: Random J Developer <random@developer.example.org>
> drivers/block/cciss.c | 4 +--
> drivers/block/cpqarray.c | 72 +++++++++++++++-------------------------------
> drivers/block/loop.c | 4 +--
> 3 files changed, 25 insertions(+), 55 deletions(-)
Your diffstat should have indicated to you that this should be split up
better. Please (re-)read SubmittingPatches. *One* logical change per
patch, most importantly.
>
> diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> index 2cd3391..a800a69 100644
> --- a/drivers/block/cciss.c
> +++ b/drivers/block/cciss.c
> @@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
> return -EINVAL;
> #endif
> if (iocommand.buf_size > 0) {
> - buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
> + buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
> if (buff == NULL)
> return -EFAULT;
> }
> @@ -911,8 +911,6 @@ #endif
> kfree(buff);
> return -EFAULT;
> }
> - } else {
> - memset(buff, 0, iocommand.buf_size);
> }
> if ((c = cmd_alloc(host, 0)) == NULL) {
> kfree(buff);
This changes performance potentially, no? The memset before was
conditional upon (iocommand.Request.Type.Direction == XFER_WRITE) and
now the memory will always be zero'd.
> diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
> index 78082ed..8a697c7 100644
> --- a/drivers/block/cpqarray.c
> +++ b/drivers/block/cpqarray.c
> @@ -1642,58 +1639,46 @@ static void start_fwbk(int ctlr)
> It is used only at init time.
> *****************************************************************/
> static void getgeometry(int ctlr)
> -{
> - id_log_drv_t *id_ldrive;
> - id_ctlr_t *id_ctlr_buf;
> - sense_log_drv_stat_t *id_lstatus_buf;
> - config_t *sense_config_buf;
> +{
Unrelated whitespace change.
> + id_log_drv_t *id_ldrive = NULL;
> + id_ctlr_t *id_ctlr_buf = NULL;
> + sense_log_drv_stat_t *id_lstatus_buf = NULL;
> + config_t *sense_config_buf = NULL;
Why initialize if you're going to immediately assign the return of
kzalloc()?
> unsigned int log_unit, log_index;
> int ret_code, size;
> - drv_info_t *drv;
> + drv_info_t *drv = NULL;
What does this do? Seems unnecessary and unrelated.
<snip>
> - kfree(id_ctlr_buf);
> - kfree(id_ldrive);
> printk( KERN_ERR "cpqarray: out of memory.\n");
> - return;
> + goto end;
All of this rearrangement needs to be a separate patch.
Thanks,
Nish
--
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-18 0:53 ` Om Narasimhan
` (6 preceding siblings ...)
(?)
@ 2006-09-21 7:35 ` Thomas Petazzoni
-1 siblings, 0 replies; 55+ messages in thread
From: Thomas Petazzoni @ 2006-09-21 7:35 UTC (permalink / raw)
To: kernel-janitors
Hi,
Le Thu, 21 Sep 2006 00:20:17 -0700,
Nishanth Aravamudan <nacc@us.ibm.com> a écrit :
> > + id_log_drv_t *id_ldrive = NULL;
> > + id_ctlr_t *id_ctlr_buf = NULL;
> > + sense_log_drv_stat_t *id_lstatus_buf = NULL;
> > + config_t *sense_config_buf = NULL;
>
> Why initialize if you're going to immediately assign the return of
> kzalloc()?
I wanted to say the same, but just before sending my mail, I understood
that it was for the "goto end;" thing to work. The code at the "end:"
label kfree()s all variables, regardless of whether they have been
allocated. It works correctly if all pointers are initially set to NULL
('cause kfree(NULL) works), but not if pointers contain garbage.
However, as you said, this is another logical change, which must be
done in another patch.
Sincerly,
Thomas
--
Thomas Petazzoni - thomas.petazzoni@enix.org
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/atm [sane version]
2006-09-21 7:12 ` Om Narasimhan
@ 2006-09-21 13:36 ` Dmitry Torokhov
-1 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-21 13:36 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors, linux-atm-general
Hi,
On 9/21/06, Om Narasimhan <om.turyx@gmail.com> wrote:
> - dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
> + dev->atm_vccs = kcalloc (sizeof (struct atm_vcc *), dev->nchannels,
> GFP_KERNEL);
kcalloc's first argument is number of elements to allocate, size is
the second argument.
>
> - scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
> + scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
Kill this cast please.
--
Dmitry
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/atm [sane version]
@ 2006-09-21 13:36 ` Dmitry Torokhov
0 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-21 13:36 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors, linux-atm-general
Hi,
On 9/21/06, Om Narasimhan <om.turyx@gmail.com> wrote:
> - dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
> + dev->atm_vccs = kcalloc (sizeof (struct atm_vcc *), dev->nchannels,
> GFP_KERNEL);
kcalloc's first argument is number of elements to allocate, size is
the second argument.
>
> - scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
> + scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
Kill this cast please.
--
Dmitry
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/atm [sane version]
2006-09-21 13:36 ` Dmitry Torokhov
@ 2006-09-22 5:29 ` Om Narasimhan
-1 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 5:29 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel, kernel-janitors, linux-atm-general
Cleaned up patch, compile tested, comments incorporated.
Replaces kmalloc()s succeeded by memset (,0,) with kzalloc()/kcalloc()
in the drivers/atm directory.
Signed off by : Om Narasimhan <om.turyx@gmail.com>
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6cc93de..ac2c108 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
- adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+ adummy_dev = kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL);
if (!adummy_dev) {
- printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
+ printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
err = -ENOMEM;
goto out;
}
- memset(adummy_dev, 0, sizeof(struct adummy_dev));
-
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38fc054..30e2eb2 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS;
}
- dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
+ dev->atm_vccs = kcalloc (dev->nchannels, sizeof (struct atm_vcc *),
GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1794,7 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
-
- dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+ dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8);
@@ -1805,8 +1803,6 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1893,14 +1889,11 @@ static int __devinit firestream_init_one
if (pci_enable_device(pci_dev))
goto err_out;
- fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+ fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev));
if (!fs_dev)
goto err_out;
-
- memset (fs_dev, 0, sizeof (struct fs_dev));
-
atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev)
goto err_out_free_fs_dev;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index d369130..611a532 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, con
}
pci_set_drvdata(pci_dev, atm_dev);
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+ he_dev = kzalloc(sizeof(struct he_dev),
GFP_KERNEL);
if (!he_dev) {
err = -ENOMEM;
goto init_one_failure;
}
- memset(he_dev, 0, sizeof(struct he_dev));
-
he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index d1113e8..209dba1 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pc
goto out_disable;
}
- dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) {
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pc
goto out_release;
}
- memset(dev, 0, sizeof(hrz_dev));
-
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b0369bb..1bc3a31 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
{
struct scq_info *scq;
- scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+ scq = kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq)
return NULL;
- memset(scq, 0, sizeof(struct scq_info));
-
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr);
if (scq->base = NULL) {
@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int
{
struct rate_estimator *est;
- est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+ est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est)
return NULL;
- memset(est, 0, sizeof(*est));
-
est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps;
est->avcps = est->cps << 5;
@@ -2451,14 +2447,12 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) {
- card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex);
return -ENOMEM;
}
- memset(card->vcs[index], 0, sizeof(struct vc_map));
-
card->vcs[index]->card = card;
card->vcs[index]->index = index;
@@ -2926,13 +2920,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci);
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
-
vc->index = index;
card->vcs[index] = vc;
@@ -2995,12 +2987,11 @@ open_card_ubr0(struct idt77252_dev *card
{
struct vc_map *vc;
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc;
vc->class = SCHED_UBR0;
@@ -3695,14 +3686,12 @@ idt77252_init_one(struct pci_dev *pcidev
goto err_out_disable_pdev;
}
- card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+ card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) {
printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM;
goto err_out_disable_pdev;
}
- memset(card, 0, sizeof(struct idt77252_dev));
-
card->revision = revision;
card->index = index;
card->pcidev = pcidev;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index fe60a59..b9568e1 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1482,16 +1482,10 @@ #endif
static inline struct lanai_vcc *new_lanai_vcc(void)
{
struct lanai_vcc *lvcc;
- lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
+ lvcc = kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) {
- lvcc->vbase = NULL;
- lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
- lvcc->nref = 0;
- memset(&lvcc->stats, 0, sizeof lvcc->stats);
- lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG
- lvcc->tx.unqueue = NULL;
lvcc->vci = -1;
#endif
}
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2c65e82..c491ec4 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
- memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */
@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc
skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */
- zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
+ zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM;
- memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0;
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: kmalloc to kzalloc patches for drivers/atm [sane version]
@ 2006-09-22 5:29 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 5:29 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel, kernel-janitors, linux-atm-general
Cleaned up patch, compile tested, comments incorporated.
Replaces kmalloc()s succeeded by memset (,0,) with kzalloc()/kcalloc()
in the drivers/atm directory.
Signed off by : Om Narasimhan <om.turyx@gmail.com>
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6cc93de..ac2c108 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
- adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+ adummy_dev = kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL);
if (!adummy_dev) {
- printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
+ printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
err = -ENOMEM;
goto out;
}
- memset(adummy_dev, 0, sizeof(struct adummy_dev));
-
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38fc054..30e2eb2 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS;
}
- dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *),
+ dev->atm_vccs = kcalloc (dev->nchannels, sizeof (struct atm_vcc *),
GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1794,7 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
-
- dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+ dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8);
@@ -1805,8 +1803,6 @@ static int __devinit fs_init (struct fs_
/* XXX Clean up..... */
return 1;
}
- memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1893,14 +1889,11 @@ static int __devinit firestream_init_one
if (pci_enable_device(pci_dev))
goto err_out;
- fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+ fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev));
if (!fs_dev)
goto err_out;
-
- memset (fs_dev, 0, sizeof (struct fs_dev));
-
atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev)
goto err_out_free_fs_dev;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index d369130..611a532 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, con
}
pci_set_drvdata(pci_dev, atm_dev);
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+ he_dev = kzalloc(sizeof(struct he_dev),
GFP_KERNEL);
if (!he_dev) {
err = -ENOMEM;
goto init_one_failure;
}
- memset(he_dev, 0, sizeof(struct he_dev));
-
he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index d1113e8..209dba1 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pc
goto out_disable;
}
- dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) {
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pc
goto out_release;
}
- memset(dev, 0, sizeof(hrz_dev));
-
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index b0369bb..1bc3a31 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
{
struct scq_info *scq;
- scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+ scq = kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq)
return NULL;
- memset(scq, 0, sizeof(struct scq_info));
-
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr);
if (scq->base == NULL) {
@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int
{
struct rate_estimator *est;
- est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+ est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est)
return NULL;
- memset(est, 0, sizeof(*est));
-
est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps;
est->avcps = est->cps << 5;
@@ -2451,14 +2447,12 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) {
- card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex);
return -ENOMEM;
}
- memset(card->vcs[index], 0, sizeof(struct vc_map));
-
card->vcs[index]->card = card;
card->vcs[index]->index = index;
@@ -2926,13 +2920,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci);
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
-
vc->index = index;
card->vcs[index] = vc;
@@ -2995,12 +2987,11 @@ open_card_ubr0(struct idt77252_dev *card
{
struct vc_map *vc;
- vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+ vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) {
printk("%s: can't alloc vc\n", card->name);
return -ENOMEM;
}
- memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc;
vc->class = SCHED_UBR0;
@@ -3695,14 +3686,12 @@ idt77252_init_one(struct pci_dev *pcidev
goto err_out_disable_pdev;
}
- card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+ card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) {
printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM;
goto err_out_disable_pdev;
}
- memset(card, 0, sizeof(struct idt77252_dev));
-
card->revision = revision;
card->index = index;
card->pcidev = pcidev;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index fe60a59..b9568e1 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1482,16 +1482,10 @@ #endif
static inline struct lanai_vcc *new_lanai_vcc(void)
{
struct lanai_vcc *lvcc;
- lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
+ lvcc = kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) {
- lvcc->vbase = NULL;
- lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
- lvcc->nref = 0;
- memset(&lvcc->stats, 0, sizeof lvcc->stats);
- lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG
- lvcc->tx.unqueue = NULL;
lvcc->vci = -1;
#endif
}
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2c65e82..c491ec4 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
- memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */
@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc
skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */
- zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
+ zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM;
- memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0;
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-21 7:20 ` Nishanth Aravamudan
@ 2006-09-22 5:40 ` Om Narasimhan
-1 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 5:40 UTC (permalink / raw)
To: Nishanth Aravamudan; +Cc: linux-kernel, kernel-janitors
Thanks for the comments.
> >
> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>
> This is not the canonical format, per SubmittingPatches. It should be:
>
> Signed-off-by: Random J Developer <random@developer.example.org>
OK. I would take care of it.
>
> > drivers/block/cciss.c | 4 +--
> > drivers/block/cpqarray.c | 72 +++++++++++++++-------------------------------
> > drivers/block/loop.c | 4 +--
> > 3 files changed, 25 insertions(+), 55 deletions(-)
>
> Your diffstat should have indicated to you that this should be split up
> better. Please (re-)read SubmittingPatches. *One* logical change per
> patch, most importantly.
OK. I would resubmit.
> >
> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> > index 2cd3391..a800a69 100644
> > --- a/drivers/block/cciss.c
> > +++ b/drivers/block/cciss.c
> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
> > return -EINVAL;
> > #endif
> > if (iocommand.buf_size > 0) {
> > - buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
> > + buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
> > if (buff = NULL)
> > return -EFAULT;
> > }
> > @@ -911,8 +911,6 @@ #endif
> > kfree(buff);
> > return -EFAULT;
> > }
> > - } else {
> > - memset(buff, 0, iocommand.buf_size);
> > }
> > if ((c = cmd_alloc(host, 0)) = NULL) {
> > kfree(buff);
>
> This changes performance potentially, no? The memset before was
> conditional upon (iocommand.Request.Type.Direction = XFER_WRITE) and
> now the memory will always be zero'd.
Yes, but not the functionality.
if (iocommand.buf_size > 0), code allocates using kmalloc. if
direction is XFER_WRITE, it does a copy_from_user(), and free()s the
allocated buffer, not really caring what data came in from userspace.
Else, it does memset(). So I could safely replace the kmalloc() with
kzalloc() without compromising functionality.
Thanks,
Om.
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 5:40 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 5:40 UTC (permalink / raw)
To: Nishanth Aravamudan; +Cc: linux-kernel, kernel-janitors
Thanks for the comments.
> >
> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>
> This is not the canonical format, per SubmittingPatches. It should be:
>
> Signed-off-by: Random J Developer <random@developer.example.org>
OK. I would take care of it.
>
> > drivers/block/cciss.c | 4 +--
> > drivers/block/cpqarray.c | 72 +++++++++++++++-------------------------------
> > drivers/block/loop.c | 4 +--
> > 3 files changed, 25 insertions(+), 55 deletions(-)
>
> Your diffstat should have indicated to you that this should be split up
> better. Please (re-)read SubmittingPatches. *One* logical change per
> patch, most importantly.
OK. I would resubmit.
> >
> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> > index 2cd3391..a800a69 100644
> > --- a/drivers/block/cciss.c
> > +++ b/drivers/block/cciss.c
> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
> > return -EINVAL;
> > #endif
> > if (iocommand.buf_size > 0) {
> > - buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
> > + buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
> > if (buff == NULL)
> > return -EFAULT;
> > }
> > @@ -911,8 +911,6 @@ #endif
> > kfree(buff);
> > return -EFAULT;
> > }
> > - } else {
> > - memset(buff, 0, iocommand.buf_size);
> > }
> > if ((c = cmd_alloc(host, 0)) == NULL) {
> > kfree(buff);
>
> This changes performance potentially, no? The memset before was
> conditional upon (iocommand.Request.Type.Direction == XFER_WRITE) and
> now the memory will always be zero'd.
Yes, but not the functionality.
if (iocommand.buf_size > 0), code allocates using kmalloc. if
direction is XFER_WRITE, it does a copy_from_user(), and free()s the
allocated buffer, not really caring what data came in from userspace.
Else, it does memset(). So I could safely replace the kmalloc() with
kzalloc() without compromising functionality.
Thanks,
Om.
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 5:40 ` Om Narasimhan
@ 2006-09-22 6:04 ` Om Narasimhan
-1 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 6:04 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Comments incorporated
Changes kmalloc() calls succeeded by memset(,0,) to kzalloc()
Signed off by : Om Narasimhan <om.turyx@gmail.com>
drivers/block/cciss.c | 4 +---
drivers/block/cpqarray.c | 7 ++-----
drivers/block/loop.c | 3 +--
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..a800a69 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
return -EINVAL;
#endif
if (iocommand.buf_size > 0) {
- buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+ buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
if (buff = NULL)
return -EFAULT;
}
@@ -911,8 +911,6 @@ #endif
kfree(buff);
return -EFAULT;
}
- } else {
- memset(buff, 0, iocommand.buf_size);
}
if ((c = cmd_alloc(host, 0)) = NULL) {
kfree(buff);
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..34f8e96 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
&(hba[i]->cmd_pool_dhandle));
- hba[i]->cmd_pool_bits = kmalloc(
+ hba[i]->cmd_pool_bits = kzalloc(
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
GFP_KERNEL);
@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
goto Enomem1;
memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
- memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
printk(KERN_INFO "cpqarray: Finding drives on %s",
hba[i]->devname);
@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
i = alloc_cpqarray_hba();
if( i < 0 )
return (-1);
- memset(hba[i], 0, sizeof(ctlr_info_t));
sprintf(hba[i]->devname, "ida%d", i);
hba[i]->ctlr = i;
/* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
for(i=0; i< MAX_CTLR; i++) {
if (hba[i] = NULL) {
- hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+ hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
if(hba[i]=NULL) {
printk(KERN_ERR "cpqarray: out of memory.\n");
return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
continue;
}
- memset(hba[ctlr], 0, sizeof(ctlr_info_t));
hba[ctlr]->io_mem_addr = eisa[i];
hba[ctlr]->io_mem_length = 0x7FF;
if(!request_region(hba[ctlr]->io_mem_addr,
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..91b48ef 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,10 +1260,9 @@ static int __init loop_init(void)
if (register_blkdev(LOOP_MAJOR, "loop"))
return -EIO;
- loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+ loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
if (!loop_dev)
goto out_mem1;
- memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
if (!disks)
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 6:04 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 6:04 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
Comments incorporated
Changes kmalloc() calls succeeded by memset(,0,) to kzalloc()
Signed off by : Om Narasimhan <om.turyx@gmail.com>
drivers/block/cciss.c | 4 +---
drivers/block/cpqarray.c | 7 ++-----
drivers/block/loop.c | 3 +--
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..a800a69 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
return -EINVAL;
#endif
if (iocommand.buf_size > 0) {
- buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+ buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
if (buff == NULL)
return -EFAULT;
}
@@ -911,8 +911,6 @@ #endif
kfree(buff);
return -EFAULT;
}
- } else {
- memset(buff, 0, iocommand.buf_size);
}
if ((c = cmd_alloc(host, 0)) == NULL) {
kfree(buff);
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..34f8e96 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
&(hba[i]->cmd_pool_dhandle));
- hba[i]->cmd_pool_bits = kmalloc(
+ hba[i]->cmd_pool_bits = kzalloc(
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
GFP_KERNEL);
@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
goto Enomem1;
memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
- memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
printk(KERN_INFO "cpqarray: Finding drives on %s",
hba[i]->devname);
@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
i = alloc_cpqarray_hba();
if( i < 0 )
return (-1);
- memset(hba[i], 0, sizeof(ctlr_info_t));
sprintf(hba[i]->devname, "ida%d", i);
hba[i]->ctlr = i;
/* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
for(i=0; i< MAX_CTLR; i++) {
if (hba[i] == NULL) {
- hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+ hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
if(hba[i]==NULL) {
printk(KERN_ERR "cpqarray: out of memory.\n");
return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
continue;
}
- memset(hba[ctlr], 0, sizeof(ctlr_info_t));
hba[ctlr]->io_mem_addr = eisa[i];
hba[ctlr]->io_mem_length = 0x7FF;
if(!request_region(hba[ctlr]->io_mem_addr,
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..91b48ef 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,10 +1260,9 @@ static int __init loop_init(void)
if (register_blkdev(LOOP_MAJOR, "loop"))
return -EIO;
- loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+ loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
if (!loop_dev)
goto out_mem1;
- memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
if (!disks)
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 5:40 ` Om Narasimhan
@ 2006-09-22 8:36 ` Jiri Slaby
-1 siblings, 0 replies; 55+ messages in thread
From: Jiri Slaby @ 2006-09-22 8:36 UTC (permalink / raw)
To: Om Narasimhan; +Cc: Nishanth Aravamudan, linux-kernel, kernel-janitors
Om Narasimhan wrote:
> Thanks for the comments.
>> >
>> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>>
>> This is not the canonical format, per SubmittingPatches. It should be:
>>
>> Signed-off-by: Random J Developer <random@developer.example.org>
> OK. I would take care of it.
>>
>> > drivers/block/cciss.c | 4 +--
>> > drivers/block/cpqarray.c | 72
>> +++++++++++++++-------------------------------
>> > drivers/block/loop.c | 4 +--
>> > 3 files changed, 25 insertions(+), 55 deletions(-)
>>
>> Your diffstat should have indicated to you that this should be split up
>> better. Please (re-)read SubmittingPatches. *One* logical change per
>> patch, most importantly.
> OK. I would resubmit.
>> >
>> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
>> > index 2cd3391..a800a69 100644
>> > --- a/drivers/block/cciss.c
>> > +++ b/drivers/block/cciss.c
>> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size'
>> member is 16-bits
>> > return -EINVAL;
>> > #endif
>> > if (iocommand.buf_size > 0) {
>> > - buff = kmalloc(iocommand.buf_size,
>> GFP_KERNEL);
>> > + buff = kzalloc(iocommand.buf_size,
>> GFP_KERNEL);
>> > if (buff = NULL)
>> > return -EFAULT;
>> > }
>> > @@ -911,8 +911,6 @@ #endif
>> > kfree(buff);
>> > return -EFAULT;
>> > }
>> > - } else {
>> > - memset(buff, 0, iocommand.buf_size);
>> > }
>> > if ((c = cmd_alloc(host, 0)) = NULL) {
>> > kfree(buff);
>>
>> This changes performance potentially, no? The memset before was
>> conditional upon (iocommand.Request.Type.Direction = XFER_WRITE) and
>> now the memory will always be zero'd.
> Yes, but not the functionality.
> if (iocommand.buf_size > 0), code allocates using kmalloc. if
> direction is XFER_WRITE, it does a copy_from_user(), and free()s the
> allocated buffer, not really caring what data came in from userspace.
> Else, it does memset(). So I could safely replace the kmalloc() with
> kzalloc() without compromising functionality.
Ok, this is something like I need 10 bytes of memory, so I request two memory
pages for reserved use. It works, but it kills performance.
Why you zero memory that is not needed to be zeroed?
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 8:36 ` Jiri Slaby
0 siblings, 0 replies; 55+ messages in thread
From: Jiri Slaby @ 2006-09-22 8:36 UTC (permalink / raw)
To: Om Narasimhan; +Cc: Nishanth Aravamudan, linux-kernel, kernel-janitors
Om Narasimhan wrote:
> Thanks for the comments.
>> >
>> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>>
>> This is not the canonical format, per SubmittingPatches. It should be:
>>
>> Signed-off-by: Random J Developer <random@developer.example.org>
> OK. I would take care of it.
>>
>> > drivers/block/cciss.c | 4 +--
>> > drivers/block/cpqarray.c | 72
>> +++++++++++++++-------------------------------
>> > drivers/block/loop.c | 4 +--
>> > 3 files changed, 25 insertions(+), 55 deletions(-)
>>
>> Your diffstat should have indicated to you that this should be split up
>> better. Please (re-)read SubmittingPatches. *One* logical change per
>> patch, most importantly.
> OK. I would resubmit.
>> >
>> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
>> > index 2cd3391..a800a69 100644
>> > --- a/drivers/block/cciss.c
>> > +++ b/drivers/block/cciss.c
>> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size'
>> member is 16-bits
>> > return -EINVAL;
>> > #endif
>> > if (iocommand.buf_size > 0) {
>> > - buff = kmalloc(iocommand.buf_size,
>> GFP_KERNEL);
>> > + buff = kzalloc(iocommand.buf_size,
>> GFP_KERNEL);
>> > if (buff == NULL)
>> > return -EFAULT;
>> > }
>> > @@ -911,8 +911,6 @@ #endif
>> > kfree(buff);
>> > return -EFAULT;
>> > }
>> > - } else {
>> > - memset(buff, 0, iocommand.buf_size);
>> > }
>> > if ((c = cmd_alloc(host, 0)) == NULL) {
>> > kfree(buff);
>>
>> This changes performance potentially, no? The memset before was
>> conditional upon (iocommand.Request.Type.Direction == XFER_WRITE) and
>> now the memory will always be zero'd.
> Yes, but not the functionality.
> if (iocommand.buf_size > 0), code allocates using kmalloc. if
> direction is XFER_WRITE, it does a copy_from_user(), and free()s the
> allocated buffer, not really caring what data came in from userspace.
> Else, it does memset(). So I could safely replace the kmalloc() with
> kzalloc() without compromising functionality.
Ok, this is something like I need 10 bytes of memory, so I request two memory
pages for reserved use. It works, but it kills performance.
Why you zero memory that is not needed to be zeroed?
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 6:04 ` Om Narasimhan
@ 2006-09-22 8:43 ` Jiri Slaby
-1 siblings, 0 replies; 55+ messages in thread
From: Jiri Slaby @ 2006-09-22 8:43 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
Om Narasimhan wrote:
> Comments incorporated
> Changes kmalloc() calls succeeded by memset(,0,) to kzalloc()
>
> Signed off by : Om Narasimhan <om.turyx@gmail.com>
> drivers/block/cciss.c | 4 +---
> drivers/block/cpqarray.c | 7 ++-----
> drivers/block/loop.c | 3 +--
> 3 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> index 2cd3391..a800a69 100644
> --- a/drivers/block/cciss.c
> +++ b/drivers/block/cciss.c
> @@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
> return -EINVAL;
> #endif
> if (iocommand.buf_size > 0) {
> - buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
> + buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
> if (buff = NULL)
> return -EFAULT;
> }
> @@ -911,8 +911,6 @@ #endif
> kfree(buff);
> return -EFAULT;
> }
> - } else {
> - memset(buff, 0, iocommand.buf_size);
No.
> }
> if ((c = cmd_alloc(host, 0)) = NULL) {
> kfree(buff);
> diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
> index 78082ed..34f8e96 100644
> --- a/drivers/block/cpqarray.c
> +++ b/drivers/block/cpqarray.c
> @@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
> hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
> hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
> &(hba[i]->cmd_pool_dhandle));
> - hba[i]->cmd_pool_bits = kmalloc(
> + hba[i]->cmd_pool_bits = kzalloc(
> ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
> GFP_KERNEL);
kcalloc?
> @@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
> goto Enomem1;
>
> memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
> - memset(hba[i]->cmd_pool_bits, 0,
> ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
What's this? Wrapped? kcalloc?
> printk(KERN_INFO "cpqarray: Finding drives on %s",
> hba[i]->devname);
>
> @@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
> i = alloc_cpqarray_hba();
> if( i < 0 )
> return (-1);
> - memset(hba[i], 0, sizeof(ctlr_info_t));
> sprintf(hba[i]->devname, "ida%d", i);
> hba[i]->ctlr = i;
> /* Initialize the pdev driver private data */
> @@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
>
> for(i=0; i< MAX_CTLR; i++) {
> if (hba[i] = NULL) {
> - hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
> + hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
> if(hba[i]=NULL) {
> printk(KERN_ERR "cpqarray: out of memory.\n");
> return (-1);
> @@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
> continue;
> }
>
> - memset(hba[ctlr], 0, sizeof(ctlr_info_t));
> hba[ctlr]->io_mem_addr = eisa[i];
> hba[ctlr]->io_mem_length = 0x7FF;
> if(!request_region(hba[ctlr]->io_mem_addr,
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 7b3b94d..91b48ef 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1260,10 +1260,9 @@ static int __init loop_init(void)
> if (register_blkdev(LOOP_MAJOR, "loop"))
> return -EIO;
>
> - loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
> + loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
kcalloc?
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 8:43 ` Jiri Slaby
0 siblings, 0 replies; 55+ messages in thread
From: Jiri Slaby @ 2006-09-22 8:43 UTC (permalink / raw)
To: Om Narasimhan; +Cc: linux-kernel, kernel-janitors
Om Narasimhan wrote:
> Comments incorporated
> Changes kmalloc() calls succeeded by memset(,0,) to kzalloc()
>
> Signed off by : Om Narasimhan <om.turyx@gmail.com>
> drivers/block/cciss.c | 4 +---
> drivers/block/cpqarray.c | 7 ++-----
> drivers/block/loop.c | 3 +--
> 3 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> index 2cd3391..a800a69 100644
> --- a/drivers/block/cciss.c
> +++ b/drivers/block/cciss.c
> @@ -900,7 +900,7 @@ #if 0 /* 'buf_size' member is 16-bits
> return -EINVAL;
> #endif
> if (iocommand.buf_size > 0) {
> - buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
> + buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
> if (buff == NULL)
> return -EFAULT;
> }
> @@ -911,8 +911,6 @@ #endif
> kfree(buff);
> return -EFAULT;
> }
> - } else {
> - memset(buff, 0, iocommand.buf_size);
No.
> }
> if ((c = cmd_alloc(host, 0)) == NULL) {
> kfree(buff);
> diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
> index 78082ed..34f8e96 100644
> --- a/drivers/block/cpqarray.c
> +++ b/drivers/block/cpqarray.c
> @@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
> hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
> hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
> &(hba[i]->cmd_pool_dhandle));
> - hba[i]->cmd_pool_bits = kmalloc(
> + hba[i]->cmd_pool_bits = kzalloc(
> ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
> GFP_KERNEL);
kcalloc?
> @@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
> goto Enomem1;
>
> memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
> - memset(hba[i]->cmd_pool_bits, 0,
> ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));
What's this? Wrapped? kcalloc?
> printk(KERN_INFO "cpqarray: Finding drives on %s",
> hba[i]->devname);
>
> @@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
> i = alloc_cpqarray_hba();
> if( i < 0 )
> return (-1);
> - memset(hba[i], 0, sizeof(ctlr_info_t));
> sprintf(hba[i]->devname, "ida%d", i);
> hba[i]->ctlr = i;
> /* Initialize the pdev driver private data */
> @@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)
>
> for(i=0; i< MAX_CTLR; i++) {
> if (hba[i] == NULL) {
> - hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
> + hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
> if(hba[i]==NULL) {
> printk(KERN_ERR "cpqarray: out of memory.\n");
> return (-1);
> @@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
> continue;
> }
>
> - memset(hba[ctlr], 0, sizeof(ctlr_info_t));
> hba[ctlr]->io_mem_addr = eisa[i];
> hba[ctlr]->io_mem_length = 0x7FF;
> if(!request_region(hba[ctlr]->io_mem_addr,
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 7b3b94d..91b48ef 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1260,10 +1260,9 @@ static int __init loop_init(void)
> if (register_blkdev(LOOP_MAJOR, "loop"))
> return -EIO;
>
> - loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
> + loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
kcalloc?
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 8:36 ` Jiri Slaby
@ 2006-09-22 11:28 ` Paulo Marques
-1 siblings, 0 replies; 55+ messages in thread
From: Paulo Marques @ 2006-09-22 11:28 UTC (permalink / raw)
To: Jiri Slaby
Cc: Om Narasimhan, Nishanth Aravamudan, linux-kernel, kernel-janitors
Jiri Slaby wrote:
> Om Narasimhan wrote:
>> Thanks for the comments.
>>> >
>>> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>>>
>>> This is not the canonical format, per SubmittingPatches. It should be:
>>>
>>> Signed-off-by: Random J Developer <random@developer.example.org>
>> OK. I would take care of it.
>>>
>>> > drivers/block/cciss.c | 4 +--
>>> > drivers/block/cpqarray.c | 72
>>> +++++++++++++++-------------------------------
>>> > drivers/block/loop.c | 4 +--
>>> > 3 files changed, 25 insertions(+), 55 deletions(-)
>>>
>>> Your diffstat should have indicated to you that this should be split up
>>> better. Please (re-)read SubmittingPatches. *One* logical change per
>>> patch, most importantly.
>> OK. I would resubmit.
>>> >
>>> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
>>> > index 2cd3391..a800a69 100644
>>> > --- a/drivers/block/cciss.c
>>> > +++ b/drivers/block/cciss.c
>>> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size'
>>> member is 16-bits
>>> > return -EINVAL;
>>> > #endif
>>> > if (iocommand.buf_size > 0) {
>>> > - buff = kmalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > + buff = kzalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > if (buff = NULL)
>>> > return -EFAULT;
>>> > }
>>> > @@ -911,8 +911,6 @@ #endif
>>> > kfree(buff);
>>> > return -EFAULT;
>>> > }
>>> > - } else {
>>> > - memset(buff, 0, iocommand.buf_size);
>>> > }
>>> > if ((c = cmd_alloc(host, 0)) = NULL) {
>>> > kfree(buff);
>>>
>>> This changes performance potentially, no? The memset before was
>>> conditional upon (iocommand.Request.Type.Direction = XFER_WRITE) and
>>> now the memory will always be zero'd.
>> Yes, but not the functionality.
>> if (iocommand.buf_size > 0), code allocates using kmalloc. if
>> direction is XFER_WRITE, it does a copy_from_user(), and free()s the
>> allocated buffer, not really caring what data came in from userspace.
You really misread that code. It frees the buffer and returns -EFAULT if
the copy_from_user _failed_. This is standard procedure and that code
doesn't need to be changed to kzalloc.
Please only do kmalloc to k[zc]alloc changes that are really trivial.
There is no point in risking inserting new bugs (or performance
regressions) for some micro-space-optimization such as this.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 11:28 ` Paulo Marques
0 siblings, 0 replies; 55+ messages in thread
From: Paulo Marques @ 2006-09-22 11:28 UTC (permalink / raw)
To: Jiri Slaby
Cc: Om Narasimhan, Nishanth Aravamudan, linux-kernel, kernel-janitors
Jiri Slaby wrote:
> Om Narasimhan wrote:
>> Thanks for the comments.
>>> >
>>> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>>>
>>> This is not the canonical format, per SubmittingPatches. It should be:
>>>
>>> Signed-off-by: Random J Developer <random@developer.example.org>
>> OK. I would take care of it.
>>>
>>> > drivers/block/cciss.c | 4 +--
>>> > drivers/block/cpqarray.c | 72
>>> +++++++++++++++-------------------------------
>>> > drivers/block/loop.c | 4 +--
>>> > 3 files changed, 25 insertions(+), 55 deletions(-)
>>>
>>> Your diffstat should have indicated to you that this should be split up
>>> better. Please (re-)read SubmittingPatches. *One* logical change per
>>> patch, most importantly.
>> OK. I would resubmit.
>>> >
>>> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
>>> > index 2cd3391..a800a69 100644
>>> > --- a/drivers/block/cciss.c
>>> > +++ b/drivers/block/cciss.c
>>> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size'
>>> member is 16-bits
>>> > return -EINVAL;
>>> > #endif
>>> > if (iocommand.buf_size > 0) {
>>> > - buff = kmalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > + buff = kzalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > if (buff == NULL)
>>> > return -EFAULT;
>>> > }
>>> > @@ -911,8 +911,6 @@ #endif
>>> > kfree(buff);
>>> > return -EFAULT;
>>> > }
>>> > - } else {
>>> > - memset(buff, 0, iocommand.buf_size);
>>> > }
>>> > if ((c = cmd_alloc(host, 0)) == NULL) {
>>> > kfree(buff);
>>>
>>> This changes performance potentially, no? The memset before was
>>> conditional upon (iocommand.Request.Type.Direction == XFER_WRITE) and
>>> now the memory will always be zero'd.
>> Yes, but not the functionality.
>> if (iocommand.buf_size > 0), code allocates using kmalloc. if
>> direction is XFER_WRITE, it does a copy_from_user(), and free()s the
>> allocated buffer, not really caring what data came in from userspace.
You really misread that code. It frees the buffer and returns -EFAULT if
the copy_from_user _failed_. This is standard procedure and that code
doesn't need to be changed to kzalloc.
Please only do kmalloc to k[zc]alloc changes that are really trivial.
There is no point in risking inserting new bugs (or performance
regressions) for some micro-space-optimization such as this.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 8:43 ` Jiri Slaby
@ 2006-09-22 11:32 ` Paulo Marques
-1 siblings, 0 replies; 55+ messages in thread
From: Paulo Marques @ 2006-09-22 11:32 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Om Narasimhan, linux-kernel, kernel-janitors
Jiri Slaby wrote:
> Om Narasimhan wrote:
>> [...]
>> --- a/drivers/block/cpqarray.c
>> +++ b/drivers/block/cpqarray.c
>> @@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
>> hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
>> hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
>> &(hba[i]->cmd_pool_dhandle));
>> - hba[i]->cmd_pool_bits = kmalloc(
>> + hba[i]->cmd_pool_bits = kzalloc(
>> ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
>> GFP_KERNEL);
>
> kcalloc?
Agreed on every comment except this one. That complex expression is
really just a constant in the end, so there is no point in using kcalloc.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 11:32 ` Paulo Marques
0 siblings, 0 replies; 55+ messages in thread
From: Paulo Marques @ 2006-09-22 11:32 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Om Narasimhan, linux-kernel, kernel-janitors
Jiri Slaby wrote:
> Om Narasimhan wrote:
>> [...]
>> --- a/drivers/block/cpqarray.c
>> +++ b/drivers/block/cpqarray.c
>> @@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
>> hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
>> hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
>> &(hba[i]->cmd_pool_dhandle));
>> - hba[i]->cmd_pool_bits = kmalloc(
>> + hba[i]->cmd_pool_bits = kzalloc(
>> ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
>> GFP_KERNEL);
>
> kcalloc?
Agreed on every comment except this one. That complex expression is
really just a constant in the end, so there is no point in using kcalloc.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 11:32 ` Paulo Marques
@ 2006-09-22 12:03 ` Pekka Enberg
-1 siblings, 0 replies; 55+ messages in thread
From: Pekka Enberg @ 2006-09-22 12:03 UTC (permalink / raw)
To: Paulo Marques; +Cc: Jiri Slaby, Om Narasimhan, linux-kernel, kernel-janitors
On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
> Agreed on every comment except this one. That complex expression is
> really just a constant in the end, so there is no point in using kcalloc.
The code is arguably easier to read with kcalloc.
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 12:03 ` Pekka Enberg
0 siblings, 0 replies; 55+ messages in thread
From: Pekka Enberg @ 2006-09-22 12:03 UTC (permalink / raw)
To: Paulo Marques; +Cc: Jiri Slaby, Om Narasimhan, linux-kernel, kernel-janitors
On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
> Agreed on every comment except this one. That complex expression is
> really just a constant in the end, so there is no point in using kcalloc.
The code is arguably easier to read with kcalloc.
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 12:03 ` Pekka Enberg
@ 2006-09-22 13:03 ` Paulo Marques
-1 siblings, 0 replies; 55+ messages in thread
From: Paulo Marques @ 2006-09-22 13:03 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Jiri Slaby, Om Narasimhan, linux-kernel, kernel-janitors
Pekka Enberg wrote:
> On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
>> Agreed on every comment except this one. That complex expression is
>> really just a constant in the end, so there is no point in using kcalloc.
>
> The code is arguably easier to read with kcalloc.
I was afraid the kcalloc call would have the added overhead of an extra
parameter and a multiplication, but since it is actually declared as a
static inline, gcc should optimize everything away (because both
parameters are constants) and give the same result in the end.
So, its fine by me either way.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 13:03 ` Paulo Marques
0 siblings, 0 replies; 55+ messages in thread
From: Paulo Marques @ 2006-09-22 13:03 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Jiri Slaby, Om Narasimhan, linux-kernel, kernel-janitors
Pekka Enberg wrote:
> On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
>> Agreed on every comment except this one. That complex expression is
>> really just a constant in the end, so there is no point in using kcalloc.
>
> The code is arguably easier to read with kcalloc.
I was afraid the kcalloc call would have the added overhead of an extra
parameter and a multiplication, but since it is actually declared as a
static inline, gcc should optimize everything away (because both
parameters are constants) and give the same result in the end.
So, its fine by me either way.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 13:03 ` Paulo Marques
@ 2006-09-22 13:45 ` Dmitry Torokhov
-1 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-22 13:45 UTC (permalink / raw)
To: Paulo Marques
Cc: Pekka Enberg, Jiri Slaby, Om Narasimhan, linux-kernel,
kernel-janitors
On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
> Pekka Enberg wrote:
> > On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
> >> Agreed on every comment except this one. That complex expression is
> >> really just a constant in the end, so there is no point in using kcalloc.
> >
> > The code is arguably easier to read with kcalloc.
>
> I was afraid the kcalloc call would have the added overhead of an extra
> parameter and a multiplication, but since it is actually declared as a
> static inline, gcc should optimize everything away (because both
> parameters are constants) and give the same result in the end.
>
I think the we should follow a rule like this: when allocating several
separate objects of the same type at the same time (like 10 "card"
structures) kcalloc should be used. When allocating one object (even
consisting of "several ints") kmalloc/kzalloc should be used. As far
as I can see the code just tries to allocate longish bitmap and so
kzalloc is better.
Better yet, why don't you DECLARE_BITMAP(cmd_pool_bits) and embed it
right into struct ctrl_info instead of dynamically allocating it?
--
Dmitry
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 13:45 ` Dmitry Torokhov
0 siblings, 0 replies; 55+ messages in thread
From: Dmitry Torokhov @ 2006-09-22 13:45 UTC (permalink / raw)
To: Paulo Marques
Cc: Pekka Enberg, Jiri Slaby, Om Narasimhan, linux-kernel,
kernel-janitors
On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
> Pekka Enberg wrote:
> > On 9/22/06, Paulo Marques <pmarques@grupopie.com> wrote:
> >> Agreed on every comment except this one. That complex expression is
> >> really just a constant in the end, so there is no point in using kcalloc.
> >
> > The code is arguably easier to read with kcalloc.
>
> I was afraid the kcalloc call would have the added overhead of an extra
> parameter and a multiplication, but since it is actually declared as a
> static inline, gcc should optimize everything away (because both
> parameters are constants) and give the same result in the end.
>
I think the we should follow a rule like this: when allocating several
separate objects of the same type at the same time (like 10 "card"
structures) kcalloc should be used. When allocating one object (even
consisting of "several ints") kmalloc/kzalloc should be used. As far
as I can see the code just tries to allocate longish bitmap and so
kzalloc is better.
Better yet, why don't you DECLARE_BITMAP(cmd_pool_bits) and embed it
right into struct ctrl_info instead of dynamically allocating it?
--
Dmitry
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
2006-09-22 13:45 ` Dmitry Torokhov
@ 2006-09-22 22:55 ` Om Narasimhan
-1 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 22:55 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Paulo Marques, Pekka Enberg, Jiri Slaby, linux-kernel,
kernel-janitors
> I think the we should follow a rule like this: when allocating several
> separate objects of the same type at the same time (like 10 "card"
> structures) kcalloc should be used. When allocating one object (even
> consisting of "several ints") kmalloc/kzalloc should be used. As far
> as I can see the code just tries to allocate longish bitmap and so
> kzalloc is better.
>
> Better yet, why don't you DECLARE_BITMAP(cmd_pool_bits) and embed it
> right into struct ctrl_info instead of dynamically allocating it?
hba is decalred as
static ctlr_info_t *hba[MAX_CTLR]
So if I change the cmd_pool_bits to embed the DECLARE_BITMAP
statement, while compiling this file as a module, is there not a
chance of cmd_pool_bits cross a page boundary and allocated in two non
contiguous (physical) pages? Would it cause a problem with
__find_fist_zero_bit() and friends?
Regards,
Om.
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
@ 2006-09-22 22:55 ` Om Narasimhan
0 siblings, 0 replies; 55+ messages in thread
From: Om Narasimhan @ 2006-09-22 22:55 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Paulo Marques, Pekka Enberg, Jiri Slaby, linux-kernel,
kernel-janitors
> I think the we should follow a rule like this: when allocating several
> separate objects of the same type at the same time (like 10 "card"
> structures) kcalloc should be used. When allocating one object (even
> consisting of "several ints") kmalloc/kzalloc should be used. As far
> as I can see the code just tries to allocate longish bitmap and so
> kzalloc is better.
>
> Better yet, why don't you DECLARE_BITMAP(cmd_pool_bits) and embed it
> right into struct ctrl_info instead of dynamically allocating it?
hba is decalred as
static ctlr_info_t *hba[MAX_CTLR]
So if I change the cmd_pool_bits to embed the DECLARE_BITMAP
statement, while compiling this file as a module, is there not a
chance of cmd_pool_bits cross a page boundary and allocated in two non
contiguous (physical) pages? Would it cause a problem with
__find_fist_zero_bit() and friends?
Regards,
Om.
^ permalink raw reply [flat|nested] 55+ messages in thread
end of thread, other threads:[~2006-09-22 22:55 UTC | newest]
Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-18 0:53 [KJ] kmalloc to kzalloc patches for drivers/mfd Om Narasimhan
2006-09-18 0:53 ` Om Narasimhan
2006-09-18 0:53 ` [KJ] kmalloc to kzalloc patches for drivers/atm Om Narasimhan
2006-09-18 0:53 ` Om Narasimhan
2006-09-18 1:19 ` [KJ] " Dmitry Torokhov
2006-09-18 1:19 ` Dmitry Torokhov
2006-09-18 9:42 ` [KJ] " Alan Cox
2006-09-18 9:42 ` Alan Cox
2006-09-18 12:07 ` [KJ] " Pekka Enberg
2006-09-18 12:07 ` Pekka Enberg
2006-09-18 0:53 ` [KJ] kmalloc to kzalloc patches for drivers/base Om Narasimhan
2006-09-18 0:53 ` Om Narasimhan
2006-09-18 1:08 ` [KJ] " Dmitry Torokhov
2006-09-18 1:08 ` Dmitry Torokhov
2006-09-18 2:27 ` [KJ] " Om Narasimhan
2006-09-18 2:27 ` Om Narasimhan
2006-09-18 9:40 ` [KJ] " Alan Cox
2006-09-18 9:40 ` Alan Cox
2006-09-18 12:31 ` [KJ] " Greg KH
2006-09-18 12:31 ` Greg KH
2006-09-18 0:54 ` [KJ] kmalloc to kzalloc patches for drivers/block Om Narasimhan
2006-09-18 0:54 ` Om Narasimhan
2006-09-18 9:43 ` [KJ] kmalloc to kzalloc patches for drivers/mfd Alan Cox
2006-09-18 9:43 ` Alan Cox
2006-09-21 6:11 ` [KJ] kmalloc to kzalloc patches for drivers/block [sane version] Om Narasimhan
2006-09-21 6:11 ` Om Narasimhan
2006-09-21 7:20 ` [KJ] " Nishanth Aravamudan
2006-09-21 7:20 ` Nishanth Aravamudan
2006-09-22 5:40 ` Om Narasimhan
2006-09-22 5:40 ` Om Narasimhan
2006-09-22 6:04 ` Om Narasimhan
2006-09-22 6:04 ` Om Narasimhan
2006-09-22 8:43 ` Jiri Slaby
2006-09-22 8:43 ` Jiri Slaby
2006-09-22 11:32 ` Paulo Marques
2006-09-22 11:32 ` Paulo Marques
2006-09-22 12:03 ` Pekka Enberg
2006-09-22 12:03 ` Pekka Enberg
2006-09-22 13:03 ` Paulo Marques
2006-09-22 13:03 ` Paulo Marques
2006-09-22 13:45 ` Dmitry Torokhov
2006-09-22 13:45 ` Dmitry Torokhov
2006-09-22 22:55 ` Om Narasimhan
2006-09-22 22:55 ` Om Narasimhan
2006-09-22 8:36 ` Jiri Slaby
2006-09-22 8:36 ` Jiri Slaby
2006-09-22 11:28 ` Paulo Marques
2006-09-22 11:28 ` Paulo Marques
2006-09-21 7:12 ` [KJ] kmalloc to kzalloc patches for drivers/atm " Om Narasimhan
2006-09-21 7:12 ` Om Narasimhan
2006-09-21 13:36 ` [KJ] " Dmitry Torokhov
2006-09-21 13:36 ` Dmitry Torokhov
2006-09-22 5:29 ` [KJ] " Om Narasimhan
2006-09-22 5:29 ` Om Narasimhan
2006-09-21 7:35 ` [KJ] kmalloc to kzalloc patches for drivers/block " Thomas Petazzoni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.