linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	m.szyprowski@samsung.com, kyungmin.park@samsung.com,
	thomas@tommie-lie.de, sean@mess.org, linux-input@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org, lars@opdenkamp.eu,
	kamil@wypas.org, Hans Verkuil <hansverk@cisco.com>
Subject: Re: [PATCHv8 07/15] cec: add HDMI CEC framework
Date: Tue, 18 Aug 2015 13:22:02 -0700	[thread overview]
Message-ID: <20150818202202.GA18724@dtor-pixel> (raw)
In-Reply-To: <20150818100020.GM7557@n2100.arm.linux.org.uk>

On Tue, Aug 18, 2015 at 11:00:20AM +0100, Russell King - ARM Linux wrote:
> On Tue, Aug 18, 2015 at 10:26:32AM +0200, Hans Verkuil wrote:
> > +	/* Part 2: Initialize and register the character device */
> > +	cdev_init(&cecdev->cdev, &cec_devnode_fops);
> > +	cecdev->cdev.owner = owner;
> > +
> > +	ret = cdev_add(&cecdev->cdev, MKDEV(MAJOR(cec_dev_t), cecdev->minor),
> > +									1);
> > +	if (ret < 0) {
> > +		pr_err("%s: cdev_add failed\n", __func__);
> > +		goto error;
> > +	}
> > +
> > +	/* Part 3: Register the cec device */
> > +	cecdev->dev.bus = &cec_bus_type;
> > +	cecdev->dev.devt = MKDEV(MAJOR(cec_dev_t), cecdev->minor);
> > +	cecdev->dev.release = cec_devnode_release;
> > +	if (cecdev->parent)
> > +		cecdev->dev.parent = cecdev->parent;
> > +	dev_set_name(&cecdev->dev, "cec%d", cecdev->minor);
> > +	ret = device_register(&cecdev->dev);
> 
> It's worth pointing out that you can greatly simplify the lifetime
> handling (you don't need to get and put cecdev->dev) if you make
> the cdev a child of the cecdev->dev.
> 
> If you grep for kobj.parent in drivers/ you'll see many drivers are
> doing this.
> 
> 	cecdev->cdev.kobj.parent = &cecdev->dev.kobj;
> 
> but you will need to call device_initialize() on cecdev->dev first,
> and use device_add() here.

This is basically a requirement if one embeds both device and a cdev
into the same structure. Trying to do get/put in the driver is racy,
you need to let framework know (by setting cdve's parent to the device
structure).

Thanks.

-- 
Dmitry

  reply	other threads:[~2015-08-19  5:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18  8:26 [PATCHv8 00/15] HDMI CEC framework Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 01/15] dts: exynos4*: add HDMI CEC pin definition to pinctrl Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 02/15] dts: exynos4: add node for the HDMI CEC device Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 03/15] dts: exynos4412-odroid*: enable " Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 04/15] input.h: add BUS_CEC type Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 05/15] HID: add HDMI CEC specific keycodes Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 06/15] rc: Add HDMI CEC protocol handling Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 07/15] cec: add HDMI CEC framework Hans Verkuil
2015-08-18 10:00   ` Russell King - ARM Linux
2015-08-18 20:22     ` Dmitry Torokhov [this message]
2015-08-18  8:26 ` [PATCHv8 08/15] cec.txt: add CEC framework documentation Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 09/15] DocBook/media: add CEC documentation Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 10/15] v4l2-subdev: add HDMI CEC ops Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 11/15] cec: adv7604: add cec support Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 12/15] cec: adv7842: " Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 13/15] cec: adv7511: " Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 14/15] cec: s5p-cec: Add s5p-cec driver Hans Verkuil
2015-08-18  8:26 ` [PATCHv8 15/15] cobalt: add cec support Hans Verkuil

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=20150818202202.GA18724@dtor-pixel \
    --to=dmitry.torokhov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hans.verkuil@cisco.com \
    --cc=hansverk@cisco.com \
    --cc=kamil@wypas.org \
    --cc=kyungmin.park@samsung.com \
    --cc=lars@opdenkamp.eu \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=sean@mess.org \
    --cc=thomas@tommie-lie.de \
    /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;
as well as URLs for NNTP newsgroup(s).