aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2015-03-23 19:01:23 (GMT)
committerSteven Toth <stoth@kernellabs.com>2015-03-23 19:01:23 (GMT)
commit3eaf8b872eaf3a6ed7067fb0ed9a11189c696379 (patch)
tree3301a906d312734750fb5bba2ce56c650e1a53c4
parentfe0e7ebb3c8f259ae70eb23acec73305de38d322 (diff)
[media] cx23885: Expose device serial number via sysfs.cx23885-dev
Signed-off-by: Steven Toth <stoth@kernellabs.com>
-rw-r--r--drivers/media/pci/cx23885/cx23885-cards.c5
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c30
-rw-r--r--drivers/media/pci/cx23885/cx23885.h2
3 files changed, 35 insertions, 2 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index f384f29..71c2f95 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1040,6 +1040,7 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
eeprom_data);
+ dev->serial_number = tv.serial_number;
/* Make sure we support the board model */
switch (tv.model) {
@@ -1184,8 +1185,8 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
break;
}
- printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
- dev->name, tv.model);
+ printk(KERN_INFO "%s: hauppauge eeprom: model=%d serial_number=%08x\n",
+ dev->name, tv.model, dev->serial_number);
}
/* Some TBS cards require initing a chip using a bitbanged SPI attached
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index 1ad4994..edfe1de 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -588,6 +588,34 @@ static void cx23885_risc_disasm(struct cx23885_tsport *port,
}
}
+static ssize_t driver_attr_serialnumber(struct device *device,
+ struct device_attribute *attr, char *buf)
+{
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(device);
+ struct cx23885_dev *dev = to_cx23885(v4l2_dev);
+
+ return sprintf(buf, "%08x\n", dev->serial_number);
+}
+static DEVICE_ATTR(serialnumber, S_IRUGO, driver_attr_serialnumber, NULL);
+
+static int sysfs_register(struct cx23885_dev *dev)
+{
+ int ret = 0;
+
+ /* Create a SYSFS entry so udev can determine our serial number for hotplug */
+ ret = device_create_file(&dev->pci->dev, &dev_attr_serialnumber);
+ if (ret != 0) {
+ printk(KERN_ERR "could not register sysfs serialnumber entry\n");
+ }
+
+ return ret;
+}
+
+static void sysfs_unregister(struct cx23885_dev *dev)
+{
+ device_remove_file(&dev->pci->dev, &dev_attr_serialnumber);
+}
+
static void cx23885_shutdown(struct cx23885_dev *dev)
{
/* disable RISC controller */
@@ -2025,6 +2053,7 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
cx23885_ir_pci_int_enable(dev);
cx23885_input_init(dev);
+ sysfs_register(dev);
return 0;
fail_irq:
@@ -2054,6 +2083,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
pci_disable_device(pci_dev);
+ sysfs_unregister(dev);
cx23885_dev_unregister(dev);
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
v4l2_ctrl_handler_free(&dev->ctrl_handler);
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index aeda8d3..33bacf2 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -35,6 +35,7 @@
#include <linux/mutex.h>
#define CX23885_VERSION "0.0.4"
+#define CX23885_SYSFS_ATTR_SERIALNUMBER 1
#define UNSET (-1U)
@@ -377,6 +378,7 @@ struct cx23885_dev {
/* board details */
unsigned int board;
char name[32];
+ u32 serial_number;
struct cx23885_tsport ts1, ts2;

Privacy Policy