All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	tiwai@suse.com, clemens@ladisch.de, hans.verkuil@cisco.com,
	laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com,
	javier@osg.samsung.com, pawel@osciak.com,
	m.szyprowski@samsung.com, kyungmin.park@samsung.com,
	perex@perex.cz, arnd@arndb.de, tvboxspy@gmail.com, crope@iki.fi,
	ruchandani.tina@gmail.com, corbet@lwn.net,
	chehabrafael@gmail.com, k.kozlowski@samsung.com,
	stefanr@s5r6.in-berlin.de, inki.dae@samsung.com,
	jh1009.sung@samsung.com, elfring@users.sourceforge.net,
	prabhakar.csengg@gmail.com, sw0312.kim@samsung.com,
	p.zabel@pengutronix.de, ricardo.ribalda@gmail.com,
	labbott@fedoraproject.org, pierre-louis.bossart@linux.intel.com,
	ricard.wanderlof@axis.com, julian@jusst.de,
	takamichiho@gmail.com, dominic.sacre@gmx.de, misterpib@gmail.com,
	daniel@zonque.org, gtmkramer@xs4all.nl, normalperson@yhbt.net,
	joe@oampo.co.uk
Subject: Re: [PATCH v5 22/22] sound/usb: Use Media Controller API to share media resources
Date: Thu, 3 Mar 2016 15:21:52 -0300	[thread overview]
Message-ID: <20160303152152.303c85ea@recife.lan> (raw)
In-Reply-To: <56D76FBF.9050209@osg.samsung.com>

Em Wed, 2 Mar 2016 15:57:03 -0700
Shuah Khan <shuahkh@osg.samsung.com> escreveu:

