linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] use a function for DVB media controller register
@ 2015-03-02 14:31 Mauro Carvalho Chehab
  2015-03-02 16:54 ` Tycho Lürsen
  0 siblings, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2015-03-02 14:31 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Antti Palosaari,
	Matthias Schwarzott, Hans Verkuil,
	Rafael Lourenço de Lima Chehab

This is really a simple function, but using it avoids to have
if's inside the drivers.

Also, the kABI becomes a little more clearer.

This shouldn't generate any overhead, and the type check
will happen when compiling with MC DVB enabled.

So, let's do it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index c739725ca7ee..367b8e77feb8 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -1104,9 +1104,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
 		pr_err("dvb_register_adapter() failed %d\n", rc);
 		goto adapter_error;
 	}
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-	client->adapter.mdev = coredev->media_dev;
-#endif
+	dvb_register_media_controller(&client->adapter, coredev->media_dev);
 
 	/* init dvb demux */
 	client->demux.dmx.capabilities = DMX_TS_FILTERING;
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index 556c9e9d1d4e..12629b8ecb0c 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -125,8 +125,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);
 
 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
 void dvb_create_media_graph(struct dvb_adapter *adap);
+static inline void dvb_register_media_controller(struct dvb_adapter *adap,
+						 struct media_device *mdev)
+{
+	adap->mdev = mdev;
+}
+
 #else
 static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
+#define dvb_register_media_controller(a, b) {}
 #endif
 
 extern int dvb_generic_open (struct inode *inode, struct file *file);
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 8bf2baae387f..ff39bf22442d 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -465,9 +465,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
 		       dev->name, result);
 		goto fail_adapter;
 	}
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-	dvb->adapter.mdev = dev->media_dev;
-#endif
+	dvb_register_media_controller(&dvb->adapter, dev->media_dev);
 
 	/* Ensure all frontends negotiate bus access */
 	dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl;
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index 8bd08ba4f869..f5df9eaba04f 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -429,7 +429,7 @@ static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap)
 		return;
 	}
 
-	adap->dvb_adap.mdev = mdev;
+	dvb_register_media_controller(&adap->dvb_adap, mdev);
 
 	dev_info(&d->udev->dev, "media controller created\n");
 
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
index 980d976960d9..7b7b834777b7 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
@@ -122,7 +122,7 @@ static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap)
 		kfree(mdev);
 		return;
 	}
-	adap->dvb_adap.mdev = mdev;
+	dvb_register_media_controller(&adap->dvb_adap, mdev);
 
 	dev_info(&d->udev->dev, "media controller created\n");
 #endif
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] [media] use a function for DVB media controller register
  2015-03-02 14:31 [PATCH] [media] use a function for DVB media controller register Mauro Carvalho Chehab
@ 2015-03-02 16:54 ` Tycho Lürsen
  2015-03-02 17:06   ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 5+ messages in thread
From: Tycho Lürsen @ 2015-03-02 16:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Antti Palosaari, Matthias Schwarzott,
	Hans Verkuil, Rafael Lourenço de Lima Chehab

