From patchwork Tue Jun 7 09:47:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2016 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 293473F08A for ; Tue, 7 Jun 2022 11:48:17 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id j31-20020a05600c1c1f00b0039c481c4664sf1483091wms.7 for ; Tue, 07 Jun 2022 02:48:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595297; cv=pass; d=google.com; s=arc-20160816; b=jHkhT+QBRe7WTyUEMygp910noMeP/AWCdNWo0dl+EY8ZqQeIHrKjURndGPAghmv/Fe t2hf3afnFLl1TZcvHHFtwOowCtCQjp81quvz6gfMX0FdMzY+1igVwi5yHfclJKnvnktZ ZI2Ae/0ZT1k8vk+bNouWPQE6FNYrAt15ghcjMm1AWxlTHDyhyBDUaZnTu+Aw/L5wqjvA kh6vul95NmIopk6zM/jqdFwMaToe4i8penDUryBOV/9MkUz6qU3qTnYFXV4hC08jVwYB gkLHykst0jTxvlJSAVw/fM5+56TLjUx8ISe1pmyiKa/hLD/TGTXBc+xFqUeD1RIh0oxw mLSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=XHA7f4LCtbrNkNnN4dtjW5H/4bu5CeCPdCr7gwLpDxc=; b=cM3EoPcNczRKFI/RB5HQ6sbWaeGFw9W9iraxi6l2FDQyR5rd7Bc6nEKyQDNaEurRMM D+oDJgM0WOviCcSRJ2GXxcuPZJedrgiz/QG2Kp1b7yWWh0RU9YzHyBepeSYUUNdM2NJA OvRH+v6JaMYmJqSQQIciilM2rIHWhmVLr1XE688JyzjyZj4YN53kRlJDIeeesZbNvLT3 8arkb4nZRZUMnV9EukuDJhzozEmFSbQO4k2h/0APpWHOQ8GSIiFz4MdXu3dJrSnQDbPx dV+j449q/GdlnDyR4M5J7oBJ5cNMneAw2d/TD5w6cx4YDMJgfbOYiia3bUWIhzoJiNpV NkNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fD6TXB5k; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=XHA7f4LCtbrNkNnN4dtjW5H/4bu5CeCPdCr7gwLpDxc=; b=QOVi/BMuXakOX3QLbMKqrwuLMigS6GYqJFbm9X/Pk23gWR80TSWV93cQvARUlQGou0 NGsAQ/BOCGMihaLjirR3alOxNIjb98cntaUAcoQZf9un7OLovL2Z1oYsgcYgHrcnAxQE ABHEU6msarIrd71dw8WbQNl5zB/LWEugLjB8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=XHA7f4LCtbrNkNnN4dtjW5H/4bu5CeCPdCr7gwLpDxc=; b=RCGIf5UTvR3JfWRFsqFEWge4CTFg8maOt8gPA4bQGdQnWq8Ds8L4mbWP6KkjQXrR1t ns9b26wGWVzrK73O49VggLOPLjXPUcbOqJEPjrDq7RzwbJwLk5c0dX74bBLjdAkhLFuZ LzTdI9aD2+LGZAWdHgL6hcCPX724Ri1oiSXbJv75tkpotCFuYQj+yZgrOb9DRFVEQuSU ItiFjBYssg6swxHBmUUwT2A2kf3TJejM1fm3HDx+zzNgFAKILZos+I+5vKaU7llsrHlT qQ0qSIhAW6dRcVoAq4TTRorojka8l2OCZabeeZ/BONBHSNo9nqeO0fktToNki3FGzWNL Nmtw== X-Gm-Message-State: AOAM530au/5Il/IFLNNNAqhIkzsk1tz1WIY9GXDcLQpSG94LaAGAO3Fz 6f5p8/mIIA0biflqlwjKEL8l3kwo X-Google-Smtp-Source: ABdhPJzPVXN54yTfE1dgZ60beJRcDv/XotC3s9ojblfLMTaHOXDqXh6KaOTNL1jW0u4SwgeLfjQS7A== X-Received: by 2002:a5d:6386:0:b0:213:b939:8272 with SMTP id p6-20020a5d6386000000b00213b9398272mr22709649wru.396.1654595296763; Tue, 07 Jun 2022 02:48:16 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6000:144a:b0:20f:f1e7:c71c with SMTP id v10-20020a056000144a00b0020ff1e7c71cls4152110wrx.0.gmail; Tue, 07 Jun 2022 02:48:15 -0700 (PDT) X-Received: by 2002:adf:e30f:0:b0:210:346e:d5da with SMTP id b15-20020adfe30f000000b00210346ed5damr25983444wrj.313.1654595295616; Tue, 07 Jun 2022 02:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595295; cv=none; d=google.com; s=arc-20160816; b=r6hRMZvLNYTCgbifXLerD59N95th6YeUDMLl4rkrwqpIzIMWn4NdlbvCz+dgQ5/G3x P995FS6Cc0DRZRp+U81ytiT3PDHBKJcPYENS7oKAKy3zQBoAHFle8hgrQMFrGN18vxQ/ AhqdOxYDnh5igXGY9g1MktAU7b7ftitzD4xO6GLTlYVCgw/CQmop0G4R/MbceHujFTys 1v/H/sYA11x+U+CcCF1tDgNBsGEoYKqm4k9Ejfi8DRR1ZyVyWwNtbKI9Au3geFPl8+sk g2KKhh5/bJqjy8uGjPaf393tIz6tM1pZfJd966uVEoEuHdHwBIaQbjuQ/t+y2yVhsloy 8rZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ReHEa9nvpM4WWSAEnsEWGM+1xrVLxiybh/+LZPFyWR0=; b=sUJ0tRQWSduJELlJRA9K11YmScxKKBi32SZsNsXPpKg7c1PSYiqkuiYrEs+LWZSTgl U9gj7llsufcX3/rKF/r2Oh4CIguBUtxxDZyb68pVTUXmVEShwBUUEVlckYCbl2k3qkoM RxNNg9P551himkIcOAJSPKk27EYq1AOOr3gBslqFfdrcW0V/GNw00BVB0gENVcXPjjjS AbhFRHd4NvGQmUqgCXphx/GYRh/TNGobqDi9Xbti4dWmHDXujxmG6VkkCzdbZJ1NSPM5 s9nyrMa6TtmaxWQetPKiH9Wa7k4Z4yof52ydkQAmu8Ut9+B+F38IK/bXkyewruni5ZR/ s2fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fD6TXB5k; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id t16-20020a05600c2f9000b00389ec8cb433sor6716640wmn.44.2022.06.07.02.48.15 for (Google Transport Security); Tue, 07 Jun 2022 02:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:600c:1f0e:b0:397:707f:5a60 with SMTP id bd14-20020a05600c1f0e00b00397707f5a60mr27183939wmb.3.1654595295377; Tue, 07 Jun 2022 02:48:15 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-137-51.net.vodafone.it. [5.90.137.51]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c510400b0039748be12dbsm23200547wms.47.2022.06.07.02.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:14 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 03/13] can: slcan: use the alloc_can_skb() helper Date: Tue, 7 Jun 2022 11:47:42 +0200 Message-Id: <20220607094752.1029295-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220607094752.1029295-1-dario.binacchi@amarulasolutions.com> References: <20220607094752.1029295-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fD6TXB5k; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , It is used successfully by most (if not all) CAN device drivers. It allows to remove replicated code. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 6162a9c21672..964b02f321ab 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -143,7 +144,7 @@ static struct net_device **slcan_devs; static void slc_bump(struct slcan *sl) { struct sk_buff *skb; - struct can_frame cf; + struct can_frame cf, *scf; int i, tmp; u32 tmpid; char *cmd = sl->rbuff; @@ -201,21 +202,11 @@ static void slc_bump(struct slcan *sl) } } - skb = dev_alloc_skb(sizeof(struct can_frame) + - sizeof(struct can_skb_priv)); - if (!skb) + skb = alloc_can_skb(sl->dev, &scf); + if (unlikely(!skb)) return; - skb->dev = sl->dev; - skb->protocol = htons(ETH_P_CAN); - skb->pkt_type = PACKET_BROADCAST; - skb->ip_summed = CHECKSUM_UNNECESSARY; - - can_skb_reserve(skb); - can_skb_prv(skb)->ifindex = sl->dev->ifindex; - can_skb_prv(skb)->skbcnt = 0; - - skb_put_data(skb, &cf, sizeof(struct can_frame)); + memcpy(scf, &cf, sizeof(*scf)); sl->dev->stats.rx_packets++; if (!(cf.can_id & CAN_RTR_FLAG))