Skip to content

Commit 764def9

Browse files
Stefan Haberlandaxboe
authored andcommitted
s390/dasd: Remove unnecessary debugfs_create() return checks
The DASD driver only uses the dentry pointers when removing debugfs entries, and debugfs_remove() can safely handle both NULL and ERR_PTR. There is therefore no need to check debugfs_create() return values. This simplifies the debugfs setup code without changing functionality. Suggested-by: Heiko Carstens <hca@linux.ibm.com> Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com> Signed-off-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c943bfc commit 764def9

1 file changed

Lines changed: 8 additions & 56 deletions

File tree

drivers/s390/block/dasd.c

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,6 @@ static int dasd_state_known_to_new(struct dasd_device *device)
207207
return 0;
208208
}
209209

210-
static struct dentry *dasd_debugfs_setup(const char *name,
211-
struct dentry *base_dentry)
212-
{
213-
struct dentry *pde;
214-
215-
if (!base_dentry)
216-
return NULL;
217-
pde = debugfs_create_dir(name, base_dentry);
218-
if (!pde || IS_ERR(pde))
219-
return NULL;
220-
return pde;
221-
}
222-
223210
/*
224211
* Request the irq line for the device.
225212
*/
@@ -234,14 +221,14 @@ static int dasd_state_known_to_basic(struct dasd_device *device)
234221
if (rc)
235222
return rc;
236223
block->debugfs_dentry =
237-
dasd_debugfs_setup(block->gdp->disk_name,
224+
debugfs_create_dir(block->gdp->disk_name,
238225
dasd_debugfs_root_entry);
239226
dasd_profile_init(&block->profile, block->debugfs_dentry);
240227
if (dasd_global_profile_level == DASD_PROFILE_ON)
241228
dasd_profile_on(&device->block->profile);
242229
}
243230
device->debugfs_dentry =
244-
dasd_debugfs_setup(dev_name(&device->cdev->dev),
231+
debugfs_create_dir(dev_name(&device->cdev->dev),
245232
dasd_debugfs_root_entry);
246233
dasd_profile_init(&device->profile, device->debugfs_dentry);
247234
dasd_hosts_init(device->debugfs_dentry, device);
@@ -1058,19 +1045,9 @@ static const struct file_operations dasd_stats_raw_fops = {
10581045
static void dasd_profile_init(struct dasd_profile *profile,
10591046
struct dentry *base_dentry)
10601047
{
1061-
umode_t mode;
1062-
struct dentry *pde;
1063-
1064-
if (!base_dentry)
1065-
return;
1066-
profile->dentry = NULL;
10671048
profile->data = NULL;
1068-
mode = (S_IRUSR | S_IWUSR | S_IFREG);
1069-
pde = debugfs_create_file("statistics", mode, base_dentry,
1070-
profile, &dasd_stats_raw_fops);
1071-
if (pde && !IS_ERR(pde))
1072-
profile->dentry = pde;
1073-
return;
1049+
profile->dentry = debugfs_create_file("statistics", 0600, base_dentry,
1050+
profile, &dasd_stats_raw_fops);
10741051
}
10751052

10761053
static void dasd_profile_exit(struct dasd_profile *profile)
@@ -1090,25 +1067,9 @@ static void dasd_statistics_removeroot(void)
10901067

10911068
static void dasd_statistics_createroot(void)
10921069
{
1093-
struct dentry *pde;
1094-
1095-
dasd_debugfs_root_entry = NULL;
1096-
pde = debugfs_create_dir("dasd", NULL);
1097-
if (!pde || IS_ERR(pde))
1098-
goto error;
1099-
dasd_debugfs_root_entry = pde;
1100-
pde = debugfs_create_dir("global", dasd_debugfs_root_entry);
1101-
if (!pde || IS_ERR(pde))
1102-
goto error;
1103-
dasd_debugfs_global_entry = pde;
1070+
dasd_debugfs_root_entry = debugfs_create_dir("dasd", NULL);
1071+
dasd_debugfs_global_entry = debugfs_create_dir("global", dasd_debugfs_root_entry);
11041072
dasd_profile_init(&dasd_global_profile, dasd_debugfs_global_entry);
1105-
return;
1106-
1107-
error:
1108-
DBF_EVENT(DBF_ERR, "%s",
1109-
"Creation of the dasd debugfs interface failed");
1110-
dasd_statistics_removeroot();
1111-
return;
11121073
}
11131074

11141075
#else
@@ -1169,17 +1130,8 @@ static void dasd_hosts_exit(struct dasd_device *device)
11691130
static void dasd_hosts_init(struct dentry *base_dentry,
11701131
struct dasd_device *device)
11711132
{
1172-
struct dentry *pde;
1173-
umode_t mode;
1174-
1175-
if (!base_dentry)
1176-
return;
1177-
1178-
mode = S_IRUSR | S_IFREG;
1179-
pde = debugfs_create_file("host_access_list", mode, base_dentry,
1180-
device, &dasd_hosts_fops);
1181-
if (pde && !IS_ERR(pde))
1182-
device->hosts_dentry = pde;
1133+
device->hosts_dentry = debugfs_create_file("host_access_list", 0400, base_dentry,
1134+
device, &dasd_hosts_fops);
11831135
}
11841136

11851137
struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize,

0 commit comments

Comments
 (0)