From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::443; helo=mail-wr1-x443.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 51232211B5A5E for ; Mon, 14 Jan 2019 14:58:49 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id u4so849789wrp.3 for ; Mon, 14 Jan 2019 14:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mkxGoW4Re+Y/47NmrFTrT6TrSRqlGM7S+vY5QEeYvMo=; b=kFpm6R1xUc4AzRIwQdV7MFvbLbmUvPCj8U2RXGt2Nep1ayp9aRW/d5ERp+Jqh+pVf3 RF5hqMQUc1KrZUW5JVadGWe/2LFtQAH4PHWZnQu1POnNGm/qaLQi3+jLhe+OnDiNuxMZ mz56ND6admWSCe6x35WSt4Ti9UOtGdW55iGP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mkxGoW4Re+Y/47NmrFTrT6TrSRqlGM7S+vY5QEeYvMo=; b=cEYomVefumElIbaWMOyGnITtGXv2KbjBbtNLsxKKNn7fjdxLCK+SATo2is1QqOm33n 89bgS9X58d+e3mc/496ChNO2cjDYdyRES+tcynef2pmYft0BpaigMjycvenRO+bWvsxk qcTmK2FpvD6xgXJci/BX4RL8atNusfqNabALtWdj4O7gaZdWF3Dn5CBMtT+GD0uxQNVh qi5vC08fKSukKsCpjSzGqCOOTtqR2N13bghwurKtMw7ZMjrrV+BpKGXdH4G8PyrSPARO ZuQi5Zrx6n99jZ6r19ks5tZLptugxVi5P9CPk4LND60QXi9xbO36NuEq+akM3FzwUGbC dtTQ== X-Gm-Message-State: AJcUukc8TlomO/am5WCiklCeci/2xW+vZWKhbUkwGpT+oWmxe5B3aSGo cjZv7u721q1Ati2rqJdpGt3DvyRe/6s= X-Google-Smtp-Source: ALg8bN6YM30ih23m9cqPhk9+6++4KMOF79Cy75/p3T6hmvpRIXT5Ekb8OIDGCkixQ7pU+JJ5IkZ7xw== X-Received: by 2002:a5d:6808:: with SMTP id w8mr548892wru.270.1547506727751; Mon, 14 Jan 2019 14:58:47 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id e16sm107527668wrn.72.2019.01.14.14.58.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 14:58:47 -0800 (PST) Date: Mon, 14 Jan 2019 22:58:45 +0000 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com Message-ID: <20190114225845.3cnoerfpbbclsmdj@bivouac.eciton.net> References: <1547084679-29597-1-git-send-email-mw@semihalf.com> <1547084679-29597-7-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1547084679-29597-7-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH v2 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2019 22:58:49 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 10, 2019 at 02:44:33AM +0100, Marcin Wojtas wrote: > Introduce new callback that can provide information > about GPIO SoC controllers, as well as on-board > I2C IO expanders. According ArmadaSoCDescLib > ArmadaBoardDescLib routines are used for > obtaining required data. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas > --- > Silicon/Marvell/Include/Protocol/BoardDesc.h | 8 ++++ > Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 43 ++++++++++++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h b/Silicon/Marvell/Include/Protocol/BoardDesc.h > index 1d57a16..02905ea 100644 > --- a/Silicon/Marvell/Include/Protocol/BoardDesc.h > +++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h > @@ -50,6 +50,13 @@ EFI_STATUS > > typedef > EFI_STATUS > +(EFIAPI *MV_BOARD_GPIO_DESCRIPTION_GET) ( > + IN MARVELL_BOARD_DESC_PROTOCOL *This, > + IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription > + ); > + > +typedef > +EFI_STATUS > (EFIAPI *MV_BOARD_DESC_I2C_GET) ( > IN MARVELL_BOARD_DESC_PROTOCOL *This, > IN OUT MV_BOARD_I2C_DESC **I2cDesc > @@ -113,6 +120,7 @@ struct _MARVELL_BOARD_DESC_PROTOCOL { > MV_BOARD_DESC_UTMI_GET BoardDescUtmiGet; > MV_BOARD_DESC_XHCI_GET BoardDescXhciGet; > MV_BOARD_DESC_FREE BoardDescFree; > + MV_BOARD_GPIO_DESCRIPTION_GET GpioDescriptionGet; > }; > > #endif // __MARVELL_BOARD_DESC_PROTOCOL_H__ > diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c > index f71bfc4..e348b85 100644 > --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c > +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c > @@ -100,6 +100,48 @@ MvBoardDescComPhyGet ( > > STATIC > EFI_STATUS > +MvBoardGpioDescriptionGet ( > + IN MARVELL_BOARD_DESC_PROTOCOL *This, > + IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription > + ) > +{ > + MV_BOARD_GPIO_DESCRIPTION *Description; My request on v1 was that this be refactored from a STATIC local variable to a global variable. > + UINTN SoCGpioCount, GpioExpanderCount; > + MV_GPIO_EXPANDER *GpioExpanders; > + GPIO_CONTROLLER *SoCGpio; > + EFI_STATUS Status; > + > + /* Get SoC data about all available GPIO controllers */ > + Status = ArmadaSoCGpioGet (&SoCGpio, &SoCGpioCount); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + /* Get per-board information about all available I2C IO expanders */ GPIO > + Status = ArmadaBoardGpioExpanderGet (&GpioExpanders, &GpioExpanderCount); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + /* Allocate and fill board description */ > + Description = AllocateZeroPool (sizeof (MV_BOARD_GPIO_DESCRIPTION)); Instead, this space is now dynamically allocated. But none of the call sites actually change, leading to potential memory leaks. I don't have a problem if you prefer an alternative solution to the one I propose, but please discuss the change first rather than submitting a new revision containing something I didn't ask for. / Leif > + if (Description == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + Description->SoCGpio = SoCGpio; > + Description->GpioDeviceCount = SoCGpioCount; > + Description->GpioExpanders = GpioExpanders; > + Description->GpioExpanderCount = GpioExpanderCount; > + > + *GpioDescription = Description; > + > + return EFI_SUCCESS; > +} > + > +STATIC > +EFI_STATUS > MvBoardDescI2cGet ( > IN MARVELL_BOARD_DESC_PROTOCOL *This, > IN OUT MV_BOARD_I2C_DESC **I2cDesc > @@ -571,6 +613,7 @@ MvBoardDescInitProtocol ( > BoardDescProtocol->BoardDescUtmiGet = MvBoardDescUtmiGet; > BoardDescProtocol->BoardDescXhciGet = MvBoardDescXhciGet; > BoardDescProtocol->BoardDescFree = MvBoardDescFree; > + BoardDescProtocol->GpioDescriptionGet = MvBoardGpioDescriptionGet; > > return EFI_SUCCESS; > } > -- > 2.7.4 >