Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp108622ybb; Thu, 19 Mar 2020 12:31:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuhbcLhifAF2YvBFBN7nQUEQQ1Ou8Yk9S6yggmDvUUIhXCuhjfosrYXAN4MJePmmHXHr0Ue X-Received: by 2002:aca:f4d0:: with SMTP id s199mr3705038oih.109.1584646301628; Thu, 19 Mar 2020 12:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584646301; cv=none; d=google.com; s=arc-20160816; b=zt/8KhRy6EJZaFsUJSkfYJUDujGj4/m1lvs9yAgi1LaHGeom1NW/2C9KLRWfuSydVQ eETxRO5cCg8jXsALCJ4XVz7ntkHRAELEz7fPkzH7dJDDwAMeGBcNE0RAkJF4Joo4AyRu 6qrhJsyBU1yi8OmInK9KJ4//E3E3we0SkeHHMrcmek/9SQKOZxfGy+su+qETRGVkOUjH TTJJaKZKWISkSCmT798uO4ig3lmwG6Ht8FIKVoDUd6dd3YTRcxvdKbxf6vgZtWzSyBda EjpgaZrjgbKv2NqBfggv3o/qI1f+6IF7F6FrMPH6ccAVNnZat+ItgxDR31oZFqlHyOzz 8Hzg== 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=vT+n4BrnMm/bchv1vViM8P6pbC+Ks+gdvvifumj7UvICw3vyX3XbjyeWD3eVt+vkQc WQ2ueUstVjIHbklU9mFPiRbiWMFRBticBQQeOxjHKdcwe5uYiQ1rjRlmGswoz/z4rlW1 6bsvw1xrS29YhQpoA0ohhi5c5uNn/MWduAWpc54od2Dk0gEv//14GRSysGIrGpSJGxat JFYVkRpwqP7+gJoUrLV/24M6z85voHYsy4ZSR9WngD6EYhr362duJM4XRymuqf1FOadO c7qblCx0oyfw15BwJquBDcD6f1/9sowaqKzROi8sxJ8ZUcR9mO4wltwEibovn5UQmXDw w2Sw== 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 u7si1487442otq.323.2020.03.19.12.31.28; Thu, 19 Mar 2020 12:31:41 -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 S1728133AbgCST3k (ORCPT + 99 others); Thu, 19 Mar 2020 15:29:40 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:41082 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727680AbgCST3G (ORCPT ); Thu, 19 Mar 2020 15:29:06 -0400 Received: by mail-qk1-f193.google.com with SMTP id s11so4398172qks.8; Thu, 19 Mar 2020 12:29:05 -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=hl4+7OxzmZoKh1tf52qqlmvsCIY9ioNlqZ+mBm0RkLlcVY/ybQlIKqqUrd7g6hZwSp iIyNmQIsQ0rqGB6qscrBKc+x+xAKCQ8DbaRsRYseWLiRIQYNc0MnHqbWt2lRP4WlMgHJ /nzaT+vVQUc9NWisazbFeYHW8cMBd1zy6hVjNs/mvUTdevoB7xtcBfYkwF7zybpH8AcG EevYO7ZcXXkgNivyjXt618KDpg+vl2hcvuYXOunXaM5vFXu2QEP4AJXvFeFTsMAOaqzx ZoGADzMCZXAj6wHlotv/6WBL1mSI8L6YeXIHo9FmNL6CEwcVjAz6LP574RubEYbWRu4D HZ9w== X-Gm-Message-State: ANhLgQ1RfGjHsd8GHOOhVT5jKzbPtg+vb/RnrW3ebnHc270UoX3m2sVA jBnnc0WcjgloCVSipi7WZ+NN8MH7 X-Received: by 2002:a37:a484:: with SMTP id n126mr4476686qke.362.1584646145137; Thu, 19 Mar 2020 12:29:05 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id x89sm2292649qtd.43.2020.03.19.12.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 12:29:04 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/14] efi/gop: Remove unreachable code from setup_pixel_info Date: Thu, 19 Mar 2020 15:28:50 -0400 Message-Id: <20200319192855.29876-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