Re: [PATCH] Staging: pi433: Change bit_rate type from u16 to u32
From: Dan Carpenter
Date: Sat Mar 11 2023 - 08:18:13 EST
On Sat, Mar 11, 2023 at 05:00:23AM -0800, Sumitra Sharma wrote:
> Hi Dan,
>
> The description in TODO is difficult to understand. I would appreciae if
> you could help me understand it more in a step-by-step simplified means.
>
> "This configuration needs to be moved to sysfs instead of being done through
> + IOCTL. Goind forward, we need to port userspace tools to use sysfs instead
> + of IOCTL and then we would delete IOCTL."
>
This driver comes with a user space program to control it. Your patch
breaks that program. Someone could find the program and change it to
use a u32 instead of a u16 but the old version would still be broken so
users would be confused.
Generally, in the kernel we try to avoid doing configuration through
ioctls these days but instead prefer to use sysfs.
Now the driver uses a pi433_tx_cfg struct which is the same for both
user space and kernel space. What we do is create a different one which
is private to the kernel. Then in pi433_ioctl() we copy the user space
struct and convert it to a kernel space struct (new format with a u32).
Change the kernel to use the new struct every where except the
pi433_ioctl.
Then add some new sysfs files so that the user can control the bitrate
without changing any of the rest of the struct. Update the user space
tool to use sysfs instead of the ioctl. Then after everyone upgrades to
the new version delete the ioctl.
regards,
dan carpenter