aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.if>2012-09-15 17:26:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-26 16:43:54 -0400
commiteba66b3e341ef7b72c2603b55cd5cd38d028c9da (patch)
tree995f04e0e7a9c74dd785e38c22ed13bb264a3830
parentf67e1573f08efb3225e7b1f05ecfec8b2ca8224b (diff)
[media] smiapp: Provide module identification information through sysfs
Provide module ident information through sysfs. Signed-off-by: Sakari Ailus <sakari.ailus@iki.if> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 02bfa4472e02..e08e588ad24b 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2211,6 +2211,21 @@ smiapp_sysfs_nvm_read(struct device *dev, struct device_attribute *attr,
2211} 2211}
2212static DEVICE_ATTR(nvm, S_IRUGO, smiapp_sysfs_nvm_read, NULL); 2212static DEVICE_ATTR(nvm, S_IRUGO, smiapp_sysfs_nvm_read, NULL);
2213 2213
2214static ssize_t
2215smiapp_sysfs_ident_read(struct device *dev, struct device_attribute *attr,
2216 char *buf)
2217{
2218 struct v4l2_subdev *subdev = i2c_get_clientdata(to_i2c_client(dev));
2219 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2220 struct smiapp_module_info *minfo = &sensor->minfo;
2221
2222 return snprintf(buf, PAGE_SIZE, "%2.2x%4.4x%2.2x\n",
2223 minfo->manufacturer_id, minfo->model_id,
2224 minfo->revision_number_major) + 1;
2225}
2226
2227static DEVICE_ATTR(ident, S_IRUGO, smiapp_sysfs_ident_read, NULL);
2228
2214/* ----------------------------------------------------------------------------- 2229/* -----------------------------------------------------------------------------
2215 * V4L2 subdev core operations 2230 * V4L2 subdev core operations
2216 */ 2231 */
@@ -2467,6 +2482,11 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2467 sensor->binning_horizontal = 1; 2482 sensor->binning_horizontal = 1;
2468 sensor->binning_vertical = 1; 2483 sensor->binning_vertical = 1;
2469 2484
2485 if (device_create_file(&client->dev, &dev_attr_ident) != 0) {
2486 dev_err(&client->dev, "sysfs ident entry creation failed\n");
2487 rval = -ENOENT;
2488 goto out_power_off;
2489 }
2470 /* SMIA++ NVM initialization - it will be read from the sensor 2490 /* SMIA++ NVM initialization - it will be read from the sensor
2471 * when it is first requested by userspace. 2491 * when it is first requested by userspace.
2472 */ 2492 */
@@ -2476,13 +2496,13 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2476 if (sensor->nvm == NULL) { 2496 if (sensor->nvm == NULL) {
2477 dev_err(&client->dev, "nvm buf allocation failed\n"); 2497 dev_err(&client->dev, "nvm buf allocation failed\n");
2478 rval = -ENOMEM; 2498 rval = -ENOMEM;
2479 goto out_power_off; 2499 goto out_ident_release;
2480 } 2500 }
2481 2501
2482 if (device_create_file(&client->dev, &dev_attr_nvm) != 0) { 2502 if (device_create_file(&client->dev, &dev_attr_nvm) != 0) {
2483 dev_err(&client->dev, "sysfs nvm entry failed\n"); 2503 dev_err(&client->dev, "sysfs nvm entry failed\n");
2484 rval = -EBUSY; 2504 rval = -EBUSY;
2485 goto out_power_off; 2505 goto out_ident_release;
2486 } 2506 }
2487 } 2507 }
2488 2508
@@ -2637,6 +2657,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2637out_nvm_release: 2657out_nvm_release:
2638 device_remove_file(&client->dev, &dev_attr_nvm); 2658 device_remove_file(&client->dev, &dev_attr_nvm);
2639 2659
2660out_ident_release:
2661 device_remove_file(&client->dev, &dev_attr_ident);
2662
2640out_power_off: 2663out_power_off:
2641 smiapp_power_off(sensor); 2664 smiapp_power_off(sensor);
2642 2665
@@ -2832,6 +2855,7 @@ static int __exit smiapp_remove(struct i2c_client *client)
2832 sensor->power_count = 0; 2855 sensor->power_count = 0;
2833 } 2856 }
2834 2857
2858 device_remove_file(&client->dev, &dev_attr_ident);
2835 if (sensor->nvm) 2859 if (sensor->nvm)
2836 device_remove_file(&client->dev, &dev_attr_nvm); 2860 device_remove_file(&client->dev, &dev_attr_nvm);
2837 2861