# Re: \[PATCH 1/2\] char\_dev: allow setting up and pinning parent devices

- From: Dmitry Torokhov \<dmitry.torokhov@gmail.com\>
- Date: 2012-10-21 08:13:35 
- List: linux-input
- Page: https://ratatoskr.run/linux-input/2012/10/3942819
- Thread: https://ratatoskr.run/linux-input/2012/10/3942813/t.md

```text
On Sun, Oct 21, 2012 at 08:39:28AM +0100, Al Viro wrote:
> On Sun, Oct 21, 2012 at 12:24:30AM -0700, Dmitry Torokhov wrote:
> > In certain cases (for example when a cdev structure is embedded into
> > another object whose lifetime is controlled by a separate device object)
> > it is beneficial to tie lifetime of another struct device to the lifetime
> > of character device so that related object is not freed until after
> > char_dev object is freed. To achieve this allow setting a "parent" device
> > for character devices and pin them when doing cdev_add() and unpin when
> > last reference to cdev structure is being released.
> 
> Why struct device and not simply struct kobject?

It was more convenient for my uses and I also think that parents of
character devices will be struct devices... I however will not insist
and if you prefer using more generic kobject I can change it,

Thanks.

-- 
Dmitry
```
