mbox series

[v8,0/5] staging: vc04_services: vchiq: Register devices with a custom bus_type

Message ID 20230627201628.207483-1-umang.jain@ideasonboard.com
Headers show
Series staging: vc04_services: vchiq: Register devices with a custom bus_type | expand

Message

Umang Jain June 27, 2023, 8:16 p.m. UTC
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.

Patch 1/5 and 2/5 adds a new bus_type and registers them to vchiq
interface

Patch 3/5 and 4/5 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 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 (5):
  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
  staging: vc04_services: vchiq_arm: Remove vchiq_register_child()

 drivers/staging/vc04_services/Makefile        |  1 +
 .../vc04_services/bcm2835-audio/bcm2835.c     | 17 ++--
 .../bcm2835-camera/bcm2835-camera.c           | 16 ++--
 .../interface/vchiq_arm/vchiq_arm.c           | 56 +++++++------
 .../interface/vchiq_arm/vchiq_device.c        | 78 +++++++++++++++++++
 .../interface/vchiq_arm/vchiq_device.h        | 43 ++++++++++
 6 files changed, 165 insertions(+), 46 deletions(-)
 create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_device.c
 create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_device.h

Comments

Kieran Bingham June 28, 2023, 11:21 a.m. UTC | #1
Quoting Umang Jain (2023-06-27 21:16:25)
> Register the vchiq_bus_type bus with the vchiq interface.
> The bcm2835-camera nad bcm2835_audio will be registered to this bus type

s/nad/and/

Is it possible to rename bcm2835_audio to bcm2835-audio for consistency?
Or is that baked into existing usage/abi already?

If it can be changed, I think it's probably something to do in an
independent patch at the end of the series anyway.

I suspect this patch could be merged with 1/5 but I think it's ok
separate too.


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> going ahead.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  .../vc04_services/interface/vchiq_arm/vchiq_arm.c        | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> 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..e8d40f891449 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>
> @@ -34,6 +35,7 @@
>  #include "vchiq_ioctl.h"
>  #include "vchiq_arm.h"
>  #include "vchiq_debugfs.h"
> +#include "vchiq_device.h"
>  #include "vchiq_connected.h"
>  #include "vchiq_pagelist.h"
>  
> @@ -1870,6 +1872,12 @@ 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)
>                 pr_err("Failed to register vchiq driver\n");
> @@ -1880,6 +1888,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.39.1
>
Umang Jain June 28, 2023, 9:08 p.m. UTC | #2
Hi Kieran,

On 6/28/23 1:21 PM, Kieran Bingham wrote:
> Quoting Umang Jain (2023-06-27 21:16:25)
>> Register the vchiq_bus_type bus with the vchiq interface.
>> The bcm2835-camera nad bcm2835_audio will be registered to this bus type
> s/nad/and/

Oops,  v9 probably?
>
> Is it possible to rename bcm2835_audio to bcm2835-audio for consistency?
> Or is that baked into existing usage/abi already?

well, there are more (bcm2835_hdmi, bcm2835_headphones) so, I don't 
think I will address in this series.
>
> If it can be changed, I think it's probably something to do in an
> independent patch at the end of the series anyway.
>
> I suspect this patch could be merged with 1/5 but I think it's ok
> separate too.
>
>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
>> going ahead.
>>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>> ---
>>   .../vc04_services/interface/vchiq_arm/vchiq_arm.c        | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> 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..e8d40f891449 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>
>> @@ -34,6 +35,7 @@
>>   #include "vchiq_ioctl.h"
>>   #include "vchiq_arm.h"
>>   #include "vchiq_debugfs.h"
>> +#include "vchiq_device.h"
>>   #include "vchiq_connected.h"
>>   #include "vchiq_pagelist.h"
>>   
>> @@ -1870,6 +1872,12 @@ 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)
>>                  pr_err("Failed to register vchiq driver\n");
>> @@ -1880,6 +1888,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.39.1
>>
Kieran Bingham June 28, 2023, 10:46 p.m. UTC | #3
Quoting Umang Jain (2023-06-27 21:16:28)
> vchiq_register_child() is used to registered child devices as platform

s/registered/register/

> devices. Now that the child devices are migrated to use the
> vchiq_bus_type instead, they will be registered to that. Hence, drop
> vchiq_register_child() as it is no more required.
> 

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  .../interface/vchiq_arm/vchiq_arm.c           | 22 -------------------
>  1 file changed, 22 deletions(-)
> 
> 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 75da37fa6372..3c52b09c49ea 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -1778,28 +1778,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;
> -- 
> 2.39.1
>