History

HSI: hsi: Rework hsi_event interface

Remove custom hack and make use of the notifier chain interfaces for delivering events from the ports to their associated clients. Clients that want to receive port events need to register their callbacks using hsi_register_port_event(). The callbacks can be called in interrupt context. Use hsi_unregestier_port_event() to undo the registration.

Carlos Chinea committed 14 years ago

Commit ec1c56f1 parent 6f02b9e2 files · +68 −58Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/hsi/hsi.h+14−11
@@ -26,9 +26,9 @@ · 25 unmodified lines
2626 #include <linux/device.h>
2727 #include <linux/mutex.h>
2828 #include <linux/scatterlist.h>
29−#include <linux/spinlock.h>
3029 #include <linux/list.h>
3130 #include <linux/module.h>
31+#include <linux/notifier.h>
3232
3333 /* HSI message ttype */
3434 #define HSI_MSG_READ 0
@@ -121,18 +121,18 @@ static inline int hsi_register_board_info(struct hsi_board_info const *info, · 86 unmodified lines
121121 * @device: Driver model representation of the device
122122 * @tx_cfg: HSI TX configuration
123123 * @rx_cfg: HSI RX configuration
124− * @hsi_start_rx: Called after incoming wake line goes high
125− * @hsi_stop_rx: Called after incoming wake line goes low
124+ * @e_handler: Callback for handling port events (RX Wake High/Low)
125+ * @pclaimed: Keeps tracks if the clients claimed its associated HSI port
126+ * @nb: Notifier block for port events
126127 */
127128 struct hsi_client {
128129 struct device device;
129130 struct hsi_config tx_cfg;
130131 struct hsi_config rx_cfg;
131− void (*hsi_start_rx)(struct hsi_client *cl);
132− void (*hsi_stop_rx)(struct hsi_client *cl);
133132 /* private: */
133+ void (*ehandler)(struct hsi_client *, unsigned long);
134134 unsigned int pclaimed:1;
135− struct list_head link;
135+ struct notifier_block nb;
136136 };
137137
138138 #define to_hsi_client(dev) container_of(dev, struct hsi_client, device)
@@ -147,6 +147,10 @@ static inline void *hsi_client_drvdata(struct hsi_client *cl) · 8 unmodified lines
147147 return dev_get_drvdata(&cl->device);
148148 }
149149
150+int hsi_register_port_event(struct hsi_client *cl,
151+ void (*handler)(struct hsi_client *, unsigned long));
152+int hsi_unregister_port_event(struct hsi_client *cl);
153+
150154 /**
151155 * struct hsi_client_driver - Driver associated to an HSI client
152156 * @driver: Driver model representation of the driver
@@ -214,8 +218,7 @@ void hsi_free_msg(struct hsi_msg *msg); · 61 unmodified lines
214218 * @start_tx: Callback to inform that a client wants to TX data
215219 * @stop_tx: Callback to inform that a client no longer wishes to TX data
216220 * @release: Callback to inform that a client no longer uses the port
217− * @clients: List of hsi_clients using the port.
218− * @clock: Lock to serialize access to the clients list.
221+ * @n_head: Notifier chain for signaling port events to the clients.
219222 */
220223 struct hsi_port {
221224 struct device device;
@@ -231,14 +234,14 @@ struct hsi_port { · 9 unmodified lines
231234 int (*start_tx)(struct hsi_client *cl);
232235 int (*stop_tx)(struct hsi_client *cl);
233236 int (*release)(struct hsi_client *cl);
234− struct list_head clients;
235− spinlock_t clock;
237+ /* private */
238+ struct atomic_notifier_head n_head;
236239 };
237240
238241 #define to_hsi_port(dev) container_of(dev, struct hsi_port, device)
239242 #define hsi_get_port(cl) to_hsi_port((cl)->device.parent)
240243
241−void hsi_event(struct hsi_port *port, unsigned int event);
244+int hsi_event(struct hsi_port *port, unsigned long event);
242245 int hsi_claim_port(struct hsi_client *cl, unsigned int share);
243246 void hsi_release_port(struct hsi_client *cl);
244247