UPSTREAM: char_dev: pin parent kobject
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 22 Oct 2012 00:57:19 +0000 (17:57 -0700)
committerGerrit <chrome-bot@google.com>
Fri, 2 Nov 2012 17:47:22 +0000 (10:47 -0700)
commit0389bf5d192fb822271e5e63068a84775a2c7c79
treedfc73f55295fe6e6694f958716e48cee49c0ac67
parenta16583b2a0799fffc4f3df22a15a282f851e3735
UPSTREAM: char_dev: pin parent kobject

In certain cases (for example when a cdev structure is embedded into
another object whose lifetime is controlled by a separate kobject) it is
beneficial to tie lifetime of another object to the lifetime of
character device so that related object is not freed until after
char_dev object is freed.

To achieve this let's pin kobject's parent when doing cdev_add() and
unpin when last reference to cdev structure is being released.

BUG=chrome-os-partner:15849
TEST=suspend_stress_test

Change-Id: I35d1762c94afa8b3eda6329a0bf0cfc7dde98b7b
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Michael Spang <spang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37134
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
fs/char_dev.c