pkarashchenko commented on code in PR #6344:
URL: https://github.com/apache/incubator-nuttx/pull/6344#discussion_r884886624
##########
drivers/video/isx012.c:
##########
@@ -215,8 +220,10 @@ static bool is_movie_needed(uint8_t fmt, uint8_t fps);
/* image sensor device operations interface */
+static bool isx012_is_available(void);
static int isx012_init(void);
static int isx012_uninit(void);
+static const char *isx012_get_driver_name(void);
Review Comment:
```suggestion
static FAR const char *isx012_get_driver_name(void);
```
##########
drivers/video/isx012.c:
##########
@@ -628,6 +637,16 @@ static struct imgsensor_ops_s g_isx012_ops =
* Private Functions
****************************************************************************/
+static void i2c_lock(void)
+{
+ nxsem_wait_uninterruptible(&g_isx012_private.i2c_lock);
+}
+
+static void i2c_unlock(void)
+{
+ nxsem_post(&g_isx012_private.i2c_lock);
+}
+
static uint16_t isx012_getreg(isx012_dev_t *priv,
Review Comment:
```suggestion
static uint16_t isx012_getreg(FAR isx012_dev_t *priv,
```
##########
drivers/video/isx012.c:
##########
@@ -644,26 +663,33 @@ static uint16_t isx012_getreg(isx012_dev_t *priv,
buffer[0] = regaddr >> 8;
buffer[1] = regaddr & 0xff;
+ i2c_lock();
+
/* Write the register address */
ret = i2c_write(priv->i2c, &config, (uint8_t *)buffer, 2);
if (ret < 0)
{
verr("i2c_write failed: %d\n", ret);
- return 0;
+ }
+ else
+ {
+ /* Restart and read 16bits from the register */
+
+ ret = i2c_read(priv->i2c, &config, (uint8_t *)buffer, regsize);
Review Comment:
```suggestion
ret = i2c_read(priv->i2c, &config, (FAR uint8_t *)buffer, regsize);
```
##########
drivers/video/isx012.c:
##########
@@ -644,26 +663,33 @@ static uint16_t isx012_getreg(isx012_dev_t *priv,
buffer[0] = regaddr >> 8;
buffer[1] = regaddr & 0xff;
+ i2c_lock();
+
/* Write the register address */
ret = i2c_write(priv->i2c, &config, (uint8_t *)buffer, 2);
if (ret < 0)
{
verr("i2c_write failed: %d\n", ret);
- return 0;
+ }
+ else
+ {
+ /* Restart and read 16bits from the register */
+
+ ret = i2c_read(priv->i2c, &config, (uint8_t *)buffer, regsize);
+ if (ret < 0)
+ {
+ verr("i2c_read failed: %d\n", ret);
+ }
}
- /* Restart and read 16bits from the register */
+ i2c_unlock();
- ret = i2c_read(priv->i2c, &config, (uint8_t *)buffer, regsize);
- if (ret < 0)
+ if (ret >= 0)
{
- verr("i2c_read failed: %d\n", ret);
- return 0;
+ memcpy((uint8_t *)®val, (uint8_t *)buffer, regsize);
Review Comment:
```suggestion
memcpy((FAR uint8_t *)®val, (FAR uint8_t *)buffer, regsize);
```
##########
drivers/video/isx012.c:
##########
@@ -1278,12 +1329,19 @@ static int isx012_uninit(void)
return ret;
}
+ board_isx012_uninitialize(priv->i2c);
+
priv->i2c_freq = I2CFREQ_STANDARD;
priv->state = STATE_ISX012_POWEROFF;
return ret;
}
+static const char *isx012_get_driver_name(void)
Review Comment:
```suggestion
static FAR const char *isx012_get_driver_name(void)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]