Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Wed, 7 Aug 2002 23:53:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Wed, 7 Aug 2002 23:53:17 -0400 Received: from samba.sourceforge.net ([198.186.203.85]:15086 "EHLO lists.samba.org") by vger.kernel.org with ESMTP id ; Wed, 7 Aug 2002 23:53:17 -0400 Date: Thu, 8 Aug 2002 13:44:07 +1000 From: Rusty Russell To: Patrick Mochel Cc: linux-kernel@vger.kernel.org Subject: Re: driverfs API Updates Message-Id: <20020808134407.18fe4041.rusty@rustcorp.com.au> In-Reply-To: References: X-Mailer: Sylpheed version 0.7.4 (GTK+ 1.2.10; powerpc-debian-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1469 Lines: 40 On Mon, 5 Aug 2002 12:17:13 -0700 (PDT) Patrick Mochel wrote: > I've also created a macro[1] for defining device attributes, that goes > like this: > > DEVICE_ATTR(name,"strname",mode,show,store); > > This will create a structure by the name of 'dev_attr_##name', where > ##name is the first parameter, which can then be passed to > device_create_file(). [2] Hi Patrick, I'll grab 2.5.31 when it comes out and play with it. Personally, I would get rid of the "strname" (make it implied by the variable name), and use type instead of show & store, eg: DEVICE_ATTR(frobbable, O_RDWR, int); This means you can (1) check that frobbable is actually an int at compile time (__check_int), (2) you can use __show_int and __store_int as standard routines, and (3) you can use your own types by: #define __check_frobbable_t(x) ((void)((&x) == (frobbable_t *)0) /* Define show_frobbable and store_frobbable here */ DEVICE_ATTR(frobbable, O_RDWR, frobbable_t); This ties into alot of other projects such as event logging, etc. Rusty. PS. yeah yeah, I'll send code RSN. -- there are those who do and those who hang on and you don't see too many doers quoting their contemporaries. -- Larry McVoy - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/