[patch 10/13] ptp: Split out PTP_MASK_CLEAR_ALL ioctl code

Thomas Gleixner posted 13 patches 3 months, 2 weeks ago
There is a newer version of this series
[patch 10/13] ptp: Split out PTP_MASK_CLEAR_ALL ioctl code
Posted by Thomas Gleixner 3 months, 2 weeks ago
Continue the ptp_ioctl() cleanup by splitting out the PTP_MASK_CLEAR_ALL ioctl
code into a helper function.

No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/ptp/ptp_chardev.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -442,6 +442,12 @@ static long ptp_pin_setfunc(struct ptp_c
 		return ptp_set_pinfunc(ptp, pin_index, pd.func, pd.chan);
 }
 
+static long ptp_mask_clear_all(struct timestamp_event_queue *tsevq)
+{
+	bitmap_clear(tsevq->mask, 0, PTP_MAX_CHANNELS);
+	return 0;
+}
+
 long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
 	       unsigned long arg)
 {
@@ -504,8 +510,7 @@ long ptp_ioctl(struct posix_clock_contex
 		return ptp_pin_setfunc(ptp, cmd, argptr);
 
 	case PTP_MASK_CLEAR_ALL:
-		bitmap_clear(tsevq->mask, 0, PTP_MAX_CHANNELS);
-		break;
+		return ptp_mask_clear_all(pccontext->private_clkdata);
 
 	case PTP_MASK_EN_SINGLE:
 		if (copy_from_user(&i, (void __user *)arg, sizeof(i))) {
Re: [patch 10/13] ptp: Split out PTP_MASK_CLEAR_ALL ioctl code
Posted by Vadim Fedorenko 3 months, 2 weeks ago
On 20/06/2025 14:24, Thomas Gleixner wrote:
> Continue the ptp_ioctl() cleanup by splitting out the PTP_MASK_CLEAR_ALL ioctl
> code into a helper function.
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>   drivers/ptp/ptp_chardev.c |    9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -442,6 +442,12 @@ static long ptp_pin_setfunc(struct ptp_c
>   		return ptp_set_pinfunc(ptp, pin_index, pd.func, pd.chan);
>   }
>   
> +static long ptp_mask_clear_all(struct timestamp_event_queue *tsevq)
> +{
> +	bitmap_clear(tsevq->mask, 0, PTP_MAX_CHANNELS);
> +	return 0;
> +}
> +
>   long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
>   	       unsigned long arg)
>   {
> @@ -504,8 +510,7 @@ long ptp_ioctl(struct posix_clock_contex
>   		return ptp_pin_setfunc(ptp, cmd, argptr);
>   
>   	case PTP_MASK_CLEAR_ALL:
> -		bitmap_clear(tsevq->mask, 0, PTP_MAX_CHANNELS);
> -		break;
> +		return ptp_mask_clear_all(pccontext->private_clkdata);
>   
>   	case PTP_MASK_EN_SINGLE:
>   		if (copy_from_user(&i, (void __user *)arg, sizeof(i))) {
> 

Not quite sure there is a benefit of having a function for this type,
apart from having one style. But it adds some LoC...
Re: [patch 10/13] ptp: Split out PTP_MASK_CLEAR_ALL ioctl code
Posted by Thomas Gleixner 3 months, 2 weeks ago
On Sat, Jun 21 2025 at 21:36, Vadim Fedorenko wrote:
> On 20/06/2025 14:24, Thomas Gleixner wrote:
>> Continue the ptp_ioctl() cleanup by splitting out the PTP_MASK_CLEAR_ALL ioctl
>> code into a helper function.
>>   	case PTP_MASK_CLEAR_ALL:
>> -		bitmap_clear(tsevq->mask, 0, PTP_MAX_CHANNELS);
>> -		break;
>> +		return ptp_mask_clear_all(pccontext->private_clkdata);
>>   
>>   	case PTP_MASK_EN_SINGLE:
>>   		if (copy_from_user(&i, (void __user *)arg, sizeof(i))) {
>> 
>
> Not quite sure there is a benefit of having a function for this type,
> apart from having one style. But it adds some LoC...

Sure it's debatable benefit, but it makes the code more consistent and
does not introduce this oddball in the middle of the other function
calls.

Thanks,

        tglx
Re: [patch 10/13] ptp: Split out PTP_MASK_CLEAR_ALL ioctl code
Posted by Vadim Fedorenko 3 months, 2 weeks ago
On 21/06/2025 21:44, Thomas Gleixner wrote:
> On Sat, Jun 21 2025 at 21:36, Vadim Fedorenko wrote:
>> On 20/06/2025 14:24, Thomas Gleixner wrote:
>>> Continue the ptp_ioctl() cleanup by splitting out the PTP_MASK_CLEAR_ALL ioctl
>>> code into a helper function.
>>>    	case PTP_MASK_CLEAR_ALL:
>>> -		bitmap_clear(tsevq->mask, 0, PTP_MAX_CHANNELS);
>>> -		break;
>>> +		return ptp_mask_clear_all(pccontext->private_clkdata);
>>>    
>>>    	case PTP_MASK_EN_SINGLE:
>>>    		if (copy_from_user(&i, (void __user *)arg, sizeof(i))) {
>>>
>>
>> Not quite sure there is a benefit of having a function for this type,
>> apart from having one style. But it adds some LoC...
> 
> Sure it's debatable benefit, but it makes the code more consistent and
> does not introduce this oddball in the middle of the other function
> calls.

Fair.

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>