From patchwork Fri Dec 1 10:47:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17166 X-Patchwork-Delegate: sven@narfation.org Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id BA28980961; Fri, 1 Dec 2017 11:48:25 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="CYJGtM1E"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 04C33803A4 for ; Fri, 1 Dec 2017 11:48:19 +0100 (CET) Received: from sven-desktop.home.narfation.org (p2003007C6F651FFE000000000000070D.dip0.t-ipconnect.de [IPv6:2003:7c:6f65:1ffe::70d]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 7D3A91100D4; Fri, 1 Dec 2017 11:48:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1512125296; bh=86OuW4pFqqK0IuOkBpIVPjEjAPfF6uzt6c/XpGUeubY=; h=From:To:Cc:Subject:Date:From; b=CYJGtM1E8xgYWINPIzeHi4mj/X0UmJSWK2K5bK/ppit6AzheUHIv4CBVKu04VR+cr e4tV2EhTP1AFCB0wdhz1OP5oCK0Npaw9tzmZkVW0eaYq18qAXlcvIEVIgHcq6nn5Ya ZfRlkHPmIi4xSeNRO8tpSJPmkd1Wr4odCl49KVpQ= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 1 Dec 2017 11:47:55 +0100 Message-Id: <20171201104756.4476-1-sven@narfation.org> X-Mailer: git-send-email 2.11.0 Subject: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: setup_timer() -> timer_setup() X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Kees Cook This converts all remaining cases of the old setup_timer() API into using timer_setup(), where the callback argument is the structure already holding the struct timer_list. These should have no behavioral changes, since they just change which pointer is passed into the callback with the same available pointers after conversion. Signed-off-by: Kees Cook [sven@narfation.org: removed spatch and examples, added compat code] Signed-off-by: Sven Eckelmann --- compat-include/linux/timer.h | 59 ++++++++++++++++++++++++++++++++++++++++++++ net/batman-adv/tp_meter.c | 14 +++++------ 2 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 compat-include/linux/timer.h diff --git a/compat-include/linux/timer.h b/compat-include/linux/timer.h new file mode 100644 index 0000000..750b6ae --- /dev/null +++ b/compat-include/linux/timer.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * License-Filename: LICENSES/preferred/GPL-2.0 + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_TIMER_H +#define _NET_BATMAN_ADV_COMPAT_LINUX_TIMER_H + +#include +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) + +#define __setup_timer(_timer, _fn, _data, _flags) \ + do { \ + init_timer(_timer); \ + (_timer)->function = (_fn); \ + (_timer)->data = (_data); \ + } while (0) + +#endif /* < KERNEL_VERSION(3, 7, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) + +#define TIMER_DATA_TYPE unsigned long +#define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE) + +static inline void timer_setup(struct timer_list *timer, + void (*callback)(struct timer_list *), + unsigned int flags) +{ + __setup_timer(timer, (TIMER_FUNC_TYPE)callback, + (TIMER_DATA_TYPE)timer, flags); +} + +#define from_timer(var, callback_timer, timer_fieldname) \ + container_of(callback_timer, typeof(*var), timer_fieldname) + +#endif /* < KERNEL_VERSION(4, 14, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_TIMER_H */ diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index 4b90033..15cd213 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -488,9 +488,9 @@ static void batadv_tp_reset_sender_timer(struct batadv_tp_vars *tp_vars) * Switch to Slow Start, set the ss_threshold to half of the current cwnd and * reset the cwnd to 3*MSS */ -static void batadv_tp_sender_timeout(unsigned long arg) +static void batadv_tp_sender_timeout(struct timer_list *t) { - struct batadv_tp_vars *tp_vars = (struct batadv_tp_vars *)arg; + struct batadv_tp_vars *tp_vars = from_timer(tp_vars, t, timer); struct batadv_priv *bat_priv = tp_vars->bat_priv; if (atomic_read(&tp_vars->sending) == 0) @@ -1020,8 +1020,7 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst, atomic64_set(&tp_vars->tot_sent, 0); kref_get(&tp_vars->refcount); - setup_timer(&tp_vars->timer, batadv_tp_sender_timeout, - (unsigned long)tp_vars); + timer_setup(&tp_vars->timer, batadv_tp_sender_timeout, 0); tp_vars->bat_priv = bat_priv; tp_vars->start_time = jiffies; @@ -1109,9 +1108,9 @@ static void batadv_tp_reset_receiver_timer(struct batadv_tp_vars *tp_vars) * reached without received ack * @arg: address of the related tp_vars */ -static void batadv_tp_receiver_shutdown(unsigned long arg) +static void batadv_tp_receiver_shutdown(struct timer_list *t) { - struct batadv_tp_vars *tp_vars = (struct batadv_tp_vars *)arg; + struct batadv_tp_vars *tp_vars = from_timer(tp_vars, t, timer); struct batadv_tp_unacked *un, *safe; struct batadv_priv *bat_priv; @@ -1373,8 +1372,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list); kref_get(&tp_vars->refcount); - setup_timer(&tp_vars->timer, batadv_tp_receiver_shutdown, - (unsigned long)tp_vars); + timer_setup(&tp_vars->timer, batadv_tp_receiver_shutdown, 0); batadv_tp_reset_receiver_timer(tp_vars); From patchwork Fri Dec 1 10:47:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17167 X-Patchwork-Delegate: sven@narfation.org Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 8950D80CF6; Fri, 1 Dec 2017 11:48:33 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="CKrb/2aC"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id 7A74B8072B for ; Fri, 1 Dec 2017 11:48:25 +0100 (CET) Received: from sven-desktop.home.narfation.org (p2003007C6F651FFE000000000000070D.dip0.t-ipconnect.de [IPv6:2003:7c:6f65:1ffe::70d]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 1BBFB1100D7; Fri, 1 Dec 2017 11:48:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1512125303; bh=2R+WkvLIzvefgXC69/4RQZjfgNZdaz3JpgSxGSeXJtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CKrb/2aC3v7SAST9OEQp4u+6fYfzjemN6G2+/9vlCLDAALC757aAViLsb0lexlBaj LRhlPY88Fk5N2LC3aVWgr3T38WlhKx9q9wwChGTk9x/eCrctAPkm9fm0CDZKMmhP17 YYDYHTMUVtq6f5oZPzlTg3ucE20FoxcfyjX/BP5c= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 1 Dec 2017 11:47:56 +0100 Message-Id: <20171201104756.4476-2-sven@narfation.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171201104756.4476-1-sven@narfation.org> References: <20171201104756.4476-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Fix kernel-doc for timer functions X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Kees Cook Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" The commit e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()") changed the argument name and type of the timer function but didn't adjust the kernel-doc of these functions. Signed-off-by: Sven Eckelmann Acked-by: Kees Cook --- Cc: Kees Cook --- net/batman-adv/tp_meter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index 15cd213..ebc4e22 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -482,7 +482,7 @@ static void batadv_tp_reset_sender_timer(struct batadv_tp_vars *tp_vars) /** * batadv_tp_sender_timeout - timer that fires in case of packet loss - * @arg: address of the related tp_vars + * @t: address to timer_list inside tp_vars * * If fired it means that there was packet loss. * Switch to Slow Start, set the ss_threshold to half of the current cwnd and @@ -1106,7 +1106,7 @@ static void batadv_tp_reset_receiver_timer(struct batadv_tp_vars *tp_vars) /** * batadv_tp_receiver_shutdown - stop a tp meter receiver when timeout is * reached without received ack - * @arg: address of the related tp_vars + * @t: address to timer_list inside tp_vars */ static void batadv_tp_receiver_shutdown(struct timer_list *t) {