From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2607:f8b0:4864:20::d42; helo=mail-io1-xd42.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 33D61211B5A57 for ; Tue, 15 Jan 2019 02:14:26 -0800 (PST) Received: by mail-io1-xd42.google.com with SMTP id c2so1578851iom.12 for ; Tue, 15 Jan 2019 02:14:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9Keeawte8uxQMe1tjIkoegxw+PnvZlJsv4X+RJdMekM=; b=F97YdFqrdTUUsRFKQS/RJRzIaDMCuPQcE3afaV9BYPc6lzJk60giTVlzgyeKjpUP9d YX3/xZG5p3I8GJOHPbEE5QxzrVoH7+gn4En9c5DUS+6XvuJPMgf3Y/hX1C1E3aCzY9jj 3yCUM6zXgX14QdwKL2aF53/k9AD9y6SEvsm5KtIOign9c0KCz4xsB0wKY+gd2Kg7m/95 jCKeC00PxcdX2LMOs4uXkfGBlccr+JseGAvmG/iItcTHpc0UENtS/ISpxN577VwGDue9 qGYwCyjSsyt+5t9GjlkRmK0l/bQfjiIb06IsdtH056du2KfK3FbdUfdZEBfCh+ZbNSVq WdYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9Keeawte8uxQMe1tjIkoegxw+PnvZlJsv4X+RJdMekM=; b=fd1yE4JUFCa7rNv7FvNLs+Es088le4dYHYVXYdR7jOFmR4OoZkBXfKSF1AmZHsUsF0 dY+FP46lxLboI2n+BvtrPtj7G2AqbZKH4QLlQHSXKsg7Wu6ZB5VV4sYZWBlBW819hjn/ k4p+jJ914hoORsLOUcljo4dmAAxKulm7Mds/APUorwyMs7c16cyKOXVx/PS3MsUNPBck GvctcMOmmsVT5lttSW0tO3mZOruEtXcW/yoJdJuatuFhePDzX+MMwmFz8e1v89m/jiPb 74umE3KwvUNFUOujkVUbVwQw3trYSPe/6ZTPYVQFYm73ygFTYreHmfEhLgk5EapPEr7h Zwvg== X-Gm-Message-State: AJcUukdP6DP2JCP4IRGRXBkpoIDBDsJBRdtjKP0N6bL0ZE+iPwvqXBK+ SbATKz3wV6fCDnhlYKWW74HenK9sYb+JBXIoEM5hQA== X-Google-Smtp-Source: ALg8bN4qlgTVyORbku2yC4OYCjV2ilv2O75d+P03PUhAAJpbGf+CmplfKbAyV2BTNtRU+5/GfjAN+Ns+isev9NqD014= X-Received: by 2002:a6b:92d6:: with SMTP id u205mr1587447iod.221.1547547265456; Tue, 15 Jan 2019 02:14:25 -0800 (PST) MIME-Version: 1.0 References: <1547084679-29597-1-git-send-email-mw@semihalf.com> <1547084679-29597-7-git-send-email-mw@semihalf.com> <20190114225845.3cnoerfpbbclsmdj@bivouac.eciton.net> <20190115095612.v7qwnmttzptayhee@bivouac.eciton.net> <20190115101208.x5afouybv6rkp3y2@bivouac.eciton.net> In-Reply-To: <20190115101208.x5afouybv6rkp3y2@bivouac.eciton.net> From: Marcin Wojtas Date: Tue, 15 Jan 2019 11:14:16 +0100 Message-ID: To: Leif Lindholm Cc: edk2-devel-01 , Ard Biesheuvel , nadavh@marvell.com, "jsd@semihalf.com" , Grzegorz Jaszczyk , Kostya Porotchkin 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: Tue, 15 Jan 2019 10:14:26 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable wt., 15 sty 2019 o 11:12 Leif Lindholm napisa=C5= =82(a): > > On Tue, Jan 15, 2019 at 11:05:12AM +0100, Marcin Wojtas wrote: > > > > Anyway, I tried to play with the MV_BOARD_GPIO_DESCRIPTION to be th= e > > > > global variable, but was not convinced by the outcome. My biggest > > > > objection to the global variable and checking whether it's NULL in = the > > > > consumer driver is following - until now all users of the > > > > BoardDescProtocol 'know' and call only the relevant protocol routin= e, > > > > everything what happens underneath (PCDs, variable names, etc) is > > > > transparent. > > > > > > > > The consumers should be responsible for avoiding the memory leaks a= nd > > > > this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have > > > > now fixed error path an properly take care of freeing the memory af= ter > > > > using protocol. > > > > > > But the call sites don't keep track of freeing it when error handling= . > > > > > > Which I think serves as a clear demonstrator of how magically > > > allocating buffers makes for difficult code to keep correct. (Which i= s > > > why the UEFI intefaces all require you to allocate a buffer and then > > > pass that and a size as parameters.) > > > > > > So, since we are dealing with data that isn't changing, I prefer the > > > original design - just not the original implemenation. > > > > > > So how about sticking with that, but moving the STATIC struct global > > > in that source file (but keeping it STATIC)? > > > > > > > Good, keeping the global variable inside MvBoardDescDxe and checking > > it there is a clean and easy solution (consumers won't have to bother > > about the stuff additional to calling the protocol and error handling > > will be simpler). > > > > How about on top of the file I add a section for global varibles (IMO > > it's worth to modify other interfaces to that scheme later) and call > > it: > > > > STATIC MV_BOARD_GPIO_DESCRIPTION gGpioDescription; > > ? > > Static, so 'm', not 'g', but yeah. > Effectively it will be global to other files :) But I will change to 'm' prefix of course. Thanks, Marcin