forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/natsemi/xtsonic.c
....@@ -35,9 +35,9 @@
3535 #include <linux/platform_device.h>
3636 #include <linux/dma-mapping.h>
3737 #include <linux/slab.h>
38
+#include <linux/pgtable.h>
3839
3940 #include <asm/io.h>
40
-#include <asm/pgtable.h>
4141 #include <asm/dma.h>
4242
4343 static char xtsonic_string[] = "xtsonic";
....@@ -167,47 +167,11 @@
167167 dev->dev_addr[i*2+1] = val >> 8;
168168 }
169169
170
- /* Initialize the device structure. */
171
-
172170 lp->dma_bitmode = SONIC_BITMODE32;
173171
174
- /*
175
- * Allocate local private descriptor areas in uncached space.
176
- * The entire structure must be located within the same 64kb segment.
177
- * A simple way to ensure this is to allocate twice the
178
- * size of the structure -- given that the structure is
179
- * much less than 64 kB, at least one of the halves of
180
- * the allocated area will be contained entirely in 64 kB.
181
- * We also allocate extra space for a pointer to allow freeing
182
- * this structure later on (in xtsonic_cleanup_module()).
183
- */
184
- lp->descriptors = dma_alloc_coherent(lp->device,
185
- SIZEOF_SONIC_DESC *
186
- SONIC_BUS_SCALE(lp->dma_bitmode),
187
- &lp->descriptors_laddr,
188
- GFP_KERNEL);
189
- if (lp->descriptors == NULL) {
190
- err = -ENOMEM;
172
+ err = sonic_alloc_descriptors(dev);
173
+ if (err)
191174 goto out;
192
- }
193
-
194
- lp->cda = lp->descriptors;
195
- lp->tda = lp->cda + (SIZEOF_SONIC_CDA
196
- * SONIC_BUS_SCALE(lp->dma_bitmode));
197
- lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
198
- * SONIC_BUS_SCALE(lp->dma_bitmode));
199
- lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
200
- * SONIC_BUS_SCALE(lp->dma_bitmode));
201
-
202
- /* get the virtual dma address */
203
-
204
- lp->cda_laddr = lp->descriptors_laddr;
205
- lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA
206
- * SONIC_BUS_SCALE(lp->dma_bitmode));
207
- lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
208
- * SONIC_BUS_SCALE(lp->dma_bitmode));
209
- lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
210
- * SONIC_BUS_SCALE(lp->dma_bitmode));
211175
212176 dev->netdev_ops = &xtsonic_netdev_ops;
213177 dev->watchdog_timeo = TX_TIMEOUT;