Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2405588ybh; Mon, 16 Mar 2020 02:31:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtkegkdrpaUsyOyGWzgMkoND4+Vwo8ImUMbbVzRDeaoHAzff4y7dU4EFP8YObXX25TKEqiZ X-Received: by 2002:a9d:19ef:: with SMTP id k102mr21939557otk.220.1584351116567; Mon, 16 Mar 2020 02:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584351116; cv=none; d=google.com; s=arc-20160816; b=QV8hKLBBiXa3oeyA4fWD9aQB93SRp2q1yHE0grGhqyAFRTHPmCgOHhmw9soClyov+M 6/0MjZZ9HHj5bmrj/xFKjiPHANHWfdEYonU+tLZAKkQovrmDHZoWKcCgJnMHov3Iuc/b WdcyKd1rXZYlxlEHXOLJvDFmsTjoQb5MTvzW6yIn6oKcTpH8l9RIVXHqqF0+vm5rkhoo UjNClmlXuXlw2FanEd/oGFaAH3pTeCV2Ml3FWRyRIaTigOPwx4juE9uF4vE4hic+6q9m 38mQnzAJc1cvVd7EqD/hp4hYj93HjpkfMxW0vDPpMnevwiaRJJ7XwEbJDNwI3aKCJXOu djPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=e/ksiddUErz9dGVWE2UE8EQ9TOo//fHUKhGBIAL1Tuk=; b=D4iBL/tbJkKgLVL36+h7mfK/D5TGsBaaFpeBSnyOYi2C+RxOFvB2nIBl6arhbIjG4S QbQ47yeTrBvbE6U8tMfZGRFcB48Nb3PbmlP7008e/iFH/sqJ0HLs9fID+k/JrK7JmRzB hlsSbpIow7wEmLE+XFUHMS1XkjjfsV9YsbRlUupBw9jLylrYF3XOFHVNvxx9sTSCNmBL kBpuLjPVmqrWLd1G/rF3Kw0jzf0FgadKgdhlAXQkZleEU0TsKNVLy7ASS1cft8GAgw1o imUiXcpWG4sHI6Ic7B4eO6HqxMmHS3DfgAe7nV23oQ64UhqQLF1vaSOahnZblyH5fM6D x3xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Z3KhRTH7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h192si8654608oib.166.2020.03.16.02.31.44; Mon, 16 Mar 2020 02:31:56 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=Z3KhRTH7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730435AbgCPJb0 (ORCPT + 99 others); Mon, 16 Mar 2020 05:31:26 -0400 Received: from mail.skyhub.de ([5.9.137.197]:34070 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbgCPJbZ (ORCPT ); Mon, 16 Mar 2020 05:31:25 -0400 Received: from zn.tnic (p200300EC2F06AB0069F33882ABEAD541.dip0.t-ipconnect.de [IPv6:2003:ec:2f06:ab00:69f3:3882:abea:d541]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 544771EC0CD0; Mon, 16 Mar 2020 10:31:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1584351084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=e/ksiddUErz9dGVWE2UE8EQ9TOo//fHUKhGBIAL1Tuk=; b=Z3KhRTH7zoeWs62R9l7tErKfxlxS3sWy6e2hDrsDgxE0LhFp1a68YRUJEL8tVqWrG4AcPS xcgn7yOqdHyDH2ZMoojUmENGIZ623EQLdeWQzgmgu/Gz5Iw5PjHr3F5/mM6BtPDf4z1X5N MxeXJL9kOSOwawxGVW/XiH4ZiniC4BY= Date: Mon, 16 Mar 2020 10:31:34 +0100 From: Borislav Petkov To: Robert Richter Cc: Mauro Carvalho Chehab , Tony Luck , James Morse , Aristeu Rozanski , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/11] EDAC/ghes: Carve out MC device handling into separate functions Message-ID: <20200316093134.GB26126@zn.tnic> References: <20200306151318.17422-1-rrichter@marvell.com> <20200306151318.17422-7-rrichter@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200306151318.17422-7-rrichter@marvell.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2020 at 04:13:13PM +0100, Robert Richter wrote: > The functions are too long, carve out code that handles MC devices > into the new functions ghes_mc_create(), ghes_mc_add_or_free() and > ghes_mc_free(). Apart from better code readability the functions can > be reused and the implementation of the error paths becomes easier. > > Signed-off-by: Robert Richter > --- > drivers/edac/ghes_edac.c | 133 +++++++++++++++++++++++---------------- > 1 file changed, 79 insertions(+), 54 deletions(-) > > diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c > index 358519e8c2e9..5a4c9694bbff 100644 > --- a/drivers/edac/ghes_edac.c > +++ b/drivers/edac/ghes_edac.c > @@ -462,16 +462,81 @@ static struct acpi_platform_list plat_list[] = { > { } /* End */ > }; > > -int ghes_edac_register(struct ghes *ghes, struct device *dev) > +static struct mem_ctl_info *ghes_mc_create(struct device *dev, int mc_idx, > + int num_dimm) > { > - bool fake = false; > - int rc = 0, num_dimm = 0; > + struct edac_mc_layer layers[1]; > struct mem_ctl_info *mci; > struct ghes_mci *pvt; > - struct edac_mc_layer layers[1]; > - struct ghes_dimm_fill dimm_fill; > + > + layers[0].type = EDAC_MC_LAYER_ALL_MEM; > + layers[0].size = num_dimm; > + layers[0].is_virt_csrow = true; > + > + mci = edac_mc_alloc(mc_idx, ARRAY_SIZE(layers), layers, sizeof(*pvt)); > + if (!mci) > + return NULL; > + > + pvt = mci->pvt_info; > + pvt->mci = mci; > + > + mci->pdev = dev; > + mci->mtype_cap = MEM_FLAG_EMPTY; > + mci->edac_ctl_cap = EDAC_FLAG_NONE; > + mci->edac_cap = EDAC_FLAG_NONE; > + mci->mod_name = "ghes_edac.c"; > + mci->ctl_name = "ghes_edac"; > + mci->dev_name = "ghes"; > + > + return mci; > +} > + > +static int ghes_mc_add_or_free(struct mem_ctl_info *mci) ghes_mc_add() is good enough. The fact that the function has error handling doesn't need to be in the name. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette