Skip to content

Commit 3be7999

Browse files
Al ViroKernel Patches Daemon
authored andcommitted
hypfs: switch hypfs_create_str() to returning int
Every single caller only cares about PTR_ERR_OR_ZERO() of return value... Signed-off-by: Al Viro <[email protected]>
1 parent 52ae271 commit 3be7999

File tree

4 files changed

+18
-40
lines changed

4 files changed

+18
-40
lines changed

arch/s390/hypfs/hypfs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ extern struct dentry *hypfs_mkdir(struct dentry *parent, const char *name);
2525
extern struct dentry *hypfs_create_u64(struct dentry *dir, const char *name,
2626
__u64 value);
2727

28-
extern struct dentry *hypfs_create_str(struct dentry *dir, const char *name,
29-
char *string);
28+
extern int hypfs_create_str(struct dentry *dir, const char *name, char *string);
3029

3130
/* LPAR Hypervisor */
3231
extern int hypfs_diag_init(void);

arch/s390/hypfs/hypfs_diag_fs.c

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info)
228228
return PTR_ERR(rc);
229229
}
230230
diag224_idx2name(cpu_info__ctidx(diag204_get_info_type(), cpu_info), buffer);
231-
rc = hypfs_create_str(cpu_dir, "type", buffer);
232-
return PTR_ERR_OR_ZERO(rc);
231+
return hypfs_create_str(cpu_dir, "type", buffer);
233232
}
234233

235234
static void *hypfs_create_lpar_files(struct dentry *systems_dir, void *part_hdr)
@@ -276,8 +275,7 @@ static int hypfs_create_phys_cpu_files(struct dentry *cpus_dir, void *cpu_info)
276275
if (IS_ERR(rc))
277276
return PTR_ERR(rc);
278277
diag224_idx2name(phys_cpu__ctidx(diag204_get_info_type(), cpu_info), buffer);
279-
rc = hypfs_create_str(cpu_dir, "type", buffer);
280-
return PTR_ERR_OR_ZERO(rc);
278+
return hypfs_create_str(cpu_dir, "type", buffer);
281279
}
282280

283281
static void *hypfs_create_phys_files(struct dentry *parent_dir, void *phys_hdr)
@@ -316,41 +314,25 @@ int hypfs_diag_create_files(struct dentry *root)
316314
return rc;
317315

318316
systems_dir = hypfs_mkdir(root, "systems");
319-
if (IS_ERR(systems_dir)) {
320-
rc = PTR_ERR(systems_dir);
321-
goto err_out;
322-
}
317+
if (IS_ERR(systems_dir))
318+
return PTR_ERR(systems_dir);
323319
time_hdr = (struct x_info_blk_hdr *)buffer;
324320
part_hdr = time_hdr + info_blk_hdr__size(diag204_get_info_type());
325321
for (i = 0; i < info_blk_hdr__npar(diag204_get_info_type(), time_hdr); i++) {
326322
part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr);
327-
if (IS_ERR(part_hdr)) {
328-
rc = PTR_ERR(part_hdr);
329-
goto err_out;
330-
}
323+
if (IS_ERR(part_hdr))
324+
return PTR_ERR(part_hdr);
331325
}
332326
if (info_blk_hdr__flags(diag204_get_info_type(), time_hdr) &
333327
DIAG204_LPAR_PHYS_FLG) {
334328
ptr = hypfs_create_phys_files(root, part_hdr);
335-
if (IS_ERR(ptr)) {
336-
rc = PTR_ERR(ptr);
337-
goto err_out;
338-
}
329+
if (IS_ERR(ptr))
330+
return PTR_ERR(ptr);
339331
}
340332
hyp_dir = hypfs_mkdir(root, "hyp");
341-
if (IS_ERR(hyp_dir)) {
342-
rc = PTR_ERR(hyp_dir);
343-
goto err_out;
344-
}
345-
ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
346-
if (IS_ERR(ptr)) {
347-
rc = PTR_ERR(ptr);
348-
goto err_out;
349-
}
350-
rc = 0;
351-
352-
err_out:
353-
return rc;
333+
if (IS_ERR(hyp_dir))
334+
return PTR_ERR(hyp_dir);
335+
return hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
354336
}
355337

356338
/* Diagnose 224 functions */

arch/s390/hypfs/hypfs_vm_fs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ int hypfs_vm_create_files(struct dentry *root)
100100
rc = PTR_ERR(dir);
101101
goto failed;
102102
}
103-
file = hypfs_create_str(dir, "type", "z/VM Hypervisor");
104-
if (IS_ERR(file)) {
105-
rc = PTR_ERR(file);
103+
rc = hypfs_create_str(dir, "type", "z/VM Hypervisor");
104+
if (rc)
106105
goto failed;
107-
}
108106

109107
/* physical cpus */
110108
dir = hypfs_mkdir(root, "cpus");

arch/s390/hypfs/inode.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,24 +398,23 @@ struct dentry *hypfs_create_u64(struct dentry *dir,
398398
return dentry;
399399
}
400400

401-
struct dentry *hypfs_create_str(struct dentry *dir,
402-
const char *name, char *string)
401+
int hypfs_create_str(struct dentry *dir, const char *name, char *string)
403402
{
404403
char *buffer;
405404
struct dentry *dentry;
406405

407406
buffer = kmalloc(strlen(string) + 2, GFP_KERNEL);
408407
if (!buffer)
409-
return ERR_PTR(-ENOMEM);
408+
return -ENOMEM;
410409
sprintf(buffer, "%s\n", string);
411410
dentry =
412411
hypfs_create_file(dir, name, buffer, S_IFREG | REG_FILE_MODE);
413412
if (IS_ERR(dentry)) {
414413
kfree(buffer);
415-
return ERR_PTR(-ENOMEM);
414+
return -ENOMEM;
416415
}
417416
hypfs_add_dentry(dentry);
418-
return dentry;
417+
return 0;
419418
}
420419

421420
static const struct file_operations hypfs_file_ops = {

0 commit comments

Comments
 (0)