diff options
Diffstat (limited to 'drivers/usb/misc/emi26.c')
-rw-r--r-- | drivers/usb/misc/emi26.c | 59 |
1 files changed, 18 insertions, 41 deletions
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index da97dcec1f3..d65984dee75 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -78,18 +78,14 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
78 | const struct firmware *bitstream_fw = NULL; | 78 | const struct firmware *bitstream_fw = NULL; |
79 | const struct firmware *firmware_fw = NULL; | 79 | const struct firmware *firmware_fw = NULL; |
80 | const struct ihex_binrec *rec; | 80 | const struct ihex_binrec *rec; |
81 | int err; | 81 | int err = -ENOMEM; |
82 | int i; | 82 | int i; |
83 | __u32 addr; /* Address to write */ | 83 | __u32 addr; /* Address to write */ |
84 | __u8 *buf; | 84 | __u8 *buf; |
85 | 85 | ||
86 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); | 86 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); |
87 | if (!buf) { | 87 | if (!buf) |
88 | dev_err(&dev->dev, "%s - error loading firmware: error = %d\n", | ||
89 | __func__, -ENOMEM); | ||
90 | err = -ENOMEM; | ||
91 | goto wraperr; | 88 | goto wraperr; |
92 | } | ||
93 | 89 | ||
94 | err = request_ihex_firmware(&loader_fw, "emi26/loader.fw", &dev->dev); | 90 | err = request_ihex_firmware(&loader_fw, "emi26/loader.fw", &dev->dev); |
95 | if (err) | 91 | if (err) |
@@ -111,11 +107,8 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
111 | 107 | ||
112 | /* Assert reset (stop the CPU in the EMI) */ | 108 | /* Assert reset (stop the CPU in the EMI) */ |
113 | err = emi26_set_reset(dev,1); | 109 | err = emi26_set_reset(dev,1); |
114 | if (err < 0) { | 110 | if (err < 0) |
115 | dev_err(&dev->dev,"%s - error loading firmware: error = %d\n", | ||
116 | __func__, err); | ||
117 | goto wraperr; | 111 | goto wraperr; |
118 | } | ||
119 | 112 | ||
120 | rec = (const struct ihex_binrec *)loader_fw->data; | 113 | rec = (const struct ihex_binrec *)loader_fw->data; |
121 | /* 1. We need to put the loader for the FPGA into the EZ-USB */ | 114 | /* 1. We need to put the loader for the FPGA into the EZ-USB */ |
@@ -123,19 +116,15 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
123 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), | 116 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), |
124 | rec->data, be16_to_cpu(rec->len), | 117 | rec->data, be16_to_cpu(rec->len), |
125 | ANCHOR_LOAD_INTERNAL); | 118 | ANCHOR_LOAD_INTERNAL); |
126 | if (err < 0) { | 119 | if (err < 0) |
127 | err("%s - error loading firmware: error = %d", __func__, err); | ||
128 | goto wraperr; | 120 | goto wraperr; |
129 | } | ||
130 | rec = ihex_next_binrec(rec); | 121 | rec = ihex_next_binrec(rec); |
131 | } | 122 | } |
132 | 123 | ||
133 | /* De-assert reset (let the CPU run) */ | 124 | /* De-assert reset (let the CPU run) */ |
134 | err = emi26_set_reset(dev,0); | 125 | err = emi26_set_reset(dev,0); |
135 | if (err < 0) { | 126 | if (err < 0) |
136 | err("%s - error loading firmware: error = %d", __func__, err); | ||
137 | goto wraperr; | 127 | goto wraperr; |
138 | } | ||
139 | msleep(250); /* let device settle */ | 128 | msleep(250); /* let device settle */ |
140 | 129 | ||
141 | /* 2. We upload the FPGA firmware into the EMI | 130 | /* 2. We upload the FPGA firmware into the EMI |
@@ -153,18 +142,14 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
153 | rec = ihex_next_binrec(rec); | 142 | rec = ihex_next_binrec(rec); |
154 | } | 143 | } |
155 | err = emi26_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); | 144 | err = emi26_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); |
156 | if (err < 0) { | 145 | if (err < 0) |
157 | err("%s - error loading firmware: error = %d", __func__, err); | ||
158 | goto wraperr; | 146 | goto wraperr; |
159 | } | ||
160 | } while (rec); | 147 | } while (rec); |
161 | 148 | ||
162 | /* Assert reset (stop the CPU in the EMI) */ | 149 | /* Assert reset (stop the CPU in the EMI) */ |
163 | err = emi26_set_reset(dev,1); | 150 | err = emi26_set_reset(dev,1); |
164 | if (err < 0) { | 151 | if (err < 0) |
165 | err("%s - error loading firmware: error = %d", __func__, err); | ||
166 | goto wraperr; | 152 | goto wraperr; |
167 | } | ||
168 | 153 | ||
169 | /* 3. We need to put the loader for the firmware into the EZ-USB (again...) */ | 154 | /* 3. We need to put the loader for the firmware into the EZ-USB (again...) */ |
170 | for (rec = (const struct ihex_binrec *)loader_fw->data; | 155 | for (rec = (const struct ihex_binrec *)loader_fw->data; |
@@ -172,19 +157,15 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
172 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), | 157 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), |
173 | rec->data, be16_to_cpu(rec->len), | 158 | rec->data, be16_to_cpu(rec->len), |
174 | ANCHOR_LOAD_INTERNAL); | 159 | ANCHOR_LOAD_INTERNAL); |
175 | if (err < 0) { | 160 | if (err < 0) |
176 | err("%s - error loading firmware: error = %d", __func__, err); | ||
177 | goto wraperr; | 161 | goto wraperr; |
178 | } | ||
179 | } | 162 | } |
180 | msleep(250); /* let device settle */ | 163 | msleep(250); /* let device settle */ |
181 | 164 | ||
182 | /* De-assert reset (let the CPU run) */ | 165 | /* De-assert reset (let the CPU run) */ |
183 | err = emi26_set_reset(dev,0); | 166 | err = emi26_set_reset(dev,0); |
184 | if (err < 0) { | 167 | if (err < 0) |
185 | err("%s - error loading firmware: error = %d", __func__, err); | ||
186 | goto wraperr; | 168 | goto wraperr; |
187 | } | ||
188 | 169 | ||
189 | /* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */ | 170 | /* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */ |
190 | 171 | ||
@@ -194,19 +175,15 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
194 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), | 175 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), |
195 | rec->data, be16_to_cpu(rec->len), | 176 | rec->data, be16_to_cpu(rec->len), |
196 | ANCHOR_LOAD_EXTERNAL); | 177 | ANCHOR_LOAD_EXTERNAL); |
197 | if (err < 0) { | 178 | if (err < 0) |
198 | err("%s - error loading firmware: error = %d", __func__, err); | ||
199 | goto wraperr; | 179 | goto wraperr; |
200 | } | ||
201 | } | 180 | } |
202 | } | 181 | } |
203 | 182 | ||
204 | /* Assert reset (stop the CPU in the EMI) */ | 183 | /* Assert reset (stop the CPU in the EMI) */ |
205 | err = emi26_set_reset(dev,1); | 184 | err = emi26_set_reset(dev,1); |
206 | if (err < 0) { | 185 | if (err < 0) |
207 | err("%s - error loading firmware: error = %d", __func__, err); | ||
208 | goto wraperr; | 186 | goto wraperr; |
209 | } | ||
210 | 187 | ||
211 | for (rec = (const struct ihex_binrec *)firmware_fw->data; | 188 | for (rec = (const struct ihex_binrec *)firmware_fw->data; |
212 | rec; rec = ihex_next_binrec(rec)) { | 189 | rec; rec = ihex_next_binrec(rec)) { |
@@ -214,19 +191,15 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
214 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), | 191 | err = emi26_writememory(dev, be32_to_cpu(rec->addr), |
215 | rec->data, be16_to_cpu(rec->len), | 192 | rec->data, be16_to_cpu(rec->len), |
216 | ANCHOR_LOAD_INTERNAL); | 193 | ANCHOR_LOAD_INTERNAL); |
217 | if (err < 0) { | 194 | if (err < 0) |
218 | err("%s - error loading firmware: error = %d", __func__, err); | ||
219 | goto wraperr; | 195 | goto wraperr; |
220 | } | ||
221 | } | 196 | } |
222 | } | 197 | } |
223 | 198 | ||
224 | /* De-assert reset (let the CPU run) */ | 199 | /* De-assert reset (let the CPU run) */ |
225 | err = emi26_set_reset(dev,0); | 200 | err = emi26_set_reset(dev,0); |
226 | if (err < 0) { | 201 | if (err < 0) |
227 | err("%s - error loading firmware: error = %d", __func__, err); | ||
228 | goto wraperr; | 202 | goto wraperr; |
229 | } | ||
230 | msleep(250); /* let device settle */ | 203 | msleep(250); /* let device settle */ |
231 | 204 | ||
232 | /* return 1 to fail the driver inialization | 205 | /* return 1 to fail the driver inialization |
@@ -234,6 +207,10 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
234 | err = 1; | 207 | err = 1; |
235 | 208 | ||
236 | wraperr: | 209 | wraperr: |
210 | if (err < 0) | ||
211 | dev_err(&dev->dev,"%s - error loading firmware: error = %d\n", | ||
212 | __func__, err); | ||
213 | |||
237 | release_firmware(loader_fw); | 214 | release_firmware(loader_fw); |
238 | release_firmware(bitstream_fw); | 215 | release_firmware(bitstream_fw); |
239 | release_firmware(firmware_fw); | 216 | release_firmware(firmware_fw); |