Re: [PATCH 11/11] lpfc: don't use file->f_path.dentry for comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> [PATCH v2] lpfc: don't use file->f_path.dentry for comparisons
>
> If you want a home-grown switch, at least use enum for selector...
>
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> ---
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
> index 3fd1aa5cc78c..42d138ec11b4 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> @@ -2375,32 +2375,32 @@ static ssize_t
>  lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
>         size_t nbytes, loff_t *ppos)
>  {
> -       struct dentry *dent = file->f_path.dentry;
>         struct lpfc_hba *phba = file->private_data;
> +       int kind = debugfs_get_aux_num(file);
>         char cbuf[32];
>         uint64_t tmp = 0;
>         int cnt = 0;
>
> -       if (dent == phba->debug_writeGuard)
> +       if (kind == writeGuard)
>                 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
> -       else if (dent == phba->debug_writeApp)
> +       else if (kind == writeApp)
>                 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
> -       else if (dent == phba->debug_writeRef)
> +       else if (kind == writeRef)
>                 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
> -       else if (dent == phba->debug_readGuard)
> +       else if (kind == readGuard)
>                 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
> -       else if (dent == phba->debug_readApp)
> +       else if (kind == readApp)
>                 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
> -       else if (dent == phba->debug_readRef)
> +       else if (kind == readRef)
>                 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
> -       else if (dent == phba->debug_InjErrNPortID)
> +       else if (kind == InjErrNPortID)
>                 cnt = scnprintf(cbuf, 32, "0x%06x\n",
>                                 phba->lpfc_injerr_nportid);
> -       else if (dent == phba->debug_InjErrWWPN) {
> +       else if (kind == InjErrWWPN) {
>                 memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
>                 tmp = cpu_to_be64(tmp);
>                 cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp);
> -       } else if (dent == phba->debug_InjErrLBA) {
> +       } else if (kind == InjErrLBA) {
>                 if (phba->lpfc_injerr_lba == (sector_t)(-1))
>                         cnt = scnprintf(cbuf, 32, "off\n");
>                 else
> @@ -2417,8 +2417,8 @@ static ssize_t
>  lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
>         size_t nbytes, loff_t *ppos)
>  {
> -       struct dentry *dent = file->f_path.dentry;
>         struct lpfc_hba *phba = file->private_data;
> +       int kind = debugfs_get_aux_num(file);
>         char dstbuf[33];
>         uint64_t tmp = 0;
>         int size;
> @@ -2428,7 +2428,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
>         if (copy_from_user(dstbuf, buf, size))
>                 return -EFAULT;
>
> -       if (dent == phba->debug_InjErrLBA) {
> +       if (kind == InjErrLBA) {
>                 if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') &&
>                     (dstbuf[2] == 'f'))
>                         tmp = (uint64_t)(-1);
> @@ -2437,23 +2437,23 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
>         if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
>                 return -EINVAL;
>
> -       if (dent == phba->debug_writeGuard)
> +       if (kind == writeGuard)
>                 phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
> -       else if (dent == phba->debug_writeApp)
> +       else if (kind == writeApp)
>                 phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp;
> -       else if (dent == phba->debug_writeRef)
> +       else if (kind == writeRef)
>                 phba->lpfc_injerr_wref_cnt = (uint32_t)tmp;
> -       else if (dent == phba->debug_readGuard)
> +       else if (kind == readGuard)
>                 phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp;
> -       else if (dent == phba->debug_readApp)
> +       else if (kind == readApp)
>                 phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp;
> -       else if (dent == phba->debug_readRef)
> +       else if (kind == readRef)
>                 phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
> -       else if (dent == phba->debug_InjErrLBA)
> +       else if (kind == InjErrLBA)
>                 phba->lpfc_injerr_lba = (sector_t)tmp;
> -       else if (dent == phba->debug_InjErrNPortID)
> +       else if (kind == InjErrNPortID)
>                 phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID);
> -       else if (dent == phba->debug_InjErrWWPN) {
> +       else if (kind == InjErrWWPN) {
>                 tmp = cpu_to_be64(tmp);
>                 memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name));
>         } else
> @@ -6160,60 +6160,51 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                         phba->debug_dumpHostSlim = NULL;
>
>                 /* Setup DIF Error Injections */
> -               snprintf(name, sizeof(name), "InjErrLBA");
>                 phba->debug_InjErrLBA =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("InjErrLBA", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, InjErrLBA, &lpfc_debugfs_op_dif_err);
>                 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
>
> -               snprintf(name, sizeof(name), "InjErrNPortID");
>                 phba->debug_InjErrNPortID =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("InjErrNPortID", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, InjErrNPortID, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "InjErrWWPN");
>                 phba->debug_InjErrWWPN =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("InjErrWWPN", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, InjErrWWPN, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "writeGuardInjErr");
>                 phba->debug_writeGuard =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("writeGuardInjErr", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, writeGuard, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "writeAppInjErr");
>                 phba->debug_writeApp =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("writeAppInjErr", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, writeApp, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "writeRefInjErr");
>                 phba->debug_writeRef =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("writeRefInjErr", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, writeRef, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "readGuardInjErr");
>                 phba->debug_readGuard =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("readGuardInjErr", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, readGuard, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "readAppInjErr");
>                 phba->debug_readApp =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("readAppInjErr", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, readApp, &lpfc_debugfs_op_dif_err);
>
> -               snprintf(name, sizeof(name), "readRefInjErr");
>                 phba->debug_readRef =
> -                       debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
> +                       debugfs_create_file_aux_num("readRefInjErr", 0644,
>                         phba->hba_debugfs_root,
> -                       phba, &lpfc_debugfs_op_dif_err);
> +                       phba, readRef, &lpfc_debugfs_op_dif_err);
>
>                 /* Setup slow ring trace */
>                 if (lpfc_debugfs_max_slow_ring_trc) {
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
> index 8d2e8d05bbc0..f319f3af0400 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.h
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.h
> @@ -322,6 +322,17 @@ enum {
>                                                  * discovery */
>  #endif /* H_LPFC_DEBUG_FS */
>
> +enum {
> +       writeGuard = 1,
> +       writeApp,
> +       writeRef,
> +       readGuard,
> +       readApp,
> +       readRef,
> +       InjErrLBA,
> +       InjErrNPortID,
> +       InjErrWWPN,
> +};
>
>  /*
>   * Driver debug utility routines outside of debugfs. The debug utility

Reviewed-by: Justin Tee <justin.tee@xxxxxxxxxxxx>

Regards,
Justin




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux