aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wimax/i2400m/driver.c
diff options
context:
space:
mode:
authorInaky Perez-Gonzalez <inaky@linux.intel.com>2009-09-14 16:29:32 -0400
committerInaky Perez-Gonzalez <inaky@linux.intel.com>2009-10-19 02:56:00 -0400
commitb0fbcb2a0b54ee201fa8af61fdebe14c050f18fe (patch)
tree81ad0f43ffd45e3d677c2bc0da50af8c9ee1de58 /drivers/net/wimax/i2400m/driver.c
parent7329012e673231dee9a21567cfb9881f5ea462ba (diff)
wimax/i2400m: clean up & add a payload argument to i2400m_schedule_work()
Forthcoming commits use having a payload argument added to i2400m_schedule_work(), which then becomes nearly identical to i2400m_queue_work(). This patch thus cleans up both's implementation, making it share common helpers and adding the payload argument to i2400m_schedule_work(). Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Diffstat (limited to 'drivers/net/wimax/i2400m/driver.c')
-rw-r--r--drivers/net/wimax/i2400m/driver.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c
index 73f45ea010a7..5803a2bfd6af 100644
--- a/drivers/net/wimax/i2400m/driver.c
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -107,6 +107,24 @@ MODULE_PARM_DESC(barkers,
107 "signal; values are appended to a list--setting one value " 107 "signal; values are appended to a list--setting one value "
108 "as zero cleans the existing list and starts a new one."); 108 "as zero cleans the existing list and starts a new one.");
109 109
110static
111struct i2400m_work *__i2400m_work_setup(
112 struct i2400m *i2400m, void (*fn)(struct work_struct *),
113 gfp_t gfp_flags, const void *pl, size_t pl_size)
114{
115 struct i2400m_work *iw;
116
117 iw = kzalloc(sizeof(*iw) + pl_size, gfp_flags);
118 if (iw == NULL)
119 return NULL;
120 iw->i2400m = i2400m_get(i2400m);
121 iw->pl_size = pl_size;
122 memcpy(iw->pl, pl, pl_size);
123 INIT_WORK(&iw->ws, fn);
124 return iw;
125}
126
127
110/** 128/**
111 * i2400m_queue_work - schedule work on a i2400m's queue 129 * i2400m_queue_work - schedule work on a i2400m's queue
112 * 130 *
@@ -166,14 +184,12 @@ int i2400m_queue_work(struct i2400m *i2400m,
166 184
167 BUG_ON(i2400m->work_queue == NULL); 185 BUG_ON(i2400m->work_queue == NULL);
168 result = -ENOMEM; 186 result = -ENOMEM;
169 iw = kzalloc(sizeof(*iw) + pl_size, gfp_flags); 187 iw = __i2400m_work_setup(i2400m, fn, gfp_flags, pl, pl_size);
170 if (iw == NULL) 188 if (iw != NULL) {
171 goto error_kzalloc; 189 result = queue_work(i2400m->work_queue, &iw->ws);
172 iw->i2400m = i2400m_get(i2400m); 190 if (WARN_ON(result == 0))
173 memcpy(iw->pl, pl, pl_size); 191 result = -ENXIO;
174 INIT_WORK(&iw->ws, fn); 192 }
175 result = queue_work(i2400m->work_queue, &iw->ws);
176error_kzalloc:
177 return result; 193 return result;
178} 194}
179EXPORT_SYMBOL_GPL(i2400m_queue_work); 195EXPORT_SYMBOL_GPL(i2400m_queue_work);
@@ -192,21 +208,19 @@ EXPORT_SYMBOL_GPL(i2400m_queue_work);
192 * it should not happen. 208 * it should not happen.
193 */ 209 */
194int i2400m_schedule_work(struct i2400m *i2400m, 210int i2400m_schedule_work(struct i2400m *i2400m,
195 void (*fn)(struct work_struct *), gfp_t gfp_flags) 211 void (*fn)(struct work_struct *), gfp_t gfp_flags,
212 const void *pl, size_t pl_size)
196{ 213{
197 int result; 214 int result;
198 struct i2400m_work *iw; 215 struct i2400m_work *iw;
199 216
200 result = -ENOMEM; 217 result = -ENOMEM;
201 iw = kzalloc(sizeof(*iw), gfp_flags); 218 iw = __i2400m_work_setup(i2400m, fn, gfp_flags, pl, pl_size);
202 if (iw == NULL) 219 if (iw != NULL) {
203 goto error_kzalloc; 220 result = schedule_work(&iw->ws);
204 iw->i2400m = i2400m_get(i2400m); 221 if (WARN_ON(result == 0))
205 INIT_WORK(&iw->ws, fn); 222 result = -ENXIO;
206 result = schedule_work(&iw->ws); 223 }
207 if (result == 0)
208 result = -ENXIO;
209error_kzalloc:
210 return result; 224 return result;
211} 225}
212 226
@@ -630,7 +644,7 @@ int i2400m_dev_reset_handle(struct i2400m *i2400m)
630 i2400m->boot_mode = 1; 644 i2400m->boot_mode = 1;
631 wmb(); /* Make sure i2400m_msg_to_dev() sees boot_mode */ 645 wmb(); /* Make sure i2400m_msg_to_dev() sees boot_mode */
632 return i2400m_schedule_work(i2400m, __i2400m_dev_reset_handle, 646 return i2400m_schedule_work(i2400m, __i2400m_dev_reset_handle,
633 GFP_ATOMIC); 647 GFP_ATOMIC, NULL, 0);
634} 648}
635EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle); 649EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
636 650