Skip to content

Commit 7ac2ed0

Browse files
JoePerchesdavem330
authored andcommitted
caif: Remove OOM messages, use kzalloc
Remove per site OOM messages because they duplicate the generic mm subsystem OOM message. Use kzalloc instead of kmalloc/memset when next to the OOM message removals. Reduces object size (allyesconfig ~2%) $ size -t drivers/net/caif/built-in.o.old net/caif/built-in.o.old text data bss dec hex filename 32297 700 8224 41221 a105 drivers/net/caif/built-in.o.old 72159 1317 20552 94028 16f4c net/caif/built-in.o.old 104456 2017 28776 135249 21051 (TOTALS) $ size -t drivers/net/caif/built-in.o.new net/caif/built-in.o.new text data bss dec hex filename 31975 700 8184 40859 9f9b drivers/net/caif/built-in.o.new 70748 1317 20152 92217 16839 net/caif/built-in.o.new 102723 2017 28336 133076 207d4 (TOTALS) Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 343e43c commit 7ac2ed0

13 files changed

Lines changed: 28 additions & 87 deletions

File tree

‎drivers/net/caif/caif_hsi.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,8 @@ int cfhsi_probe(struct platform_device *pdev)
937937
int res;
938938

939939
ndev = alloc_netdev(sizeof(struct cfhsi), "cfhsi%d", cfhsi_setup);
940-
if (!ndev) {
941-
dev_err(&pdev->dev, "%s: alloc_netdev failed.\n",
942-
__func__);
940+
if (!ndev)
943941
return -ENODEV;
944-
}
945942

946943
cfhsi = netdev_priv(ndev);
947944
cfhsi->ndev = ndev;
@@ -969,8 +966,6 @@ int cfhsi_probe(struct platform_device *pdev)
969966
*/
970967
cfhsi->tx_buf = kzalloc(CFHSI_BUF_SZ_TX, GFP_KERNEL);
971968
if (!cfhsi->tx_buf) {
972-
dev_err(&ndev->dev, "%s: Failed to allocate TX buffer.\n",
973-
__func__);
974969
res = -ENODEV;
975970
goto err_alloc_tx;
976971
}
@@ -981,8 +976,6 @@ int cfhsi_probe(struct platform_device *pdev)
981976
*/
982977
cfhsi->rx_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL);
983978
if (!cfhsi->rx_buf) {
984-
dev_err(&ndev->dev, "%s: Failed to allocate RX buffer.\n",
985-
__func__);
986979
res = -ENODEV;
987980
goto err_alloc_rx;
988981
}

‎drivers/net/caif/caif_spi.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,17 +664,13 @@ int cfspi_spi_probe(struct platform_device *pdev)
664664
/* Allocate DMA buffers. */
665665
cfspi->xfer.va_tx = dma_alloc(&cfspi->xfer.pa_tx);
666666
if (!cfspi->xfer.va_tx) {
667-
printk(KERN_WARNING
668-
"CFSPI: failed to allocate dma TX buffer.\n");
669667
res = -ENODEV;
670668
goto err_dma_alloc_tx;
671669
}
672670

673671
cfspi->xfer.va_rx = dma_alloc(&cfspi->xfer.pa_rx);
674672

675673
if (!cfspi->xfer.va_rx) {
676-
printk(KERN_WARNING
677-
"CFSPI: failed to allocate dma TX buffer.\n");
678674
res = -ENODEV;
679675
goto err_dma_alloc_rx;
680676
}

‎net/caif/cfcnfg.c‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ struct cfcnfg *cfcnfg_create(void)
7878

7979
/* Initiate this layer */
8080
this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
81-
if (!this) {
82-
pr_warn("Out of memory\n");
81+
if (!this)
8382
return NULL;
84-
}
8583
this->mux = cfmuxl_create();
8684
if (!this->mux)
8785
goto out_of_mem;
@@ -108,8 +106,6 @@ struct cfcnfg *cfcnfg_create(void)
108106

109107
return this;
110108
out_of_mem:
111-
pr_warn("Out of memory\n");
112-
113109
synchronize_rcu();
114110

