linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Sebastian Reichel <sre@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Tony Lindgren <tony@atomide.com>
Cc: Rob Herring <robh@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Pavel Machek <pavel@ucw.cz>,
	linux-bluetooth@vger.kernel.org, linux-media@vger.kernel.org,
	linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCH 06/14] media: wl128x-radio: remove global radio_dev
Date: Fri, 21 Dec 2018 02:17:44 +0100	[thread overview]
Message-ID: <20181221011752.25627-7-sre@kernel.org> (raw)
In-Reply-To: <20181221011752.25627-1-sre@kernel.org>

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Move global radio_dev into device structure to prepare converting
this driver into a normal platform device driver supporting multiple
instances.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/media/radio/wl128x/fmdrv.h        |  2 +-
 drivers/media/radio/wl128x/fmdrv_common.c | 10 +++++---
 drivers/media/radio/wl128x/fmdrv_v4l2.c   | 28 +++++++----------------
 drivers/media/radio/wl128x/fmdrv_v4l2.h   |  2 +-
 4 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index fa89eef59295..4a337f38cfc9 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -197,7 +197,7 @@ struct fmtx_data {
 
 /* FM driver operation structure */
 struct fmdev {
-	struct video_device *radio_dev;	/* V4L2 video device pointer */
+	struct video_device radio_dev;	/* V4L2 video device pointer */
 	struct v4l2_device v4l2_dev;	/* V4L2 top level struct */
 	struct snd_card *card;	/* Card which holds FM mixer controls */
 	u16 asci_id;
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 6bbae074f02d..f77acec0addf 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -38,6 +38,8 @@
 #include "fmdrv_rx.h"
 #include "fmdrv_tx.h"
 
+struct fmdev *global_fmdev;
+
 /* Region info */
 static struct region_info region_configs[] = {
 	/* Europe/US */
@@ -1241,7 +1243,7 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name)
 	set_bit(FM_FW_DW_INPROGRESS, &fmdev->flag);
 
 	ret = request_firmware(&fw_entry, fw_name,
-				&fmdev->radio_dev->dev);
+				&fmdev->radio_dev.dev);
 	if (ret < 0) {
 		fmerr("Unable to read firmware(%s) content\n", fw_name);
 		return ret;
@@ -1629,6 +1631,7 @@ static int __init fm_drv_init(void)
 		fmerr("Can't allocate operation structure memory\n");
 		return ret;
 	}
+	global_fmdev = fmdev;
 	fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE;
 	fmdev->rx.rds.buff = kzalloc(fmdev->rx.rds.buf_size, GFP_KERNEL);
 	if (NULL == fmdev->rx.rds.buff) {
@@ -1657,9 +1660,10 @@ static int __init fm_drv_init(void)
 /* Module exit function. Ask FM V4L module to unregister video device */
 static void __exit fm_drv_exit(void)
 {
-	struct fmdev *fmdev = NULL;
+	struct fmdev *fmdev = global_fmdev;
 
-	fmdev = fm_v4l2_deinit_video_device();
+	/* Ask FM V4L module to unregister video device */
+	fm_v4l2_deinit_video_device(fmdev);
 	if (fmdev != NULL) {
 		kfree(fmdev->rx.rds.buff);
 		kfree(fmdev);
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index f541b5802844..affa9e199dfb 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -32,8 +32,6 @@
 #include "fmdrv_rx.h"
 #include "fmdrv_tx.h"
 
-static struct video_device gradio_dev;
-
 /* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
 
 /* Read RX RDS data */
@@ -540,23 +538,20 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
 	mutex_init(&fmdev->mutex);
 
 	/* Setup FM driver's V4L2 properties */
-	gradio_dev = fm_viddev_template;
-
-	video_set_drvdata(&gradio_dev, fmdev);
+	fmdev->radio_dev = fm_viddev_template;
 
-	gradio_dev.lock = &fmdev->mutex;
-	gradio_dev.v4l2_dev = &fmdev->v4l2_dev;
+	video_set_drvdata(&fmdev->radio_dev, fmdev);
+	fmdev->radio_dev.lock = &fmdev->mutex;
+	fmdev->radio_dev.v4l2_dev = &fmdev->v4l2_dev;
 
 	/* Register with V4L2 subsystem as RADIO device */
-	if (video_register_device(&gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
+	if (video_register_device(&fmdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) {
 		fmerr("Could not register video device\n");
 		return -ENOMEM;
 	}
 
-	fmdev->radio_dev = &gradio_dev;
-
 	/* Register to v4l2 ctrl handler framework */
-	fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler;
+	fmdev->radio_dev.ctrl_handler = &fmdev->ctrl_handler;
 
 	ret = v4l2_ctrl_handler_init(&fmdev->ctrl_handler, 5);
 	if (ret < 0) {
@@ -594,20 +589,13 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
 	return 0;
 }
 
-void *fm_v4l2_deinit_video_device(void)
+void fm_v4l2_deinit_video_device(struct fmdev *fmdev)
 {
-	struct fmdev *fmdev;
-
-
-	fmdev = video_get_drvdata(&gradio_dev);
-
 	/* Unregister to v4l2 ctrl handler framework*/
 	v4l2_ctrl_handler_free(&fmdev->ctrl_handler);
 
 	/* Unregister RADIO device from V4L2 subsystem */
-	video_unregister_device(&gradio_dev);
+	video_unregister_device(&fmdev->radio_dev);
 
 	v4l2_device_unregister(&fmdev->v4l2_dev);
-
-	return fmdev;
 }
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.h b/drivers/media/radio/wl128x/fmdrv_v4l2.h
index 9babb4ab2fad..b1a117eb0eb7 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.h
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.h
@@ -24,6 +24,6 @@
 #include <media/v4l2-ctrls.h>
 
 int fm_v4l2_init_video_device(struct fmdev *, int);
-void *fm_v4l2_deinit_video_device(void);
+void fm_v4l2_deinit_video_device(struct fmdev *);
 
 #endif
-- 
2.19.2


  parent reply	other threads:[~2018-12-21  1:19 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21  1:17 [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST Sebastian Reichel
2018-12-21  1:17 ` [PATCH 01/14] ARM: dts: LogicPD Torpedo: Add WiLink UART node Sebastian Reichel
2018-12-21 20:05   ` Adam Ford
2018-12-21  1:17 ` [PATCH 02/14] ARM: dts: IGEP: " Sebastian Reichel
2019-02-18 22:04   ` Enric Balletbo Serra
2018-12-21  1:17 ` [PATCH 03/14] ARM: OMAP2+: pdata-quirks: drop TI_ST/KIM support Sebastian Reichel
2018-12-21  1:17 ` [PATCH 04/14] media: wl128x-radio: remove module version Sebastian Reichel
2018-12-21  1:17 ` [PATCH 05/14] media: wl128x-radio: remove global radio_disconnected Sebastian Reichel
2018-12-22 19:10   ` Pavel Machek
2018-12-21  1:17 ` Sebastian Reichel [this message]
2018-12-22 19:16   ` [PATCH 06/14] media: wl128x-radio: remove global radio_dev Pavel Machek
2018-12-21  1:17 ` [PATCH 07/14] media: wl128x-radio: convert to platform device Sebastian Reichel
2018-12-22 19:17   ` Pavel Machek
2018-12-21  1:17 ` [PATCH 08/14] media: wl128x-radio: use device managed memory allocation Sebastian Reichel
2018-12-22 19:20   ` Pavel Machek
2018-12-21  1:17 ` [PATCH 09/14] media: wl128x-radio: load firmware from ti-connectivity/ Sebastian Reichel
2018-12-21  1:17 ` [PATCH 10/14] media: wl128x-radio: simplify fmc_prepare/fmc_release Sebastian Reichel
2018-12-22 19:29   ` Pavel Machek
2019-01-09 18:17     ` Sebastian Reichel
2018-12-21  1:17 ` [PATCH 11/14] media: wl128x-radio: fix skb debug printing Sebastian Reichel
2018-12-22 19:30   ` Pavel Machek
2018-12-21  1:17 ` [PATCH 12/14] media: wl128x-radio: move from TI_ST to hci_ll driver Sebastian Reichel
2018-12-23 15:56   ` Marcel Holtmann
2019-01-09 18:11     ` Sebastian Reichel
2019-01-09 19:24       ` Marcel Holtmann
2019-01-10  1:23         ` Rob Herring
2018-12-21  1:17 ` [PATCH 13/14] Bluetooth: btwilink: drop superseded driver Sebastian Reichel
2018-12-21  1:17 ` [PATCH 14/14] misc: ti-st: Drop " Sebastian Reichel
2018-12-21 21:10   ` Adam Ford
2018-12-21 18:02 ` [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST Tony Lindgren
2018-12-22  2:47   ` Sebastian Reichel
2018-12-23 16:15     ` Tony Lindgren
2018-12-22 20:36   ` Adam Ford
2018-12-23 16:22     ` Tony Lindgren
2018-12-22 20:08 ` Pavel Machek
2018-12-22 22:40   ` Pavel Machek
2019-01-10 17:42   ` Sebastian Reichel
2019-03-14  8:20 ` Hans Verkuil
2019-03-14 12:18   ` Adam Ford
2019-03-19 13:31   ` Sebastian Reichel
2019-05-07 17:26     ` Adam Ford
2019-05-07 18:34       ` Adam Ford
2019-05-08 20:58         ` Marcel Holtmann
2019-05-10 13:28           ` Adam Ford
2019-05-10 15:38             ` Marcel Holtmann
2019-09-30 23:42               ` Adam Ford
2019-10-02 19:03     ` Adam Ford
2019-10-03 13:42       ` Sebastian Reichel

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=20181221011752.25627-7-sre@kernel.org \
    --to=sre@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mchehab@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=tony@atomide.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 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).