public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Gaston Gonzalez <gascoar@gmail.com>
Cc: linux-staging@lists.linux.dev, nsaenz@kernel.org,
	f.fainelli@gmail.com, rjui@broadcom.com, sbranden@broadcom.com,
	bcm-kernel-feedback-list@broadcom.com,
	juerg.haefliger@canonical.com, rdunlap@infradead.org,
	dave.stevenson@raspberrypi.com, stefan.wahren@i2se.com,
	unixbhaskar@gmail.com, mitaliborkar810@gmail.com,
	phil@raspberrypi.com, linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] staging: vc04_services: avoid the use of typedef for function pointers
Date: Tue, 21 Dec 2021 07:22:05 +0100	[thread overview]
Message-ID: <YcFyjXOfGz9GwPAD@kroah.com> (raw)
In-Reply-To: <a218f1bd092d874ccd96e3a94c1174ad41fffebc.1639858361.git.gascoar@gmail.com>

On Mon, Dec 20, 2021 at 06:29:13PM -0300, Gaston Gonzalez wrote:
> Replace the function pointer typedef vchiq_mmal_buffer_cb with
> equivalent declaration to better align with the linux kernel coding
> style.
> 
> While at it, realignments were done in some touched lines.
> 
> Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
> ---
>  .../vc04_services/vchiq-mmal/mmal-vchiq.c     | 24 +++++++++----------
>  .../vc04_services/vchiq-mmal/mmal-vchiq.h     | 13 +++++-----
>  2 files changed, 18 insertions(+), 19 deletions(-)

Same subject line as patch 1/4 :(

> 
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> index 76d3f0399964..54e5ce245ae7 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> @@ -269,10 +269,10 @@ static void buffer_work_cb(struct work_struct *work)
>  
>  	atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
>  
> -	msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
> -					    msg_context->u.bulk.port,
> -					    msg_context->u.bulk.status,
> -					    msg_context->u.bulk.buffer);
> +	msg_context->u.bulk.port->vchiq_mmal_buffer_cb(msg_context->u.bulk.instance,
> +						       msg_context->u.bulk.port,
> +						       msg_context->u.bulk.status,
> +						       msg_context->u.bulk.buffer);
>  }
>  
>  /* workqueue scheduled callback to handle receiving buffers
> @@ -1327,13 +1327,12 @@ static int port_disable(struct vchiq_mmal_instance *instance,
>  			mmalbuf = list_entry(buf_head, struct mmal_buffer,
>  					     list);
>  			list_del(buf_head);
> -			if (port->buffer_cb) {
> +			if (port->vchiq_mmal_buffer_cb) {
>  				mmalbuf->length = 0;
>  				mmalbuf->mmal_flags = 0;
>  				mmalbuf->dts = MMAL_TIME_UNKNOWN;
>  				mmalbuf->pts = MMAL_TIME_UNKNOWN;
> -				port->buffer_cb(instance,
> -						port, 0, mmalbuf);
> +				port->vchiq_mmal_buffer_cb(instance, port, 0, mmalbuf);
>  			}
>  		}
>  
> @@ -1363,7 +1362,7 @@ static int port_enable(struct vchiq_mmal_instance *instance,
>  
>  	port->enabled = 1;
>  
> -	if (port->buffer_cb) {
> +	if (port->vchiq_mmal_buffer_cb) {
>  		/* send buffer headers to videocore */
>  		hdr_count = 1;
>  		list_for_each_safe(buf_head, q, &port->buffers) {
> @@ -1454,9 +1453,10 @@ EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_get);
>   * enables a port and queues buffers for satisfying callbacks if we
>   * provide a callback handler
>   */
> -int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
> -			   struct vchiq_mmal_port *port,
> -			   vchiq_mmal_buffer_cb buffer_cb)
> +int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance, struct vchiq_mmal_port *port,
> +			   void (*vchiq_mmal_buffer_cb)(struct vchiq_mmal_instance  *instance,
> +							struct vchiq_mmal_port *port, int status,
> +							struct mmal_buffer *buffer))
>  {
>  	int ret;
>  
> @@ -1469,7 +1469,7 @@ int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
>  		goto unlock;
>  	}
>  
> -	port->buffer_cb = buffer_cb;
> +	port->vchiq_mmal_buffer_cb = vchiq_mmal_buffer_cb;
>  
>  	ret = port_enable(instance, port);
>  
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> index 1dc81ecf9268..39615ce6584a 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> @@ -42,11 +42,6 @@ struct vchiq_mmal_port_buffer {
>  
>  struct vchiq_mmal_port;
>  
> -typedef void (*vchiq_mmal_buffer_cb)(
> -		struct vchiq_mmal_instance  *instance,
> -		struct vchiq_mmal_port *port,
> -		int status, struct mmal_buffer *buffer);
> -
>  struct vchiq_mmal_port {
>  	u32 enabled:1;
>  	u32 handle;
> @@ -76,7 +71,9 @@ struct vchiq_mmal_port {
>  	/* Count of buffers the VPU has yet to return */
>  	atomic_t buffers_with_vpu;
>  	/* callback on buffer completion */
> -	vchiq_mmal_buffer_cb buffer_cb;
> +	void (*vchiq_mmal_buffer_cb)(struct vchiq_mmal_instance  *instance,
> +				     struct vchiq_mmal_port *port, int status,
> +				     struct mmal_buffer *buffer);

There is no need to rename the function pointer at all.

>  	/* callback context */
>  	void *cb_ctx;
>  };
> @@ -126,7 +123,9 @@ int vchiq_mmal_component_disable(
>  int vchiq_mmal_port_enable(
>  		struct vchiq_mmal_instance *instance,
>  		struct vchiq_mmal_port *port,
> -		vchiq_mmal_buffer_cb buffer_cb);
> +		void (*vchiq_mmal_buffer_cb)(struct vchiq_mmal_instance  *instance,
> +					     struct vchiq_mmal_port *port, int status,
> +					     struct mmal_buffer *buffer));
>  

Here is where using a typedef is ok.  Again, typedefs for function
pointers is normal and keeps code smaller and easier to follow.

thanks,

greg k-h

  reply	other threads:[~2021-12-21  6:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 21:29 [PATCH 0/4] staging: vc04_services: avoid the use of typedef for function pointers Gaston Gonzalez
2021-12-20 21:29 ` [PATCH 1/4] " Gaston Gonzalez
2021-12-20 21:29 ` [PATCH 2/4] " Gaston Gonzalez
2021-12-20 23:28   ` Stefan Wahren
2021-12-21  6:19   ` Greg KH
2021-12-21 20:41     ` Gaston Gonzalez
2021-12-20 21:29 ` [PATCH 3/4] " Gaston Gonzalez
2021-12-21  6:22   ` Greg KH [this message]
2021-12-21 20:43     ` Gaston Gonzalez
2021-12-20 21:29 ` [PATCH 4/4] staging: vc04_services: update TODO file Gaston Gonzalez
2021-12-21  6:20 ` [PATCH 0/4] staging: vc04_services: avoid the use of typedef for function pointers Greg KH
2021-12-21 20:40   ` Gaston Gonzalez

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=YcFyjXOfGz9GwPAD@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=f.fainelli@gmail.com \
    --cc=gascoar@gmail.com \
    --cc=juerg.haefliger@canonical.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mitaliborkar810@gmail.com \
    --cc=nsaenz@kernel.org \
    --cc=phil@raspberrypi.com \
    --cc=rdunlap@infradead.org \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=stefan.wahren@i2se.com \
    --cc=unixbhaskar@gmail.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