115111
kfree(this->mux);
@@ -448,10 +444,8 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv,
448444
"- unknown channel type\n");
449445
goto unlock;
450446
}
451-
if (!servicel) {
452-
pr_warn("Out of memory\n");
447+
if (!servicel)
453448
goto unlock;
454-
}
455449
layer_set_dn(servicel, cnfg->mux);
456450
cfmuxl_set_uplayer(cnfg->mux, servicel, channel_id);
457451
layer_set_up(servicel, adapt_layer);
@@ -497,10 +491,8 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
497491
case CFPHYTYPE_FRAG:
498492
phy_driver =
499493
cfserl_create(CFPHYTYPE_FRAG, phyid, stx);
500-
if (!phy_driver) {
501-
pr_warn("Out of memory\n");
494+
if (!phy_driver)
502495
goto out;
503-
}
504496
break;
505497
case CFPHYTYPE_CAIF:
506498
phy_driver = NULL;
@@ -521,7 +513,6 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
521513
frml = cffrml_create(phyid, fcs);
522514

523515
if (!frml) {
524-
pr_warn("Out of memory\n");
525516
kfree(phyinfo);
526517
goto out;
527518
}

‎net/caif/cfctrl.c‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@ struct cflayer *cfctrl_create(void)
3535
{
3636
struct dev_info dev_info;
3737
struct cfctrl *this =
38-
kmalloc(sizeof(struct cfctrl), GFP_ATOMIC);
39-
if (!this) {
40-
pr_warn("Out of memory\n");
38+
kzalloc(sizeof(struct cfctrl), GFP_ATOMIC);
39+
if (!this)
4140
return NULL;
42-
}
4341
caif_assert(offsetof(struct cfctrl, serv.layer) == 0);
4442
memset(&dev_info, 0, sizeof(dev_info));
4543
dev_info.id = 0xff;
46-
memset(this, 0, sizeof(*this));
4744
cfsrvl_init(&this->serv, 0, &dev_info, false);
4845
atomic_set(&this->req_seq_no, 1);
4946
atomic_set(&this->rsp_seq_no, 1);
@@ -180,10 +177,8 @@ void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid)
180177
struct cfctrl *cfctrl = container_obj(layer);
181178
struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
182179
struct cflayer *dn = cfctrl->serv.layer.dn;
183-
if (!pkt) {
184-
pr_warn("Out of memory\n");
180+
if (!pkt)
185181
return;
186-
}
187182
if (!dn) {
188183
pr_debug("not able to send enum request\n");
189184
return;
@@ -224,10 +219,8 @@ int cfctrl_linkup_request(struct cflayer *layer,
224219
}
225220

226221
pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
227-
if (!pkt) {
228-
pr_warn("Out of memory\n");
222+
if (!pkt)
229223
return -ENOMEM;
230-
}
231224
cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_SETUP);
232225
cfpkt_addbdy(pkt, (param->chtype << 4) | param->linktype);
233226
cfpkt_addbdy(pkt, (param->priority << 3) | param->phyid);
@@ -275,10 +268,8 @@ int cfctrl_linkup_request(struct cflayer *layer,
275268
return -EINVAL;
276269
}
277270
req = kzalloc(sizeof(*req), GFP_KERNEL);
278-
if (!req) {
279-
pr_warn("Out of memory\n");
271+
if (!req)
280272
return -ENOMEM;
281-
}
282273
req->client_layer = user_layer;
283274
req->cmd = CFCTRL_CMD_LINK_SETUP;
284275
req->param = *param;
@@ -312,10 +303,8 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid,
312303
struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
313304
struct cflayer *dn = cfctrl->serv.layer.dn;
314305

315-
if (!pkt) {
316-
pr_warn("Out of memory\n");
306+
if (!pkt)
317307
return -ENOMEM;
318-
}
319308

320309
if (!dn) {
321310
pr_debug("not able to send link-down request\n");

‎net/caif/cfdbgl.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt);
1919

2020
struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
2121
{
22-
struct cfsrvl *dbg = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
23-
if (!dbg) {
24-
pr_warn("Out of memory\n");
22+
struct cfsrvl *dbg = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
23+
if (!dbg)
2524
return NULL;
26-
}
2725
caif_assert(offsetof(struct cfsrvl, layer) == 0);
28-
memset(dbg, 0, sizeof(struct cfsrvl));
2926
cfsrvl_init(dbg, channel_id, dev_info, false);
3027
dbg->layer.receive = cfdbgl_receive;
3128
dbg->layer.transmit = cfdbgl_transmit;

‎net/caif/cfdgml.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt);
2626

