From patchwork Wed Apr 26 08:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp82297vqo; Wed, 26 Apr 2023 01:16:15 -0700 (PDT) X-Google-Smtp-Source: AKy350YPvQQflCyeBYqj//wjgYhMB+4sC1ieMrNuvSyKGdgtuYDwaGQJV4EHAp6f3Kie23nyuW3f X-Received: by 2002:a05:6a00:1a50:b0:627:e49a:871a with SMTP id h16-20020a056a001a5000b00627e49a871amr28769824pfv.23.1682496975379; Wed, 26 Apr 2023 01:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496975; cv=none; d=google.com; s=arc-20160816; b=AKT7m8ZH42qZyV2pj8zUDKkLPpZTGa/Zlq9HeZxEkQiI9tsSewc3+rbJMGgCUyNk6m 091H4oc5Hh7dRieyBRDYtAEBOqI0UjZtNZCb85RsUeN2V4jo5TqV6EUQtWekTil9v+Wj v3coxWf5MafgAPky5wPY+XGC2Cpdww8/LouPfUnI3rzm9wx036PBveOkSU/Tf0LAEZuF 2TZZrsEfD48FMKMQlx8vdcbSdNo0nXnx5IQFRbenuqf9XUEE1UfXXYX5yPQ7RMLUNhVi WdBQf3qCQMwAGcl+BpuYrjd6FshyDUoC7EOpzzIIkw95+koRcxCl1FDL5AUiTOXex2lU ELow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g/POsgYzx0iNIkOXHjUNfsg79fBTNv1rDvs7utfEfXM=; b=jtH1JN3JB3rUqmMXAAXY4bsze8PXarrVHcPVfJG0mwX39HSZrPWiU+9fXI8k3mYYUs 7ovEjOCdvobYCb5UTSLZpRfiMPfVRNMFqjB4uwFNLzRBOXBQGLtf4KsYJPiYnd7QiCFj +9JlKsUYQmFlpuGLAFsHKNahOUz22PORYEANAFsJr6hFyIjnS9h2PaLL7jyPuGX8COpp MLrNz1jWXcnIRDLrjCHjwzL+chbCO6FiWYvSL7d1Ip514Ersza0dRaFL9Lw0HfWSgA/u ZsAYUqA60NGuPULDMEl+NY5dHt55M69vIzELxi1vOmvPwwWiMWaXeUn1ojypd0Vbghs9 j0Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=cvdcFMRd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020aa7984f000000b0063b13efdd06si13286988pfq.345.2023.04.26.01.16.00; Wed, 26 Apr 2023 01:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=cvdcFMRd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239943AbjDZIFT (ORCPT + 99 others); Wed, 26 Apr 2023 04:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240106AbjDZIFE (ORCPT ); Wed, 26 Apr 2023 04:05:04 -0400 X-Greylist: delayed 61 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 26 Apr 2023 01:04:37 PDT Received: from mta-65-226.siemens.flowmailer.net (mta-65-226.siemens.flowmailer.net [185.136.65.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04D1140F4 for ; Wed, 26 Apr 2023 01:04:36 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 2023042608033228aa3e9bc3d44d7d04 for ; Wed, 26 Apr 2023 10:03:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=g/POsgYzx0iNIkOXHjUNfsg79fBTNv1rDvs7utfEfXM=; b=cvdcFMRdlJamOkipMgieO06dzyWVLe0EQdcpYtvw0PWGAJBs42zxXYwuqB+A8+jcNmRisV RGC4oAnWGH8+0ckTdHRh8q7MFKnY/YmJpPLXH5zPYm9J7Wjj+dt9lAPqxNnvFED0xIZ5KUnW JhVDxKNHveQk41ZRz0NG0wQcdwyzQ=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 7/8] tty: n_gsm: cleanup gsm_control_command and gsm_control_reply Date: Wed, 26 Apr 2023 10:03:14 +0200 Message-Id: <20230426080315.7595-7-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225948122808822?= X-GMAIL-MSGID: =?utf-8?q?1764225948122808822?= From: Daniel Starke There are multiple places in gsm_control_command and gsm_control_reply that derive the specific DLCI handle directly out of the DLCI table in gsm. Add a local variable which holds this handle and use it instead to improve code readability. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-7-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 42a8507aae4a..62bff4474b57 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1451,15 +1451,16 @@ static int gsm_control_command(struct gsm_mux *gsm, int cmd, const u8 *data, int dlen) { struct gsm_msg *msg; + struct gsm_dlci *dlci = gsm->dlci[0]; - msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->dlci[0]->ftype); + msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); if (msg == NULL) return -ENOMEM; msg->data[0] = (cmd << 1) | CR | EA; /* Set C/R */ msg->data[1] = (dlen << 1) | EA; memcpy(msg->data + 2, data, dlen); - gsm_data_queue(gsm->dlci[0], msg); + gsm_data_queue(dlci, msg); return 0; } @@ -1478,14 +1479,15 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, const u8 *data, int dlen) { struct gsm_msg *msg; + struct gsm_dlci *dlci = gsm->dlci[0]; - msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->dlci[0]->ftype); + msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); if (msg == NULL) return; msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */ msg->data[1] = (dlen << 1) | EA; memcpy(msg->data + 2, data, dlen); - gsm_data_queue(gsm->dlci[0], msg); + gsm_data_queue(dlci, msg); } /**