Commit 7ac2ed0c authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 343e43c0
...@@ -937,11 +937,8 @@ int cfhsi_probe(struct platform_device *pdev) ...@@ -937,11 +937,8 @@ int cfhsi_probe(struct platform_device *pdev)
int res; int res;
ndev = alloc_netdev(sizeof(struct cfhsi), "cfhsi%d", cfhsi_setup); ndev = alloc_netdev(sizeof(struct cfhsi), "cfhsi%d", cfhsi_setup);
if (!ndev) { if (!ndev)
dev_err(&pdev->dev, "%s: alloc_netdev failed.\n",
__func__);
return -ENODEV; return -ENODEV;
}
cfhsi = netdev_priv(ndev); cfhsi = netdev_priv(ndev);
cfhsi->ndev = ndev; cfhsi->ndev = ndev;
...@@ -969,8 +966,6 @@ int cfhsi_probe(struct platform_device *pdev) ...@@ -969,8 +966,6 @@ int cfhsi_probe(struct platform_device *pdev)
*/ */
cfhsi->tx_buf = kzalloc(CFHSI_BUF_SZ_TX, GFP_KERNEL); cfhsi->tx_buf = kzalloc(CFHSI_BUF_SZ_TX, GFP_KERNEL);
if (!cfhsi->tx_buf) { if (!cfhsi->tx_buf) {
dev_err(&ndev->dev, "%s: Failed to allocate TX buffer.\n",
__func__);
res = -ENODEV; res = -ENODEV;
goto err_alloc_tx; goto err_alloc_tx;
} }
...@@ -981,8 +976,6 @@ int cfhsi_probe(struct platform_device *pdev) ...@@ -981,8 +976,6 @@ int cfhsi_probe(struct platform_device *pdev)
*/ */
cfhsi->rx_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL); cfhsi->rx_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL);
if (!cfhsi->rx_buf) { if (!cfhsi->rx_buf) {
dev_err(&ndev->dev, "%s: Failed to allocate RX buffer.\n",
__func__);
res = -ENODEV; res = -ENODEV;
goto err_alloc_rx; goto err_alloc_rx;
} }
......
...@@ -664,8 +664,6 @@ int cfspi_spi_probe(struct platform_device *pdev) ...@@ -664,8 +664,6 @@ int cfspi_spi_probe(struct platform_device *pdev)
/* Allocate DMA buffers. */ /* Allocate DMA buffers. */
cfspi->xfer.va_tx = dma_alloc(&cfspi->xfer.pa_tx); cfspi->xfer.va_tx = dma_alloc(&cfspi->xfer.pa_tx);
if (!cfspi->xfer.va_tx) { if (!cfspi->xfer.va_tx) {
printk(KERN_WARNING
"CFSPI: failed to allocate dma TX buffer.\n");
res = -ENODEV; res = -ENODEV;
goto err_dma_alloc_tx; goto err_dma_alloc_tx;
} }
...@@ -673,8 +671,6 @@ int cfspi_spi_probe(struct platform_device *pdev) ...@@ -673,8 +671,6 @@ int cfspi_spi_probe(struct platform_device *pdev)
cfspi->xfer.va_rx = dma_alloc(&cfspi->xfer.pa_rx); cfspi->xfer.va_rx = dma_alloc(&cfspi->xfer.pa_rx);
if (!cfspi->xfer.va_rx) { if (!cfspi->xfer.va_rx) {
printk(KERN_WARNING
"CFSPI: failed to allocate dma TX buffer.\n");
res = -ENODEV; res = -ENODEV;
goto err_dma_alloc_rx; goto err_dma_alloc_rx;
} }
......
...@@ -78,10 +78,8 @@ struct cfcnfg *cfcnfg_create(void) ...@@ -78,10 +78,8 @@ struct cfcnfg *cfcnfg_create(void)
/* Initiate this layer */ /* Initiate this layer */
this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC); this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
if (!this) { if (!this)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
this->mux = cfmuxl_create(); this->mux = cfmuxl_create();
if (!this->mux) if (!this->mux)
goto out_of_mem; goto out_of_mem;
...@@ -108,8 +106,6 @@ struct cfcnfg *cfcnfg_create(void) ...@@ -108,8 +106,6 @@ struct cfcnfg *cfcnfg_create(void)
return this; return this;
out_of_mem: out_of_mem:
pr_warn("Out of memory\n");
synchronize_rcu(); synchronize_rcu();
kfree(this->mux); kfree(this->mux);
...@@ -448,10 +444,8 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv, ...@@ -448,10 +444,8 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv,
"- unknown channel type\n"); "- unknown channel type\n");
goto unlock; goto unlock;
} }
if (!servicel) { if (!servicel)
pr_warn("Out of memory\n");
goto unlock; goto unlock;
}
layer_set_dn(servicel, cnfg->mux); layer_set_dn(servicel, cnfg->mux);
cfmuxl_set_uplayer(cnfg->mux, servicel, channel_id); cfmuxl_set_uplayer(cnfg->mux, servicel, channel_id);
layer_set_up(servicel, adapt_layer); layer_set_up(servicel, adapt_layer);
...@@ -497,10 +491,8 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, ...@@ -497,10 +491,8 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
case CFPHYTYPE_FRAG: case CFPHYTYPE_FRAG:
phy_driver = phy_driver =
cfserl_create(CFPHYTYPE_FRAG, phyid, stx); cfserl_create(CFPHYTYPE_FRAG, phyid, stx);
if (!phy_driver) { if (!phy_driver)
pr_warn("Out of memory\n");
goto out; goto out;
}
break; break;
case CFPHYTYPE_CAIF: case CFPHYTYPE_CAIF:
phy_driver = NULL; phy_driver = NULL;
...@@ -521,7 +513,6 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, ...@@ -521,7 +513,6 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
frml = cffrml_create(phyid, fcs); frml = cffrml_create(phyid, fcs);
if (!frml) { if (!frml) {
pr_warn("Out of memory\n");
kfree(phyinfo); kfree(phyinfo);
goto out; goto out;
} }
......
...@@ -35,15 +35,12 @@ struct cflayer *cfctrl_create(void) ...@@ -35,15 +35,12 @@ struct cflayer *cfctrl_create(void)
{ {
struct dev_info dev_info; struct dev_info dev_info;
struct cfctrl *this = struct cfctrl *this =
kmalloc(sizeof(struct cfctrl), GFP_ATOMIC); kzalloc(sizeof(struct cfctrl), GFP_ATOMIC);
if (!this) { if (!this)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfctrl, serv.layer) == 0); caif_assert(offsetof(struct cfctrl, serv.layer) == 0);
memset(&dev_info, 0, sizeof(dev_info)); memset(&dev_info, 0, sizeof(dev_info));
dev_info.id = 0xff; dev_info.id = 0xff;
memset(this, 0, sizeof(*this));
cfsrvl_init(&this->serv, 0, &dev_info, false); cfsrvl_init(&this->serv, 0, &dev_info, false);
atomic_set(&this->req_seq_no, 1); atomic_set(&this->req_seq_no, 1);
atomic_set(&this->rsp_seq_no, 1); atomic_set(&this->rsp_seq_no, 1);
...@@ -180,10 +177,8 @@ void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid) ...@@ -180,10 +177,8 @@ void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid)
struct cfctrl *cfctrl = container_obj(layer); struct cfctrl *cfctrl = container_obj(layer);
struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
struct cflayer *dn = cfctrl->serv.layer.dn; struct cflayer *dn = cfctrl->serv.layer.dn;
if (!pkt) { if (!pkt)
pr_warn("Out of memory\n");
return; return;
}
if (!dn) { if (!dn) {
pr_debug("not able to send enum request\n"); pr_debug("not able to send enum request\n");
return; return;
...@@ -224,10 +219,8 @@ int cfctrl_linkup_request(struct cflayer *layer, ...@@ -224,10 +219,8 @@ int cfctrl_linkup_request(struct cflayer *layer,
} }
pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
if (!pkt) { if (!pkt)
pr_warn("Out of memory\n");
return -ENOMEM; return -ENOMEM;
}
cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_SETUP); cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_SETUP);
cfpkt_addbdy(pkt, (param->chtype << 4) | param->linktype); cfpkt_addbdy(pkt, (param->chtype << 4) | param->linktype);
cfpkt_addbdy(pkt, (param->priority << 3) | param->phyid); cfpkt_addbdy(pkt, (param->priority << 3) | param->phyid);
...@@ -275,10 +268,8 @@ int cfctrl_linkup_request(struct cflayer *layer, ...@@ -275,10 +268,8 @@ int cfctrl_linkup_request(struct cflayer *layer,
return -EINVAL; return -EINVAL;
} }
req = kzalloc(sizeof(*req), GFP_KERNEL); req = kzalloc(sizeof(*req), GFP_KERNEL);
if (!req) { if (!req)
pr_warn("Out of memory\n");
return -ENOMEM; return -ENOMEM;
}
req->client_layer = user_layer; req->client_layer = user_layer;
req->cmd = CFCTRL_CMD_LINK_SETUP; req->cmd = CFCTRL_CMD_LINK_SETUP;
req->param = *param; req->param = *param;
...@@ -312,10 +303,8 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid, ...@@ -312,10 +303,8 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid,
struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
struct cflayer *dn = cfctrl->serv.layer.dn; struct cflayer *dn = cfctrl->serv.layer.dn;
if (!pkt) { if (!pkt)
pr_warn("Out of memory\n");
return -ENOMEM; return -ENOMEM;
}
if (!dn) { if (!dn) {
pr_debug("not able to send link-down request\n"); pr_debug("not able to send link-down request\n");
......
...@@ -19,13 +19,10 @@ static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt); ...@@ -19,13 +19,10 @@ static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info) struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
{ {
struct cfsrvl *dbg = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); struct cfsrvl *dbg = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
if (!dbg) { if (!dbg)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(dbg, 0, sizeof(struct cfsrvl));
cfsrvl_init(dbg, channel_id, dev_info, false); cfsrvl_init(dbg, channel_id, dev_info, false);
dbg->layer.receive = cfdbgl_receive; dbg->layer.receive = cfdbgl_receive;
dbg->layer.transmit = cfdbgl_transmit; dbg->layer.transmit = cfdbgl_transmit;
......
...@@ -26,13 +26,10 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt); ...@@ -26,13 +26,10 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info) struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
{ {
struct cfsrvl *dgm = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); struct cfsrvl *dgm = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
if (!dgm) { if (!dgm)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(dgm, 0, sizeof(struct cfsrvl));
cfsrvl_init(dgm, channel_id, dev_info, true); cfsrvl_init(dgm, channel_id, dev_info, true);
dgm->layer.receive = cfdgml_receive; dgm->layer.receive = cfdgml_receive;
dgm->layer.transmit = cfdgml_transmit; dgm->layer.transmit = cfdgml_transmit;
......
...@@ -34,11 +34,9 @@ static u32 cffrml_rcv_error; ...@@ -34,11 +34,9 @@ static u32 cffrml_rcv_error;
static u32 cffrml_rcv_checsum_error; static u32 cffrml_rcv_checsum_error;
struct cflayer *cffrml_create(u16 phyid, bool use_fcs) struct cflayer *cffrml_create(u16 phyid, bool use_fcs)
{ {
struct cffrml *this = kmalloc(sizeof(struct cffrml), GFP_ATOMIC); struct cffrml *this = kzalloc(sizeof(struct cffrml), GFP_ATOMIC);
if (!this) { if (!this)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
this->pcpu_refcnt = alloc_percpu(int); this->pcpu_refcnt = alloc_percpu(int);
if (this->pcpu_refcnt == NULL) { if (this->pcpu_refcnt == NULL) {
kfree(this); kfree(this);
...@@ -47,7 +45,6 @@ struct cflayer *cffrml_create(u16 phyid, bool use_fcs) ...@@ -47,7 +45,6 @@ struct cflayer *cffrml_create(u16 phyid, bool use_fcs)
caif_assert(offsetof(struct cffrml, layer) == 0); caif_assert(offsetof(struct cffrml, layer) == 0);
memset(this, 0, sizeof(struct cflayer));
this->layer.receive = cffrml_receive; this->layer.receive = cffrml_receive;
this->layer.transmit = cffrml_transmit; this->layer.transmit = cffrml_transmit;
this->layer.ctrlcmd = cffrml_ctrlcmd; this->layer.ctrlcmd = cffrml_ctrlcmd;
......
...@@ -46,13 +46,10 @@ struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info, ...@@ -46,13 +46,10 @@ struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info,
int mtu_size) int mtu_size)
{ {
int tmp; int tmp;
struct cfrfml *this = struct cfrfml *this = kzalloc(sizeof(struct cfrfml), GFP_ATOMIC);
kzalloc(sizeof(struct cfrfml), GFP_ATOMIC);
if (!this) { if (!this)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
cfsrvl_init(&this->serv, channel_id, dev_info, false); cfsrvl_init(&this->serv, channel_id, dev_info, false);
this->serv.release = cfrfml_release; this->serv.release = cfrfml_release;
......
...@@ -33,13 +33,10 @@ static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, ...@@ -33,13 +33,10 @@ static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
struct cflayer *cfserl_create(int type, int instance, bool use_stx) struct cflayer *cfserl_create(int type, int instance, bool use_stx)
{ {
struct cfserl *this = kmalloc(sizeof(struct cfserl), GFP_ATOMIC); struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
if (!this) { if (!this)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfserl, layer) == 0); caif_assert(offsetof(struct cfserl, layer) == 0);
memset(this, 0, sizeof(struct cfserl));
this->layer.receive = cfserl_receive; this->layer.receive = cfserl_receive;
this->layer.transmit = cfserl_transmit; this->layer.transmit = cfserl_transmit;
this->layer.ctrlcmd = cfserl_ctrlcmd; this->layer.ctrlcmd = cfserl_ctrlcmd;
......
...@@ -108,10 +108,8 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) ...@@ -108,10 +108,8 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
struct caif_payload_info *info; struct caif_payload_info *info;
u8 flow_on = SRVL_FLOW_ON; u8 flow_on = SRVL_FLOW_ON;
pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE); pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE);
if (!pkt) { if (!pkt)
pr_warn("Out of memory\n");
return -ENOMEM; return -ENOMEM;
}
if (cfpkt_add_head(pkt, &flow_on, 1) < 0) { if (cfpkt_add_head(pkt, &flow_on, 1) < 0) {
pr_err("Packet is erroneous!\n"); pr_err("Packet is erroneous!\n");
...@@ -130,10 +128,8 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) ...@@ -130,10 +128,8 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
struct caif_payload_info *info; struct caif_payload_info *info;
u8 flow_off = SRVL_FLOW_OFF; u8 flow_off = SRVL_FLOW_OFF;
pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE); pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE);
if (!pkt) { if (!pkt)
pr_warn("Out of memory\n");
return -ENOMEM; return -ENOMEM;
}
if (cfpkt_add_head(pkt, &flow_off, 1) < 0) { if (cfpkt_add_head(pkt, &flow_off, 1) < 0) {
pr_err("Packet is erroneous!\n"); pr_err("Packet is erroneous!\n");
......
...@@ -26,13 +26,10 @@ static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt); ...@@ -26,13 +26,10 @@ static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info) struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
{ {
struct cfsrvl *util = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); struct cfsrvl *util = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
if (!util) { if (!util)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(util, 0, sizeof(struct cfsrvl));
cfsrvl_init(util, channel_id, dev_info, true); cfsrvl_init(util, channel_id, dev_info, true);
util->layer.receive = cfutill_receive; util->layer.receive = cfutill_receive;
util->layer.transmit = cfutill_transmit; util->layer.transmit = cfutill_transmit;
......
...@@ -25,13 +25,10 @@ static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt); ...@@ -25,13 +25,10 @@ static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info) struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
{ {
struct cfsrvl *vei = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); struct cfsrvl *vei = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
if (!vei) { if (!vei)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(vei, 0, sizeof(struct cfsrvl));
cfsrvl_init(vei, channel_id, dev_info, true); cfsrvl_init(vei, channel_id, dev_info, true);
vei->layer.receive = cfvei_receive; vei->layer.receive = cfvei_receive;
vei->layer.transmit = cfvei_transmit; vei->layer.transmit = cfvei_transmit;
......
...@@ -21,14 +21,11 @@ static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt); ...@@ -21,14 +21,11 @@ static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info) struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
{ {
struct cfsrvl *vid = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); struct cfsrvl *vid = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
if (!vid) { if (!vid)
pr_warn("Out of memory\n");
return NULL; return NULL;
}
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(vid, 0, sizeof(struct cfsrvl));
cfsrvl_init(vid, channel_id, dev_info, false); cfsrvl_init(vid, channel_id, dev_info, false);
vid->layer.receive = cfvidl_receive; vid->layer.receive = cfvidl_receive;
vid->layer.transmit = cfvidl_transmit; vid->layer.transmit = cfvidl_transmit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment