Skip to content

Commit

Permalink
Staging: ti-st: cleanup code comments
Browse files Browse the repository at this point in the history
cleanup the code commenting in the headers/structures,
also cleanup few inline commenting in the function

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Pavan Savoy authored and Greg Kroah-Hartman committed Jul 22, 2010
1 parent e6d9e64 commit 36b5aee
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 117 deletions.
44 changes: 21 additions & 23 deletions drivers/staging/ti-st/st.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
#define ST_H

#include <linux/skbuff.h>
/*
* st.h
*/

/* TODO:
* Move the following to tty.h upon acceptance
*/
#define N_TI_WL 20 /* Ldisc for TI's WL BT, FM, GPS combo chips */

/* some gpios have active high, others like fm have
* active low
/**
* enum kim_gpio_state - Few protocols such as FM have ACTIVE LOW
* gpio states for their chip/core enable gpios
*/
enum kim_gpio_state {
KIM_GPIO_INACTIVE,
KIM_GPIO_ACTIVE,
};
/*
* the list of protocols on chip

/**
* enum proto-type - The protocol on WiLink chips which share a
* common physical interface like UART.
*/
enum proto_type {
ST_BT,
Expand All @@ -50,28 +50,26 @@ enum proto_type {
ST_MAX,
};

/* per protocol structure
* for BT/FM and GPS
/**
* struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
* @type: type of the protocol being registered among the
* available proto_type(BT, FM, GPS the protocol which share TTY).
* @recv: the receiver callback pointing to a function in the
* protocol drivers called by the ST driver upon receiving
* relevant data.
* @match_packet: reserved for future use, to make ST more generic
* @reg_complete_cb: callback handler pointing to a function in protocol
* handler called by ST when the pending registrations are complete.
* The registrations are marked pending, in situations when fw
* download is in progress.
* @write: pointer to function in ST provided to protocol drivers from ST,
* to be made use when protocol drivers have data to send to TTY.
*/
struct st_proto_s {
enum proto_type type;
/*
* to be called by ST when data arrives
*/
long (*recv) (struct sk_buff *);
/*
* for future use, logic now to be in ST
*/
unsigned char (*match_packet) (const unsigned char *data);
/*
* subsequent registration return PENDING,
* signalled complete by this callback function
*/
void (*reg_complete_cb) (char data);
/*
* write function, sent in as NULL and to be returned to
* protocol drivers
*/
long (*write) (struct sk_buff *skb);
};

Expand Down
54 changes: 28 additions & 26 deletions drivers/staging/ti-st/st_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ bool is_protocol_list_empty(void)
return ST_EMPTY;
}
#endif

/* can be called in from
* -- KIM (during fw download)
* -- ST Core (during st_write)
Expand Down Expand Up @@ -131,7 +132,8 @@ void st_send_frame(enum proto_type protoid, struct st_data_s *st_gdata)
return;
}

/*
/**
* st_reg_complete -
* to call registration complete callbacks
* of all protocol stack drivers
*/
Expand Down Expand Up @@ -185,8 +187,9 @@ static inline int st_check_data_len(struct st_data_s *st_gdata,
return 0;
}

/* internal function for action when wake-up ack
* received
/**
* st_wakeup_ack - internal function for action when wake-up ack
* received
*/
static inline void st_wakeup_ack(struct st_data_s *st_gdata,
unsigned char cmd)
Expand All @@ -209,9 +212,13 @@ static inline void st_wakeup_ack(struct st_data_s *st_gdata,
st_tx_wakeup(st_gdata);
}

/* Decodes received RAW data and forwards to corresponding
* client drivers (Bluetooth,FM,GPS..etc).
*
/**
* st_int_recv - ST's internal receive function.
* Decodes received RAW data and forwards to corresponding
* client drivers (Bluetooth,FM,GPS..etc).
* This can receive various types of packets,
* HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets
* CH-8 packets from FM, CH-9 packets from GPS cores.
*/
void st_int_recv(void *disc_data,
const unsigned char *data, long count)
Expand Down Expand Up @@ -438,41 +445,39 @@ void st_int_recv(void *disc_data,
return;
}

/* internal de-Q function
* -- return previous in-completely written skb
* or return the skb in the txQ
/**
* st_int_dequeue - internal de-Q function.
* If the previous data set was not written
* completely, return that skb which has the pending data.
* In normal cases, return top of txq.
*/
struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata)
{
struct sk_buff *returning_skb;

pr_debug("%s", __func__);
/* if the previous skb wasn't written completely
*/
if (st_gdata->tx_skb != NULL) {
returning_skb = st_gdata->tx_skb;
st_gdata->tx_skb = NULL;
return returning_skb;
}

/* de-Q from the txQ always if previous write is complete */
return skb_dequeue(&st_gdata->txq);
}

