diff mbox

[1/2] btrfs: Cleanup the btrfs_workqueue related function type

Message ID 1394079657-24937-1-git-send-email-quwenruo@cn.fujitsu.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Qu Wenruo March 6, 2014, 4:19 a.m. UTC
The new btrfs_workqueue still use open-coded function defition,
this patch will change them into btrfs_func_t type which is much the
same as kernel workqueue.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 fs/btrfs/async-thread.c |  6 +++---
 fs/btrfs/async-thread.h | 20 +++++++++++---------
 2 files changed, 14 insertions(+), 12 deletions(-)

Comments

David Sterba March 14, 2014, 2:39 p.m. UTC | #1
On Thu, Mar 06, 2014 at 04:19:50AM +0000, quwenruo@cn.fujitsu.com wrote:
> @@ -23,11 +23,13 @@
>  struct btrfs_workqueue;
>  /* Internal use only */
>  struct __btrfs_workqueue;
> +struct btrfs_work;
> +typedef void (*btrfs_func_t)(struct btrfs_work *arg);

I don't see what's wrong with the non-typedef type, CodingStyle
discourages from using typedefs in general (Chapter 5).

The name btrfs_func_t is a generic, if you really need to use a typedef
here, please change it to something closer to the workqueues, eg.
btrfs_work_func_t.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Qu Wenruo March 16, 2014, 12:41 a.m. UTC | #2
On Fri, 14 Mar 2014 15:39:03 +0100, David Sterba wrote:
> On Thu, Mar 06, 2014 at 04:19:50AM +0000, quwenruo@cn.fujitsu.com wrote:

>> @@ -23,11 +23,13 @@

>>   struct btrfs_workqueue;

>>   /* Internal use only */

>>   struct __btrfs_workqueue;

>> +struct btrfs_work;

>> +typedef void (*btrfs_func_t)(struct btrfs_work *arg);

> I don't see what's wrong with the non-typedef type, CodingStyle

> discourages from using typedefs in general (Chapter 5).

>

> The name btrfs_func_t is a generic, if you really need to use a typedef

> here, please change it to something closer to the workqueues, eg.

> btrfs_work_func_t.

>

btrfs_func_t is just following the work_func_t naming style,
for btrfs it's only used to reduce the length of prototype definition.

Since btrfs_func_t is only used in btrfs, this patch can be ignored.

Thanks
Qu
David Sterba March 17, 2014, 11:58 a.m. UTC | #3
On Sun, Mar 16, 2014 at 12:41:17AM +0000, quwenruo@cn.fujitsu.com wrote:
> On Fri, 14 Mar 2014 15:39:03 +0100, David Sterba wrote:
> > On Thu, Mar 06, 2014 at 04:19:50AM +0000, quwenruo@cn.fujitsu.com wrote:
> >> @@ -23,11 +23,13 @@
> >>   struct btrfs_workqueue;
> >>   /* Internal use only */
> >>   struct __btrfs_workqueue;
> >> +struct btrfs_work;
> >> +typedef void (*btrfs_func_t)(struct btrfs_work *arg);
> > I don't see what's wrong with the non-typedef type, CodingStyle
> > discourages from using typedefs in general (Chapter 5).
> >
> > The name btrfs_func_t is a generic, if you really need to use a typedef
> > here, please change it to something closer to the workqueues, eg.
> > btrfs_work_func_t.
> >
> btrfs_func_t is just following the work_func_t naming style,
> for btrfs it's only used to reduce the length of prototype definition.
> 
> Since btrfs_func_t is only used in btrfs, this patch can be ignored.

Thanks for considerations.  In case of the generic workqueues interface
it makes sense to provide a shortcut to the callback definition because
it appears in many structures.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index a709585..d8c07e5 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -255,9 +255,9 @@  static void normal_work_helper(struct work_struct *arg)
 }
 
 void btrfs_init_work(struct btrfs_work *work,
-		     void (*func)(struct btrfs_work *),
-		     void (*ordered_func)(struct btrfs_work *),
-		     void (*ordered_free)(struct btrfs_work *))
+		     btrfs_func_t func,
+		     btrfs_func_t ordered_func,
+		     btrfs_func_t ordered_free)
 {
 	work->func = func;
 	work->ordered_func = ordered_func;
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index 08d7174..0a891cd 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -23,11 +23,13 @@ 
 struct btrfs_workqueue;
 /* Internal use only */
 struct __btrfs_workqueue;
+struct btrfs_work;
+typedef void (*btrfs_func_t)(struct btrfs_work *arg);
 
 struct btrfs_work {
-	void (*func)(struct btrfs_work *arg);
-	void (*ordered_func)(struct btrfs_work *arg);
-	void (*ordered_free)(struct btrfs_work *arg);
+	btrfs_func_t func;
+	btrfs_func_t ordered_func;
+	btrfs_func_t ordered_free;
 
 	/* Don't touch things below */
 	struct work_struct normal_work;
@@ -37,13 +39,13 @@  struct btrfs_work {
 };
 
 struct btrfs_workqueue *btrfs_alloc_workqueue(char *name,
-						     int flags,
-						     int max_active,
-						     int thresh);
+					      int flags,
+					      int max_active,
+					      int thresh);
 void btrfs_init_work(struct btrfs_work *work,
-		     void (*func)(struct btrfs_work *),
-		     void (*ordered_func)(struct btrfs_work *),
-		     void (*ordered_free)(struct btrfs_work *));
+		     btrfs_func_t func,
+		     btrfs_func_t ordered_func,
+		     btrfs_func_t ordered_free);
 void btrfs_queue_work(struct btrfs_workqueue *wq,
 		      struct btrfs_work *work);
 void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);