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::441; helo=mail-wr1-x441.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 02D9C211B5A57 for ; Tue, 15 Jan 2019 02:12:11 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id x10so2228161wrs.8 for ; Tue, 15 Jan 2019 02:12: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:in-reply-to:user-agent; bh=aguRD77TG1xDHkGxzeoWaQGUyf5o5jgP1HYIb2wpxz0=; b=Z9XlAoZlmrkAC0Glp/BhX/T0AMszu23Pct7hpyZAvCWHEUb0RrWWXhmEfWP/4kJo2K 1X6rene5xZKtvquXfIz9+/LYDqaG5tnoW7V7spKzNgiv1USbbrx3oKgagpZUJebe5FyH 9Yqze6Zl33NZrzymB15Hmq+FZtlyE+zmPj8V4= 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=aguRD77TG1xDHkGxzeoWaQGUyf5o5jgP1HYIb2wpxz0=; b=BS9oVJoJdTERJihlt/3gP3x836w8wIMHtetjk+NB725g9c/tdwR1iAK3ZmIw+nG7kI sGZWuA/9SbyEIg5ayn08WWIIWPNe68ohM0qJWC2KYtGZdezLCkElnvruN4s5p19Tl2rN zDDbPd1p85W9sXDsGkoF3vw+hXsVFDU5QSXAyEcbLFQ5QW2LssNjYhmHWuknU+rUx5ZQ 7TR4Nz24sZtuX+wjKt4ofStYEGNkVPcCqDfbm5eSWsNZ3TaP1CFXuJOUT04RY1OcSDrJ J0HqhKL9i+kqQBrwSabYAXzKeRlHeyyOGvFBSB6tKvTJNcAC6qhUoGSf5VRw+sh82ogu OOAA== X-Gm-Message-State: AJcUukcLRz0J91gu1M4kP7/CZIurBakXdt0JhNwPZUn+apQYxIpChUHm RMDq0bpqCjQqdrzfYxsWAVl6FQ== X-Google-Smtp-Source: ALg8bN640dQVPNqAxJck7OV3xrC5B8V55Yz8jV209w0+LMoaCHdPJfXEYWBj/QPMjFaEm9QTDBbzGw== X-Received: by 2002:adf:fe11:: with SMTP id n17mr2295504wrr.329.1547547130439; Tue, 15 Jan 2019 02:12: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 h10sm26716887wmf.44.2019.01.15.02.12.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jan 2019 02:12:09 -0800 (PST) Date: Tue, 15 Jan 2019 10:12: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: <20190115101208.x5afouybv6rkp3y2@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> 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:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 X-List-Received-Date: Tue, 15 Jan 2019 10:12:12 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Regards, Leif