Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363082
b: refs/heads/master
c: c8c8d08
h: refs/heads/master
v: v3
  • Loading branch information
Tomas Winkler authored and Greg Kroah-Hartman committed Mar 15, 2013
1 parent ec5f142 commit 21658e8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 388f7bd24d2ffc945ad08be3a592672c1e32156e
refs/heads/master: c8c8d080ed94cea6757f2d781b6e360a74b256fd
11 changes: 6 additions & 5 deletions trunk/drivers/misc/mei/amthif.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
struct mei_msg_hdr mei_hdr;
struct mei_cl *cl = cb->cl;
size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
size_t msg_slots = mei_data2slots(len);
u32 msg_slots = mei_data2slots(len);

mei_hdr.host_addr = cl->host_client_id;
mei_hdr.me_addr = cl->me_client_id;
Expand Down Expand Up @@ -566,12 +566,13 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
*/
int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
{
u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));

if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr)
+ sizeof(struct hbm_flow_control))) {
if (*slots < msg_slots)
return -EMSGSIZE;
}
*slots -= mei_data2slots(sizeof(struct hbm_flow_control));

*slots -= msg_slots;

if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) {
dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
return -EIO;
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/misc/mei/hw-me.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@ static int mei_me_write_message(struct mei_device *dev,
unsigned char *buf)
{
struct mei_me_hw *hw = to_me_hw(dev);
unsigned long rem, dw_cnt;
unsigned long rem;
unsigned long length = header->length;
u32 *reg_buf = (u32 *)buf;
u32 hcsr;
u32 dw_cnt;
int i;
int empty_slots;

Expand Down
6 changes: 0 additions & 6 deletions trunk/drivers/misc/mei/hw-me.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ struct mei_me_hw {

struct mei_device *mei_me_dev_init(struct pci_dev *pdev);

/* get slots (dwords) from a message length + header (bytes) */
static inline unsigned char mei_data2slots(size_t length)
{
return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, 4);
}

irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id);
irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id);

Expand Down
50 changes: 28 additions & 22 deletions trunk/drivers/misc/mei/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,27 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
struct mei_cl *cl,
struct mei_cl_cb *cmpl_list)
{
if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
sizeof(struct hbm_client_connect_request)))
return -EBADMSG;
u32 msg_slots =
mei_data2slots(sizeof(struct hbm_client_connect_request));

*slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
if (*slots < msg_slots)
return -EMSGSIZE;

*slots -= msg_slots;

if (mei_hbm_cl_disconnect_req(dev, cl)) {
cl->status = 0;
cb_pos->buf_idx = 0;
list_move_tail(&cb_pos->list, &cmpl_list->list);
return -EMSGSIZE;
} else {
cl->state = MEI_FILE_DISCONNECTING;
cl->status = 0;
cb_pos->buf_idx = 0;
list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
cl->timer_count = MEI_CONNECT_TIMEOUT;
return -EIO;
}

cl->state = MEI_FILE_DISCONNECTING;
cl->status = 0;
cb_pos->buf_idx = 0;
list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
cl->timer_count = MEI_CONNECT_TIMEOUT;

return 0;
}

Expand All @@ -192,14 +194,15 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
struct mei_cl *cl,
struct mei_cl_cb *cmpl_list)
{
if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
sizeof(struct hbm_flow_control))) {
u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));

if (*slots < msg_slots) {
/* return the cancel routine */
list_del(&cb_pos->list);
return -EBADMSG;
return -EMSGSIZE;
}

*slots -= mei_data2slots(sizeof(struct hbm_flow_control));
*slots -= msg_slots;

if (mei_hbm_cl_flow_control_req(dev, cl)) {
cl->status = -ENODEV;
Expand Down Expand Up @@ -229,15 +232,19 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
struct mei_cl *cl,
struct mei_cl_cb *cmpl_list)
{
if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
sizeof(struct hbm_client_connect_request))) {
u32 msg_slots =
mei_data2slots(sizeof(struct hbm_client_connect_request));

if (*slots < msg_slots) {
/* return the cancel routine */
list_del(&cb_pos->list);
return -EBADMSG;
return -EMSGSIZE;
}

*slots -= msg_slots;

cl->state = MEI_FILE_CONNECTING;
*slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));

if (mei_hbm_cl_connect_req(dev, cl)) {
cl->status = -ENODEV;
cb_pos->buf_idx = 0;
Expand Down Expand Up @@ -266,7 +273,7 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
struct mei_msg_hdr mei_hdr;
struct mei_cl *cl = cb->cl;
size_t len = cb->request_buffer.size - cb->buf_idx;
size_t msg_slots = mei_data2slots(len);
u32 msg_slots = mei_data2slots(len);

mei_hdr.host_addr = cl->host_client_id;
mei_hdr.me_addr = cl->me_client_id;
Expand Down Expand Up @@ -419,8 +426,7 @@ int mei_irq_read_handler(struct mei_device *dev,
*
* returns 0 on success, <0 on failure.
*/
int mei_irq_write_handler(struct mei_device *dev,
struct mei_cl_cb *cmpl_list)
int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
{

struct mei_cl *cl;
Expand Down
11 changes: 11 additions & 0 deletions trunk/drivers/misc/mei/mei_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
return msecs_to_jiffies(sec * MSEC_PER_SEC);
}

/**
* mei_data2slots - get slots - number of (dwords) from a message length
* + size of the mei header
* @length - size of the messages in bytes
* returns - number of slots
*/
static inline u32 mei_data2slots(size_t length)
{
return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, 4);
}


/*
* mei init function prototypes
Expand Down

0 comments on commit 21658e8

Please sign in to comment.