Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp168927ybb; Thu, 19 Mar 2020 19:02:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtJGfkpdt87DnJdGPb4EGo7vBAFGS45OTOEKQ7L0DcNAp1NBbT5q8ptGWL6cgr7t3hyVEqu X-Received: by 2002:a05:6830:19c7:: with SMTP id p7mr5120190otp.79.1584669765991; Thu, 19 Mar 2020 19:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584669765; cv=none; d=google.com; s=arc-20160816; b=yn7NCj5gdPpEKX1wdsDaR3sF5WFHZfJpvADuyQ8amIRCMHFLFPyWaE+J75WvHS2rl5 DvahR0iUN0tonoKA5zuMddzb8DykkixaU9kaualHNYqoFEQoYMtyL7MAN3zjh2s0CRdX QPvoR9XIba4eWP7jBm7lqea2uZL04hjVUFx6xF+zmK5jBP47qLPXW+MoWx8EJCtQbJIo kyCzHK/FPtMMw92vvZ2WctbS2g/2XBcUNjd5kTQyvoo4hl+jiIyqadtws67Zvj/M48qp 8SUCY1Tj5Jy18C/vG7eD7RiqikgbMDDEP7tYcl1Ig641vd4sezGuLkNOHNbJCo2hUND7 WFGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vUhHlOPkJK/Ny0i92TgGsRnozqELZwVVJe4uW2CfbBQ=; b=D9Xg+40/1zreMasUYS6eIycvomvneY1Sygy4mhTw1bTt88cMZHhNeXyiKqHWXL+0X8 8q3/Dde3QQHaQHsr8jFB9Cxl87vgMIf6win7f7fbe4wcKhFXNDqenRQ2tqjgfZk77NGT u/ufAe/aPi+spw+bO91iRW4vg8XpM2xo/UMifhBCMsYE3Ze3SvlnmSTLYi/+47yHVoAy lRbTn3gaet3B5r+me9gglur3KmjDGl88U1QDvRDV1j1xnQ/DWW+yPs9ZxIgZYDAw7Awj 2S67vI9kVv9BoJLKnElYnQ9FSBI8vF556+j9IMQ+b1Gb3pXSqOymeFVx9tsdl2RSEm8B Acaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y64si1978846oiy.12.2020.03.19.19.02.33; Thu, 19 Mar 2020 19:02:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727619AbgCTCBB (ORCPT + 99 others); Thu, 19 Mar 2020 22:01:01 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35121 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727486AbgCTCAj (ORCPT ); Thu, 19 Mar 2020 22:00:39 -0400 Received: by mail-qt1-f196.google.com with SMTP id v15so3772924qto.2; Thu, 19 Mar 2020 19:00:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vUhHlOPkJK/Ny0i92TgGsRnozqELZwVVJe4uW2CfbBQ=; b=rY8qSULu7gLc+ZZ4xZu46Um4flsyD9M0nmRK5AbS7CUxT39PHKb7SLbjDAWN5CEFwp nxWdg8d/sQ5jWYpWh7TCF9FK1jYL2/IjdzsCBOnivm9w9gfRw+F+jZoKDabYgxn6vIF2 FXr1k1wL8EpuGFlVzWRoI2tmFTEwVNw4l5hxgVuWWgJauFtuWXbZ2plhyMv2Byi516fO ModF4s9ZVCyGNvY2HEFl0H+BLlFVM1GQVIrsrUPHl8TbqJ4ovRQKDXMJsSeZvfFh/ZdL TI9D2vZL8Wie06rc8OZdCF8k1qaOKQP2RsXVO2a4SZm7JLIT8VTC/gA4bgd9GxPFhqma XjvA== X-Gm-Message-State: ANhLgQ1KxdiLwDdpCqvGjDJbtSAIyRCbGYD7iiFbhqtmXoxzmDC2RQNy WO9uowds+AC3sRtvDkY0Bk8= X-Received: by 2002:ac8:24db:: with SMTP id t27mr6181613qtt.49.1584669637823; Thu, 19 Mar 2020 19:00:37 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id n46sm3342198qtb.48.2020.03.19.19.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 19:00:37 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: Hans de Goede , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/14] efi/gop: Remove unreachable code from setup_pixel_info Date: Thu, 19 Mar 2020 22:00:23 -0400 Message-Id: <20200320020028.1936003-10-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200319192855.29876-1-nivedita@alum.mit.edu> References: <20200319192855.29876-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pixel_format must be one of PIXEL_RGB_RESERVED_8BIT_PER_COLOR PIXEL_BGR_RESERVED_8BIT_PER_COLOR PIXEL_BIT_MASK since we skip PIXEL_BLT_ONLY when finding a gop. Remove the redundant code and add another check in find_gop to skip any pixel formats that we don't know about, in case a later version of the UEFI spec adds one. Reformat the code a little. Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/gop.c | 66 ++++++++++++------------------ 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index 8bf424f35759..2d91699e3061 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -29,49 +29,34 @@ static void setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line, efi_pixel_bitmask_t pixel_info, int pixel_format) { - if (pixel_format == PIXEL_RGB_RESERVED_8BIT_PER_COLOR) { - si->lfb_depth = 32; - si->lfb_linelength = pixels_per_scan_line * 4; - si->red_size = 8; - si->red_pos = 0; - si->green_size = 8; - si->green_pos = 8; - si->blue_size = 8; - si->blue_pos = 16; - si->rsvd_size = 8; - si->rsvd_pos = 24; - } else if (pixel_format == PIXEL_BGR_RESERVED_8BIT_PER_COLOR) { - si->lfb_depth = 32; - si->lfb_linelength = pixels_per_scan_line * 4; - si->red_size = 8; - si->red_pos = 16; - si->green_size = 8; - si->green_pos = 8; - si->blue_size = 8; - si->blue_pos = 0; - si->rsvd_size = 8; - si->rsvd_pos = 24; - } else if (pixel_format == PIXEL_BIT_MASK) { - find_bits(pixel_info.red_mask, &si->red_pos, &si->red_size); - find_bits(pixel_info.green_mask, &si->green_pos, - &si->green_size); - find_bits(pixel_info.blue_mask, &si->blue_pos, &si->blue_size); - find_bits(pixel_info.reserved_mask, &si->rsvd_pos, - &si->rsvd_size); + if (pixel_format == PIXEL_BIT_MASK) { + find_bits(pixel_info.red_mask, + &si->red_pos, &si->red_size); + find_bits(pixel_info.green_mask, + &si->green_pos, &si->green_size); + find_bits(pixel_info.blue_mask, + &si->blue_pos, &si->blue_size); + find_bits(pixel_info.reserved_mask, + &si->rsvd_pos, &si->rsvd_size); si->lfb_depth = si->red_size + si->green_size + si->blue_size + si->rsvd_size; si->lfb_linelength = (pixels_per_scan_line * si->lfb_depth) / 8; } else { - si->lfb_depth = 4; - si->lfb_linelength = si->lfb_width / 2; - si->red_size = 0; - si->red_pos = 0; - si->green_size = 0; - si->green_pos = 0; - si->blue_size = 0; - si->blue_pos = 0; - si->rsvd_size = 0; - si->rsvd_pos = 0; + if (pixel_format == PIXEL_RGB_RESERVED_8BIT_PER_COLOR) { + si->red_pos = 0; + si->blue_pos = 16; + } else /* PIXEL_BGR_RESERVED_8BIT_PER_COLOR */ { + si->blue_pos = 0; + si->red_pos = 16; + } + + si->green_pos = 8; + si->rsvd_pos = 24; + si->red_size = si->green_size = + si->blue_size = si->rsvd_size = 8; + + si->lfb_depth = 32; + si->lfb_linelength = pixels_per_scan_line * 4; } } @@ -100,7 +85,8 @@ find_gop(efi_guid_t *proto, unsigned long size, void **handles) mode = efi_table_attr(gop, mode); info = efi_table_attr(mode, info); - if (info->pixel_format == PIXEL_BLT_ONLY) + if (info->pixel_format == PIXEL_BLT_ONLY || + info->pixel_format >= PIXEL_FORMAT_MAX) continue; /* -- 2.24.1