Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1326388 > unrolled thread
| Started by | Shuah Khan <shuahkh@osg.samsung.com> |
|---|---|
| First post | 2016-02-04 05:10 +0100 |
| Last post | 2016-02-04 11:10 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 14/22] media: au0828 change to use Managed Media Controller API Shuah Khan <shuahkh@osg.samsung.com> - 2016-02-04 05:10 +0100
Re: [PATCH v2 14/22] media: au0828 change to use Managed Media Controller API Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-02-04 11:10 +0100
Re: [PATCH v2 14/22] media: au0828 change to use Managed Media Controller API Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-02-04 11:10 +0100
| From | Shuah Khan <shuahkh@osg.samsung.com> |
|---|---|
| Date | 2016-02-04 05:10 +0100 |
| Subject | [PATCH v2 14/22] media: au0828 change to use Managed Media Controller API |
| Message-ID | <qYjp1-3uR-37@gated-at.bofh.it> |
Change au0828 to use Managed Media Controller API to
share media device and coordinate creating/deleting
the shared media device with the snd-usb-audio driver.
The shared media device is created as device resource
of the parent usb device of the two drivers.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
drivers/media/usb/au0828/au0828-core.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index df2bc3f..b8c4bdd 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -134,10 +134,10 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
{
#ifdef CONFIG_MEDIA_CONTROLLER
- if (dev->media_dev) {
+ if (dev->media_dev &&
+ media_devnode_is_registered(&dev->media_dev->devnode)) {
media_device_unregister(dev->media_dev);
media_device_cleanup(dev->media_dev);
- kfree(dev->media_dev);
dev->media_dev = NULL;
}
#endif
@@ -223,23 +223,24 @@ static int au0828_media_device_init(struct au0828_dev *dev,
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ mdev = media_device_get_devres(&udev->dev);
if (!mdev)
return -ENOMEM;
- mdev->dev = &udev->dev;
+ if (!media_devnode_is_registered(&mdev->devnode)) {
+ mdev->dev = &udev->dev;
- if (!dev->board.name)
- strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
- else
- strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
- if (udev->serial)
- strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
- strcpy(mdev->bus_info, udev->devpath);
- mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
- mdev->driver_version = LINUX_VERSION_CODE;
+ if (udev->product)
+ strlcpy(mdev->model, udev->product,
+ sizeof(mdev->model));
+ if (udev->serial)
+ strlcpy(mdev->serial, udev->serial,
+ sizeof(mdev->serial));
+ strcpy(mdev->bus_info, udev->devpath);
+ mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
- media_device_init(mdev);
+ media_device_init(mdev);
+ }
dev->media_dev = mdev;
#endif
--
2.5.0
[toc] | [next] | [standalone]
| From | Mauro Carvalho Chehab <mchehab@osg.samsung.com> |
|---|---|
| Date | 2016-02-04 11:10 +0100 |
| Subject | Re: [PATCH v2 14/22] media: au0828 change to use Managed Media Controller API |
| Message-ID | <qYp1p-7ay-31@gated-at.bofh.it> |
| In reply to | #1326388 |
Em Thu, 4 Feb 2016 08:05:00 -0200
Mauro Carvalho Chehab <mchehab@osg.samsung.com> escreveu:
> Em Wed, 03 Feb 2016 21:03:46 -0700
> Shuah Khan <shuahkh@osg.samsung.com> escreveu:
>
> > Change au0828 to use Managed Media Controller API to
> > share media device and coordinate creating/deleting
> > the shared media device with the snd-usb-audio driver.
> > The shared media device is created as device resource
> > of the parent usb device of the two drivers.
> >
> > Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> > ---
> > drivers/media/usb/au0828/au0828-core.c | 29 +++++++++++++++--------------
> > 1 file changed, 15 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> > index df2bc3f..b8c4bdd 100644
> > --- a/drivers/media/usb/au0828/au0828-core.c
> > +++ b/drivers/media/usb/au0828/au0828-core.c
> > @@ -134,10 +134,10 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
> > {
> >
> > #ifdef CONFIG_MEDIA_CONTROLLER
> > - if (dev->media_dev) {
> > + if (dev->media_dev &&
> > + media_devnode_is_registered(&dev->media_dev->devnode)) {
> > media_device_unregister(dev->media_dev);
> > media_device_cleanup(dev->media_dev);
> > - kfree(dev->media_dev);
> > dev->media_dev = NULL;
> > }
> > #endif
> > @@ -223,23 +223,24 @@ static int au0828_media_device_init(struct au0828_dev *dev,
> > #ifdef CONFIG_MEDIA_CONTROLLER
> > struct media_device *mdev;
> >
> > - mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
> > + mdev = media_device_get_devres(&udev->dev);
> > if (!mdev)
> > return -ENOMEM;
> >
> > - mdev->dev = &udev->dev;
> > + if (!media_devnode_is_registered(&mdev->devnode)) {
> > + mdev->dev = &udev->dev;
> >
> > - if (!dev->board.name)
> > - strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
> > - else
> > - strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
> > - if (udev->serial)
> > - strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
> > - strcpy(mdev->bus_info, udev->devpath);
> > - mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
> > - mdev->driver_version = LINUX_VERSION_CODE;
> > + if (udev->product)
> > + strlcpy(mdev->model, udev->product,
> > + sizeof(mdev->model));
>
> Why did you change that? On some boards, udev->product doesn't reflect
> the brand name, but have just some random generic data.
>
> Also, as the other logs associated with the device uses dev->board.name,
> we want the media controller to use the same name here. Ok, if this
> is null, we could use udev->product as a replacement.
Ah, looking at patch 15/22, I understood why you wanted the above
change: if the device is registered first by ALSA, it won't have a
dev->board.name.
It looks OK to change from dev->board.name to udev->product then,
but please document the reason for it at the patch description.
Regards,
Mauro
[toc] | [prev] | [next] | [standalone]
| From | Mauro Carvalho Chehab <mchehab@osg.samsung.com> |
|---|---|
| Date | 2016-02-04 11:10 +0100 |
| Subject | Re: [PATCH v2 14/22] media: au0828 change to use Managed Media Controller API |
| Message-ID | <qYp1p-7ay-33@gated-at.bofh.it> |
| In reply to | #1326388 |
Em Wed, 03 Feb 2016 21:03:46 -0700
Shuah Khan <shuahkh@osg.samsung.com> escreveu:
> Change au0828 to use Managed Media Controller API to
> share media device and coordinate creating/deleting
> the shared media device with the snd-usb-audio driver.
> The shared media device is created as device resource
> of the parent usb device of the two drivers.
>
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> ---
> drivers/media/usb/au0828/au0828-core.c | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index df2bc3f..b8c4bdd 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -134,10 +134,10 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
> {
>
> #ifdef CONFIG_MEDIA_CONTROLLER
> - if (dev->media_dev) {
> + if (dev->media_dev &&
> + media_devnode_is_registered(&dev->media_dev->devnode)) {
> media_device_unregister(dev->media_dev);
> media_device_cleanup(dev->media_dev);
> - kfree(dev->media_dev);
> dev->media_dev = NULL;
> }
> #endif
> @@ -223,23 +223,24 @@ static int au0828_media_device_init(struct au0828_dev *dev,
> #ifdef CONFIG_MEDIA_CONTROLLER
> struct media_device *mdev;
>
> - mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
> + mdev = media_device_get_devres(&udev->dev);
> if (!mdev)
> return -ENOMEM;
>
> - mdev->dev = &udev->dev;
> + if (!media_devnode_is_registered(&mdev->devnode)) {
> + mdev->dev = &udev->dev;
>
> - if (!dev->board.name)
> - strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
> - else
> - strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
> - if (udev->serial)
> - strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
> - strcpy(mdev->bus_info, udev->devpath);
> - mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
> - mdev->driver_version = LINUX_VERSION_CODE;
> + if (udev->product)
> + strlcpy(mdev->model, udev->product,
> + sizeof(mdev->model));
Why did you change that? On some boards, udev->product doesn't reflect
the brand name, but have just some random generic data.
Also, as the other logs associated with the device uses dev->board.name,
we want the media controller to use the same name here. Ok, if this
is null, we could use udev->product as a replacement.
> + if (udev->serial)
> + strlcpy(mdev->serial, udev->serial,
> + sizeof(mdev->serial));
> + strcpy(mdev->bus_info, udev->devpath);
> + mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
>
> - media_device_init(mdev);
> + media_device_init(mdev);
> + }
>
> dev->media_dev = mdev;
> #endif
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web