Hi Mauro,
Op 02-03-15 om 15:31 schreef Mauro Carvalho Chehab:
> This is really a simple function, but using it avoids to have
> if's inside the drivers.
>
> Also, the kABI becomes a little more clearer.
>
> This shouldn't generate any overhead, and the type check
> will happen when compiling with MC DVB enabled.
>
> So, let's do it.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>
> diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
> index c739725ca7ee..367b8e77feb8 100644
> --- a/drivers/media/common/siano/smsdvb-main.c
> +++ b/drivers/media/common/siano/smsdvb-main.c
> @@ -1104,9 +1104,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
>   		pr_err("dvb_register_adapter() failed %d\n", rc);
>   		goto adapter_error;
>   	}
> -#ifdef CONFIG_MEDIA_CONTROLLER_DVB
> -	client->adapter.mdev = coredev->media_dev;
> -#endif
> +	dvb_register_media_controller(&client->adapter, coredev->media_dev);
>   
>   	/* init dvb demux */
>   	client->demux.dmx.capabilities = DMX_TS_FILTERING;
> diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
> index 556c9e9d1d4e..12629b8ecb0c 100644
> --- a/drivers/media/dvb-core/dvbdev.h
> +++ b/drivers/media/dvb-core/dvbdev.h
> @@ -125,8 +125,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);
>   
>   #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>   void dvb_create_media_graph(struct dvb_adapter *adap);
> +static inline void dvb_register_media_controller(struct dvb_adapter *adap,
> +						 struct media_device *mdev)
> +{
> +	adap->mdev = mdev;
> +}
> +
>   #else
>   static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
> +#define dvb_register_media_controller(a, b) {}
>   #endif
Does "#define dvb_register_media_controller(a, b) {}" restrict the 
number of registerd controllers in any way?
I mean, I've got a couple of TBS quad adapters, 4 tuner and 4 demod 
chips on each card. Will they still work with this change?
>   
>   extern int dvb_generic_open (struct inode *inode, struct file *file);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> index 8bf2baae387f..ff39bf22442d 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> @@ -465,9 +465,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
>   		       dev->name, result);
>   		goto fail_adapter;
>   	}
> -#ifdef CONFIG_MEDIA_CONTROLLER_DVB
> -	dvb->adapter.mdev = dev->media_dev;
> -#endif
> +	dvb_register_media_controller(&dvb->adapter, dev->media_dev);
>   
>   	/* Ensure all frontends negotiate bus access */
>   	dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl;
> diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> index 8bd08ba4f869..f5df9eaba04f 100644
> --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> @@ -429,7 +429,7 @@ static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap)
>   		return;
>   	}
>   
> -	adap->dvb_adap.mdev = mdev;
> +	dvb_register_media_controller(&adap->dvb_adap, mdev);
>   
>   	dev_info(&d->udev->dev, "media controller created\n");
>   
> diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
> index 980d976960d9..7b7b834777b7 100644
> --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
> +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
> @@ -122,7 +122,7 @@ static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap)
>   		kfree(mdev);
>   		return;
>   	}
> -	adap->dvb_adap.mdev = mdev;
> +	dvb_register_media_controller(&adap->dvb_adap, mdev);
>   
>   	dev_info(&d->udev->dev, "media controller created\n");
>   #endif


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [media] use a function for DVB media controller register
  2015-03-02 16:54 ` Tycho Lürsen
@ 2015-03-02 17:06   ` Mauro Carvalho Chehab
  2015-03-02 17:37     ` Tycho Lürsen
  0 siblings, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2015-03-02 17:06 UTC (permalink / raw)
  To: Tycho Lürsen
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Antti Palosaari,
	Matthias Schwarzott, Hans Verkuil,
	Rafael Lourenço de Lima Chehab

Em Mon, 02 Mar 2015 17:54:53 +0100
Tycho Lürsen <tycholursen@gmail.com> escreveu:

> Hi Mauro,
> Op 02-03-15 om 15:31 schreef Mauro Carvalho Chehab:
> > This is really a simple function, but using it avoids to have
> > if's inside the drivers.
> >
> > Also, the kABI becomes a little more clearer.
> >
> > This shouldn't generate any overhead, and the type check
> > will happen when compiling with MC DVB enabled.
> >
> > So, let's do it.
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> >
> > diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
> > index c739725ca7ee..367b8e77feb8 100644
> > --- a/drivers/media/common/siano/smsdvb-main.c
> > +++ b/drivers/media/common/siano/smsdvb-main.c
> > @@ -1104,9 +1104,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
> >   		pr_err("dvb_register_adapter() failed %d\n", rc);
> >   		goto adapter_error;
> >   	}
> > -#ifdef CONFIG_MEDIA_CONTROLLER_DVB
> > -	client->adapter.mdev = coredev->media_dev;
> > -#endif
> > +	dvb_register_media_controller(&client->adapter, coredev->media_dev);
> >   
> >   	/* init dvb demux */
> >   	client->demux.dmx.capabilities = DMX_TS_FILTERING;
> > diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
> > index 556c9e9d1d4e..12629b8ecb0c 100644
> > --- a/drivers/media/dvb-core/dvbdev.h
> > +++ b/drivers/media/dvb-core/dvbdev.h
> > @@ -125,8 +125,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);
> >   
> >   #ifdef CONFIG_MEDIA_CONTROLLER_DVB
> >   void dvb_create_media_graph(struct dvb_adapter *adap);
> > +static inline void dvb_register_media_controller(struct dvb_adapter *adap,
> > +						 struct media_device *mdev)
> > +{
> > +	adap->mdev = mdev;
> > +}
> > +
> >   #else
> >   static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
> > +#define dvb_register_media_controller(a, b) {}
> >   #endif
> Does "#define dvb_register_media_controller(a, b) {}" restrict the 
> number of registerd controllers in any way?
> I mean, I've got a couple of TBS quad adapters, 4 tuner and 4 demod 
> chips on each card. Will they still work with this change?

No. What the above define does is to replace the function call by nothing,
if MEDIA_CONTROLLER_DVB is not set.

Neither it or the current patches for the media controller on DVB should
affect the TBS quad adapters. If you're having some regressions with it,
please report.

Regards,
Mauro

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [media] use a function for DVB media controller register
  2015-03-02 17:06   ` Mauro Carvalho Chehab
@ 2015-03-02 17:37     ` Tycho Lürsen
  2015-03-02 18:25       ` Tycho Lürsen
  0 siblings, 1 reply; 5+ messages in thread
From: Tycho Lürsen @ 2015-03-02 17:37 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Antti Palosaari,
	Matthias Schwarzott, Hans Verkuil,
	Rafael Lourenço de Lima Chehab

Hi Mauro,
Op 02-03-15 om 18:06 schreef Mauro Carvalho Chehab:
> Em Mon, 02 Mar 2015 17:54:53 +0100
> Tycho Lürsen <tycholursen@gmail.com> escreveu:
>
>> Hi Mauro,
>> Op 02-03-15 om 15:31 schreef Mauro Carvalho Chehab:
>>> This is really a simple function, but using it avoids to have
>>> if's inside the drivers.
>>>
>>> Also, the kABI becomes a little more clearer.
>>>
>>> This shouldn't generate any overhead, and the type check
>>> will happen when compiling with MC DVB enabled.
>>>
>>> So, let's do it.
>>>
>>> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>>>
>>> diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
>>> index c739725ca7ee..367b8e77feb8 100644
>>> --- a/drivers/media/common/siano/smsdvb-main.c
>>> +++ b/drivers/media/common/siano/smsdvb-main.c
>>> @@ -1104,9 +1104,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
>>>    		pr_err("dvb_register_adapter() failed %d\n", rc);
>>>    		goto adapter_error;
>>>    	}
>>> -#ifdef CONFIG_MEDIA_CONTROLLER_DVB
>>> -	client->adapter.mdev = coredev->media_dev;
>>> -#endif
>>> +	dvb_register_media_controller(&client->adapter, coredev->media_dev);
>>>    
>>>    	/* init dvb demux */
>>>    	client->demux.dmx.capabilities = DMX_TS_FILTERING;
>>> diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
>>> index 556c9e9d1d4e..12629b8ecb0c 100644
>>> --- a/drivers/media/dvb-core/dvbdev.h
>>> +++ b/drivers/media/dvb-core/dvbdev.h
>>> @@ -125,8 +125,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);
>>>    
>>>    #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>>>    void dvb_create_media_graph(struct dvb_adapter *adap);
>>> +static inline void dvb_register_media_controller(struct dvb_adapter *adap,
>>> +						 struct media_device *mdev)
>>> +{
>>> +	adap->mdev = mdev;
>>> +}
>>> +
>>>    #else
>>>    static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
>>> +#define dvb_register_media_controller(a, b) {}
>>>    #endif
>> Does "#define dvb_register_media_controller(a, b) {}" restrict the
>> number of registerd controllers in any way?
>> I mean, I've got a couple of TBS quad adapters, 4 tuner and 4 demod
>> chips on each card. Will they still work with this change?
> No. What the above define does is to replace the function call by nothing,
> if MEDIA_CONTROLLER_DVB is not set.
>
> Neither it or the current patches for the media controller on DVB should
> affect the TBS quad adapters. If you're having some regressions with it,
> please report.
>
> Regards,
> Mauro
Thanks for your reply, I will test this for regression as soon as it 
hits the master branch.

Regards,
Tycho.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [media] use a function for DVB media controller register
  2015-03-02 17:37     ` Tycho Lürsen
@ 2015-03-02 18:25       ` Tycho Lürsen
  0 siblings, 0 replies; 5+ messages in thread
From: Tycho Lürsen @ 2015-03-02 18:25 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Antti Palosaari,
	Matthias Schwarzott, Hans Verkuil,
	Rafael Lourenço de Lima Chehab

Hi Mauro,
I tested this an I've got no issues to report.

If I was in the position to do so, I'd ack these patches.

Regards,
Tycho


Op 02-03-15 om 18:37 schreef Tycho Lürsen:
> Hi Mauro,
> Op 02-03-15 om 18:06 schreef Mauro Carvalho Chehab:
>> Em Mon, 02 Mar 2015 17:54:53 +0100
>> Tycho Lürsen <tycholursen@gmail.com> escreveu:
>>
>>> Hi Mauro,
>>> Op 02-03-15 om 15:31 schreef Mauro Carvalho Chehab:
>>>> This is really a simple function, but using it avoids to have
>>>> if's inside the drivers.
>>>>
>>>> Also, the kABI becomes a little more clearer.
>>>>
>>>> This shouldn't generate any overhead, and the type check
>>>> will happen when compiling with MC DVB enabled.
>>>>
>>>> So, let's do it.
>>>>
>>>> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>>>>
>>>> diff --git a/drivers/media/common/siano/smsdvb-main.c 
>>>> b/drivers/media/common/siano/smsdvb-main.c
>>>> index c739725ca7ee..367b8e77feb8 100644
>>>> --- a/drivers/media/common/siano/smsdvb-main.c
>>>> +++ b/drivers/media/common/siano/smsdvb-main.c
>>>> @@ -1104,9 +1104,7 @@ static int smsdvb_hotplug(struct 
>>>> smscore_device_t *coredev,
>>>>            pr_err("dvb_register_adapter() failed %d\n", rc);
>>>>            goto adapter_error;
>>>>        }
>>>> -#ifdef CONFIG_MEDIA_CONTROLLER_DVB
>>>> -    client->adapter.mdev = coredev->media_dev;
>>>> -#endif
>>>> +    dvb_register_media_controller(&client->adapter, 
>>>> coredev->media_dev);
>>>>           /* init dvb demux */
>>>>        client->demux.dmx.capabilities = DMX_TS_FILTERING;
>>>> diff --git a/drivers/media/dvb-core/dvbdev.h 
>>>> b/drivers/media/dvb-core/dvbdev.h
>>>> index 556c9e9d1d4e..12629b8ecb0c 100644
>>>> --- a/drivers/media/dvb-core/dvbdev.h
>>>> +++ b/drivers/media/dvb-core/dvbdev.h
>>>> @@ -125,8 +125,15 @@ extern void dvb_unregister_device (struct 
>>>> dvb_device *dvbdev);
>>>>       #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>>>>    void dvb_create_media_graph(struct dvb_adapter *adap);
>>>> +static inline void dvb_register_media_controller(struct 
>>>> dvb_adapter *adap,
>>>> +                         struct media_device *mdev)
>>>> +{
>>>> +    adap->mdev = mdev;
>>>> +}
>>>> +
>>>>    #else
>>>>    static inline void dvb_create_media_graph(struct dvb_adapter 
>>>> *adap) {}
>>>> +#define dvb_register_media_controller(a, b) {}
>>>>    #endif
>>> Does "#define dvb_register_media_controller(a, b) {}" restrict the
>>> number of registerd controllers in any way?
>>> I mean, I've got a couple of TBS quad adapters, 4 tuner and 4 demod
>>> chips on each card. Will they still work with this change?
>> No. What the above define does is to replace the function call by 
>> nothing,
>> if MEDIA_CONTROLLER_DVB is not set.
>>
>> Neither it or the current patches for the media controller on DVB should
>> affect the TBS quad adapters. If you're having some regressions with it,
>> please report.
>>
>> Regards,
>> Mauro
> Thanks for your reply, I will test this for regression as soon as it 
> hits the master branch.
>
> Regards,
> Tycho.
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-02 18:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02 14:31 [PATCH] [media] use a function for DVB media controller register Mauro Carvalho Chehab
2015-03-02 16:54 ` Tycho Lürsen
2015-03-02 17:06   ` Mauro Carvalho Chehab
2015-03-02 17:37     ` Tycho Lürsen
2015-03-02 18:25       ` Tycho Lürsen

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).