From patchwork Sun May 15 14:07:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Falak R Wani X-Patchwork-Id: 622391 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3r756L30Xlz9snm for ; Mon, 16 May 2016 00:08:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mjgCvXiI; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752220AbcEOOH6 (ORCPT ); Sun, 15 May 2016 10:07:58 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34543 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbcEOOH5 (ORCPT ); Sun, 15 May 2016 10:07:57 -0400 Received: by mail-pf0-f193.google.com with SMTP id 145so13422521pfz.1; Sun, 15 May 2016 07:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=96jAcod/e1lpRWj5qt+YYU04Bo4L+Jot+0RXyteWiWc=; b=mjgCvXiIxoRFQQtxNyppbps9dwgjUN6KoxyNgsNRdLUUPhh8sgIrqNPaLGmRUGT6ZB DyE0jfTta7MUrFaTnFBdJCw+QY4NReujOeR+Dk8KyvvbQz517gFGk4UP/yZcnWI7W13R DPhxL3oO0FUq9icKnL4FUsnl1BA4fa4B/4LijxqSB5dUuHT6Km/TeL2vCosChJJ3c9lR iCVj5zT8NGFxjNe+s0aryCP+y73ZkXXdpoX9lVR52Y5DRlqvHM4E3+/tHEavoca7JpWp ruBbDiRT4u/LGQN3gWM6LuCkd7W6J1CqPCh7Zm9azqxjPZjUOiEZ9mTG7qFIXnPddOdq CVSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=96jAcod/e1lpRWj5qt+YYU04Bo4L+Jot+0RXyteWiWc=; b=FCURhzyg/4Bnx79OTegGLlDaJizNLCz4rj7+gRNuAS+nsBKalYsRkLhl+2xoBgjA/g HxE6/0ARpuWQKnrNf8PNj3rA8fCdxch0NEDpMfz0Uo2FQj+1XjXH2hFDi0vJZq9FPe3E KBE9GcrAeqFuQNicvxICCn3dDfYaeXZki0Mxg4EXxhM+ha6RSQOlTqyTuyQtntGSACeV qznGwjtrK4yOLHKOGqqy0fFa6mkgEi2tsl/l2XgmLyXpK8w6miuuKXqQO+C4BBCwCNjn c1gYQ74MtO9ZptIisZNW4PxNe1KUHBPgygWBypqDtmnGTH//pz8iR2a09ilaBwQyKFL0 HyOA== X-Gm-Message-State: AOPr4FWoxkHMuxFvMx3U18liz/vWPRI5H1inLyiyuvTZ+cL1I9GIfy/sM0xexSsunM4GYQ== X-Received: by 10.98.28.65 with SMTP id c62mr38170947pfc.61.1463321276294; Sun, 15 May 2016 07:07:56 -0700 (PDT) Received: from kp.domain.name ([110.235.28.83]) by smtp.gmail.com with ESMTPSA id y2sm40789080pfi.39.2016.05.15.07.07.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 May 2016 07:07:55 -0700 (PDT) From: Muhammad Falak R Wani To: David Miller Cc: Arvid Brodin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/hsr: Use setup_timer and mod_timer. Date: Sun, 15 May 2016 19:37:44 +0530 Message-Id: <1463321265-11577-1-git-send-email-falakreyaz@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The function setup_timer combines the initialization of a timer with the initialization of the timer's function and data fields. The mulitiline code for timer initialization is now replaced with function setup_timer. Also, quoting the mod_timer() function comment: -> mod_timer() is a more efficient way to update the expire field of an active timer (if the timer is inactive it will be activated). Use setup_timer() and mod_timer() to setup and arm a timer, making the code compact and aid readablity. Signed-off-by: Muhammad Falak R Wani --- net/hsr/hsr_device.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 386cbce..16737cd 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -461,13 +461,9 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], hsr->sequence_nr = HSR_SEQNR_START; hsr->sup_sequence_nr = HSR_SUP_SEQNR_START; - init_timer(&hsr->announce_timer); - hsr->announce_timer.function = hsr_announce; - hsr->announce_timer.data = (unsigned long) hsr; + setup_timer(&hsr->announce_timer, hsr_announce, (unsigned long)hsr); - init_timer(&hsr->prune_timer); - hsr->prune_timer.function = hsr_prune_nodes; - hsr->prune_timer.data = (unsigned long) hsr; + setup_timer(&hsr->prune_timer, hsr_prune_nodes, (unsigned long)hsr); ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr); hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; @@ -502,8 +498,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], if (res) goto fail; - hsr->prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD); - add_timer(&hsr->prune_timer); + mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD)); return 0;