diff mbox series

[RFC,16/32] misc: handle HAS_IOPORT dependencies

Message ID 20211227164317.4146918-17-schnelle@linux.ibm.com (mailing list archive)
State Not Applicable
Delegated to: Bjorn Helgaas
Headers show
Series Kconfig: Introduce HAS_IOPORT and LEGACY_PCI options | expand

Commit Message

Niklas Schnelle Dec. 27, 2021, 4:43 p.m. UTC
In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
not being declared. We thus need to add HAS_IOPORT as dependency for
those drivers using them.

Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
 drivers/misc/altera-stapl/Makefile | 3 ++-
 drivers/misc/altera-stapl/altera.c | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Greg KH Dec. 28, 2021, 8:15 a.m. UTC | #1
On Mon, Dec 27, 2021 at 05:43:01PM +0100, Niklas Schnelle wrote:
> In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
> not being declared. We thus need to add HAS_IOPORT as dependency for
> those drivers using them.
> 
> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
>  drivers/misc/altera-stapl/Makefile | 3 ++-
>  drivers/misc/altera-stapl/altera.c | 6 +++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/altera-stapl/Makefile b/drivers/misc/altera-stapl/Makefile
> index dd0f8189666b..90f18e7bf9b0 100644
> --- a/drivers/misc/altera-stapl/Makefile
> +++ b/drivers/misc/altera-stapl/Makefile
> @@ -1,4 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -altera-stapl-objs = altera-lpt.o altera-jtag.o altera-comp.o altera.o
> +altera-stapl-y = altera-jtag.o altera-comp.o altera.o
> +altera-stapl-$(CONFIG_HAS_IOPORT) += altera-lpt.o
>  
>  obj-$(CONFIG_ALTERA_STAPL) += altera-stapl.o
> diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c
> index 92c0611034b0..c7ae64de8bb4 100644
> --- a/drivers/misc/altera-stapl/altera.c
> +++ b/drivers/misc/altera-stapl/altera.c
> @@ -2431,6 +2431,10 @@ int altera_init(struct altera_config *config, const struct firmware *fw)
>  
>  	astate->config = config;
>  	if (!astate->config->jtag_io) {
> +		if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
> +			retval = -ENODEV;
> +			goto free_state;
> +		}

A comment as to why you are doing this check here would be nice, as it
is not obvious at all what is going on.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/misc/altera-stapl/Makefile b/drivers/misc/altera-stapl/Makefile
index dd0f8189666b..90f18e7bf9b0 100644
--- a/drivers/misc/altera-stapl/Makefile
+++ b/drivers/misc/altera-stapl/Makefile
@@ -1,4 +1,5 @@ 
 # SPDX-License-Identifier: GPL-2.0-only
-altera-stapl-objs = altera-lpt.o altera-jtag.o altera-comp.o altera.o
+altera-stapl-y = altera-jtag.o altera-comp.o altera.o
+altera-stapl-$(CONFIG_HAS_IOPORT) += altera-lpt.o
 
 obj-$(CONFIG_ALTERA_STAPL) += altera-stapl.o
diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c
index 92c0611034b0..c7ae64de8bb4 100644
--- a/drivers/misc/altera-stapl/altera.c
+++ b/drivers/misc/altera-stapl/altera.c
@@ -2431,6 +2431,10 @@  int altera_init(struct altera_config *config, const struct firmware *fw)
 
 	astate->config = config;
 	if (!astate->config->jtag_io) {
+		if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
+			retval = -ENODEV;
+			goto free_state;
+		}
 		dprintk("%s: using byteblaster!\n", __func__);
 		astate->config->jtag_io = netup_jtag_io_lpt;
 	}
@@ -2505,7 +2509,7 @@  int altera_init(struct altera_config *config, const struct firmware *fw)
 
 	} else if (exec_result)
 		printk(KERN_ERR "%s: error %d\n", __func__, exec_result);
-
+free_state:
 	kfree(astate);
 free_value:
 	kfree(value);