From patchwork Fri Mar 4 08:03:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12768703 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4DA5C433EF for ; Fri, 4 Mar 2022 08:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xbMY61lYCTvvSvF6oMu7bGBXm7y9/uhwuwlvOOieZ3k=; b=D3C32ZJiuO/yR9 sge4I1hyz51j6yMtptUibgaFfp4VkNtQVDR5/dgX6xO32x4vx3U8cZ+Rt18tLvOz7yQ7h6NxikpLG X9EsAbq/XS/fr6N37Kq/iIwqTP8QD0dwR6HjCvZFyPTj+kudwQuZCfcOnhnkZehhCOcHakoVLuZ3N JJdb3vW7hMaa0pzF9p2/8Kl2I4CtJpgyA8YDxzIV/1mU+1lWZ8Z4RT/5PAqslV9g+I64opqhZv54k EulDU8tVpoZjkk+r+WCcGqdmWf0l7qB+9R3TnhbJ2Utun/WUnNwJhFas0csrvP4XTwNr6BknAePMc CRWz6aCPdPdHrm9kgMDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ2yO-008vuX-D4; Fri, 04 Mar 2022 08:07:37 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ2v1-008uSE-Ol for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 08:04:12 +0000 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8DFA43F621 for ; Fri, 4 Mar 2022 08:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646381046; bh=tkFzw6lPD+d7IUHuEyg4SR+Uqauf7bGHXxHOG6uOhJE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GXkiMeLDypCK2HgzyI22Z5pP0TqGwLx1YhSE1WO5NmIwgpIj4ObIF7Lx7KLQWYoSm qG3XOIwNLiVPHZTexVpI/6pJeUh6Q/qTb3iWUrbS0MBjfnX8NVB77MLfsihdzvhANS Dtuf5viJHnDxClYhOYht4HPmouzafED4Y0/UcNGrH9ExHXo7AtTdBGnBs+/aTg2Ybs 4p68WvjJeKcE19G7Og4AOqkSgFPGvc87ZsG8ju8gnQTroPvJYo8w0o5jrSOH0A0cX4 TtO0b/4haN5AC5Jvuc/ki52npKRFQR8QtbUHiJnhqBrwCo0h5GuOiVgFwuGP4HYNNb nnULiZCtUwCRA== Received: by mail-ed1-f71.google.com with SMTP id y10-20020a056402358a00b00410deddea4cso4200285edc.16 for ; Fri, 04 Mar 2022 00:04:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tkFzw6lPD+d7IUHuEyg4SR+Uqauf7bGHXxHOG6uOhJE=; b=LdE+yELrFWtzj3CHJ4xdz51as91BFnJxQ45LgRhYnNavboE853YM65uzj6JGInC61Y Qrt7mk3p4QgnPSZa39tq5w2EOLzg/WWQA90ATWRTJ10GCbO47QLlYr3j6dEHa+nu9kAK ltAeFoVfDbBucVDQqXNbsZ9f2N/4ZEkXT6arXl1r+DtZ9OLbWVnuggbLNKIvVWNTXN0C 1/NwEpLn2u7YoqXrI8ElW/IPYQsY3lFL66f0KETHSn8ZKSQHVAHF+28R+5w76mevJaYQ FpM9w0sguBySKCLe86uyH+O67JSwM7zpp+hR+4aG7/Ctw0NgG2h8APQAyy8s2/QfzKph K2xw== X-Gm-Message-State: AOAM533qoQQfpx5PaCy96fDRdUaumLqNOuOPjhu4Nk81nJKLBRBpW47R UKKh5ziJGszty5HQ3PFF3tWfe/Kj0j86nV0GUSRhL10BrCTF1FCrZun18bbDHBJdaHP6MpLDD3u uXkjlzF6pd4/2jwr8QVqqbKjwR11NrZDAd3dqX9wWJSXB97blSV8f X-Received: by 2002:aa7:c3d8:0:b0:415:a0a9:1f18 with SMTP id l24-20020aa7c3d8000000b00415a0a91f18mr13900980edr.412.1646381046224; Fri, 04 Mar 2022 00:04:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAoYlFqtIS/wNs7p5E3iZzy6T1pQuvHkOTV8Oa+pnRvMS1Gv2k/UzkFrbgh4dvOK2sCCYu/Q== X-Received: by 2002:aa7:c3d8:0:b0:415:a0a9:1f18 with SMTP id l24-20020aa7c3d8000000b00415a0a91f18mr13900967edr.412.1646381046030; Fri, 04 Mar 2022 00:04:06 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id rv11-20020a17090710cb00b006d5c0cd5e0dsm1481465ejb.82.2022.03.04.00.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 00:04:05 -0800 (PST) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] tty: serial: samsung: constify variables and pointers Date: Fri, 4 Mar 2022 09:03:47 +0100 Message-Id: <20220304080348.218581-6-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220304080348.218581-1-krzysztof.kozlowski@canonical.com> References: <20220304080348.218581-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_000408_049225_4408A934 X-CRM114-Status: GOOD ( 17.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Constify variables, data pointed by several pointers and "udivslot_table" static array. This makes code a bit safer. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jiri Slaby --- drivers/tty/serial/samsung_tty.c | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index eecefff5c4a4..00e7c34fad46 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -164,7 +164,7 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport); #define portaddrl(port, reg) \ ((unsigned long *)(unsigned long)((port)->membase + (reg))) -static u32 rd_reg(struct uart_port *port, u32 reg) +static u32 rd_reg(const struct uart_port *port, u32 reg) { switch (port->iotype) { case UPIO_MEM: @@ -179,7 +179,7 @@ static u32 rd_reg(struct uart_port *port, u32 reg) #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg))) -static void wr_reg(struct uart_port *port, u32 reg, u32 val) +static void wr_reg(const struct uart_port *port, u32 reg, u32 val) { switch (port->iotype) { case UPIO_MEM: @@ -195,7 +195,7 @@ static void wr_reg(struct uart_port *port, u32 reg, u32 val) /* Byte-order aware bit setting/clearing functions. */ -static inline void s3c24xx_set_bit(struct uart_port *port, int idx, +static inline void s3c24xx_set_bit(const struct uart_port *port, int idx, unsigned int reg) { unsigned long flags; @@ -208,7 +208,7 @@ static inline void s3c24xx_set_bit(struct uart_port *port, int idx, local_irq_restore(flags); } -static inline void s3c24xx_clear_bit(struct uart_port *port, int idx, +static inline void s3c24xx_clear_bit(const struct uart_port *port, int idx, unsigned int reg) { unsigned long flags; @@ -221,19 +221,19 @@ static inline void s3c24xx_clear_bit(struct uart_port *port, int idx, local_irq_restore(flags); } -static inline struct s3c24xx_uart_port *to_ourport(const struct uart_port *port) +static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port) { return container_of(port, struct s3c24xx_uart_port, port); } /* translate a port to the device name */ -static inline const char *s3c24xx_serial_portname(struct uart_port *port) +static inline const char *s3c24xx_serial_portname(const struct uart_port *port) { return to_platform_device(port->dev)->name; } -static int s3c24xx_serial_txempty_nofifo(struct uart_port *port) +static int s3c24xx_serial_txempty_nofifo(const struct uart_port *port) { return rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE; } @@ -358,7 +358,7 @@ static void s3c24xx_serial_tx_dma_complete(void *args) static void enable_tx_dma(struct s3c24xx_uart_port *ourport) { - struct uart_port *port = &ourport->port; + const struct uart_port *port = &ourport->port; u32 ucon; /* Mask Tx interrupt */ @@ -387,7 +387,7 @@ static void enable_tx_dma(struct s3c24xx_uart_port *ourport) static void enable_tx_pio(struct s3c24xx_uart_port *ourport) { - struct uart_port *port = &ourport->port; + const struct uart_port *port = &ourport->port; u32 ucon, ufcon; /* Set ufcon txtrig */ @@ -580,9 +580,9 @@ static inline const struct s3c24xx_uart_info } static inline const struct s3c2410_uartcfg - *s3c24xx_port_to_cfg(struct uart_port *port) + *s3c24xx_port_to_cfg(const struct uart_port *port) { - struct s3c24xx_uart_port *ourport; + const struct s3c24xx_uart_port *ourport; if (port->dev == NULL) return NULL; @@ -591,7 +591,7 @@ static inline const struct s3c2410_uartcfg return ourport->cfg; } -static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport, +static int s3c24xx_serial_rx_fifocnt(const struct s3c24xx_uart_port *ourport, unsigned long ufstat) { const struct s3c24xx_uart_info *info = ourport->info; @@ -947,8 +947,8 @@ static irqreturn_t s3c24xx_serial_tx_irq(int irq, void *id) /* interrupt handler for s3c64xx and later SoC's.*/ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id) { - struct s3c24xx_uart_port *ourport = id; - struct uart_port *port = &ourport->port; + const struct s3c24xx_uart_port *ourport = id; + const struct uart_port *port = &ourport->port; unsigned int pend = rd_regl(port, S3C64XX_UINTP); irqreturn_t ret = IRQ_HANDLED; @@ -966,8 +966,8 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id) /* interrupt handler for Apple SoC's.*/ static irqreturn_t apple_serial_handle_irq(int irq, void *id) { - struct s3c24xx_uart_port *ourport = id; - struct uart_port *port = &ourport->port; + const struct s3c24xx_uart_port *ourport = id; + const struct uart_port *port = &ourport->port; unsigned int pend = rd_regl(port, S3C2410_UTRSTAT); irqreturn_t ret = IRQ_NONE; @@ -1499,7 +1499,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, * This table takes the fractional value of the baud divisor and gives * the recommended setting for the UDIVSLOT register. */ -static u16 udivslot_table[16] = { +static const u16 udivslot_table[16] = { [0] = 0x0000, [1] = 0x0080, [2] = 0x0808, @@ -1675,7 +1675,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, static const char *s3c24xx_serial_type(struct uart_port *port) { - struct s3c24xx_uart_port *ourport = to_ourport(port); + const struct s3c24xx_uart_port *ourport = to_ourport(port); switch (ourport->info->type) { case TYPE_S3C24XX: @@ -2450,7 +2450,7 @@ s3c24xx_port_configured(unsigned int ucon) static int s3c24xx_serial_get_poll_char(struct uart_port *port) { - struct s3c24xx_uart_port *ourport = to_ourport(port); + const struct s3c24xx_uart_port *ourport = to_ourport(port); unsigned int ufstat; ufstat = rd_regl(port, S3C2410_UFSTAT);