rpms/kernel/devel hdpvr-ir-enable.patch, 1.3, 1.4 kernel.spec, 1.1763, 1.1764 lirc-2.6.31.patch, 1.2, 1.3

Jarod Wilson jwilson at fedoraproject.org
Thu Sep 3 21:02:14 UTC 2009


Author: jwilson

Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13560

Modified Files:
	hdpvr-ir-enable.patch kernel.spec lirc-2.6.31.patch 
Log Message:
* Thu Sep 03 2009 Jarod Wilson <jarod at redhat.com>
- Update hdpvr and lirc_zilog drivers for 2.6.31 i2c


hdpvr-ir-enable.patch:
 Makefile     |    4 --
 hdpvr-core.c |   12 ++------
 hdpvr-i2c.c  |   88 +++++++++++++++++++++++++++++++++++++++++------------------
 hdpvr.h      |    2 -
 4 files changed, 68 insertions(+), 38 deletions(-)

Index: hdpvr-ir-enable.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/hdpvr-ir-enable.patch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -r1.3 -r1.4
--- hdpvr-ir-enable.patch	26 Aug 2009 21:23:36 -0000	1.3
+++ hdpvr-ir-enable.patch	3 Sep 2009 21:02:14 -0000	1.4
@@ -1,10 +1,11 @@
 From http://hg.jannau.net/hdpvr/, pending v4l-dvb pull request
 
 ---
- drivers/media/video/hdpvr/Makefile     |    4 +--
- drivers/media/video/hdpvr/hdpvr-core.c |    7 ++--
- drivers/media/video/hdpvr/hdpvr-i2c.c  |   49 ++++++++++++++++++++++++++-----
- 3 files changed, 45 insertions(+), 15 deletions(-)
+ drivers/media/video/hdpvr/Makefile     |    4 +-
+ drivers/media/video/hdpvr/hdpvr-core.c |   12 ++---
+ drivers/media/video/hdpvr/hdpvr-i2c.c  |   88 ++++++++++++++++++++++---------
+ drivers/media/video/hdpvr/hdpvr.h      |    2 +-
+ 4 files changed, 68 insertions(+), 38 deletions(-)
 
 diff --git a/drivers/media/video/hdpvr/Makefile b/drivers/media/video/hdpvr/Makefile
 index e0230fc..79ad2e1 100644
@@ -19,7 +20,7 @@ index e0230fc..79ad2e1 100644
  obj-$(CONFIG_VIDEO_HDPVR) += hdpvr.o
  
 diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
