2021-12-27 16:44:42

by Niklas Schnelle

[permalink] [raw]
Subject: [RFC 16/32] misc: handle HAS_IOPORT dependencies

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 <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Niklas Schnelle <[email protected]>
---
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;
+ }
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);
--
2.32.0



2021-12-28 08:15:20

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [RFC 16/32] misc: handle HAS_IOPORT dependencies

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 <[email protected]>
> Signed-off-by: Arnd Bergmann <[email protected]>
> Signed-off-by: Niklas Schnelle <[email protected]>
> ---
> 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