diff options
Diffstat (limited to 'drivers/net/caif')
| -rw-r--r-- | drivers/net/caif/caif_hsi.c | 13 | ||||
| -rw-r--r-- | drivers/net/caif/caif_serial.c | 10 | ||||
| -rw-r--r-- | drivers/net/caif/caif_shmcore.c | 27 | ||||
| -rw-r--r-- | drivers/net/caif/caif_spi.c | 178 | 
4 files changed, 113 insertions, 115 deletions
diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c index 073352517ad..0a4fc62a381 100644 --- a/drivers/net/caif/caif_hsi.c +++ b/drivers/net/caif/caif_hsi.c @@ -117,15 +117,6 @@ static int cfhsi_flush_fifo(struct cfhsi *cfhsi)  	dev_dbg(&cfhsi->ndev->dev, "%s.\n",  		__func__); - -	ret = cfhsi->dev->cfhsi_wake_up(cfhsi->dev); -	if (ret) { -		dev_warn(&cfhsi->ndev->dev, -			"%s: can't wake up HSI interface: %d.\n", -			__func__, ret); -		return ret; -	} -  	do {  		ret = cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev,  				&fifo_occupancy); @@ -168,8 +159,6 @@ static int cfhsi_flush_fifo(struct cfhsi *cfhsi)  		}  	} while (1); -	cfhsi->dev->cfhsi_wake_down(cfhsi->dev); -  	return ret;  } @@ -944,7 +933,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)  		/* Create HSI frame. */  		len = cfhsi_tx_frm(desc, cfhsi); -		BUG_ON(!len); +		WARN_ON(!len);  		/* Set up new transfer. */  		res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev); diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 23406e62c0b..8a3054b8481 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -38,15 +38,15 @@ MODULE_ALIAS_LDISC(N_CAIF);  /*This list is protected by the rtnl lock. */  static LIST_HEAD(ser_list); -static int ser_loop; +static bool ser_loop;  module_param(ser_loop, bool, S_IRUGO);  MODULE_PARM_DESC(ser_loop, "Run in simulated loopback mode."); -static int ser_use_stx = 1; +static bool ser_use_stx = true;  module_param(ser_use_stx, bool, S_IRUGO);  MODULE_PARM_DESC(ser_use_stx, "STX enabled or not."); -static int ser_use_fcs = 1; +static bool ser_use_fcs = true;  module_param(ser_use_fcs, bool, S_IRUGO);  MODULE_PARM_DESC(ser_use_fcs, "FCS enabled or not."); @@ -261,7 +261,7 @@ static int handle_tx(struct ser_device *ser)  		skb_pull(skb, tty_wr);  		if (skb->len == 0) {  			struct sk_buff *tmp = skb_dequeue(&ser->head); -			BUG_ON(tmp != skb); +			WARN_ON(tmp != skb);  			if (in_interrupt())  				dev_kfree_skb_irq(skb);  			else @@ -305,7 +305,7 @@ static void ldisc_tx_wakeup(struct tty_struct *tty)  	ser = tty->disc_data;  	BUG_ON(ser == NULL); -	BUG_ON(ser->tty != tty); +	WARN_ON(ser->tty != tty);  	handle_tx(ser);  } diff --git a/drivers/net/caif/caif_shmcore.c b/drivers/net/caif/caif_shmcore.c index d4b26fb24ed..5b2041319a3 100644 --- a/drivers/net/caif/caif_shmcore.c +++ b/drivers/net/caif/caif_shmcore.c @@ -238,11 +238,11 @@ int caif_shmdrv_rx_cb(u32 mbx_msg, void *priv)  		if ((avail_emptybuff > HIGH_WATERMARK) &&  					(!pshm_drv->tx_empty_available)) {  			pshm_drv->tx_empty_available = 1; +			spin_unlock_irqrestore(&pshm_drv->lock, flags);  			pshm_drv->cfdev.flowctrl  					(pshm_drv->pshm_dev->pshm_netdev,  								CAIF_FLOW_ON); -			spin_unlock_irqrestore(&pshm_drv->lock, flags);  			/* Schedule the work queue. if required */  			if (!work_pending(&pshm_drv->shm_tx_work)) @@ -285,6 +285,7 @@ static void shm_rx_work_func(struct work_struct *rx_work)  			list_entry(pshm_drv->rx_full_list.next, struct buf_list,  					list);  		list_del_init(&pbuf->list); +		spin_unlock_irqrestore(&pshm_drv->lock, flags);  		/* Retrieve pointer to start of the packet descriptor area. */  		pck_desc = (struct shm_pck_desc *) pbuf->desc_vptr; @@ -336,7 +337,11 @@ static void shm_rx_work_func(struct work_struct *rx_work)  			/* Get a suitable CAIF packet and copy in data. */  			skb = netdev_alloc_skb(pshm_drv->pshm_dev->pshm_netdev,  							frm_pck_len + 1); -			BUG_ON(skb == NULL); + +			if (skb == NULL) { +				pr_info("OOM: Try next frame in descriptor\n"); +				break; +			}  			p = skb_put(skb, frm_pck_len);  			memcpy(p, pbuf->desc_vptr + frm_pck_ofs, frm_pck_len); @@ -360,6 +365,7 @@ static void shm_rx_work_func(struct work_struct *rx_work)  			pck_desc++;  		} +		spin_lock_irqsave(&pshm_drv->lock, flags);  		list_add_tail(&pbuf->list, &pshm_drv->rx_pend_list);  		spin_unlock_irqrestore(&pshm_drv->lock, flags); @@ -412,7 +418,6 @@ static void shm_tx_work_func(struct work_struct *tx_work)  		if (skb == NULL)  			goto send_msg; -  		/* Check the available no. of buffers in the empty list */  		list_for_each(pos, &pshm_drv->tx_empty_list)  			avail_emptybuff++; @@ -421,9 +426,11 @@ static void shm_tx_work_func(struct work_struct *tx_work)  					pshm_drv->tx_empty_available) {  			/* Update blocking condition. */  			pshm_drv->tx_empty_available = 0; +			spin_unlock_irqrestore(&pshm_drv->lock, flags);  			pshm_drv->cfdev.flowctrl  					(pshm_drv->pshm_dev->pshm_netdev,  					CAIF_FLOW_OFF); +			spin_lock_irqsave(&pshm_drv->lock, flags);  		}  		/*  		 * We simply return back to the caller if we do not have space @@ -469,6 +476,8 @@ static void shm_tx_work_func(struct work_struct *tx_work)  			}  			skb = skb_dequeue(&pshm_drv->sk_qhead); +			if (skb == NULL) +				break;  			/* Copy in CAIF frame. */  			skb_copy_bits(skb, 0, pbuf->desc_vptr +  					pbuf->frm_ofs + SHM_HDR_LEN + @@ -477,7 +486,7 @@ static void shm_tx_work_func(struct work_struct *tx_work)  			pshm_drv->pshm_dev->pshm_netdev->stats.tx_packets++;  			pshm_drv->pshm_dev->pshm_netdev->stats.tx_bytes +=  									frmlen; -			dev_kfree_skb(skb); +			dev_kfree_skb_irq(skb);  			/* Fill in the shared memory packet descriptor area. */  			pck_desc = (struct shm_pck_desc *) (pbuf->desc_vptr); @@ -512,16 +521,11 @@ send_msg:  static int shm_netdev_tx(struct sk_buff *skb, struct net_device *shm_netdev)  {  	struct shmdrv_layer *pshm_drv; -	unsigned long flags = 0;  	pshm_drv = netdev_priv(shm_netdev); -	spin_lock_irqsave(&pshm_drv->lock, flags); -  	skb_queue_tail(&pshm_drv->sk_qhead, skb); -	spin_unlock_irqrestore(&pshm_drv->lock, flags); -  	/* Schedule Tx work queue. for deferred processing of skbs*/  	if (!work_pending(&pshm_drv->shm_tx_work))  		queue_work(pshm_drv->pshm_tx_workqueue, &pshm_drv->shm_tx_work); @@ -606,6 +610,7 @@ int caif_shmcore_probe(struct shmdev_layer *pshm_dev)  		pshm_drv->shm_rx_addr = pshm_dev->shm_base_addr +  						(NR_TX_BUF * TX_BUF_SZ); +	spin_lock_init(&pshm_drv->lock);  	INIT_LIST_HEAD(&pshm_drv->tx_empty_list);  	INIT_LIST_HEAD(&pshm_drv->tx_pend_list);  	INIT_LIST_HEAD(&pshm_drv->tx_full_list); @@ -640,7 +645,7 @@ int caif_shmcore_probe(struct shmdev_layer *pshm_dev)  		tx_buf->frm_ofs = SHM_CAIF_FRM_OFS;  		if (pshm_dev->shm_loopback) -			tx_buf->desc_vptr = (char *)tx_buf->phy_addr; +			tx_buf->desc_vptr = (unsigned char *)tx_buf->phy_addr;  		else  			tx_buf->desc_vptr =  					ioremap(tx_buf->phy_addr, TX_BUF_SZ); @@ -664,7 +669,7 @@ int caif_shmcore_probe(struct shmdev_layer *pshm_dev)  		rx_buf->len = RX_BUF_SZ;  		if (pshm_dev->shm_loopback) -			rx_buf->desc_vptr = (char *)rx_buf->phy_addr; +			rx_buf->desc_vptr = (unsigned char *)rx_buf->phy_addr;  		else  			rx_buf->desc_vptr =  					ioremap(rx_buf->phy_addr, RX_BUF_SZ); diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c index 05e791f46ae..96391c36fa7 100644 --- a/drivers/net/caif/caif_spi.c +++ b/drivers/net/caif/caif_spi.c @@ -35,7 +35,7 @@ MODULE_DESCRIPTION("CAIF SPI driver");  /* Returns the number of padding bytes for alignment. */  #define PAD_POW2(x, pow) ((((x)&((pow)-1))==0) ? 0 : (((pow)-((x)&((pow)-1))))) -static int spi_loop; +static bool spi_loop;  module_param(spi_loop, bool, S_IRUGO);  MODULE_PARM_DESC(spi_loop, "SPI running in loopback mode."); @@ -226,7 +226,7 @@ static ssize_t dbgfs_frame(struct file *file, char __user *user_buf,  			"Tx data (Len: %d):\n", cfspi->tx_cpck_len);  	len += print_frame((buf + len), (DEBUGFS_BUF_SIZE - len), -			   cfspi->xfer.va_tx, +			   cfspi->xfer.va_tx[0],  			   (cfspi->tx_cpck_len + SPI_CMD_SZ), 100);  	len += snprintf((buf + len), (DEBUGFS_BUF_SIZE - len), @@ -599,48 +599,11 @@ static int cfspi_close(struct net_device *dev)  	netif_stop_queue(dev);  	return 0;  } -static const struct net_device_ops cfspi_ops = { -	.ndo_open = cfspi_open, -	.ndo_stop = cfspi_close, -	.ndo_start_xmit = cfspi_xmit -}; -static void cfspi_setup(struct net_device *dev) +static int cfspi_init(struct net_device *dev)  { +	int res = 0;  	struct cfspi *cfspi = netdev_priv(dev); -	dev->features = 0; -	dev->netdev_ops = &cfspi_ops; -	dev->type = ARPHRD_CAIF; -	dev->flags = IFF_NOARP | IFF_POINTOPOINT; -	dev->tx_queue_len = 0; -	dev->mtu = SPI_MAX_PAYLOAD_SIZE; -	dev->destructor = free_netdev; -	skb_queue_head_init(&cfspi->qhead); -	skb_queue_head_init(&cfspi->chead); -	cfspi->cfdev.link_select = CAIF_LINK_HIGH_BANDW; -	cfspi->cfdev.use_frag = false; -	cfspi->cfdev.use_stx = false; -	cfspi->cfdev.use_fcs = false; -	cfspi->ndev = dev; -} - -int cfspi_spi_probe(struct platform_device *pdev) -{ -	struct cfspi *cfspi = NULL; -	struct net_device *ndev; -	struct cfspi_dev *dev; -	int res; -	dev = (struct cfspi_dev *)pdev->dev.platform_data; - -	ndev = alloc_netdev(sizeof(struct cfspi), -			"cfspi%d", cfspi_setup); -	if (!ndev) -		return -ENOMEM; - -	cfspi = netdev_priv(ndev); -	netif_stop_queue(ndev); -	cfspi->ndev = ndev; -	cfspi->pdev = pdev;  	/* Set flow info. */  	cfspi->flow_off_sent = 0; @@ -656,16 +619,11 @@ int cfspi_spi_probe(struct platform_device *pdev)  		cfspi->slave_talked = false;  	} -	/* Assign the SPI device. */ -	cfspi->dev = dev; -	/* Assign the device ifc to this SPI interface. */ -	dev->ifc = &cfspi->ifc; -  	/* Allocate DMA buffers. */ -	cfspi->xfer.va_tx = dma_alloc(&cfspi->xfer.pa_tx); -	if (!cfspi->xfer.va_tx) { +	cfspi->xfer.va_tx[0] = dma_alloc(&cfspi->xfer.pa_tx[0]); +	if (!cfspi->xfer.va_tx[0]) {  		res = -ENODEV; -		goto err_dma_alloc_tx; +		goto err_dma_alloc_tx_0;  	}  	cfspi->xfer.va_rx = dma_alloc(&cfspi->xfer.pa_rx); @@ -714,6 +672,87 @@ int cfspi_spi_probe(struct platform_device *pdev)  	/* Schedule the work queue. */  	queue_work(cfspi->wq, &cfspi->work); +	return 0; + + err_create_wq: +	dma_free(cfspi->xfer.va_rx, cfspi->xfer.pa_rx); + err_dma_alloc_rx: +	dma_free(cfspi->xfer.va_tx[0], cfspi->xfer.pa_tx[0]); + err_dma_alloc_tx_0: +	return res; +} + +static void cfspi_uninit(struct net_device *dev) +{ +	struct cfspi *cfspi = netdev_priv(dev); + +	/* Remove from list. */ +	spin_lock(&cfspi_list_lock); +	list_del(&cfspi->list); +	spin_unlock(&cfspi_list_lock); + +	cfspi->ndev = NULL; +	/* Free DMA buffers. */ +	dma_free(cfspi->xfer.va_rx, cfspi->xfer.pa_rx); +	dma_free(cfspi->xfer.va_tx[0], cfspi->xfer.pa_tx[0]); +	set_bit(SPI_TERMINATE, &cfspi->state); +	wake_up_interruptible(&cfspi->wait); +	destroy_workqueue(cfspi->wq); +	/* Destroy debugfs directory and files. */ +	dev_debugfs_rem(cfspi); +	return; +} + +static const struct net_device_ops cfspi_ops = { +	.ndo_open = cfspi_open, +	.ndo_stop = cfspi_close, +	.ndo_init = cfspi_init, +	.ndo_uninit = cfspi_uninit, +	.ndo_start_xmit = cfspi_xmit +}; + +static void cfspi_setup(struct net_device *dev) +{ +	struct cfspi *cfspi = netdev_priv(dev); +	dev->features = 0; +	dev->netdev_ops = &cfspi_ops; +	dev->type = ARPHRD_CAIF; +	dev->flags = IFF_NOARP | IFF_POINTOPOINT; +	dev->tx_queue_len = 0; +	dev->mtu = SPI_MAX_PAYLOAD_SIZE; +	dev->destructor = free_netdev; +	skb_queue_head_init(&cfspi->qhead); +	skb_queue_head_init(&cfspi->chead); +	cfspi->cfdev.link_select = CAIF_LINK_HIGH_BANDW; +	cfspi->cfdev.use_frag = false; +	cfspi->cfdev.use_stx = false; +	cfspi->cfdev.use_fcs = false; +	cfspi->ndev = dev; +} + +int cfspi_spi_probe(struct platform_device *pdev) +{ +	struct cfspi *cfspi = NULL; +	struct net_device *ndev; +	struct cfspi_dev *dev; +	int res; +	dev = (struct cfspi_dev *)pdev->dev.platform_data; + +	ndev = alloc_netdev(sizeof(struct cfspi), +			"cfspi%d", cfspi_setup); +	if (!dev) +		return -ENODEV; + +	cfspi = netdev_priv(ndev); +	netif_stop_queue(ndev); +	cfspi->ndev = ndev; +	cfspi->pdev = pdev; + +	/* Assign the SPI device. */ +	cfspi->dev = dev; +	/* Assign the device ifc to this SPI interface. */ +	dev->ifc = &cfspi->ifc; +  	/* Register network device. */  	res = register_netdev(ndev);  	if (res) { @@ -723,15 +762,6 @@ int cfspi_spi_probe(struct platform_device *pdev)  	return res;   err_net_reg: -	dev_debugfs_rem(cfspi); -	set_bit(SPI_TERMINATE, &cfspi->state); -	wake_up_interruptible(&cfspi->wait); -	destroy_workqueue(cfspi->wq); - err_create_wq: -	dma_free(cfspi->xfer.va_rx, cfspi->xfer.pa_rx); - err_dma_alloc_rx: -	dma_free(cfspi->xfer.va_tx, cfspi->xfer.pa_tx); - err_dma_alloc_tx:  	free_netdev(ndev);  	return res; @@ -739,34 +769,8 @@ int cfspi_spi_probe(struct platform_device *pdev)  int cfspi_spi_remove(struct platform_device *pdev)  { -	struct list_head *list_node; -	struct list_head *n; -	struct cfspi *cfspi = NULL; -	struct cfspi_dev *dev; - -	dev = (struct cfspi_dev *)pdev->dev.platform_data; -	spin_lock(&cfspi_list_lock); -	list_for_each_safe(list_node, n, &cfspi_list) { -		cfspi = list_entry(list_node, struct cfspi, list); -		/* Find the corresponding device. */ -		if (cfspi->dev == dev) { -			/* Remove from list. */ -			list_del(list_node); -			/* Free DMA buffers. */ -			dma_free(cfspi->xfer.va_rx, cfspi->xfer.pa_rx); -			dma_free(cfspi->xfer.va_tx, cfspi->xfer.pa_tx); -			set_bit(SPI_TERMINATE, &cfspi->state); -			wake_up_interruptible(&cfspi->wait); -			destroy_workqueue(cfspi->wq); -			/* Destroy debugfs directory and files. */ -			dev_debugfs_rem(cfspi); -			unregister_netdev(cfspi->ndev); -			spin_unlock(&cfspi_list_lock); -			return 0; -		} -	} -	spin_unlock(&cfspi_list_lock); -	return -ENODEV; +	/* Everything is done in cfspi_uninit(). */ +	return 0;  }  static void __exit cfspi_exit_module(void) @@ -777,7 +781,7 @@ static void __exit cfspi_exit_module(void)  	list_for_each_safe(list_node, n, &cfspi_list) {  		cfspi = list_entry(list_node, struct cfspi, list); -		platform_device_unregister(cfspi->pdev); +		unregister_netdev(cfspi->ndev);  	}  	/* Destroy sysfs files. */  |