* [PATCH] remove unnecessary initial allocation of vc
@ 2017-02-21 14:03 Pranay Kr. Srivastava
2017-02-21 14:11 ` Samuel Thibault
2017-02-24 17:37 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Pranay Kr. Srivastava @ 2017-02-21 14:03 UTC (permalink / raw)
To: w.d.hubbs, chris, kirk, samuel.thibault, gregkh, sfr, speakup,
devel, linux-kernel
Cc: Pranay Kr. Srivastava
This patch removes the unnecessary allocation of
current foreground vc during initialization.
Also change the prototype of speakup_allocate to take
extra argument of gfp_* flags. Thus not requiring
GFP_ATOMIC during initialization.
Signed-off-by: Pranay Kr. Srivastava <pranjas@gmail.com>
---
drivers/staging/speakup/main.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index ad95905..4437b39 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1328,14 +1328,14 @@ static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key)
}
/* Allocation concurrency is protected by the console semaphore */
-static int speakup_allocate(struct vc_data *vc)
+static int speakup_allocate(struct vc_data *vc, gfp_t gfp_flags)
{
int vc_num;
vc_num = vc->vc_num;
if (speakup_console[vc_num] == NULL) {
speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]),
- GFP_ATOMIC);
+ gfp_flags);
if (speakup_console[vc_num] == NULL)
return -ENOMEM;
speakup_date(vc);
@@ -2258,7 +2258,7 @@ static int vt_notifier_call(struct notifier_block *nb,
switch (code) {
case VT_ALLOCATE:
if (vc->vc_mode == KD_TEXT)
- speakup_allocate(vc);
+ speakup_allocate(vc, GFP_ATOMIC);
break;
case VT_DEALLOCATE:
speakup_deallocate(vc);
@@ -2318,7 +2318,6 @@ static int __init speakup_init(void)
{
int i;
long err = 0;
- struct st_spk_t *first_console;
struct vc_data *vc = vc_cons[fg_console].d;
struct var_t *var;
@@ -2343,18 +2342,9 @@ static int __init speakup_init(void)
if (err)
goto error_virtkeyboard;
- first_console = kzalloc(sizeof(*first_console), GFP_KERNEL);
- if (!first_console) {
- err = -ENOMEM;
- goto error_alloc;
- }
-
- speakup_console[vc->vc_num] = first_console;
- speakup_date(vc);
-
for (i = 0; i < MAX_NR_CONSOLES; i++)
if (vc_cons[i].d) {
- err = speakup_allocate(vc_cons[i].d);
+ err = speakup_allocate(vc_cons[i].d, GFP_KERNEL);
if (err)
goto error_kobjects;
}
@@ -2413,7 +2403,6 @@ static int __init speakup_init(void)
for (i = 0; i < MAX_NR_CONSOLES; i++)
kfree(speakup_console[i]);
-error_alloc:
speakup_remove_virtual_keyboard();
error_virtkeyboard:
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] remove unnecessary initial allocation of vc
2017-02-21 14:03 [PATCH] remove unnecessary initial allocation of vc Pranay Kr. Srivastava
@ 2017-02-21 14:11 ` Samuel Thibault
2017-02-24 17:37 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2017-02-21 14:11 UTC (permalink / raw)
To: Pranay Kr. Srivastava
Cc: w.d.hubbs, chris, kirk, gregkh, sfr, speakup, devel, linux-kernel
Pranay Kr. Srivastava, on mar. 21 févr. 2017 19:33:32 +0530, wrote:
> This patch removes the unnecessary allocation of
> current foreground vc during initialization.
>
> Also change the prototype of speakup_allocate to take
> extra argument of gfp_* flags. Thus not requiring
> GFP_ATOMIC during initialization.
>
> Signed-off-by: Pranay Kr. Srivastava <pranjas@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Just add in the log that it's unnecessary because the for loop below
does the initialization already.
> ---
> drivers/staging/speakup/main.c | 19 ++++---------------
> 1 file changed, 4 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index ad95905..4437b39 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -1328,14 +1328,14 @@ static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key)
> }
>
> /* Allocation concurrency is protected by the console semaphore */
> -static int speakup_allocate(struct vc_data *vc)
> +static int speakup_allocate(struct vc_data *vc, gfp_t gfp_flags)
> {
> int vc_num;
>
> vc_num = vc->vc_num;
> if (speakup_console[vc_num] == NULL) {
> speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]),
> - GFP_ATOMIC);
> + gfp_flags);
> if (speakup_console[vc_num] == NULL)
> return -ENOMEM;
> speakup_date(vc);
> @@ -2258,7 +2258,7 @@ static int vt_notifier_call(struct notifier_block *nb,
> switch (code) {
> case VT_ALLOCATE:
> if (vc->vc_mode == KD_TEXT)
> - speakup_allocate(vc);
> + speakup_allocate(vc, GFP_ATOMIC);
> break;
> case VT_DEALLOCATE:
> speakup_deallocate(vc);
> @@ -2318,7 +2318,6 @@ static int __init speakup_init(void)
> {
> int i;
> long err = 0;
> - struct st_spk_t *first_console;
> struct vc_data *vc = vc_cons[fg_console].d;
> struct var_t *var;
>
> @@ -2343,18 +2342,9 @@ static int __init speakup_init(void)
> if (err)
> goto error_virtkeyboard;
>
> - first_console = kzalloc(sizeof(*first_console), GFP_KERNEL);
> - if (!first_console) {
> - err = -ENOMEM;
> - goto error_alloc;
> - }
> -
> - speakup_console[vc->vc_num] = first_console;
> - speakup_date(vc);
> -
> for (i = 0; i < MAX_NR_CONSOLES; i++)
> if (vc_cons[i].d) {
> - err = speakup_allocate(vc_cons[i].d);
> + err = speakup_allocate(vc_cons[i].d, GFP_KERNEL);
> if (err)
> goto error_kobjects;
> }
> @@ -2413,7 +2403,6 @@ static int __init speakup_init(void)
> for (i = 0; i < MAX_NR_CONSOLES; i++)
> kfree(speakup_console[i]);
>
> -error_alloc:
> speakup_remove_virtual_keyboard();
>
> error_virtkeyboard:
> --
> 2.10.2
>
--
Samuel
Battery 1: charging, 90%, charging at zero rate - will never fully charge.
-+- acpi - et pourtant, ca monte -+-
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] remove unnecessary initial allocation of vc
2017-02-21 14:03 [PATCH] remove unnecessary initial allocation of vc Pranay Kr. Srivastava
2017-02-21 14:11 ` Samuel Thibault
@ 2017-02-24 17:37 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2017-02-24 17:37 UTC (permalink / raw)
To: Pranay Kr. Srivastava
Cc: w.d.hubbs, chris, kirk, samuel.thibault, sfr, speakup, devel,
linux-kernel
On Tue, Feb 21, 2017 at 07:33:32PM +0530, Pranay Kr. Srivastava wrote:
> This patch removes the unnecessary allocation of
> current foreground vc during initialization.
>
> Also change the prototype of speakup_allocate to take
> extra argument of gfp_* flags. Thus not requiring
> GFP_ATOMIC during initialization.
That's two different things, please do this in two different patches.
And always say what driver/subsystem you are patching in your subject
line, like other patches for the same driver.
Please fix up and resend.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-24 17:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-21 14:03 [PATCH] remove unnecessary initial allocation of vc Pranay Kr. Srivastava
2017-02-21 14:11 ` Samuel Thibault
2017-02-24 17:37 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox