diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2015-02-10 03:39:41 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-01 22:37:00 -0500 |
commit | 331e4187017e5dc12fddfcca3f8041e5610ea23b (patch) | |
tree | 285f81afe13626373cb7c73726ee01a43df12169 /drivers/misc/mei/interrupt.c | |
parent | 8660172e1d6528be02eba78516ff8282e694bb26 (diff) |
mei: iamthif: use regular client read functions
Reduce code duplication in amthif by reusing
regular client read functions.
The change also removes the need for amthif
own buffering
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/interrupt.c')
-rw-r--r-- | drivers/misc/mei/interrupt.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 89f2fbce160f..466c1d22fb16 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -82,6 +82,24 @@ static bool mei_cl_is_reading(struct mei_cl *cl) | |||
82 | } | 82 | } |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * mei_irq_discard_msg - discard received message | ||
86 | * | ||
87 | * @dev: mei device | ||
88 | * @hdr: message header | ||
89 | */ | ||
90 | static inline | ||
91 | void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr) | ||
92 | { | ||
93 | /* | ||
94 | * no need to check for size as it is guarantied | ||
95 | * that length fits into rd_msg_buf | ||
96 | */ | ||
97 | mei_read_slots(dev, dev->rd_msg_buf, hdr->length); | ||
98 | dev_dbg(dev->dev, "discarding message " MEI_HDR_FMT "\n", | ||
99 | MEI_HDR_PRM(hdr)); | ||
100 | } | ||
101 | |||
102 | /** | ||
85 | * mei_cl_irq_read_msg - process client message | 103 | * mei_cl_irq_read_msg - process client message |
86 | * | 104 | * |
87 | * @cl: reading client | 105 | * @cl: reading client |
@@ -90,9 +108,9 @@ static bool mei_cl_is_reading(struct mei_cl *cl) | |||
90 | * | 108 | * |
91 | * Return: always 0 | 109 | * Return: always 0 |
92 | */ | 110 | */ |
93 | static int mei_cl_irq_read_msg(struct mei_cl *cl, | 111 | int mei_cl_irq_read_msg(struct mei_cl *cl, |
94 | struct mei_msg_hdr *mei_hdr, | 112 | struct mei_msg_hdr *mei_hdr, |
95 | struct mei_cl_cb *complete_list) | 113 | struct mei_cl_cb *complete_list) |
96 | { | 114 | { |
97 | struct mei_device *dev = cl->dev; | 115 | struct mei_device *dev = cl->dev; |
98 | struct mei_cl_cb *cb; | 116 | struct mei_cl_cb *cb; |
@@ -144,20 +162,17 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl, | |||
144 | mei_read_slots(dev, buffer, mei_hdr->length); | 162 | mei_read_slots(dev, buffer, mei_hdr->length); |
145 | 163 | ||
146 | cb->buf_idx += mei_hdr->length; | 164 | cb->buf_idx += mei_hdr->length; |
165 | |||
147 | if (mei_hdr->msg_complete) { | 166 | if (mei_hdr->msg_complete) { |
167 | cb->read_time = jiffies; | ||
148 | cl_dbg(dev, cl, "completed read length = %lu\n", | 168 | cl_dbg(dev, cl, "completed read length = %lu\n", |
149 | cb->buf_idx); | 169 | cb->buf_idx); |
150 | list_move_tail(&cb->list, &complete_list->list); | 170 | list_move_tail(&cb->list, &complete_list->list); |
151 | } | 171 | } |
152 | 172 | ||
153 | out: | 173 | out: |
154 | if (!buffer) { | 174 | if (!buffer) |
155 | /* assume that mei_hdr->length <= MEI_RD_MSG_BUF_SIZE */ | 175 | mei_irq_discard_msg(dev, mei_hdr); |
156 | BUG_ON(mei_hdr->length > MEI_RD_MSG_BUF_SIZE); | ||
157 | mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length); | ||
158 | dev_dbg(dev->dev, "discarding message " MEI_HDR_FMT "\n", | ||
159 | MEI_HDR_PRM(mei_hdr)); | ||
160 | } | ||
161 | 176 | ||
162 | return 0; | 177 | return 0; |
163 | } | 178 | } |
@@ -569,8 +584,6 @@ void mei_timer(struct work_struct *work) | |||
569 | if (--dev->iamthif_stall_timer == 0) { | 584 | if (--dev->iamthif_stall_timer == 0) { |
570 | dev_err(dev->dev, "timer: amthif hanged.\n"); | 585 | dev_err(dev->dev, "timer: amthif hanged.\n"); |
571 | mei_reset(dev); | 586 | mei_reset(dev); |
572 | dev->iamthif_msg_buf_size = 0; | ||
573 | dev->iamthif_msg_buf_index = 0; | ||
574 | dev->iamthif_canceled = false; | 587 | dev->iamthif_canceled = false; |
575 | dev->iamthif_state = MEI_IAMTHIF_IDLE; | 588 | dev->iamthif_state = MEI_IAMTHIF_IDLE; |
576 | dev->iamthif_timer = 0; | 589 | dev->iamthif_timer = 0; |