lkml.org 
[lkml]   [2015]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 0/8] introduce dynamic device creation/removal
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


\
 
 \ /
  Last update: 2015-02-28 04:41    [W:0.096 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site