Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 232255
b: refs/heads/master
c: 559d162
h: refs/heads/master
i:
  232253: 5d8ad76
  232251: aae28fb
  232247: 36fcb6f
  232239: d6f9a0a
  232223: 6a39f10
  232191: 75fb186
v: v3
  • Loading branch information
Jarod Wilson authored and Mauro Carvalho Chehab committed Jan 19, 2011
1 parent 03e008f commit 54b51ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 324b04ba5da7918a2409f8113e46843bfbd89e67
refs/heads/master: 559d162e1ebcdb61e89f154f2c2db376af072b0e
30 changes: 13 additions & 17 deletions trunk/drivers/media/video/hdpvr/hdpvr-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,55 +57,51 @@ static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus,
unsigned char addr, char *data, int len)
{
int ret;
char *buf = kmalloc(len, GFP_KERNEL);
if (!buf)
return -ENOMEM;

if (len > sizeof(dev->i2c_buf))
return -EINVAL;

ret = usb_control_msg(dev->udev,
usb_rcvctrlpipe(dev->udev, 0),
REQTYPE_I2C_READ, CTRL_READ_REQUEST,
(bus << 8) | addr, 0, buf, len, 1000);
(bus << 8) | addr, 0, &dev->i2c_buf, len, 1000);

if (ret == len) {
memcpy(data, buf, len);
memcpy(data, &dev->i2c_buf, len);
ret = 0;
} else if (ret >= 0)
ret = -EIO;

kfree(buf);

return ret;
}

static int hdpvr_i2c_write(struct hdpvr_device *dev, int bus,
unsigned char addr, char *data, int len)
{
int ret;
char *buf = kmalloc(len, GFP_KERNEL);
if (!buf)
return -ENOMEM;

memcpy(buf, data, len);
if (len > sizeof(dev->i2c_buf))
return -EINVAL;

memcpy(&dev->i2c_buf, data, len);
ret = usb_control_msg(dev->udev,
usb_sndctrlpipe(dev->udev, 0),
REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST,
(bus << 8) | addr, 0, buf, len, 1000);
(bus << 8) | addr, 0, &dev->i2c_buf, len, 1000);

if (ret < 0)
goto error;
return ret;

ret = usb_control_msg(dev->udev,
usb_rcvctrlpipe(dev->udev, 0),
REQTYPE_I2C_WRITE_STATT, CTRL_READ_REQUEST,
0, 0, buf, 2, 1000);
0, 0, &dev->i2c_buf, 2, 1000);

if ((ret == 2) && (buf[1] == (len - 1)))
if ((ret == 2) && (dev->i2c_buf[1] == (len - 1)))
ret = 0;
else if (ret >= 0)
ret = -EIO;

error:
kfree(buf);
return ret;
}

Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/media/video/hdpvr/hdpvr.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE)

#define HDPVR_MAX 8
#define HDPVR_I2C_MAX_SIZE 128

/* Define these values to match your devices */
#define HD_PVR_VENDOR_ID 0x2040
Expand Down Expand Up @@ -109,6 +110,8 @@ struct hdpvr_device {
struct i2c_adapter i2c_adapter;
/* I2C lock */
struct mutex i2c_mutex;
/* I2C message buffer space */
char i2c_buf[HDPVR_I2C_MAX_SIZE];

/* For passing data to ir-kbd-i2c */
struct IR_i2c_init_data ir_i2c_init_data;
Expand Down

0 comments on commit 54b51ee

Please sign in to comment.