LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input()
@ 2008-10-13 20:54 Németh Márton
2008-10-13 21:28 ` Hans Verkuil
0 siblings, 1 reply; 5+ messages in thread
From: Németh Márton @ 2008-10-13 20:54 UTC (permalink / raw)
To: video4linux-list; +Cc: LKML
From: Márton Németh <nm127@freemail.hu>
The cx18_get_input() and ivtv_get_input() are called
once from the VIDIOC_ENUMINPUT ioctl() and once from
the *_log_status() functions. In the first case the
struct v4l2_input is already filled with zeros,
so doing this again is unnecessary.
The *_log_status() functions are called from
VIDIOC_LOG_STATUS ioctl() which is only used for
debug purposes, so it is worth to move the filling
with zeros to a least frequently used function.
Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -upr linux-2.6.27.orig/drivers/media/video/cx18/cx18-cards.c linux-2.6.27/drivers/media/video/cx18/cx18-cards.c
--- linux-2.6.27.orig/drivers/media/video/cx18/cx18-cards.c 2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.27/drivers/media/video/cx18/cx18-cards.c 2008-10-13 21:27:54.000000000 +0200
@@ -320,10 +320,9 @@ int cx18_get_input(struct cx18 *cx, u16
"Composite 3"
};
- memset(input, 0, sizeof(*input));
if (index >= cx->nof_inputs)
return -EINVAL;
- input->index = index;
+
strlcpy(input->name, input_strs[card_input->video_type - 1],
sizeof(input->name));
input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
diff -upr linux-2.6.27.orig/drivers/media/video/cx18/cx18-ioctl.c linux-2.6.27/drivers/media/video/cx18/cx18-ioctl.c
--- linux-2.6.27.orig/drivers/media/video/cx18/cx18-ioctl.c 2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.27/drivers/media/video/cx18/cx18-ioctl.c 2008-10-13 21:28:11.000000000 +0200
@@ -712,7 +712,11 @@ static int cx18_log_status(struct file *
cx18_read_eeprom(cx, &tv);
}
cx18_call_i2c_clients(cx, VIDIOC_LOG_STATUS, NULL);
+
+ memset(&vidin, 0, sizeof(vidin));
+ vidin.index = cx->active_input;
cx18_get_input(cx, cx->active_input, &vidin);
+
cx18_get_audio_input(cx, cx->audio_input, &audin);
CX18_INFO("Video Input: %s\n", vidin.name);
CX18_INFO("Audio Input: %s\n", audin.name);
diff -upr linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-cards.c linux-2.6.27/drivers/media/video/ivtv/ivtv-cards.c
--- linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-cards.c 2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.27/drivers/media/video/ivtv/ivtv-cards.c 2008-10-13 21:22:59.000000000 +0200
@@ -1199,10 +1199,9 @@ int ivtv_get_input(struct ivtv *itv, u16
"Composite 3"
};
- memset(input, 0, sizeof(*input));
if (index >= itv->nof_inputs)
return -EINVAL;
- input->index = index;
+
strlcpy(input->name, input_strs[card_input->video_type - 1],
sizeof(input->name));
input->type = (card_input->video_type == IVTV_CARD_INPUT_VID_TUNER ?
diff -upr linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-ioctl.c linux-2.6.27/drivers/media/video/ivtv/ivtv-ioctl.c
--- linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-ioctl.c 2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.27/drivers/media/video/ivtv/ivtv-ioctl.c 2008-10-13 21:21:35.000000000 +0200
@@ -1446,7 +1446,11 @@ static int ivtv_log_status(struct file *
ivtv_read_eeprom(itv, &tv);
}
ivtv_call_i2c_clients(itv, VIDIOC_LOG_STATUS, NULL);
+
+ memset(&vidin, 0, sizeof(vidin));
+ vidin.index = itv->active_input;
ivtv_get_input(itv, itv->active_input, &vidin);
+
ivtv_get_audio_input(itv, itv->audio_input, &audin);
IVTV_INFO("Video Input: %s\n", vidin.name);
IVTV_INFO("Audio Input: %s%s\n", audin.name,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input()
2008-10-13 20:54 [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input() Németh Márton
@ 2008-10-13 21:28 ` Hans Verkuil
2008-10-13 21:40 ` Robert William Fuller
0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2008-10-13 21:28 UTC (permalink / raw)
To: Németh Márton; +Cc: video4linux-list, LKML
On Monday 13 October 2008 22:54:06 Németh Márton wrote:
> From: Márton Németh <nm127@freemail.hu>
>
> The cx18_get_input() and ivtv_get_input() are called
> once from the VIDIOC_ENUMINPUT ioctl() and once from
> the *_log_status() functions. In the first case the
> struct v4l2_input is already filled with zeros,
> so doing this again is unnecessary.
And in the second case no one cares whether the struct is zeroed. And
the same situation is also true for ivtv_get_output().
I would suggest just removing the memset() from ivtv_get_input,
ivtv_get_output and cx18_get_input.
Good that you spotted that this memset is no longer needed BTW. I hadn't
realized that.
For the record, I NACK this patch, but if you can make a new one that
just removes the memsets then I'll sign off on that.
Regards,
Hans
> The *_log_status() functions are called from
> VIDIOC_LOG_STATUS ioctl() which is only used for
> debug purposes, so it is worth to move the filling
> with zeros to a least frequently used function.
>
> Signed-off-by: Márton Németh <nm127@freemail.hu>
> ---
> diff -upr linux-2.6.27.orig/drivers/media/video/cx18/cx18-cards.c
> linux-2.6.27/drivers/media/video/cx18/cx18-cards.c ---
> linux-2.6.27.orig/drivers/media/video/cx18/cx18-cards.c 2008-10-10
> 00:13:53.000000000 +0200 +++
> linux-2.6.27/drivers/media/video/cx18/cx18-cards.c 2008-10-13
> 21:27:54.000000000 +0200 @@ -320,10 +320,9 @@ int
> cx18_get_input(struct cx18 *cx, u16 "Composite 3"
> };
>
> - memset(input, 0, sizeof(*input));
> if (index >= cx->nof_inputs)
> return -EINVAL;
> - input->index = index;
> +
> strlcpy(input->name, input_strs[card_input->video_type - 1],
> sizeof(input->name));
> input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER
> ? diff -upr linux-2.6.27.orig/drivers/media/video/cx18/cx18-ioctl.c
> linux-2.6.27/drivers/media/video/cx18/cx18-ioctl.c ---
> linux-2.6.27.orig/drivers/media/video/cx18/cx18-ioctl.c 2008-10-10
> 00:13:53.000000000 +0200 +++
> linux-2.6.27/drivers/media/video/cx18/cx18-ioctl.c 2008-10-13
> 21:28:11.000000000 +0200 @@ -712,7 +712,11 @@ static int
> cx18_log_status(struct file * cx18_read_eeprom(cx, &tv);
> }
> cx18_call_i2c_clients(cx, VIDIOC_LOG_STATUS, NULL);
> +
> + memset(&vidin, 0, sizeof(vidin));
> + vidin.index = cx->active_input;
> cx18_get_input(cx, cx->active_input, &vidin);
> +
> cx18_get_audio_input(cx, cx->audio_input, &audin);
> CX18_INFO("Video Input: %s\n", vidin.name);
> CX18_INFO("Audio Input: %s\n", audin.name);
> diff -upr linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-cards.c
> linux-2.6.27/drivers/media/video/ivtv/ivtv-cards.c ---
> linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-cards.c 2008-10-10
> 00:13:53.000000000 +0200 +++
> linux-2.6.27/drivers/media/video/ivtv/ivtv-cards.c 2008-10-13
> 21:22:59.000000000 +0200 @@ -1199,10 +1199,9 @@ int
> ivtv_get_input(struct ivtv *itv, u16 "Composite 3"
> };
>
> - memset(input, 0, sizeof(*input));
> if (index >= itv->nof_inputs)
> return -EINVAL;
> - input->index = index;
> +
> strlcpy(input->name, input_strs[card_input->video_type - 1],
> sizeof(input->name));
> input->type = (card_input->video_type == IVTV_CARD_INPUT_VID_TUNER
> ? diff -upr linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-ioctl.c
> linux-2.6.27/drivers/media/video/ivtv/ivtv-ioctl.c ---
> linux-2.6.27.orig/drivers/media/video/ivtv/ivtv-ioctl.c 2008-10-10
> 00:13:53.000000000 +0200 +++
> linux-2.6.27/drivers/media/video/ivtv/ivtv-ioctl.c 2008-10-13
> 21:21:35.000000000 +0200 @@ -1446,7 +1446,11 @@ static int
> ivtv_log_status(struct file * ivtv_read_eeprom(itv, &tv);
> }
> ivtv_call_i2c_clients(itv, VIDIOC_LOG_STATUS, NULL);
> +
> + memset(&vidin, 0, sizeof(vidin));
> + vidin.index = itv->active_input;
> ivtv_get_input(itv, itv->active_input, &vidin);
> +
> ivtv_get_audio_input(itv, itv->audio_input, &audin);
> IVTV_INFO("Video Input: %s\n", vidin.name);
> IVTV_INFO("Audio Input: %s%s\n", audin.name,
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-kernel" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input()
2008-10-13 21:28 ` Hans Verkuil
@ 2008-10-13 21:40 ` Robert William Fuller
2008-10-13 21:49 ` Hans Verkuil
0 siblings, 1 reply; 5+ messages in thread
From: Robert William Fuller @ 2008-10-13 21:40 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Németh Márton, video4linux-list, LKML
Hans Verkuil wrote:
> On Monday 13 October 2008 22:54:06 Németh Márton wrote:
>> From: Márton Németh <nm127@freemail.hu>
>>
>> The cx18_get_input() and ivtv_get_input() are called
>> once from the VIDIOC_ENUMINPUT ioctl() and once from
>> the *_log_status() functions. In the first case the
>> struct v4l2_input is already filled with zeros,
>> so doing this again is unnecessary.
>
> And in the second case no one cares whether the struct is zeroed. And
> the same situation is also true for ivtv_get_output().
Yeah, 'cos there's nothing better than uninitialized fields, like the
recent report of a control that returns minimum and maximum values of
zero, but a step-size of 9. Why are we optimizing code paths that are
not performance critical by uninitializing memory?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input()
2008-10-13 21:40 ` Robert William Fuller
@ 2008-10-13 21:49 ` Hans Verkuil
2008-11-01 20:00 ` Németh Márton
0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2008-10-13 21:49 UTC (permalink / raw)
To: Robert William Fuller; +Cc: Németh Márton, video4linux-list, LKML
On Monday 13 October 2008 23:40:48 Robert William Fuller wrote:
> Hans Verkuil wrote:
> > On Monday 13 October 2008 22:54:06 Németh Márton wrote:
> >> From: Márton Németh <nm127@freemail.hu>
> >>
> >> The cx18_get_input() and ivtv_get_input() are called
> >> once from the VIDIOC_ENUMINPUT ioctl() and once from
> >> the *_log_status() functions. In the first case the
> >> struct v4l2_input is already filled with zeros,
> >> so doing this again is unnecessary.
> >
> > And in the second case no one cares whether the struct is zeroed.
> > And the same situation is also true for ivtv_get_output().
>
> Yeah, 'cos there's nothing better than uninitialized fields, like the
> recent report of a control that returns minimum and maximum values of
> zero, but a step-size of 9. Why are we optimizing code paths that
> are not performance critical by uninitializing memory?
It's already initialized to 0 in v4l2-ioctl.c. No need to do it twice.
Regards,
Hans
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input()
2008-10-13 21:49 ` Hans Verkuil
@ 2008-11-01 20:00 ` Németh Márton
0 siblings, 0 replies; 5+ messages in thread
From: Németh Márton @ 2008-11-01 20:00 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Robert William Fuller, video4linux-list, LKML
From: Márton Németh <nm127@freemail.hu>
The cx18_get_input() and ivtv_get_input() are called
once from the VIDIOC_ENUMINPUT ioctl() (see
drivers/media/video/v4l2-ioctl.c:1165) and once from
the *_log_status() functions. In the first case the
struct v4l2_input is already filled with zeros,
so doing this again is unnecessary.
The second case is only used for debugging purposes
from the VIDIOC_LOG_STATUS ioctl(). Currently only
the "name" field is used in the *_log_status() functions.
Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -upr linux-2.6.28-rc1.orig/drivers/media/video/cx18/cx18-cards.c linux-2.6.28-rc1/drivers/media/video/cx18/cx18-cards.c
--- linux-2.6.28-rc1.orig/drivers/media/video/cx18/cx18-cards.c 2008-11-01 20:27:58.000000000 +0100
+++ linux-2.6.28-rc1/drivers/media/video/cx18/cx18-cards.c 2008-11-01 20:36:39.000000000 +0100
@@ -419,10 +419,8 @@ int cx18_get_input(struct cx18 *cx, u16
"Composite 3"
};
- memset(input, 0, sizeof(*input));
if (index >= cx->nof_inputs)
return -EINVAL;
- input->index = index;
strlcpy(input->name, input_strs[card_input->video_type - 1],
sizeof(input->name));
input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
diff -upr linux-2.6.28-rc1.orig/drivers/media/video/ivtv/ivtv-cards.c linux-2.6.28-rc1/drivers/media/video/ivtv/ivtv-cards.c
--- linux-2.6.28-rc1.orig/drivers/media/video/ivtv/ivtv-cards.c 2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.28-rc1/drivers/media/video/ivtv/ivtv-cards.c 2008-11-01 20:37:27.000000000 +0100
@@ -1199,10 +1199,8 @@ int ivtv_get_input(struct ivtv *itv, u16
"Composite 3"
};
- memset(input, 0, sizeof(*input));
if (index >= itv->nof_inputs)
return -EINVAL;
- input->index = index;
strlcpy(input->name, input_strs[card_input->video_type - 1],
sizeof(input->name));
input->type = (card_input->video_type == IVTV_CARD_INPUT_VID_TUNER ?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-01 20:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-13 20:54 [PATCH 2/2] video: simplify cx18_get_input() and ivtv_get_input() Németh Márton
2008-10-13 21:28 ` Hans Verkuil
2008-10-13 21:40 ` Robert William Fuller
2008-10-13 21:49 ` Hans Verkuil
2008-11-01 20:00 ` Németh Márton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).