From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751381AbdAQXMO (ORCPT ); Tue, 17 Jan 2017 18:12:14 -0500 Received: from mail.skyhub.de ([78.46.96.112]:50753 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060AbdAQXMN (ORCPT ); Tue, 17 Jan 2017 18:12:13 -0500 Date: Wed, 18 Jan 2017 00:12:10 +0100 From: Borislav Petkov To: Thomas Gleixner Cc: X86 ML , LKML Subject: Re: [PATCH 03/13] x86/microcode/AMD: Clean up find_equiv_id() Message-ID: <20170117231209.pwetyowcime7sfym@pd.tnic> References: <20170117173734.14251-1-bp@alien8.de> <20170117173734.14251-4-bp@alien8.de> <20170117184927.fecw3m6cm6rb3p3j@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 17, 2017 at 08:02:59PM +0100, Thomas Gleixner wrote: > That's how it parses best. The opening brace after the for() tells us: here > comes a multiline statement. And the inner if (othercond) w/o the opening > brace tells: here comes a single line statement. > > Reading code/patches very much depends on patterns and structuring. If they > are consistent the reading flow is undisturbed. Yeah, very true. --- From: Borislav Petkov Date: Sun, 18 Dec 2016 12:05:50 +0100 Subject: [PATCH] x86/microcode/AMD: Clean up find_equiv_id() No need to have it marked "inline" - let gcc decide. Also, shorten the argument name and simplify while-test. While at it, make it into a proper for-loop and simplify it even more, as tglx suggests. No functionality change. Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/amd.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 6a31e2691f3a..5c1509a38048 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -97,20 +97,13 @@ static size_t compute_container_size(u8 *data, u32 total_size) return size; } -static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table, - unsigned int sig) +static u16 find_equiv_id(struct equiv_cpu_entry *equiv_table, u32 sig) { - int i = 0; - - if (!equiv_cpu_table) - return 0; - - while (equiv_cpu_table[i].installed_cpu != 0) { - if (sig == equiv_cpu_table[i].installed_cpu) - return equiv_cpu_table[i].equiv_cpu; - - i++; + for (; equiv_table && equiv_table->installed_cpu; equiv_table++) { + if (sig == equiv_table->installed_cpu) + return equiv_table->equiv_cpu; } + return 0; } -- 2.11.0 -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.