aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethoc.c')
-rw-r--r--drivers/net/ethoc.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 34d0c69e67f7..f7d9ac8324cb 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -17,6 +17,7 @@
17#include <linux/mii.h> 17#include <linux/mii.h>
18#include <linux/phy.h> 18#include <linux/phy.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/sched.h>
20#include <net/ethoc.h> 21#include <net/ethoc.h>
21 22
22static int buffer_size = 0x8000; /* 32 KBytes */ 23static int buffer_size = 0x8000; /* 32 KBytes */
@@ -222,24 +223,25 @@ struct ethoc_bd {
222 u32 addr; 223 u32 addr;
223}; 224};
224 225
225static u32 ethoc_read(struct ethoc *dev, loff_t offset) 226static inline u32 ethoc_read(struct ethoc *dev, loff_t offset)
226{ 227{
227 return ioread32(dev->iobase + offset); 228 return ioread32(dev->iobase + offset);
228} 229}
229 230
230static void ethoc_write(struct ethoc *dev, loff_t offset, u32 data) 231static inline void ethoc_write(struct ethoc *dev, loff_t offset, u32 data)
231{ 232{
232 iowrite32(data, dev->iobase + offset); 233 iowrite32(data, dev->iobase + offset);
233} 234}
234 235
235static void ethoc_read_bd(struct ethoc *dev, int index, struct ethoc_bd *bd) 236static inline void ethoc_read_bd(struct ethoc *dev, int index,
237 struct ethoc_bd *bd)
236{ 238{
237 loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd)); 239 loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd));
238 bd->stat = ethoc_read(dev, offset + 0); 240 bd->stat = ethoc_read(dev, offset + 0);
239 bd->addr = ethoc_read(dev, offset + 4); 241 bd->addr = ethoc_read(dev, offset + 4);
240} 242}
241 243
242static void ethoc_write_bd(struct ethoc *dev, int index, 244static inline void ethoc_write_bd(struct ethoc *dev, int index,
243 const struct ethoc_bd *bd) 245 const struct ethoc_bd *bd)
244{ 246{
245 loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd)); 247 loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd));
@@ -247,33 +249,33 @@ static void ethoc_write_bd(struct ethoc *dev, int index,
247 ethoc_write(dev, offset + 4, bd->addr); 249 ethoc_write(dev, offset + 4, bd->addr);
248} 250}
249 251
250static void ethoc_enable_irq(struct ethoc *dev, u32 mask) 252static inline void ethoc_enable_irq(struct ethoc *dev, u32 mask)
251{ 253{
252 u32 imask = ethoc_read(dev, INT_MASK); 254 u32 imask = ethoc_read(dev, INT_MASK);
253 imask |= mask; 255 imask |= mask;
254 ethoc_write(dev, INT_MASK, imask); 256 ethoc_write(dev, INT_MASK, imask);
255} 257}
256 258
257static void ethoc_disable_irq(struct ethoc *dev, u32 mask) 259static inline void ethoc_disable_irq(struct ethoc *dev, u32 mask)
258{ 260{
259 u32 imask = ethoc_read(dev, INT_MASK); 261 u32 imask = ethoc_read(dev, INT_MASK);
260 imask &= ~mask; 262 imask &= ~mask;
261 ethoc_write(dev, INT_MASK, imask); 263 ethoc_write(dev, INT_MASK, imask);
262} 264}
263 265
264static void ethoc_ack_irq(struct ethoc *dev, u32 mask) 266static inline void ethoc_ack_irq(struct ethoc *dev, u32 mask)
265{ 267{
266 ethoc_write(dev, INT_SOURCE, mask); 268 ethoc_write(dev, INT_SOURCE, mask);
267} 269}
268 270
269static void ethoc_enable_rx_and_tx(struct ethoc *dev) 271static inline void ethoc_enable_rx_and_tx(struct ethoc *dev)
270{ 272{
271 u32 mode = ethoc_read(dev, MODER); 273 u32 mode = ethoc_read(dev, MODER);
272 mode |= MODER_RXEN | MODER_TXEN; 274 mode |= MODER_RXEN | MODER_TXEN;
273 ethoc_write(dev, MODER, mode); 275 ethoc_write(dev, MODER, mode);
274} 276}
275 277
276static void ethoc_disable_rx_and_tx(struct ethoc *dev) 278static inline void ethoc_disable_rx_and_tx(struct ethoc *dev)
277{ 279{
278 u32 mode = ethoc_read(dev, MODER); 280 u32 mode = ethoc_read(dev, MODER);
279 mode &= ~(MODER_RXEN | MODER_TXEN); 281 mode &= ~(MODER_RXEN | MODER_TXEN);
@@ -507,7 +509,7 @@ static irqreturn_t ethoc_interrupt(int irq, void *dev_id)
507 return IRQ_NONE; 509 return IRQ_NONE;
508 } 510 }
509 511
510 ethoc_ack_irq(priv, INT_MASK_ALL); 512 ethoc_ack_irq(priv, pending);
511 513
512 if (pending & INT_MASK_BUSY) { 514 if (pending & INT_MASK_BUSY) {
513 dev_err(&dev->dev, "packet dropped\n"); 515 dev_err(&dev->dev, "packet dropped\n");
@@ -663,7 +665,8 @@ static int ethoc_open(struct net_device *dev)
663 return ret; 665 return ret;
664 666
665 /* calculate the number of TX/RX buffers, maximum 128 supported */ 667 /* calculate the number of TX/RX buffers, maximum 128 supported */
666 num_bd = min(128, (dev->mem_end - dev->mem_start + 1) / ETHOC_BUFSIZ); 668 num_bd = min_t(unsigned int,
669 128, (dev->mem_end - dev->mem_start + 1) / ETHOC_BUFSIZ);
667 priv->num_tx = max(min_tx, num_bd / 4); 670 priv->num_tx = max(min_tx, num_bd / 4);
668 priv->num_rx = num_bd - priv->num_tx; 671 priv->num_rx = num_bd - priv->num_tx;
669 ethoc_write(priv, TX_BD_NUM, priv->num_tx); 672 ethoc_write(priv, TX_BD_NUM, priv->num_tx);