diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2013-02-06 07:06:44 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-02-06 14:24:33 -0500 |
commit | 074b4c01abb68c6767612a01f41e9b4ed93d5fb8 (patch) | |
tree | be333e9d5b652e7dab23e1fb8d7f57255b3e5729 /drivers/misc | |
parent | 330dd7da5ec80e2c49c66bf353d8b4fa4fb8f5a9 (diff) |
mei: move clients cleanup code from init.c to client.c
during reset we clean up client data structures
we move that code into wrappers in client
and call the wrappers
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/mei/client.c | 51 | ||||
-rw-r--r-- | drivers/misc/mei/client.h | 5 | ||||
-rw-r--r-- | drivers/misc/mei/init.c | 28 |
3 files changed, 62 insertions, 22 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index e46663ee76de..1569afe935de 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -676,3 +676,54 @@ err: | |||
676 | return rets; | 676 | return rets; |
677 | } | 677 | } |
678 | 678 | ||
679 | /** | ||
680 | * mei_cl_all_disconnect - disconnect forcefully all connected clients | ||
681 | * | ||
682 | * @dev - mei device | ||
683 | */ | ||
684 | |||
685 | void mei_cl_all_disconnect(struct mei_device *dev) | ||
686 | { | ||
687 | struct mei_cl *cl, *next; | ||
688 | |||
689 | list_for_each_entry_safe(cl, next, &dev->file_list, link) { | ||
690 | cl->state = MEI_FILE_DISCONNECTED; | ||
691 | cl->mei_flow_ctrl_creds = 0; | ||
692 | cl->read_cb = NULL; | ||
693 | cl->timer_count = 0; | ||
694 | } | ||
695 | } | ||
696 | |||
697 | |||
698 | /** | ||
699 | * mei_cl_all_read_wakeup - wake up all readings so they can be interrupted | ||
700 | * | ||
701 | * @dev - mei device | ||
702 | */ | ||
703 | void mei_cl_all_read_wakeup(struct mei_device *dev) | ||
704 | { | ||
705 | struct mei_cl *cl, *next; | ||
706 | list_for_each_entry_safe(cl, next, &dev->file_list, link) { | ||
707 | if (waitqueue_active(&cl->rx_wait)) { | ||
708 | dev_dbg(&dev->pdev->dev, "Waking up client!\n"); | ||
709 | wake_up_interruptible(&cl->rx_wait); | ||
710 | } | ||
711 | } | ||
712 | } | ||
713 | |||
714 | /** | ||
715 | * mei_cl_all_write_clear - clear all pending writes | ||
716 | |||
717 | * @dev - mei device | ||
718 | */ | ||
719 | void mei_cl_all_write_clear(struct mei_device *dev) | ||
720 | { | ||
721 | struct mei_cl_cb *cb, *next; | ||
722 | |||
723 | list_for_each_entry_safe(cb, next, &dev->write_list.list, list) { | ||
724 | list_del(&cb->list); | ||
725 | mei_io_cb_free(cb); | ||
726 | } | ||
727 | } | ||
728 | |||
729 | |||
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h index 240a1f321342..214b2397ec3e 100644 --- a/drivers/misc/mei/client.h +++ b/drivers/misc/mei/client.h | |||
@@ -94,4 +94,9 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file); | |||
94 | void mei_host_client_init(struct work_struct *work); | 94 | void mei_host_client_init(struct work_struct *work); |
95 | 95 | ||
96 | 96 | ||
97 | void mei_cl_all_disconnect(struct mei_device *dev); | ||
98 | void mei_cl_all_read_wakeup(struct mei_device *dev); | ||
99 | void mei_cl_all_write_clear(struct mei_device *dev); | ||
100 | |||
101 | |||
97 | #endif /* _MEI_CLIENT_H_ */ | 102 | #endif /* _MEI_CLIENT_H_ */ |
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 51a005e80952..6ec530168afb 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -135,10 +135,6 @@ err: | |||
135 | */ | 135 | */ |
136 | void mei_reset(struct mei_device *dev, int interrupts_enabled) | 136 | void mei_reset(struct mei_device *dev, int interrupts_enabled) |
137 | { | 137 | { |
138 | struct mei_cl *cl_pos = NULL; | ||
139 | struct mei_cl *cl_next = NULL; | ||
140 | struct mei_cl_cb *cb_pos = NULL; | ||
141 | struct mei_cl_cb *cb_next = NULL; | ||
142 | bool unexpected; | 138 | bool unexpected; |
143 | 139 | ||
144 | if (dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) | 140 | if (dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) |
@@ -157,13 +153,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
157 | dev->dev_state != MEI_DEV_POWER_DOWN) | 153 | dev->dev_state != MEI_DEV_POWER_DOWN) |
158 | dev->dev_state = MEI_DEV_RESETING; | 154 | dev->dev_state = MEI_DEV_RESETING; |
159 | 155 | ||
160 | list_for_each_entry_safe(cl_pos, | 156 | mei_cl_all_disconnect(dev); |
161 | cl_next, &dev->file_list, link) { | 157 | |
162 | cl_pos->state = MEI_FILE_DISCONNECTED; | ||
163 | cl_pos->mei_flow_ctrl_creds = 0; | ||
164 | cl_pos->read_cb = NULL; | ||
165 | cl_pos->timer_count = 0; | ||
166 | } | ||
167 | /* remove entry if already in list */ | 158 | /* remove entry if already in list */ |
168 | dev_dbg(&dev->pdev->dev, "remove iamthif and wd from the file list.\n"); | 159 | dev_dbg(&dev->pdev->dev, "remove iamthif and wd from the file list.\n"); |
169 | mei_cl_unlink(&dev->wd_cl); | 160 | mei_cl_unlink(&dev->wd_cl); |
@@ -185,18 +176,11 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
185 | dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n", | 176 | dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n", |
186 | mei_dev_state_str(dev->dev_state)); | 177 | mei_dev_state_str(dev->dev_state)); |
187 | 178 | ||
188 | /* Wake up all readings so they can be interrupted */ | 179 | /* wake up all readings so they can be interrupted */ |
189 | list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { | 180 | mei_cl_all_read_wakeup(dev); |
190 | if (waitqueue_active(&cl_pos->rx_wait)) { | 181 | |
191 | dev_dbg(&dev->pdev->dev, "Waking up client!\n"); | ||
192 | wake_up_interruptible(&cl_pos->rx_wait); | ||
193 | } | ||
194 | } | ||
195 | /* remove all waiting requests */ | 182 | /* remove all waiting requests */ |
196 | list_for_each_entry_safe(cb_pos, cb_next, &dev->write_list.list, list) { | 183 | mei_cl_all_write_clear(dev); |
197 | list_del(&cb_pos->list); | ||
198 | mei_io_cb_free(cb_pos); | ||
199 | } | ||
200 | } | 184 | } |
201 | 185 | ||
202 | 186 | ||