From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbdBUOD4 (ORCPT ); Tue, 21 Feb 2017 09:03:56 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33650 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752485AbdBUODq (ORCPT ); Tue, 21 Feb 2017 09:03:46 -0500 From: "Pranay Kr. Srivastava" To: w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca, samuel.thibault@ens-lyon.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: "Pranay Kr. Srivastava" Subject: [PATCH] remove unnecessary initial allocation of vc Date: Tue, 21 Feb 2017 19:33:32 +0530 Message-Id: <20170221140332.60200-1-pranjas@gmail.com> X-Mailer: git-send-email 2.10.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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