[S390] ctc: kmalloc->kzalloc/casting cleanups.
A patch for the CTC / ESCON network driver. Switch from kmalloc to kzalloc when appropriate, remove some unnecessary kmalloc casts too. Since I have no s390 machine, I didn't compile it but I examined it carefully. Signed-off-by: "Ahmed S. Darwish" <darwish.07@gmail.com> Cc: Frank Pavlic <fpavlic@de.ibm.com> Cc: Ursula Braun <braunu@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
committed by
Martin Schwidefsky
parent
411ed32257
commit
b7127dfeed
@@ -1638,21 +1638,19 @@ add_channel(struct ccw_device *cdev, enum channel_types type)
|
|||||||
struct channel *ch;
|
struct channel *ch;
|
||||||
|
|
||||||
DBF_TEXT(trace, 2, __FUNCTION__);
|
DBF_TEXT(trace, 2, __FUNCTION__);
|
||||||
if ((ch =
|
ch = kzalloc(sizeof(struct channel), GFP_KERNEL);
|
||||||
(struct channel *) kmalloc(sizeof (struct channel),
|
if (!ch) {
|
||||||
GFP_KERNEL)) == NULL) {
|
|
||||||
ctc_pr_warn("ctc: Out of memory in add_channel\n");
|
ctc_pr_warn("ctc: Out of memory in add_channel\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(ch, 0, sizeof (struct channel));
|
/* assure all flags and counters are reset */
|
||||||
if ((ch->ccw = kmalloc(8*sizeof(struct ccw1),
|
ch->ccw = kzalloc(8 * sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
|
||||||
GFP_KERNEL | GFP_DMA)) == NULL) {
|
if (!ch->ccw) {
|
||||||
kfree(ch);
|
kfree(ch);
|
||||||
ctc_pr_warn("ctc: Out of memory in add_channel\n");
|
ctc_pr_warn("ctc: Out of memory in add_channel\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(ch->ccw, 0, 8*sizeof(struct ccw1)); // assure all flags and counters are reset
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "static" ccws are used in the following way:
|
* "static" ccws are used in the following way:
|
||||||
@@ -1692,15 +1690,14 @@ add_channel(struct ccw_device *cdev, enum channel_types type)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fsm_newstate(ch->fsm, CH_STATE_IDLE);
|
fsm_newstate(ch->fsm, CH_STATE_IDLE);
|
||||||
if ((ch->irb = kmalloc(sizeof (struct irb),
|
ch->irb = kzalloc(sizeof(struct irb), GFP_KERNEL);
|
||||||
GFP_KERNEL)) == NULL) {
|
if (!ch->irb) {
|
||||||
ctc_pr_warn("ctc: Out of memory in add_channel\n");
|
ctc_pr_warn("ctc: Out of memory in add_channel\n");
|
||||||
kfree_fsm(ch->fsm);
|
kfree_fsm(ch->fsm);
|
||||||
kfree(ch->ccw);
|
kfree(ch->ccw);
|
||||||
kfree(ch);
|
kfree(ch);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(ch->irb, 0, sizeof (struct irb));
|
|
||||||
while (*c && less_than((*c)->id, ch->id))
|
while (*c && less_than((*c)->id, ch->id))
|
||||||
c = &(*c)->next;
|
c = &(*c)->next;
|
||||||
if (*c && (!strncmp((*c)->id, ch->id, CTC_ID_SIZE))) {
|
if (*c && (!strncmp((*c)->id, ch->id, CTC_ID_SIZE))) {
|
||||||
@@ -2745,14 +2742,13 @@ ctc_probe_device(struct ccwgroup_device *cgdev)
|
|||||||
if (!get_device(&cgdev->dev))
|
if (!get_device(&cgdev->dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
priv = kmalloc(sizeof (struct ctc_priv), GFP_KERNEL);
|
priv = kzalloc(sizeof(struct ctc_priv), GFP_KERNEL);
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
ctc_pr_err("%s: Out of memory\n", __func__);
|
ctc_pr_err("%s: Out of memory\n", __func__);
|
||||||
put_device(&cgdev->dev);
|
put_device(&cgdev->dev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(priv, 0, sizeof (struct ctc_priv));
|
|
||||||
rc = ctc_add_files(&cgdev->dev);
|
rc = ctc_add_files(&cgdev->dev);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
kfree(priv);
|
kfree(priv);
|
||||||
@@ -2793,10 +2789,9 @@ ctc_init_netdevice(struct net_device * dev, int alloc_device,
|
|||||||
DBF_TEXT(setup, 3, __FUNCTION__);
|
DBF_TEXT(setup, 3, __FUNCTION__);
|
||||||
|
|
||||||
if (alloc_device) {
|
if (alloc_device) {
|
||||||
dev = kmalloc(sizeof (struct net_device), GFP_KERNEL);
|
dev = kzalloc(sizeof(struct net_device), GFP_KERNEL);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(dev, 0, sizeof (struct net_device));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->priv = privptr;
|
dev->priv = privptr;
|
||||||
|
Reference in New Issue
Block a user