[PATCH 6/9] em28xx: move the probing of Micron sensors to a separate function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Other sensors like the ones from OmniVision need a different probing procedure,
so it makes sense have separate functions for each manufacturer/sensor type.

Signed-off-by: Frank Schäfer <fschaefer.oss@xxxxxxxxxxxxxx>
---
 drivers/media/usb/em28xx/em28xx-camera.c |   23 +++++++++++++++++++----
 1 Datei geändert, 19 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index 2e4856a..d744af6 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -83,9 +83,9 @@ static int em28xx_initialize_mt9m001(struct em28xx *dev)
 
 
 /*
- * This method works for webcams with Micron sensors
+ * Probes Micron sensors with 8 bit address and 16 bit register width
  */
-int em28xx_detect_sensor(struct em28xx *dev)
+static int em28xx_probe_sensor_micron(struct em28xx *dev)
 {
 	int ret, i;
 	char *name;
@@ -96,7 +96,6 @@ int em28xx_detect_sensor(struct em28xx *dev)
 	struct i2c_client client = dev->i2c_client[dev->def_i2c_bus];
 
 	dev->em28xx_sensor = EM28XX_NOSENSOR;
-	/* Probe Micron sensors with 8 bit address and 16 bit register width */
 	for (i = 0; micron_sensor_addrs[i] != I2C_CLIENT_END; i++) {
 		client.addr = micron_sensor_addrs[i];
 		/* NOTE: i2c_smbus_read_word_data() doesn't work with BE data */
@@ -167,7 +166,7 @@ int em28xx_detect_sensor(struct em28xx *dev)
 		default:
 			em28xx_info("unknown Micron sensor detected: 0x%04x\n",
 				    id);
-			return -EINVAL;
+			return 0;
 		}
 
 		if (dev->em28xx_sensor == EM28XX_NOSENSOR)
@@ -182,6 +181,22 @@ int em28xx_detect_sensor(struct em28xx *dev)
 	return -ENODEV;
 }
 
+/*
+ * This method works for webcams with Micron sensors
+ */
+int em28xx_detect_sensor(struct em28xx *dev)
+{
+	int ret;
+
+	ret = em28xx_probe_sensor_micron(dev);
+	if (dev->em28xx_sensor == EM28XX_NOSENSOR && ret < 0) {
+		em28xx_info("No sensor detected\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 int em28xx_init_camera(struct em28xx *dev)
 {
 	switch (dev->em28xx_sensor) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux