From da2ff527e44bf3af851c1e5d9ac82d248df35417 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Mon, 16 Mar 2015 20:17:13 +0100 Subject: char: constify of_device_id array of_device_id is always used as const. (See driver.of_match_table and open firmware functions) Signed-off-by: Fabian Frederick Signed-off-by: Greg Kroah-Hartman --- drivers/char/hw_random/pasemi-rng.c | 2 +- drivers/char/hw_random/powernv-rng.c | 2 +- drivers/char/hw_random/ppc4xx-rng.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/char/hw_random') diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c index 3eb7bdd7f93b..51cb1d5cc489 100644 --- a/drivers/char/hw_random/pasemi-rng.c +++ b/drivers/char/hw_random/pasemi-rng.c @@ -133,7 +133,7 @@ static int rng_remove(struct platform_device *dev) return 0; } -static struct of_device_id rng_match[] = { +static const struct of_device_id rng_match[] = { { .compatible = "1682m-rng", }, { .compatible = "pasemi,pwrficient-rng", }, { }, diff --git a/drivers/char/hw_random/powernv-rng.c b/drivers/char/hw_random/powernv-rng.c index 3f4f63204560..263a5bb8e605 100644 --- a/drivers/char/hw_random/powernv-rng.c +++ b/drivers/char/hw_random/powernv-rng.c @@ -61,7 +61,7 @@ static int powernv_rng_probe(struct platform_device *pdev) return 0; } -static struct of_device_id powernv_rng_match[] = { +static const struct of_device_id powernv_rng_match[] = { { .compatible = "ibm,power-rng",}, {}, }; diff --git a/drivers/char/hw_random/ppc4xx-rng.c b/drivers/char/hw_random/ppc4xx-rng.c index c85d31a5f9e3..b2cfda0fa93e 100644 --- a/drivers/char/hw_random/ppc4xx-rng.c +++ b/drivers/char/hw_random/ppc4xx-rng.c @@ -123,7 +123,7 @@ static int ppc4xx_rng_remove(struct platform_device *dev) return 0; } -static struct of_device_id ppc4xx_rng_match[] = { +static const struct of_device_id ppc4xx_rng_match[] = { { .compatible = "ppc4xx-rng", }, { .compatible = "amcc,ppc460ex-rng", }, { .compatible = "amcc,ppc440epx-rng", }, -- cgit 1.4.1 From 0daa7a0afd0fa7aad83cbde0fb341d7fbeac952c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 2 Feb 2015 15:44:55 +0100 Subject: hwrng: Avoid manual device_create_file() calls Use the new group field of struct miscdevice for managing the sysfs entries instead of manually adding/removing via device_create_file() and device_remove_file(). This simplifies the code a lot and fixes the possible races. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- drivers/char/hw_random/core.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'drivers/char/hw_random') diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 32a8a867f7f8..0a8194525baf 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -299,11 +299,14 @@ static const struct file_operations rng_chrdev_ops = { .llseek = noop_llseek, }; +static const struct attribute_group *rng_dev_groups[]; + static struct miscdevice rng_miscdev = { .minor = RNG_MISCDEV_MINOR, .name = RNG_MODULE_NAME, .nodename = "hwrng", .fops = &rng_chrdev_ops, + .groups = rng_dev_groups, }; @@ -376,37 +379,22 @@ static DEVICE_ATTR(rng_available, S_IRUGO, hwrng_attr_available_show, NULL); +static struct attribute *rng_dev_attrs[] = { + &dev_attr_rng_current.attr, + &dev_attr_rng_available.attr, + NULL +}; + +ATTRIBUTE_GROUPS(rng_dev); static void __exit unregister_miscdev(void) { - device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); - device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); misc_deregister(&rng_miscdev); } static int __init register_miscdev(void) { - int err; - - err = misc_register(&rng_miscdev); - if (err) - goto out; - err = device_create_file(rng_miscdev.this_device, - &dev_attr_rng_current); - if (err) - goto err_misc_dereg; - err = device_create_file(rng_miscdev.this_device, - &dev_attr_rng_available); - if (err) - goto err_remove_current; -out: - return err; - -err_remove_current: - device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); -err_misc_dereg: - misc_deregister(&rng_miscdev); - goto out; + return misc_register(&rng_miscdev); } static int hwrng_fillfn(void *unused) -- cgit 1.4.1