* [PATCH] fs/ncpfs: Convert timers to use timer_setup()
@ 2017-10-05 0:52 Kees Cook
2017-10-10 11:22 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2017-10-05 0:52 UTC (permalink / raw)
To: linux-kernel
Cc: Petr Vandrovec, Jan Kara, Jens Axboe, Al Viro, Thomas Gleixner
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.
Cc: Petr Vandrovec <petr@vandrovec.name>
Cc: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@fb.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
fs/ncpfs/inode.c | 4 +---
fs/ncpfs/ncp_fs_sb.h | 2 +-
fs/ncpfs/sock.c | 6 +++---
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 6d0f14c86099..129f1937fa2c 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -618,7 +618,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
server->tx.creq = NULL;
server->rcv.creq = NULL;
- init_timer(&server->timeout_tm);
+ timer_setup(&server->timeout_tm, ncpdgram_timeout_call, 0);
#undef NCP_PACKET_SIZE
#define NCP_PACKET_SIZE 131072
error = -ENOMEM;
@@ -650,8 +650,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
} else {
INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc);
INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc);
- server->timeout_tm.data = (unsigned long)server;
- server->timeout_tm.function = ncpdgram_timeout_call;
}
release_sock(sock->sk);
diff --git a/fs/ncpfs/ncp_fs_sb.h b/fs/ncpfs/ncp_fs_sb.h
index 366fd63cc506..2088d94ead93 100644
--- a/fs/ncpfs/ncp_fs_sb.h
+++ b/fs/ncpfs/ncp_fs_sb.h
@@ -149,7 +149,7 @@ extern void ncp_tcp_rcv_proc(struct work_struct *work);
extern void ncp_tcp_tx_proc(struct work_struct *work);
extern void ncpdgram_rcv_proc(struct work_struct *work);
extern void ncpdgram_timeout_proc(struct work_struct *work);
-extern void ncpdgram_timeout_call(unsigned long server);
+extern void ncpdgram_timeout_call(struct timer_list *t);
extern void ncp_tcp_data_ready(struct sock* sk);
extern void ncp_tcp_write_space(struct sock* sk);
extern void ncp_tcp_error_report(struct sock* sk);
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 98b6db0ed63e..56c45c78b0b8 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -116,10 +116,10 @@ void ncp_tcp_write_space(struct sock *sk)
schedule_work(&server->tx.tq);
}
-void ncpdgram_timeout_call(unsigned long v)
+void ncpdgram_timeout_call(struct timer_list *t)
{
- struct ncp_server *server = (void*)v;
-
+ struct ncp_server *server = from_timer(server, t, timeout_tm);
+
schedule_work(&server->timeout_tq);
}
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/ncpfs: Convert timers to use timer_setup()
2017-10-05 0:52 [PATCH] fs/ncpfs: Convert timers to use timer_setup() Kees Cook
@ 2017-10-10 11:22 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2017-10-10 11:22 UTC (permalink / raw)
To: Kees Cook
Cc: linux-kernel, Petr Vandrovec, Jan Kara, Jens Axboe, Al Viro,
Thomas Gleixner
On Wed 04-10-17 17:52:50, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
>
> Cc: Petr Vandrovec <petr@vandrovec.name>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Looks good to me. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> This requires commit 686fef928bba ("timer: Prepare to change timer
> callback argument type") in v4.14-rc3, but should be otherwise
> stand-alone.
> ---
> fs/ncpfs/inode.c | 4 +---
> fs/ncpfs/ncp_fs_sb.h | 2 +-
> fs/ncpfs/sock.c | 6 +++---
> 3 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
> index 6d0f14c86099..129f1937fa2c 100644
> --- a/fs/ncpfs/inode.c
> +++ b/fs/ncpfs/inode.c
> @@ -618,7 +618,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
> server->tx.creq = NULL;
> server->rcv.creq = NULL;
>
> - init_timer(&server->timeout_tm);
> + timer_setup(&server->timeout_tm, ncpdgram_timeout_call, 0);
> #undef NCP_PACKET_SIZE
> #define NCP_PACKET_SIZE 131072
> error = -ENOMEM;
> @@ -650,8 +650,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
> } else {
> INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc);
> INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc);
> - server->timeout_tm.data = (unsigned long)server;
> - server->timeout_tm.function = ncpdgram_timeout_call;
> }
> release_sock(sock->sk);
>
> diff --git a/fs/ncpfs/ncp_fs_sb.h b/fs/ncpfs/ncp_fs_sb.h
> index 366fd63cc506..2088d94ead93 100644
> --- a/fs/ncpfs/ncp_fs_sb.h
> +++ b/fs/ncpfs/ncp_fs_sb.h
> @@ -149,7 +149,7 @@ extern void ncp_tcp_rcv_proc(struct work_struct *work);
> extern void ncp_tcp_tx_proc(struct work_struct *work);
> extern void ncpdgram_rcv_proc(struct work_struct *work);
> extern void ncpdgram_timeout_proc(struct work_struct *work);
> -extern void ncpdgram_timeout_call(unsigned long server);
> +extern void ncpdgram_timeout_call(struct timer_list *t);
> extern void ncp_tcp_data_ready(struct sock* sk);
> extern void ncp_tcp_write_space(struct sock* sk);
> extern void ncp_tcp_error_report(struct sock* sk);
> diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
> index 98b6db0ed63e..56c45c78b0b8 100644
> --- a/fs/ncpfs/sock.c
> +++ b/fs/ncpfs/sock.c
> @@ -116,10 +116,10 @@ void ncp_tcp_write_space(struct sock *sk)
> schedule_work(&server->tx.tq);
> }
>
> -void ncpdgram_timeout_call(unsigned long v)
> +void ncpdgram_timeout_call(struct timer_list *t)
> {
> - struct ncp_server *server = (void*)v;
> -
> + struct ncp_server *server = from_timer(server, t, timeout_tm);
> +
> schedule_work(&server->timeout_tq);
> }
>
> --
> 2.7.4
>
>
> --
> Kees Cook
> Pixel Security
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-10 11:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-05 0:52 [PATCH] fs/ncpfs: Convert timers to use timer_setup() Kees Cook
2017-10-10 11:22 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox