From patchwork Wed May 17 15:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 683873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72CDDC77B7A for ; Wed, 17 May 2023 15:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbjEQP7F (ORCPT ); Wed, 17 May 2023 11:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbjEQP7A (ORCPT ); Wed, 17 May 2023 11:59:00 -0400 Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C1407DA1 for ; Wed, 17 May 2023 08:58:34 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 2023051715583076c3e5effb9f815987 for ; Wed, 17 May 2023 17:58:30 +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=8JZ3aNj2YfHl3YwKHBbNEj8X9wcN9oM57BAa2nlT+Po=; b=ABTv8j70Np0JRokN+q2Jfx+1JhRLSh7J7PBOYernGtJzjh9JrozrFbXSB8JOIX29YvhnwD dE4QNPFJUV03D8FpAuYyTXbLPlkgCG50l+RouAdDcMAyIkmK8oenN3gnN7aMJ2ZzhV/FD/lX TgwG3yiwuvWSoMfXqo5rwXqbVqg3c=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com, felix-haase@siemens.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v5 07/10] tty: n_gsm: cleanup gsm_control_command and gsm_control_reply Date: Wed, 17 May 2023 17:57:01 +0200 Message-Id: <20230517155704.5701-7-daniel.starke@siemens.com> In-Reply-To: <20230517155704.5701-1-daniel.starke@siemens.com> References: <20230517155704.5701-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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(-) v4 -> v5: No changes. Please note that I cannot response to emails until August 7th. Felix Haase will take over from our side for questions regarding this patch series or the n_gsm. Link: https://lore.kernel.org/all/20230426080315.7595-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); } /**