Re: [PATCH v8 01/25] scsi/atari_scsi: Don't select CONFIG_NVRAM
Hi Finn, Am 26.12.2018 um 13:37 schrieb Finn Thain: On powerpc, setting CONFIG_NVRAM=n builds a kernel with no NVRAM support. Setting CONFIG_NVRAM=m enables the /dev/nvram misc device module without enabling NVRAM support in drivers. Setting CONFIG_NVRAM=y enables the misc device (built-in) and also enables NVRAM support in drivers. m68k shares the valkyriefb driver with powerpc, and since that driver uses NVRAM, it is affected by CONFIG_ATARI_SCSI, because of the use of "select NVRAM". Adopt the powerpc convention on m68k to avoid surprises. Signed-off-by: Finn Thain Tested-by: Christian T. Steigies Acked-by: Michael Schmitz --- This patch temporarily disables CONFIG_NVRAM on Atari, to prevent build failures when bisecting the rest of this patch series. It gets enabled again with the introduction of CONFIG_HAVE_ARCH_NVRAM_OPS, once the nvram_* global functions have been moved to an ops struct. --- drivers/char/Kconfig | 5 + drivers/scsi/Kconfig | 6 +++--- drivers/scsi/atari_scsi.c | 7 --- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 9d03b2ff5df6..5b54595dfe30 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -236,7 +236,7 @@ source "drivers/char/hw_random/Kconfig" config NVRAM tristate "/dev/nvram support" - depends on ATARI || X86 || GENERIC_NVRAM + depends on X86 || GENERIC_NVRAM ---help--- If you say Y here and create a character special file /dev/nvram with major number 10 and minor number 144 using mknod ("man mknod"), @@ -254,9 +254,6 @@ config NVRAM should NEVER idly tamper with it. See Ralf Brown's interrupt list for a guide to the use of CMOS bytes by your BIOS. - On Atari machines, /dev/nvram is always configured and does not need - to be selected. - To compile this driver as a module, choose M here: the module will be called nvram. diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 640cd1b31a18..924eb69e7fc4 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -1381,14 +1381,14 @@ config ATARI_SCSI tristate "Atari native SCSI support" depends on ATARI && SCSI select SCSI_SPI_ATTRS - select NVRAM ---help--- If you have an Atari with built-in NCR5380 SCSI controller (TT, Falcon, ...) say Y to get it supported. Of course also, if you have a compatible SCSI controller (e.g. for Medusa). - To compile this driver as a module, choose M here: the - module will be called atari_scsi. + To compile this driver as a module, choose M here: the module will + be called atari_scsi. If you also enable NVRAM support, the SCSI + host's ID is taken from the setting in TT RTC NVRAM. This driver supports both styles of NCR integration into the system: the TT style (separate DMA), and the Falcon style (via diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 89f5154c40b6..99e5729d910d 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -755,9 +755,10 @@ static int __init atari_scsi_probe(struct platform_device *pdev) if (ATARIHW_PRESENT(TT_SCSI) && setup_sg_tablesize >= 0) atari_scsi_template.sg_tablesize = setup_sg_tablesize; - if (setup_hostid >= 0) { + if (setup_hostid >= 0) atari_scsi_template.this_id = setup_hostid & 7; - } else { +#ifdef CONFIG_NVRAM + else /* Test if a host id is set in the NVRam */ if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) { unsigned char b = nvram_read_byte(16); @@ -768,7 +769,7 @@ static int __init atari_scsi_probe(struct platform_device *pdev) if (b & 0x80) atari_scsi_template.this_id = b & 7; } - } +#endif /* If running on a Falcon and if there's TT-Ram (i.e., more than one * memory block, since there's always ST-Ram in a Falcon), then
Re: [PATCH v8 01/25] scsi/atari_scsi: Don't select CONFIG_NVRAM
Hi Finn, Am 29.12.2018 um 15:34 schrieb Finn Thain: On Sat, 29 Dec 2018, Michael Schmitz wrote: IS_BUILTIN(CONFIG_NVRAM) is probably what Christophe really meant to suggest. Or (really going out on a limb here): IS_BUILTIN(CONFIG_NVRAM) || ( IS_MODULE(CONFIG_ATARI_SCSI) && IS_ENABLED(CONFIG_NVRAM) ) Not that I'd advocate that, for this series. Well, you are a maintainer for atari_scsi.c. Are you saying that you want IS_BUILTIN(CONFIG_NVRAM) used here instead of ifdef? No, just pointing out that there would be a way to avoid the ifdef without messing up driver behaviour. I'm fine with the ifdef - not least because it clearly eliminates code that would be unreachable. (On second thought - I don't want to speculate whether there's weird compiler options that could result in the nvram_check_checksum and nvram_read_bytes symbols to still be referenced in the final link, even though IS_BUILTIN(CONFIG_NVRAM) always evaluates to false. Best leave this as-is.) OTOH, if you approve of the existing patch, please send your acked-by. Of course - I'd seen Geert's acked-by on some of the patches and forgot to check which still required acks. Cheers, Michael
Re: [PATCH v8 01/25] scsi/atari_scsi: Don't select CONFIG_NVRAM
On Sat, 29 Dec 2018, Michael Schmitz wrote: > > IS_BUILTIN(CONFIG_NVRAM) is probably what Christophe really meant to suggest. > > Or (really going out on a limb here): > > IS_BUILTIN(CONFIG_NVRAM) || > ( IS_MODULE(CONFIG_ATARI_SCSI) && IS_ENABLED(CONFIG_NVRAM) ) > > Not that I'd advocate that, for this series. > Well, you are a maintainer for atari_scsi.c. Are you saying that you want IS_BUILTIN(CONFIG_NVRAM) used here instead of ifdef? OTOH, if you approve of the existing patch, please send your acked-by. -- > Cheers, > > Michael > > > >
Re: [PATCH v8 01/25] scsi/atari_scsi: Don't select CONFIG_NVRAM
Hi Finn, Am 29.12.2018 um 14:06 schrieb Finn Thain: On Fri, 28 Dec 2018, LEROY Christophe wrote: diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 89f5154c40b6..99e5729d910d 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -755,9 +755,10 @@ static int __init atari_scsi_probe(struct platform_device *pdev) if (ATARIHW_PRESENT(TT_SCSI) && setup_sg_tablesize >= 0) atari_scsi_template.sg_tablesize = setup_sg_tablesize; - if (setup_hostid >= 0) { + if (setup_hostid >= 0) atari_scsi_template.this_id = setup_hostid & 7; - } else { +#ifdef CONFIG_NVRAM + else Such ifdefs should be avoided in C files. It would be better to use } else if (IS_ENABLED(CONFIG_NVRAM)) { I don't like #ifdefs either. However, as the maintainer of this file, I am okay with this one. The old #ifdef CONFIG_NVRAM conditional compilation convention that gets used here and under drivers/video/fbdev could probably be improved upon but I consider this to be out-of-scope for this series, which is complicated enough. And as explained in the commit log, CONFIG_NVRAM=y and CONFIG_NVRAM=m are treaded differently by drivers. Therefore, IS_ENABLED would be incorrect. IS_BUILTIN(CONFIG_NVRAM) is probably what Christophe really meant to suggest. Or (really going out on a limb here): IS_BUILTIN(CONFIG_NVRAM) || ( IS_MODULE(CONFIG_ATARI_SCSI) && IS_ENABLED(CONFIG_NVRAM) ) Not that I'd advocate that, for this series. Cheers, Michael
Re: [PATCH v8 02/25] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c
On Fri, 28 Dec 2018, LEROY Christophe wrote: > Finn Thain a ?crit?: > > > Move the m68k-specific code out of the driver to make the driver generic. > > > > I've used 'SPDX-License-Identifier: GPL-2.0+' for the new file because the > > old file is covered by MODULE_LICENSE("GPL"). > > > > Signed-off-by: Finn Thain > > Tested-by: Christian T. Steigies > > Acked-by: Geert Uytterhoeven > > --- > > Changed since v7: > > - Added SPDX-License-Identifier. > > --- > > arch/m68k/atari/Makefile | 2 + > > arch/m68k/atari/nvram.c | 243 + > > drivers/char/nvram.c | 280 +-- > > 3 files changed, 280 insertions(+), 245 deletions(-) > > create mode 100644 arch/m68k/atari/nvram.c > > > > diff --git a/arch/m68k/atari/Makefile b/arch/m68k/atari/Makefile > > index 0cac723306f9..0b86bb6cfa87 100644 > > --- a/arch/m68k/atari/Makefile > > +++ b/arch/m68k/atari/Makefile > > @@ -6,3 +6,5 @@ obj-y := config.o time.o debug.o ataints.o > > stdma.o \ > > atasound.o stram.o > > > > obj-$(CONFIG_ATARI_KBD_CORE) += atakeyb.o > > + > > +obj-$(CONFIG_NVRAM:m=y)+= nvram.o > > diff --git a/arch/m68k/atari/nvram.c b/arch/m68k/atari/nvram.c > > new file mode 100644 > > index ..3e620ee955ba > > --- /dev/null > > +++ b/arch/m68k/atari/nvram.c > > @@ -0,0 +1,243 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * CMOS/NV-RAM driver for Atari. Adapted from drivers/char/nvram.c. > > + * Copyright (C) 1997 Roman Hodek > > + * idea by and with help from Richard Jelinek > > + * Portions copyright (c) 2001,2002 Sun Microsystems (thoc...@sun.com) > > + * Further contributions from Cesar Barros, Erik Gilling, Tim Hockin and > > + * Wim Van Sebroeck. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define NVRAM_BYTES50 > > + > > +/* It is worth noting that these functions all access bytes of general > > + * purpose memory in the NVRAM - that is to say, they all add the > > + * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not > > + * know about the RTC cruft. > > + */ > > + > > +/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with > > + * rtc_lock held. Due to the index-port/data-port design of the RTC, we > > + * don't want two different things trying to get to it at once. (e.g. the > > + * periodic 11 min sync from kernel/time/ntp.c vs. this driver.) > > + */ > > + > > +unsigned char __nvram_read_byte(int i) > > +{ > > + return CMOS_READ(NVRAM_FIRST_BYTE + i); > > +} > > + > > +unsigned char nvram_read_byte(int i) > > +{ > > + unsigned long flags; > > + unsigned char c; > > + > > + spin_lock_irqsave(_lock, flags); > > + c = __nvram_read_byte(i); > > + spin_unlock_irqrestore(_lock, flags); > > + return c; > > +} > > +EXPORT_SYMBOL(nvram_read_byte); > > + > > +/* This races nicely with trying to read with checksum checking */ > > +void __nvram_write_byte(unsigned char c, int i) > > +{ > > + CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); > > +} > > + > > +void nvram_write_byte(unsigned char c, int i) > > +{ > > + unsigned long flags; > > + > > + spin_lock_irqsave(_lock, flags); > > + __nvram_write_byte(c, i); > > + spin_unlock_irqrestore(_lock, flags); > > +} > > + > > +/* On Ataris, the checksum is over all bytes except the checksum bytes > > + * themselves; these are at the very end. > > + */ > > +#define ATARI_CKS_RANGE_START 0 > > +#define ATARI_CKS_RANGE_END47 > > +#define ATARI_CKS_LOC 48 > > + > > +int __nvram_check_checksum(void) > > +{ > > + int i; > > + unsigned char sum = 0; > > + > > + for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) > > + sum += __nvram_read_byte(i); > > + return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) && > > + (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff)); > > +} > > + > > +int nvram_check_checksum(void) > > +{ > > + unsigned long flags; > > + int rv; > > + > > + spin_lock_irqsave(_lock, flags); > > + rv = __nvram_check_checksum(); > > + spin_unlock_irqrestore(_lock, flags); > > + return rv; > > +} > > +EXPORT_SYMBOL(nvram_check_checksum); > > + > > +static void __nvram_set_checksum(void) > > +{ > > + int i; > > + unsigned char sum = 0; > > + > > + for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) > > + sum += __nvram_read_byte(i); > > + __nvram_write_byte(~sum, ATARI_CKS_LOC); > > + __nvram_write_byte(sum, ATARI_CKS_LOC + 1); > > +} > > + > > +#ifdef CONFIG_PROC_FS > > +static struct { > > + unsigned char val; > > + const char *name; > > +} boot_prefs[] = { > > + { 0x80, "TOS" }, > > + { 0x40, "ASV" }, > > + { 0x20, "NetBSD (?)" }, > > + { 0x10, "Linux" }, > > + { 0x00, "unspecified" }, > > +}; > > + > > +static
Re: [PATCH v8 01/25] scsi/atari_scsi: Don't select CONFIG_NVRAM
On Fri, 28 Dec 2018, LEROY Christophe wrote: > Finn Thain a ?crit?: > > > On powerpc, setting CONFIG_NVRAM=n builds a kernel with no NVRAM support. > > Setting CONFIG_NVRAM=m enables the /dev/nvram misc device module without > > enabling NVRAM support in drivers. Setting CONFIG_NVRAM=y enables the > > misc device (built-in) and also enables NVRAM support in drivers. > > > > m68k shares the valkyriefb driver with powerpc, and since that driver uses > > NVRAM, it is affected by CONFIG_ATARI_SCSI, because of the use of > > "select NVRAM". > > > > Adopt the powerpc convention on m68k to avoid surprises. > > > > Signed-off-by: Finn Thain > > Tested-by: Christian T. Steigies > > --- > > This patch temporarily disables CONFIG_NVRAM on Atari, to prevent build > > failures when bisecting the rest of this patch series. It gets enabled > > again with the introduction of CONFIG_HAVE_ARCH_NVRAM_OPS, once the > > nvram_* global functions have been moved to an ops struct. > > --- > > drivers/char/Kconfig | 5 + > > drivers/scsi/Kconfig | 6 +++--- > > drivers/scsi/atari_scsi.c | 7 --- > > 3 files changed, 8 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig > > index 9d03b2ff5df6..5b54595dfe30 100644 > > --- a/drivers/char/Kconfig > > +++ b/drivers/char/Kconfig > > @@ -236,7 +236,7 @@ source "drivers/char/hw_random/Kconfig" > > > > config NVRAM > > tristate "/dev/nvram support" > > - depends on ATARI || X86 || GENERIC_NVRAM > > + depends on X86 || GENERIC_NVRAM > > ---help--- > > If you say Y here and create a character special file /dev/nvram > > with major number 10 and minor number 144 using mknod ("man mknod"), > > @@ -254,9 +254,6 @@ config NVRAM > > should NEVER idly tamper with it. See Ralf Brown's interrupt list > > for a guide to the use of CMOS bytes by your BIOS. > > > > - On Atari machines, /dev/nvram is always configured and does not need > > - to be selected. > > - > > To compile this driver as a module, choose M here: the > > module will be called nvram. > > > > diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig > > index 640cd1b31a18..924eb69e7fc4 100644 > > --- a/drivers/scsi/Kconfig > > +++ b/drivers/scsi/Kconfig > > @@ -1381,14 +1381,14 @@ config ATARI_SCSI > > tristate "Atari native SCSI support" > > depends on ATARI && SCSI > > select SCSI_SPI_ATTRS > > - select NVRAM > > ---help--- > > If you have an Atari with built-in NCR5380 SCSI controller (TT, > > Falcon, ...) say Y to get it supported. Of course also, if you have > > a compatible SCSI controller (e.g. for Medusa). > > > > - To compile this driver as a module, choose M here: the > > - module will be called atari_scsi. > > + To compile this driver as a module, choose M here: the module will > > + be called atari_scsi. If you also enable NVRAM support, the SCSI > > + host's ID is taken from the setting in TT RTC NVRAM. > > > > This driver supports both styles of NCR integration into the > > system: the TT style (separate DMA), and the Falcon style (via > > diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c > > index 89f5154c40b6..99e5729d910d 100644 > > --- a/drivers/scsi/atari_scsi.c > > +++ b/drivers/scsi/atari_scsi.c > > @@ -755,9 +755,10 @@ static int __init atari_scsi_probe(struct > > platform_device *pdev) > > if (ATARIHW_PRESENT(TT_SCSI) && setup_sg_tablesize >= 0) > > atari_scsi_template.sg_tablesize = setup_sg_tablesize; > > > > - if (setup_hostid >= 0) { > > + if (setup_hostid >= 0) > > atari_scsi_template.this_id = setup_hostid & 7; > > - } else { > > +#ifdef CONFIG_NVRAM > > + else > > Such ifdefs should be avoided in C files. > It would be better to use > > } else if (IS_ENABLED(CONFIG_NVRAM)) { > I don't like #ifdefs either. However, as the maintainer of this file, I am okay with this one. The old #ifdef CONFIG_NVRAM conditional compilation convention that gets used here and under drivers/video/fbdev could probably be improved upon but I consider this to be out-of-scope for this series, which is complicated enough. And as explained in the commit log, CONFIG_NVRAM=y and CONFIG_NVRAM=m are treaded differently by drivers. Therefore, IS_ENABLED would be incorrect. -- > > /* Test if a host id is set in the NVRam */ > > if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) { > > unsigned char b = nvram_read_byte(16); > > @@ -768,7 +769,7 @@ static int __init atari_scsi_probe(struct > > platform_device *pdev) > > if (b & 0x80) > > atari_scsi_template.this_id = b & 7; > > } > > - } > > +#endif > > > > /* If running on a Falcon and if there's TT-Ram (i.e., more than one > > * memory block, since there's always ST-Ram in a Falcon), then > > -- > > 2.19.2 > > >
Re: [PATCH net-next] Amiga PCMCIA 100 MBit card support
From: Michael Schmitz Date: Sat, 22 Dec 2018 10:30:58 +1300 > Am 21.12.2018 um 13:10 schrieb David Miller: >> And in particular this huge complicated Kconfig construct is not >> maintainable at all. > > We can trim this down a bit (for reasons I've outlined before): > > +if APNE > +config APNE100MBIT > + bool "PCMCIA NE2000 100MBit support" > + default n > + depends on NE2000=n && PCMCIA_AXNET=n > + depends on PCMCIA_PCNET=n && STNIC=n && ULTRA=n && WD80x3=n > > In all honesty, I doubt anyone could ever use the stnic, ultra and wd > drivers on m68k (Geert?) so these could be omitted as well. Not sure > pcnet_cs or axnet_cs are possible to use on the Amiga PCMCIA slot, so > all that remains in practice is the ne driver (which is used on > Atari). > > Still too ugly? I'm sorry, maybe I didn't express my concern clearly. Any sizable list of exceptions in a Kconfig conditional has long term maintainence costs. If, for some reason, a new variant of support for this chip arrives there will be a new Kconfig setting that would need to be added here to your expressions. That is insanely error prone, and I can guarantee it will get missed. Having so many front end drivers for a chipset should be done in a more modular manner, so that in fact they could all coexist if necessary.
Re: [PATCH v8 02/25] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c
Finn Thain a écrit : Move the m68k-specific code out of the driver to make the driver generic. I've used 'SPDX-License-Identifier: GPL-2.0+' for the new file because the old file is covered by MODULE_LICENSE("GPL"). Signed-off-by: Finn Thain Tested-by: Christian T. Steigies Acked-by: Geert Uytterhoeven --- Changed since v7: - Added SPDX-License-Identifier. --- arch/m68k/atari/Makefile | 2 + arch/m68k/atari/nvram.c | 243 + drivers/char/nvram.c | 280 +-- 3 files changed, 280 insertions(+), 245 deletions(-) create mode 100644 arch/m68k/atari/nvram.c diff --git a/arch/m68k/atari/Makefile b/arch/m68k/atari/Makefile index 0cac723306f9..0b86bb6cfa87 100644 --- a/arch/m68k/atari/Makefile +++ b/arch/m68k/atari/Makefile @@ -6,3 +6,5 @@ obj-y := config.o time.o debug.o ataints.o stdma.o \ atasound.o stram.o obj-$(CONFIG_ATARI_KBD_CORE) += atakeyb.o + +obj-$(CONFIG_NVRAM:m=y)+= nvram.o diff --git a/arch/m68k/atari/nvram.c b/arch/m68k/atari/nvram.c new file mode 100644 index ..3e620ee955ba --- /dev/null +++ b/arch/m68k/atari/nvram.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * CMOS/NV-RAM driver for Atari. Adapted from drivers/char/nvram.c. + * Copyright (C) 1997 Roman Hodek + * idea by and with help from Richard Jelinek + * Portions copyright (c) 2001,2002 Sun Microsystems (thoc...@sun.com) + * Further contributions from Cesar Barros, Erik Gilling, Tim Hockin and + * Wim Van Sebroeck. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NVRAM_BYTES50 + +/* It is worth noting that these functions all access bytes of general + * purpose memory in the NVRAM - that is to say, they all add the + * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not + * know about the RTC cruft. + */ + +/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with + * rtc_lock held. Due to the index-port/data-port design of the RTC, we + * don't want two different things trying to get to it at once. (e.g. the + * periodic 11 min sync from kernel/time/ntp.c vs. this driver.) + */ + +unsigned char __nvram_read_byte(int i) +{ + return CMOS_READ(NVRAM_FIRST_BYTE + i); +} + +unsigned char nvram_read_byte(int i) +{ + unsigned long flags; + unsigned char c; + + spin_lock_irqsave(_lock, flags); + c = __nvram_read_byte(i); + spin_unlock_irqrestore(_lock, flags); + return c; +} +EXPORT_SYMBOL(nvram_read_byte); + +/* This races nicely with trying to read with checksum checking */ +void __nvram_write_byte(unsigned char c, int i) +{ + CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); +} + +void nvram_write_byte(unsigned char c, int i) +{ + unsigned long flags; + + spin_lock_irqsave(_lock, flags); + __nvram_write_byte(c, i); + spin_unlock_irqrestore(_lock, flags); +} + +/* On Ataris, the checksum is over all bytes except the checksum bytes + * themselves; these are at the very end. + */ +#define ATARI_CKS_RANGE_START 0 +#define ATARI_CKS_RANGE_END47 +#define ATARI_CKS_LOC 48 + +int __nvram_check_checksum(void) +{ + int i; + unsigned char sum = 0; + + for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) + sum += __nvram_read_byte(i); + return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) && + (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff)); +} + +int nvram_check_checksum(void) +{ + unsigned long flags; + int rv; + + spin_lock_irqsave(_lock, flags); + rv = __nvram_check_checksum(); + spin_unlock_irqrestore(_lock, flags); + return rv; +} +EXPORT_SYMBOL(nvram_check_checksum); + +static void __nvram_set_checksum(void) +{ + int i; + unsigned char sum = 0; + + for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) + sum += __nvram_read_byte(i); + __nvram_write_byte(~sum, ATARI_CKS_LOC); + __nvram_write_byte(sum, ATARI_CKS_LOC + 1); +} + +#ifdef CONFIG_PROC_FS +static struct { + unsigned char val; + const char *name; +} boot_prefs[] = { + { 0x80, "TOS" }, + { 0x40, "ASV" }, + { 0x20, "NetBSD (?)" }, + { 0x10, "Linux" }, + { 0x00, "unspecified" }, +}; + +static const char * const languages[] = { + "English (US)", + "German", + "French", + "English (UK)", + "Spanish", + "Italian", + "6 (undefined)", + "Swiss (French)", + "Swiss (German)", +}; + +static const char * const dateformat[] = { + "MM%cDD%cYY", + "DD%cMM%cYY", + "YY%cMM%cDD", + "YY%cDD%cMM", + "4 (undefined)", + "5 (undefined)", + "6 (undefined)", + "7 (undefined)", +}; + +static const char * const colors[] = { + "2", "4",
Re: [PATCH v8 01/25] scsi/atari_scsi: Don't select CONFIG_NVRAM
Finn Thain a écrit : On powerpc, setting CONFIG_NVRAM=n builds a kernel with no NVRAM support. Setting CONFIG_NVRAM=m enables the /dev/nvram misc device module without enabling NVRAM support in drivers. Setting CONFIG_NVRAM=y enables the misc device (built-in) and also enables NVRAM support in drivers. m68k shares the valkyriefb driver with powerpc, and since that driver uses NVRAM, it is affected by CONFIG_ATARI_SCSI, because of the use of "select NVRAM". Adopt the powerpc convention on m68k to avoid surprises. Signed-off-by: Finn Thain Tested-by: Christian T. Steigies --- This patch temporarily disables CONFIG_NVRAM on Atari, to prevent build failures when bisecting the rest of this patch series. It gets enabled again with the introduction of CONFIG_HAVE_ARCH_NVRAM_OPS, once the nvram_* global functions have been moved to an ops struct. --- drivers/char/Kconfig | 5 + drivers/scsi/Kconfig | 6 +++--- drivers/scsi/atari_scsi.c | 7 --- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 9d03b2ff5df6..5b54595dfe30 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -236,7 +236,7 @@ source "drivers/char/hw_random/Kconfig" config NVRAM tristate "/dev/nvram support" - depends on ATARI || X86 || GENERIC_NVRAM + depends on X86 || GENERIC_NVRAM ---help--- If you say Y here and create a character special file /dev/nvram with major number 10 and minor number 144 using mknod ("man mknod"), @@ -254,9 +254,6 @@ config NVRAM should NEVER idly tamper with it. See Ralf Brown's interrupt list for a guide to the use of CMOS bytes by your BIOS. - On Atari machines, /dev/nvram is always configured and does not need - to be selected. - To compile this driver as a module, choose M here: the module will be called nvram. diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 640cd1b31a18..924eb69e7fc4 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -1381,14 +1381,14 @@ config ATARI_SCSI tristate "Atari native SCSI support" depends on ATARI && SCSI select SCSI_SPI_ATTRS - select NVRAM ---help--- If you have an Atari with built-in NCR5380 SCSI controller (TT, Falcon, ...) say Y to get it supported. Of course also, if you have a compatible SCSI controller (e.g. for Medusa). - To compile this driver as a module, choose M here: the - module will be called atari_scsi. + To compile this driver as a module, choose M here: the module will + be called atari_scsi. If you also enable NVRAM support, the SCSI + host's ID is taken from the setting in TT RTC NVRAM. This driver supports both styles of NCR integration into the system: the TT style (separate DMA), and the Falcon style (via diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 89f5154c40b6..99e5729d910d 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -755,9 +755,10 @@ static int __init atari_scsi_probe(struct platform_device *pdev) if (ATARIHW_PRESENT(TT_SCSI) && setup_sg_tablesize >= 0) atari_scsi_template.sg_tablesize = setup_sg_tablesize; - if (setup_hostid >= 0) { + if (setup_hostid >= 0) atari_scsi_template.this_id = setup_hostid & 7; - } else { +#ifdef CONFIG_NVRAM + else Such ifdefs should be avoided in C files. It would be better to use } else if (IS_ENABLED(CONFIG_NVRAM)) { /* Test if a host id is set in the NVRam */ if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) { unsigned char b = nvram_read_byte(16); @@ -768,7 +769,7 @@ static int __init atari_scsi_probe(struct platform_device *pdev) if (b & 0x80) atari_scsi_template.this_id = b & 7; } - } +#endif /* If running on a Falcon and if there's TT-Ram (i.e., more than one * memory block, since there's always ST-Ram in a Falcon), then -- 2.19.2