From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A75EC35244 for ; Sat, 25 Jan 2020 13:29:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 007712071E for ; Sat, 25 Jan 2020 13:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579958973; bh=ZlARgGBv0efHgDPaj5HZbh4hEPn9xIvhPiiZnur8dEI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=T3bCo/870p27EF4grtwMVTn++bwg2lKDMQPKhzet0ZckhcKnK8GLmpMwOzxslr8f+ dR5zAfRRt1c4Xxq9YEFzIL/Kx+j/ajqx7QkG6WlswowURqABjH5Bl/ByMDEmfnin8M 3r9p3b9nKf9gz5WKsHfhpi4AB8bxBRRVUHQlATf0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbgAYN3c (ORCPT ); Sat, 25 Jan 2020 08:29:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:40316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbgAYN3b (ORCPT ); Sat, 25 Jan 2020 08:29:31 -0500 Received: from localhost (unknown [145.15.244.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 484E2206F0; Sat, 25 Jan 2020 13:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579958971; bh=ZlARgGBv0efHgDPaj5HZbh4hEPn9xIvhPiiZnur8dEI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B33H/q9u6nNS8fgmrR+xa9fC0LuzjgUzLU49IWbQm3xmL5ZpLOuYL7uWBgZ5iCAHn uNj2zoQd0jfz/sHHeNYBl4TRRRYykecoTvtmTT/foX9/2XHuIsoUPGLexAq/+vWD1k AbZp4FkwgfWJotDe6rziQVLRSOH6S/LE2zrYOaMM= Date: Sat, 25 Jan 2020 14:26:15 +0100 From: Greg KH To: Jeffrey Hugo Cc: Manivannan Sadhasivam , arnd@arndb.de, smohanad@codeaurora.org, kvalo@codeaurora.org, bjorn.andersson@linaro.org, hemantk@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/16] bus: mhi: core: Add support for registering MHI controllers Message-ID: <20200125132615.GA3516435@kroah.com> References: <20200123111836.7414-1-manivannan.sadhasivam@linaro.org> <20200123111836.7414-3-manivannan.sadhasivam@linaro.org> <20200124082939.GA2921617@kroah.com> <42c79181-9d97-3542-c6b0-1e37f9b2ff39@codeaurora.org> <20200124174707.GB3417153@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 24, 2020 at 11:12:57AM -0700, Jeffrey Hugo wrote: > On 1/24/2020 10:47 AM, Greg KH wrote: > > On Fri, Jan 24, 2020 at 07:24:43AM -0700, Jeffrey Hugo wrote: > > > > > +/** > > > > > + * struct mhi_result - Completed buffer information > > > > > + * @buf_addr: Address of data buffer > > > > > + * @dir: Channel direction > > > > > + * @bytes_xfer: # of bytes transferred > > > > > + * @transaction_status: Status of last transaction > > > > > + */ > > > > > +struct mhi_result { > > > > > + void *buf_addr; > > > > > > > > Why void *? > > > > > > Because its not possible to resolve this more clearly. The client provides > > > the buffer and knows what the structure is. The bus does not. Its just an > > > opaque pointer (hence void *) to the bus, and the client needs to decode it. > > > This is the struct that is handed to the client to allow them to decode the > > > activity (either a received buf, or a confirmation that a transmitted buf > > > has been consumed). > > > > Then shouldn't this be a "u8 *" instead as you are saying how many bytes > > are here? > > I'm sorry, I don't see the benefit of that. Can you elaborate on why you > think that u8 * is a better type? > > Sure, its an arbitrary byte stream from the perspective of the bus, but to > the client, 99% of the time its going to have some structure. So which side is in control here, the "bus" or the "client"? For the bus to care, it's a bytestream and should be represented as such (like you have) with a number of bytes in the "packet". If you already know the structure types, just make a union of all of the valid ones and be done with it. In other words, try to avoid using void * as much as is ever possible please. thanks, greg k-h