Lines Matching refs:tdev

50 	struct mbox_test_device *tdev = filp->private_data;  in mbox_test_signal_write()  local
52 if (!tdev->tx_channel) { in mbox_test_signal_write()
53 dev_err(tdev->dev, "Channel cannot do Tx\n"); in mbox_test_signal_write()
58 dev_err(tdev->dev, in mbox_test_signal_write()
65 if (!tdev->signal) { in mbox_test_signal_write()
66 tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL); in mbox_test_signal_write()
67 if (!tdev->signal) in mbox_test_signal_write()
71 if (copy_from_user(tdev->signal, userbuf, count)) { in mbox_test_signal_write()
72 kfree(tdev->signal); in mbox_test_signal_write()
73 tdev->signal = NULL; in mbox_test_signal_write()
88 struct mbox_test_device *tdev = filp->private_data; in mbox_test_message_fasync() local
90 return fasync_helper(fd, filp, on, &tdev->async_queue); in mbox_test_message_fasync()
97 struct mbox_test_device *tdev = filp->private_data; in mbox_test_message_write() local
101 if (!tdev->tx_channel) { in mbox_test_message_write()
102 dev_err(tdev->dev, "Channel cannot do Tx\n"); in mbox_test_message_write()
107 dev_err(tdev->dev, in mbox_test_message_write()
113 tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL); in mbox_test_message_write()
114 if (!tdev->message) in mbox_test_message_write()
117 ret = copy_from_user(tdev->message, userbuf, count); in mbox_test_message_write()
127 if (tdev->tx_mmio && tdev->signal) { in mbox_test_message_write()
129 tdev->signal, MBOX_MAX_SIG_LEN); in mbox_test_message_write()
131 data = tdev->signal; in mbox_test_message_write()
133 data = tdev->message; in mbox_test_message_write()
136 tdev->message, MBOX_MAX_MSG_LEN); in mbox_test_message_write()
138 ret = mbox_send_message(tdev->tx_channel, data); in mbox_test_message_write()
140 dev_err(tdev->dev, "Failed to send message via mailbox\n"); in mbox_test_message_write()
143 kfree(tdev->signal); in mbox_test_message_write()
144 kfree(tdev->message); in mbox_test_message_write()
145 tdev->signal = NULL; in mbox_test_message_write()
150 static bool mbox_test_message_data_ready(struct mbox_test_device *tdev) in mbox_test_message_data_ready() argument
155 spin_lock_irqsave(&tdev->lock, flags); in mbox_test_message_data_ready()
157 spin_unlock_irqrestore(&tdev->lock, flags); in mbox_test_message_data_ready()
165 struct mbox_test_device *tdev = filp->private_data; in mbox_test_message_read() local
177 if (!tdev->rx_channel) { in mbox_test_message_read()
184 add_wait_queue(&tdev->waitq, &wait); in mbox_test_message_read()
189 if (mbox_test_message_data_ready(tdev)) in mbox_test_message_read()
205 spin_lock_irqsave(&tdev->lock, flags); in mbox_test_message_read()
207 ptr = tdev->rx_buffer; in mbox_test_message_read()
220 memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN); in mbox_test_message_read()
223 spin_unlock_irqrestore(&tdev->lock, flags); in mbox_test_message_read()
228 remove_wait_queue(&tdev->waitq, &wait); in mbox_test_message_read()
237 struct mbox_test_device *tdev = filp->private_data; in mbox_test_message_poll() local
239 poll_wait(filp, &tdev->waitq, wait); in mbox_test_message_poll()
241 if (mbox_test_message_data_ready(tdev)) in mbox_test_message_poll()
256 struct mbox_test_device *tdev) in mbox_test_add_debugfs() argument
261 tdev->root_debugfs_dir = debugfs_create_dir(dev_name(&pdev->dev), NULL); in mbox_test_add_debugfs()
262 if (!tdev->root_debugfs_dir) { in mbox_test_add_debugfs()
267 debugfs_create_file("message", 0600, tdev->root_debugfs_dir, in mbox_test_add_debugfs()
268 tdev, &mbox_test_message_ops); in mbox_test_add_debugfs()
270 debugfs_create_file("signal", 0200, tdev->root_debugfs_dir, in mbox_test_add_debugfs()
271 tdev, &mbox_test_signal_ops); in mbox_test_add_debugfs()
278 struct mbox_test_device *tdev = dev_get_drvdata(client->dev); in mbox_test_receive_message() local
281 spin_lock_irqsave(&tdev->lock, flags); in mbox_test_receive_message()
282 if (tdev->rx_mmio) { in mbox_test_receive_message()
283 memcpy_fromio(tdev->rx_buffer, tdev->rx_mmio, MBOX_MAX_MSG_LEN); in mbox_test_receive_message()
285 tdev->rx_buffer, MBOX_MAX_MSG_LEN); in mbox_test_receive_message()
289 memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN); in mbox_test_receive_message()
292 spin_unlock_irqrestore(&tdev->lock, flags); in mbox_test_receive_message()
294 wake_up_interruptible(&tdev->waitq); in mbox_test_receive_message()
296 kill_fasync(&tdev->async_queue, SIGIO, POLL_IN); in mbox_test_receive_message()
301 struct mbox_test_device *tdev = dev_get_drvdata(client->dev); in mbox_test_prepare_message() local
303 if (tdev->tx_mmio) { in mbox_test_prepare_message()
304 if (tdev->signal) in mbox_test_prepare_message()
305 memcpy_toio(tdev->tx_mmio, tdev->message, MBOX_MAX_MSG_LEN); in mbox_test_prepare_message()
307 memcpy_toio(tdev->tx_mmio, message, MBOX_MAX_MSG_LEN); in mbox_test_prepare_message()
351 struct mbox_test_device *tdev; in mbox_test_probe() local
356 tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); in mbox_test_probe()
357 if (!tdev) in mbox_test_probe()
362 tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res); in mbox_test_probe()
363 if (PTR_ERR(tdev->tx_mmio) == -EBUSY) { in mbox_test_probe()
366 tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size); in mbox_test_probe()
367 } else if (IS_ERR(tdev->tx_mmio)) { in mbox_test_probe()
368 tdev->tx_mmio = NULL; in mbox_test_probe()
373 tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res); in mbox_test_probe()
374 if (PTR_ERR(tdev->rx_mmio) == -EBUSY) { in mbox_test_probe()
376 tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size); in mbox_test_probe()
377 } else if (IS_ERR(tdev->rx_mmio)) { in mbox_test_probe()
378 tdev->rx_mmio = tdev->tx_mmio; in mbox_test_probe()
381 tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); in mbox_test_probe()
382 tdev->rx_channel = mbox_test_request_channel(pdev, "rx"); in mbox_test_probe()
384 if (!tdev->tx_channel && !tdev->rx_channel) in mbox_test_probe()
388 if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio)) in mbox_test_probe()
389 tdev->rx_channel = tdev->tx_channel; in mbox_test_probe()
391 tdev->dev = &pdev->dev; in mbox_test_probe()
392 platform_set_drvdata(pdev, tdev); in mbox_test_probe()
394 spin_lock_init(&tdev->lock); in mbox_test_probe()
396 if (tdev->rx_channel) { in mbox_test_probe()
397 tdev->rx_buffer = devm_kzalloc(&pdev->dev, in mbox_test_probe()
399 if (!tdev->rx_buffer) in mbox_test_probe()
403 ret = mbox_test_add_debugfs(pdev, tdev); in mbox_test_probe()
407 init_waitqueue_head(&tdev->waitq); in mbox_test_probe()
415 struct mbox_test_device *tdev = platform_get_drvdata(pdev); in mbox_test_remove() local
417 debugfs_remove_recursive(tdev->root_debugfs_dir); in mbox_test_remove()
419 if (tdev->tx_channel) in mbox_test_remove()
420 mbox_free_channel(tdev->tx_channel); in mbox_test_remove()
421 if (tdev->rx_channel) in mbox_test_remove()
422 mbox_free_channel(tdev->rx_channel); in mbox_test_remove()