Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: vc04_services: Drop vchiq_connected.[ch] files

The vchiq_connected.[ch] just implements two function:

- vchiq_add_connected_callback()
- vchiq_call_connected_callbacks()

for the deferred vchiq callbacks. Those can easily live in
vchiq_arm.[ch], hence move them. This allows making the
vchiq_call_connected_callbacks() function static.

The move doesn't copy over MAX_CALLBACKS because it is the same as
VCHIQ_DRV_MAX_CALLBACKS. Hence, it now being used in
vchiq_add_connected_callback().

No functional changes intended in this patch.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20240412075743.60712-6-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Umang Jain and committed by
Greg Kroah-Hartman
f875976e e1c0af4f

+55 -76
-1
drivers/staging/vc04_services/Makefile
··· 6 6 interface/vchiq_arm/vchiq_arm.o \ 7 7 interface/vchiq_arm/vchiq_bus.o \ 8 8 interface/vchiq_arm/vchiq_debugfs.o \ 9 - interface/vchiq_arm/vchiq_connected.o \ 10 9 11 10 ifdef CONFIG_VCHIQ_CDEV 12 11 vchiq-objs += interface/vchiq_arm/vchiq_dev.o
+50 -1
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
··· 36 36 #include "vchiq_arm.h" 37 37 #include "vchiq_bus.h" 38 38 #include "vchiq_debugfs.h" 39 - #include "vchiq_connected.h" 40 39 #include "vchiq_pagelist.h" 41 40 42 41 #define DEVICE_NAME "vchiq" ··· 187 188 188 189 return tmp == (addr & PAGE_MASK); 189 190 } 191 + 192 + /* 193 + * This function is called by the vchiq stack once it has been connected to 194 + * the videocore and clients can start to use the stack. 195 + */ 196 + static void vchiq_call_connected_callbacks(struct vchiq_drv_mgmt *drv_mgmt) 197 + { 198 + int i; 199 + 200 + if (mutex_lock_killable(&drv_mgmt->connected_mutex)) 201 + return; 202 + 203 + for (i = 0; i < drv_mgmt->num_deferred_callbacks; i++) 204 + drv_mgmt->deferred_callback[i](); 205 + 206 + drv_mgmt->num_deferred_callbacks = 0; 207 + drv_mgmt->connected = true; 208 + mutex_unlock(&drv_mgmt->connected_mutex); 209 + } 210 + 211 + /* 212 + * This function is used to defer initialization until the vchiq stack is 213 + * initialized. If the stack is already initialized, then the callback will 214 + * be made immediately, otherwise it will be deferred until 215 + * vchiq_call_connected_callbacks is called. 216 + */ 217 + void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)(void)) 218 + { 219 + struct vchiq_drv_mgmt *drv_mgmt = device->drv_mgmt; 220 + 221 + if (mutex_lock_killable(&drv_mgmt->connected_mutex)) 222 + return; 223 + 224 + if (drv_mgmt->connected) { 225 + /* We're already connected. Call the callback immediately. */ 226 + callback(); 227 + } else { 228 + if (drv_mgmt->num_deferred_callbacks >= VCHIQ_DRV_MAX_CALLBACKS) { 229 + dev_err(&device->dev, 230 + "core: deferred callbacks(%d) exceeded the maximum limit(%d)\n", 231 + drv_mgmt->num_deferred_callbacks, VCHIQ_DRV_MAX_CALLBACKS); 232 + } else { 233 + drv_mgmt->deferred_callback[drv_mgmt->num_deferred_callbacks] = 234 + callback; 235 + drv_mgmt->num_deferred_callbacks++; 236 + } 237 + } 238 + mutex_unlock(&drv_mgmt->connected_mutex); 239 + } 240 + EXPORT_SYMBOL(vchiq_add_connected_callback); 190 241 191 242 /* There is a potential problem with partial cache lines (pages?) 192 243 * at the ends of the block when reading. If the CPU accessed anything in
+5
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
··· 23 23 #define VCHIQ_DRV_MAX_CALLBACKS 10 24 24 25 25 struct rpi_firmware; 26 + struct vchiq_device; 26 27 27 28 enum USE_TYPE_E { 28 29 USE_TYPE_SERVICE, ··· 132 131 133 132 extern void 134 133 vchiq_instance_set_trace(struct vchiq_instance *instance, int trace); 134 + 135 + extern void 136 + vchiq_add_connected_callback(struct vchiq_device *device, 137 + void (*callback)(void)); 135 138 136 139 #if IS_ENABLED(CONFIG_VCHIQ_CDEV) 137 140
-60
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 - /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ 3 - 4 - #include "vchiq_arm.h" 5 - #include "vchiq_connected.h" 6 - #include "vchiq_core.h" 7 - #include <linux/module.h> 8 - #include <linux/mutex.h> 9 - 10 - #define MAX_CALLBACKS 10 11 - 12 - /* 13 - * This function is used to defer initialization until the vchiq stack is 14 - * initialized. If the stack is already initialized, then the callback will 15 - * be made immediately, otherwise it will be deferred until 16 - * vchiq_call_connected_callbacks is called. 17 - */ 18 - void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)(void)) 19 - { 20 - struct vchiq_drv_mgmt *drv_mgmt = device->drv_mgmt; 21 - 22 - if (mutex_lock_killable(&drv_mgmt->connected_mutex)) 23 - return; 24 - 25 - if (drv_mgmt->connected) { 26 - /* We're already connected. Call the callback immediately. */ 27 - callback(); 28 - } else { 29 - if (drv_mgmt->num_deferred_callbacks >= MAX_CALLBACKS) { 30 - dev_err(&device->dev, 31 - "core: There already %d callback registered - please increase MAX_CALLBACKS\n", 32 - drv_mgmt->num_deferred_callbacks); 33 - } else { 34 - drv_mgmt->deferred_callback[drv_mgmt->num_deferred_callbacks] = 35 - callback; 36 - drv_mgmt->num_deferred_callbacks++; 37 - } 38 - } 39 - mutex_unlock(&drv_mgmt->connected_mutex); 40 - } 41 - EXPORT_SYMBOL(vchiq_add_connected_callback); 42 - 43 - /* 44 - * This function is called by the vchiq stack once it has been connected to 45 - * the videocore and clients can start to use the stack. 46 - */ 47 - void vchiq_call_connected_callbacks(struct vchiq_drv_mgmt *drv_mgmt) 48 - { 49 - int i; 50 - 51 - if (mutex_lock_killable(&drv_mgmt->connected_mutex)) 52 - return; 53 - 54 - for (i = 0; i < drv_mgmt->num_deferred_callbacks; i++) 55 - drv_mgmt->deferred_callback[i](); 56 - 57 - drv_mgmt->num_deferred_callbacks = 0; 58 - drv_mgmt->connected = true; 59 - mutex_unlock(&drv_mgmt->connected_mutex); 60 - }
-14
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 - /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ 3 - 4 - #include "vchiq_bus.h" 5 - 6 - #ifndef VCHIQ_CONNECTED_H 7 - #define VCHIQ_CONNECTED_H 8 - 9 - struct vchiq_drv_mgmt; 10 - 11 - void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)(void)); 12 - void vchiq_call_connected_callbacks(struct vchiq_drv_mgmt *mgmt); 13 - 14 - #endif /* VCHIQ_CONNECTED_H */