public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Minchan Kim <minchan@kernel.org>,
	Jerome Marchand <jmarchan@redhat.com>,
	Nitin Gupta <ngupta@vflare.org>,
	linux-kernel@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH 0/8] introduce dynamic device creation/removal
Date: Fri, 27 Feb 2015 20:29:14 -0800	[thread overview]
Message-ID: <20150227202914.466bbb2e.akpm@linux-foundation.org> (raw)
In-Reply-To: <20150228033415.GC5768@swordfish>

On Sat, 28 Feb 2015 12:34:15 +0900 Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> 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?

That would be more conventional.  There's no pretty way of doing this
really.  

http://yarchive.net/comp/linux/ioctl.html does a pretty good job of the
thinking on ioctl - mainly the typelessness of it all.  That's very old
and doesn't discuss the 32/64 bit compat issues.

Your patch doesn't really have this problem at this stage, but once the
ioctl interface is added, new controls which are added later should use
it, and we're likely to get into the same issues.


  reply	other threads:[~2015-02-28  4:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 14:10 [PATCH 0/8] introduce dynamic device creation/removal Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 1/8] zram: cosmetic ZRAM_ATTR_RO code formatting tweak Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 2/8] zram: use idr instead of `zram_devices' array Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 3/8] zram: factor out device reset from reset_store() Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 4/8] zram: add dynamic device add/remove functionality Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 5/8] zram: return zram device_id value from zram_add() Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 6/8] zram: allow automatic new zram device_id assignment Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 7/8] zram: remove max_num_devices limitation Sergey Senozhatsky
2015-02-26 14:10 ` [PATCH 8/8] zram: report every added and removed device Sergey Senozhatsky
2015-02-27 22:51 ` [PATCH 0/8] introduce dynamic device creation/removal Andrew Morton
2015-02-28  1:33   ` Sergey Senozhatsky
2015-02-28  1:50     ` Sergey Senozhatsky
2015-02-28  3:34   ` Sergey Senozhatsky
2015-02-28  4:29     ` Andrew Morton [this message]
2015-03-02 14:18   ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150227202914.466bbb2e.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jmarchan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox