Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754557AbbDGOjS (ORCPT ); Tue, 7 Apr 2015 10:39:18 -0400 Received: from smtprelay0252.hostedemail.com ([216.40.44.252]:38956 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754322AbbDGOjO (ORCPT ); Tue, 7 Apr 2015 10:39:14 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3874:4250:4321:5007:6261:7904:9040:10004:10400:10848:11026:11232:11658:11914:12043:12438:12517:12519:12740:13069:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: van93_502bbcfa3df3f X-Filterd-Recvd-Size: 1905 Message-ID: <1428417548.20888.105.camel@perches.com> Subject: Re: [PATCH] x86: Fix earlyprintk ttyS2/3 From: Joe Perches To: Daniel J Blueman Cc: "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org, Steffen Persvold Date: Tue, 07 Apr 2015 07:39:08 -0700 In-Reply-To: <1428416957-19278-1-git-send-email-daniel@numascale.com> References: <1428416957-19278-1-git-send-email-daniel@numascale.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1187 Lines: 33 On Tue, 2015-04-07 at 22:29 +0800, Daniel J Blueman wrote: > Quite a few platforms use ttyS2 for their serial-over-LAN, so fix early > printk support for ttyS2 and 3, avoiding the need to hard-code the IO port. [] > diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c [] > @@ -71,15 +71,16 @@ static void parse_earlyprintk(void) > else > pos = e - arg; > } else if (!strncmp(arg + pos, "ttyS", 4)) { > - static const int bases[] = { 0x3f8, 0x2f8 }; > - int idx = 0; > + static const int bases[] = {0x3f8, 0x2f8, 0x3e8, 0x2e8}; > + unsigned idx = 0; > > if (!strncmp(arg + pos, "ttyS", 4)) > pos += 4; > > - if (arg[pos++] == '1') > - idx = 1; > + if ((arg[pos] - '0') < (sizeof(bases) / sizeof(bases[0]))) > + idx = arg[pos] - '0'; This doesn't prevent negative indexing in case someone does something like shift key typo "ttyS!" for "ttyS1". I've done that. -- 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/