pcmcia: avoid defines prefixed with CONFIG

Message ID n-Xd5VZl4mxdBIPvH-LgdDqAi8N9cL3TiAQ6fKEOpXLKsyDAxcf9VWQZfnMobTdIXucJJ1U2B82W6KhoODwWr_n3d-V9YkDcV92AjzxMrys=@n8pjl.ca
State New
Headers
Series pcmcia: avoid defines prefixed with CONFIG |

Commit Message

Peter Lafreniere Jan. 13, 2023, 3:30 p.m. UTC
  Macros prefixed with "CONFIG_" should be relegated to Kconfig switches,
so we should change the config state flags to avoid conflicts.

This change affects only code readability, not function.

Signed-off-by: Peter Lafreniere <peter@n8pjl.ca>
---
 drivers/pcmcia/cs_internal.h     |  6 +++---
 drivers/pcmcia/pcmcia_resource.c | 26 +++++++++++++-------------
 2 files changed, 16 insertions(+), 16 deletions(-)
  

Comments

Lukas Bulwahn Jan. 16, 2023, 7:41 a.m. UTC | #1
On Fri, Jan 13, 2023 at 4:30 PM Peter Lafreniere <peter@n8pjl.ca> wrote:
>
> Macros prefixed with "CONFIG_" should be relegated to Kconfig switches,
> so we should change the config state flags to avoid conflicts.
>
> This change affects only code readability, not function.
>
> Signed-off-by: Peter Lafreniere <peter@n8pjl.ca>
> ---

Thanks for supporting the effort of the clean-up on removing CONFIG
definitions that are not Kconfig options. Those three instances are
all instances in drivers/pcmcia/ that the
./scripts/checkkconfigsymbols.py points out. So that addresses yet
another subsystem that is cleaned up. Renaming the defines is a good
solution for these three instances.

Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>

Lukas