> On 03/02/2016 01:41 PM, Dan Carpenter wrote:
> > On Wed, Mar 02, 2016 at 09:50:31AM -0700, Shuah Khan wrote:
> >> +	mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
> >> +	if (!mctl)
> >> +		return -ENOMEM;
> >> +
> >> +	mctl->media_dev = mdev;
> >> +	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
> >> +		intf_type = MEDIA_INTF_T_ALSA_PCM_PLAYBACK;
> >> +		mctl->media_entity.function = MEDIA_ENT_F_AUDIO_PLAYBACK;
> >> +		mctl->media_pad.flags = MEDIA_PAD_FL_SOURCE;
> >> +		mixer_pad = 1;
> >> +	} else {
> >> +		intf_type = MEDIA_INTF_T_ALSA_PCM_CAPTURE;
> >> +		mctl->media_entity.function = MEDIA_ENT_F_AUDIO_CAPTURE;
> >> +		mctl->media_pad.flags = MEDIA_PAD_FL_SINK;
> >> +		mixer_pad = 2;
> >> +	}
> >> +	mctl->media_entity.name = pcm->name;
> >> +	media_entity_pads_init(&mctl->media_entity, 1, &mctl->media_pad);
> >> +	ret =  media_device_register_entity(mctl->media_dev,
> >> +					    &mctl->media_entity);
> >> +	if (ret)
> >> +		goto err1;
> > 
> > Could we give this label a meaningful name instead of a number?
> > goto free_mctl;
> 
> I do see other places where numbered labels are used.
> Names might help with code readability.
> 
> register_entity_fail probably makes more sense as a
> label than free_mctl. In any case, I can address the
> labels in a follow-on patch.
> 
> > 
> >> +
> >> +	mctl->intf_devnode = media_devnode_create(mdev, intf_type, 0,
> >> +						  MAJOR(pcm_dev->devt),
> >> +						  MINOR(pcm_dev->devt));
> >> +	if (!mctl->intf_devnode) {
> >> +		ret = -ENOMEM;
> >> +		goto err2;
> > 
> > goto unregister_device;
> > 
> >> +	}
> >> +	mctl->intf_link = media_create_intf_link(&mctl->media_entity,
> >> +						 &mctl->intf_devnode->intf,
> >> +						 MEDIA_LNK_FL_ENABLED);
> >> +	if (!mctl->intf_link) {
> >> +		ret = -ENOMEM;
> >> +		goto err3;
> > 
> > goto delete_devnode;
> > 
> >> +	}
> >> +
> >> +	/* create link between mixer and audio */
> >> +	media_device_for_each_entity(entity, mdev) {
> >> +		switch (entity->function) {
> >> +		case MEDIA_ENT_F_AUDIO_MIXER:
> >> +			ret = media_create_pad_link(entity, mixer_pad,
> >> +						    &mctl->media_entity, 0,
> >> +						    MEDIA_LNK_FL_ENABLED);
> >> +			if (ret)
> >> +				goto err4;
> > 
> > This is a bit weird because we're inside a loop.  Shouldn't we call
> > media_entity_remove_links() or something if this is the second time
> > through the loop?
> 
> Links are removed from media_device_unregister_entity()
> which is called in the error path.
> 
> > 
> > I don't understand this.  The kernel has the media_entity_cleanup() stub
> > function which is supposed to do this but it hasn't been implemented
> > yet?
> > 
> 
> Please see above. Links are removed when entity is
> unregistered. media_entity_cleanup() is a stub. It
> isn't intended for removing links.

Shuah,

Please address the issue that Dan is pointing on a separate
patch.

Thanks,
Mauro

WARNING: multiple messages have this Message-ID (diff)
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	tiwai@suse.com, clemens@ladisch.de, hans.verkuil@cisco.com,
	laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com,
	javier@osg.samsung.com, pawel@osciak.com,
	m.szyprowski@samsung.com, kyungmin.park@samsung.com,
	perex@perex.cz, arnd@arndb.de, tvboxspy@gmail.com, crope@iki.fi,
	ruchandani.tina@gmail.com, corbet@lwn.net,
	chehabrafael@gmail.com, k.kozlowski@samsung.com,
	stefanr@s5r6.in-berlin.de, inki.dae@samsung.com,
	jh1009.sung@samsung.com, elfring@users.sourceforge.net,
	prabhakar.csengg@gmail.com, sw0312.kim@samsung.com,
	p.zabel@pengutronix.de, ricardo.ribalda@gmail.com,
	labbott@fedoraproject.org, pierre-louis.bossart@linux.intel.com,
	ricard.wanderlof@axis.com, julian@jusst.de,
	takamichiho@gmail.com, dominic.sacre@gmx.de, misterpib@gmail.com,
	daniel@zonque.org, gtmkramer@xs4all.nl, normalperson@yhbt.net,
	joe@oampo.co.uk, linuxbugs@vittgam.net, johan@oljud.se,
	klock.android@gmail.com, nenggun.kim@samsung.com,
	j.anaszewski@samsung.com, geliangtang@163.com,
	albert@huitsing.nl, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, alsa-devel@alsa-project.org
Subject: Re: [PATCH v5 22/22] sound/usb: Use Media Controller API to share media resources
Date: Thu, 3 Mar 2016 15:21:52 -0300	[thread overview]
Message-ID: <20160303152152.303c85ea@recife.lan> (raw)
In-Reply-To: <56D76FBF.9050209@osg.samsung.com>

Em Wed, 2 Mar 2016 15:57:03 -0700
Shuah Khan <shuahkh@osg.samsung.com> escreveu:

> On 03/02/2016 01:41 PM, Dan Carpenter wrote:
> > On Wed, Mar 02, 2016 at 09:50:31AM -0700, Shuah Khan wrote:
> >> +	mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
> >> +	if (!mctl)
> >> +		return -ENOMEM;
> >> +
> >> +	mctl->media_dev = mdev;
> >> +	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
> >> +		intf_type = MEDIA_INTF_T_ALSA_PCM_PLAYBACK;
> >> +		mctl->media_entity.function = MEDIA_ENT_F_AUDIO_PLAYBACK;
> >> +		mctl->media_pad.flags = MEDIA_PAD_FL_SOURCE;
> >> +		mixer_pad = 1;
> >> +	} else {
> >> +		intf_type = MEDIA_INTF_T_ALSA_PCM_CAPTURE;
> >> +		mctl->media_entity.function = MEDIA_ENT_F_AUDIO_CAPTURE;
> >> +		mctl->media_pad.flags = MEDIA_PAD_FL_SINK;
> >> +		mixer_pad = 2;
> >> +	}
> >> +	mctl->media_entity.name = pcm->name;
> >> +	media_entity_pads_init(&mctl->media_entity, 1, &mctl->media_pad);
> >> +	ret =  media_device_register_entity(mctl->media_dev,
> >> +					    &mctl->media_entity);
> >> +	if (ret)
> >> +		goto err1;
> > 
> > Could we give this label a meaningful name instead of a number?
> > goto free_mctl;
> 
> I do see other places where numbered labels are used.
> Names might help with code readability.
> 
> register_entity_fail probably makes more sense as a
> label than free_mctl. In any case, I can address the
> labels in a follow-on patch.
> 
> > 
> >> +
> >> +	mctl->intf_devnode = media_devnode_create(mdev, intf_type, 0,
> >> +						  MAJOR(pcm_dev->devt),
> >> +						  MINOR(pcm_dev->devt));
> >> +	if (!mctl->intf_devnode) {
> >> +		ret = -ENOMEM;
> >> +		goto err2;
> > 
> > goto unregister_device;
> > 
> >> +	}
> >> +	mctl->intf_link = media_create_intf_link(&mctl->media_entity,
> >> +						 &mctl->intf_devnode->intf,
> >> +						 MEDIA_LNK_FL_ENABLED);
> >> +	if (!mctl->intf_link) {
> >> +		ret = -ENOMEM;
> >> +		goto err3;
> > 
> > goto delete_devnode;
> > 
> >> +	}
> >> +
> >> +	/* create link between mixer and audio */
> >> +	media_device_for_each_entity(entity, mdev) {
> >> +		switch (entity->function) {
> >> +		case MEDIA_ENT_F_AUDIO_MIXER:
> >> +			ret = media_create_pad_link(entity, mixer_pad,
> >> +						    &mctl->media_entity, 0,
> >> +						    MEDIA_LNK_FL_ENABLED);
> >> +			if (ret)
> >> +				goto err4;
> > 
> > This is a bit weird because we're inside a loop.  Shouldn't we call
> > media_entity_remove_links() or something if this is the second time
> > through the loop?
> 
> Links are removed from media_device_unregister_entity()
> which is called in the error path.
> 
> > 
> > I don't understand this.  The kernel has the media_entity_cleanup() stub
> > function which is supposed to do this but it hasn't been implemented
> > yet?
> > 
> 
> Please see above. Links are removed when entity is
> unregistered. media_entity_cleanup() is a stub. It
> isn't intended for removing links.

Shuah,

Please address the issue that Dan is pointing on a separate
patch.

Thanks,
Mauro

  parent reply	other threads:[~2016-03-03 18:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 16:50 [PATCH v5 22/22] sound/usb: Use Media Controller API to share media resources Shuah Khan
2016-03-02 16:50 ` Shuah Khan
2016-03-02 20:41 ` Dan Carpenter
2016-03-02 20:41   ` Dan Carpenter
2016-03-02 22:57   ` Shuah Khan
2016-03-02 22:57     ` Shuah Khan
2016-03-03 10:36     ` Dan Carpenter
2016-03-03 10:36       ` Dan Carpenter
2016-03-03 14:25       ` Shuah Khan
2016-03-03 14:25         ` Shuah Khan
2016-03-03 18:21     ` Mauro Carvalho Chehab [this message]
2016-03-03 18:21       ` Mauro Carvalho Chehab
2016-03-03 19:06       ` Shuah Khan
2016-03-03 19:06         ` Shuah Khan
2016-03-05 10:00 ` Mauro Carvalho Chehab
2016-03-05 10:00   ` Mauro Carvalho Chehab
2016-03-07 14:16   ` Shuah Khan
2016-03-07 14:16     ` Shuah Khan
2016-03-07 20:03     ` Shuah Khan
2016-03-07 20:03       ` Shuah Khan
2016-03-07 22:06   ` Shuah Khan
2016-03-07 22:06     ` Shuah Khan
2016-03-07 22:10   ` Shuah Khan
2016-03-07 22:10     ` Shuah Khan

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=20160303152152.303c85ea@recife.lan \
    --to=mchehab@osg.samsung.com \
    --cc=arnd@arndb.de \
    --cc=chehabrafael@gmail.com \
    --cc=clemens@ladisch.de \
    --cc=corbet@lwn.net \
    --cc=crope@iki.fi \
    --cc=dan.carpenter@oracle.com \
    --cc=daniel@zonque.org \
    --cc=dominic.sacre@gmx.de \
    --cc=elfring@users.sourceforge.net \
    --cc=gtmkramer@xs4all.nl \
    --cc=hans.verkuil@cisco.com \
    --cc=inki.dae@samsung.com \
    --cc=javier@osg.samsung.com \
    --cc=jh1009.sung@samsung.com \
    --cc=joe@oampo.co.uk \
    --cc=julian@jusst.de \
    --cc=k.kozlowski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=labbott@fedoraproject.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=m.szyprowski@samsung.com \
    --cc=misterpib@gmail.com \
    --cc=normalperson@yhbt.net \
    --cc=p.zabel@pengutronix.de \
    --cc=pawel@osciak.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=prabhakar.csengg@gmail.com \
    --cc=ricard.wanderlof@axis.com \
    --cc=ricardo.ribalda@gmail.com \
    --cc=ruchandani.tina@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shuahkh@osg.samsung.com \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=sw0312.kim@samsung.com \
    --cc=takamichiho@gmail.com \
    --cc=tiwai@suse.com \
    --cc=tvboxspy@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.