From patchwork Sun Jan 8 21:56:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 40587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1865989wrt; Sun, 8 Jan 2023 13:59:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1PqEczATuHnWZ3D8h7Lcm4QVS/NQkXTEXiPkSGT0ncwjuuL1hKWmmNOKiDT4Kw3iZuQga X-Received: by 2002:a17:906:c250:b0:79e:4880:dd85 with SMTP id bl16-20020a170906c25000b0079e4880dd85mr46842999ejb.47.1673215197728; Sun, 08 Jan 2023 13:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673215197; cv=none; d=google.com; s=arc-20160816; b=zBtR2R1h9ijGvWriAVtxGK9xYVvqYdt50VIuhKGqb70Id2RCQcSk9lMO8vMksZ57CO 36V0nsyMxsh8CXEAq2G7gbku58oe2uQZMn2VAVa3Ss2krPb9Ytqp0pOjOReZPKXgdeWC 7olS2PEZwdfGLgfMMy1s7G7ZlmChhfco37J2Wwe3KJVVL4Jzy2uVLUexSzHOEyZIl2AA xIt/8JW/SfGSSKkApVQ3z73/xjpQKfxSG8B22BlNixRWMcbazPZaeJSdMR/AKUOYAyX5 4LTpcFk6lQaEo3ZYwS3JeuVye53Z0mvc8w2yyKzHYFXfGG/cvLxeqasZcDq6uh+BqwWo WJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PuHjicZYsZv1YxafD0PitIxhFzu7w+N5/HlaM8PLcI4=; b=U8E5XTYTAa5CrZrEAm1GozTrNR3PtjZ81A6c9t1l+mzO2WXMyO1kmbP4VCxCY0DZ+1 QAoQT11pOwvmQ/LIiNeHc4pyOSU6FOvh8GEGvguOCKhPdsCeyp9NovEzWwGBcrlMnjbB gvEkzkaBM3ZIl1PtJFy5jOc6oXWRc6f17ZSqt9ayNT1oYA57cVG49x3RIUpIP1ko4wxM bMsG3yUdXVrd6FZ+qhAnKrsJoUcPMbI3eP775dn2HvUD1acmh3mWbCUhxCCIhvKuzMv5 pH/5+ui7ezMBYGXH3NxS0mfxBmhalj2D/rTkvO4zeRjx/6rm6tH+/T7oGCcxQDRnQ3UO 2kFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ldezYofx; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt20-20020a170907729400b00812e75e5257si7965243ejc.293.2023.01.08.13.59.34; Sun, 08 Jan 2023 13:59:57 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=ldezYofx; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236260AbjAHV5N (ORCPT + 99 others); Sun, 8 Jan 2023 16:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236219AbjAHV5J (ORCPT ); Sun, 8 Jan 2023 16:57:09 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2285B7677 for ; Sun, 8 Jan 2023 13:57:08 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so5241699wms.2 for ; Sun, 08 Jan 2023 13:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PuHjicZYsZv1YxafD0PitIxhFzu7w+N5/HlaM8PLcI4=; b=ldezYofxF0jJjJeJC1RD3qkb4zEl0FmqQ0EzLX/Nkhv7NxXSNNuTeZx31gd9ZYfA9t YXnoXkg4aiNaDbUAOFjZ2a166mwOtET4tc5l0zf9nl97m3RqWI9/NqTjxyJNMWoXdiC1 G7d07sdLjN0QUk221voWKI1iZntHD7Yr1vj+jnnIvKGQPu4jBRnp0DW/uxYzMpKjlvWB pzCRMO0Zu1Ok0opQ8rJFJoVkih8W51eiuzIzpn3RFUc9297YdFG1oUh0f8AKtXi1+CrO clVWqODs4HTpr+0d+eyFk+EofoizImSSPjhwnyCZE6yWu/ge9KhR90Jd1vQwRwmGeape tKbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PuHjicZYsZv1YxafD0PitIxhFzu7w+N5/HlaM8PLcI4=; b=DZaL1Nev9UCpC1a6zfgIKI67l7ery4TOMascHT6TEKKo99B18ZveVP/K0fYFQ8S6b6 /yKj58+9slVW6hXFW6abvbOJORZuNUGi3wpBuBPkcoBdbvRkvJ7mQEsJjYytb7ug1jR4 mwQ1AAy6i3QYd11/IeKjdacEHaiyT+jdZ2xkeHzuogr30Kh2Jr7U3ZFWJ83LcImjfnpB B3F0Uod6lJUBPW6dZ72LIzOhQy3VCgX634IrzyaQwYYLuF2x99wRWRU+wjO3Qi9yDuKc rNyX3S8RT7LgoTucwhP+8QFS827QwJIxAtCFm99+6ZgauuxG1tRmDXwBxo7NCm6/GNeh cS/w== X-Gm-Message-State: AFqh2kp3HXOg1FNvboGbeq7A9YzD6FO9Zkz4KaSs3Wq9mT2ibiq560rY F9ip0+1aR5nrZuSzS5ipYXs= X-Received: by 2002:a05:600c:2247:b0:3d3:4b1a:6ff9 with SMTP id a7-20020a05600c224700b003d34b1a6ff9mr45128622wmm.26.1673215026538; Sun, 08 Jan 2023 13:57:06 -0800 (PST) Received: from localhost.localdomain ([2a10:d582:3bb:0:63f8:f640:f53e:dd47]) by smtp.gmail.com with ESMTPSA id h15-20020a05600c314f00b003d99469ece1sm14654071wmo.24.2023.01.08.13.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 13:57:06 -0800 (PST) From: Sudip Mukherjee To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, "Maciej W. Rozycki" , Sudip Mukherjee Subject: [PATCH 2/7] parport_pc: Let chipset drivers mask unsupported modes Date: Sun, 8 Jan 2023 21:56:51 +0000 Message-Id: <20230108215656.6433-2-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230108215656.6433-1-sudipm.mukherjee@gmail.com> References: <20230108215656.6433-1-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1754493299276059601?= X-GMAIL-MSGID: =?utf-8?q?1754493299276059601?= From: "Maciej W. Rozycki" Rename `parport_pc_probe_port' to `__parport_pc_probe_port' and add a `mode_mask' parameter so that callers can specify a mask of unsupported modes to exclude even if mode probing seems to indicate otherwise. Add a `parport_pc_probe_port' wrapper with an implicit mask of 0 for the current callers to use. No functional change at this point, but the configuration of data write handlers is now no longer intertwined with determination and reporting of available modes. Signed-off-by: Maciej W. Rozycki Signed-off-by: Sudip Mukherjee --- drivers/parport/parport_pc.c | 45 ++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index de7afbea96cd..9daaaaa305e6 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -2000,11 +2000,12 @@ static int parport_dma_probe(struct parport *p) static LIST_HEAD(ports_list); static DEFINE_SPINLOCK(ports_lock); -struct parport *parport_pc_probe_port(unsigned long int base, - unsigned long int base_hi, - int irq, int dma, - struct device *dev, - int irqflags) +static struct parport *__parport_pc_probe_port(unsigned long int base, + unsigned long int base_hi, + int irq, int dma, + struct device *dev, + int irqflags, + unsigned int mode_mask) { struct parport_pc_private *priv; struct parport_operations *ops; @@ -2116,18 +2117,28 @@ struct parport *parport_pc_probe_port(unsigned long int base, p->dma != PARPORT_DMA_NOFIFO && priv->fifo_depth > 0 && p->irq != PARPORT_IRQ_NONE) { p->modes |= PARPORT_MODE_ECP | PARPORT_MODE_COMPAT; + if (p->dma != PARPORT_DMA_NONE) + p->modes |= PARPORT_MODE_DMA; + } else + /* We can't use the DMA channel after all. */ + p->dma = PARPORT_DMA_NONE; +#endif /* Allowed to use FIFO/DMA */ + + p->modes &= ~mode_mask; + +#ifdef CONFIG_PARPORT_PC_FIFO + if ((p->modes & PARPORT_MODE_COMPAT) != 0) p->ops->compat_write_data = parport_pc_compat_write_block_pio; #ifdef CONFIG_PARPORT_1284 + if ((p->modes & PARPORT_MODE_ECP) != 0) p->ops->ecp_write_data = parport_pc_ecp_write_block_pio; -#endif /* IEEE 1284 support */ - if (p->dma != PARPORT_DMA_NONE) { +#endif + if ((p->modes & (PARPORT_MODE_ECP | PARPORT_MODE_COMPAT)) != 0) { + if ((p->modes & PARPORT_MODE_DMA) != 0) pr_cont(", dma %d", p->dma); - p->modes |= PARPORT_MODE_DMA; - } else + else pr_cont(", using FIFO"); - } else - /* We can't use the DMA channel after all. */ - p->dma = PARPORT_DMA_NONE; + } #endif /* Allowed to use FIFO/DMA */ pr_cont(" ["); @@ -2237,6 +2248,16 @@ do { \ platform_device_unregister(pdev); return NULL; } + +struct parport *parport_pc_probe_port(unsigned long int base, + unsigned long int base_hi, + int irq, int dma, + struct device *dev, + int irqflags) +{ + return __parport_pc_probe_port(base, base_hi, irq, dma, + dev, irqflags, 0); +} EXPORT_SYMBOL(parport_pc_probe_port); void parport_pc_unregister_port(struct parport *p)