diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-05-09 11:13:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-14 08:43:01 -0400 |
commit | cb0988cb82f216cf7e38c374d6eaf3131debf031 (patch) | |
tree | aaabfd21e0138d2048bf97547ee4f0a14e613a4f | |
parent | a8a478601ac1d8877e23cb832fe4b44042ce6f20 (diff) |
[media] gscpa_pac207: use usb_err for error handling
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/gspca/pac207.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c index 3844c49f269c..c70b258a0ae3 100644 --- a/drivers/media/video/gspca/pac207.c +++ b/drivers/media/video/gspca/pac207.c | |||
@@ -167,39 +167,44 @@ static const __u8 pac207_sensor_init[][8] = { | |||
167 | {0x32, 0x00, 0x96, 0x00, 0xa2, 0x02, 0xaf, 0x00}, | 167 | {0x32, 0x00, 0x96, 0x00, 0xa2, 0x02, 0xaf, 0x00}, |
168 | }; | 168 | }; |
169 | 169 | ||
170 | static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, | 170 | static void pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, |
171 | const u8 *buffer, u16 length) | 171 | const u8 *buffer, u16 length) |
172 | { | 172 | { |
173 | struct usb_device *udev = gspca_dev->dev; | 173 | struct usb_device *udev = gspca_dev->dev; |
174 | int err; | 174 | int err; |
175 | 175 | ||
176 | if (gspca_dev->usb_err < 0) | ||
177 | return; | ||
178 | |||
176 | memcpy(gspca_dev->usb_buf, buffer, length); | 179 | memcpy(gspca_dev->usb_buf, buffer, length); |
177 | 180 | ||
178 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x01, | 181 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x01, |
179 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 182 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
180 | 0x00, index, | 183 | 0x00, index, |
181 | gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT); | 184 | gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT); |
182 | if (err < 0) | 185 | if (err < 0) { |
183 | pr_err("Failed to write registers to index 0x%04X, error %d\n", | 186 | pr_err("Failed to write registers to index 0x%04X, error %d\n", |
184 | index, err); | 187 | index, err); |
185 | 188 | gspca_dev->usb_err = err; | |
186 | return err; | 189 | } |
187 | } | 190 | } |
188 | 191 | ||
189 | 192 | static void pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value) | |
190 | static int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value) | ||
191 | { | 193 | { |
192 | struct usb_device *udev = gspca_dev->dev; | 194 | struct usb_device *udev = gspca_dev->dev; |
193 | int err; | 195 | int err; |
194 | 196 | ||
197 | if (gspca_dev->usb_err < 0) | ||
198 | return; | ||
199 | |||
195 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, | 200 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, |
196 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 201 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
197 | value, index, NULL, 0, PAC207_CTRL_TIMEOUT); | 202 | value, index, NULL, 0, PAC207_CTRL_TIMEOUT); |
198 | if (err) | 203 | if (err) { |
199 | pr_err("Failed to write a register (index 0x%04X, value 0x%02X, error %d)\n", | 204 | pr_err("Failed to write a register (index 0x%04X, value 0x%02X, error %d)\n", |
200 | index, value, err); | 205 | index, value, err); |
201 | 206 | gspca_dev->usb_err = err; | |
202 | return err; | 207 | } |
203 | } | 208 | } |
204 | 209 | ||
205 | static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index) | 210 | static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index) |
@@ -207,6 +212,9 @@ static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index) | |||
207 | struct usb_device *udev = gspca_dev->dev; | 212 | struct usb_device *udev = gspca_dev->dev; |
208 | int res; | 213 | int res; |
209 | 214 | ||
215 | if (gspca_dev->usb_err < 0) | ||
216 | return 0; | ||
217 | |||
210 | res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, | 218 | res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, |
211 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 219 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
212 | 0x00, index, | 220 | 0x00, index, |
@@ -214,7 +222,8 @@ static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index) | |||
214 | if (res < 0) { | 222 | if (res < 0) { |
215 | pr_err("Failed to read a register (index 0x%04X, error %d)\n", | 223 | pr_err("Failed to read a register (index 0x%04X, error %d)\n", |
216 | index, res); | 224 | index, res); |
217 | return res; | 225 | gspca_dev->usb_err = res; |
226 | return 0; | ||
218 | } | 227 | } |
219 | 228 | ||
220 | return gspca_dev->usb_buf[0]; | 229 | return gspca_dev->usb_buf[0]; |
@@ -264,7 +273,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
264 | * Bit_2=Compression test mode enable */ | 273 | * Bit_2=Compression test mode enable */ |
265 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ | 274 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ |
266 | 275 | ||
267 | return 0; | 276 | return gspca_dev->usb_err; |
268 | } | 277 | } |
269 | 278 | ||
270 | /* -- start the camera -- */ | 279 | /* -- start the camera -- */ |
@@ -308,7 +317,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
308 | sd->sof_read = 0; | 317 | sd->sof_read = 0; |
309 | sd->autogain_ignore_frames = 0; | 318 | sd->autogain_ignore_frames = 0; |
310 | atomic_set(&sd->avg_lum, -1); | 319 | atomic_set(&sd->avg_lum, -1); |
311 | return 0; | 320 | return gspca_dev->usb_err; |
312 | } | 321 | } |
313 | 322 | ||
314 | static void sd_stopN(struct gspca_dev *gspca_dev) | 323 | static void sd_stopN(struct gspca_dev *gspca_dev) |