linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type
@ 2023-09-23 14:31 Umang Jain
  2023-09-23 14:31 ` [PATCH v12 1/6] staging: vc04_services: bcm2835-camera: Explicitly set DMA mask Umang Jain
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:31 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

The patch series added a new bus type vchiq_bus_type and registers
child devices in order to move them away from using platform
device/driver.

Tested on RPi-3-b with media tree master branch.

Patch 1/6 and 2/6 adds explicit DMA mask to bcm2835-camera
and bcm2835-audio respectively to avoid regression when moving
to away from platform device/driver model.

Patch 3/6 and 4/6 adds a new bus_type and registers them to vchiq
interface

Patch 5/6 and 6/6 moves the bcm2835-camera and bcm2835-audio
to the new bus respectively

Patch 5/5 removes a platform registeration helper which is no
longer required.

Changes in v12:
- Add initial two patches to set DMA Mask explicitly to avoid regression
- fixup vchiq_device.c bad squash in v11
- Rename vchiq_device.[ch] to vchiq_bus.[ch]
- Fix memory leak if device cannot be registered
- Make vchiq_bus_type_match() use bool values
- vchiq_register_child() helper removal folded in 6/6
  instead of creating extra patch.

Changes in v11:
- Move setting of DMA mask in child devices (3/5 and 4/5)
- Fixes "DMA mask not set issue" reported in v10.

Changes in v10:
- fix dma_attr WARN issue with bcm2835-audio module loading
- Unregister bus on parent platform device fails to register
- Reword commit to highlight bcm2835_audio to bcm2835-audio name change

Changes in v9:
- Fix module autoloading
- Implement bus_type's probe() callback to load drivers
- Implement bus_type's uevent() to make sure appropriate drivers are
  loaded when device are registed from vchiq.

Changes in v8:
- Drop dual licensing. Instead use GPL-2.0 only for patch 1/5

Changes in v7:
(5 out of 6 patches from v6 merged)
- Split the main patch (6/6) as requested.
- Use struct vchiq_device * instead of struct device * in
  all bus functions.
- Drop additional name attribute displayed in sysfs (redundant info)
- Document vchiq_interface doesn't enumerate device discovery
- remove EXPORT_SYMBOL_GPL(vchiq_bus_type)

Changes in v6:
- Split struct device and struct driver wrappers in vchiq_device.[ch]
- Move vchiq_bus_type definition to vchiq_device.[ch] as well
- return error on bus_register() failure
- drop dma_set_mask_and_coherent
- trivial variable name change

Changes in v5:
- Fixup missing "staging: " in commits' subject line
- No code changes from v4

Changes in v4:
- Introduce patches to drop include directives from Makefile

Changes in v3:
- Rework entirely to replace platform devices/driver model

-v2:
https://lore.kernel.org/all/20221222191500.515795-1-umang.jain@ideasonboard.com/

-v1:
https://lore.kernel.org/all/20221220084404.19280-1-umang.jain@ideasonboard.com/

Umang Jain (6):
  staging: vc04_services: bcm2835-camera: Explicitly set DMA mask
  staging: vc04_services: bcm2835-audio: Explicitly set DMA mask
  staging: vc04_services: vchiq_arm: Add new bus type and device type
  staging: vc04_services: vchiq_arm: Register vchiq_bus_type
  staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type
  staging: bcm2835-audio: Register bcm2835-audio with vchiq_bus_type

 drivers/staging/vc04_services/Makefile        |   1 +
 .../vc04_services/bcm2835-audio/bcm2835.c     |  26 +++--
 .../bcm2835-camera/bcm2835-camera.c           |  23 ++--
 .../interface/vchiq_arm/vchiq_arm.c           |  52 ++++-----
 .../interface/vchiq_arm/vchiq_bus.c           | 100 ++++++++++++++++++
 .../interface/vchiq_arm/vchiq_bus.h           |  54 ++++++++++
 6 files changed, 209 insertions(+), 47 deletions(-)
 create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
 create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h


base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v12 1/6] staging: vc04_services: bcm2835-camera: Explicitly set DMA mask
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
@ 2023-09-23 14:31 ` Umang Jain
  2023-09-23 14:31 ` [PATCH v12 2/6] staging: vc04_services: bcm2835-audio: " Umang Jain
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:31 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

In the following patches, vchiq_arm will be migrated to create and use
its own bus and all the vchiq drivers (bcm2835-camera, bcm2835-audio)
will be registered to it. Since the platform driver/device model
internally sets the DMA mask for its registered devices, we would have
to do it ourself when we remove the platform driver/device registration
for vchiq devices.

This patch explicitly sets the DMA mask to bcm2835-camera so as not
to introduce a regression when we move away from platform
device/driver model.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index 346d00df815a..fcad5118f3e8 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -1852,6 +1852,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
 	unsigned int resolutions[MAX_BCM2835_CAMERAS][2];
 	int i;
 
+	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	if (ret) {
+		dev_err(&pdev->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
+		return ret;
+	}
+
 	ret = vchiq_mmal_init(&instance);
 	if (ret < 0)
 		return ret;
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v12 2/6] staging: vc04_services: bcm2835-audio: Explicitly set DMA mask
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
  2023-09-23 14:31 ` [PATCH v12 1/6] staging: vc04_services: bcm2835-camera: Explicitly set DMA mask Umang Jain
@ 2023-09-23 14:31 ` Umang Jain
  2023-09-23 14:31 ` [PATCH v12 3/6] staging: vc04_services: vchiq_arm: Add new bus type and device type Umang Jain
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:31 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

In the following patches, vchiq_arm will be migrated to create and use
its own bus and all the vchiq drivers (bcm2835-camera, bcm2835-audio)
will be registered to it. Since the platform driver/device model
internally sets the DMA mask for its registered devices, we would have
to do it ourself when we remove the platform driver/device registration
for vchiq devices.

This patch explicitly sets the DMA mask to bcm2835-audio so as not
to introduce a regression when we move away from platform
device/driver model.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 drivers/staging/vc04_services/bcm2835-audio/bcm2835.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
index 00bc898b0189..f3ad2543d1c0 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
@@ -3,6 +3,7 @@
 
 #include <linux/platform_device.h>
 
+#include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -273,6 +274,12 @@ static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	int err;
 
