Hello,
On 10/14/2015 12:09 PM, Sakari Ailus wrote:
On Mon, Oct 12, 2015 at 08:52:43PM -0300, Mauro Carvalho Chehab wrote:
Sakari Ailus sakari.ailus@iki.fi escreveu:
[snip]
static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);
- struct v4l2_device *v4l2_dev = &isp->v4l2_dev;
- struct v4l2_subdev *sd;
- struct isp_bus_cfg *bus;
- int ret;
- list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
list_for_each_entry(sd, &isp->v4l2_dev.subdevs, list) {
And you can drop local v4l2_dev.
This is Javier's patch, but I agree that this can be simplified.
Yes, the local variable is not needed but usually I prefer to use a variable when two levels of indirection are needed since I think that makes the code easier to read.
I don't have a strong opinion though so I don't mind if is dropped.
/* Only try to link entities whose interface was set on bound */
if (sd->host_priv) {
bus = (struct isp_bus_cfg *)sd->host_priv;
struct isp_bus_cfg *bus = sd->host_priv;
And you can drop "bus" from the beginning of the function.
Perhaps not a big deal, but I think it's cleaner this way.
I actually prefer to allocate the local vars only once at the function :)
Ok, if the compiler optimizer is good enough, this won't make any difference, but, if the optimizer is not that good, at least on archs with not many registers like x86, allocating local vars inside loops may create extra code.
I'm more worried about accidentally using the variables when they're not supposed to. I don't think there's much risk of that here though. Cc Javier.
I thought that declaring all local variables at the beginning of the function was a convention but from a quick look at CodingStyle I found nothing so I agree with declaring the variable as locally as possible.
Best regards,