Skip to contentSkip to conversation

staging: vc04_services: avoid the use of typedef for function pointers

PATCH In review Gaston Gonzalez 3 participants 6 messages Dec 30, 2021 – Jan 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover staging: vc04_services: avoid the use of typedef for function pointers

This patch set removes some typedefs for function pointers in vc04_services.

v1 -> v2:

- Following Greg suggestion, functions pointers were not renamed making patches 1 and 2 much smaller.
- Function pointers in vchiq-mmal were not touched as the result is less readable than the original.
- In the description of changes in the TODO file, it was specified that there are no current 'struct typedefs' left inside vc04_servivces.
- The name of the particular subsystem of vc04_services was included in the title of each commit.

Gaston Gonzalez (3):
staging: vc04_services: bcm2835-audio: avoid the use of typedef for
function pointers
staging: vc04_services: bcm2835-camera: avoid the use of typedef for
function pointers
staging: vc04_services: update TODO file

 .../staging/vc04_services/bcm2835-audio/bcm2835.c    | 12 +++---------
 .../staging/vc04_services/bcm2835-camera/controls.c  | 10 ++--------
 drivers/staging/vc04_services/interface/TODO         |  8 ++------
 3 files changed, 7 insertions(+), 23 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 staging: vc04_services: bcm2835-audio: avoid the use of typedef for function pointers

Replace typedefs bcm2835_audio_newpcm_func and bcm2835_audio_newctl_func with equivalent declarations to better align with the linux kernel coding style.

---
 .../staging/vc04_services/bcm2835-audio/bcm2835.c    | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +3 -9
index c250fbef2fa3..628732d7bf6a 100644
@@ -52,20 +52,14 @@ static int bcm2835_devm_add_vchi_ctx(struct device *dev)
 	return 0;
 }
 
-typedef int (*bcm2835_audio_newpcm_func)(struct bcm2835_chip *chip,
-					 const char *name,
-					 enum snd_bcm2835_route route,
-					 u32 numchannels);
-
-typedef int (*bcm2835_audio_newctl_func)(struct bcm2835_chip *chip);
-
 struct bcm2835_audio_driver {
 	struct device_driver driver;
 	const char *shortname;
 	const char *longname;
 	int minchannels;
-	bcm2835_audio_newpcm_func newpcm;
-	bcm2835_audio_newctl_func newctl;
+	int (*newpcm)(struct bcm2835_chip *chip, const char *name,
+		      enum snd_bcm2835_route route, u32 numchannels);
+	int (*newctl)(struct bcm2835_chip *chip);
 	enum snd_bcm2835_route route;
 };
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/3 staging: vc04_services: bcm2835-camera: avoid the use of typedef for function pointers

In reply to Gaston Gonzalez

Replace typedef bm2835_mmal_v4l2_ctrl_cb with equivalent declaration to better align with the linux kernel coding style.

---
 .../staging/vc04_services/bcm2835-camera/controls.c    | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/controls.c +2 -8
index b096a12387f7..3696dfb5a020 100644
@@ -65,13 +65,6 @@ enum bm2835_mmal_ctrl_type {
 	MMAL_CONTROL_TYPE_CLUSTER, /* special cluster entry */
 };
 
-struct bm2835_mmal_v4l2_ctrl;
-
-typedef	int(bm2835_mmal_v4l2_ctrl_cb)(
-				struct bm2835_mmal_dev *dev,
-				struct v4l2_ctrl *ctrl,
-				const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl);
-
 struct bm2835_mmal_v4l2_ctrl {
 	u32 id; /* v4l2 control identifier */
 	enum bm2835_mmal_ctrl_type type;
@@ -84,7 +77,8 @@ struct bm2835_mmal_v4l2_ctrl {
 	u64 step; /* step size of the control */
 	const s64 *imenu; /* integer menu array */
 	u32 mmal_id; /* mmal parameter id */
-	bm2835_mmal_v4l2_ctrl_cb *setter;
+	int (*setter)(struct bm2835_mmal_dev *dev, struct v4l2_ctrl *ctrl,
+		      const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl);
 };
 
 struct v4l2_to_mmal_effects_setting {
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/3 staging: vc04_services: update TODO file

In reply to Gaston Gonzalez

There are no struct typedef remaining inside vc04_services/. Hence, remove the task from the TODO file.

While at it, fix the items sequential numbering.

---
 drivers/staging/vc04_services/interface/TODO | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/vc04_services/interface/TODO +2 -6
index 39810ce017cd..241ca004735c 100644
@@ -80,11 +80,7 @@ vchiq-core.ko and vchiq-dev.ko. This would also ease the upstreaming process.
 
 The code in vchiq_bcm2835_arm.c should fit in the generic platform file.
 
-12) Get rid of all the struct typedefs
-
-Most structs are typedefd, it's not encouraged in the kernel.
-
-13) Get rid of all non essential global structures and create a proper per
+11) Get rid of all non essential global structures and create a proper per
 device structure
 
 The first thing one generally sees in a probe function is a memory allocation
@@ -92,6 +88,6 @@ for all the device specific data. This structure is then passed all over the
 driver. This is good practice since it makes the driver work regardless of the
 number of devices probed.
 
-14) Clean up Sparse warnings from __user annotations. See
+12) Clean up Sparse warnings from __user annotations. See
 vchiq_irq_queue_bulk_tx_rx(). Ensure that the address of "&waiter->bulk_waiter"
 is never disclosed to userspace.
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v2 3/3] staging: vc04_services: update TODO file

Quoted 4 lines · Gaston Gonzalez

There are no struct typedef remaining inside vc04_services/. Hence, remove the task from the TODO file.

While at it, fix the items sequential numbering.

The previous developers who let the numbers bitrot did the right thing. There is a kind of ethereal beauty to misnumbered TODO lists. #Hyperart

Or just replace the numbers with asterisks.

regards,
dan carpenter

maintainer
#5 lore raw
In reply to Gaston Gonzalez
Quoted 4 lines · Gaston Gonzalez

This patch set removes some typedefs for function pointers in vc04_services.

v1 -> v2:

Quoted 8 lines

- Following Greg suggestion, functions pointers were not renamed making patches 1 and 2 much smaller.
- Function pointers in vchiq-mmal were not touched as the result is less readable than the original.
- In the description of changes in the TODO file, it was specified that there are no current 'struct typedefs' left inside vc04_servivces.
- The name of the particular subsystem of vc04_services was included in the title of each commit.

Much nicer, thanks for redoing this. Now queued up.

greg k-h