aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2006-12-19 22:36:32 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-22 14:12:00 -0500
commit1f8a5fb80e63aab63de81169ab749d73e7509e3f (patch)
tree82119a1ab1214345df41f7d0af3b94033638417f /drivers/atm
parent52a91071306c3b129efa6ea2bfe16244b8619cd9 (diff)
[ATM] drivers/atm/fore200e.c: Cleanups.
This patch contains the following transformations from custom functions to standard kernel version: - fore200e_kmalloc() -> kzalloc() - fore200e_kfree() -> kfree() - fore200e_swap() -> cpu_to_be32() Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm')
-rw-r--r--drivers/atm/fore200e.c166
1 files changed, 68 insertions, 98 deletions
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 3a7b21ff30a5..4aeb3d062ff6 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -172,25 +172,6 @@ fore200e_irq_itoa(int irq)
172} 172}
173 173
174 174
175static void*
176fore200e_kmalloc(int size, gfp_t flags)
177{
178 void *chunk = kzalloc(size, flags);
179
180 if (!chunk)
181 printk(FORE200E "kmalloc() failed, requested size = %d, flags = 0x%x\n", size, flags);
182
183 return chunk;
184}
185
186
187static void
188fore200e_kfree(void* chunk)
189{
190 kfree(chunk);
191}
192
193
194/* allocate and align a chunk of memory intended to hold the data behing exchanged 175/* allocate and align a chunk of memory intended to hold the data behing exchanged
195 between the driver and the adapter (using streaming DVMA) */ 176 between the driver and the adapter (using streaming DVMA) */
196 177
@@ -206,7 +187,7 @@ fore200e_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, int size, i
206 chunk->align_size = size; 187 chunk->align_size = size;
207 chunk->direction = direction; 188 chunk->direction = direction;
208 189
209 chunk->alloc_addr = fore200e_kmalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA); 190 chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA);
210 if (chunk->alloc_addr == NULL) 191 if (chunk->alloc_addr == NULL)
211 return -ENOMEM; 192 return -ENOMEM;
212 193
@@ -228,7 +209,7 @@ fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk)
228{ 209{
229 fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction); 210 fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction);
230 211
231 fore200e_kfree(chunk->alloc_addr); 212 kfree(chunk->alloc_addr);
232} 213}
233 214
234 215
@@ -882,7 +863,7 @@ fore200e_sba_detect(const struct fore200e_bus* bus, int index)
882 return NULL; 863 return NULL;
883 } 864 }
884 865
885 fore200e = fore200e_kmalloc(sizeof(struct fore200e), GFP_KERNEL); 866 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL);
886 if (fore200e == NULL) 867 if (fore200e == NULL)
887 return NULL; 868 return NULL;
888 869
@@ -1505,7 +1486,7 @@ fore200e_open(struct atm_vcc *vcc)
1505 1486
1506 spin_unlock_irqrestore(&fore200e->q_lock, flags); 1487 spin_unlock_irqrestore(&fore200e->q_lock, flags);
1507 1488
1508 fore200e_vcc = fore200e_kmalloc(sizeof(struct fore200e_vcc), GFP_ATOMIC); 1489 fore200e_vcc = kzalloc(sizeof(struct fore200e_vcc), GFP_ATOMIC);
1509 if (fore200e_vcc == NULL) { 1490 if (fore200e_vcc == NULL) {
1510 vc_map->vcc = NULL; 1491 vc_map->vcc = NULL;
1511 return -ENOMEM; 1492 return -ENOMEM;
@@ -1526,7 +1507,7 @@ fore200e_open(struct atm_vcc *vcc)
1526 if (fore200e->available_cell_rate < vcc->qos.txtp.max_pcr) { 1507 if (fore200e->available_cell_rate < vcc->qos.txtp.max_pcr) {
1527 up(&fore200e->rate_sf); 1508 up(&fore200e->rate_sf);
1528 1509
1529 fore200e_kfree(fore200e_vcc); 1510 kfree(fore200e_vcc);
1530 vc_map->vcc = NULL; 1511 vc_map->vcc = NULL;
1531 return -EAGAIN; 1512 return -EAGAIN;
1532 } 1513 }
@@ -1554,7 +1535,7 @@ fore200e_open(struct atm_vcc *vcc)
1554 1535
1555 fore200e->available_cell_rate += vcc->qos.txtp.max_pcr; 1536 fore200e->available_cell_rate += vcc->qos.txtp.max_pcr;
1556 1537
1557 fore200e_kfree(fore200e_vcc); 1538 kfree(fore200e_vcc);
1558 return -EINVAL; 1539 return -EINVAL;
1559 } 1540 }
1560 1541
@@ -1630,7 +1611,7 @@ fore200e_close(struct atm_vcc* vcc)
1630 clear_bit(ATM_VF_PARTIAL,&vcc->flags); 1611 clear_bit(ATM_VF_PARTIAL,&vcc->flags);
1631 1612
1632 ASSERT(fore200e_vcc); 1613 ASSERT(fore200e_vcc);
1633 fore200e_kfree(fore200e_vcc); 1614 kfree(fore200e_vcc);
1634} 1615}
1635 1616
1636 1617
@@ -1831,7 +1812,7 @@ fore200e_getstats(struct fore200e* fore200e)
1831 u32 stats_dma_addr; 1812 u32 stats_dma_addr;
1832 1813
1833 if (fore200e->stats == NULL) { 1814 if (fore200e->stats == NULL) {
1834 fore200e->stats = fore200e_kmalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA); 1815 fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA);
1835 if (fore200e->stats == NULL) 1816 if (fore200e->stats == NULL)
1836 return -ENOMEM; 1817 return -ENOMEM;
1837 } 1818 }
@@ -2002,17 +1983,6 @@ fore200e_setloop(struct fore200e* fore200e, int loop_mode)
2002} 1983}
2003 1984
2004 1985
2005static inline unsigned int
2006fore200e_swap(unsigned int in)
2007{
2008#if defined(__LITTLE_ENDIAN)
2009 return swab32(in);
2010#else
2011 return in;
2012#endif
2013}
2014
2015
2016static int 1986static int
2017fore200e_fetch_stats(struct fore200e* fore200e, struct sonet_stats __user *arg) 1987fore200e_fetch_stats(struct fore200e* fore200e, struct sonet_stats __user *arg)
2018{ 1988{
@@ -2021,19 +1991,19 @@ fore200e_fetch_stats(struct fore200e* fore200e, struct sonet_stats __user *arg)
2021 if (fore200e_getstats(fore200e) < 0) 1991 if (fore200e_getstats(fore200e) < 0)
2022 return -EIO; 1992 return -EIO;
2023 1993
2024 tmp.section_bip = fore200e_swap(fore200e->stats->oc3.section_bip8_errors); 1994 tmp.section_bip = cpu_to_be32(fore200e->stats->oc3.section_bip8_errors);
2025 tmp.line_bip = fore200e_swap(fore200e->stats->oc3.line_bip24_errors); 1995 tmp.line_bip = cpu_to_be32(fore200e->stats->oc3.line_bip24_errors);
2026 tmp.path_bip = fore200e_swap(fore200e->stats->oc3.path_bip8_errors); 1996 tmp.path_bip = cpu_to_be32(fore200e->stats->oc3.path_bip8_errors);
2027 tmp.line_febe = fore200e_swap(fore200e->stats->oc3.line_febe_errors); 1997 tmp.line_febe = cpu_to_be32(fore200e->stats->oc3.line_febe_errors);
2028 tmp.path_febe = fore200e_swap(fore200e->stats->oc3.path_febe_errors); 1998 tmp.path_febe = cpu_to_be32(fore200e->stats->oc3.path_febe_errors);
2029 tmp.corr_hcs = fore200e_swap(fore200e->stats->oc3.corr_hcs_errors); 1999 tmp.corr_hcs = cpu_to_be32(fore200e->stats->oc3.corr_hcs_errors);
2030 tmp.uncorr_hcs = fore200e_swap(fore200e->stats->oc3.ucorr_hcs_errors); 2000 tmp.uncorr_hcs = cpu_to_be32(fore200e->stats->oc3.ucorr_hcs_errors);
2031 tmp.tx_cells = fore200e_swap(fore200e->stats->aal0.cells_transmitted) + 2001 tmp.tx_cells = cpu_to_be32(fore200e->stats->aal0.cells_transmitted) +
2032 fore200e_swap(fore200e->stats->aal34.cells_transmitted) + 2002 cpu_to_be32(fore200e->stats->aal34.cells_transmitted) +
2033 fore200e_swap(fore200e->stats->aal5.cells_transmitted); 2003 cpu_to_be32(fore200e->stats->aal5.cells_transmitted);
2034 tmp.rx_cells = fore200e_swap(fore200e->stats->aal0.cells_received) + 2004 tmp.rx_cells = cpu_to_be32(fore200e->stats->aal0.cells_received) +
2035 fore200e_swap(fore200e->stats->aal34.cells_received) + 2005 cpu_to_be32(fore200e->stats->aal34.cells_received) +
2036 fore200e_swap(fore200e->stats->aal5.cells_received); 2006 cpu_to_be32(fore200e->stats->aal5.cells_received);
2037 2007
2038 if (arg) 2008 if (arg)
2039 return copy_to_user(arg, &tmp, sizeof(struct sonet_stats)) ? -EFAULT : 0; 2009 return copy_to_user(arg, &tmp, sizeof(struct sonet_stats)) ? -EFAULT : 0;
@@ -2146,7 +2116,7 @@ fore200e_irq_request(struct fore200e* fore200e)
2146static int __devinit 2116static int __devinit
2147fore200e_get_esi(struct fore200e* fore200e) 2117fore200e_get_esi(struct fore200e* fore200e)
2148{ 2118{
2149 struct prom_data* prom = fore200e_kmalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA); 2119 struct prom_data* prom = kzalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA);
2150 int ok, i; 2120 int ok, i;
2151 2121
2152 if (!prom) 2122 if (!prom)
@@ -2154,7 +2124,7 @@ fore200e_get_esi(struct fore200e* fore200e)
2154 2124
2155 ok = fore200e->bus->prom_read(fore200e, prom); 2125 ok = fore200e->bus->prom_read(fore200e, prom);
2156 if (ok < 0) { 2126 if (ok < 0) {
2157 fore200e_kfree(prom); 2127 kfree(prom);
2158 return -EBUSY; 2128 return -EBUSY;
2159 } 2129 }
2160 2130
@@ -2169,7 +2139,7 @@ fore200e_get_esi(struct fore200e* fore200e)
2169 fore200e->esi[ i ] = fore200e->atm_dev->esi[ i ] = prom->mac_addr[ i + 2 ]; 2139 fore200e->esi[ i ] = fore200e->atm_dev->esi[ i ] = prom->mac_addr[ i + 2 ];
2170 } 2140 }
2171 2141
2172 fore200e_kfree(prom); 2142 kfree(prom);
2173 2143
2174 return 0; 2144 return 0;
2175} 2145}
@@ -2194,7 +2164,7 @@ fore200e_alloc_rx_buf(struct fore200e* fore200e)
2194 DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn); 2164 DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn);
2195 2165
2196 /* allocate the array of receive buffers */ 2166 /* allocate the array of receive buffers */
2197 buffer = bsq->buffer = fore200e_kmalloc(nbr * sizeof(struct buffer), GFP_KERNEL); 2167 buffer = bsq->buffer = kzalloc(nbr * sizeof(struct buffer), GFP_KERNEL);
2198 2168
2199 if (buffer == NULL) 2169 if (buffer == NULL)
2200 return -ENOMEM; 2170 return -ENOMEM;
@@ -2217,7 +2187,7 @@ fore200e_alloc_rx_buf(struct fore200e* fore200e)
2217 2187
2218 while (i > 0) 2188 while (i > 0)
2219 fore200e_chunk_free(fore200e, &buffer[ --i ].data); 2189 fore200e_chunk_free(fore200e, &buffer[ --i ].data);
2220 fore200e_kfree(buffer); 2190 kfree(buffer);
2221 2191
2222 return -ENOMEM; 2192 return -ENOMEM;
2223 } 2193 }
@@ -2736,7 +2706,7 @@ fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent
2736 goto out; 2706 goto out;
2737 } 2707 }
2738 2708
2739 fore200e = fore200e_kmalloc(sizeof(struct fore200e), GFP_KERNEL); 2709 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL);
2740 if (fore200e == NULL) { 2710 if (fore200e == NULL) {
2741 err = -ENOMEM; 2711 err = -ENOMEM;
2742 goto out_disable; 2712 goto out_disable;
@@ -2999,8 +2969,8 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
2999 " 4b5b:\n" 2969 " 4b5b:\n"
3000 " crc_header_errors:\t\t%10u\n" 2970 " crc_header_errors:\t\t%10u\n"
3001 " framing_errors:\t\t%10u\n", 2971 " framing_errors:\t\t%10u\n",
3002 fore200e_swap(fore200e->stats->phy.crc_header_errors), 2972 cpu_to_be32(fore200e->stats->phy.crc_header_errors),
3003 fore200e_swap(fore200e->stats->phy.framing_errors)); 2973 cpu_to_be32(fore200e->stats->phy.framing_errors));
3004 2974
3005 if (!left--) 2975 if (!left--)
3006 return sprintf(page, "\n" 2976 return sprintf(page, "\n"
@@ -3012,13 +2982,13 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
3012 " path_febe_errors:\t\t%10u\n" 2982 " path_febe_errors:\t\t%10u\n"
3013 " corr_hcs_errors:\t\t%10u\n" 2983 " corr_hcs_errors:\t\t%10u\n"
3014 " ucorr_hcs_errors:\t\t%10u\n", 2984 " ucorr_hcs_errors:\t\t%10u\n",
3015 fore200e_swap(fore200e->stats->oc3.section_bip8_errors), 2985 cpu_to_be32(fore200e->stats->oc3.section_bip8_errors),
3016 fore200e_swap(fore200e->stats->oc3.path_bip8_errors), 2986 cpu_to_be32(fore200e->stats->oc3.path_bip8_errors),
3017 fore200e_swap(fore200e->stats->oc3.line_bip24_errors), 2987 cpu_to_be32(fore200e->stats->oc3.line_bip24_errors),
3018 fore200e_swap(fore200e->stats->oc3.line_febe_errors), 2988 cpu_to_be32(fore200e->stats->oc3.line_febe_errors),
3019 fore200e_swap(fore200e->stats->oc3.path_febe_errors), 2989 cpu_to_be32(fore200e->stats->oc3.path_febe_errors),
3020 fore200e_swap(fore200e->stats->oc3.corr_hcs_errors), 2990 cpu_to_be32(fore200e->stats->oc3.corr_hcs_errors),
3021 fore200e_swap(fore200e->stats->oc3.ucorr_hcs_errors)); 2991 cpu_to_be32(fore200e->stats->oc3.ucorr_hcs_errors));
3022 2992
3023 if (!left--) 2993 if (!left--)
3024 return sprintf(page,"\n" 2994 return sprintf(page,"\n"
@@ -3029,12 +2999,12 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
3029 " vpi no conn:\t\t%10u\n" 2999 " vpi no conn:\t\t%10u\n"
3030 " vci out of range:\t\t%10u\n" 3000 " vci out of range:\t\t%10u\n"
3031 " vci no conn:\t\t%10u\n", 3001 " vci no conn:\t\t%10u\n",
3032 fore200e_swap(fore200e->stats->atm.cells_transmitted), 3002 cpu_to_be32(fore200e->stats->atm.cells_transmitted),
3033 fore200e_swap(fore200e->stats->atm.cells_received), 3003 cpu_to_be32(fore200e->stats->atm.cells_received),
3034 fore200e_swap(fore200e->stats->atm.vpi_bad_range), 3004 cpu_to_be32(fore200e->stats->atm.vpi_bad_range),
3035 fore200e_swap(fore200e->stats->atm.vpi_no_conn), 3005 cpu_to_be32(fore200e->stats->atm.vpi_no_conn),
3036 fore200e_swap(fore200e->stats->atm.vci_bad_range), 3006 cpu_to_be32(fore200e->stats->atm.vci_bad_range),
3037 fore200e_swap(fore200e->stats->atm.vci_no_conn)); 3007 cpu_to_be32(fore200e->stats->atm.vci_no_conn));
3038 3008
3039 if (!left--) 3009 if (!left--)
3040 return sprintf(page,"\n" 3010 return sprintf(page,"\n"
@@ -3042,9 +3012,9 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
3042 " TX:\t\t\t%10u\n" 3012 " TX:\t\t\t%10u\n"
3043 " RX:\t\t\t%10u\n" 3013 " RX:\t\t\t%10u\n"
3044 " dropped:\t\t\t%10u\n", 3014 " dropped:\t\t\t%10u\n",
3045 fore200e_swap(fore200e->stats->aal0.cells_transmitted), 3015 cpu_to_be32(fore200e->stats->aal0.cells_transmitted),
3046 fore200e_swap(fore200e->stats->aal0.cells_received), 3016 cpu_to_be32(fore200e->stats->aal0.cells_received),
3047 fore200e_swap(fore200e->stats->aal0.cells_dropped)); 3017 cpu_to_be32(fore200e->stats->aal0.cells_dropped));
3048 3018
3049 if (!left--) 3019 if (!left--)
3050 return sprintf(page,"\n" 3020 return sprintf(page,"\n"
@@ -3060,15 +3030,15 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
3060 " RX:\t\t\t%10u\n" 3030 " RX:\t\t\t%10u\n"
3061 " dropped:\t\t\t%10u\n" 3031 " dropped:\t\t\t%10u\n"
3062 " protocol errors:\t\t%10u\n", 3032 " protocol errors:\t\t%10u\n",
3063 fore200e_swap(fore200e->stats->aal34.cells_transmitted), 3033 cpu_to_be32(fore200e->stats->aal34.cells_transmitted),
3064 fore200e_swap(fore200e->stats->aal34.cells_received), 3034 cpu_to_be32(fore200e->stats->aal34.cells_received),
3065 fore200e_swap(fore200e->stats->aal34.cells_dropped), 3035 cpu_to_be32(fore200e->stats->aal34.cells_dropped),
3066 fore200e_swap(fore200e->stats->aal34.cells_crc_errors), 3036 cpu_to_be32(fore200e->stats->aal34.cells_crc_errors),
3067 fore200e_swap(fore200e->stats->aal34.cells_protocol_errors), 3037 cpu_to_be32(fore200e->stats->aal34.cells_protocol_errors),
3068 fore200e_swap(fore200e->stats->aal34.cspdus_transmitted), 3038 cpu_to_be32(fore200e->stats->aal34.cspdus_transmitted),
3069 fore200e_swap(fore200e->stats->aal34.cspdus_received), 3039 cpu_to_be32(fore200e->stats->aal34.cspdus_received),
3070 fore200e_swap(fore200e->stats->aal34.cspdus_dropped), 3040 cpu_to_be32(fore200e->stats->aal34.cspdus_dropped),
3071 fore200e_swap(fore200e->stats->aal34.cspdus_protocol_errors)); 3041 cpu_to_be32(fore200e->stats->aal34.cspdus_protocol_errors));
3072 3042
3073 if (!left--) 3043 if (!left--)
3074 return sprintf(page,"\n" 3044 return sprintf(page,"\n"
@@ -3084,15 +3054,15 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
3084 " dropped:\t\t\t%10u\n" 3054 " dropped:\t\t\t%10u\n"
3085 " CRC errors:\t\t%10u\n" 3055 " CRC errors:\t\t%10u\n"
3086 " protocol errors:\t\t%10u\n", 3056 " protocol errors:\t\t%10u\n",
3087 fore200e_swap(fore200e->stats->aal5.cells_transmitted), 3057 cpu_to_be32(fore200e->stats->aal5.cells_transmitted),
3088 fore200e_swap(fore200e->stats->aal5.cells_received), 3058 cpu_to_be32(fore200e->stats->aal5.cells_received),
3089 fore200e_swap(fore200e->stats->aal5.cells_dropped), 3059 cpu_to_be32(fore200e->stats->aal5.cells_dropped),
3090 fore200e_swap(fore200e->stats->aal5.congestion_experienced), 3060 cpu_to_be32(fore200e->stats->aal5.congestion_experienced),
3091 fore200e_swap(fore200e->stats->aal5.cspdus_transmitted), 3061 cpu_to_be32(fore200e->stats->aal5.cspdus_transmitted),
3092 fore200e_swap(fore200e->stats->aal5.cspdus_received), 3062 cpu_to_be32(fore200e->stats->aal5.cspdus_received),
3093 fore200e_swap(fore200e->stats->aal5.cspdus_dropped), 3063 cpu_to_be32(fore200e->stats->aal5.cspdus_dropped),
3094 fore200e_swap(fore200e->stats->aal5.cspdus_crc_errors), 3064 cpu_to_be32(fore200e->stats->aal5.cspdus_crc_errors),
3095 fore200e_swap(fore200e->stats->aal5.cspdus_protocol_errors)); 3065 cpu_to_be32(fore200e->stats->aal5.cspdus_protocol_errors));
3096 3066
3097 if (!left--) 3067 if (!left--)
3098 return sprintf(page,"\n" 3068 return sprintf(page,"\n"
@@ -3103,11 +3073,11 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
3103 " large b2:\t\t\t%10u\n" 3073 " large b2:\t\t\t%10u\n"
3104 " RX PDUs:\t\t\t%10u\n" 3074 " RX PDUs:\t\t\t%10u\n"
3105 " TX PDUs:\t\t\t%10lu\n", 3075 " TX PDUs:\t\t\t%10lu\n",
3106 fore200e_swap(fore200e->stats->aux.small_b1_failed), 3076 cpu_to_be32(fore200e->stats->aux.small_b1_failed),
3107 fore200e_swap(fore200e->stats->aux.large_b1_failed), 3077 cpu_to_be32(fore200e->stats->aux.large_b1_failed),
3108 fore200e_swap(fore200e->stats->aux.small_b2_failed), 3078 cpu_to_be32(fore200e->stats->aux.small_b2_failed),
3109 fore200e_swap(fore200e->stats->aux.large_b2_failed), 3079 cpu_to_be32(fore200e->stats->aux.large_b2_failed),
3110 fore200e_swap(fore200e->stats->aux.rpd_alloc_failed), 3080 cpu_to_be32(fore200e->stats->aux.rpd_alloc_failed),
3111 fore200e->tx_sat); 3081 fore200e->tx_sat);
3112 3082
3113 if (!left--) 3083 if (!left--)