staging: cxt1e1: replace kmalloc/kfree with OS_kmalloc/OS_kfree
PATCH 1/1 staging: cxt1e1: replace kmalloc/kfree with OS_kmalloc/OS_kfree
Replace kmalloc/kfree with OS_kmalloc/OS_kfree. And also some allocation doesn't need to use GFP_DMA so just use GFP_KERNEL.
c4_new() function is never called, remove it.
---
I'm not sure what GFP_DMA use correctly for km{,z}alloc(). Please review this.
And this patch has coding style issues. coding style issues will be fixed with another one.
drivers/staging/cxt1e1/hwprobe.c | 2 +- drivers/staging/cxt1e1/linux.c | 21 +++++------ drivers/staging/cxt1e1/musycc.c | 12 ++++--- drivers/staging/cxt1e1/pmcc4_drv.c | 47 +++++--------------------- drivers/staging/cxt1e1/sbecom_inline_linux.h | 23 +------------ drivers/staging/cxt1e1/sbecrc.c | 5 ++- drivers/staging/cxt1e1/sbeproc.c | 2 +- 7 files changed, 32 insertions(+), 80 deletions(-)
drivers/staging/cxt1e1/hwprobe.c +1 -1
@@ -205,7 +205,7 @@ cleanup_devs(void)#ifdef CONFIG_SBE_PMCC4_NCOMM free_irq (hi->pdev[1 ]->irq, hi->ndev);#endif -OS_kfree (hi->ndev); +kfree (hi->ndev); } }
drivers/staging/cxt1e1/linux.c +10 -11
@@ -60,7 +60,6 @@ status_t c4_chan_work_init(mpi_t *, mch_t *);void musycc_wq_chan_restart (void *);status_t __init c4_init (ci_t *,u_char *,u_char *);status_t __init c4_init2 (ci_t *); -ci_t *__init c4_new (void *);int __init c4hw_attach_all (void );void __init hdw_sn_get (hdw_info_t *,int );
@@ -418,7 +417,7 @@ create_chan(struct net_device *ndev, ci_t *ci,struct c4_priv *priv;/* allocate then fill in private data structure */ - priv =OS_kmalloc (sizeof (struct c4_priv )); + priv =kzalloc (sizeof (struct c4_priv ),GFP_KERNEL );if (!priv) {pr_warning ("%s: no memory for net_device !\n" , ci->devname);
@@ -428,7 +427,7 @@ create_chan(struct net_device *ndev, ci_t *ci,if (!dev) {pr_warning ("%s: no memory for hdlc_device !\n" , ci->devname); -OS_kfree (priv); +kfree (priv);return NULL ; } priv->ci = ci;
@@ -972,8 +971,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,if (register_netdev (ndev) || (c4_init (ci, (u_char *) f0, (u_char *) f1) !=SBE_DRVR_SUCCESS )) { -OS_kfree (netdev_priv (ndev)); -OS_kfree (ndev); +kfree (netdev_priv (ndev)); +kfree (ndev); error_flag = -ENODEV ;return NULL ; }
@@ -998,8 +997,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,pr_warning ("%s: MUSYCC could not get irq: %d\n" , ndev->name, irq0);unregister_netdev (ndev); -OS_kfree (netdev_priv (ndev)); -OS_kfree (ndev); +kfree (netdev_priv (ndev)); +kfree (ndev); error_flag = -EIO ;return NULL ; }
@@ -1008,8 +1007,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,pr_warning ("%s: EBUS could not get irq: %d\n" , hi->devname, irq1);unregister_netdev (ndev);free_irq (irq0, ndev); -OS_kfree (netdev_priv (ndev)); -OS_kfree (ndev); +kfree (netdev_priv (ndev)); +kfree (ndev); error_flag = -EIO ;return NULL ; }
@@ -1068,8 +1067,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,unregister_netdev (ndev);free_irq (irq1, ndev);free_irq (irq0, ndev); -OS_kfree (netdev_priv (ndev)); -OS_kfree (ndev); +kfree (netdev_priv (ndev)); +kfree (ndev);/* failure, error_flag is set */ return NULL ; }
drivers/staging/cxt1e1/musycc.c +7 -5
@@ -744,7 +744,8 @@ musycc_init(ci_t *ci)#define INT_QUEUE_BOUNDARY 4 - regaddr =OS_kmalloc ((INT_QUEUE_SIZE +1 ) *sizeof (u_int32_t)); + regaddr =kmalloc ((INT_QUEUE_SIZE +1 ) *sizeof (u_int32_t), +GFP_KERNEL |GFP_DMA );if (!regaddr)return -ENOMEM ; ci->iqd_p_saved = regaddr;/* save orig value for free's usage */
@@ -765,11 +766,12 @@ musycc_init(ci_t *ci)#define GROUP_BOUNDARY 0x800 - regaddr =OS_kmalloc (sizeof (struct musycc_groupr ) +GROUP_BOUNDARY ); + regaddr =kmalloc (sizeof (struct musycc_groupr ) +GROUP_BOUNDARY , +GFP_KERNEL |GFP_DMA );if (!regaddr) {for (gchan =0 ; gchan < i; gchan++) { pi = &ci->port[gchan]; -OS_kfree (pi->reg); +kfree (pi->reg); pi->reg =NULL ; }return -ENOMEM ;
@@ -1576,10 +1578,10 @@ musycc_chan_down(ci_t *dummy, int channum)if (ch->mdr[i].mem_token)OS_mem_token_free (ch->mdr[i].mem_token); -OS_kfree (ch->mdr); +kfree (ch->mdr); ch->mdr =NULL ; ch->rxd_num =0 ; -OS_kfree (ch->mdt); +kfree (ch->mdt); ch->mdt =NULL ; ch->txd_num =0 ;
drivers/staging/cxt1e1/pmcc4_drv.c +9 -38
81 lines not on this page · raw message
drivers/staging/cxt1e1/sbecom_inline_linux.h +1 -22
@@ -39,27 +39,6 @@ void pci_write_32 (u_int32_t *p, u_int32_t v);* system dependent callbacks */ -/**********/ -/* malloc */ -/**********/ - -static inline void * -OS_kmalloc (size_t size) -{ -char *ptr =kmalloc (size,GFP_KERNEL |GFP_DMA ); - -if (ptr) -memset (ptr,0 , size); -return ptr; -} - -static inline void -OS_kfree (void *x) -{ -kfree (x); -} - -/****************/ /* memory token */ /****************/
@@ -197,7 +176,7 @@ static inline int OS_free_watchdog (struct watchdog *wd) {OS_stop_watchdog (wd); -OS_kfree (wd); +kfree (wd);return 0 ; }
drivers/staging/cxt1e1/sbecrc.c +3 -2
@@ -101,7 +101,8 @@ sbeCrc(u_int8_t *buffer, /* data buffer to crc */ tbl = &CRCTable;genCrcTable (tbl);#else - tbl = (u_int32_t *)OS_kmalloc (CRC_TABLE_ENTRIES *sizeof (u_int32_t)); + tbl =kmalloc (CRC_TABLE_ENTRIES *sizeof (u_int32_t), +GFP_KERNEL );if (!tbl) { *result =0 ;/* dummy up return value due to malloc * failure */
@@ -125,7 +126,7 @@ sbeCrc(u_int8_t *buffer, /* data buffer to crc */#ifndef STATIC_CRC_TABLE crcTableInit =0 ; -OS_kfree (tbl); +kfree (tbl);#endif }
drivers/staging/cxt1e1/sbeproc.c +1 -1
@@ -72,7 +72,7 @@ static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v)char *spd;struct sbe_brd_info *bip; - bip =OS_kmalloc (sizeof (struct sbe_brd_info )); + bip =kzalloc (sizeof (struct sbe_brd_info ),GFP_KERNEL |GFP_DMA );if (!bip)return -ENOMEM ;
Signature · 1 line
1.7.4.4
Greg KH
maintainerQuoted 2 lines · Daeseok Youn
Replace kmalloc/kfree with OS_kmalloc/OS_kfree.
I think you mean this the other way around, right?
Yes. It was already noticed by Joe Perches.
I will send it again.
Thanks.
Daeseok Youn.
2014-03-21 11:35 GMT+09:00, Greg KH <[email protected]>:
Quoted 7 lines · Daeseok Youn
Quoted 2 lines
Replace kmalloc/kfree with OS_kmalloc/OS_kfree.
I think you mean this the other way around, right?