Lines Matching defs:ks
56 #define to_ks8851_spi(ks) container_of((ks), struct ks8851_net_spi, ks8851)
73 * @ks: The chip state
78 static void ks8851_lock_spi(struct ks8851_net *ks, unsigned long *flags)
80 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
87 * @ks: The chip state
92 static void ks8851_unlock_spi(struct ks8851_net *ks, unsigned long *flags)
94 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
108 * @ks: The chip state
114 static void ks8851_wrreg16_spi(struct ks8851_net *ks, unsigned int reg,
117 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
132 netdev_err(ks->netdev, "spi_sync() failed\n");
137 * @ks: The device state
145 static void ks8851_rdreg(struct ks8851_net *ks, unsigned int op,
148 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
151 __le16 *txb = (__le16 *)ks->txd;
152 u8 *trx = ks->rxd;
180 netdev_err(ks->netdev, "read: spi_sync() failed\n");
189 * @ks: The chip information
194 static unsigned int ks8851_rdreg16_spi(struct ks8851_net *ks, unsigned int reg)
198 ks8851_rdreg(ks, MK_OP(reg & 2 ? 0xC : 0x3, reg), (u8 *)&rx, 2);
204 * @ks: The device state.
211 static void ks8851_rdfifo_spi(struct ks8851_net *ks, u8 *buff, unsigned int len)
213 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
219 netif_dbg(ks, rx_status, ks->netdev,
236 netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
241 * @ks: The device state.
250 static void ks8851_wrfifo_spi(struct ks8851_net *ks, struct sk_buff *txp,
253 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
259 netif_dbg(ks, tx_queued, ks->netdev, "%s: skb %p, %d@%p, irq %d\n",
262 fid = ks->fid++;
269 ks->txh.txb[1] = KS_SPIOP_TXFIFO;
270 ks->txh.txw[1] = cpu_to_le16(fid);
271 ks->txh.txw[2] = cpu_to_le16(txp->len);
273 xfer->tx_buf = &ks->txh.txb[1];
284 netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
311 struct ks8851_net *ks;
317 ks = &kss->ks8851;
318 last = skb_queue_empty(&ks->txq);
320 ks8851_lock_spi(ks, &flags);
323 txb = skb_dequeue(&ks->txq);
324 last = skb_queue_empty(&ks->txq);
329 ks8851_wrreg16_spi(ks, KS_RXQCR,
330 ks->rc_rxqcr | RXQCR_SDA);
331 ks8851_wrfifo_spi(ks, txb, last);
332 ks8851_wrreg16_spi(ks, KS_RXQCR, ks->rc_rxqcr);
333 ks8851_wrreg16_spi(ks, KS_TXQCR, TXQCR_METFE);
335 ks8851_done_tx(ks, txb);
339 tx_space = ks8851_rdreg16_spi(ks, KS_TXMIR);
341 spin_lock_bh(&ks->statelock);
342 ks->queued_len -= dequeued_len;
343 ks->tx_space = tx_space;
344 spin_unlock_bh(&ks->statelock);
346 ks8851_unlock_spi(ks, &flags);
351 * @ks: The device state
353 static void ks8851_flush_tx_work_spi(struct ks8851_net *ks)
355 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
377 struct ks8851_net *ks = netdev_priv(dev);
381 kss = to_ks8851_spi(ks);
383 netif_dbg(ks, tx_queued, ks->netdev,
386 spin_lock(&ks->statelock);
388 if (ks->queued_len + needed > ks->tx_space) {
392 ks->queued_len += needed;
393 skb_queue_tail(&ks->txq, skb);
396 spin_unlock(&ks->statelock);
408 struct ks8851_net *ks;
417 ks = &kss->ks8851;
419 ks->lock = ks8851_lock_spi;
420 ks->unlock = ks8851_unlock_spi;
421 ks->rdreg16 = ks8851_rdreg16_spi;
422 ks->wrreg16 = ks8851_wrreg16_spi;
423 ks->rdfifo = ks8851_rdfifo_spi;
424 ks->wrfifo = ks8851_wrfifo_spi;
425 ks->start_xmit = ks8851_start_xmit_spi;
426 ks->flush_tx_work = ks8851_flush_tx_work_spi;
434 ks->rc_ier = STD_IRQ;