[PATCH] pcmcia: remove PCCARD_IODYN

Lukas Bulwahn posted 1 patch 3 months, 1 week ago
drivers/pcmcia/Kconfig      |   3 -
drivers/pcmcia/Makefile     |   1 -
drivers/pcmcia/rsrc_iodyn.c | 168 ------------------------------------
include/pcmcia/ss.h         |   8 +-
4 files changed, 1 insertion(+), 179 deletions(-)
delete mode 100644 drivers/pcmcia/rsrc_iodyn.c
[PATCH] pcmcia: remove PCCARD_IODYN
Posted by Lukas Bulwahn 3 months, 1 week ago
From: Lukas Bulwahn <lukas.bulwahn@redhat.com>

The config PCCARD_IODYN was last used in the config option PCMCIA_M8XX with
its m8xx_pcmcia driver. This driver was removed with commit 39eb56da2b53
("pcmcia: Remove m8xx_pcmcia driver"), included in v3.17, back in 2014.
Since then, the config PCCARD_IODYN is unused. Remove the config option,
the corresponding file included with this config and the corresponding
definition in the pcmcia header file.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@redhat.com>
---
 drivers/pcmcia/Kconfig      |   3 -
 drivers/pcmcia/Makefile     |   1 -
 drivers/pcmcia/rsrc_iodyn.c | 168 ------------------------------------
 include/pcmcia/ss.h         |   8 +-
 4 files changed, 1 insertion(+), 179 deletions(-)
 delete mode 100644 drivers/pcmcia/rsrc_iodyn.c

diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index dddb235dd020..660a95805524 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -250,7 +250,4 @@ config ELECTRA_CF
 config PCCARD_NONSTATIC
 	bool
 
-config PCCARD_IODYN
-	bool
-
 endif	# PCCARD
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index c9d51b150682..d16a0317ce43 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -12,7 +12,6 @@ obj-$(CONFIG_PCMCIA)				+= pcmcia.o
 
 pcmcia_rsrc-y					+= rsrc_mgr.o
 pcmcia_rsrc-$(CONFIG_PCCARD_NONSTATIC)		+= rsrc_nonstatic.o
-pcmcia_rsrc-$(CONFIG_PCCARD_IODYN)		+= rsrc_iodyn.o
 obj-$(CONFIG_PCCARD)				+= pcmcia_rsrc.o
 
 