2727
struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
2828
{
29-
struct cfsrvl *dgm = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
30-
if (!dgm) {
31-
pr_warn("Out of memory\n");
29+
struct cfsrvl *dgm = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
30+
if (!dgm)
3231
return NULL;
33-
}
3432
caif_assert(offsetof(struct cfsrvl, layer) == 0);
35-
memset(dgm, 0, sizeof(struct cfsrvl));
3633
cfsrvl_init(dgm, channel_id, dev_info, true);
3734
dgm->layer.receive = cfdgml_receive;
3835
dgm->layer.transmit = cfdgml_transmit;

‎net/caif/cffrml.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ static u32 cffrml_rcv_error;
3434
static u32 cffrml_rcv_checsum_error;
3535
struct cflayer *cffrml_create(u16 phyid, bool use_fcs)
3636
{
37-
struct cffrml *this = kmalloc(sizeof(struct cffrml), GFP_ATOMIC);
38-
if (!this) {
39-
pr_warn("Out of memory\n");
37+
struct cffrml *this = kzalloc(sizeof(struct cffrml), GFP_ATOMIC);
38+
if (!this)
4039
return NULL;
41-
}
4240
this->pcpu_refcnt = alloc_percpu(int);
4341
if (this->pcpu_refcnt == NULL) {
4442
kfree(this);
@@ -47,7 +45,6 @@ struct cflayer *cffrml_create(u16 phyid, bool use_fcs)
4745

4846
caif_assert(offsetof(struct cffrml, layer) == 0);
4947

50-
memset(this, 0, sizeof(struct cflayer));
5148
this->layer.receive = cffrml_receive;
5249
this->layer.transmit = cffrml_transmit;
5350
this->layer.ctrlcmd = cffrml_ctrlcmd;

‎net/caif/cfrfml.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,10 @@ struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info,
4646
int mtu_size)
4747
{
4848
int tmp;
49-
struct cfrfml *this =
50-
kzalloc(sizeof(struct cfrfml), GFP_ATOMIC);
49+
struct cfrfml *this = kzalloc(sizeof(struct cfrfml), GFP_ATOMIC);
5150

52-
if (!this) {
53-
pr_warn("Out of memory\n");
51+
if (!this)
5452
return NULL;
55-
}
5653

5754
cfsrvl_init(&this->serv, channel_id, dev_info, false);
5855
this->serv.release = cfrfml_release;

‎net/caif/cfserl.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
3333

3434
struct cflayer *cfserl_create(int type, int instance, bool use_stx)
3535
{
36-
struct cfserl *this = kmalloc(sizeof(struct cfserl), GFP_ATOMIC);
37-
if (!this) {
38-
pr_warn("Out of memory\n");
36+
struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
37+
if (!this)
3938
return NULL;
40-
}
4139
caif_assert(offsetof(struct cfserl, layer) == 0);
42-
memset(this, 0, sizeof(struct cfserl));
4340
this->layer.receive = cfserl_receive;
4441
this->layer.transmit = cfserl_transmit;
4542
this->layer.ctrlcmd = cfserl_ctrlcmd;

‎net/caif/cfsrvl.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
108108
struct caif_payload_info *info;
109109
u8 flow_on = SRVL_FLOW_ON;
110110
pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE);
111-
if (!pkt) {
112-
pr_warn("Out of memory\n");
111+
if (!pkt)
113112
return -ENOMEM;
114-
}
115113

116114
if (cfpkt_add_head(pkt, &flow_on, 1) < 0) {
117115
pr_err("Packet is erroneous!\n");
@@ -130,10 +128,8 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
130128
struct caif_payload_info *info;
131129
u8 flow_off = SRVL_FLOW_OFF;
132130
pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE);
133-
if (!pkt) {
134-
pr_warn("Out of memory\n");
131+
if (!pkt)
135132
return -ENOMEM;
136-
}
137133

138134
if (cfpkt_add_head(pkt, &flow_off, 1) < 0) {
139135
pr_err("Packet is erroneous!\n");

0 commit comments

Comments
 (0)