diff options
author | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-09-14 16:29:32 -0400 |
---|---|---|
committer | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-10-19 02:56:00 -0400 |
commit | b0fbcb2a0b54ee201fa8af61fdebe14c050f18fe (patch) | |
tree | 81ad0f43ffd45e3d677c2bc0da50af8c9ee1de58 /drivers/net/wimax/i2400m | |
parent | 7329012e673231dee9a21567cfb9881f5ea462ba (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')
-rw-r--r-- | drivers/net/wimax/i2400m/driver.c | 52 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/i2400m.h | 6 |
2 files changed, 37 insertions, 21 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 | ||
110 | static | ||
111 | struct 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); | ||
176 | error_kzalloc: | ||
177 | return result; | 193 | return result; |
178 | } | 194 | } |
179 | EXPORT_SYMBOL_GPL(i2400m_queue_work); | 195 | EXPORT_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 | */ |
194 | int i2400m_schedule_work(struct i2400m *i2400m, | 210 | int 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; | ||
209 | error_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 | } |
635 | EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle); | 649 | EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle); |
636 | 650 | ||
diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h index 5ac2cce88ba0..700f87be4acf 100644 --- a/drivers/net/wimax/i2400m/i2400m.h +++ b/drivers/net/wimax/i2400m/i2400m.h | |||
@@ -695,8 +695,6 @@ extern void i2400m_dev_shutdown(struct i2400m *); | |||
695 | 695 | ||
696 | extern struct attribute_group i2400m_dev_attr_group; | 696 | extern struct attribute_group i2400m_dev_attr_group; |
697 | 697 | ||
698 | extern int i2400m_schedule_work(struct i2400m *, | ||
699 | void (*)(struct work_struct *), gfp_t); | ||
700 | 698 | ||
701 | /* HDI message's payload description handling */ | 699 | /* HDI message's payload description handling */ |
702 | 700 | ||
@@ -778,10 +776,14 @@ struct device *i2400m_dev(struct i2400m *i2400m) | |||
778 | struct i2400m_work { | 776 | struct i2400m_work { |
779 | struct work_struct ws; | 777 | struct work_struct ws; |
780 | struct i2400m *i2400m; | 778 | struct i2400m *i2400m; |
779 | size_t pl_size; | ||
781 | u8 pl[0]; | 780 | u8 pl[0]; |
782 | }; | 781 | }; |
783 | extern int i2400m_queue_work(struct i2400m *, | 782 | extern int i2400m_queue_work(struct i2400m *, |
784 | void (*)(struct work_struct *), gfp_t, | 783 | void (*)(struct work_struct *), gfp_t, |
784 | const void *, size_t); | ||
785 | extern int i2400m_schedule_work(struct i2400m *, | ||
786 | void (*)(struct work_struct *), gfp_t, | ||
785 | const void *, size_t); | 787 | const void *, size_t); |
786 | 788 | ||
787 | extern int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *, | 789 | extern int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *, |