Commit 1e632eaa authored by Julian Wiedmann's avatar Julian Wiedmann Committed by Heiko Carstens
Browse files

s390/prng: let misc_register() add the prng sysfs attributes



Instead of creating the sysfs attributes for the prng devices by hand,
describe them in .groups and let the misdevice core handle it.

This also ensures that the attributes are available when the KOBJ_ADD
event is raised.

Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 5ec11d09
Loading
Loading
Loading
Loading
+16 −37
Original line number Diff line number Diff line
@@ -674,20 +674,6 @@ static const struct file_operations prng_tdes_fops = {
	.llseek		= noop_llseek,
};

static struct miscdevice prng_sha512_dev = {
	.name	= "prandom",
	.minor	= MISC_DYNAMIC_MINOR,
	.mode	= 0644,
	.fops	= &prng_sha512_fops,
};
static struct miscdevice prng_tdes_dev = {
	.name	= "prandom",
	.minor	= MISC_DYNAMIC_MINOR,
	.mode	= 0644,
	.fops	= &prng_tdes_fops,
};


/* chunksize attribute (ro) */
static ssize_t prng_chunksize_show(struct device *dev,
				   struct device_attribute *attr,
@@ -801,18 +787,30 @@ static struct attribute *prng_sha512_dev_attrs[] = {
	&dev_attr_strength.attr,
	NULL
};
ATTRIBUTE_GROUPS(prng_sha512_dev);

static struct attribute *prng_tdes_dev_attrs[] = {
	&dev_attr_chunksize.attr,
	&dev_attr_byte_counter.attr,
	&dev_attr_mode.attr,
	NULL
};
ATTRIBUTE_GROUPS(prng_tdes_dev);

static struct attribute_group prng_sha512_dev_attr_group = {
	.attrs = prng_sha512_dev_attrs
static struct miscdevice prng_sha512_dev = {
	.name	= "prandom",
	.minor	= MISC_DYNAMIC_MINOR,
	.mode	= 0644,
	.fops	= &prng_sha512_fops,
	.groups = prng_sha512_dev_groups,
};
static struct attribute_group prng_tdes_dev_attr_group = {
	.attrs = prng_tdes_dev_attrs

static struct miscdevice prng_tdes_dev = {
	.name	= "prandom",
	.minor	= MISC_DYNAMIC_MINOR,
	.mode	= 0644,
	.fops	= &prng_tdes_fops,
	.groups = prng_tdes_dev_groups,
};


@@ -867,13 +865,6 @@ static int __init prng_init(void)
			prng_sha512_deinstantiate();
			goto out;
		}
		ret = sysfs_create_group(&prng_sha512_dev.this_device->kobj,
					 &prng_sha512_dev_attr_group);
		if (ret) {
			misc_deregister(&prng_sha512_dev);
			prng_sha512_deinstantiate();
			goto out;
		}

	} else {

@@ -898,14 +889,6 @@ static int __init prng_init(void)
			prng_tdes_deinstantiate();
			goto out;
		}
		ret = sysfs_create_group(&prng_tdes_dev.this_device->kobj,
					 &prng_tdes_dev_attr_group);
		if (ret) {
			misc_deregister(&prng_tdes_dev);
			prng_tdes_deinstantiate();
			goto out;
		}

	}

out:
@@ -916,13 +899,9 @@ static int __init prng_init(void)
static void __exit prng_exit(void)
{
	if (prng_mode == PRNG_MODE_SHA512) {
		sysfs_remove_group(&prng_sha512_dev.this_device->kobj,
				   &prng_sha512_dev_attr_group);
		misc_deregister(&prng_sha512_dev);
		prng_sha512_deinstantiate();
	} else {
		sysfs_remove_group(&prng_tdes_dev.this_device->kobj,
				   &prng_tdes_dev_attr_group);
		misc_deregister(&prng_tdes_dev);
		prng_tdes_deinstantiate();
	}