Commit eba66b3e authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] smiapp: Provide module identification information through sysfs

Provide module ident information through sysfs.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@iki.if>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f67e1573
...@@ -2211,6 +2211,21 @@ smiapp_sysfs_nvm_read(struct device *dev, struct device_attribute *attr, ...@@ -2211,6 +2211,21 @@ smiapp_sysfs_nvm_read(struct device *dev, struct device_attribute *attr,
} }
static DEVICE_ATTR(nvm, S_IRUGO, smiapp_sysfs_nvm_read, NULL); static DEVICE_ATTR(nvm, S_IRUGO, smiapp_sysfs_nvm_read, NULL);
static ssize_t
smiapp_sysfs_ident_read(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct v4l2_subdev *subdev = i2c_get_clientdata(to_i2c_client(dev));
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
struct smiapp_module_info *minfo = &sensor->minfo;
return snprintf(buf, PAGE_SIZE, "%2.2x%4.4x%2.2x\n",
minfo->manufacturer_id, minfo->model_id,
minfo->revision_number_major) + 1;
}
static DEVICE_ATTR(ident, S_IRUGO, smiapp_sysfs_ident_read, NULL);
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* V4L2 subdev core operations * V4L2 subdev core operations
*/ */
...@@ -2467,6 +2482,11 @@ static int smiapp_registered(struct v4l2_subdev *subdev) ...@@ -2467,6 +2482,11 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
sensor->binning_horizontal = 1; sensor->binning_horizontal = 1;
sensor->binning_vertical = 1; sensor->binning_vertical = 1;
if (device_create_file(&client->dev, &dev_attr_ident) != 0) {
dev_err(&client->dev, "sysfs ident entry creation failed\n");
rval = -ENOENT;
goto out_power_off;
}
/* SMIA++ NVM initialization - it will be read from the sensor /* SMIA++ NVM initialization - it will be read from the sensor
* when it is first requested by userspace. * when it is first requested by userspace.
*/ */
...@@ -2476,13 +2496,13 @@ static int smiapp_registered(struct v4l2_subdev *subdev) ...@@ -2476,13 +2496,13 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
if (sensor->nvm == NULL) { if (sensor->nvm == NULL) {
dev_err(&client->dev, "nvm buf allocation failed\n"); dev_err(&client->dev, "nvm buf allocation failed\n");
rval = -ENOMEM; rval = -ENOMEM;
goto out_power_off; goto out_ident_release;
} }
if (device_create_file(&client->dev, &dev_attr_nvm) != 0) { if (device_create_file(&client->dev, &dev_attr_nvm) != 0) {
dev_err(&client->dev, "sysfs nvm entry failed\n"); dev_err(&client->dev, "sysfs nvm entry failed\n");
rval = -EBUSY; rval = -EBUSY;
goto out_power_off; goto out_ident_release;
} }
} }
...@@ -2637,6 +2657,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev) ...@@ -2637,6 +2657,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
out_nvm_release: out_nvm_release:
device_remove_file(&client->dev, &dev_attr_nvm); device_remove_file(&client->dev, &dev_attr_nvm);
out_ident_release:
device_remove_file(&client->dev, &dev_attr_ident);
out_power_off: out_power_off:
smiapp_power_off(sensor); smiapp_power_off(sensor);
...@@ -2832,6 +2855,7 @@ static int __exit smiapp_remove(struct i2c_client *client) ...@@ -2832,6 +2855,7 @@ static int __exit smiapp_remove(struct i2c_client *client)
sensor->power_count = 0; sensor->power_count = 0;
} }
device_remove_file(&client->dev, &dev_attr_ident);
if (sensor->nvm) if (sensor->nvm)
device_remove_file(&client->dev, &dev_attr_nvm); device_remove_file(&client->dev, &dev_attr_nvm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment