summaryrefslogtreecommitdiff
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-22 12:10:49 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-23 07:19:39 -0300
commit6cf5dad17e913fce1ccb0c38e199eff15b0f03cc (patch)
treeb039fae16d8290e8d54e4e614a1a0fb3dfd7e34a /drivers/media/usb
parent41b44e35ba9b34e50a65c05ecf7642c07bd3e8aa (diff)
[media] media_device: move allocation out of media_device_*_init
Right now, media_device_pci_init and media_device_usb_init does media_device allocation internaly. That preents its usage when the media_device struct is embedded on some other structure. Move memory allocation outside it, to make it more generic. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/au0828/au0828-core.c10
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c4
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-dvb.c6
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c16
-rw-r--r--drivers/media/usb/siano/smsusb.c4
6 files changed, 28 insertions, 16 deletions
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index cfcd08ec388f..5fea4adef90b 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -191,13 +191,15 @@ static int au0828_media_device_init(struct au0828_dev *dev,
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- if (!dev->board.name)
- mdev = media_device_usb_init(udev, "unknown au0828");
- else
- mdev = media_device_usb_init(udev, dev->board.name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ if (!dev->board.name)
+ media_device_usb_init(mdev, udev, "unknown au0828");
+ else
+ media_device_usb_init(mdev, udev, dev->board.name);
+
dev->media_dev = mdev;
#endif
return 0;
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 29bd7536feed..c63248a18823 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1212,10 +1212,12 @@ static int cx231xx_media_device_init(struct cx231xx *dev,
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- mdev = media_device_usb_init(udev, dev->board.name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ media_device_usb_init(mdev, udev, dev->board.name);
+
dev->media_dev = mdev;
#endif
return 0;
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 58250250a443..3fbb2cd19f5e 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -408,10 +408,12 @@ static int dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
struct dvb_usb_device *d = adap_to_d(adap);
struct usb_device *udev = d->udev;
- mdev = media_device_usb_init(udev, d->name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ media_device_usb_init(mdev, udev, d->name);
+
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 7509408b0b8e..6477b04e95c7 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
@@ -103,7 +103,11 @@ static int dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
struct dvb_usb_device *d = adap->dev;
struct usb_device *udev = d->udev;
- mdev = media_device_usb_init(udev, d->desc->name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ if (!mdev)
+ return -ENOMEM;
+
+ media_device_usb_init(mdev, udev, d->desc->name);
dvb_register_media_controller(&adap->dvb_adap, mdev);
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 0bae26325253..1f4047b3f3f7 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3019,17 +3019,17 @@ static int em28xx_media_device_init(struct em28xx *dev,
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- if (udev->product) {
- mdev = media_device_usb_init(udev, udev->product);
- } else if (udev->manufacturer) {
- mdev = media_device_usb_init(udev, udev->manufacturer);
- } else {
- mdev = media_device_usb_init(udev, dev->name);
- }
-
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ if (udev->product)
+ media_device_usb_init(mdev, udev, udev->product);
+ else if (udev->manufacturer)
+ media_device_usb_init(mdev, udev, udev->manufacturer);
+ else
+ media_device_usb_init(mdev, udev, dev->name);
+
dev->media_dev = mdev;
#endif
return 0;
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 4a0def1e1528..c2e25876e93b 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -367,10 +367,12 @@ static void *siano_media_device_register(struct smsusb_device_t *dev,
struct sms_board *board = sms_get_board(board_id);
int ret;
- mdev = media_device_usb_init(udev, board->name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return NULL;
+ media_device_usb_init(mdev, udev, board->name);
+
ret = media_device_register(mdev);
if (ret) {
media_device_cleanup(mdev);