From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v7 3/5] dma-buf: heaps: Add system heap to dmabuf heaps Date: Thu, 25 Jul 2019 06:02:04 -0700 Message-ID: <20190725130204.GG20286@infradead.org> References: <20190724003656.59780-1-john.stultz@linaro.org> <20190724003656.59780-4-john.stultz@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190724003656.59780-4-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org To: John Stultz Cc: lkml , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , Vincent Donnefort , Sudipto Paul , "Andrew F . Davis" , Christoph Hellwig , Chenbo Feng , Alistair Strachan , Hridya Valsaraju , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org > +struct system_heap { > + struct dma_heap *heap; > +} sys_heap; It seems like this structure could be removed and if would improve the code flow. > +static struct dma_heap_ops system_heap_ops = { > + .allocate = system_heap_allocate, > +}; > + > +static int system_heap_create(void) > +{ > + struct dma_heap_export_info exp_info; > + int ret = 0; > + > + exp_info.name = "system_heap"; > + exp_info.ops = &system_heap_ops; > + exp_info.priv = &sys_heap; > + > + sys_heap.heap = dma_heap_add(&exp_info); > + if (IS_ERR(sys_heap.heap)) > + ret = PTR_ERR(sys_heap.heap); > + > + return ret; The data structures here seem a little odd. I think you want to: - mark all dma_heap_ops instanes consts, as we generally do that for all structures containing function pointers - move the name into dma_heap_ops. - remove the dma_heap_export_info structure, which is a bit pointless - don't bother setting a private data, as you don't need it. If other heaps need private data I'd suggest to switch to embedding the dma_heap structure into containing structure insted so that you can use container_of to get at it. - also why is the free callback passed as a callback rather than kept in dma_heap_ops, next to the paired alloc one?