From patchwork Thu Jun 2 16:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1987 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 390983F06D for ; Thu, 2 Jun 2022 18:04:43 +0200 (CEST) Received: by mail-ej1-f70.google.com with SMTP id au8-20020a170907092800b00707784fd7e0sf2579037ejc.22 for ; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185883; cv=pass; d=google.com; s=arc-20160816; b=JTn8qAWUbmVV22C2omg+OXA/IX49or2dYs2nk2eEfFi6U5b85INv/MNpSt9672ZiVi 53p3wI0QTXouhHYBA/OYTl2LkESKSVf2K3DJuXijCrs1jeileIhzUkuxzMqKByVwo1gs 18zRttA8MLT/Rlz58wFPG6bCLng46tOdxxNcd/f4HnUDV3xNyFm+oYQCHYFMrsaHkySL pym/58U1zCt1gaXnp3skDk9D8O4ZyxTWWyIa9sA7y1emDlPvmCNfc3WzrcRSE+hs1muQ phIPCRFIMyp+gWxSXmCQ+BzVZ/xSaiZ06OfTarnH6bjXNlE32fu0B6x3OvW8V2s85l5w BugA== 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=rd5fKQGrmVRcVydHoscc46oqD2f+jRXRiIdavWAgeLs=; b=QkPxjAcaKkRQ8Zwsm63u7dgWWirZqXASnu6sdVWVIVuEGIbpvyHwQ3aNko63idsdRl b6W3vzccbFslru1JH2odi21OinVjWDPwXtftF6ZM/+5KwO14bsgAm1aYNHdLgbz7xvj6 sT/YmkMLf/pa3VPkBmIa1kfisgM0u/qZm0LD0VrvwtK1Uc+cbdeezx42BqQ1/K6kZX7h ZmeWVJ4Y3JNa3yjiVj6wtVV79TZjpDCz2Q15ffNgP3xPftIoxxqPokrrm4rtJ6pzfOMK 115ER99b9PkNeTB6m6YEWSu6wgGEXEyXlEwhDSbhTC6V7l3b6HoPYlyUOGPLiM3INdys ZvfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=l5nClT2K; 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=rd5fKQGrmVRcVydHoscc46oqD2f+jRXRiIdavWAgeLs=; b=jBPkJ/iAN7/3e2chZndPCxzXS8Orq3miIGJhSKktJLyPa9+R9f+HPjE2dRccp9uFIs x+nSA7XgXfalznoXfeWAVuFBhyjJowNvLEPl++qxnt6fDb35cJVLU6OOjySUWeI9tzAu RryVsj4iIHX3DEd/u3Ui0yRjZcsFiCr+K6l9g= 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=rd5fKQGrmVRcVydHoscc46oqD2f+jRXRiIdavWAgeLs=; b=zSxNoKaBTvuhozWIdH76m6z4ALiV8NLZxm71DM4i0antMFdFYMyz8wrnx5tarfAGwD uoDZaW27ulzrIdDjYRmmQOkiMTpqwyjjuK+gtRjBOVQqESw+MF1ORRBr9l1yIYWJvjZV lw3mjAUjg9jYvGJ2wjiBt8FULgA/yj8yvbNhXJey+AJCme2HPriiEtdpEM9w2pFWl/Yb tscFNBN8UbGKWwSr2+YWhFm573yPP4IycO/4CowbHaOii+nK/tK9QXljFWvuA+lgOOZ/ +JRYS9kqfZX/eApAo4NKfVMRBOl1RI+Xhdfmkt+5tOyDaGk7mvf3Wu7cbUHOWsirpLep gg3g== X-Gm-Message-State: AOAM531gIKBQoL6wix95oLSqnAxrUH+G5LvLAYXcApTPLkIUtYzW+972 +IIqwGiTuL10xZ/a5TIJxboY7i+E X-Google-Smtp-Source: ABdhPJxKtR3juT0s4sU60etljd4ssLcx9oYstdba3qiz5/R5ZMQ0uC1ubqmp2Qcp0i9JdUGl6bbvLA== X-Received: by 2002:a05:6402:1341:b0:42a:f7cb:44dc with SMTP id y1-20020a056402134100b0042af7cb44dcmr6286357edw.165.1654185883071; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:70cf:b0:6fe:d027:3c1f with SMTP id g15-20020a17090670cf00b006fed0273c1fls2947737ejk.2.gmail; Thu, 02 Jun 2022 09:04:42 -0700 (PDT) X-Received: by 2002:a17:907:ea1:b0:6fe:f6a5:6009 with SMTP id ho33-20020a1709070ea100b006fef6a56009mr5179921ejc.275.1654185881901; Thu, 02 Jun 2022 09:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185881; cv=none; d=google.com; s=arc-20160816; b=b4ww9Q9ebkxB6aKKwfag2Vn0GNaAVDzWwtEcTIDze9e2cY/pJRQWsm2MxmMb7U0bPQ z4ngB97F0escHun+OxcvK3pJ7fZByYrcJqC3wy/5JfIlUTMH2AfXAAS0F5aKERs/Cts7 GibxCDgRAQ6946ZWhJdglQ/gDKwP7S1om6ai+PTk8YzQ/cpwIA8csOSPvGGz0tbO2j6N Se/Dr+BvkRn/skO0V/WSdHuMjNJN+YbwPKBYKG6Pt8NWcM5EOatZinXy+i6gyh4S6P+k AEz2qCLviDLwbcOmFW3jic+jrI1Dr7sqtsAzuzRW4OPy5d5lGaxWZIL3RbEzmA+pD4Cl Z2mA== 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=kPBEgvyVQ38r5lH7fJdN35/kW0pwQ4FNxeQ+95rO0+8=; b=P/3XawvQpEjBoHvMS2xZ4GhfT05gC2qIO/OMy/2A3XW3inLotTvtvlBiSlxjHQLEzO siU5bF+WgT5FfUh1HMhfFmXUsFBQJ4DLvh6y5X95a4NnBapA00LPPZqg9gTu9DMpUhWi KoyfabT30ynR69RvYkr7TzkL5E0/LvUheHL7lauamw7dqSw5jEfsmmJAGBtO9KELQzmZ Gx+qk5s3Rjdqjt5YwzGvg+8J+JMh6tZn9y+c6NJijS4MHDl2/OJMAo6U6yywyFGGaJ3C taAeX0OOcGvCCLANr7yTHXGbp15zHcqCg/ZZir65He8rg1InoYYHEuJbFRrpQzzqwpsJ kQdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=l5nClT2K; 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 m19-20020a056402511300b0042de1ae31a6sor3179004edd.65.2022.06.02.09.04.41 for (Google Transport Security); Thu, 02 Jun 2022 09:04:41 -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:6402:3291:b0:42d:dd03:cbb1 with SMTP id f17-20020a056402329100b0042ddd03cbb1mr6137692eda.268.1654185881443; Thu, 02 Jun 2022 09:04:41 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:41 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 03/13] can: slcan: use the alloc_can_skb() helper Date: Thu, 2 Jun 2022 18:04:24 +0200 Message-Id: <20220602160434.225417-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-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=l5nClT2K; 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 --- (no changes since v1) 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))