linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: comedi: introduce 'comedi_get_board' helper function
@ 2012-04-27 18:49 H Hartley Sweeten
  2012-04-27 19:29 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: H Hartley Sweeten @ 2012-04-27 18:49 UTC (permalink / raw)
  To: Linux Kernel; +Cc: devel, abbotti, fmhess, gregkh

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.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---

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

diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 300fd84..53a05dd 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: comedi: introduce 'comedi_get_board' helper function
  2012-04-27 18:49 [PATCH] staging: comedi: introduce 'comedi_get_board' helper function H Hartley Sweeten
@ 2012-04-27 19:29 ` Greg KH
  2012-04-27 20:13   ` H Hartley Sweeten
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2012-04-27 19:29 UTC (permalink / raw)
  To: H Hartley Sweeten; +Cc: Linux Kernel, devel, fmhess, abbotti

On Fri, Apr 27, 2012 at 11:49:48AM -0700, H Hartley Sweeten wrote:
> 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.
> 
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: Mori Hess <fmhess@users.sourceforge.net>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> ---
> 
> With this helper removing all the 'this_board' defines in the drivers
> will be easier (and cleaner).
> 
> diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
> index 300fd84..53a05dd 100644
> --- a/drivers/staging/comedi/comedidev.h
> +++ b/drivers/staging/comedi/comedidev.h
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] staging: comedi: introduce 'comedi_get_board' helper function
  2012-04-27 19:29 ` Greg KH
@ 2012-04-27 20:13   ` H Hartley Sweeten
  0 siblings, 0 replies; 3+ messages in thread
From: H Hartley Sweeten @ 2012-04-27 20:13 UTC (permalink / raw)
  To: Greg KH; +Cc: Linux Kernel, devel, fmhess, abbotti

On Friday, April 27, 2012 12:29 PM, Greg KH wrote:
> On Fri, Apr 27, 2012 at 11:49:48AM -0700, H Hartley Sweeten wrote:
>> 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.
>> 
>> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
>> Cc: Ian Abbott <abbotti@mev.co.uk>
>> Cc: Mori Hess <fmhess@users.sourceforge.net>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> 
>> ---
>> 
>> With this helper removing all the 'this_board' defines in the drivers
>> will be easier (and cleaner).
>> 
>> diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
>> index 300fd84..53a05dd 100644
>> --- a/drivers/staging/comedi/comedidev.h
>> +++ b/drivers/staging/comedi/comedidev.h
>> @@ -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.

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

> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-27 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27 18:49 [PATCH] staging: comedi: introduce 'comedi_get_board' helper function H Hartley Sweeten
2012-04-27 19:29 ` Greg KH
2012-04-27 20:13   ` H Hartley Sweeten

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).