mirror of https://gitee.com/openkylin/linux.git
[media] stk-webcam: fix an endian bug in stk_camera_read_reg()
We pass an int pointer to stk_camera_read_reg() but only write to the highest byte. It's a bug on big endian systems and generally a nasty thing to do and doesn't match the write function either. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
414e72c729
commit
d08876f524
|
@ -228,7 +228,7 @@
|
||||||
static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
|
static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int tmpval = 0;
|
u8 tmpval = 0;
|
||||||
|
|
||||||
if (stk_camera_write_reg(dev, STK_IIC_TX_INDEX, reg))
|
if (stk_camera_write_reg(dev, STK_IIC_TX_INDEX, reg))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -253,7 +253,7 @@ static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
|
||||||
static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
|
static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int tmpval = 0;
|
u8 tmpval = 0;
|
||||||
|
|
||||||
if (stk_camera_write_reg(dev, STK_IIC_RX_INDEX, reg))
|
if (stk_camera_write_reg(dev, STK_IIC_RX_INDEX, reg))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -274,7 +274,7 @@ static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
|
||||||
if (stk_camera_read_reg(dev, STK_IIC_RX_VALUE, &tmpval))
|
if (stk_camera_read_reg(dev, STK_IIC_RX_VALUE, &tmpval))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
*val = (u8) tmpval;
|
*val = tmpval;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ int stk_camera_write_reg(struct stk_camera *dev, u16 index, u8 value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value)
|
int stk_camera_read_reg(struct stk_camera *dev, u16 index, u8 *value)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev->udev;
|
struct usb_device *udev = dev->udev;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
@ -163,7 +163,7 @@ int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value)
|
||||||
sizeof(u8),
|
sizeof(u8),
|
||||||
500);
|
500);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
memcpy(value, buf, sizeof(u8));
|
*value = *buf;
|
||||||
|
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -171,9 +171,10 @@ int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value)
|
||||||
|
|
||||||
static int stk_start_stream(struct stk_camera *dev)
|
static int stk_start_stream(struct stk_camera *dev)
|
||||||
{
|
{
|
||||||
int value;
|
u8 value;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
int value_116, value_117;
|
u8 value_116, value_117;
|
||||||
|
|
||||||
|
|
||||||
if (!is_present(dev))
|
if (!is_present(dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -213,7 +214,7 @@ static int stk_start_stream(struct stk_camera *dev)
|
||||||
|
|
||||||
static int stk_stop_stream(struct stk_camera *dev)
|
static int stk_stop_stream(struct stk_camera *dev)
|
||||||
{
|
{
|
||||||
int value;
|
u8 value;
|
||||||
int i;
|
int i;
|
||||||
if (is_present(dev)) {
|
if (is_present(dev)) {
|
||||||
stk_camera_read_reg(dev, 0x0100, &value);
|
stk_camera_read_reg(dev, 0x0100, &value);
|
||||||
|
|
|
@ -129,7 +129,7 @@ struct stk_camera {
|
||||||
#define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
|
#define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
|
||||||
|
|
||||||
int stk_camera_write_reg(struct stk_camera *, u16, u8);
|
int stk_camera_write_reg(struct stk_camera *, u16, u8);
|
||||||
int stk_camera_read_reg(struct stk_camera *, u16, int *);
|
int stk_camera_read_reg(struct stk_camera *, u16, u8 *);
|
||||||
|
|
||||||
int stk_sensor_init(struct stk_camera *);
|
int stk_sensor_init(struct stk_camera *);
|
||||||
int stk_sensor_configure(struct stk_camera *);
|
int stk_sensor_configure(struct stk_camera *);
|
||||||
|
|
Loading…
Reference in New Issue