Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1659211

[PATCH v8 11/24] drivers/fsi: Add master unscan

From Christopher Bostic <cbostic@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH v8 11/24] drivers/fsi: Add master unscan
Date 2017-06-06 23:10 +0200
Message-ID <tPtTI-5H7-15@gated-at.bofh.it> (permalink)
References <tPtTH-5H7-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Allow a master to undo a previous scan.  Should a master scan a bus
twice it will need to ensure it doesn't double register any
previously detected device.

Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
----
v7 - Unscan when unregistering master
   - Remove leading '__'s from function names
   - Return fail state for sysfs rescan file
---
 drivers/fsi/fsi-core.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index d7a6e76..fcb0c81 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -71,6 +71,7 @@ struct fsi_slave {
 	uint32_t		size;	/* size of slave address space */
 };
 
+#define to_fsi_master(d) container_of(d, struct fsi_master, dev)
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
 static int fsi_master_read(struct fsi_master *master, int link,
@@ -488,6 +489,40 @@ static int fsi_master_scan(struct fsi_master *master)
 	return 0;
 }
 
+static int fsi_slave_remove_device(struct device *dev, void *arg)
+{
+	device_unregister(dev);
+	return 0;
+}
+
+static int fsi_master_remove_slave(struct device *dev, void *arg)
+{
+	device_for_each_child(dev, NULL, fsi_slave_remove_device);
+	device_unregister(dev);
+	return 0;
+}
+
+static void fsi_master_unscan(struct fsi_master *master)
+{
+	device_for_each_child(&master->dev, NULL, fsi_master_remove_slave);
+}
+
+static ssize_t master_rescan_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct fsi_master *master = to_fsi_master(dev);
+	int rc;
+
+	fsi_master_unscan(master);
+	rc = fsi_master_scan(master);
+	if (rc < 0)
+		return rc;
+
+	return count;
+}
+
+static DEVICE_ATTR(rescan, 0200, NULL, master_rescan_store);
+
 int fsi_master_register(struct fsi_master *master)
 {
 	int rc;
@@ -504,7 +539,15 @@ int fsi_master_register(struct fsi_master *master)
 		return rc;
 	}
 
+	rc = device_create_file(&master->dev, &dev_attr_rescan);
+	if (rc) {
+		device_unregister(&master->dev);
+		ida_simple_remove(&master_ida, master->idx);
+		return rc;
+	}
+
 	fsi_master_scan(master);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(fsi_master_register);
@@ -516,6 +559,7 @@ void fsi_master_unregister(struct fsi_master *master)
 		master->idx = -1;
 	}
 
+	fsi_master_unscan(master);
 	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
-- 
1.8.2.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v8 00/24] FSI device driver implementation Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:10 +0200
  [PATCH v8 06/24] drivers/fsi: Set up links for slave communication Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:10 +0200
  [PATCH v8 01/24] drivers/fsi: Add fsi master definition Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:10 +0200
  [PATCH v8 11/24] drivers/fsi: Add master unscan Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:10 +0200
  [PATCH v8 05/24] drivers/fsi: Add slave & master read/write APIs Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:10 +0200
  [PATCH v8 04/24] lib: Add crc4 module Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:10 +0200
  [PATCH v8 12/24] drivers/fsi: Add documentation for GPIO bindings Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 24/24] drivers/fsi: Add module license to core driver Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 19/24] drivers/fsi: Add GPIO based FSI master Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 14/24] drivers/fsi: Add sysfs files for FSI master & slave accesses Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 20/24] drivers/fsi/gpio: Add tracepoints for GPIO master Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 22/24] drivers/fsi: Add hub master support Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 17/24] drivers/fsi: Add error handling for slave Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 16/24] drivers/fsi: Add tracepoints for low-level operations Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 10/24] drivers/fsi: Add device read/write/peek API Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 21/24] drivers/fsi: Add SCOM FSI client device driver Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 18/24] drivers/fsi: Document FSI master sysfs files in ABI Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 08/24] drivers/fsi: Set slave SMODE to init communication Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 15/24] drivers/fsi: expose direct-access slave API Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 07/24] drivers/fsi: Implement slave initialisation Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 02/24] drivers/fsi: Add slave definition Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 13/24] drivers/fsi: Add client driver register utilities Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 23/24] drivers/fsi: Use asynchronous slave mode Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 03/24] drivers/fsi: Add empty master scan Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200
  [PATCH v8 09/24] drivers/fsi: scan slaves & register devices Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-06-06 23:20 +0200

csiph-web