-index 188bd5a..9fa3d8d 100644
+index 188bd5a..d2bb4c2 100644
 --- a/drivers/media/video/hdpvr/hdpvr-core.c
 +++ b/drivers/media/video/hdpvr/hdpvr-core.c
 @@ -362,9 +362,8 @@ static int hdpvr_probe(struct usb_interface *interface,
@@ -34,30 +35,42 @@ index 188bd5a..9fa3d8d 100644
  	if (retval < 0) {
  		v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n");
  		goto error;
-@@ -414,7 +413,7 @@ static void hdpvr_disconnect(struct usb_interface *interface)
+@@ -414,12 +413,9 @@ static void hdpvr_disconnect(struct usb_interface *interface)
  	mutex_unlock(&dev->io_mutex);
  
  	/* deregister I2C adapter */
 -#ifdef CONFIG_I2C
 +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  	mutex_lock(&dev->i2c_mutex);
- 	if (dev->i2c_adapter)
- 		i2c_del_adapter(dev->i2c_adapter);
+-	if (dev->i2c_adapter)
+-		i2c_del_adapter(dev->i2c_adapter);
+-	kfree(dev->i2c_adapter);
+-	dev->i2c_adapter = NULL;
++	i2c_del_adapter(&dev->i2c_adapter);
+ 	mutex_unlock(&dev->i2c_mutex);
+ #endif /* CONFIG_I2C */
+ 
 diff --git a/drivers/media/video/hdpvr/hdpvr-i2c.c b/drivers/media/video/hdpvr/hdpvr-i2c.c
-index c4b5d15..bc33607 100644
+index c4b5d15..7cd977f 100644
 --- a/drivers/media/video/hdpvr/hdpvr-i2c.c
 +++ b/drivers/media/video/hdpvr/hdpvr-i2c.c
-@@ -10,6 +10,8 @@
+@@ -10,6 +10,7 @@
   *
   */
  
 +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
-+
  #include <linux/i2c.h>
  
  #include "hdpvr.h"
-@@ -22,7 +24,7 @@
- #define REQTYPE_I2C_WRITE_STATT	0xd0
+@@ -19,10 +20,13 @@
+ 
+ #define REQTYPE_I2C_READ	0xb1
+ #define REQTYPE_I2C_WRITE	0xb0
+-#define REQTYPE_I2C_WRITE_STATT	0xd0
++#define REQTYPE_I2C_WRITE_STAT	0xd0
++
++#define HDPVR_HW_Z8F0811_IR_TX_I2C_ADDR	0x70
++#define HDPVR_HW_Z8F0811_IR_RX_I2C_ADDR	0x71
  
  static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr,
 -			  char *data, int len)
@@ -65,7 +78,7 @@ index c4b5d15..bc33607 100644
  {
  	int ret;
  	char *buf = kmalloc(len, GFP_KERNEL);
-@@ -32,7 +34,7 @@ static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr,
+@@ -32,7 +36,7 @@ static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr,
  	ret = usb_control_msg(dev->udev,
  			      usb_rcvctrlpipe(dev->udev, 0),
  			      REQTYPE_I2C_READ, CTRL_READ_REQUEST,
@@ -74,7 +87,7 @@ index c4b5d15..bc33607 100644
  
  	if (ret == len) {
  		memcpy(data, buf, len);
-@@ -46,7 +48,7 @@ static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr,
+@@ -46,7 +50,7 @@ static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr,
  }
  
  static int hdpvr_i2c_write(struct hdpvr_device *dev, unsigned char addr,
@@ -83,7 +96,7 @@ index c4b5d15..bc33607 100644
  {
  	int ret;
  	char *buf = kmalloc(len, GFP_KERNEL);
-@@ -57,7 +59,7 @@ static int hdpvr_i2c_write(struct hdpvr_device *dev, unsigned char addr,
+@@ -57,17 +61,17 @@ static int hdpvr_i2c_write(struct hdpvr_device *dev, unsigned char addr,
  	ret = usb_control_msg(dev->udev,
  			      usb_sndctrlpipe(dev->udev, 0),
  			      REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST,
@@ -92,7 +105,19 @@ index c4b5d15..bc33607 100644
  
  	if (ret < 0)
  		goto error;
-@@ -93,10 +95,10 @@ static int hdpvr_transfer(struct i2c_adapter *i2c_adapter, struct i2c_msg *msgs,
+ 
+ 	ret = usb_control_msg(dev->udev,
+ 			      usb_rcvctrlpipe(dev->udev, 0),
+-			      REQTYPE_I2C_WRITE_STATT, CTRL_READ_REQUEST,
++			      REQTYPE_I2C_WRITE_STAT, CTRL_READ_REQUEST,
+ 			      0, 0, buf, 2, 1000);
+ 
+-	if (ret == 2)
++	if ((ret == 2) && (buf[1] == (len - 1)))
+ 		ret = 0;
+ 	else if (ret >= 0)
+ 		ret = -EIO;
+@@ -93,10 +97,10 @@ static int hdpvr_transfer(struct i2c_adapter *i2c_adapter, struct i2c_msg *msgs,
  
  		if (msgs[i].flags & I2C_M_RD)
  			retval = hdpvr_i2c_read(dev, addr, msgs[i].buf,
@@ -105,10 +130,25 @@ index c4b5d15..bc33607 100644
  	}
  
  	mutex_unlock(&dev->i2c_mutex);
-@@ -114,15 +116,39 @@ static struct i2c_algorithm hdpvr_algo = {
+@@ -114,32 +118,64 @@ static struct i2c_algorithm hdpvr_algo = {
  	.functionality = hdpvr_functionality,
  };
  
++static struct i2c_adapter hdpvr_i2c_adap_template = {
++	.name		= "Hauppauge HD PVR I2C",
++	.owner		= THIS_MODULE,
++	.id		= I2C_HW_B_HDPVR,
++	.algo		= &hdpvr_algo,
++	.class		= I2C_CLASS_TV_ANALOG,
++};
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
++static struct i2c_board_info hdpvr_i2c_board_info = {
++	I2C_BOARD_INFO("ir_tx_z8f0811_haup", HDPVR_HW_Z8F0811_IR_TX_I2C_ADDR),
++	I2C_BOARD_INFO("ir_rx_z8f0811_haup", HDPVR_HW_Z8F0811_IR_RX_I2C_ADDR),
++};
++#endif
++
 +static int hdpvr_activate_ir(struct hdpvr_device *dev)
 +{
 +	char buffer[8];
@@ -128,41 +168,60 @@ index c4b5d15..bc33607 100644
 +	return 0;
 +}
 +
-+
  int hdpvr_register_i2c_adapter(struct hdpvr_device *dev)
  {
- 	struct i2c_adapter *i2c_adap;
-+	struct i2c_board_info info;
+-	struct i2c_adapter *i2c_adap;
  	int retval = -ENOMEM;
-+	const unsigned short addr_list[] = { 0x54, I2C_CLIENT_END };
- 
- 	i2c_adap = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
- 	if (i2c_adap == NULL)
- 		goto error;
  
+-	i2c_adap = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
+-	if (i2c_adap == NULL)
+-		goto error;
 +	hdpvr_activate_ir(dev);
 +
- 	strlcpy(i2c_adap->name, "Hauppauge HD PVR I2C",
- 		sizeof(i2c_adap->name));
- 	i2c_adap->algo  = &hdpvr_algo;
-@@ -135,11 +161,18 @@ int hdpvr_register_i2c_adapter(struct hdpvr_device *dev)
++	memcpy(&dev->i2c_adapter, &hdpvr_i2c_adap_template,
++	       sizeof(struct i2c_adapter));
  
- 	retval = i2c_add_adapter(i2c_adap);
+-	strlcpy(i2c_adap->name, "Hauppauge HD PVR I2C",
+-		sizeof(i2c_adap->name));
+-	i2c_adap->algo  = &hdpvr_algo;
+-	i2c_adap->class = I2C_CLASS_TV_ANALOG;
+-	i2c_adap->id    = I2C_HW_B_HDPVR;
+-	i2c_adap->owner = THIS_MODULE;
+-	i2c_adap->dev.parent = &dev->udev->dev;
++	dev->i2c_adapter.dev.parent = &dev->udev->dev;
+ 
+-	i2c_set_adapdata(i2c_adap, dev);
++	i2c_set_adapdata(&dev->i2c_adapter, dev);
+ 
+-	retval = i2c_add_adapter(i2c_adap);
++	retval = i2c_add_adapter(&dev->i2c_adapter);
  
 -	if (!retval)
-+	if (!retval) {
- 		dev->i2c_adapter = i2c_adap;
+-		dev->i2c_adapter = i2c_adap;
 -	else
-+		memset(&info, 0, sizeof(struct i2c_board_info));
-+		strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
-+		i2c_new_probed_device(&dev->i2c_adapter, &info, addr_list);
-+
-+	} else {
- 		kfree(i2c_adap);
-+	}
+-		kfree(i2c_adap);
++	if (retval)
++		goto error;
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
++	i2c_new_device(&dev->i2c_adapter, &hdpvr_i2c_board_info);
++#endif
  
  error:
  	return retval;
  }
 +
 +#endif /* CONFIG_I2C */
+diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h
+index 1edd875..173aefa 100644
+--- a/drivers/media/video/hdpvr/hdpvr.h
++++ b/drivers/media/video/hdpvr/hdpvr.h
+@@ -101,7 +101,7 @@ struct hdpvr_device {
+ 	struct work_struct	worker;
+ 
+ 	/* I2C adapter */
+-	struct i2c_adapter	*i2c_adapter;
++	struct i2c_adapter	i2c_adapter;
+ 	/* I2C lock */
+ 	struct mutex		i2c_mutex;
+ 


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.1763
retrieving revision 1.1764
diff -u -p -r1.1763 -r1.1764
--- kernel.spec	3 Sep 2009 14:14:21 -0000	1.1763
+++ kernel.spec	3 Sep 2009 21:02:14 -0000	1.1764
@@ -2020,6 +2020,9 @@ fi
 # and build.
 
 %changelog
+* Thu Sep 03 2009 Jarod Wilson <jarod at redhat.com>
+- Update hdpvr and lirc_zilog drivers for 2.6.31 i2c
+
 * Thu Sep 03 2009 Justin M.Forbes <jforbes at redhat.com>
 - Fix xen guest with stack protector. (#508120)
 - Small kvm fixes.

lirc-2.6.31.patch:
 MAINTAINERS                           |    9 
 drivers/input/Kconfig                 |    2 
 drivers/input/Makefile                |    2 
 drivers/input/lirc/Kconfig            |  119 +
 drivers/input/lirc/Makefile           |   21 
 drivers/input/lirc/lirc.h             |  100 +
 drivers/input/lirc/lirc_bt829.c       |  383 +++++
 drivers/input/lirc/lirc_dev.c         |  839 ++++++++++++
 drivers/input/lirc/lirc_dev.h         |  184 ++
 drivers/input/lirc/lirc_ene0100.c     |  644 +++++++++
 drivers/input/lirc/lirc_ene0100.h     |  169 ++
 drivers/input/lirc/lirc_i2c.c         |  537 +++++++
 drivers/input/lirc/lirc_igorplugusb.c |  556 ++++++++
 drivers/input/lirc/lirc_imon.c        | 2301 ++++++++++++++++++++++++++++++++++
 drivers/input/lirc/lirc_it87.c        |  986 ++++++++++++++
 drivers/input/lirc/lirc_it87.h        |  116 +
 drivers/input/lirc/lirc_ite8709.c     |  539 +++++++
 drivers/input/lirc/lirc_mceusb.c      | 1242 ++++++++++++++++++
 drivers/input/lirc/lirc_parallel.c    |  709 ++++++++++
 drivers/input/lirc/lirc_parallel.h    |   26 
 drivers/input/lirc/lirc_sasem.c       |  931 +++++++++++++
 drivers/input/lirc/lirc_serial.c      | 1316 +++++++++++++++++++
 drivers/input/lirc/lirc_sir.c         | 1283 ++++++++++++++++++
 drivers/input/lirc/lirc_streamzap.c   |  794 +++++++++++
 drivers/input/lirc/lirc_ttusbir.c     |  397 +++++
 drivers/input/lirc/lirc_zilog.c       | 1395 ++++++++++++++++++++
 26 files changed, 15600 insertions(+)

Index: lirc-2.6.31.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/lirc-2.6.31.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- lirc-2.6.31.patch	1 Sep 2009 04:44:15 -0000	1.2
+++ lirc-2.6.31.patch	3 Sep 2009 21:02:14 -0000	1.3
@@ -1,6 +1,6 @@
 Linux Infrared Remote Control drivers -- http://www.lirc.org
 
-Last updated: Tuesday, September 01, 2009
+Last updated: Thursday, September 03, 2009
 
 From http://git.wilsonet.com/linux-2.6-lirc.git/
 
@@ -24,7 +24,7 @@ Signed-off-by: Jarod Wilson <jarod at redha
  drivers/input/lirc/lirc_it87.c        |  986 ++++++++++++++
  drivers/input/lirc/lirc_it87.h        |  116 ++
  drivers/input/lirc/lirc_ite8709.c     |  539 ++++++++
- drivers/input/lirc/lirc_mceusb.c      | 1244 ++++++++++++++++++
+ drivers/input/lirc/lirc_mceusb.c      | 1242 ++++++++++++++++++
  drivers/input/lirc/lirc_parallel.c    |  709 ++++++++++
  drivers/input/lirc/lirc_parallel.h    |   26 +
  drivers/input/lirc/lirc_sasem.c       |  931 +++++++++++++
@@ -33,7 +33,7 @@ Signed-off-by: Jarod Wilson <jarod at redha
  drivers/input/lirc/lirc_streamzap.c   |  794 ++++++++++++
  drivers/input/lirc/lirc_ttusbir.c     |  397 ++++++
  drivers/input/lirc/lirc_zilog.c       | 1395 ++++++++++++++++++++
- 26 files changed, 15602 insertions(+), 0 deletions(-)
+ 26 files changed, 15600 insertions(+), 0 deletions(-)
 
 diff --git a/MAINTAINERS b/MAINTAINERS
 index 8dca9d8..f25dc26 100644
@@ -7658,10 +7658,10 @@ index 0000000..3d53181
 +MODULE_PARM_DESC(debug, "Enable debugging messages");
 diff --git a/drivers/input/lirc/lirc_mceusb.c b/drivers/input/lirc/lirc_mceusb.c
 new file mode 100644
-index 0000000..3dd4cfb
+index 0000000..8b48a56
 --- /dev/null
 +++ b/drivers/input/lirc/lirc_mceusb.c
-@@ -0,0 +1,1244 @@
+@@ -0,0 +1,1242 @@
 +/*
 + * LIRC driver for Windows Media Center Edition USB Infrared Transceivers
 + *
@@ -7675,12 +7675,12 @@ index 0000000..3dd4cfb
 + *
 + * Original lirc_mceusb driver deprecated in favor of this driver, which
 + * supports the 1st-gen device now too. Transmitting on the 1st-gen device
-+ * is as yet untested, but receiving definitely works.
++ * only functions on port #2 at the moment.
 + *
 + * Support for 1st-gen device added June 2009,
 + * by Jarod Wilson <jarod at wilsonet.com>
 + *
-+ * Transmission support for 1st-gen device added August 2009,
++ * Initial transmission support for 1st-gen device added August 2009,
 + * by Patrick Calhoun <phineas at ou.edu>
 + *
 + * Derived from ATI USB driver by Paul Miller and the original
@@ -8791,32 +8791,30 @@ index 0000000..3dd4cfb
 +		request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
 +		request_packet_async(ir, ep_out, pin_init3, sizeof(pin_init3),
 +				     MCEUSB_OUTBOUND);
-+		/* if we don't issue the correct number of receives
-+		 * (MCEUSB_INBOUND) for each outbound, then the first few ir
-+		 * pulses will be interpreted by the usb_async_callback routine
-+		 * - we should ensure we have the right amount OR less - as the
-+		 * mceusb_dev_recv routine will handle the control packets OK -
-+		 * they start with 0x9f - but the async callback doesn't handle
-+		 * ir pulse packets
-+		 */
-+		request_packet_async(ir, ep_in, NULL, maxp, 0);
-+	} else {
++	} else if (ir->flags.microsoft_gen1) {
 +		/* original ms mce device requires some additional setup */
-+		if (ir->flags.microsoft_gen1)
-+			mceusb_gen1_init(ir);
++		mceusb_gen1_init(ir);
++	} else {
 +
 +		request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
 +		request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
 +		request_packet_async(ir, ep_out, init1,
 +				     sizeof(init1), MCEUSB_OUTBOUND);
 +		request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
-+		/* This breaks transmit on orig ms mce device */
-+		if (!ir->flags.microsoft_gen1)
-+			request_packet_async(ir, ep_out, init2,
-+					     sizeof(init2), MCEUSB_OUTBOUND);
-+		request_packet_async(ir, ep_in, NULL, maxp, 0);
++		request_packet_async(ir, ep_out, init2,
++				     sizeof(init2), MCEUSB_OUTBOUND);
 +	}
 +
++	/*
++	 * if we don't issue the correct number of receives (MCEUSB_INBOUND)
++	 * for each outbound, then the first few ir pulses will be interpreted
++	 * by the usb_async_callback routine - we should ensure we have the
++	 * right amount OR less - as the mceusb_dev_recv routine will handle
++	 * the control packets OK - they start with 0x9f - but the async
++	 * callback doesn't handle ir pulse packets
++	 */
++	request_packet_async(ir, ep_in, NULL, maxp, 0);
++
 +	usb_set_intfdata(intf, ir);
 +
 +	return 0;
@@ -14406,7 +14404,7 @@ index 0000000..2955bad
 +module_exit(ttusbir_exit_module);
 diff --git a/drivers/input/lirc/lirc_zilog.c b/drivers/input/lirc/lirc_zilog.c
 new file mode 100644
-index 0000000..f86db02
+index 0000000..c4080f5
 --- /dev/null
 +++ b/drivers/input/lirc/lirc_zilog.c
 @@ -0,0 +1,1395 @@
@@ -14476,31 +14474,30 @@ index 0000000..f86db02
 +	struct lirc_driver l;
 +
 +	/* Device info */
-+	struct mutex       lock;
-+	int		   open;
++	struct mutex lock;
++	int open;
 +
 +	/* RX device */
-+	struct i2c_client  c_rx;
++	struct i2c_client c_rx;
++	int have_rx;
 +
 +	/* RX device buffer & lock */
 +	struct lirc_buffer buf;
-+	struct mutex       buf_lock;
++	struct mutex buf_lock;
 +
 +	/* RX polling thread data */
-+	struct completion  *t_notify;
-+	struct completion  *t_notify2;
-+	int		   shutdown;
++	struct completion *t_notify;
++	struct completion *t_notify2;
++	int shutdown;
 +	struct task_struct *task;
 +
 +	/* RX read data */
-+	unsigned char      b[3];
++	unsigned char b[3];
 +
 +	/* TX device */
-+	struct i2c_client  c_tx;
-+	int		   need_boot;
-+
-+	/* # devices, for shutdown */
-+	int		   devs;
++	struct i2c_client c_tx;
++	int need_boot;
++	int have_tx;
 +};
 +
 +/* Minor -> data mapping */
@@ -14531,13 +14528,15 @@ index 0000000..f86db02
 +};
 +
 +static struct tx_data_struct *tx_data;
-+struct mutex tx_data_lock;
++static struct mutex tx_data_lock;
 +
-+#define DEVICE_NAME "lirc_zilog"
 +#define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \
 +					## args)
 +#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
 +
++#define ZILOG_HAUPPAUGE_IR_RX_NAME "Zilog/Hauppauge IR RX"
++#define ZILOG_HAUPPAUGE_IR_TX_NAME "Zilog/Hauppauge IR TX"
++
 +/* module parameters */
 +static int debug;	/* debug output */
 +static int disable_rx;	/* disable RX device */
@@ -14547,7 +14546,7 @@ index 0000000..f86db02
 +#define dprintk(fmt, args...)						\
 +	do {								\
 +		if (debug)						\
-+			printk(KERN_DEBUG DEVICE_NAME ": " fmt,		\
++			printk(KERN_DEBUG KBUILD_MODNAME ": " fmt,	\
 +				 ## args);				\
 +	} while (0)
 +
@@ -14926,8 +14925,8 @@ index 0000000..f86db02
 +		zilog_error("unexpected IR TX response: %02x\n", buf[0]);
 +		return 0;
 +	}
-+	zilog_notify("Zilog/Hauppauge IR blaster: firmware version "
-+		     "%d.%d.%d\n", buf[1], buf[2], buf[3]);
++	zilog_notify("Zilog/Hauppauge IR blaster firmware version "
++		     "%d.%d.%d loaded\n", buf[1], buf[2], buf[3]);
 +
 +	return 0;
 +}
@@ -14962,7 +14961,7 @@ index 0000000..f86db02
 +	int ret;
 +	unsigned int i;
 +	unsigned char *data, version, num_global_fixed;
-+	const struct firmware *fw_entry = NULL;
++	const struct firmware *fw_entry;
 +
 +	/* Already loaded? */
 +	mutex_lock(&tx_data_lock);
@@ -14979,7 +14978,7 @@ index 0000000..f86db02
 +		ret = ret < 0 ? ret : -EFAULT;
 +		goto out;
 +	}
-+	zilog_notify("firmware of size %zu loaded\n", fw_entry->size);
++	dprintk("firmware of size %zu loaded\n", fw_entry->size);
 +
 +	/* Parse the file */
 +	tx_data = vmalloc(sizeof(*tx_data));
@@ -15026,7 +15025,7 @@ index 0000000..f86db02
 +			      &tx_data->num_code_sets))
 +		goto corrupt;
 +
-+	zilog_notify("%u codesets loaded\n", tx_data->num_code_sets);
++	dprintk("%u IR blaster codesets loaded\n", tx_data->num_code_sets);
 +
 +	tx_data->code_sets = vmalloc(
 +		tx_data->num_code_sets * sizeof(char *));
@@ -15520,7 +15519,6 @@ index 0000000..f86db02
 +	.owner		= THIS_MODULE
 +};
 +
-+static int ir_attach(struct i2c_adapter *adap, int have_rx, int have_tx);
 +static int ir_remove(struct i2c_client *client);
 +static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id);
 +static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg);
@@ -15528,14 +15526,16 @@ index 0000000..f86db02
 +static const struct i2c_device_id ir_transceiver_id[] = {
 +	/* Generic entry for any IR transceiver */
 +	{ "ir_video", 0 },
-+	/* IR device specific entries could be added here */
++	/* IR device specific entries should be added here */
++	{ "ir_tx_z8f0811_haup", 0 },
++	{ "ir_rx_z8f0811_haup", 0 },
 +	{ }
 +};
 +
 +static struct i2c_driver driver = {
 +	.driver = {
 +		.owner	= THIS_MODULE,
-+		.name	= "i2c ir driver",
++		.name	= "Zilog/Hauppauge i2c IR",
 +	},
 +	.probe		= ir_probe,
 +	.remove		= ir_remove,
@@ -15543,11 +15543,6 @@ index 0000000..f86db02
 +	.id_table	= ir_transceiver_id,
 +};
 +
-+static struct i2c_client client_template = {
-+	.name	= "unset",
-+	.driver	= &driver
-+};
-+
 +static struct file_operations lirc_fops = {
 +	.owner		= THIS_MODULE,
 +	.llseek		= lseek,
@@ -15559,30 +15554,107 @@ index 0000000..f86db02
 +	.release	= close
 +};
 +
-+static int i2c_attach(struct i2c_client *client, struct IR *ir)
++static int ir_remove(struct i2c_client *client)
 +{
-+	i2c_set_clientdata(client, ir);
++	struct IR *ir = i2c_get_clientdata(client);
++
++	mutex_lock(&ir->lock);
++
++	if (ir->have_rx || ir->have_tx) {
++		DECLARE_COMPLETION(tn);
++		DECLARE_COMPLETION(tn2);
++
++		/* end up polling thread */
++		if (ir->task && !IS_ERR(ir->task)) {
++			ir->t_notify = &tn;
++			ir->t_notify2 = &tn2;
++			ir->shutdown = 1;
++			wake_up_process(ir->task);
++			complete(&tn2);
++			wait_for_completion(&tn);
++			ir->t_notify = NULL;
++			ir->t_notify2 = NULL;
++		}
++
++	} else {
++		mutex_unlock(&ir->lock);
++		zilog_error("%s: detached from something we didn't "
++			    "attach to\n", __func__);
++		return -ENODEV;
++	}
++
++	/* unregister lirc driver */
++	if (ir->l.minor >= 0 && ir->l.minor < MAX_IRCTL_DEVICES) {
++		lirc_unregister_driver(ir->l.minor);
++		ir_devices[ir->l.minor] = NULL;
++	}
++
++	/* free memory */
++	lirc_buffer_free(&ir->buf);
++	mutex_unlock(&ir->lock);
++	kfree(ir);
 +
-+	++ir->devs;
 +	return 0;
 +}
 +
-+static int ir_attach(struct i2c_adapter *adap, int have_rx, int have_tx)
++static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 +{
-+	struct IR *ir;
++	struct IR *ir = NULL;
++	struct i2c_adapter *adap = client->adapter;
++	char buf;
 +	int ret;
++	int have_rx = 0, have_tx = 0;
++
++	dprintk("%s: adapter id=0x%x, client addr=0x%02x\n",
++		__func__, adap->id, client->addr);
 +
-+	printk("lirc_zilog: chip found with %s\n",
++	/* if this isn't an appropriate device, bail w/-ENODEV now */
++	if (!(adap->id == I2C_HW_B_BT848 ||
++#ifdef I2C_HW_B_HDPVR
++	      adap->id == I2C_HW_B_HDPVR ||
++#endif
++	      adap->id == I2C_HW_B_CX2341X))
++		goto out_nodev;
++
++	/*
++	 * The external IR receiver is at i2c address 0x71.
++	 * The IR transmitter is at 0x70.
++	 */
++	client->addr = 0x70;
++
++	if (!disable_tx) {
++		if (i2c_master_recv(client, &buf, 1) == 1)
++			have_tx = 1;
++		dprintk("probe 0x70 @ %s: %s\n",
++			adap->name, have_tx ? "success" : "failed");
++	}
++
++	if (!disable_rx) {
++		client->addr = 0x71;
++		if (i2c_master_recv(client, &buf, 1) == 1)
++			have_rx = 1;
++		dprintk("probe 0x71 @ %s: %s\n",
++			adap->name, have_rx ? "success" : "failed");
++	}
++
++	if (!(have_rx || have_tx)) {
++		zilog_error("%s: no devices found\n", adap->name);
++		goto out_nodev;
++	}
++
++	printk(KERN_INFO "lirc_zilog: chip found with %s\n",
 +		have_rx && have_tx ? "RX and TX" :
 +			have_rx ? "RX only" : "TX only");
 +
 +	ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
-+	if (ir == NULL)
-+		return -ENOMEM;
-+	if (lirc_buffer_init(&ir->buf, 2, BUFLEN/2) != 0) {
-+		kfree(ir);
-+		return -ENOMEM;
-+	}
++
++	if (!ir)
++		goto out_nomem;
++
++	ret = lirc_buffer_init(&ir->buf, 2, BUFLEN / 2);
++	if (ret)
++		goto out_nomem;
++
 +	mutex_init(&ir->lock);
 +	mutex_init(&ir->buf_lock);
 +	ir->need_boot = 1;
@@ -15590,18 +15662,17 @@ index 0000000..f86db02
 +	memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));
 +	ir->l.minor = -1;
 +
++	/* I2C attach to device */
++	i2c_set_clientdata(client, ir);
++
 +	/* initialise RX device */
-+	client_template.adapter = adap;
-+	memcpy(&ir->c_rx, &client_template, sizeof(struct i2c_client));
 +	if (have_rx) {
 +		DECLARE_COMPLETION(tn);
++		memcpy(&ir->c_rx, client, sizeof(struct i2c_client));
 +
-+		/* I2C attach to device */
 +		ir->c_rx.addr = 0x71;
-+		strncpy(ir->c_rx.name, "Zilog/Hauppauge RX", I2C_NAME_SIZE);
-+		ret = i2c_attach(&ir->c_rx, ir);
-+		if (ret != 0)
-+			goto err;
++		strncpy(ir->c_rx.name, ZILOG_HAUPPAUGE_IR_RX_NAME,
++			I2C_NAME_SIZE);
 +
 +		/* try to fire up polling thread */
 +		ir->t_notify = &tn;
@@ -15614,24 +15685,23 @@ index 0000000..f86db02
 +		}
 +		wait_for_completion(&tn);
 +		ir->t_notify = NULL;
++		ir->have_rx = 1;
 +	}
 +
 +	/* initialise TX device */
-+	memcpy(&ir->c_tx, &client_template, sizeof(struct i2c_client));
 +	if (have_tx) {
-+		/* I2C attach to device */
++		memcpy(&ir->c_tx, client, sizeof(struct i2c_client));
 +		ir->c_tx.addr = 0x70;
-+		strncpy(ir->c_tx.name, "Zilog/Hauppauge TX", I2C_NAME_SIZE);
-+		ret = i2c_attach(&ir->c_tx, ir);
-+		if (ret != 0)
-+			goto err;
++		strncpy(ir->c_tx.name, ZILOG_HAUPPAUGE_IR_TX_NAME,
++			I2C_NAME_SIZE);
++		ir->have_tx = 1;
 +	}
 +
 +	/* set lirc_dev stuff */
 +	ir->l.code_length = 13;
 +	ir->l.rbuf	  = &ir->buf;
-+	ir->l.fops	= &lirc_fops;
-+	ir->l.data	= ir;
++	ir->l.fops	  = &lirc_fops;
++	ir->l.data	  = ir;
 +	ir->l.minor       = minor;
 +	ir->l.sample_rate = 0;
 +
@@ -15658,6 +15728,7 @@ index 0000000..f86db02
 +		if (ret != 0)
 +			goto err;
 +	}
++
 +	return 0;
 +
 +err:
@@ -15667,100 +15738,15 @@ index 0000000..f86db02
 +	if (ir->c_tx.addr)
 +		ir_remove(&ir->c_tx);
 +	return ret;
-+}
-+
-+static int ir_remove(struct i2c_client *client)
-+{
-+	struct IR *ir = i2c_get_clientdata(client);
-+	mutex_lock(&ir->lock);
-+
-+	if (client == &ir->c_rx) {
-+		DECLARE_COMPLETION(tn);
-+		DECLARE_COMPLETION(tn2);
-+
-+		/* end up polling thread */
-+		if (ir->task && !IS_ERR(ir->task)) {
-+			ir->t_notify = &tn;
-+			ir->t_notify2 = &tn2;
-+			ir->shutdown = 1;
-+			wake_up_process(ir->task);
-+			complete(&tn2);
-+			wait_for_completion(&tn);
-+			ir->t_notify = NULL;
-+			ir->t_notify2 = NULL;
-+		}
-+
-+	} else {
-+		mutex_unlock(&ir->lock);
-+		zilog_error("%s: detached from something we didn't "
-+			    "attach to\n", __func__);
-+		return -ENODEV;
-+	}
-+
-+	--ir->devs;
-+	if (ir->devs < 0) {
-+		mutex_unlock(&ir->lock);
-+		zilog_error("%s: invalid device count\n", __func__);
-+		return -ENODEV;
-+	} else if (ir->devs == 0) {
-+		/* unregister lirc driver */
-+		if (ir->l.minor >= 0 && ir->l.minor < MAX_IRCTL_DEVICES) {
-+			lirc_unregister_driver(ir->l.minor);
-+			ir_devices[ir->l.minor] = NULL;
-+		}
 +
-+		/* free memory */
-+		lirc_buffer_free(&ir->buf);
-+		mutex_unlock(&ir->lock);
-+		kfree(ir);
-+		return 0;
-+	}
-+	mutex_unlock(&ir->lock);
-+	return 0;
-+}
++out_nodev:
++	zilog_error("no device found\n");
++	return -ENODEV;
 +
-+static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
-+{
-+	struct i2c_adapter *adap = client->adapter;
-+	char buf;
-+
-+	if (adap->id == I2C_HW_B_BT848 ||
-+#ifdef I2C_HW_B_HDPVR
-+	    adap->id == I2C_HW_B_HDPVR ||
-+#endif
-+	    adap->id == I2C_HW_B_CX2341X) {
-+		int have_rx = 0, have_tx = 0;
-+
-+		/*
-+		 * The external IR receiver is at i2c address 0x71.
-+		 * The IR transmitter is at 0x70.
-+		 */
-+		client->addr = 0x70;
-+
-+		if (!disable_rx) {
-+			if (i2c_master_recv(client, &buf, 1) == 1)
-+				have_rx = 1;
-+			dprintk("probe 0x70 @ %s: %s\n",
-+				adap->name,
-+				have_rx ? "yes" : "no");
-+		}
-+
-+		if (!disable_tx) {
-+			client->addr = 0x71;
-+			if (i2c_master_recv(client, &buf, 1) == 1)
-+				have_tx = 1;
-+			dprintk("probe 0x71 @ %s: %s\n",
-+				adap->name,
-+				have_tx ? "yes" : "no");
-+		}
-+
-+		if (have_rx || have_tx)
-+			return ir_attach(adap, have_rx, have_tx);
-+		else
-+			zilog_error("%s: no devices found\n", adap->name);
-+	}
-+
-+	return 0;
++out_nomem:
++	zilog_error("memory allocation failure\n");
++	kfree(ir);
++	return -ENOMEM;
 +}
 +
 +static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg)
@@ -15771,10 +15757,21 @@ index 0000000..f86db02
 +
 +static int __init zilog_init(void)
 +{
++	int ret;
++
++	zilog_notify("Zilog/Hauppauge IR driver initializing\n");
++
 +	mutex_init(&tx_data_lock);
++
 +	request_module("firmware_class");
-+	i2c_add_driver(&driver);
-+	return 0;
++
++	ret = i2c_add_driver(&driver);
++	if (ret)
++		zilog_error("initialization failed\n");
++	else
++		zilog_notify("initialization complete\n");
++
++	return ret;
 +}
 +
 +static void __exit zilog_exit(void)
@@ -15782,6 +15779,7 @@ index 0000000..f86db02
 +	i2c_del_driver(&driver);
 +	/* if loaded */
 +	fw_unload();
++	zilog_notify("Zilog/Hauppauge IR driver unloaded\n");
 +}
 +
 +module_init(zilog_init);




More information about the scm-commits mailing list