Subject: Re: [RFC] ptp: Delete invalided timestamp event queue code

From: Simon Horman <[email-masked]>
Date: Wed, 9 Oct 2024 08:06:37 +0100

On Mon, Oct 07, 2024 at 11:25:02PM +0800, tao wrote:
> used timestamp event queue In ptp_open func,  queue of ptp_clock_register
>  already invalid so delete it
> 
> Signed-off-by: tao <[email-masked]>
> ---
>  drivers/ptp/ptp_clock.c | 19 -------------------
>  1 file changed, 19 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index c56cd0f63909..9be8136cb64c 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -235,7 +235,6 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
>  				     struct device *parent)
>  {
>  	struct ptp_clock *ptp;
> -	struct timestamp_event_queue *queue = NULL;
>  	int err, index, major = MAJOR(ptp_devt);
>  	char debugfsname[16];
>  	size_t size;
> @@ -260,20 +259,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
>  	ptp->devid = MKDEV(major, index);
>  	ptp->index = index;
>  	INIT_LIST_HEAD(&ptp->tsevqs);
> -	queue = kzalloc(sizeof(*queue), GFP_KERNEL);
> -	if (!queue) {
> -		err = -ENOMEM;
> -		goto no_memory_queue;
> -	}
> -	list_add_tail(&queue->qlist, &ptp->tsevqs);

Here the queue is connected to ptp->tseqvs,
as was the case when it was added in

d26ab5a35ad9 ("ptp: Replace timestamp event queue with linked list")

Are you saying that it is no longer used as per that commit?

>  	spin_lock_init(&ptp->tsevqs_lock);
> -	queue->mask = bitmap_alloc(PTP_MAX_CHANNELS, GFP_KERNEL);
> -	if (!queue->mask) {
> -		err = -ENOMEM;
> -		goto no_memory_bitmap;
> -	}
> -	bitmap_set(queue->mask, 0, PTP_MAX_CHANNELS);
> -	spin_lock_init(&queue->lock);
>  	mutex_init(&ptp->pincfg_mux);
>  	mutex_init(&ptp->n_vclocks_mux);
>  	init_waitqueue_head(&ptp->tsev_wq);
> @@ -380,11 +366,6 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
>  kworker_err:
>  	mutex_destroy(&ptp->pincfg_mux);
>  	mutex_destroy(&ptp->n_vclocks_mux);
> -	bitmap_free(queue->mask);
> -no_memory_bitmap:
> -	list_del(&queue->qlist);
> -	kfree(queue);
> -no_memory_queue:
>  	xa_erase(&ptp_clocks_map, index);
>  no_slot:
>  	kfree(ptp);
> -- 
> 2.25.1
> 
>