Skip to contentSkip to conversation

staging: comedi: introduce 'comedi_get_board' helper function

PATCH Superseded H Hartley Sweeten 2 participants 3 messages Apr 27, 2012 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: comedi: introduce 'comedi_get_board' helper function

This helper function is used to fetch the comedi_device board_ptr which is used during the attach to pass board specific information to the comedi drivers.

Cc Ian Abbott <[email protected]>
Cc Mori Hess <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---

With this helper removing all the 'this_board' defines in the drivers will be easier (and cleaner).

drivers/staging/comedi/comedidev.h +5 -0
index 300fd84..53a05dd 100644
@@ -235,6 +235,11 @@ struct comedi_device {
 	void (*close) (struct comedi_device *dev);
 };
 
+static inline const void *comedi_get_board(struct comedi_device *dev)
+{
+	return dev->board_ptr;
+}
+
 struct comedi_device_file_info {
 	struct comedi_device *device;
 	struct comedi_subdevice *read_subdevice;
maintainer
#1 lore raw
Quoted 19 lines · H Hartley Sweeten

This helper function is used to fetch the comedi_device board_ptr which is used during the attach to pass board specific information to the comedi drivers.

Cc Ian Abbott <[email protected]>
Cc Mori Hess <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---

With this helper removing all the 'this_board' defines in the drivers will be easier (and cleaner).

drivers/staging/comedi/comedidev.h +0 -0
index 300fd84..53a05dd 100644

drivers/staging/comedi/comedidev.h struct comedi_device { · line 241

Quoted 7 lines
drivers/staging/comedi/comedidev.h +4 -0
@@ -235,6 +235,11 @@ struct comedi_device {
 	void (*close) (struct comedi_device *dev);
 };
 
+static inline const void *comedi_get_board(struct comedi_device *dev)
+{
+	return dev->board_ptr;
+}

"traditionally" the *get* functions increment a reference count of the pointer it returns, which isn't happening here.

How about renaming this to just be comedi_board() instead?

thanks,

greg k-h

#2 lore raw
Quoted 23 lines · Greg KH
Quoted 22 lines · H Hartley Sweeten

This helper function is used to fetch the comedi_device board_ptr which is used during the attach to pass board specific information to the comedi drivers.

Cc Ian Abbott <[email protected]>
Cc Mori Hess <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---

With this helper removing all the 'this_board' defines in the drivers will be easier (and cleaner).

drivers/staging/comedi/comedidev.h +0 -0
index 300fd84..53a05dd 100644
@@ -235,6 +235,11 @@ struct comedi_device {
 	void (*close) (struct comedi_device *dev);
 };
 
Quoted 7 lines

drivers/staging/comedi/comedidev.h struct comedi_device { · line 241

Quoted 4 lines
drivers/staging/comedi/comedidev.h +4 -0
+static inline const void *comedi_get_board(struct comedi_device *dev)
+{
+	return dev->board_ptr;
+}

"traditionally" the *get* functions increment a reference count of the pointer it returns, which isn't happening here.

I was trying to model it after dev_get_drvdata. But I see what you mean.

Quoted 1 line

How about renaming this to just be comedi_board() instead?

Or comedi_board_ptr... Either one works for me but I do like the shorter name you suggested.

I'll post an updated patch shortly using the comedi_board name.

Regards,
Hartley