Commit 23989b43 authored by Steve Longerbeam's avatar Steve Longerbeam Committed by Mauro Carvalho Chehab

media: v4l2: async: Add convenience functions to allocate and add asd's

Add these convenience functions, which allocate an asd of match type
fwnode, i2c, or device-name, of size asd_struct_size, and then adds
them to the notifier asd_list.
Signed-off-by: default avatarSteve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent b47d7ff1
...@@ -650,6 +650,82 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, ...@@ -650,6 +650,82 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier,
} }
EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_subdev); EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_subdev);
struct v4l2_async_subdev *
v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,
struct fwnode_handle *fwnode,
unsigned int asd_struct_size)
{
struct v4l2_async_subdev *asd;
int ret;
asd = kzalloc(asd_struct_size, GFP_KERNEL);
if (!asd)
return ERR_PTR(-ENOMEM);
asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
asd->match.fwnode = fwnode;
ret = v4l2_async_notifier_add_subdev(notifier, asd);
if (ret) {
kfree(asd);
return ERR_PTR(ret);
}
return asd;
}
EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_fwnode_subdev);
struct v4l2_async_subdev *
v4l2_async_notifier_add_i2c_subdev(struct v4l2_async_notifier *notifier,
int adapter_id, unsigned short address,
unsigned int asd_struct_size)
{
struct v4l2_async_subdev *asd;
int ret;
asd = kzalloc(asd_struct_size, GFP_KERNEL);
if (!asd)
return ERR_PTR(-ENOMEM);
asd->match_type = V4L2_ASYNC_MATCH_I2C;
asd->match.i2c.adapter_id = adapter_id;
asd->match.i2c.address = address;
ret = v4l2_async_notifier_add_subdev(notifier, asd);
if (ret) {
kfree(asd);
return ERR_PTR(ret);
}
return asd;
}
EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_i2c_subdev);
struct v4l2_async_subdev *
v4l2_async_notifier_add_devname_subdev(struct v4l2_async_notifier *notifier,
const char *device_name,
unsigned int asd_struct_size)
{
struct v4l2_async_subdev *asd;
int ret;
asd = kzalloc(asd_struct_size, GFP_KERNEL);
if (!asd)
return ERR_PTR(-ENOMEM);
asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
asd->match.device_name = device_name;
ret = v4l2_async_notifier_add_subdev(notifier, asd);
if (ret) {
kfree(asd);
return ERR_PTR(ret);
}
return asd;
}
EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_devname_subdev);
int v4l2_async_register_subdev(struct v4l2_subdev *sd) int v4l2_async_register_subdev(struct v4l2_subdev *sd)
{ {
struct v4l2_async_notifier *subdev_notifier; struct v4l2_async_notifier *subdev_notifier;
......
...@@ -174,6 +174,68 @@ void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier); ...@@ -174,6 +174,68 @@ void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier);
int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier,
struct v4l2_async_subdev *asd); struct v4l2_async_subdev *asd);
/**
* v4l2_async_notifier_add_fwnode_subdev - Allocate and add a fwnode async
* subdev to the notifier's master asd_list.
*
* @notifier: pointer to &struct v4l2_async_notifier
* @fwnode: fwnode handle of the sub-device to be matched
* @asd_struct_size: size of the driver's async sub-device struct, including
* sizeof(struct v4l2_async_subdev). The &struct
* v4l2_async_subdev shall be the first member of
* the driver's async sub-device struct, i.e. both
* begin at the same memory address.
*
* This can be used before registering a notifier to add a
* fwnode-matched asd to the notifiers master asd_list. If the caller
* uses this method to compose an asd list, it must never allocate
* or place asd's in the @subdevs array.
*/
struct v4l2_async_subdev *
v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,
struct fwnode_handle *fwnode,
unsigned int asd_struct_size);
/**
* v4l2_async_notifier_add_i2c_subdev - Allocate and add an i2c async
* subdev to the notifier's master asd_list.
*
* @notifier: pointer to &struct v4l2_async_notifier
* @adapter_id: I2C adapter ID to be matched
* @address: I2C address of sub-device to be matched
* @asd_struct_size: size of the driver's async sub-device struct, including
* sizeof(struct v4l2_async_subdev). The &struct
* v4l2_async_subdev shall be the first member of
* the driver's async sub-device struct, i.e. both
* begin at the same memory address.
*
* Same as above but for I2C matched sub-devices.
*/
struct v4l2_async_subdev *
v4l2_async_notifier_add_i2c_subdev(struct v4l2_async_notifier *notifier,
int adapter_id, unsigned short address,
unsigned int asd_struct_size);
/**
* v4l2_async_notifier_add_devname_subdev - Allocate and add a device-name
* async subdev to the notifier's master asd_list.
*
* @notifier: pointer to &struct v4l2_async_notifier
* @device_name: device name string to be matched
* @asd_struct_size: size of the driver's async sub-device struct, including
* sizeof(struct v4l2_async_subdev). The &struct
* v4l2_async_subdev shall be the first member of
* the driver's async sub-device struct, i.e. both
* begin at the same memory address.
*
* Same as above but for device-name matched sub-devices.
*/
struct v4l2_async_subdev *
v4l2_async_notifier_add_devname_subdev(struct v4l2_async_notifier *notifier,
const char *device_name,
unsigned int asd_struct_size);
/** /**
* v4l2_async_notifier_register - registers a subdevice asynchronous notifier * v4l2_async_notifier_register - registers a subdevice asynchronous notifier
* *
......
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