diff options
Diffstat (limited to 'drivers/ieee1394/hosts.c')
-rw-r--r-- | drivers/ieee1394/hosts.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index d90a3a1898c0..ee82a5320bf7 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c | |||
@@ -31,9 +31,10 @@ | |||
31 | #include "config_roms.h" | 31 | #include "config_roms.h" |
32 | 32 | ||
33 | 33 | ||
34 | static void delayed_reset_bus(void * __reset_info) | 34 | static void delayed_reset_bus(struct work_struct *work) |
35 | { | 35 | { |
36 | struct hpsb_host *host = (struct hpsb_host*)__reset_info; | 36 | struct hpsb_host *host = |
37 | container_of(work, struct hpsb_host, delayed_reset.work); | ||
37 | int generation = host->csr.generation + 1; | 38 | int generation = host->csr.generation + 1; |
38 | 39 | ||
39 | /* The generation field rolls over to 2 rather than 0 per IEEE | 40 | /* The generation field rolls over to 2 rather than 0 per IEEE |
@@ -43,9 +44,10 @@ static void delayed_reset_bus(void * __reset_info) | |||
43 | 44 | ||
44 | CSR_SET_BUS_INFO_GENERATION(host->csr.rom, generation); | 45 | CSR_SET_BUS_INFO_GENERATION(host->csr.rom, generation); |
45 | if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) { | 46 | if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) { |
46 | /* CSR image creation failed, reset generation field and do not | 47 | /* CSR image creation failed. |
47 | * issue a bus reset. */ | 48 | * Reset generation field and do not issue a bus reset. */ |
48 | CSR_SET_BUS_INFO_GENERATION(host->csr.rom, host->csr.generation); | 49 | CSR_SET_BUS_INFO_GENERATION(host->csr.rom, |
50 | host->csr.generation); | ||
49 | return; | 51 | return; |
50 | } | 52 | } |
51 | 53 | ||
@@ -53,7 +55,8 @@ static void delayed_reset_bus(void * __reset_info) | |||
53 | 55 | ||
54 | host->update_config_rom = 0; | 56 | host->update_config_rom = 0; |
55 | if (host->driver->set_hw_config_rom) | 57 | if (host->driver->set_hw_config_rom) |
56 | host->driver->set_hw_config_rom(host, host->csr.rom->bus_info_data); | 58 | host->driver->set_hw_config_rom(host, |
59 | host->csr.rom->bus_info_data); | ||
57 | 60 | ||
58 | host->csr.gen_timestamp[host->csr.generation] = jiffies; | 61 | host->csr.gen_timestamp[host->csr.generation] = jiffies; |
59 | hpsb_reset_bus(host, SHORT_RESET); | 62 | hpsb_reset_bus(host, SHORT_RESET); |
@@ -69,7 +72,8 @@ static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg) | |||
69 | return -1; | 72 | return -1; |
70 | } | 73 | } |
71 | 74 | ||
72 | static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg) | 75 | static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, |
76 | unsigned long arg) | ||
73 | { | 77 | { |
74 | return -1; | 78 | return -1; |
75 | } | 79 | } |
@@ -122,15 +126,13 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, | |||
122 | int i; | 126 | int i; |
123 | int hostnum = 0; | 127 | int hostnum = 0; |
124 | 128 | ||
125 | h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); | 129 | h = kzalloc(sizeof(*h) + extra, GFP_KERNEL); |
126 | if (!h) | 130 | if (!h) |
127 | return NULL; | 131 | return NULL; |
128 | 132 | ||
129 | h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); | 133 | h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); |
130 | if (!h->csr.rom) { | 134 | if (!h->csr.rom) |
131 | kfree(h); | 135 | goto fail; |
132 | return NULL; | ||
133 | } | ||
134 | 136 | ||
135 | h->hostdata = h + 1; | 137 | h->hostdata = h + 1; |
136 | h->driver = drv; | 138 | h->driver = drv; |
@@ -145,21 +147,20 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, | |||
145 | 147 | ||
146 | atomic_set(&h->generation, 0); | 148 | atomic_set(&h->generation, 0); |
147 | 149 | ||
148 | INIT_WORK(&h->delayed_reset, delayed_reset_bus, h); | 150 | INIT_DELAYED_WORK(&h->delayed_reset, delayed_reset_bus); |
149 | 151 | ||
150 | init_timer(&h->timeout); | 152 | init_timer(&h->timeout); |
151 | h->timeout.data = (unsigned long) h; | 153 | h->timeout.data = (unsigned long) h; |
152 | h->timeout.function = abort_timedouts; | 154 | h->timeout.function = abort_timedouts; |
153 | h->timeout_interval = HZ / 20; // 50ms by default | 155 | h->timeout_interval = HZ / 20; /* 50ms, half of minimum SPLIT_TIMEOUT */ |
154 | 156 | ||
155 | h->topology_map = h->csr.topology_map + 3; | 157 | h->topology_map = h->csr.topology_map + 3; |
156 | h->speed_map = (u8 *)(h->csr.speed_map + 2); | 158 | h->speed_map = (u8 *)(h->csr.speed_map + 2); |
157 | 159 | ||
158 | mutex_lock(&host_num_alloc); | 160 | mutex_lock(&host_num_alloc); |
159 | |||
160 | while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb)) | 161 | while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb)) |
161 | hostnum++; | 162 | hostnum++; |
162 | 163 | mutex_unlock(&host_num_alloc); | |
163 | h->id = hostnum; | 164 | h->id = hostnum; |
164 | 165 | ||
165 | memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device)); | 166 | memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device)); |
@@ -170,13 +171,19 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, | |||
170 | h->class_dev.class = &hpsb_host_class; | 171 | h->class_dev.class = &hpsb_host_class; |
171 | snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id); | 172 | snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id); |
172 | 173 | ||
173 | device_register(&h->device); | 174 | if (device_register(&h->device)) |
174 | class_device_register(&h->class_dev); | 175 | goto fail; |
176 | if (class_device_register(&h->class_dev)) { | ||
177 | device_unregister(&h->device); | ||
178 | goto fail; | ||
179 | } | ||
175 | get_device(&h->device); | 180 | get_device(&h->device); |
176 | 181 | ||
177 | mutex_unlock(&host_num_alloc); | ||
178 | |||
179 | return h; | 182 | return h; |
183 | |||
184 | fail: | ||
185 | kfree(h); | ||
186 | return NULL; | ||
180 | } | 187 | } |
181 | 188 | ||
182 | int hpsb_add_host(struct hpsb_host *host) | 189 | int hpsb_add_host(struct hpsb_host *host) |
@@ -228,13 +235,14 @@ int hpsb_update_config_rom_image(struct hpsb_host *host) | |||
228 | if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ)) | 235 | if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ)) |
229 | /* Wait 60 seconds from the last time this generation number was | 236 | /* Wait 60 seconds from the last time this generation number was |
230 | * used. */ | 237 | * used. */ |
231 | reset_delay = (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies; | 238 | reset_delay = |
239 | (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies; | ||
232 | else | 240 | else |
233 | /* Wait 1 second in case some other code wants to change the | 241 | /* Wait 1 second in case some other code wants to change the |
234 | * Config ROM in the near future. */ | 242 | * Config ROM in the near future. */ |
235 | reset_delay = HZ; | 243 | reset_delay = HZ; |
236 | 244 | ||
237 | PREPARE_WORK(&host->delayed_reset, delayed_reset_bus, host); | 245 | PREPARE_DELAYED_WORK(&host->delayed_reset, delayed_reset_bus); |
238 | schedule_delayed_work(&host->delayed_reset, reset_delay); | 246 | schedule_delayed_work(&host->delayed_reset, reset_delay); |
239 | 247 | ||
240 | return 0; | 248 | return 0; |