Commit 63f76f51 authored by Al Viro's avatar Al Viro
Browse files

hypfs: switch hypfs_create_str() to returning int



Every single caller only cares about PTR_ERR_OR_ZERO() of return value...

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 781716cd
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -25,8 +25,7 @@ extern struct dentry *hypfs_mkdir(struct dentry *parent, const char *name);
extern struct dentry *hypfs_create_u64(struct dentry *dir, const char *name,
				       __u64 value);

extern struct dentry *hypfs_create_str(struct dentry *dir, const char *name,
				       char *string);
extern int hypfs_create_str(struct dentry *dir, const char *name, char *string);

/* LPAR Hypervisor */
extern int hypfs_diag_init(void);
+11 −29
Original line number Diff line number Diff line
@@ -228,8 +228,7 @@ static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info)
			return PTR_ERR(rc);
	}
	diag224_idx2name(cpu_info__ctidx(diag204_get_info_type(), cpu_info), buffer);
	rc = hypfs_create_str(cpu_dir, "type", buffer);
	return PTR_ERR_OR_ZERO(rc);
	return hypfs_create_str(cpu_dir, "type", buffer);
}

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)
	if (IS_ERR(rc))
		return PTR_ERR(rc);
	diag224_idx2name(phys_cpu__ctidx(diag204_get_info_type(), cpu_info), buffer);
	rc = hypfs_create_str(cpu_dir, "type", buffer);
	return PTR_ERR_OR_ZERO(rc);
	return hypfs_create_str(cpu_dir, "type", buffer);
}

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)
		return rc;

	systems_dir = hypfs_mkdir(root, "systems");
	if (IS_ERR(systems_dir)) {
		rc = PTR_ERR(systems_dir);
		goto err_out;
	}
	if (IS_ERR(systems_dir))
		return PTR_ERR(systems_dir);
	time_hdr = (struct x_info_blk_hdr *)buffer;
	part_hdr = time_hdr + info_blk_hdr__size(diag204_get_info_type());
	for (i = 0; i < info_blk_hdr__npar(diag204_get_info_type(), time_hdr); i++) {
		part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr);
		if (IS_ERR(part_hdr)) {
			rc = PTR_ERR(part_hdr);
			goto err_out;
		}
		if (IS_ERR(part_hdr))
			return PTR_ERR(part_hdr);
	}
	if (info_blk_hdr__flags(diag204_get_info_type(), time_hdr) &
	    DIAG204_LPAR_PHYS_FLG) {
		ptr = hypfs_create_phys_files(root, part_hdr);
		if (IS_ERR(ptr)) {
			rc = PTR_ERR(ptr);
			goto err_out;
		}
		if (IS_ERR(ptr))
			return PTR_ERR(ptr);
	}
	hyp_dir = hypfs_mkdir(root, "hyp");
	if (IS_ERR(hyp_dir)) {
		rc = PTR_ERR(hyp_dir);
		goto err_out;
	}
	ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
	if (IS_ERR(ptr)) {
		rc = PTR_ERR(ptr);
		goto err_out;
	}
	rc = 0;

err_out:
	return rc;
	if (IS_ERR(hyp_dir))
		return PTR_ERR(hyp_dir);
	return hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
}

/* Diagnose 224 functions */
+2 −4
Original line number Diff line number Diff line
@@ -100,11 +100,9 @@ int hypfs_vm_create_files(struct dentry *root)
		rc = PTR_ERR(dir);
		goto failed;
	}
	file = hypfs_create_str(dir, "type", "z/VM Hypervisor");
	if (IS_ERR(file)) {
		rc = PTR_ERR(file);
	rc = hypfs_create_str(dir, "type", "z/VM Hypervisor");
	if (rc)
		goto failed;
	}

	/* physical cpus */
	dir = hypfs_mkdir(root, "cpus");
+4 −5
Original line number Diff line number Diff line
@@ -398,24 +398,23 @@ struct dentry *hypfs_create_u64(struct dentry *dir,
	return dentry;
}

struct dentry *hypfs_create_str(struct dentry *dir,
				const char *name, char *string)
int hypfs_create_str(struct dentry *dir, const char *name, char *string)
{
	char *buffer;
	struct dentry *dentry;

	buffer = kmalloc(strlen(string) + 2, GFP_KERNEL);
	if (!buffer)
		return ERR_PTR(-ENOMEM);
		return -ENOMEM;
	sprintf(buffer, "%s\n", string);
	dentry =
	    hypfs_create_file(dir, name, buffer, S_IFREG | REG_FILE_MODE);
	if (IS_ERR(dentry)) {
		kfree(buffer);
		return ERR_PTR(-ENOMEM);
		return -ENOMEM;
	}
	hypfs_add_dentry(dentry);
	return dentry;
	return 0;
}

static const struct file_operations hypfs_file_ops = {