Re: [PATCH v2 2/2] mmc: debugfs: Allow host caps to be modified
From: Vincent Whitchurch
Date: Mon Oct 09 2023 - 03:28:23 EST
On Sat, 2023-10-07 at 10:27 +0800, Wenchao Chen wrote:
> On Fri, 29 Sept 2023 at 21:17, Vincent Whitchurch
> <vincent.whitchurch@xxxxxxxx> wrote:
> > // MMC_CAP2_HS200_1_8V_SDR
> > /sys/kernel/debug/mmc0# echo $(($(cat caps2) & ~(1 << 5))) > caps2
>
> $(($(cat caps2) & ~(1 << 5))) looks complicated, does it use echo DDR52 > caps2?
1 << 5 is (as the comment above says) MMC_CAP2_HS200_1_8V_SDR. The
read-modify-write is needed to not clear unrelated bits. The MMC
framework picks the best possible mode supported by both the card and
the host controller, so disabling support for HS200 in the host
controller leads to DDR52 being picked in this case.
[...]
> > void mmc_add_host_debugfs(struct mmc_host *host)
> > {
> > struct dentry *root;
> > @@ -306,8 +352,9 @@ void mmc_add_host_debugfs(struct mmc_host *host)
> > host->debugfs_root = root;
> >
> > debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops);
> > - debugfs_create_x32("caps", S_IRUSR, root, &host->caps);
> > - debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2);
> > + debugfs_create_file("caps", 0600, root, &host->caps, &mmc_caps_fops);
> > + debugfs_create_file("caps2", 0600, root, &host->caps2,
> > + &mmc_caps2_fops);
>
> Would it be better to use "S_IRUSR | S_IWUSR" instead of "0600"?
No, not according to checkpatch which says that numeric permissions are
preferred.