>  drivers/pcmcia/cs_internal.h     |  6 +++---
>  drivers/pcmcia/pcmcia_resource.c | 26 +++++++++++++-------------
>  2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
> index 580369f3c0b0..95df616fb0a4 100644
> --- a/drivers/pcmcia/cs_internal.h
> +++ b/drivers/pcmcia/cs_internal.h
> @@ -59,9 +59,9 @@ struct pccard_resource_ops {
>  };
>
>  /* Flags in config state */
> -#define CONFIG_LOCKED          0x01
> -#define CONFIG_IRQ_REQ         0x02
> -#define CONFIG_IO_REQ          0x04
> +#define CFG_LOCKED             0x01
> +#define CFG_IRQ_REQ            0x02
> +#define CFG_IO_REQ             0x04
>
>  /* Flags in socket state */
>  #define SOCKET_PRESENT         0x0008
> diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
> index d78091e79a0f..d559977b9332 100644
> --- a/drivers/pcmcia/pcmcia_resource.c
> +++ b/drivers/pcmcia/pcmcia_resource.c
> @@ -168,7 +168,7 @@ static int pcmcia_access_config(struct pcmcia_device *p_dev,
>         mutex_lock(&s->ops_mutex);
>         c = p_dev->function_config;
>
> -       if (!(c->state & CONFIG_LOCKED)) {
> +       if (!(c->state & CFG_LOCKED)) {
>                 dev_dbg(&p_dev->dev, "Configuration isn't locked\n");
>                 mutex_unlock(&s->ops_mutex);
>                 return -EACCES;
> @@ -262,7 +262,7 @@ int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev)
>         dev_dbg(&p_dev->dev, "fixup iowidth to 8bit\n");
>
>         if (!(s->state & SOCKET_PRESENT) ||
> -               !(p_dev->function_config->state & CONFIG_LOCKED)) {
> +               !(p_dev->function_config->state & CFG_LOCKED)) {
>                 dev_dbg(&p_dev->dev, "No card? Config not locked?\n");
>                 ret = -EACCES;
>                 goto unlock;
> @@ -310,7 +310,7 @@ int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp)
>         dev_dbg(&p_dev->dev, "fixup Vpp to %d\n", new_vpp);
>
>         if (!(s->state & SOCKET_PRESENT) ||
> -               !(p_dev->function_config->state & CONFIG_LOCKED)) {
> +               !(p_dev->function_config->state & CFG_LOCKED)) {
>                 dev_dbg(&p_dev->dev, "No card? Config not locked?\n");
>                 ret = -EACCES;
>                 goto unlock;
> @@ -361,9 +361,9 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
>                         s->ops->set_socket(s, &s->socket);
>                 }
>         }
> -       if (c->state & CONFIG_LOCKED) {
> -               c->state &= ~CONFIG_LOCKED;
> -               if (c->state & CONFIG_IO_REQ)
> +       if (c->state & CFG_LOCKED) {
> +               c->state &= ~CFG_LOCKED;
> +               if (c->state & CFG_IO_REQ)
>                         for (i = 0; i < MAX_IO_WIN; i++) {
>                                 if (!s->io[i].res)
>                                         continue;
> @@ -407,7 +407,7 @@ static void pcmcia_release_io(struct pcmcia_device *p_dev)
>                 release_io_space(s, &c->io[1]);
>
>         p_dev->_io = 0;
> -       c->state &= ~CONFIG_IO_REQ;
> +       c->state &= ~CFG_IO_REQ;
>
>  out:
>         mutex_unlock(&s->ops_mutex);
> @@ -491,7 +491,7 @@ int pcmcia_enable_device(struct pcmcia_device *p_dev)
>
>         mutex_lock(&s->ops_mutex);
>         c = p_dev->function_config;
> -       if (c->state & CONFIG_LOCKED) {
> +       if (c->state & CFG_LOCKED) {
>                 mutex_unlock(&s->ops_mutex);
>                 dev_dbg(&p_dev->dev, "Configuration is locked\n");
>                 return -EACCES;
> @@ -581,7 +581,7 @@ int pcmcia_enable_device(struct pcmcia_device *p_dev)
>         }
>
>         /* Configure I/O windows */
> -       if (c->state & CONFIG_IO_REQ) {
> +       if (c->state & CFG_IO_REQ) {
>                 iomap.speed = io_speed;
>                 for (i = 0; i < MAX_IO_WIN; i++)
>                         if (s->io[i].res) {
> @@ -602,7 +602,7 @@ int pcmcia_enable_device(struct pcmcia_device *p_dev)
>                         }
>         }
>
> -       c->state |= CONFIG_LOCKED;
> +       c->state |= CFG_LOCKED;
>         p_dev->_locked = 1;
>         mutex_unlock(&s->ops_mutex);
>         return 0;
> @@ -635,11 +635,11 @@ int pcmcia_request_io(struct pcmcia_device *p_dev)
>                 goto out;
>         }
>
> -       if (c->state & CONFIG_LOCKED) {
> +       if (c->state & CFG_LOCKED) {
>                 dev_dbg(&p_dev->dev, "Configuration is locked\n");
>                 goto out;
>         }
> -       if (c->state & CONFIG_IO_REQ) {
> +       if (c->state & CFG_IO_REQ) {
>                 dev_dbg(&p_dev->dev, "IO already configured\n");
>                 goto out;
>         }
> @@ -663,7 +663,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev)
>         } else
>                 c->io[1].start = 0;
>
> -       c->state |= CONFIG_IO_REQ;
> +       c->state |= CFG_IO_REQ;
>         p_dev->_io = 1;
>
>         dev_dbg(&p_dev->dev, "pcmcia_request_io succeeded: %pR , %pR",
> --
> 2.39.0
>
  
Lukas Bulwahn Jan. 16, 2023, 7:48 a.m. UTC | #2
On Fri, Jan 13, 2023 at 4:30 PM Peter Lafreniere <peter@n8pjl.ca> wrote:
>
> Macros prefixed with "CONFIG_" should be relegated to Kconfig switches,
> so we should change the config state flags to avoid conflicts.
>
> This change affects only code readability, not function.
>

Peter,

If you are interested in doing more clean-up work in this area, please
let me know. I have a longer patch series of various changes that have
been partially submitted and have not been included yet and some
changes I have not sent yet, as they are really minor spelling fixes
in comments. Further, I have a list of known false positives from the
./scripts/checkkconfigsymbols.py warnings, which you can use to filter
out some of the warnings, and some experience on this script to find
what is more relevant to address first and what could go to the
low-priority TODO list (that just might disappear, as old code is
completely deleted).

I can share all that with you if you just give me a ping.

Best regards,

Lukas
  
Peter Lafreniere Jan. 16, 2023, 1:23 p.m. UTC | #3
> Peter,
> 
> If you are interested in doing more clean-up work in this area, please
> let me know. I have a longer patch series of various changes that have
> been partially submitted and have not been included yet and some
> changes I have not sent yet, as they are really minor spelling fixes
> in comments. Further, I have a list of known false positives from the
> ./scripts/checkkconfigsymbols.py warnings, which you can use to filter
> out some of the warnings, and some experience on this script to find
> what is more relevant to address first and what could go to the
> low-priority TODO list (that just might disappear, as old code is
> completely deleted).
> 
> I can share all that with you if you just give me a ping.

Why not? I wouldn't mind helping with this effort.

> Best regards,
> 
> Lukas

Cheers,
Peter
  

Patch

diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 580369f3c0b0..95df616fb0a4 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -59,9 +59,9 @@  struct pccard_resource_ops {
 };
 
 /* Flags in config state */
-#define CONFIG_LOCKED		0x01
-#define CONFIG_IRQ_REQ		0x02
-#define CONFIG_IO_REQ		0x04
+#define CFG_LOCKED		0x01
+#define CFG_IRQ_REQ		0x02
+#define CFG_IO_REQ		0x04
 
 /* Flags in socket state */
 #define SOCKET_PRESENT		0x0008
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index d78091e79a0f..d559977b9332 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -168,7 +168,7 @@  static int pcmcia_access_config(struct pcmcia_device *p_dev,
 	mutex_lock(&s->ops_mutex);
 	c = p_dev->function_config;
 
-	if (!(c->state & CONFIG_LOCKED)) {
+	if (!(c->state & CFG_LOCKED)) {
 		dev_dbg(&p_dev->dev, "Configuration isn't locked\n");
 		mutex_unlock(&s->ops_mutex);
 		return -EACCES;
@@ -262,7 +262,7 @@  int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev)
 	dev_dbg(&p_dev->dev, "fixup iowidth to 8bit\n");
 
 	if (!(s->state & SOCKET_PRESENT) ||
-		!(p_dev->function_config->state & CONFIG_LOCKED)) {
+		!(p_dev->function_config->state & CFG_LOCKED)) {
 		dev_dbg(&p_dev->dev, "No card? Config not locked?\n");
 		ret = -EACCES;
 		goto unlock;
@@ -310,7 +310,7 @@  int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp)
 	dev_dbg(&p_dev->dev, "fixup Vpp to %d\n", new_vpp);
 
 	if (!(s->state & SOCKET_PRESENT) ||
-		!(p_dev->function_config->state & CONFIG_LOCKED)) {
+		!(p_dev->function_config->state & CFG_LOCKED)) {
 		dev_dbg(&p_dev->dev, "No card? Config not locked?\n");
 		ret = -EACCES;
 		goto unlock;
@@ -361,9 +361,9 @@  int pcmcia_release_configuration(struct pcmcia_device *p_dev)
 			s->ops->set_socket(s, &s->socket);
 		}
 	}
-	if (c->state & CONFIG_LOCKED) {
-		c->state &= ~CONFIG_LOCKED;
-		if (c->state & CONFIG_IO_REQ)
+	if (c->state & CFG_LOCKED) {
+		c->state &= ~CFG_LOCKED;
+		if (c->state & CFG_IO_REQ)
 			for (i = 0; i < MAX_IO_WIN; i++) {
 				if (!s->io[i].res)
 					continue;
@@ -407,7 +407,7 @@  static void pcmcia_release_io(struct pcmcia_device *p_dev)
 		release_io_space(s, &c->io[1]);
 
 	p_dev->_io = 0;
-	c->state &= ~CONFIG_IO_REQ;
+	c->state &= ~CFG_IO_REQ;
 
 out:
 	mutex_unlock(&s->ops_mutex);
@@ -491,7 +491,7 @@  int pcmcia_enable_device(struct pcmcia_device *p_dev)
 
 	mutex_lock(&s->ops_mutex);
 	c = p_dev->function_config;
-	if (c->state & CONFIG_LOCKED) {
+	if (c->state & CFG_LOCKED) {
 		mutex_unlock(&s->ops_mutex);
 		dev_dbg(&p_dev->dev, "Configuration is locked\n");
 		return -EACCES;
@@ -581,7 +581,7 @@  int pcmcia_enable_device(struct pcmcia_device *p_dev)
 	}
 
 	/* Configure I/O windows */
-	if (c->state & CONFIG_IO_REQ) {
+	if (c->state & CFG_IO_REQ) {
 		iomap.speed = io_speed;
 		for (i = 0; i < MAX_IO_WIN; i++)
 			if (s->io[i].res) {
@@ -602,7 +602,7 @@  int pcmcia_enable_device(struct pcmcia_device *p_dev)
 			}
 	}
 
-	c->state |= CONFIG_LOCKED;
+	c->state |= CFG_LOCKED;
 	p_dev->_locked = 1;
 	mutex_unlock(&s->ops_mutex);
 	return 0;
@@ -635,11 +635,11 @@  int pcmcia_request_io(struct pcmcia_device *p_dev)
 		goto out;
 	}
 
-	if (c->state & CONFIG_LOCKED) {
+	if (c->state & CFG_LOCKED) {
 		dev_dbg(&p_dev->dev, "Configuration is locked\n");
 		goto out;
 	}
-	if (c->state & CONFIG_IO_REQ) {
+	if (c->state & CFG_IO_REQ) {
 		dev_dbg(&p_dev->dev, "IO already configured\n");
 		goto out;
 	}
@@ -663,7 +663,7 @@  int pcmcia_request_io(struct pcmcia_device *p_dev)
 	} else
 		c->io[1].start = 0;
 
-	c->state |= CONFIG_IO_REQ;
+	c->state |= CFG_IO_REQ;
 	p_dev->_io = 1;
 
 	dev_dbg(&p_dev->dev, "pcmcia_request_io succeeded: %pR , %pR",