+	err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+	if (err) {
+		dev_err(dev, "dma_set_mask_and_coherent failed: %d\n", err);
+		return err;
+	}
+
 	if (num_channels <= 0 || num_channels > MAX_SUBSTREAMS) {
 		num_channels = MAX_SUBSTREAMS;
 		dev_warn(dev, "Illegal num_channels value, will use %u\n",
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v12 3/6] staging: vc04_services: vchiq_arm: Add new bus type and device type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
  2023-09-23 14:31 ` [PATCH v12 1/6] staging: vc04_services: bcm2835-camera: Explicitly set DMA mask Umang Jain
  2023-09-23 14:31 ` [PATCH v12 2/6] staging: vc04_services: bcm2835-audio: " Umang Jain
@ 2023-09-23 14:31 ` Umang Jain
  2023-10-05  8:03   ` Greg Kroah-Hartman
  2023-09-23 14:31 ` [PATCH v12 4/6] staging: vc04_services: vchiq_arm: Register vchiq_bus_type Umang Jain
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:31 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

The devices that the vchiq interface registers (bcm2835-audio,
bcm2835-camera) are implemented and exposed by the VC04 firmware.
The device tree describes the VC04 itself with the resources required
to communicate with it through a mailbox interface. However, the
vchiq interface registers these devices as platform devices. This
also means the specific drivers for these devices are getting
registered as platform drivers. This is not correct and a blatant
abuse of platform device/driver.

Add a new bus type, vchiq_bus_type and device type (struct vchiq_device)
which will be used to migrate child devices that the vchiq interfaces
creates/registers from the platform device/driver.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 drivers/staging/vc04_services/Makefile        |   1 +
 .../interface/vchiq_arm/vchiq_bus.c           | 100 ++++++++++++++++++
 .../interface/vchiq_arm/vchiq_bus.h           |  54 ++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
 create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h

diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile
index 44794bdf6173..e8b897a7b9a6 100644
--- a/drivers/staging/vc04_services/Makefile
+++ b/drivers/staging/vc04_services/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_BCM2835_VCHIQ)	+= vchiq.o
 vchiq-objs := \
    interface/vchiq_arm/vchiq_core.o  \
    interface/vchiq_arm/vchiq_arm.o \
+   interface/vchiq_arm/vchiq_bus.o \
    interface/vchiq_arm/vchiq_debugfs.o \
    interface/vchiq_arm/vchiq_connected.o \
 
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
new file mode 100644
index 000000000000..4ac3491efe45
--- /dev/null
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * vchiq_device.c - VCHIQ generic device and bus-type
+ *
+ * Copyright (c) 2023 Ideas On Board Oy
+ */
+
+#include <linux/device/bus.h>
+#include <linux/dma-mapping.h>
+#include <linux/of_device.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+
+#include "vchiq_bus.h"
+
+static int vchiq_bus_type_match(struct device *dev, struct device_driver *drv)
+{
+	if (dev->bus == &vchiq_bus_type &&
+	    strcmp(dev_name(dev), drv->name) == 0)
+		return true;
+
+	return false;
+}
+
+static int vchiq_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
+{
+	const struct vchiq_device *device = container_of_const(dev, struct vchiq_device, dev);
+
+	return add_uevent_var(env, "MODALIAS=%s", dev_name(&device->dev));
+}
+
+static int vchiq_bus_probe(struct device *dev)
+{
+	struct vchiq_device *device = to_vchiq_device(dev);
+	struct vchiq_driver *driver = to_vchiq_driver(dev->driver);
+
+	return driver->probe(device);
+}
+
+struct bus_type vchiq_bus_type = {
+	.name   = "vchiq-bus",
+	.match  = vchiq_bus_type_match,
+	.uevent = vchiq_bus_uevent,
+	.probe  = vchiq_bus_probe,
+};
+
+static void vchiq_device_release(struct device *dev)
+{
+	struct vchiq_device *device = to_vchiq_device(dev);
+
+	kfree(device);
+}
+
+struct vchiq_device *
+vchiq_device_register(struct device *parent, const char *name)
+{
+	struct vchiq_device *device;
+	int ret;
+
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
+	if (!device)
+		return NULL;
+
+	device->dev.init_name = name;
+	device->dev.parent = parent;
+	device->dev.bus = &vchiq_bus_type;
+	device->dev.dma_mask = &device->dev.coherent_dma_mask;
+	device->dev.release = vchiq_device_release;
+
+	of_dma_configure(&device->dev, parent->of_node, true);
+
+	ret = device_register(&device->dev);
+	if (ret) {
+		dev_err(parent, "Cannot register %s: %d\n", name, ret);
+		put_device(&device->dev);
+		kfree(device);
+		return NULL;
+	}
+
+	return device;
+}
+
+void vchiq_device_unregister(struct vchiq_device *vchiq_dev)
+{
+	device_unregister(&vchiq_dev->dev);
+}
+
+int vchiq_driver_register(struct vchiq_driver *vchiq_drv)
+{
+	vchiq_drv->driver.bus = &vchiq_bus_type;
+
+	return driver_register(&vchiq_drv->driver);
+}
+EXPORT_SYMBOL_GPL(vchiq_driver_register);
+
+void vchiq_driver_unregister(struct vchiq_driver *vchiq_drv)
+{
+	driver_unregister(&vchiq_drv->driver);
+}
+EXPORT_SYMBOL_GPL(vchiq_driver_unregister);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h
new file mode 100644
index 000000000000..7eaaf9a91cda
--- /dev/null
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2023 Ideas On Board Oy
+ */
+
+#ifndef _VCHIQ_DEVICE_H
+#define _VCHIQ_DEVICE_H
+
+#include <linux/device.h>
+
+struct vchiq_device {
+	struct device dev;
+};
+
+struct vchiq_driver {
+	int		(*probe)(struct vchiq_device *device);
+	void		(*remove)(struct vchiq_device *device);
+	int		(*resume)(struct vchiq_device *device);
+	int		(*suspend)(struct vchiq_device *device,
+				   pm_message_t state);
+	struct device_driver driver;
+};
+
+static inline struct vchiq_device *to_vchiq_device(struct device *d)
+{
+	return container_of(d, struct vchiq_device, dev);
+}
+
+static inline struct vchiq_driver *to_vchiq_driver(struct device_driver *d)
+{
+	return container_of(d, struct vchiq_driver, driver);
+}
+
+extern struct bus_type vchiq_bus_type;
+
+struct vchiq_device *
+vchiq_device_register(struct device *parent, const char *name);
+void vchiq_device_unregister(struct vchiq_device *dev);
+
+int vchiq_driver_register(struct vchiq_driver *vchiq_drv);
+void vchiq_driver_unregister(struct vchiq_driver *vchiq_drv);
+
+/**
+ * module_vchiq_driver() - Helper macro for registering a vchiq driver
+ * @__vchiq_driver: vchiq driver struct
+ *
+ * Helper macro for vchiq drivers which do not do anything special in
+ * module init/exit. This eliminates a lot of boilerplate. Each module may only
+ * use this macro once, and calling it replaces module_init() and module_exit()
+ */
+#define module_vchiq_driver(__vchiq_driver) \
+	module_driver(__vchiq_driver, vchiq_driver_register, vchiq_driver_unregister)
+
+#endif /* _VCHIQ_DEVICE_H */
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v12 4/6] staging: vc04_services: vchiq_arm: Register vchiq_bus_type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (2 preceding siblings ...)
  2023-09-23 14:31 ` [PATCH v12 3/6] staging: vc04_services: vchiq_arm: Add new bus type and device type Umang Jain
@ 2023-09-23 14:31 ` Umang Jain
  2023-09-23 14:31 ` [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Umang Jain
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:31 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

Register the vchiq_bus_type bus with the vchiq interface.
The bcm2835-camera and bcm2835_audio will be registered to this bus type
going ahead.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index aa2313f3bcab..9388859b9b56 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -12,6 +12,7 @@
 #include <linux/cdev.h>
 #include <linux/fs.h>
 #include <linux/device.h>
+#include <linux/device/bus.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
@@ -33,6 +34,7 @@
 #include "vchiq_core.h"
 #include "vchiq_ioctl.h"
 #include "vchiq_arm.h"
+#include "vchiq_bus.h"
 #include "vchiq_debugfs.h"
 #include "vchiq_connected.h"
 #include "vchiq_pagelist.h"
@@ -1870,9 +1872,17 @@ static int __init vchiq_driver_init(void)
 {
 	int ret;
 
+	ret = bus_register(&vchiq_bus_type);
+	if (ret) {
+		pr_err("Failed to register %s\n", vchiq_bus_type.name);
+		return ret;
+	}
+
 	ret = platform_driver_register(&vchiq_driver);
-	if (ret)
+	if (ret) {
 		pr_err("Failed to register vchiq driver\n");
+		bus_unregister(&vchiq_bus_type);
+	}
 
 	return ret;
 }
@@ -1880,6 +1890,7 @@ module_init(vchiq_driver_init);
 
 static void __exit vchiq_driver_exit(void)
 {
+	bus_unregister(&vchiq_bus_type);
 	platform_driver_unregister(&vchiq_driver);
 }
 module_exit(vchiq_driver_exit);
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (3 preceding siblings ...)
  2023-09-23 14:31 ` [PATCH v12 4/6] staging: vc04_services: vchiq_arm: Register vchiq_bus_type Umang Jain
@ 2023-09-23 14:31 ` Umang Jain
  2023-10-05  8:04   ` Greg Kroah-Hartman
  2023-09-23 14:32 ` [PATCH v12 6/6] staging: bcm2835-audio: Register bcm2835-audio " Umang Jain
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:31 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

Register the bcm2835-camera with the vchiq_bus_type instead of using
platform driver/device.

Since we moved away bcm2835-camera from platform driver/device,
we have to set the DMA mask explicitly. Set the DMA mask at probe
time.

Also the VCHIQ firmware doesn't support device enumeration, hence
one has to maintain a list of devices to be registered in the interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 .../bcm2835-camera/bcm2835-camera.c           | 21 ++++++++++---------
 .../interface/vchiq_arm/vchiq_arm.c           | 11 +++++++---
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index fcad5118f3e8..c873eace1437 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -11,6 +11,7 @@
  *          Luke Diamand @ Broadcom
  */
 
+#include <linux/dma-mapping.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -24,8 +25,8 @@
 #include <media/v4l2-event.h>
 #include <media/v4l2-common.h>
 #include <linux/delay.h>
-#include <linux/platform_device.h>
 
+#include "../interface/vchiq_arm/vchiq_bus.h"
 #include "../vchiq-mmal/mmal-common.h"
 #include "../vchiq-mmal/mmal-encodings.h"
 #include "../vchiq-mmal/mmal-vchiq.h"
@@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = {
 	.fmt.pix.sizeimage = 1024 * 768,
 };
 
-static int bcm2835_mmal_probe(struct platform_device *pdev)
+static int bcm2835_mmal_probe(struct vchiq_device *device)
 {
 	int ret;
 	struct bcm2835_mmal_dev *dev;
@@ -1852,9 +1853,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
 	unsigned int resolutions[MAX_BCM2835_CAMERAS][2];
 	int i;
 
-	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	ret = dma_set_mask_and_coherent(&device->dev, DMA_BIT_MASK(32));
 	if (ret) {
-		dev_err(&pdev->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
+		dev_err(&device->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
 		return ret;
 	}
 
@@ -1902,7 +1903,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
 						       &camera_instance);
 		ret = v4l2_device_register(NULL, &dev->v4l2_dev);
 		if (ret) {
-			dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n",
+			dev_err(&device->dev, "%s: could not register V4L2 device: %d\n",
 				__func__, ret);
 			goto free_dev;
 		}
@@ -1982,7 +1983,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static void bcm2835_mmal_remove(struct platform_device *pdev)
+static void bcm2835_mmal_remove(struct vchiq_device *device)
 {
 	int camera;
 	struct vchiq_mmal_instance *instance = gdev[0]->instance;
@@ -1994,17 +1995,17 @@ static void bcm2835_mmal_remove(struct platform_device *pdev)
 	vchiq_mmal_finalise(instance);
 }
 
-static struct platform_driver bcm2835_camera_driver = {
+static struct vchiq_driver bcm2835_camera_driver = {
 	.probe		= bcm2835_mmal_probe,
-	.remove_new	= bcm2835_mmal_remove,
+	.remove		= bcm2835_mmal_remove,
 	.driver		= {
 		.name	= "bcm2835-camera",
 	},
 };
 
-module_platform_driver(bcm2835_camera_driver)
+module_vchiq_driver(bcm2835_camera_driver)
 
 MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture");
 MODULE_AUTHOR("Vincent Sanders");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:bcm2835-camera");
+MODULE_ALIAS("bcm2835-camera");
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 9388859b9b56..886025f0a452 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -67,8 +67,13 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR;
 DEFINE_SPINLOCK(msg_queue_spinlock);
 struct vchiq_state g_state;
 
-static struct platform_device *bcm2835_camera;
 static struct platform_device *bcm2835_audio;
+/*
+ * The devices implemented in the VCHIQ firmware are not discoverable,
+ * so we need to maintain a list of them in order to register them with
+ * the interface.
+ */
+static struct vchiq_device *bcm2835_camera;
 
 struct vchiq_drvdata {
 	const unsigned int cache_line_size;
@@ -1840,8 +1845,8 @@ static int vchiq_probe(struct platform_device *pdev)
 		goto error_exit;
 	}
 
-	bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera");
 	bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio");
+	bcm2835_camera = vchiq_device_register(&pdev->dev, "bcm2835-camera");
 
 	return 0;
 
@@ -1854,7 +1859,7 @@ static int vchiq_probe(struct platform_device *pdev)
 static void vchiq_remove(struct platform_device *pdev)
 {
 	platform_device_unregister(bcm2835_audio);
-	platform_device_unregister(bcm2835_camera);
+	vchiq_device_unregister(bcm2835_camera);
 	vchiq_debugfs_deinit();
 	vchiq_deregister_chrdev();
 }
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v12 6/6] staging: bcm2835-audio: Register bcm2835-audio with vchiq_bus_type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (4 preceding siblings ...)
  2023-09-23 14:31 ` [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Umang Jain
@ 2023-09-23 14:32 ` Umang Jain
  2023-10-05  8:04   ` Greg Kroah-Hartman
  2023-09-23 14:33 ` [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:32 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart, Umang Jain

Similar to how bcm2385-camera device is registered, register the
bcm2835-audio with vchiq_bus_type as well.

Since we moved away bcm2835-audio from platform driver/device,
we have to set the DMA mask explicitly. Set the DMA mask at probe
time.

Meanwhile at it, change the name and module alias from "bcm2835_audio"
to "bcm2835-audio" to be consistent with bcm2835-camera device. This
does not brings any functional change as '-' and '_' are
interchangeable as per modprobe man pages.

Also, drop vchiq_register_child() helper which is no longer
needed after this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 .../vc04_services/bcm2835-audio/bcm2835.c     | 19 ++++++-------
 .../interface/vchiq_arm/vchiq_arm.c           | 28 ++-----------------
 2 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
index f3ad2543d1c0..06bdc7673d4b 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
@@ -1,13 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright 2011 Broadcom Corporation.  All rights reserved. */
 
-#include <linux/platform_device.h>
-
 #include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 
+#include "../interface/vchiq_arm/vchiq_bus.h"
 #include "bcm2835.h"
 
 static bool enable_hdmi;
@@ -269,9 +268,9 @@ static int snd_add_child_devices(struct device *device, u32 numchans)
 	return 0;
 }
 
-static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
+static int snd_bcm2835_alsa_probe(struct vchiq_device *device)
 {
-	struct device *dev = &pdev->dev;
+	struct device *dev = &device->dev;
 	int err;
 
 	err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
@@ -299,32 +298,32 @@ static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
 
 #ifdef CONFIG_PM
 
-static int snd_bcm2835_alsa_suspend(struct platform_device *pdev,
+static int snd_bcm2835_alsa_suspend(struct vchiq_device *device,
 				    pm_message_t state)
 {
 	return 0;
 }
 
-static int snd_bcm2835_alsa_resume(struct platform_device *pdev)
+static int snd_bcm2835_alsa_resume(struct vchiq_device *device)
 {
 	return 0;
 }
 
 #endif
 
-static struct platform_driver bcm2835_alsa_driver = {
+static struct vchiq_driver bcm2835_alsa_driver = {
 	.probe = snd_bcm2835_alsa_probe,
 #ifdef CONFIG_PM
 	.suspend = snd_bcm2835_alsa_suspend,
 	.resume = snd_bcm2835_alsa_resume,
 #endif
 	.driver = {
-		.name = "bcm2835_audio",
+		.name = "bcm2835-audio",
 	},
 };
-module_platform_driver(bcm2835_alsa_driver);
+module_vchiq_driver(bcm2835_alsa_driver);
 
 MODULE_AUTHOR("Dom Cobley");
 MODULE_DESCRIPTION("Alsa driver for BCM2835 chip");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:bcm2835_audio");
+MODULE_ALIAS("bcm2835-audio");
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 886025f0a452..eef9c8c06e66 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -67,12 +67,12 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR;
 DEFINE_SPINLOCK(msg_queue_spinlock);
 struct vchiq_state g_state;
 
-static struct platform_device *bcm2835_audio;
 /*
  * The devices implemented in the VCHIQ firmware are not discoverable,
  * so we need to maintain a list of them in order to register them with
  * the interface.
  */
+static struct vchiq_device *bcm2835_audio;
 static struct vchiq_device *bcm2835_camera;
 
 struct vchiq_drvdata {
@@ -1776,28 +1776,6 @@ static const struct of_device_id vchiq_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, vchiq_of_match);
 
-static struct platform_device *
-vchiq_register_child(struct platform_device *pdev, const char *name)
-{
-	struct platform_device_info pdevinfo;
-	struct platform_device *child;
-
-	memset(&pdevinfo, 0, sizeof(pdevinfo));
-
-	pdevinfo.parent = &pdev->dev;
-	pdevinfo.name = name;
-	pdevinfo.id = PLATFORM_DEVID_NONE;
-	pdevinfo.dma_mask = DMA_BIT_MASK(32);
-
-	child = platform_device_register_full(&pdevinfo);
-	if (IS_ERR(child)) {
-		dev_warn(&pdev->dev, "%s not registered\n", name);
-		child = NULL;
-	}
-
-	return child;
-}
-
 static int vchiq_probe(struct platform_device *pdev)
 {
 	struct device_node *fw_node;
@@ -1845,7 +1823,7 @@ static int vchiq_probe(struct platform_device *pdev)
 		goto error_exit;
 	}
 
-	bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio");
+	bcm2835_audio = vchiq_device_register(&pdev->dev, "bcm2835-audio");
 	bcm2835_camera = vchiq_device_register(&pdev->dev, "bcm2835-camera");
 
 	return 0;
@@ -1858,7 +1836,7 @@ static int vchiq_probe(struct platform_device *pdev)
 
 static void vchiq_remove(struct platform_device *pdev)
 {
-	platform_device_unregister(bcm2835_audio);
+	vchiq_device_unregister(bcm2835_audio);
 	vchiq_device_unregister(bcm2835_camera);
 	vchiq_debugfs_deinit();
 	vchiq_deregister_chrdev();
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (5 preceding siblings ...)
  2023-09-23 14:32 ` [PATCH v12 6/6] staging: bcm2835-audio: Register bcm2835-audio " Umang Jain
@ 2023-09-23 14:33 ` Umang Jain
  2023-09-30 10:10 ` Stefan Wahren
  2023-10-05  8:05 ` Greg Kroah-Hartman
  8 siblings, 0 replies; 15+ messages in thread
From: Umang Jain @ 2023-09-23 14:33 UTC (permalink / raw)
  To: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart

Hi all,

On 9/23/23 8:01 PM, Umang Jain wrote:
> The patch series added a new bus type vchiq_bus_type and registers
> child devices in order to move them away from using platform
> device/driver.
>
> Tested on RPi-3-b with media tree master branch.
>
> Patch 1/6 and 2/6 adds explicit DMA mask to bcm2835-camera
> and bcm2835-audio respectively to avoid regression when moving
> to away from platform device/driver model.
>
> Patch 3/6 and 4/6 adds a new bus_type and registers them to vchiq
> interface
>
> Patch 5/6 and 6/6 moves the bcm2835-camera and bcm2835-audio
> to the new bus respectively
>
> Patch 5/5 removes a platform registeration helper which is no
> longer required.

Please ignore the  just above line, forgot to delete while editing the 
cover letter.
>
> Changes in v12:
> - Add initial two patches to set DMA Mask explicitly to avoid regression
> - fixup vchiq_device.c bad squash in v11
> - Rename vchiq_device.[ch] to vchiq_bus.[ch]
> - Fix memory leak if device cannot be registered
> - Make vchiq_bus_type_match() use bool values
> - vchiq_register_child() helper removal folded in 6/6
>    instead of creating extra patch.
>
> Changes in v11:
> - Move setting of DMA mask in child devices (3/5 and 4/5)
> - Fixes "DMA mask not set issue" reported in v10.
>
> Changes in v10:
> - fix dma_attr WARN issue with bcm2835-audio module loading
> - Unregister bus on parent platform device fails to register
> - Reword commit to highlight bcm2835_audio to bcm2835-audio name change
>
> Changes in v9:
> - Fix module autoloading
> - Implement bus_type's probe() callback to load drivers
> - Implement bus_type's uevent() to make sure appropriate drivers are
>    loaded when device are registed from vchiq.
>
> Changes in v8:
> - Drop dual licensing. Instead use GPL-2.0 only for patch 1/5
>
> Changes in v7:
> (5 out of 6 patches from v6 merged)
> - Split the main patch (6/6) as requested.
> - Use struct vchiq_device * instead of struct device * in
>    all bus functions.
> - Drop additional name attribute displayed in sysfs (redundant info)
> - Document vchiq_interface doesn't enumerate device discovery
> - remove EXPORT_SYMBOL_GPL(vchiq_bus_type)
>
> Changes in v6:
> - Split struct device and struct driver wrappers in vchiq_device.[ch]
> - Move vchiq_bus_type definition to vchiq_device.[ch] as well
> - return error on bus_register() failure
> - drop dma_set_mask_and_coherent
> - trivial variable name change
>
> Changes in v5:
> - Fixup missing "staging: " in commits' subject line
> - No code changes from v4
>
> Changes in v4:
> - Introduce patches to drop include directives from Makefile
>
> Changes in v3:
> - Rework entirely to replace platform devices/driver model
>
> -v2:
> https://lore.kernel.org/all/20221222191500.515795-1-umang.jain@ideasonboard.com/
>
> -v1:
> https://lore.kernel.org/all/20221220084404.19280-1-umang.jain@ideasonboard.com/
>
> Umang Jain (6):
>    staging: vc04_services: bcm2835-camera: Explicitly set DMA mask
>    staging: vc04_services: bcm2835-audio: Explicitly set DMA mask
>    staging: vc04_services: vchiq_arm: Add new bus type and device type
>    staging: vc04_services: vchiq_arm: Register vchiq_bus_type
>    staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type
>    staging: bcm2835-audio: Register bcm2835-audio with vchiq_bus_type
>
>   drivers/staging/vc04_services/Makefile        |   1 +
>   .../vc04_services/bcm2835-audio/bcm2835.c     |  26 +++--
>   .../bcm2835-camera/bcm2835-camera.c           |  23 ++--
>   .../interface/vchiq_arm/vchiq_arm.c           |  52 ++++-----
>   .../interface/vchiq_arm/vchiq_bus.c           | 100 ++++++++++++++++++
>   .../interface/vchiq_arm/vchiq_bus.h           |  54 ++++++++++
>   6 files changed, 209 insertions(+), 47 deletions(-)
>   create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
>   create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h
>
>
> base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (6 preceding siblings ...)
  2023-09-23 14:33 ` [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
@ 2023-09-30 10:10 ` Stefan Wahren
  2023-10-05  8:05 ` Greg Kroah-Hartman
  8 siblings, 0 replies; 15+ messages in thread
From: Stefan Wahren @ 2023-09-30 10:10 UTC (permalink / raw)
  To: Umang Jain, linux-staging, linux-arm-kernel, linux-rpi-kernel,
	linux-media, linux-kernel
  Cc: Stefan Wahren, Greg Kroah-Hartman, Florian Fainelli,
	Adrien Thierry, Dan Carpenter, Dave Stevenson, Kieran Bingham,
	Laurent Pinchart


Am 23.09.23 um 16:31 schrieb Umang Jain:
> The patch series added a new bus type vchiq_bus_type and registers
> child devices in order to move them away from using platform
> device/driver.
>
> Tested on RPi-3-b with media tree master branch.
>
> Patch 1/6 and 2/6 adds explicit DMA mask to bcm2835-camera
> and bcm2835-audio respectively to avoid regression when moving
> to away from platform device/driver model.
>
> Patch 3/6 and 4/6 adds a new bus_type and registers them to vchiq
> interface
>
> Patch 5/6 and 6/6 moves the bcm2835-camera and bcm2835-audio
> to the new bus respectively
>
> Patch 5/5 removes a platform registeration helper which is no
> longer required.
>
> Changes in v12:
> - Add initial two patches to set DMA Mask explicitly to avoid regression
> - fixup vchiq_device.c bad squash in v11
> - Rename vchiq_device.[ch] to vchiq_bus.[ch]
> - Fix memory leak if device cannot be registered
> - Make vchiq_bus_type_match() use bool values
> - vchiq_register_child() helper removal folded in 6/6
>    instead of creating extra patch.

The whole series is

Reviewed-by: Stefan Wahren <wahrenst@gmx.net>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 3/6] staging: vc04_services: vchiq_arm: Add new bus type and device type
  2023-09-23 14:31 ` [PATCH v12 3/6] staging: vc04_services: vchiq_arm: Add new bus type and device type Umang Jain
@ 2023-10-05  8:03   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-05  8:03 UTC (permalink / raw)
  To: Umang Jain
  Cc: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel, Stefan Wahren, Florian Fainelli, Adrien Thierry,
	Dan Carpenter, Dave Stevenson, Kieran Bingham, Laurent Pinchart

On Sat, Sep 23, 2023 at 08:01:57PM +0530, Umang Jain wrote:
> The devices that the vchiq interface registers (bcm2835-audio,
> bcm2835-camera) are implemented and exposed by the VC04 firmware.
> The device tree describes the VC04 itself with the resources required
> to communicate with it through a mailbox interface. However, the
> vchiq interface registers these devices as platform devices. This
> also means the specific drivers for these devices are getting
> registered as platform drivers. This is not correct and a blatant
> abuse of platform device/driver.
> 
> Add a new bus type, vchiq_bus_type and device type (struct vchiq_device)
> which will be used to migrate child devices that the vchiq interfaces
> creates/registers from the platform device/driver.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  drivers/staging/vc04_services/Makefile        |   1 +
>  .../interface/vchiq_arm/vchiq_bus.c           | 100 ++++++++++++++++++
>  .../interface/vchiq_arm/vchiq_bus.h           |  54 ++++++++++
>  3 files changed, 155 insertions(+)
>  create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
>  create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h
> 
> diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile
> index 44794bdf6173..e8b897a7b9a6 100644
> --- a/drivers/staging/vc04_services/Makefile
> +++ b/drivers/staging/vc04_services/Makefile
> @@ -4,6 +4,7 @@ obj-$(CONFIG_BCM2835_VCHIQ)	+= vchiq.o
>  vchiq-objs := \
>     interface/vchiq_arm/vchiq_core.o  \
>     interface/vchiq_arm/vchiq_arm.o \
> +   interface/vchiq_arm/vchiq_bus.o \
>     interface/vchiq_arm/vchiq_debugfs.o \
>     interface/vchiq_arm/vchiq_connected.o \
>  
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
> new file mode 100644
> index 000000000000..4ac3491efe45
> --- /dev/null
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
> @@ -0,0 +1,100 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * vchiq_device.c - VCHIQ generic device and bus-type
> + *
> + * Copyright (c) 2023 Ideas On Board Oy
> + */
> +
> +#include <linux/device/bus.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/of_device.h>
> +#include <linux/slab.h>
> +#include <linux/string.h>
> +
> +#include "vchiq_bus.h"
> +
> +static int vchiq_bus_type_match(struct device *dev, struct device_driver *drv)
> +{
> +	if (dev->bus == &vchiq_bus_type &&
> +	    strcmp(dev_name(dev), drv->name) == 0)
> +		return true;
> +
> +	return false;
> +}
> +
> +static int vchiq_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
> +{
> +	const struct vchiq_device *device = container_of_const(dev, struct vchiq_device, dev);
> +
> +	return add_uevent_var(env, "MODALIAS=%s", dev_name(&device->dev));
> +}
> +
> +static int vchiq_bus_probe(struct device *dev)
> +{
> +	struct vchiq_device *device = to_vchiq_device(dev);
> +	struct vchiq_driver *driver = to_vchiq_driver(dev->driver);
> +
> +	return driver->probe(device);
> +}
> +
> +struct bus_type vchiq_bus_type = {
> +	.name   = "vchiq-bus",
> +	.match  = vchiq_bus_type_match,
> +	.uevent = vchiq_bus_uevent,
> +	.probe  = vchiq_bus_probe,
> +};
> +
> +static void vchiq_device_release(struct device *dev)
> +{
> +	struct vchiq_device *device = to_vchiq_device(dev);
> +
> +	kfree(device);
> +}
> +
> +struct vchiq_device *
> +vchiq_device_register(struct device *parent, const char *name)
> +{
> +	struct vchiq_device *device;
> +	int ret;
> +
> +	device = kzalloc(sizeof(*device), GFP_KERNEL);
> +	if (!device)
> +		return NULL;
> +
> +	device->dev.init_name = name;
> +	device->dev.parent = parent;
> +	device->dev.bus = &vchiq_bus_type;
> +	device->dev.dma_mask = &device->dev.coherent_dma_mask;
> +	device->dev.release = vchiq_device_release;
> +
> +	of_dma_configure(&device->dev, parent->of_node, true);
> +
> +	ret = device_register(&device->dev);
> +	if (ret) {
> +		dev_err(parent, "Cannot register %s: %d\n", name, ret);
> +		put_device(&device->dev);
> +		kfree(device);

As per the documentation for the device_register() call, this kfree()
will crash.  The call to put_device() is all you need here to free the
memory.

I'll take this series as it's been reviewed and tested, but can you send
a follow-on patch for this?

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type
  2023-09-23 14:31 ` [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Umang Jain
@ 2023-10-05  8:04   ` Greg Kroah-Hartman
  2023-10-09  4:20     ` Umang Jain
  0 siblings, 1 reply; 15+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-05  8:04 UTC (permalink / raw)
  To: Umang Jain
  Cc: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel, Stefan Wahren, Florian Fainelli, Adrien Thierry,
	Dan Carpenter, Dave Stevenson, Kieran Bingham, Laurent Pinchart

On Sat, Sep 23, 2023 at 08:01:59PM +0530, Umang Jain wrote:
> Register the bcm2835-camera with the vchiq_bus_type instead of using
> platform driver/device.
> 
> Since we moved away bcm2835-camera from platform driver/device,
> we have to set the DMA mask explicitly. Set the DMA mask at probe
> time.
> 
> Also the VCHIQ firmware doesn't support device enumeration, hence
> one has to maintain a list of devices to be registered in the interface.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  .../bcm2835-camera/bcm2835-camera.c           | 21 ++++++++++---------
>  .../interface/vchiq_arm/vchiq_arm.c           | 11 +++++++---
>  2 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> index fcad5118f3e8..c873eace1437 100644
> --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> @@ -11,6 +11,7 @@
>   *          Luke Diamand @ Broadcom
>   */
>  
> +#include <linux/dma-mapping.h>
>  #include <linux/errno.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> @@ -24,8 +25,8 @@
>  #include <media/v4l2-event.h>
>  #include <media/v4l2-common.h>
>  #include <linux/delay.h>
> -#include <linux/platform_device.h>
>  
> +#include "../interface/vchiq_arm/vchiq_bus.h"
>  #include "../vchiq-mmal/mmal-common.h"
>  #include "../vchiq-mmal/mmal-encodings.h"
>  #include "../vchiq-mmal/mmal-vchiq.h"
> @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = {
>  	.fmt.pix.sizeimage = 1024 * 768,
>  };
>  
> -static int bcm2835_mmal_probe(struct platform_device *pdev)
> +static int bcm2835_mmal_probe(struct vchiq_device *device)
>  {
>  	int ret;
>  	struct bcm2835_mmal_dev *dev;
> @@ -1852,9 +1853,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
>  	unsigned int resolutions[MAX_BCM2835_CAMERAS][2];
>  	int i;
>  
> -	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +	ret = dma_set_mask_and_coherent(&device->dev, DMA_BIT_MASK(32));
>  	if (ret) {
> -		dev_err(&pdev->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
> +		dev_err(&device->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
>  		return ret;
>  	}
>  
> @@ -1902,7 +1903,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
>  						       &camera_instance);
>  		ret = v4l2_device_register(NULL, &dev->v4l2_dev);
>  		if (ret) {
> -			dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n",
> +			dev_err(&device->dev, "%s: could not register V4L2 device: %d\n",
>  				__func__, ret);
>  			goto free_dev;
>  		}
> @@ -1982,7 +1983,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static void bcm2835_mmal_remove(struct platform_device *pdev)
> +static void bcm2835_mmal_remove(struct vchiq_device *device)
>  {
>  	int camera;
>  	struct vchiq_mmal_instance *instance = gdev[0]->instance;
> @@ -1994,17 +1995,17 @@ static void bcm2835_mmal_remove(struct platform_device *pdev)
>  	vchiq_mmal_finalise(instance);
>  }
>  
> -static struct platform_driver bcm2835_camera_driver = {
> +static struct vchiq_driver bcm2835_camera_driver = {
>  	.probe		= bcm2835_mmal_probe,
> -	.remove_new	= bcm2835_mmal_remove,
> +	.remove		= bcm2835_mmal_remove,
>  	.driver		= {
>  		.name	= "bcm2835-camera",
>  	},
>  };
>  
> -module_platform_driver(bcm2835_camera_driver)
> +module_vchiq_driver(bcm2835_camera_driver)
>  
>  MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture");
>  MODULE_AUTHOR("Vincent Sanders");
>  MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:bcm2835-camera");
> +MODULE_ALIAS("bcm2835-camera");

Now that you are on your own bus, why do you need the MODULE_ALIAS()
line at all?

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 6/6] staging: bcm2835-audio: Register bcm2835-audio with vchiq_bus_type
  2023-09-23 14:32 ` [PATCH v12 6/6] staging: bcm2835-audio: Register bcm2835-audio " Umang Jain
@ 2023-10-05  8:04   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-05  8:04 UTC (permalink / raw)
  To: Umang Jain
  Cc: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel, Stefan Wahren, Florian Fainelli, Adrien Thierry,
	Dan Carpenter, Dave Stevenson, Kieran Bingham, Laurent Pinchart

On Sat, Sep 23, 2023 at 08:02:00PM +0530, Umang Jain wrote:
> Similar to how bcm2385-camera device is registered, register the
> bcm2835-audio with vchiq_bus_type as well.
> 
> Since we moved away bcm2835-audio from platform driver/device,
> we have to set the DMA mask explicitly. Set the DMA mask at probe
> time.
> 
> Meanwhile at it, change the name and module alias from "bcm2835_audio"
> to "bcm2835-audio" to be consistent with bcm2835-camera device. This
> does not brings any functional change as '-' and '_' are
> interchangeable as per modprobe man pages.

Again, why is the module alias still needed?

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type
  2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
                   ` (7 preceding siblings ...)
  2023-09-30 10:10 ` Stefan Wahren
@ 2023-10-05  8:05 ` Greg Kroah-Hartman
  8 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-05  8:05 UTC (permalink / raw)
  To: Umang Jain
  Cc: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel, Stefan Wahren, Florian Fainelli, Adrien Thierry,
	Dan Carpenter, Dave Stevenson, Kieran Bingham, Laurent Pinchart

On Sat, Sep 23, 2023 at 08:01:54PM +0530, Umang Jain wrote:
> The patch series added a new bus type vchiq_bus_type and registers
> child devices in order to move them away from using platform
> device/driver.
> 
> Tested on RPi-3-b with media tree master branch.

Thanks for sticking with this through so many different revisions. I
only had minor comments on the series, you can address them in follow-on
patches if needed (one at the least is needed.)  All are now queued up
in my tree.

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type
  2023-10-05  8:04   ` Greg Kroah-Hartman
@ 2023-10-09  4:20     ` Umang Jain
  2023-10-09 10:12       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 15+ messages in thread
From: Umang Jain @ 2023-10-09  4:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel, Stefan Wahren, Florian Fainelli, Adrien Thierry,
	Dan Carpenter, Dave Stevenson, Kieran Bingham, Laurent Pinchart

Hi Greg,

Sorry for late reply, as I was traveling and then was on vacation for 
rest of the week.

On 10/5/23 1:34 PM, Greg Kroah-Hartman wrote:
> On Sat, Sep 23, 2023 at 08:01:59PM +0530, Umang Jain wrote:
>> Register the bcm2835-camera with the vchiq_bus_type instead of using
>> platform driver/device.
>>
>> Since we moved away bcm2835-camera from platform driver/device,
>> we have to set the DMA mask explicitly. Set the DMA mask at probe
>> time.
>>
>> Also the VCHIQ firmware doesn't support device enumeration, hence
>> one has to maintain a list of devices to be registered in the interface.
>>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>> ---
>>   .../bcm2835-camera/bcm2835-camera.c           | 21 ++++++++++---------
>>   .../interface/vchiq_arm/vchiq_arm.c           | 11 +++++++---
>>   2 files changed, 19 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
>> index fcad5118f3e8..c873eace1437 100644
>> --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
>> +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
>> @@ -11,6 +11,7 @@
>>    *          Luke Diamand @ Broadcom
>>    */
>>   
>> +#include <linux/dma-mapping.h>
>>   #include <linux/errno.h>
>>   #include <linux/kernel.h>
>>   #include <linux/module.h>
>> @@ -24,8 +25,8 @@
>>   #include <media/v4l2-event.h>
>>   #include <media/v4l2-common.h>
>>   #include <linux/delay.h>
>> -#include <linux/platform_device.h>
>>   
>> +#include "../interface/vchiq_arm/vchiq_bus.h"
>>   #include "../vchiq-mmal/mmal-common.h"
>>   #include "../vchiq-mmal/mmal-encodings.h"
>>   #include "../vchiq-mmal/mmal-vchiq.h"
>> @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = {
>>   	.fmt.pix.sizeimage = 1024 * 768,
>>   };
>>   
>> -static int bcm2835_mmal_probe(struct platform_device *pdev)
>> +static int bcm2835_mmal_probe(struct vchiq_device *device)
>>   {
>>   	int ret;
>>   	struct bcm2835_mmal_dev *dev;
>> @@ -1852,9 +1853,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
>>   	unsigned int resolutions[MAX_BCM2835_CAMERAS][2];
>>   	int i;
>>   
>> -	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>> +	ret = dma_set_mask_and_coherent(&device->dev, DMA_BIT_MASK(32));
>>   	if (ret) {
>> -		dev_err(&pdev->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
>> +		dev_err(&device->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> @@ -1902,7 +1903,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
>>   						       &camera_instance);
>>   		ret = v4l2_device_register(NULL, &dev->v4l2_dev);
>>   		if (ret) {
>> -			dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n",
>> +			dev_err(&device->dev, "%s: could not register V4L2 device: %d\n",
>>   				__func__, ret);
>>   			goto free_dev;
>>   		}
>> @@ -1982,7 +1983,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
>>   	return ret;
>>   }
>>   
>> -static void bcm2835_mmal_remove(struct platform_device *pdev)
>> +static void bcm2835_mmal_remove(struct vchiq_device *device)
>>   {
>>   	int camera;
>>   	struct vchiq_mmal_instance *instance = gdev[0]->instance;
>> @@ -1994,17 +1995,17 @@ static void bcm2835_mmal_remove(struct platform_device *pdev)
>>   	vchiq_mmal_finalise(instance);
>>   }
>>   
>> -static struct platform_driver bcm2835_camera_driver = {
>> +static struct vchiq_driver bcm2835_camera_driver = {
>>   	.probe		= bcm2835_mmal_probe,
>> -	.remove_new	= bcm2835_mmal_remove,
>> +	.remove		= bcm2835_mmal_remove,
>>   	.driver		= {
>>   		.name	= "bcm2835-camera",
>>   	},
>>   };
>>   
>> -module_platform_driver(bcm2835_camera_driver)
>> +module_vchiq_driver(bcm2835_camera_driver)
>>   
>>   MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture");
>>   MODULE_AUTHOR("Vincent Sanders");
>>   MODULE_LICENSE("GPL");
>> -MODULE_ALIAS("platform:bcm2835-camera");
>> +MODULE_ALIAS("bcm2835-camera");
> Now that you are on your own bus, why do you need the MODULE_ALIAS()
> line at all?

Because it breaks the module auto-loading support...

If you look at the vchiq_bus patch (3/6) in this series, there is 
vchiq_bus_uevent() which sends a event that includes the MODALIAS.
>
> thanks,
>
> greg k-h


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type
  2023-10-09  4:20     ` Umang Jain
@ 2023-10-09 10:12       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-09 10:12 UTC (permalink / raw)
  To: Umang Jain
  Cc: linux-staging, linux-arm-kernel, linux-rpi-kernel, linux-media,
	linux-kernel, Stefan Wahren, Florian Fainelli, Adrien Thierry,
	Dan Carpenter, Dave Stevenson, Kieran Bingham, Laurent Pinchart

On Mon, Oct 09, 2023 at 09:50:29AM +0530, Umang Jain wrote:
> Hi Greg,
> 
> Sorry for late reply, as I was traveling and then was on vacation for rest
> of the week.
> 
> On 10/5/23 1:34 PM, Greg Kroah-Hartman wrote:
> > On Sat, Sep 23, 2023 at 08:01:59PM +0530, Umang Jain wrote:
> > > Register the bcm2835-camera with the vchiq_bus_type instead of using
> > > platform driver/device.
> > > 
> > > Since we moved away bcm2835-camera from platform driver/device,
> > > we have to set the DMA mask explicitly. Set the DMA mask at probe
> > > time.
> > > 
> > > Also the VCHIQ firmware doesn't support device enumeration, hence
> > > one has to maintain a list of devices to be registered in the interface.
> > > 
> > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> > > ---
> > >   .../bcm2835-camera/bcm2835-camera.c           | 21 ++++++++++---------
> > >   .../interface/vchiq_arm/vchiq_arm.c           | 11 +++++++---
> > >   2 files changed, 19 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> > > index fcad5118f3e8..c873eace1437 100644
> > > --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> > > +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> > > @@ -11,6 +11,7 @@
> > >    *          Luke Diamand @ Broadcom
> > >    */
> > > +#include <linux/dma-mapping.h>
> > >   #include <linux/errno.h>
> > >   #include <linux/kernel.h>
> > >   #include <linux/module.h>
> > > @@ -24,8 +25,8 @@
> > >   #include <media/v4l2-event.h>
> > >   #include <media/v4l2-common.h>
> > >   #include <linux/delay.h>
> > > -#include <linux/platform_device.h>
> > > +#include "../interface/vchiq_arm/vchiq_bus.h"
> > >   #include "../vchiq-mmal/mmal-common.h"
> > >   #include "../vchiq-mmal/mmal-encodings.h"
> > >   #include "../vchiq-mmal/mmal-vchiq.h"
> > > @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = {
> > >   	.fmt.pix.sizeimage = 1024 * 768,
> > >   };
> > > -static int bcm2835_mmal_probe(struct platform_device *pdev)
> > > +static int bcm2835_mmal_probe(struct vchiq_device *device)
> > >   {
> > >   	int ret;
> > >   	struct bcm2835_mmal_dev *dev;
> > > @@ -1852,9 +1853,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
> > >   	unsigned int resolutions[MAX_BCM2835_CAMERAS][2];
> > >   	int i;
> > > -	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> > > +	ret = dma_set_mask_and_coherent(&device->dev, DMA_BIT_MASK(32));
> > >   	if (ret) {
> > > -		dev_err(&pdev->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
> > > +		dev_err(&device->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
> > >   		return ret;
> > >   	}
> > > @@ -1902,7 +1903,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
> > >   						       &camera_instance);
> > >   		ret = v4l2_device_register(NULL, &dev->v4l2_dev);
> > >   		if (ret) {
> > > -			dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n",
> > > +			dev_err(&device->dev, "%s: could not register V4L2 device: %d\n",
> > >   				__func__, ret);
> > >   			goto free_dev;
> > >   		}
> > > @@ -1982,7 +1983,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev)
> > >   	return ret;
> > >   }
> > > -static void bcm2835_mmal_remove(struct platform_device *pdev)
> > > +static void bcm2835_mmal_remove(struct vchiq_device *device)
> > >   {
> > >   	int camera;
> > >   	struct vchiq_mmal_instance *instance = gdev[0]->instance;
> > > @@ -1994,17 +1995,17 @@ static void bcm2835_mmal_remove(struct platform_device *pdev)
> > >   	vchiq_mmal_finalise(instance);
> > >   }
> > > -static struct platform_driver bcm2835_camera_driver = {
> > > +static struct vchiq_driver bcm2835_camera_driver = {
> > >   	.probe		= bcm2835_mmal_probe,
> > > -	.remove_new	= bcm2835_mmal_remove,
> > > +	.remove		= bcm2835_mmal_remove,
> > >   	.driver		= {
> > >   		.name	= "bcm2835-camera",
> > >   	},
> > >   };
> > > -module_platform_driver(bcm2835_camera_driver)
> > > +module_vchiq_driver(bcm2835_camera_driver)
> > >   MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture");
> > >   MODULE_AUTHOR("Vincent Sanders");
> > >   MODULE_LICENSE("GPL");
> > > -MODULE_ALIAS("platform:bcm2835-camera");
> > > +MODULE_ALIAS("bcm2835-camera");
> > Now that you are on your own bus, why do you need the MODULE_ALIAS()
> > line at all?
> 
> Because it breaks the module auto-loading support...

But that's not how auto-loading should work once you have a real bus.

> If you look at the vchiq_bus patch (3/6) in this series, there is
> vchiq_bus_uevent() which sends a event that includes the MODALIAS.

The module alias should be automatically picked out of the
MODULE_DEVICE_TABLE() macro that you should be using for this driver,
you should never have to manually create MODULE_ALIAS() lines.

That's a bad hold-over because the platform driver subsystem can not
handle module aliases on it's own, let's not copy that bad pattern here
as well please.

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-10-09 10:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-23 14:31 [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
2023-09-23 14:31 ` [PATCH v12 1/6] staging: vc04_services: bcm2835-camera: Explicitly set DMA mask Umang Jain
2023-09-23 14:31 ` [PATCH v12 2/6] staging: vc04_services: bcm2835-audio: " Umang Jain
2023-09-23 14:31 ` [PATCH v12 3/6] staging: vc04_services: vchiq_arm: Add new bus type and device type Umang Jain
2023-10-05  8:03   ` Greg Kroah-Hartman
2023-09-23 14:31 ` [PATCH v12 4/6] staging: vc04_services: vchiq_arm: Register vchiq_bus_type Umang Jain
2023-09-23 14:31 ` [PATCH v12 5/6] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Umang Jain
2023-10-05  8:04   ` Greg Kroah-Hartman
2023-10-09  4:20     ` Umang Jain
2023-10-09 10:12       ` Greg Kroah-Hartman
2023-09-23 14:32 ` [PATCH v12 6/6] staging: bcm2835-audio: Register bcm2835-audio " Umang Jain
2023-10-05  8:04   ` Greg Kroah-Hartman
2023-09-23 14:33 ` [PATCH v12 0/6] staging: vc04_services: vchiq: Register devices with a custom bus_type Umang Jain
2023-09-30 10:10 ` Stefan Wahren
2023-10-05  8:05 ` Greg Kroah-Hartman

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