Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3633204pxa; Sun, 9 Aug 2020 06:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgSSrQeFuqKyCt0ot9iffjY9zuypf6C0aKgyz6jfHk0nP25TaAbF81GrY3t0Nix9dxCj6d X-Received: by 2002:a17:906:fb04:: with SMTP id lz4mr18250393ejb.394.1596980628684; Sun, 09 Aug 2020 06:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596980628; cv=none; d=google.com; s=arc-20160816; b=M5j7xRtRxhukpDZ5bVzfWKTuUkfiT9xAXKkAi6rrsj3ic1q4bK5m2aPsereZAYkYqJ 5KXSr70ws6NUQsTygctE1hg+K+VQ/gQe6iki5/ym44Lx9QCtY5CVAx4x3Usvv+OCTsCO dR2LkoFSZz69llRaIa1F6oGuho/CYl+NmBbtCd96DuS2Jce1MdJXgvgZIIlnHhLtchAA QPqoQpTAbCEtnjGSUYPvlllIamVJ6HHQLd5BDfZJ8SzOwcndlOcTCoO9pQgEG6bLzL4W a+ni5LuL9STPQWVKLsTXBK0sg7lNC8VYtrL9h2lSNQDBXE1paD95+E+Je5esRMdWeXG8 LgmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ewe9EdTdS42zif4jbbCuVnI7/Ckzx0H/Z6BVskSCYWU=; b=Z/KC7jWEY+FhCjcDNBBEznIOBBQSEqGfrY6x41qWd1/kOLabetMzRPSawHnnpyC9gH As+SGQNHS4xYq0Q+HMsuHJw/9aN72StLS+2UzDYAMU3Hhl/aD8pkkLOvgWg8sTg4BrVV Rs04WGnetJ/tSYVMHT6HoODz7NmddDHLUgnLgxmvztZiwNiaG3YtfDrL+LdmCJByT2CA kbbzYQW8fGvPQ+8WxY0bbkrX4DqdKODHnAn/3PCC2IWkihIdiU/nW7haanzL0rYiCaNq 1NgMiHYf19G/wZOe5lcjfrKMqvXTqXLLj4Wu90y2T+xZaK0J0wY6r5QlDBYrRaU5ZHnp HCMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2pP5p4l1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp15si10292907ejc.199.2020.08.09.06.43.24; Sun, 09 Aug 2020 06:43:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2pP5p4l1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgHINm2 (ORCPT + 99 others); Sun, 9 Aug 2020 09:42:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:44832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgHINm1 (ORCPT ); Sun, 9 Aug 2020 09:42:27 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 8E9E6206B6; Sun, 9 Aug 2020 13:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596980546; bh=z5ggloJNSGbzFqqy5FHmnwMWQ3MZ9nRoSWZRpWR9klU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=2pP5p4l1UBj7LXtrfSEqaHQi1n0qTCP2tOejp5K7tgGCUl6sNPoRWR4+F2B1j36ln Fxh9c6u9oZyaisvh5P5Jd3KjTd7l82acjPoytbL3BDvwbNcUOWSlv/RqjfDf98xFkM IVcCj3Fm7boVUIEUt1TtKu+9xLkxS1x8Be74b/pM= Date: Sun, 9 Aug 2020 14:42:21 +0100 From: Jonathan Cameron To: David Lechner Cc: William Breathitt Gray , kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, David.Laight@ACULAB.COM Subject: Re: [PATCH v4 1/5] counter: Internalize sysfs interface code Message-ID: <20200809144221.6947ea6e@archlinux> In-Reply-To: <4061c9e4-775e-b7a6-14fa-446de4fae537@lechnology.com> References: <7209ac3d-d1ca-1b4c-b22c-8d98b13742e2@lechnology.com> <20200802210415.GA606173@shinobu> <4061c9e4-775e-b7a6-14fa-446de4fae537@lechnology.com> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 3 Aug 2020 15:00:49 -0500 David Lechner wrote: > On 8/2/20 4:04 PM, William Breathitt Gray wrote: > > On Tue, Jul 28, 2020 at 05:45:53PM -0500, David Lechner wrote: > >> On 7/21/20 2:35 PM, William Breathitt Gray wrote: > >>> This is a reimplementation of the Generic Counter driver interface. > > ... > > >>> -F: include/linux/counter_enum.h > >>> +F: include/uapi/linux/counter.h > >> > >> Seems odd to be introducing a uapi header here since this patch doesn't > >> make any changes to userspace. > > > > These defines are needed by userspace for the character device > > interface, but I see your point that at this point in the patchset they > > don't need to be exposed yet. > > > > I could create temporary include/linux/counter_types.h to house these > > defines, and then later move them to include/uapi/linux/counter.h in the > > character device interface introduction patch. Do you think I should do > > so? > > Since this patch is independent of the chardev changes and probably ready > to merge after one more round of review, I would say it probably makes > sense to just leave them in counter.h for now and move them to uapi when > the chardev interface is finalized. This way, we can just merge this patch > as soon as it is ready. > Agreed. ... > >>> /** > >>> * struct counter_device - Counter data structure > >>> - * @name: name of the device as it appears in the datasheet > >>> + * @name: name of the device > >>> * @parent: optional parent device providing the counters > >>> - * @device_state: internal device state container > >>> - * @ops: callbacks from driver > >>> + * @signal_read: optional read callback for Signals. The read value of > >>> + * the respective Signal should be passed back via the > >>> + * value parameter. > >>> + * @count_read: optional read callback for Counts. The read value of the > >>> + * respective Count should be passed back via the value > >>> + * parameter. > >>> + * @count_write: optional write callback for Counts. The write value for > >>> + * the respective Count is passed in via the value > >>> + * parameter. > >>> + * @function_read: optional read callback the Count function modes. The > >>> + * read function mode of the respective Count should be > >>> + * passed back via the function parameter. > >>> + * @function_write: option write callback for Count function modes. The > >>> + * function mode to write for the respective Count is > >>> + * passed in via the function parameter. > >>> + * @action_read: optional read callback the Synapse action modes. The > >>> + * read action mode of the respective Synapse should be > >>> + * passed back via the action parameter. > >>> + * @action_write: option write callback for Synapse action modes. The > >>> + * action mode to write for the respective Synapse is > >>> + * passed in via the action parameter. > >>> * @signals: array of Signals > >> > >> Why not keep the ops struct? > > > > Defining static ops structures in the drivers seemed to have no > > advantage when those callbacks are always used via the counter_device > > structure. I decided it'd be simpler to just set them directly in the > > counter_device structure then. > > > > I could reorganize them into an ops structure again if there's enough > > interest. > > I've been working on really constrained systems lately where every byte > counts, so this stuck out to me since there would be a copy of all > functions for each counter instance. But probably not that big of a deal > in the Linux kernel. :-) > In addition to that.. There are other advantages to keeping an ops structure including easy function order randomization (for security), plus the fact that we want to make any function pointers build time assignments if we possibly can. Makes them harder to attack. So in more recent kernel code we try to use ops structures wherever possible. Jonathan