From patchwork Wed Oct 26 22:42:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 11450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp519166wru; Wed, 26 Oct 2022 15:44:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DrcEaTFd2RBix29qTt5ewm0YsUUgeRzqRoq2fOxCM9DVxTRfCulnUUtAxTmzz7CWOaP51 X-Received: by 2002:a17:907:2c59:b0:78d:8e03:134 with SMTP id hf25-20020a1709072c5900b0078d8e030134mr38663089ejc.310.1666824291891; Wed, 26 Oct 2022 15:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666824291; cv=none; d=google.com; s=arc-20160816; b=J4hNalcZPoYdvJJWswLpWdHlXoFRfYKUBa+KRHDhjeHCjgUiqX1Hm+7D8hU3P7+Nx7 COa9jFONmD329EaF3pNVowitvT8vuPPlTr8j/QRXIAlAGBgcrRLN9Jpf5kU2i1MIfvSe w3crKvverfK7nZ+cxj40Yh7OvldLxLMnWkGBhVc6Ij+aN7MEY/n9qcr/GIdtTMZEZiWS nmaUWjAAJkNBhBqxu2bS7t3mHZynTjQbWStK4ZLzTcdA6W1r89F7kHphFxYPSgtGMzmT 8uJhdxOnCC+8ciL9KI9EMqjDApsXngmk8XzhymP3TRv18MACRZdJBGeQyXnMuwrHmYel DAgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:from:date :dkim-signature; bh=SM58FcbuNJwqSsPaOZRUPLOSRkNyAJC01HVLoHUL4EM=; b=y4LbZMrEuWy8NTCVoY+14KhZNEGvxCDjt0Sypdnlijurj85ExWFMrx4mk9feBmheni LYgugWBzioJF9JUdnZ3Cd4SDmeDwRWPS51Bh+Mt5Z3fr0ljA7NYEK+HM8sbTbbVAIG3F /8TxsAo62osa/DyCmfKu2txWrb6LCemAdVtq2QOeJxEMz3L3+WduKQ91uMPzspffx1bh m1wqqEQzM41p4e/MtqdsuMh9BK5sr67RiEjFaRxpt0sw0GNOOFzUMidZly/Rhj1rVjhH vurphMZNzBVb6y0JJASTE1XJyGR0GgC4EOPaW7LY3tOjGxniX0Qq0xB53UWbNimu+OmY Xkqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202205 header.b=Iehr94EQ; 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=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a17090658ca00b0078de536a3cdsi8031343ejs.119.2022.10.26.15.44.28; Wed, 26 Oct 2022 15:44:51 -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=@nabijaczleweli.xyz header.s=202205 header.b=Iehr94EQ; 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=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233706AbiJZWm7 (ORCPT + 99 others); Wed, 26 Oct 2022 18:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233669AbiJZWm4 (ORCPT ); Wed, 26 Oct 2022 18:42:56 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9824E356DA for ; Wed, 26 Oct 2022 15:42:54 -0700 (PDT) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id E4C3C489E; Thu, 27 Oct 2022 00:42:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202205; t=1666824173; bh=POnUIzf1npzUTJWLJxHdqxp++JUxZ5v0ALeMnMs/AHI=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=Iehr94EQZ22V2ug75Lmq0a6rPBjGWUmgXEOkpMQcrM6/PNtWezt0LVCjwWns1EwOC fVT0HDU8gnFg+GzFujXo350Z2FhzcotX6EyiYkdVgx4n9p/M9Gre9g/0pi7XHZzBVD ltEcGBzlL4TSjDOenqTgH3Vi/nIsYVguoWS/F4m4LsrBxnPGJuKe0cLc/5cBMVldms +4ixaWsYrTBIn2z2VCPsYJJyI3zPo7YrCMxB5wphuImJMGU+zBCZ9Kl0LLS7+MvI2z XrCZ2KbhPARbRmn0j61XQarO2I76Sslq+rmrlTBRyzP+5XVtFO1sVq7RbHNVU4ciRw u+/jaERqmiSIJAZclPShz1MZw0Qa7PZlHGzFcG8YxeQ52QsiOg50OdBL7IFeTj2K+8 WREzDFPaNXBmYmuiPCRD4JIR+H4SUth176ifJ8xPUufrryV4HK4ogdiawsrhh53+Un Tr6RE2K5g+K8d7JOmbxSUQUf1avqplF/PayqKAAGwNc3k0A8sUn2697I8HwJ78tZGx +14iGTmriDxP0hSljfoNm2d0WI8YohGPvJEPWdrJqKyNEzfa4v3tMZjP2StxwzQFHC HeS4vOfkbbYffc44fg/hIHoRAzEm6hn6LImAdGQYnjCKBpvwgmEXjoAg779DyspJiP vL7ES4f2G/7Pbhz5NccQNob0= Date: Thu, 27 Oct 2022 00:42:52 +0200 From: =?utf-8?b?0L3QsNCx?= Cc: Arnd Bergmann , Greg Kroah-Hartman , Ilpo =?utf-8?b?SsOkcnZp?= =?utf-8?b?bmVu?= , Andy Shevchenko , Jiri Slaby , Haowen Bai , linux-kernel@vger.kernel.org Subject: [PATCH 04/15] pcmcia: synclink_cs: remove dead paranoia_check, warn for missing line Message-ID: <051083d29e5812608deb034dfa86ae0c583fee44.1666822928.git.nabijaczleweli@nabijaczleweli.xyz> References: <9a453437b5c3b4b1887c1bd84455b0cc3d1c40b2.1666822928.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <9a453437b5c3b4b1887c1bd84455b0cc3d1c40b2.1666822928.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20220429 X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, MISSING_HEADERS,PDS_OTHER_BAD_TLD,PDS_RDNS_DYNAMIC_FP,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1747791948770099235?= X-GMAIL-MSGID: =?utf-8?q?1747791948770099235?= MGSLPC_PARANOIA_CHECK has never been defined automatically, and devices with null driver_info can't happen, since we reject the open in that case Move the log statement from dead code to the check, and log the state inconsistency like we do above for the line count ("invalid line #%d.") Signed-off-by: Ahelenia ZiemiaƄska --- drivers/char/pcmcia/synclink_cs.c | 71 +++---------------------------- 1 file changed, 6 insertions(+), 65 deletions(-) diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 262f087bfc01..19b6118639b4 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -644,25 +644,6 @@ static int mgslpc_resume(struct pcmcia_device *link) } -static inline bool mgslpc_paranoia_check(MGSLPC_INFO *info, - char *name, const char *routine) -{ -#ifdef MGSLPC_PARANOIA_CHECK - static const char *badinfo = - "Warning: null mgslpc_info for (%s) in %s\n"; - - if (!info) { - printk(badinfo, name, routine); - return true; - } -#else - if (!info) - return true; -#endif - return false; -} - - #define CMD_RXFIFO BIT7 // release current rx FIFO #define CMD_RXRESET BIT6 // receiver reset #define CMD_RXFIFO_READ BIT5 @@ -694,8 +675,6 @@ static void tx_pause(struct tty_struct *tty) MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - if (mgslpc_paranoia_check(info, tty->name, "tx_pause")) - return; if (debug_level >= DEBUG_LEVEL_INFO) printk("tx_pause(%s)\n", info->device_name); @@ -710,8 +689,6 @@ static void tx_release(struct tty_struct *tty) MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - if (mgslpc_paranoia_check(info, tty->name, "tx_release")) - return; if (debug_level >= DEBUG_LEVEL_INFO) printk("tx_release(%s)\n", info->device_name); @@ -1476,9 +1453,6 @@ static int mgslpc_put_char(struct tty_struct *tty, unsigned char ch) __FILE__, __LINE__, ch, info->device_name); } - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) - return 0; - if (!info->tx_buf) return 0; @@ -1508,9 +1482,6 @@ static void mgslpc_flush_chars(struct tty_struct *tty) printk("%s(%d):mgslpc_flush_chars() entry on %s tx_count=%d\n", __FILE__, __LINE__, info->device_name, info->tx_count); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars")) - return; - if (info->tx_count <= 0 || tty->flow.stopped || tty->hw_stopped || !info->tx_buf) return; @@ -1546,8 +1517,7 @@ static int mgslpc_write(struct tty_struct * tty, printk("%s(%d):mgslpc_write(%s) count=%d\n", __FILE__, __LINE__, info->device_name, count); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || - !info->tx_buf) + if (!info->tx_buf) goto cleanup; if (info->params.mode == MGSL_MODE_HDLC) { @@ -1600,9 +1570,6 @@ static unsigned int mgslpc_write_room(struct tty_struct *tty) MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; int ret; - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room")) - return 0; - if (info->params.mode == MGSL_MODE_HDLC) { /* HDLC (frame oriented) mode */ if (info->tx_active) @@ -1632,9 +1599,6 @@ static unsigned int mgslpc_chars_in_buffer(struct tty_struct *tty) printk("%s(%d):mgslpc_chars_in_buffer(%s)\n", __FILE__, __LINE__, info->device_name); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer")) - return 0; - if (info->params.mode == MGSL_MODE_HDLC) rc = info->tx_active ? info->max_frame_size : 0; else @@ -1658,9 +1622,6 @@ static void mgslpc_flush_buffer(struct tty_struct *tty) printk("%s(%d):mgslpc_flush_buffer(%s) entry\n", __FILE__, __LINE__, info->device_name); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer")) - return; - spin_lock_irqsave(&info->lock, flags); info->tx_count = info->tx_put = info->tx_get = 0; del_timer(&info->tx_timer); @@ -1681,9 +1642,6 @@ static void mgslpc_send_xchar(struct tty_struct *tty, char ch) printk("%s(%d):mgslpc_send_xchar(%s,%d)\n", __FILE__, __LINE__, info->device_name, ch); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar")) - return; - info->x_char = ch; if (ch) { spin_lock_irqsave(&info->lock, flags); @@ -1704,9 +1662,6 @@ static void mgslpc_throttle(struct tty_struct * tty) printk("%s(%d):mgslpc_throttle(%s) entry\n", __FILE__, __LINE__, info->device_name); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle")) - return; - if (I_IXOFF(tty)) mgslpc_send_xchar(tty, STOP_CHAR(tty)); @@ -1729,9 +1684,6 @@ static void mgslpc_unthrottle(struct tty_struct * tty) printk("%s(%d):mgslpc_unthrottle(%s) entry\n", __FILE__, __LINE__, info->device_name); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle")) - return; - if (I_IXOFF(tty)) { if (info->x_char) info->x_char = 0; @@ -2160,9 +2112,6 @@ static int mgslpc_break(struct tty_struct *tty, int break_state) printk("%s(%d):mgslpc_break(%s,%d)\n", __FILE__, __LINE__, info->device_name, break_state); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) - return -EINVAL; - spin_lock_irqsave(&info->lock, flags); if (break_state == -1) set_reg_bits(info, CHA+DAFO, BIT6); @@ -2218,9 +2167,6 @@ static int mgslpc_ioctl(struct tty_struct *tty, printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__, __LINE__, info->device_name, cmd); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) - return -ENODEV; - if (cmd != TIOCMIWAIT) { if (tty_io_error(tty)) return -EIO; @@ -2312,9 +2258,6 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; struct tty_port *port = &info->port; - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) - return; - if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", __FILE__, __LINE__, info->device_name, port->count); @@ -2352,9 +2295,6 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) printk("%s(%d):mgslpc_wait_until_sent(%s) entry\n", __FILE__, __LINE__, info->device_name); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) - return; - if (!tty_port_initialized(&info->port)) goto exit; @@ -2412,9 +2352,6 @@ static void mgslpc_hangup(struct tty_struct *tty) printk("%s(%d):mgslpc_hangup(%s)\n", __FILE__, __LINE__, info->device_name); - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) - return; - mgslpc_flush_buffer(tty); shutdown(info, tty); tty_port_hangup(&info->port); @@ -2468,8 +2405,12 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) info = mgslpc_device_list; while(info && info->line != line) info = info->next_device; - if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) + if (!info) { + printk(KERN_WARNING "%s(%d):mgslpc_open: " + "no device for line #%d.\n", + __FILE__, __LINE__, line); return -ENODEV; + } port = &info->port; tty->driver_data = info;