cregit-Linux how code gets into the kernel

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

PersonTokensPropCommitsCommitProp
johnny kimjohnny kim2752.94%17.14%
chaehyun limchaehyun lim1937.25%1071.43%
arnd bergmannarnd bergmann35.88%17.14%
dean leedean lee11.96%17.14%
leo kimleo kim11.96%17.14%
Total51100.00%14100.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

PersonTokensPropCommitsCommitProp
chaehyun limchaehyun lim4953.85%1071.43%
johnny kimjohnny kim3942.86%17.14%
leo kimleo kim11.10%17.14%
dean leedean lee11.10%17.14%
arnd bergmannarnd bergmann11.10%17.14%
Total91100.00%14100.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

PersonTokensPropCommitsCommitProp
johnny kimjohnny kim6638.82%13.70%
chaehyun limchaehyun lim6337.06%2177.78%
leo kimleo kim3822.35%311.11%
shraddha barkeshraddha barke21.18%13.70%
arnd bergmannarnd bergmann10.59%13.70%
Total170100.00%27100.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

PersonTokensPropCommitsCommitProp
johnny kimjohnny kim13053.06%13.85%
chaehyun limchaehyun lim9639.18%2284.62%
leo kimleo kim166.53%13.85%
arnd bergmannarnd bergmann20.82%13.85%
chandra s gorentlachandra s gorentla10.41%13.85%
Total245100.00%26100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
johnny kimjohnny kim27147.29%12.13%
chaehyun limchaehyun lim23040.14%3778.72%
leo kimleo kim5910.30%48.51%
arnd bergmannarnd bergmann71.22%12.13%
dean leedean lee30.52%24.26%
shraddha barkeshraddha barke20.35%12.13%
chandra s gorentlachandra s gorentla10.17%12.13%
Total573100.00%47100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}