diff mbox series

[v2,01/11] fsi: Add fsi-master class

Message ID 20191108051945.7109-2-joel@jms.id.au
State New
Headers show
Series fsi: Patches for 5.5 | expand

Commit Message

Joel Stanley Nov. 8, 2019, 5:19 a.m. UTC
From: Jeremy Kerr <jk@ozlabs.org>


This change adds a device class for FSI masters, allowing access under
/sys/class/fsi-master/, and easier udev rules.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

Signed-off-by: Joel Stanley <joel@jms.id.au>

---
 drivers/fsi/fsi-core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

-- 
2.24.0.rc1

Comments

Alistair Popple Nov. 8, 2019, 9:17 a.m. UTC | #1
Support for the new paths has been added to our user space tools as well so it 
shouldn't change anything there.

Acked-by: Alistair Popple <alistair@popple.id.au>


On Friday, 8 November 2019 4:19:35 PM AEDT Joel Stanley wrote:
> From: Jeremy Kerr <jk@ozlabs.org>

> 

> This change adds a device class for FSI masters, allowing access under

> /sys/class/fsi-master/, and easier udev rules.

> 

> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

> Signed-off-by: Joel Stanley <joel@jms.id.au>

> ---

>  drivers/fsi/fsi-core.c | 13 +++++++++++++

>  1 file changed, 13 insertions(+)

> 

> diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c

> index 1f76740f33b6..0861f6097b33 100644

> --- a/drivers/fsi/fsi-core.c

> +++ b/drivers/fsi/fsi-core.c

> @@ -1241,6 +1241,10 @@ static ssize_t master_break_store(struct device *dev,

>  

>  static DEVICE_ATTR(break, 0200, NULL, master_break_store);

>  

> +struct class fsi_master_class = {

> +	.name = "fsi-master",

> +};

> +

>  int fsi_master_register(struct fsi_master *master)

>  {

>  	int rc;

> @@ -1249,6 +1253,7 @@ int fsi_master_register(struct fsi_master *master)

>  	mutex_init(&master->scan_lock);

>  	master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);

>  	dev_set_name(&master->dev, "fsi%d", master->idx);

> +	master->dev.class = &fsi_master_class;

>  

>  	rc = device_register(&master->dev);

>  	if (rc) {

> @@ -1350,8 +1355,15 @@ static int __init fsi_init(void)

>  	rc = bus_register(&fsi_bus_type);

>  	if (rc)

>  		goto fail_bus;

> +

> +	rc = class_register(&fsi_master_class);

> +	if (rc)

> +		goto fail_class;

> +

>  	return 0;

>  

> + fail_class:

> +	bus_unregister(&fsi_bus_type);

>   fail_bus:

>  	unregister_chrdev_region(fsi_base_dev, FSI_CHAR_MAX_DEVICES);

>  	return rc;

> @@ -1360,6 +1372,7 @@ postcore_initcall(fsi_init);

>  

>  static void fsi_exit(void)

>  {

> +	class_unregister(&fsi_master_class);

>  	bus_unregister(&fsi_bus_type);

>  	unregister_chrdev_region(fsi_base_dev, FSI_CHAR_MAX_DEVICES);

>  	ida_destroy(&fsi_minor_ida);

>
diff mbox series

Patch

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 1f76740f33b6..0861f6097b33 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1241,6 +1241,10 @@  static ssize_t master_break_store(struct device *dev,
 
 static DEVICE_ATTR(break, 0200, NULL, master_break_store);
 
+struct class fsi_master_class = {
+	.name = "fsi-master",
+};
+
 int fsi_master_register(struct fsi_master *master)
 {
 	int rc;
@@ -1249,6 +1253,7 @@  int fsi_master_register(struct fsi_master *master)
 	mutex_init(&master->scan_lock);
 	master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
 	dev_set_name(&master->dev, "fsi%d", master->idx);
+	master->dev.class = &fsi_master_class;
 
 	rc = device_register(&master->dev);
 	if (rc) {
@@ -1350,8 +1355,15 @@  static int __init fsi_init(void)
 	rc = bus_register(&fsi_bus_type);
 	if (rc)
 		goto fail_bus;
+
+	rc = class_register(&fsi_master_class);
+	if (rc)
+		goto fail_class;
+
 	return 0;
 
+ fail_class:
+	bus_unregister(&fsi_bus_type);
  fail_bus:
 	unregister_chrdev_region(fsi_base_dev, FSI_CHAR_MAX_DEVICES);
 	return rc;
@@ -1360,6 +1372,7 @@  postcore_initcall(fsi_init);
 
 static void fsi_exit(void)
 {
+	class_unregister(&fsi_master_class);
 	bus_unregister(&fsi_bus_type);
 	unregister_chrdev_region(fsi_base_dev, FSI_CHAR_MAX_DEVICES);
 	ida_destroy(&fsi_minor_ida);