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::342; helo=mail-wm1-x342.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 5BF562118FF2F for ; Tue, 15 Jan 2019 02:26:11 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id t200so2629186wmt.0 for ; Tue, 15 Jan 2019 02:26:11 -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:content-transfer-encoding:in-reply-to :user-agent; bh=Pl+oZ0YJqB+HVpzmU1to8Y1XLbLoGi0KaXeHYRdmxBQ=; b=hijNqJX+NBs/t58F2AkLR/Lo6idydc1DWvj50ju8ihm93k0MNc4vcMfakg+RJnCIwv bTeO7YqmcGLfGO8loinr8JFy+6BGLO1fZ0QqltFqsp6eUA7h8SgwFNRvYpJc0OtbHO1U FLvNDCwBY9ap+7TQci0gVk02o4aASBSYy3WRA= 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:content-transfer-encoding :in-reply-to:user-agent; bh=Pl+oZ0YJqB+HVpzmU1to8Y1XLbLoGi0KaXeHYRdmxBQ=; b=kihViTWRyKW4foWMPDPnOCjU3CGBzfRUva79aTQljQdwhPpd+Vvjyw36Vvm7jYi1nW pedA7a+rR99mDT+sQtZqKH8hadHeyNWSHIfZJ2j7ueV28HjWqkQgP4FE4iFUfEunOcZY jd17YR1/wKIc0FiVrm3gZKBX8jH9xG/HMRz2I/AUjxGFXd5ZTrI900qYhcyI4HTC9rm9 0S34ICTHtBOwDsMjktCc7jz8QaFTqeqn8dxI6VIgmlb30RsEtaLhkXCqZJw2ac0JRL7A zbhz3Z3lwNLyPr4CDmvrJipFsaivz6l9OOZm1Ips+GnRd8vVNH8ZdagJPnmA15sYC+YS 4xQw== X-Gm-Message-State: AJcUukd/BYilwcNXzqOvESxXRFD1AGtQzcOhBplzQhHmyIoHHpgJn/pg /WuRvPJoybCluqmL0w+RCst1qg== X-Google-Smtp-Source: ALg8bN5X+SuDgO2GFSK6kNz+YCVAxH+kvDugergM1QZ17FoqQK0Kp7Ylx9oAajG4WziX16MGITdFbQ== X-Received: by 2002:a7b:c156:: with SMTP id z22mr2746949wmi.24.1547547970419; Tue, 15 Jan 2019 02:26:10 -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 j24sm86910222wrd.86.2019.01.15.02.26.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jan 2019 02:26:09 -0800 (PST) Date: Tue, 15 Jan 2019 10:26:08 +0000 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel-01 , Ard Biesheuvel , nadavh@marvell.com, "jsd@semihalf.com" , Grzegorz Jaszczyk , Kostya Porotchkin Message-ID: <20190115102608.5th6c4adyuksofh3@bivouac.eciton.net> 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> MIME-Version: 1.0 In-Reply-To: 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: Tue, 15 Jan 2019 10:26:12 -0000 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Jan 15, 2019 at 11:14:16AM +0100, Marcin Wojtas wrote: > wt., 15 sty 2019 o 11:12 Leif Lindholm napisaƂ(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 the > > > > > 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 routine, > > > > > everything what happens underneath (PCDs, variable names, etc) is > > > > > transparent. > > > > > > > > > > The consumers should be responsible for avoiding the memory leaks and > > > > > this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have > > > > > now fixed error path an properly take care of freeing the memory after > > > > > 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 is > > > > 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. Global is about visibility, not accessibility. This will not be globally visible. / Leif