/* internal Q-ing function
* will either Q the skb to txq or the tx_waitq
* depending on the ST LL state
*
* lock the whole func - since ll_getstate and Q-ing should happen
* in one-shot
/**
* st_int_enqueue - internal Q-ing function.
* Will either Q the skb to txq or the tx_waitq
* depending on the ST LL state.
* If the chip is asleep, then Q it onto waitq and
* wakeup the chip.
* txq and waitq needs protection since the other contexts
* may be sending data, waking up chip.
*/
void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
{
unsigned long flags = 0;

pr_debug("%s", __func__);
/* this function can be invoked in more then one context.
* so have a lock */
spin_lock_irqsave(&st_gdata->lock, flags);

switch (st_ll_getstate(st_gdata)) {
Expand All @@ -483,16 +488,12 @@ void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
case ST_LL_ASLEEP_TO_AWAKE:
skb_queue_tail(&st_gdata->tx_waitq, skb);
break;
case ST_LL_AWAKE_TO_ASLEEP: /* host cannot be in this state */
case ST_LL_AWAKE_TO_ASLEEP:
pr_err("ST LL is illegal state(%ld),"
"purging received skb.", st_ll_getstate(st_gdata));
kfree_skb(skb);
break;

case ST_LL_ASLEEP:
/* call a function of ST LL to put data
* in tx_waitQ and wake_ind in txQ
*/
skb_queue_tail(&st_gdata->tx_waitq, skb);
st_ll_wakeup(st_gdata);
break;
Expand All @@ -502,6 +503,7 @@ void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
kfree_skb(skb);
break;
}

spin_unlock_irqrestore(&st_gdata->lock, flags);
pr_debug("done %s", __func__);
return;
Expand Down
74 changes: 51 additions & 23 deletions drivers/staging/ti-st/st_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,59 +36,87 @@
#define ST_REG_PENDING 3
#define ST_WAITING_FOR_RESP 4

/*
* local data required for ST/KIM/ST-HCI-LL
/**
* struct st_data_s - ST core internal structure
* @st_state: different states of ST like initializing, registration
* in progress, this is mainly used to return relevant err codes
* when protocol drivers are registering. It is also used to track
* the recv function, as in during fw download only HCI events
* can occur , where as during other times other events CH8, CH9
* can occur.
* @tty: tty provided by the TTY core for line disciplines.
* @ldisc_ops: the procedures that this line discipline registers with TTY.
* @tx_skb: If for some reason the tty's write returns lesser bytes written
* then to maintain the rest of data to be written on next instance.
* This needs to be protected, hence the lock inside wakeup func.
* @tx_state: if the data is being written onto the TTY and protocol driver
* wants to send more, queue up data and mark that there is
* more data to send.
* @list: the list of protocols registered, only MAX can exist, one protocol
* can register only once.
* @rx_state: states to be maintained inside st's tty receive
* @rx_count: count to be maintained inside st's tty receieve
* @rx_skb: the skb where all data for a protocol gets accumulated,
* since tty might not call receive when a complete event packet
* is received, the states, count and the skb needs to be maintained.
* @txq: the list of skbs which needs to be sent onto the TTY.
* @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
* up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
* from waitq can be moved onto the txq.
* Needs locking too.
* @lock: the lock to protect skbs, queues, and ST states.
* @protos_registered: count of the protocols registered, also when 0 the
* chip enable gpio can be toggled, and when it changes to 1 the fw
* needs to be downloaded to initialize chip side ST.
* @ll_state: the various PM states the chip can be, the states are notified
* to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
* @kim_data: reference to the parent encapsulating structure.
*
*/
struct st_data_s {
unsigned long st_state;
/*
* an instance of tty_struct & ldisc ops to move around
*/
struct tty_struct *tty;
struct tty_ldisc_ops *ldisc_ops;
/*
* the tx skb -
* if the skb is already dequeued and the tty failed to write the same
* maintain the skb to write in the next transaction
*/
struct sk_buff *tx_skb;
#define ST_TX_SENDING 1
#define ST_TX_WAKEUP 2
unsigned long tx_state;
/*
* list of protocol registered
*/
struct st_proto_s *list[ST_MAX];
/*
* lock
*/
unsigned long rx_state;
unsigned long rx_count;
struct sk_buff *rx_skb;
struct sk_buff_head txq, tx_waitq;
spinlock_t lock; /* ST LL state lock */
spinlock_t lock;
unsigned char protos_registered;
unsigned long ll_state; /* ST LL power state */
/* device reference to kim data */
unsigned long ll_state;
void *kim_data;
};

/* point this to tty->driver->write or tty->ops->write
/**
* st_int_write -
* point this to tty->driver->write or tty->ops->write
* depending upon the kernel version
*/
int st_int_write(struct st_data_s*, const unsigned char*, int);
/* internal write function, passed onto protocol drivers

/**
* st_write -
* internal write function, passed onto protocol drivers
* via the write function ptr of protocol struct
*/
long st_write(struct sk_buff *);
/* function to be called from ST-LL
*/

/* function to be called from ST-LL */
void st_ll_send_frame(enum proto_type, struct sk_buff *);

/* internal wake up function */
void st_tx_wakeup(struct st_data_s *st_data);

/* init, exit entry funcs called from KIM */
int st_core_init(struct st_data_s **);
void st_core_exit(struct st_data_s *);

/* ask for reference from KIM */
void st_kim_ref(struct st_data_s **);

#define GPS_STUB_TEST
Expand Down
Loading

0 comments on commit 36b5aee

Please sign in to comment.