diff --git a/drivers/pcmcia/rsrc_iodyn.c b/drivers/pcmcia/rsrc_iodyn.c
deleted file mode 100644
index b04b16496b0c..000000000000
--- a/drivers/pcmcia/rsrc_iodyn.c
+++ /dev/null
@@ -1,168 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * rsrc_iodyn.c -- Resource management routines for MEM-static sockets.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
- *
- * (C) 1999		David A. Hinds
- */
-
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-
-#include <pcmcia/ss.h>
-#include <pcmcia/cistpl.h>
-#include "cs_internal.h"
-
-
-struct pcmcia_align_data {
-	unsigned long	mask;
-	unsigned long	offset;
-};
-
-static resource_size_t pcmcia_align(void *align_data,
-				const struct resource *res,
-				resource_size_t size, resource_size_t align)
-{
-	struct pcmcia_align_data *data = align_data;
-	resource_size_t start;
-
-	start = (res->start & ~data->mask) + data->offset;
-	if (start < res->start)
-		start += data->mask + 1;
-
-#ifdef CONFIG_X86
-	if (res->flags & IORESOURCE_IO) {
-		if (start & 0x300)
-			start = (start + 0x3ff) & ~0x3ff;
-	}
-#endif
-
-#ifdef CONFIG_M68K
-	if (res->flags & IORESOURCE_IO) {
-		if ((res->start + size - 1) >= 1024)
-			start = res->end;
-	}
-#endif
-
-	return start;
-}
-
-
-static struct resource *__iodyn_find_io_region(struct pcmcia_socket *s,
-					unsigned long base, int num,
-					unsigned long align)
-{
-	struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_IO,
-						dev_name(&s->dev));
-	struct pcmcia_align_data data;
-	unsigned long min = base;
-	int ret;
-
-	data.mask = align - 1;
-	data.offset = base & data.mask;
-
-#ifdef CONFIG_PCI
-	if (s->cb_dev) {
-		ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
-					     min, 0, pcmcia_align, &data);
-	} else
-#endif
-		ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
-					1, pcmcia_align, &data);
-
-	if (ret != 0) {
-		kfree(res);
-		res = NULL;
-	}
-	return res;
-}
-
-static int iodyn_find_io(struct pcmcia_socket *s, unsigned int attr,
-			unsigned int *base, unsigned int num,
-			unsigned int align, struct resource **parent)
-{
-	int i, ret = 0;
-
-	/* Check for an already-allocated window that must conflict with
-	 * what was asked for.  It is a hack because it does not catch all
-	 * potential conflicts, just the most obvious ones.
-	 */
-	for (i = 0; i < MAX_IO_WIN; i++) {
-		if (!s->io[i].res)
-			continue;
-
-		if (!*base)
-			continue;
-
-		if ((s->io[i].res->start & (align-1)) == *base)
-			return -EBUSY;
-	}
-
-	for (i = 0; i < MAX_IO_WIN; i++) {
-		struct resource *res = s->io[i].res;
-		unsigned int try;
-
-		if (res && (res->flags & IORESOURCE_BITS) !=
-			(attr & IORESOURCE_BITS))
-			continue;
-
-		if (!res) {
-			if (align == 0)
-				align = 0x10000;
-
-			res = s->io[i].res = __iodyn_find_io_region(s, *base,
-								num, align);
-			if (!res)
-				return -EINVAL;
-
-			*base = res->start;
-			s->io[i].res->flags =
-				((res->flags & ~IORESOURCE_BITS) |
-					(attr & IORESOURCE_BITS));
-			s->io[i].InUse = num;
-			*parent = res;
-			return 0;
-		}
-
-		/* Try to extend top of window */
-		try = res->end + 1;
-		if ((*base == 0) || (*base == try)) {
-			if (adjust_resource(s->io[i].res, res->start,
-					    resource_size(res) + num))
-				continue;
-			*base = try;
-			s->io[i].InUse += num;
-			*parent = res;
-			return 0;
-		}
-
-		/* Try to extend bottom of window */
-		try = res->start - num;
-		if ((*base == 0) || (*base == try)) {
-			if (adjust_resource(s->io[i].res,
-					    res->start - num,
-					    resource_size(res) + num))
-				continue;
-			*base = try;
-			s->io[i].InUse += num;
-			*parent = res;
-			return 0;
-		}
-	}
-
-	return -EINVAL;
-}
-
-
-struct pccard_resource_ops pccard_iodyn_ops = {
-	.validate_mem = NULL,
-	.find_io = iodyn_find_io,
-	.find_mem = NULL,
-	.init = static_init,
-	.exit = NULL,
-};
-EXPORT_SYMBOL(pccard_iodyn_ops);
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 7cf7dbbfa131..89aed99bfeae 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -227,12 +227,8 @@ struct pcmcia_socket {
 
 
 /* socket drivers must define the resource operations type they use. There
- * are three options:
+ * are two options:
  * - pccard_static_ops		iomem and ioport areas are assigned statically
- * - pccard_iodyn_ops		iomem areas is assigned statically, ioport
- *				areas dynamically
- *				If this option is selected, use
- *				"select PCCARD_IODYN" in Kconfig.
  * - pccard_nonstatic_ops	iomem and ioport areas are assigned dynamically.
  *				If this option is selected, use
  *				"select PCCARD_NONSTATIC" in Kconfig.
@@ -240,13 +236,11 @@ struct pcmcia_socket {
  */
 extern struct pccard_resource_ops pccard_static_ops;
 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
-extern struct pccard_resource_ops pccard_iodyn_ops;
 extern struct pccard_resource_ops pccard_nonstatic_ops;
 #else
 /* If PCMCIA is not used, but only CARDBUS, these functions are not used
  * at all. Therefore, do not use the large (240K!) rsrc_nonstatic module
  */
-#define pccard_iodyn_ops pccard_static_ops
 #define pccard_nonstatic_ops pccard_static_ops
 #endif
 
-- 
2.50.0
Re: [PATCH] pcmcia: remove PCCARD_IODYN
Posted by Dominik Brodowski 1 month, 3 weeks ago
Applied to pcmcia-next.

Thanks,
	Dominik

Am Mon, Jun 30, 2025 at 11:32:56AM +0200 schrieb Lukas Bulwahn:
> From: Lukas Bulwahn <lukas.bulwahn@redhat.com>
> 
> The config PCCARD_IODYN was last used in the config option PCMCIA_M8XX with
> its m8xx_pcmcia driver. This driver was removed with commit 39eb56da2b53
> ("pcmcia: Remove m8xx_pcmcia driver"), included in v3.17, back in 2014.
> Since then, the config PCCARD_IODYN is unused. Remove the config option,
> the corresponding file included with this config and the corresponding
> definition in the pcmcia header file.
> 
> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@redhat.com>
> ---
>  drivers/pcmcia/Kconfig      |   3 -
>  drivers/pcmcia/Makefile     |   1 -
>  drivers/pcmcia/rsrc_iodyn.c | 168 ------------------------------------
>  include/pcmcia/ss.h         |   8 +-
>  4 files changed, 1 insertion(+), 179 deletions(-)
>  delete mode 100644 drivers/pcmcia/rsrc_iodyn.c
> 
> diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
> index dddb235dd020..660a95805524 100644
> --- a/drivers/pcmcia/Kconfig
> +++ b/drivers/pcmcia/Kconfig
> @@ -250,7 +250,4 @@ config ELECTRA_CF
>  config PCCARD_NONSTATIC
>  	bool
>  
> -config PCCARD_IODYN
> -	bool
> -
>  endif	# PCCARD
> diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
> index c9d51b150682..d16a0317ce43 100644
> --- a/drivers/pcmcia/Makefile
> +++ b/drivers/pcmcia/Makefile
> @@ -12,7 +12,6 @@ obj-$(CONFIG_PCMCIA)				+= pcmcia.o
>  
>  pcmcia_rsrc-y					+= rsrc_mgr.o
>  pcmcia_rsrc-$(CONFIG_PCCARD_NONSTATIC)		+= rsrc_nonstatic.o
> -pcmcia_rsrc-$(CONFIG_PCCARD_IODYN)		+= rsrc_iodyn.o
>  obj-$(CONFIG_PCCARD)				+= pcmcia_rsrc.o
>  
>  
> diff --git a/drivers/pcmcia/rsrc_iodyn.c b/drivers/pcmcia/rsrc_iodyn.c
> deleted file mode 100644
> index b04b16496b0c..000000000000
> --- a/drivers/pcmcia/rsrc_iodyn.c
> +++ /dev/null
> @@ -1,168 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * rsrc_iodyn.c -- Resource management routines for MEM-static sockets.
> - *
> - * The initial developer of the original code is David A. Hinds
> - * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
> - * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
> - *
> - * (C) 1999		David A. Hinds
> - */
> -
> -#include <linux/slab.h>
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -
> -#include <pcmcia/ss.h>
> -#include <pcmcia/cistpl.h>
> -#include "cs_internal.h"
> -
> -
> -struct pcmcia_align_data {
> -	unsigned long	mask;
> -	unsigned long	offset;
> -};
> -
> -static resource_size_t pcmcia_align(void *align_data,
> -				const struct resource *res,
> -				resource_size_t size, resource_size_t align)
> -{
> -	struct pcmcia_align_data *data = align_data;
> -	resource_size_t start;
> -
> -	start = (res->start & ~data->mask) + data->offset;
> -	if (start < res->start)
> -		start += data->mask + 1;
> -
> -#ifdef CONFIG_X86
> -	if (res->flags & IORESOURCE_IO) {
> -		if (start & 0x300)
> -			start = (start + 0x3ff) & ~0x3ff;
> -	}
> -#endif
> -
> -#ifdef CONFIG_M68K
> -	if (res->flags & IORESOURCE_IO) {
> -		if ((res->start + size - 1) >= 1024)
> -			start = res->end;
> -	}
> -#endif
> -
> -	return start;
> -}
> -
> -
> -static struct resource *__iodyn_find_io_region(struct pcmcia_socket *s,
> -					unsigned long base, int num,
> -					unsigned long align)
> -{
> -	struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_IO,
> -						dev_name(&s->dev));
> -	struct pcmcia_align_data data;
> -	unsigned long min = base;
> -	int ret;
> -
> -	data.mask = align - 1;
> -	data.offset = base & data.mask;
> -
> -#ifdef CONFIG_PCI
> -	if (s->cb_dev) {
> -		ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
> -					     min, 0, pcmcia_align, &data);
> -	} else
> -#endif
> -		ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
> -					1, pcmcia_align, &data);
> -
> -	if (ret != 0) {
> -		kfree(res);
> -		res = NULL;
> -	}
> -	return res;
> -}
> -
> -static int iodyn_find_io(struct pcmcia_socket *s, unsigned int attr,
> -			unsigned int *base, unsigned int num,
> -			unsigned int align, struct resource **parent)
> -{
> -	int i, ret = 0;
> -
> -	/* Check for an already-allocated window that must conflict with
> -	 * what was asked for.  It is a hack because it does not catch all
> -	 * potential conflicts, just the most obvious ones.
> -	 */
> -	for (i = 0; i < MAX_IO_WIN; i++) {
> -		if (!s->io[i].res)
> -			continue;
> -
> -		if (!*base)
> -			continue;
> -
> -		if ((s->io[i].res->start & (align-1)) == *base)
> -			return -EBUSY;
> -	}
> -
> -	for (i = 0; i < MAX_IO_WIN; i++) {
> -		struct resource *res = s->io[i].res;
> -		unsigned int try;
> -
> -		if (res && (res->flags & IORESOURCE_BITS) !=
> -			(attr & IORESOURCE_BITS))
> -			continue;
> -
> -		if (!res) {
> -			if (align == 0)
> -				align = 0x10000;
> -
> -			res = s->io[i].res = __iodyn_find_io_region(s, *base,
> -								num, align);
> -			if (!res)
> -				return -EINVAL;
> -
> -			*base = res->start;
> -			s->io[i].res->flags =
> -				((res->flags & ~IORESOURCE_BITS) |
> -					(attr & IORESOURCE_BITS));
> -			s->io[i].InUse = num;
> -			*parent = res;
> -			return 0;
> -		}
> -
> -		/* Try to extend top of window */
> -		try = res->end + 1;
> -		if ((*base == 0) || (*base == try)) {
> -			if (adjust_resource(s->io[i].res, res->start,
> -					    resource_size(res) + num))
> -				continue;
> -			*base = try;
> -			s->io[i].InUse += num;
> -			*parent = res;
> -			return 0;
> -		}
> -
> -		/* Try to extend bottom of window */
> -		try = res->start - num;
> -		if ((*base == 0) || (*base == try)) {
> -			if (adjust_resource(s->io[i].res,
> -					    res->start - num,
> -					    resource_size(res) + num))
> -				continue;
> -			*base = try;
> -			s->io[i].InUse += num;
> -			*parent = res;
> -			return 0;
> -		}
> -	}
> -
> -	return -EINVAL;
> -}
> -
> -
> -struct pccard_resource_ops pccard_iodyn_ops = {
> -	.validate_mem = NULL,
> -	.find_io = iodyn_find_io,
> -	.find_mem = NULL,
> -	.init = static_init,
> -	.exit = NULL,
> -};
> -EXPORT_SYMBOL(pccard_iodyn_ops);
> diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
> index 7cf7dbbfa131..89aed99bfeae 100644
> --- a/include/pcmcia/ss.h
> +++ b/include/pcmcia/ss.h
> @@ -227,12 +227,8 @@ struct pcmcia_socket {
>  
>  
>  /* socket drivers must define the resource operations type they use. There
> - * are three options:
> + * are two options:
>   * - pccard_static_ops		iomem and ioport areas are assigned statically
> - * - pccard_iodyn_ops		iomem areas is assigned statically, ioport
> - *				areas dynamically
> - *				If this option is selected, use
> - *				"select PCCARD_IODYN" in Kconfig.
>   * - pccard_nonstatic_ops	iomem and ioport areas are assigned dynamically.
>   *				If this option is selected, use
>   *				"select PCCARD_NONSTATIC" in Kconfig.
> @@ -240,13 +236,11 @@ struct pcmcia_socket {
>   */
>  extern struct pccard_resource_ops pccard_static_ops;
>  #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
> -extern struct pccard_resource_ops pccard_iodyn_ops;
>  extern struct pccard_resource_ops pccard_nonstatic_ops;
>  #else
>  /* If PCMCIA is not used, but only CARDBUS, these functions are not used
>   * at all. Therefore, do not use the large (240K!) rsrc_nonstatic module
>   */
> -#define pccard_iodyn_ops pccard_static_ops
>  #define pccard_nonstatic_ops pccard_static_ops
>  #endif
>  
> -- 
> 2.50.0
> 
>