From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752444AbbB1DeP (ORCPT ); Fri, 27 Feb 2015 22:34:15 -0500 Received: from mail-pd0-f179.google.com ([209.85.192.179]:41351 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbbB1DeO (ORCPT ); Fri, 27 Feb 2015 22:34:14 -0500 Date: Sat, 28 Feb 2015 12:34:15 +0900 From: Sergey Senozhatsky To: Andrew Morton Cc: Sergey Senozhatsky , Minchan Kim , Jerome Marchand , Nitin Gupta , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Alan Cox Subject: Re: [PATCH 0/8] introduce dynamic device creation/removal Message-ID: <20150228033415.GC5768@swordfish> References: <1424959843-20409-1-git-send-email-sergey.senozhatsky@gmail.com> <20150227145109.b5656bdf853c2d283bf9268e@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150227145109.b5656bdf853c2d283bf9268e@linux-foundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (02/27/15 14:51), Andrew Morton wrote: > hoo boy. Creating a /dev node and doing ioctls on it is really old > school. So old school that I've forgotten why we don't do it any more. > > Hopefully Alan can recall the thinking? > perhaps, something like static struct class_attribute zram_class_attrs[] = { __ATTR(zram_control, S_IWUSR | S_IRUGO, zram_control_show, zram_control_store), __ATTR_NULL, }; struct class zram_class = { .name = "zram-control", .class_attrs = zram_class_attrs, }; class_register(&zram_class); or (even better) separate control files static struct class_attribute zram_class_attrs[] = { __ATTR(zram_add, ....), __ATTR(zram_remove, ....), __ATTR_NULL, }; so we can just echo `device_id' to add/remove devices echo 1 > /sys/class/zram-control/zram_add echo 1 > /sys/class/zram-control/zram_remove handling it in FOO_store() functions: static ssize_t zram_add_store(struct class *class, struct class_attribute *attr, char *buf) how about this? -ss