Hi all, Casting parameters in debugfs_create_*() calls prevents the compiler from performing some checks. Hence this patch series removes superfluous casts, or reworks code to no longer need the casts. All patches can be applied independently, there are no dependencies. Thanks for your comments! Geert Uytterhoeven (5): crypto: nx - Improve debugfs_create_u{32,64}() handling for atomics cxgb4/cxgb4vf: Remove superfluous void * cast in debugfs_create_file() call drm/amdgpu: Remove superfluous void * cast in debugfs_create_file() call power: avs: smartreflex: Remove superfluous cast in debugfs_create_file() call ionic: Use debugfs_create_bool() to export bool drivers/crypto/nx/nx_debugfs.c | 18 +++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- .../ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 2 +- .../ethernet/pensando/ionic/ionic_debugfs.c | 3 +-- drivers/power/avs/smartreflex.c | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) -- 2.17.1 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Variables of type atomic{,64}_t can be used fine with debugfs_create_u{32,64}, when passing a pointer to the embedded counter. This allows to get rid of the casts, which prevented compiler checks. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/crypto/nx/nx_debugfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/nx/nx_debugfs.c b/drivers/crypto/nx/nx_debugfs.c index e0d44a5512ab455b..1975bcbee997481e 100644 --- a/drivers/crypto/nx/nx_debugfs.c +++ b/drivers/crypto/nx/nx_debugfs.c @@ -38,23 +38,23 @@ void nx_debugfs_init(struct nx_crypto_driver *drv) drv->dfs_root = root; debugfs_create_u32("aes_ops", S_IRUSR | S_IRGRP | S_IROTH, - root, (u32 *)&drv->stats.aes_ops); + root, &drv->stats.aes_ops.counter); debugfs_create_u32("sha256_ops", S_IRUSR | S_IRGRP | S_IROTH, - root, (u32 *)&drv->stats.sha256_ops); + root, &drv->stats.sha256_ops.counter); debugfs_create_u32("sha512_ops", S_IRUSR | S_IRGRP | S_IROTH, - root, (u32 *)&drv->stats.sha512_ops); + root, &drv->stats.sha512_ops.counter); debugfs_create_u64("aes_bytes", S_IRUSR | S_IRGRP | S_IROTH, - root, (u64 *)&drv->stats.aes_bytes); + root, &drv->stats.aes_bytes.counter); debugfs_create_u64("sha256_bytes", S_IRUSR | S_IRGRP | S_IROTH, - root, (u64 *)&drv->stats.sha256_bytes); + root, &drv->stats.sha256_bytes.counter); debugfs_create_u64("sha512_bytes", S_IRUSR | S_IRGRP | S_IROTH, - root, (u64 *)&drv->stats.sha512_bytes); + root, &drv->stats.sha512_bytes.counter); debugfs_create_u32("errors", S_IRUSR | S_IRGRP | S_IROTH, - root, (u32 *)&drv->stats.errors); + root, &drv->stats.errors.counter); debugfs_create_u32("last_error", S_IRUSR | S_IRGRP | S_IROTH, - root, (u32 *)&drv->stats.last_error); + root, &drv->stats.last_error.counter); debugfs_create_u32("last_error_pid", S_IRUSR | S_IRGRP | S_IROTH, - root, (u32 *)&drv->stats.last_error_pid); + root, &drv->stats.last_error_pid.counter); } void -- 2.17.1
There is no need to cast a typed pointer to a void pointer when calling a function that accepts the latter. Remove it, as the cast prevents further compiler checks. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index f6fc0875d5b0a285..4a07a73c672b5996 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -2480,7 +2480,7 @@ static int setup_debugfs(struct adapter *adapter) for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) debugfs_create_file(debugfs_files[i].name, debugfs_files[i].mode, - adapter->debugfs_root, (void *)adapter, + adapter->debugfs_root, adapter, debugfs_files[i].fops); return 0; -- 2.17.1
There is no need to cast a typed pointer to a void pointer when calling a function that accepts the latter. Remove it, as the cast prevents further compiler checks. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index 5652cc72ed3a9b3a..b97a38b1e089b3d6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -1090,8 +1090,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) { adev->debugfs_preempt = debugfs_create_file("amdgpu_preempt_ib", 0600, - adev->ddev->primary->debugfs_root, - (void *)adev, &fops_ib_preempt); + adev->ddev->primary->debugfs_root, adev, + &fops_ib_preempt); if (!(adev->debugfs_preempt)) { DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); return -EIO; -- 2.17.1
There is no need to cast a typed pointer to a void pointer when calling a function that accepts the latter. Remove it, as the cast prevents further compiler checks. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/power/avs/smartreflex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c index 4684e7df833a81e9..5376f3d22f31eade 100644 --- a/drivers/power/avs/smartreflex.c +++ b/drivers/power/avs/smartreflex.c @@ -905,7 +905,7 @@ static int omap_sr_probe(struct platform_device *pdev) sr_info->dbg_dir = debugfs_create_dir(sr_info->name, sr_dbg_dir); debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, sr_info->dbg_dir, - (void *)sr_info, &pm_sr_fops); + sr_info, &pm_sr_fops); debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir, &sr_info->err_weight); debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir, -- 2.17.1
Currently bool ionic_cq.done_color is exported using debugfs_create_u8(), which requires a cast, preventing further compiler checks. Fix this by switching to debugfs_create_bool(), and dropping the cast. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/net/ethernet/pensando/ionic/ionic_debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c b/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c index bc03cecf80cc9eb4..5beba915f69d12dd 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c @@ -170,8 +170,7 @@ void ionic_debugfs_add_qcq(struct ionic_lif *lif, struct ionic_qcq *qcq) debugfs_create_x64("base_pa", 0400, cq_dentry, &cq->base_pa); debugfs_create_u32("num_descs", 0400, cq_dentry, &cq->num_descs); debugfs_create_u32("desc_size", 0400, cq_dentry, &cq->desc_size); - debugfs_create_u8("done_color", 0400, cq_dentry, - (u8 *)&cq->done_color); + debugfs_create_bool("done_color", 0400, cq_dentry, &cq->done_color); debugfs_create_file("tail", 0400, cq_dentry, cq, &cq_tail_fops); -- 2.17.1
On 10/21/19 7:51 AM, Geert Uytterhoeven wrote: > Currently bool ionic_cq.done_color is exported using > debugfs_create_u8(), which requires a cast, preventing further compiler > checks. > > Fix this by switching to debugfs_create_bool(), and dropping the cast. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Shannon Nelson <snelson@pensando.io> > --- > drivers/net/ethernet/pensando/ionic/ionic_debugfs.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c b/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c > index bc03cecf80cc9eb4..5beba915f69d12dd 100644 > --- a/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c > +++ b/drivers/net/ethernet/pensando/ionic/ionic_debugfs.c > @@ -170,8 +170,7 @@ void ionic_debugfs_add_qcq(struct ionic_lif *lif, struct ionic_qcq *qcq) > debugfs_create_x64("base_pa", 0400, cq_dentry, &cq->base_pa); > debugfs_create_u32("num_descs", 0400, cq_dentry, &cq->num_descs); > debugfs_create_u32("desc_size", 0400, cq_dentry, &cq->desc_size); > - debugfs_create_u8("done_color", 0400, cq_dentry, > - (u8 *)&cq->done_color); > + debugfs_create_bool("done_color", 0400, cq_dentry, &cq->done_color); > > debugfs_create_file("tail", 0400, cq_dentry, cq, &cq_tail_fops); >
On Mon, Oct 21, 2019 at 04:51:45PM +0200, Geert Uytterhoeven wrote: > Variables of type atomic{,64}_t can be used fine with > debugfs_create_u{32,64}, when passing a pointer to the embedded counter. > This allows to get rid of the casts, which prevented compiler checks. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > drivers/crypto/nx/nx_debugfs.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
On Mon, Oct 21, 2019 at 6:23 PM Geert Uytterhoeven <geert+renesas@glider.be> wrote: > > There is no need to cast a typed pointer to a void pointer when calling > a function that accepts the latter. Remove it, as the cast prevents > further compiler checks. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Applied. Thanks! Alex > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > index 5652cc72ed3a9b3a..b97a38b1e089b3d6 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > @@ -1090,8 +1090,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) > { > adev->debugfs_preempt = > debugfs_create_file("amdgpu_preempt_ib", 0600, > - adev->ddev->primary->debugfs_root, > - (void *)adev, &fops_ib_preempt); > + adev->ddev->primary->debugfs_root, adev, > + &fops_ib_preempt); > if (!(adev->debugfs_preempt)) { > DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); > return -EIO; > -- > 2.17.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Monday, October 21, 2019 4:51:48 PM CET Geert Uytterhoeven wrote: > There is no need to cast a typed pointer to a void pointer when calling > a function that accepts the latter. Remove it, as the cast prevents > further compiler checks. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Greg, have you taken this one by any chance? > --- > drivers/power/avs/smartreflex.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c > index 4684e7df833a81e9..5376f3d22f31eade 100644 > --- a/drivers/power/avs/smartreflex.c > +++ b/drivers/power/avs/smartreflex.c > @@ -905,7 +905,7 @@ static int omap_sr_probe(struct platform_device *pdev) > sr_info->dbg_dir = debugfs_create_dir(sr_info->name, sr_dbg_dir); > > debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, sr_info->dbg_dir, > - (void *)sr_info, &pm_sr_fops); > + sr_info, &pm_sr_fops); > debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir, > &sr_info->err_weight); > debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir, >
On Fri, Nov 08, 2019 at 12:24:42PM +0100, Rafael J. Wysocki wrote:
> On Monday, October 21, 2019 4:51:48 PM CET Geert Uytterhoeven wrote:
> > There is no need to cast a typed pointer to a void pointer when calling
> > a function that accepts the latter. Remove it, as the cast prevents
> > further compiler checks.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Greg, have you taken this one by any chance?
Nope, it's all yours! :)
On Monday, October 21, 2019 4:51:48 PM CET Geert Uytterhoeven wrote:
> There is no need to cast a typed pointer to a void pointer when calling
> a function that accepts the latter. Remove it, as the cast prevents
> further compiler checks.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> drivers/power/avs/smartreflex.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
> index 4684e7df833a81e9..5376f3d22f31eade 100644
> --- a/drivers/power/avs/smartreflex.c
> +++ b/drivers/power/avs/smartreflex.c
> @@ -905,7 +905,7 @@ static int omap_sr_probe(struct platform_device *pdev)
> sr_info->dbg_dir = debugfs_create_dir(sr_info->name, sr_dbg_dir);
>
> debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, sr_info->dbg_dir,
> - (void *)sr_info, &pm_sr_fops);
> + sr_info, &pm_sr_fops);
> debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir,
> &sr_info->err_weight);
> debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir,
>
Applying as 5.5 material, thanks!