mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 21:45:08 -04:00
staging: rtl8723au: Get rid of ugly cbuf interface
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
980cf72afb
commit
593ac88e76
@@ -166,20 +166,6 @@ void rtw_unlock_suspend(void);
|
||||
#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
|
||||
((u32) (a)[2]))
|
||||
|
||||
|
||||
struct rtw_cbuf {
|
||||
u32 write;
|
||||
u32 read;
|
||||
u32 size;
|
||||
void *bufs[0];
|
||||
};
|
||||
|
||||
bool rtw_cbuf_full23a(struct rtw_cbuf *cbuf);
|
||||
bool rtw_cbuf_empty23a(struct rtw_cbuf *cbuf);
|
||||
bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf);
|
||||
void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf);
|
||||
struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size);
|
||||
void rtw_cbuf_free(struct rtw_cbuf *cbuf);
|
||||
s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter);
|
||||
u8 rtw_do_join23a(struct rtw_adapter *padapter);
|
||||
|
||||
|
||||
@@ -68,95 +68,3 @@ u32 _rtw_queue_empty23a(struct rtw_queue *pqueue)
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/* rtw_cbuf_full23a - test if cbuf is full
|
||||
* @cbuf: pointer of struct rtw_cbuf
|
||||
*
|
||||
* Returns: true if cbuf is full
|
||||
*/
|
||||
inline bool rtw_cbuf_full23a(struct rtw_cbuf *cbuf)
|
||||
{
|
||||
return (cbuf->write == cbuf->read-1) ? true : false;
|
||||
}
|
||||
|
||||
/* rtw_cbuf_empty23a - test if cbuf is empty
|
||||
* @cbuf: pointer of struct rtw_cbuf
|
||||
*
|
||||
* Returns: true if cbuf is empty
|
||||
*/
|
||||
inline bool rtw_cbuf_empty23a(struct rtw_cbuf *cbuf)
|
||||
{
|
||||
return (cbuf->write == cbuf->read) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* rtw_cbuf_push23a - push a pointer into cbuf
|
||||
* @cbuf: pointer of struct rtw_cbuf
|
||||
* @buf: pointer to push in
|
||||
*
|
||||
* Lock free operation, be careful of the use scheme
|
||||
* Returns: true push success
|
||||
*/
|
||||
bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf)
|
||||
{
|
||||
if (rtw_cbuf_full23a(cbuf))
|
||||
return _FAIL;
|
||||
|
||||
if (0)
|
||||
DBG_8723A("%s on %u\n", __func__, cbuf->write);
|
||||
cbuf->bufs[cbuf->write] = buf;
|
||||
cbuf->write = (cbuf->write+1)%cbuf->size;
|
||||
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* rtw_cbuf_pop23a - pop a pointer from cbuf
|
||||
* @cbuf: pointer of struct rtw_cbuf
|
||||
*
|
||||
* Lock free operation, be careful of the use scheme
|
||||
* Returns: pointer popped out
|
||||
*/
|
||||
void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf)
|
||||
{
|
||||
void *buf;
|
||||
if (rtw_cbuf_empty23a(cbuf))
|
||||
return NULL;
|
||||
|
||||
if (0)
|
||||
DBG_8723A("%s on %u\n", __func__, cbuf->read);
|
||||
buf = cbuf->bufs[cbuf->read];
|
||||
cbuf->read = (cbuf->read+1)%cbuf->size;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* rtw_cbuf_alloc23a - allocte a rtw_cbuf with given size and do initialization
|
||||
* @size: size of pointer
|
||||
*
|
||||
* Returns: pointer of srtuct rtw_cbuf, NULL for allocation failure
|
||||
*/
|
||||
struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size)
|
||||
{
|
||||
struct rtw_cbuf *cbuf;
|
||||
|
||||
cbuf = kmalloc(sizeof(*cbuf) + sizeof(void *)*size, GFP_KERNEL);
|
||||
|
||||
if (cbuf) {
|
||||
cbuf->write = 0;
|
||||
cbuf->read = 0;
|
||||
cbuf->size = size;
|
||||
}
|
||||
|
||||
return cbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* rtw_cbuf_free - free the given rtw_cbuf
|
||||
* @cbuf: pointer of struct rtw_cbuf to free
|
||||
*/
|
||||
void rtw_cbuf_free(struct rtw_cbuf *cbuf)
|
||||
{
|
||||
kfree(cbuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user