Release 4.7 drivers/staging/wilc1000/wilc_msgqueue.c
#include "wilc_msgqueue.h"
#include <linux/spinlock.h>
#include <linux/errno.h>
#include <linux/slab.h>
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
int wilc_mq_create(struct message_queue *mq)
{
spin_lock_init(&mq->lock);
sema_init(&mq->sem, 0);
INIT_LIST_HEAD(&mq->msg_list);
mq->recv_count = 0;
mq->exiting = false;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
johnny kim | johnny kim | 27 | 52.94% | 1 | 7.14% |
chaehyun lim | chaehyun lim | 19 | 37.25% | 10 | 71.43% |
arnd bergmann | arnd bergmann | 3 | 5.88% | 1 | 7.14% |
dean lee | dean lee | 1 | 1.96% | 1 | 7.14% |
leo kim | leo kim | 1 | 1.96% | 1 | 7.14% |
| Total | 51 | 100.00% | 14 | 100.00% |
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
int wilc_mq_destroy(struct message_queue *mq)
{
struct message *msg;
mq->exiting = true;
/* Release any waiting receiver thread. */
while (mq->recv_count > 0) {
up(&mq->sem);
mq->recv_count--;
}
while (!list_empty(&mq->msg_list)) {
msg = list_first_entry(&mq->msg_list, struct message, list);
list_del(&msg->list);
kfree(msg->buf);
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
chaehyun lim | chaehyun lim | 49 | 53.85% | 10 | 71.43% |
johnny kim | johnny kim | 39 | 42.86% | 1 | 7.14% |
leo kim | leo kim | 1 | 1.10% | 1 | 7.14% |
dean lee | dean lee | 1 | 1.10% | 1 | 7.14% |
arnd bergmann | arnd bergmann | 1 | 1.10% | 1 | 7.14% |
| Total | 91 | 100.00% | 14 | 100.00% |
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
int wilc_mq_send(struct message_queue *mq,
const void *send_buf, u32 send_buf_size)
{
unsigned long flags;
struct message *new_msg = NULL;
if (!mq || (send_buf_size == 0) || !send_buf)
return -EINVAL;
if (mq->exiting)
return -EFAULT;
/* construct a new message */
new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
if (!new_msg)
return -ENOMEM;
new_msg->len = send_buf_size;
INIT_LIST_HEAD(&new_msg->list);
new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC);
if (!new_msg->buf) {
kfree(new_msg);
return -ENOMEM;
}
spin_lock_irqsave(&mq->lock, flags);
/* add it to the message queue */
list_add_tail(&new_msg->list, &mq->msg_list);
spin_unlock_irqrestore(&mq->lock, flags);
up(&mq->sem);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
johnny kim | johnny kim | 66 | 38.82% | 1 | 3.70% |
chaehyun lim | chaehyun lim | 63 | 37.06% | 21 | 77.78% |
leo kim | leo kim | 38 | 22.35% | 3 | 11.11% |
shraddha barke | shraddha barke | 2 | 1.18% | 1 | 3.70% |
arnd bergmann | arnd bergmann | 1 | 0.59% | 1 | 3.70% |
| Total | 170 | 100.00% | 27 | 100.00% |
/*!
* @author syounan
* @date 1 Sep 2010
* @note copied from FLO glue implementatuion
* @version 1.0
*/
int wilc_mq_recv(struct message_queue *mq,
void *recv_buf, u32 recv_buf_size, u32 *recv_len)
{
struct message *msg;
unsigned long flags;
if (!mq || (recv_buf_size == 0) || !recv_buf || !recv_len)
return -EINVAL;
if (mq->exiting)
return -EFAULT;
spin_lock_irqsave(&mq->lock, flags);
mq->recv_count++;
spin_unlock_irqrestore(&mq->lock, flags);
down(&mq->sem);
spin_lock_irqsave(&mq->lock, flags);
if (list_empty(&mq->msg_list)) {
spin_unlock_irqrestore(&mq->lock, flags);
up(&mq->sem);
return -EFAULT;
}
/* check buffer size */
msg = list_first_entry(&mq->msg_list, struct message, list);
if (recv_buf_size < msg->len) {
spin_unlock_irqrestore(&mq->lock, flags);
up(&mq->sem);
return -EOVERFLOW;
}
/* consume the message */
mq->recv_count--;
memcpy(recv_buf, msg->buf, msg->len);
*recv_len = msg->len;
list_del(&msg->list);
kfree(msg->buf);
kfree(msg);
spin_unlock_irqrestore(&mq->lock, flags);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
johnny kim | johnny kim | 130 | 53.06% | 1 | 3.85% |
chaehyun lim | chaehyun lim | 96 | 39.18% | 22 | 84.62% |
leo kim | leo kim | 16 | 6.53% | 1 | 3.85% |
arnd bergmann | arnd bergmann | 2 | 0.82% | 1 | 3.85% |
chandra s gorentla | chandra s gorentla | 1 | 0.41% | 1 | 3.85% |
| Total | 245 | 100.00% | 26 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
johnny kim | johnny kim | 271 | 47.29% | 1 | 2.13% |
chaehyun lim | chaehyun lim | 230 | 40.14% | 37 | 78.72% |
leo kim | leo kim | 59 | 10.30% | 4 | 8.51% |
arnd bergmann | arnd bergmann | 7 | 1.22% | 1 | 2.13% |
dean lee | dean lee | 3 | 0.52% | 2 | 4.26% |
shraddha barke | shraddha barke | 2 | 0.35% | 1 | 2.13% |
chandra s gorentla | chandra s gorentla | 1 | 0.17% | 1 | 2.13% |
| Total | 573 | 100.00% | 47 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.