2018-05-17 13:08:04

by Andrea Greco

[permalink] [raw]
Subject: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

From: Andrea Greco <[email protected]>

Add support for com20022I/com20020, io mapped.

Signed-off-by: Andrea Greco <[email protected]>
---
drivers/net/arcnet/Kconfig | 9 +-
drivers/net/arcnet/Makefile | 1 +
drivers/net/arcnet/arcdevice.h | 14 ++
drivers/net/arcnet/com20020-io.c | 287 +++++++++++++++++++++++++++++++++++++++
drivers/net/arcnet/com20020.c | 5 +-
5 files changed, 313 insertions(+), 3 deletions(-)
create mode 100644 drivers/net/arcnet/com20020-io.c

diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
index 39bd16f3f86d..85e60ed29fa8 100644
--- a/drivers/net/arcnet/Kconfig
+++ b/drivers/net/arcnet/Kconfig
@@ -3,7 +3,7 @@
#

menuconfig ARCNET
- depends on NETDEVICES && (ISA || PCI || PCMCIA)
+ depends on NETDEVICES
tristate "ARCnet support"
---help---
If you have a network card of this type, say Y and check out the
@@ -129,5 +129,12 @@ config ARCNET_COM20020_CS

To compile this driver as a module, choose M here: the module will be
called com20020_cs. If unsure, say N.
+config ARCNET_COM20020_IO
+ bool "Support for COM20020 (IO mapped)"
+ depends on ARCNET_COM20020 && !(ARCNET_COM20020_PCI || ARCNET_COM20020_ISA || ARCNET_COM20020_CS)
+ help
+ Say Y here if your custom board mount com20020 chipset or friends.
+ Supported Chipset: com20020, com20022, com20022I-3v3
+ If unsure, say N.

endif # ARCNET
diff --git a/drivers/net/arcnet/Makefile b/drivers/net/arcnet/Makefile
index 53525e8ea130..18da4341f404 100644
--- a/drivers/net/arcnet/Makefile
+++ b/drivers/net/arcnet/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_ARCNET_COM20020) += com20020.o
obj-$(CONFIG_ARCNET_COM20020_ISA) += com20020-isa.o
obj-$(CONFIG_ARCNET_COM20020_PCI) += com20020-pci.o
obj-$(CONFIG_ARCNET_COM20020_CS) += com20020_cs.o
+obj-$(CONFIG_ARCNET_COM20020_IO) += com20020-io.o
diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index d09b2b46ab63..86c36d9b666b 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -371,6 +371,19 @@ void arcnet_timeout(struct net_device *dev);
#define BUS_ALIGN 1
#endif

+#ifdef CONFIG_ARCNET_COM20020_IO
+#define arcnet_inb(addr, offset) \
+ ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
+
+#define arcnet_outb(value, addr, offset) \
+ iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
+
+#define arcnet_insb(addr, offset, buffer, count) \
+ ioread8_rep((void __iomem *)addr + BUS_ALIGN * offset, buffer, count)
+
+#define arcnet_outsb(addr, offset, buffer, count) \
+ iowrite8_rep((void __iomem *)addr + BUS_ALIGN * offset, buffer, count)
+#else
/* addr and offset allow register like names to define the actual IO address.
* A configuration option multiplies the offset for alignment.
*/
@@ -388,6 +401,7 @@ void arcnet_timeout(struct net_device *dev);
readb((addr) + (offset))
#define arcnet_writeb(value, addr, offset) \
writeb(value, (addr) + (offset))
+#endif

#endif /* __KERNEL__ */
#endif /* _LINUX_ARCDEVICE_H */
diff --git a/drivers/net/arcnet/com20020-io.c b/drivers/net/arcnet/com20020-io.c
new file mode 100644
index 000000000000..fce458242193
--- /dev/null
+++ b/drivers/net/arcnet/com20020-io.c
@@ -0,0 +1,287 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/* Linux ARCnet driver for com 20020.
+ *
+ * datasheet:
+ * http://ww1.microchip.com/downloads/en/DeviceDoc/200223vrevc.pdf
+ * http://ww1.microchip.com/downloads/en/DeviceDoc/20020.pdf
+ *
+ * Supported chip version:
+ * - com20020
+ * - com20022
+ * - com20022I-3v3
+ */
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/platform_device.h>
+#include <linux/netdevice.h>
+#include <linux/of_address.h>
+#include <linux/of_gpio.h>
+#include <linux/sizes.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include "arcdevice.h"
+#include "com20020.h"
+
+/* Reset (5 * xTalFreq), minimal com20020 xTal is 10Mhz */
+#define RESET_DELAY 500
+
+enum com20020_xtal_freq {
+ freq_10Mhz = 10,
+ freq_20Mhz = 20,
+};
+
+enum com20020_arcnet_speed {
+ arc_speed_10M_bps = 10000000,
+ arc_speed_5M_bps = 5000000,
+ arc_speed_2M50_bps = 2500000,
+ arc_speed_1M25_bps = 1250000,
+ arc_speed_625K_bps = 625000,
+ arc_speed_312K5_bps = 312500,
+ arc_speed_156K25_bps = 156250,
+};
+
+enum com20020_timeout {
+ arc_timeout_328us = 328000,
+ arc_timeout_164us = 164000,
+ arc_timeout_82us = 82000,
+ arc_timeout_20u5s = 20500,
+};
+
+static int setup_clock(int *clockp, int *clockm, int xtal, int arcnet_speed)
+{
+ int pll_factor, req_clock_frq = 20;
+
+ switch (arcnet_speed) {
+ case arc_speed_10M_bps:
+ req_clock_frq = 80;
+ *clockp = 0;
+ break;
+ case arc_speed_5M_bps:
+ req_clock_frq = 40;
+ *clockp = 0;
+ break;
+ case arc_speed_2M50_bps:
+ *clockp = 0;
+ break;
+ case arc_speed_1M25_bps:
+ *clockp = 1;
+ break;
+ case arc_speed_625K_bps:
+ *clockp = 2;
+ break;
+ case arc_speed_312K5_bps:
+ *clockp = 3;
+ break;
+ case arc_speed_156K25_bps:
+ *clockp = 4;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (xtal != freq_10Mhz && xtal != freq_20Mhz)
+ return -EINVAL;
+
+ pll_factor = (unsigned int)req_clock_frq / xtal;
+
+ switch (pll_factor) {
+ case 1:
+ *clockm = 0;
+ break;
+ case 2:
+ *clockm = 1;
+ break;
+ case 4:
+ *clockm = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int setup_timeout(int *timeout)
+{
+ switch (*timeout) {
+ case arc_timeout_328us:
+ *timeout = 0;
+ break;
+ case arc_timeout_164us:
+ *timeout = 1;
+ break;
+ case arc_timeout_82us:
+ *timeout = 2;
+ break;
+ case arc_timeout_20u5s:
+ *timeout = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int com20020_probe(struct platform_device *pdev)
+{
+ struct device_node *np;
+ struct net_device *dev;
+ struct arcnet_local *lp;
+ struct resource res, *iores;
+ int ret, phy_reset;
+ u32 timeout, xtal, arc_speed;
+ int clockp, clockm;
+ void __iomem *ioaddr;
+ bool backplane = false;
+
+ np = pdev->dev.of_node;
+
+ iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+ ret = of_address_to_resource(np, 0, &res);
+ if (ret)
+ return ret;
+
+ ret = of_property_read_u32(np, "timeout-ns", &timeout);
+ if (ret) {
+ dev_err(&pdev->dev, "timeout is required param");
+ return ret;
+ }
+
+ ret = of_property_read_u32(np, "smsc,xtal-mhz", &xtal);
+ if (ret) {
+ dev_err(&pdev->dev, "xtal-mhz is required param");
+ return ret;
+ }
+
+ ret = of_property_read_u32(np, "bus-speed-bps", &arc_speed);
+ if (ret) {
+ dev_err(&pdev->dev, "Bus speed is required param");
+ return ret;
+ }
+
+ if (of_property_read_bool(np, "smsc,backplane-enabled"))
+ backplane = true;
+
+ phy_reset = of_get_named_gpio(np, "reset-gpios", 0);
+ if (!gpio_is_valid(phy_reset)) {
+ dev_err(&pdev->dev, "reset gpio not valid");
+ return phy_reset;
+ }
+
+ ret = devm_gpio_request_one(&pdev->dev, phy_reset, GPIOF_OUT_INIT_LOW,
+ "arcnet-reset");
+ if (ret) {
+ dev_err(&pdev->dev, "failed to get phy reset gpio: %d\n", ret);
+ return ret;
+ }
+
+ dev = alloc_arcdev(NULL);
+ dev->netdev_ops = &com20020_netdev_ops;
+ lp = netdev_priv(dev);
+
+ lp->card_flags = ARC_CAN_10MBIT;
+
+ /* Will be set by userspace during if setup */
+ dev->dev_addr[0] = 0;
+
+ if (!devm_request_mem_region(&pdev->dev, res.start, resource_size(&res),
+ lp->card_name))
+ return -EBUSY;
+
+ ioaddr = devm_ioremap(&pdev->dev, iores->start, resource_size(iores));
+ if (!ioaddr) {
+ dev_err(&pdev->dev, "ioremap fallied\n");
+ return -ENOMEM;
+ }
+
+ gpio_set_value_cansleep(phy_reset, 0);
+ ndelay(RESET_DELAY);
+ gpio_set_value_cansleep(phy_reset, 1);
+
+ /* ARCNET controller needs this access to detect bustype */
+ arcnet_outb(0x00, ioaddr, COM20020_REG_W_COMMAND);
+ arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT);
+
+ dev->base_addr = (unsigned long)ioaddr;
+
+ dev->irq = of_get_named_gpio(np, "interrupts", 0);
+ if (dev->irq == -EPROBE_DEFER) {
+ return dev->irq;
+ } else if (!gpio_is_valid(dev->irq)) {
+ dev_err(&pdev->dev, "irq-gpios not valid !");
+ return -EIO;
+ }
+ dev->irq = gpio_to_irq(dev->irq);
+
+ ret = setup_clock(&clockp, &clockm, xtal, arc_speed);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "Impossible use oscillator:%dMhz and arcnet bus speed:%dKbps",
+ xtal, arc_speed / 1000);
+ return ret;
+ }
+
+ ret = setup_timeout(&timeout);
+ if (ret) {
+ dev_err(&pdev->dev, "Timeout:%d is not valid value", timeout);
+ return ret;
+ }
+
+ lp->backplane = (int)backplane;
+ lp->timeout = timeout;
+ lp->clockm = clockm;
+ lp->clockp = clockp;
+ lp->hw.owner = THIS_MODULE;
+
+ if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
+ ret = -EIO;
+ goto err_release_mem;
+ }
+
+ if (com20020_check(dev)) {
+ ret = -EIO;
+ goto err_release_mem;
+ }
+
+ ret = com20020_found(dev, IRQF_TRIGGER_FALLING);
+ if (ret)
+ goto err_release_mem;
+
+ dev_dbg(&pdev->dev, "probe Done\n");
+ return 0;
+
+err_release_mem:
+ devm_iounmap(&pdev->dev, (void __iomem *)ioaddr);
+ devm_release_mem_region(&pdev->dev, res.start, resource_size(&res));
+ dev_err(&pdev->dev, "probe failed!\n");
+ return ret;
+}
+
+static const struct of_device_id of_com20020_match[] = {
+ { .compatible = "smsc,com20020", },
+ { },
+};
+
+MODULE_DEVICE_TABLE(of, of_com20020_match);
+
+static struct platform_driver of_com20020_driver = {
+ .driver = {
+ .name = "com20020-memory-bus",
+ .of_match_table = of_com20020_match,
+ },
+ .probe = com20020_probe,
+};
+
+static int com20020_init(void)
+{
+ return platform_driver_register(&of_com20020_driver);
+}
+late_initcall(com20020_init);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 78043a9c5981..2fd00d2dd6bf 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -43,7 +43,7 @@
#include "com20020.h"

static const char * const clockrates[] = {
- "XXXXXXX", "XXXXXXXX", "XXXXXX", "2.5 Mb/s",
+ "10 Mb/s", "XXXXXXXX", "XXXXXX", "2.5 Mb/s",
"1.25Mb/s", "625 Kb/s", "312.5 Kb/s", "156.25 Kb/s",
"Reserved", "Reserved", "Reserved"
};
@@ -393,7 +393,8 @@ static void com20020_set_mc_list(struct net_device *dev)

#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \
- defined(CONFIG_ARCNET_COM20020_CS_MODULE)
+ defined(CONFIG_ARCNET_COM20020_CS_MODULE) || \
+ defined(CONFIG_ARCNET_COM20020_IO)
EXPORT_SYMBOL(com20020_check);
EXPORT_SYMBOL(com20020_found);
EXPORT_SYMBOL(com20020_netdev_ops);
--
2.14.3



2018-05-17 20:31:50

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

From: Andrea Greco <[email protected]>
Date: Thu, 17 May 2018 15:05:29 +0200

> + /* Will be set by userspace during if setup */
> + dev->dev_addr[0] = 0;

Hmmm... really?

Also, every error path from this point forward will leak 'dev'.

2018-05-18 12:20:05

by Andrea Greco

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

On 05/17/2018 10:31 PM, David Miller wrote:
> From: Andrea Greco <[email protected]>
> Date: Thu, 17 May 2018 15:05:29 +0200
>
>> + /* Will be set by userspace during if setup */
>> + dev->dev_addr[0] = 0;
>
> Hmmm... really?
>
> Also, every error path from this point forward will leak 'dev'.
>

In com20020.c found this:
/* FIXME: do this some other way! */
if (!dev->dev_addr[0])
dev->dev_addr[0] = arcnet_inb(ioaddr, 8);

NODE-ID, must be univoque, for all arcnet network.
My previews idea was take random value but, this could create a
collision over network.

A possible solution is:
In case of collision com20020 set a bit in status register.
Then peak a new NODE-ID and repeat this while correct NODE-ID is found.

Other ideas is pass it via DTS.
But suppose have 2 same product in same network, same address same problem.
For this reason i prefer left standard driver behavior.

Other ideas for solve this ?

Other question discussed with Tobin in RFC patch is:

At now a devm_ioremap is done by this driver.

Other version of this driver, PCI, PCMCIA, ISA do not remap memory.
Other implementation, use:inb outb for r/w operation.
I do a ugly #ifndef and redefine arcnet_inb in case is defined
CONFIG_ARCNET_COM20020_IO.

My proposal was:
Add relative callback arcnet_inb, arcnet_outb and friends hw struct in
arcdevice.h, then every driver set callback with required function.

Regards, Andrea

2018-05-18 17:53:53

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

From: Andrea Greco <[email protected]>
Date: Fri, 18 May 2018 14:18:41 +0200

> In com20020.c found this:
> /* FIXME: do this some other way! */
> if (!dev->dev_addr[0])
> dev->dev_addr[0] = arcnet_inb(ioaddr, 8);
>
> NODE-ID, must be univoque, for all arcnet network.
> My previews idea was take random value but, this could create a
> collision over network.
>
> A possible solution is:
> In case of collision com20020 set a bit in status register.
> Then peak a new NODE-ID and repeat this while correct NODE-ID is found.
>
> Other ideas is pass it via DTS.
> But suppose have 2 same product in same network, same address same problem.
> For this reason i prefer left standard driver behavior.
>
> Other ideas for solve this ?

Is there no way to obtain a unique value from the device?

If having a unique ID to talk on the ARCNET is so critical, there must
be some way to properly allocation and use a unique ID.

I guess this must be a general problem with this driver already.

You still need to address the issue of 'dev' being leaked on probe
error paths.

Thank you.


2018-05-20 02:14:51

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

Hi Andrea,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andrea-Greco/arcnet-com20020-Add-com20020-io-mapped-version/20180520-083936
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

In file included from drivers/net/arcnet/com90xx.c:40:0:
drivers/net/arcnet/com90xx.c: In function 'com90xx_probe':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:161:7: note: in expansion of macro 'arcnet_inb'
if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:171:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^~~~~~~~~~
>> drivers/net/arcnet/com90xx.c:233:7: error: implicit declaration of function 'arcnet_readb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
^~~~~~~~~~~~
arcnet_outsb
>> drivers/net/arcnet/com90xx.c:247:3: error: implicit declaration of function 'arcnet_writeb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
^~~~~~~~~~~~~
arcnet_outsb
In file included from drivers/net/arcnet/com90xx.c:40:0:
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:312:12: note: in expansion of macro 'arcnet_inb'
status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:324:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:326:12: note: in expansion of macro 'arcnet_inb'
status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:346:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:348:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:383:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_command':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:565:2: note: in expansion of macro 'arcnet_outb'
arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_status':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:572:9: note: in expansion of macro 'arcnet_inb'
return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_setmask':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:579:2: note: in expansion of macro 'arcnet_outb'
arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_reset':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:88:28: note: in expansion of macro 'arcnet_inb'
netdev_warn(dev, fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:90:28: note: in expansion of macro 'arcnet_inb'
netdev_info(dev, fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
include/linux/dynamic_debug.h:144:12: note: in expansion of macro 'arcnet_inb'
##__VA_ARGS__); \
^~~~~~~~~~~
include/linux/netdevice.h:4419:2: note: in expansion of macro 'dynamic_netdev_dbg'
dynamic_netdev_dbg(__dev, format, ##args); \
^~~~~~~~~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:92:4: note: in expansion of macro 'netdev_dbg'
netdev_dbg(dev, fmt, ##__VA_ARGS__); \
^~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:599:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
--
drivers/net/arcnet/arc-rimi.c: In function 'check_mirror':
>> drivers/net/arcnet/arc-rimi.c:109:7: error: implicit declaration of function 'arcnet_readb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
^~~~~~~~~~~~
arcnet_outsb
drivers/net/arcnet/arc-rimi.c: In function 'arcrimi_found':
>> drivers/net/arcnet/arc-rimi.c:147:2: error: implicit declaration of function 'arcnet_writeb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
arcnet_writeb(TESTvalue, p, COM9026_REG_W_INTMASK);
^~~~~~~~~~~~~
arcnet_outsb
cc1: some warnings being treated as errors

vim +233 drivers/net/arcnet/com90xx.c

^1da177e4 Linus Torvalds 2005-04-16 95
^1da177e4 Linus Torvalds 2005-04-16 96 static void __init com90xx_probe(void)
^1da177e4 Linus Torvalds 2005-04-16 97 {
^1da177e4 Linus Torvalds 2005-04-16 98 int count, status, ioaddr, numprint, airq, openparen = 0;
^1da177e4 Linus Torvalds 2005-04-16 99 unsigned long airqmask;
7f5e760c1 Joe Perches 2015-05-05 100 int ports[(0x3f0 - 0x200) / 16 + 1] = { 0 };
d0f6ecad3 Al Viro 2005-12-02 101 unsigned long *shmems;
d0f6ecad3 Al Viro 2005-12-02 102 void __iomem **iomem;
^1da177e4 Linus Torvalds 2005-04-16 103 int numports, numshmems, *port;
^1da177e4 Linus Torvalds 2005-04-16 104 u_long *p;
d0f6ecad3 Al Viro 2005-12-02 105 int index;
^1da177e4 Linus Torvalds 2005-04-16 106
^1da177e4 Linus Torvalds 2005-04-16 107 if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
^1da177e4 Linus Torvalds 2005-04-16 108 return;
^1da177e4 Linus Torvalds 2005-04-16 109
15901dc93 Andrew Morton 2006-04-01 110 shmems = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(unsigned long),
d0f6ecad3 Al Viro 2005-12-02 111 GFP_KERNEL);
d0f6ecad3 Al Viro 2005-12-02 112 if (!shmems)
d0f6ecad3 Al Viro 2005-12-02 113 return;
15901dc93 Andrew Morton 2006-04-01 114 iomem = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(void __iomem *),
d0f6ecad3 Al Viro 2005-12-02 115 GFP_KERNEL);
d0f6ecad3 Al Viro 2005-12-02 116 if (!iomem) {
d0f6ecad3 Al Viro 2005-12-02 117 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 118 return;
d0f6ecad3 Al Viro 2005-12-02 119 }
d0f6ecad3 Al Viro 2005-12-02 120
72aeea484 Joe Perches 2015-05-05 121 if (BUGLVL(D_NORMAL))
05a24b234 Joe Perches 2015-05-05 122 pr_info("%s\n", "COM90xx chipset support");
^1da177e4 Linus Torvalds 2005-04-16 123
^1da177e4 Linus Torvalds 2005-04-16 124 /* set up the arrays where we'll store the possible probe addresses */
^1da177e4 Linus Torvalds 2005-04-16 125 numports = numshmems = 0;
^1da177e4 Linus Torvalds 2005-04-16 126 if (io)
^1da177e4 Linus Torvalds 2005-04-16 127 ports[numports++] = io;
^1da177e4 Linus Torvalds 2005-04-16 128 else
^1da177e4 Linus Torvalds 2005-04-16 129 for (count = 0x200; count <= 0x3f0; count += 16)
^1da177e4 Linus Torvalds 2005-04-16 130 ports[numports++] = count;
^1da177e4 Linus Torvalds 2005-04-16 131 if (shmem)
^1da177e4 Linus Torvalds 2005-04-16 132 shmems[numshmems++] = shmem;
^1da177e4 Linus Torvalds 2005-04-16 133 else
^1da177e4 Linus Torvalds 2005-04-16 134 for (count = 0xA0000; count <= 0xFF800; count += 2048)
^1da177e4 Linus Torvalds 2005-04-16 135 shmems[numshmems++] = count;
^1da177e4 Linus Torvalds 2005-04-16 136
^1da177e4 Linus Torvalds 2005-04-16 137 /* Stage 1: abandon any reserved ports, or ones with status==0xFF
^1da177e4 Linus Torvalds 2005-04-16 138 * (empty), and reset any others by reading the reset port.
^1da177e4 Linus Torvalds 2005-04-16 139 */
^1da177e4 Linus Torvalds 2005-04-16 140 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 141 for (port = &ports[0]; port - ports < numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 142 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 143 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 144 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 145 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 146 arc_cont(D_INIT, "S1: ");
^1da177e4 Linus Torvalds 2005-04-16 147 }
a34c0932c Joe Perches 2015-05-05 148 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 149
^1da177e4 Linus Torvalds 2005-04-16 150 ioaddr = *port;
^1da177e4 Linus Torvalds 2005-04-16 151
d6d7d3ed5 Joe Perches 2015-05-05 152 if (!request_region(*port, ARCNET_TOTAL_SIZE,
d6d7d3ed5 Joe Perches 2015-05-05 153 "arcnet (90xx)")) {
a34c0932c Joe Perches 2015-05-05 154 arc_cont(D_INIT_REASONS, "(request_region)\n");
a34c0932c Joe Perches 2015-05-05 155 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 156 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 157 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 158 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 159 continue;
^1da177e4 Linus Torvalds 2005-04-16 160 }
09dfbcd5d Joe Perches 2015-05-05 @161 if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
a34c0932c Joe Perches 2015-05-05 162 arc_cont(D_INIT_REASONS, "(empty)\n");
a34c0932c Joe Perches 2015-05-05 163 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 164 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 165 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 166 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 167 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 168 continue;
^1da177e4 Linus Torvalds 2005-04-16 169 }
09dfbcd5d Joe Perches 2015-05-05 170 /* begin resetting card */
09dfbcd5d Joe Perches 2015-05-05 @171 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 172
a34c0932c Joe Perches 2015-05-05 173 arc_cont(D_INIT_REASONS, "\n");
a34c0932c Joe Perches 2015-05-05 174 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 175 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 176 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 177 }
a34c0932c Joe Perches 2015-05-05 178 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 179
^1da177e4 Linus Torvalds 2005-04-16 180 if (!numports) {
a34c0932c Joe Perches 2015-05-05 181 arc_cont(D_NORMAL, "S1: No ARCnet cards found.\n");
d0f6ecad3 Al Viro 2005-12-02 182 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 183 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 184 return;
^1da177e4 Linus Torvalds 2005-04-16 185 }
^1da177e4 Linus Torvalds 2005-04-16 186 /* Stage 2: we have now reset any possible ARCnet cards, so we can't
^1da177e4 Linus Torvalds 2005-04-16 187 * do anything until they finish. If D_INIT, print the list of
^1da177e4 Linus Torvalds 2005-04-16 188 * cards that are left.
^1da177e4 Linus Torvalds 2005-04-16 189 */
^1da177e4 Linus Torvalds 2005-04-16 190 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 191 for (port = &ports[0]; port < ports + numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 192 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 193 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 194 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 195 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 196 arc_cont(D_INIT, "S2: ");
^1da177e4 Linus Torvalds 2005-04-16 197 }
a34c0932c Joe Perches 2015-05-05 198 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 199 }
a34c0932c Joe Perches 2015-05-05 200 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 201 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 202
^1da177e4 Linus Torvalds 2005-04-16 203 /* Stage 3: abandon any shmem addresses that don't have the signature
^1da177e4 Linus Torvalds 2005-04-16 204 * 0xD1 byte in the right place, or are read-only.
^1da177e4 Linus Torvalds 2005-04-16 205 */
^1da177e4 Linus Torvalds 2005-04-16 206 numprint = -1;
d0f6ecad3 Al Viro 2005-12-02 207 for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
d0f6ecad3 Al Viro 2005-12-02 208 void __iomem *base;
^1da177e4 Linus Torvalds 2005-04-16 209
^1da177e4 Linus Torvalds 2005-04-16 210 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 211 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 212 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 213 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 214 arc_cont(D_INIT, "S3: ");
^1da177e4 Linus Torvalds 2005-04-16 215 }
a34c0932c Joe Perches 2015-05-05 216 arc_cont(D_INIT, "%lXh ", *p);
^1da177e4 Linus Torvalds 2005-04-16 217
d0f6ecad3 Al Viro 2005-12-02 218 if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
a34c0932c Joe Perches 2015-05-05 219 arc_cont(D_INIT_REASONS, "(request_mem_region)\n");
a34c0932c Joe Perches 2015-05-05 220 arc_cont(D_INIT_REASONS, "Stage 3: ");
72aeea484 Joe Perches 2015-05-05 221 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 222 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 223 goto out;
d0f6ecad3 Al Viro 2005-12-02 224 }
d0f6ecad3 Al Viro 2005-12-02 225 base = ioremap(*p, MIRROR_SIZE);
d0f6ecad3 Al Viro 2005-12-02 226 if (!base) {
a34c0932c Joe Perches 2015-05-05 227 arc_cont(D_INIT_REASONS, "(ioremap)\n");
a34c0932c Joe Perches 2015-05-05 228 arc_cont(D_INIT_REASONS, "Stage 3: ");
72aeea484 Joe Perches 2015-05-05 229 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 230 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 231 goto out1;
^1da177e4 Linus Torvalds 2005-04-16 232 }
a11a5442d Joe Perches 2015-05-05 @233 if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
a34c0932c Joe Perches 2015-05-05 234 arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
a11a5442d Joe Perches 2015-05-05 235 arcnet_readb(base, COM9026_REG_R_STATUS),
a11a5442d Joe Perches 2015-05-05 236 TESTvalue);
a34c0932c Joe Perches 2015-05-05 237 arc_cont(D_INIT_REASONS, "S3: ");
72aeea484 Joe Perches 2015-05-05 238 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 239 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 240 goto out2;
^1da177e4 Linus Torvalds 2005-04-16 241 }
^1da177e4 Linus Torvalds 2005-04-16 242 /* By writing 0x42 to the TESTvalue location, we also make
^1da177e4 Linus Torvalds 2005-04-16 243 * sure no "mirror" shmem areas show up - if they occur
^1da177e4 Linus Torvalds 2005-04-16 244 * in another pass through this loop, they will be discarded
^1da177e4 Linus Torvalds 2005-04-16 245 * because *cptr != TESTvalue.
^1da177e4 Linus Torvalds 2005-04-16 246 */
a11a5442d Joe Perches 2015-05-05 @247 arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
a11a5442d Joe Perches 2015-05-05 248 if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
a34c0932c Joe Perches 2015-05-05 249 arc_cont(D_INIT_REASONS, "(read only)\n");
a34c0932c Joe Perches 2015-05-05 250 arc_cont(D_INIT_REASONS, "S3: ");
d0f6ecad3 Al Viro 2005-12-02 251 goto out2;
^1da177e4 Linus Torvalds 2005-04-16 252 }
a34c0932c Joe Perches 2015-05-05 253 arc_cont(D_INIT_REASONS, "\n");
a34c0932c Joe Perches 2015-05-05 254 arc_cont(D_INIT_REASONS, "S3: ");
72aeea484 Joe Perches 2015-05-05 255 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 256 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 257 iomem[index] = base;
d0f6ecad3 Al Viro 2005-12-02 258 continue;
d0f6ecad3 Al Viro 2005-12-02 259 out2:
d0f6ecad3 Al Viro 2005-12-02 260 iounmap(base);
d0f6ecad3 Al Viro 2005-12-02 261 out1:
d0f6ecad3 Al Viro 2005-12-02 262 release_mem_region(*p, MIRROR_SIZE);
d0f6ecad3 Al Viro 2005-12-02 263 out:
d0f6ecad3 Al Viro 2005-12-02 264 *p-- = shmems[--numshmems];
d0f6ecad3 Al Viro 2005-12-02 265 index--;
^1da177e4 Linus Torvalds 2005-04-16 266 }
a34c0932c Joe Perches 2015-05-05 267 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 268
^1da177e4 Linus Torvalds 2005-04-16 269 if (!numshmems) {
a34c0932c Joe Perches 2015-05-05 270 arc_cont(D_NORMAL, "S3: No ARCnet cards found.\n");
^1da177e4 Linus Torvalds 2005-04-16 271 for (port = &ports[0]; port < ports + numports; port++)
^1da177e4 Linus Torvalds 2005-04-16 272 release_region(*port, ARCNET_TOTAL_SIZE);
d0f6ecad3 Al Viro 2005-12-02 273 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 274 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 275 return;
^1da177e4 Linus Torvalds 2005-04-16 276 }
^1da177e4 Linus Torvalds 2005-04-16 277 /* Stage 4: something of a dummy, to report the shmems that are
^1da177e4 Linus Torvalds 2005-04-16 278 * still possible after stage 3.
^1da177e4 Linus Torvalds 2005-04-16 279 */
^1da177e4 Linus Torvalds 2005-04-16 280 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 281 for (p = &shmems[0]; p < shmems + numshmems; p++) {
^1da177e4 Linus Torvalds 2005-04-16 282 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 283 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 284 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 285 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 286 arc_cont(D_INIT, "S4: ");
^1da177e4 Linus Torvalds 2005-04-16 287 }
a34c0932c Joe Perches 2015-05-05 288 arc_cont(D_INIT, "%lXh ", *p);
^1da177e4 Linus Torvalds 2005-04-16 289 }
a34c0932c Joe Perches 2015-05-05 290 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 291
^1da177e4 Linus Torvalds 2005-04-16 292 /* Stage 5: for any ports that have the correct status, can disable
^1da177e4 Linus Torvalds 2005-04-16 293 * the RESET flag, and (if no irq is given) generate an autoirq,
^1da177e4 Linus Torvalds 2005-04-16 294 * register an ARCnet device.
^1da177e4 Linus Torvalds 2005-04-16 295 *
^1da177e4 Linus Torvalds 2005-04-16 296 * Currently, we can only register one device per probe, so quit
^1da177e4 Linus Torvalds 2005-04-16 297 * after the first one is found.
^1da177e4 Linus Torvalds 2005-04-16 298 */
^1da177e4 Linus Torvalds 2005-04-16 299 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 300 for (port = &ports[0]; port < ports + numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 301 int found = 0;
01a1d5ac4 Joe Perches 2015-05-05 302
^1da177e4 Linus Torvalds 2005-04-16 303 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 304 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 305 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 306 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 307 arc_cont(D_INIT, "S5: ");
^1da177e4 Linus Torvalds 2005-04-16 308 }
a34c0932c Joe Perches 2015-05-05 309 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 310
^1da177e4 Linus Torvalds 2005-04-16 311 ioaddr = *port;
09dfbcd5d Joe Perches 2015-05-05 312 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^1da177e4 Linus Torvalds 2005-04-16 313
^1da177e4 Linus Torvalds 2005-04-16 314 if ((status & 0x9D)
^1da177e4 Linus Torvalds 2005-04-16 315 != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
a34c0932c Joe Perches 2015-05-05 316 arc_cont(D_INIT_REASONS, "(status=%Xh)\n", status);
a34c0932c Joe Perches 2015-05-05 317 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 318 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 319 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 320 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 321 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 322 continue;
^1da177e4 Linus Torvalds 2005-04-16 323 }
09dfbcd5d Joe Perches 2015-05-05 324 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
09dfbcd5d Joe Perches 2015-05-05 325 ioaddr, COM9026_REG_W_COMMAND);
09dfbcd5d Joe Perches 2015-05-05 326 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^1da177e4 Linus Torvalds 2005-04-16 327 if (status & RESETflag) {
a34c0932c Joe Perches 2015-05-05 328 arc_cont(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
^1da177e4 Linus Torvalds 2005-04-16 329 status);
a34c0932c Joe Perches 2015-05-05 330 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 331 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 332 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 333 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 334 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 335 continue;
^1da177e4 Linus Torvalds 2005-04-16 336 }
^1da177e4 Linus Torvalds 2005-04-16 337 /* skip this completely if an IRQ was given, because maybe
^1da177e4 Linus Torvalds 2005-04-16 338 * we're on a machine that locks during autoirq!
^1da177e4 Linus Torvalds 2005-04-16 339 */
^1da177e4 Linus Torvalds 2005-04-16 340 if (!irq) {
^1da177e4 Linus Torvalds 2005-04-16 341 /* if we do this, we're sure to get an IRQ since the
^1da177e4 Linus Torvalds 2005-04-16 342 * card has just reset and the NORXflag is on until
^1da177e4 Linus Torvalds 2005-04-16 343 * we tell it to start receiving.
^1da177e4 Linus Torvalds 2005-04-16 344 */
^1da177e4 Linus Torvalds 2005-04-16 345 airqmask = probe_irq_on();
09dfbcd5d Joe Perches 2015-05-05 346 arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 347 udelay(1);
09dfbcd5d Joe Perches 2015-05-05 348 arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 349 airq = probe_irq_off(airqmask);
^1da177e4 Linus Torvalds 2005-04-16 350
^1da177e4 Linus Torvalds 2005-04-16 351 if (airq <= 0) {
a34c0932c Joe Perches 2015-05-05 352 arc_cont(D_INIT_REASONS, "(airq=%d)\n", airq);
a34c0932c Joe Perches 2015-05-05 353 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 354 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 355 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 356 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 357 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 358 continue;
^1da177e4 Linus Torvalds 2005-04-16 359 }
^1da177e4 Linus Torvalds 2005-04-16 360 } else {
^1da177e4 Linus Torvalds 2005-04-16 361 airq = irq;
^1da177e4 Linus Torvalds 2005-04-16 362 }
^1da177e4 Linus Torvalds 2005-04-16 363
a34c0932c Joe Perches 2015-05-05 364 arc_cont(D_INIT, "(%d,", airq);
^1da177e4 Linus Torvalds 2005-04-16 365 openparen = 1;
^1da177e4 Linus Torvalds 2005-04-16 366
^1da177e4 Linus Torvalds 2005-04-16 367 /* Everything seems okay. But which shmem, if any, puts
^1da177e4 Linus Torvalds 2005-04-16 368 * back its signature byte when the card is reset?
^1da177e4 Linus Torvalds 2005-04-16 369 *
^1da177e4 Linus Torvalds 2005-04-16 370 * If there are multiple cards installed, there might be
^1da177e4 Linus Torvalds 2005-04-16 371 * multiple shmems still in the list.
^1da177e4 Linus Torvalds 2005-04-16 372 */
^1da177e4 Linus Torvalds 2005-04-16 373 #ifdef FAST_PROBE
^1da177e4 Linus Torvalds 2005-04-16 374 if (numports > 1 || numshmems > 1) {
09dfbcd5d Joe Perches 2015-05-05 375 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 376 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 377 } else {
^1da177e4 Linus Torvalds 2005-04-16 378 /* just one shmem and port, assume they match */
a11a5442d Joe Perches 2015-05-05 379 arcnet_writeb(TESTvalue, iomem[0],
a11a5442d Joe Perches 2015-05-05 380 COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 381 }
^1da177e4 Linus Torvalds 2005-04-16 382 #else
09dfbcd5d Joe Perches 2015-05-05 383 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 384 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 385 #endif
^1da177e4 Linus Torvalds 2005-04-16 386
d0f6ecad3 Al Viro 2005-12-02 387 for (index = 0; index < numshmems; index++) {
d0f6ecad3 Al Viro 2005-12-02 388 u_long ptr = shmems[index];
d0f6ecad3 Al Viro 2005-12-02 389 void __iomem *base = iomem[index];
^1da177e4 Linus Torvalds 2005-04-16 390
a11a5442d Joe Perches 2015-05-05 391 if (arcnet_readb(base, COM9026_REG_R_STATUS) == TESTvalue) { /* found one */
a34c0932c Joe Perches 2015-05-05 392 arc_cont(D_INIT, "%lXh)\n", *p);
^1da177e4 Linus Torvalds 2005-04-16 393 openparen = 0;
^1da177e4 Linus Torvalds 2005-04-16 394
^1da177e4 Linus Torvalds 2005-04-16 395 /* register the card */
d0f6ecad3 Al Viro 2005-12-02 396 if (com90xx_found(*port, airq, ptr, base) == 0)
^1da177e4 Linus Torvalds 2005-04-16 397 found = 1;
^1da177e4 Linus Torvalds 2005-04-16 398 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 399
^1da177e4 Linus Torvalds 2005-04-16 400 /* remove shmem from the list */
d0f6ecad3 Al Viro 2005-12-02 401 shmems[index] = shmems[--numshmems];
d0f6ecad3 Al Viro 2005-12-02 402 iomem[index] = iomem[numshmems];
^1da177e4 Linus Torvalds 2005-04-16 403 break; /* go to the next I/O port */
^1da177e4 Linus Torvalds 2005-04-16 404 } else {
a11a5442d Joe Perches 2015-05-05 405 arc_cont(D_INIT_REASONS, "%Xh-",
a11a5442d Joe Perches 2015-05-05 406 arcnet_readb(base, COM9026_REG_R_STATUS));
^1da177e4 Linus Torvalds 2005-04-16 407 }
^1da177e4 Linus Torvalds 2005-04-16 408 }
^1da177e4 Linus Torvalds 2005-04-16 409
^1da177e4 Linus Torvalds 2005-04-16 410 if (openparen) {
72aeea484 Joe Perches 2015-05-05 411 if (BUGLVL(D_INIT))
05a24b234 Joe Perches 2015-05-05 412 pr_cont("no matching shmem)\n");
72aeea484 Joe Perches 2015-05-05 413 if (BUGLVL(D_INIT_REASONS)) {
05a24b234 Joe Perches 2015-05-05 414 pr_cont("S5: ");
72aeea484 Joe Perches 2015-05-05 415 numprint = 0;
72aeea484 Joe Perches 2015-05-05 416 }
^1da177e4 Linus Torvalds 2005-04-16 417 }
^1da177e4 Linus Torvalds 2005-04-16 418 if (!found)
^1da177e4 Linus Torvalds 2005-04-16 419 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 420 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 421 }
^1da177e4 Linus Torvalds 2005-04-16 422
72aeea484 Joe Perches 2015-05-05 423 if (BUGLVL(D_INIT_REASONS))
05a24b234 Joe Perches 2015-05-05 424 pr_cont("\n");
^1da177e4 Linus Torvalds 2005-04-16 425
^1da177e4 Linus Torvalds 2005-04-16 426 /* Now put back TESTvalue on all leftover shmems. */
d0f6ecad3 Al Viro 2005-12-02 427 for (index = 0; index < numshmems; index++) {
a11a5442d Joe Perches 2015-05-05 428 arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
d0f6ecad3 Al Viro 2005-12-02 429 iounmap(iomem[index]);
d0f6ecad3 Al Viro 2005-12-02 430 release_mem_region(shmems[index], MIRROR_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 431 }
d0f6ecad3 Al Viro 2005-12-02 432 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 433 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 434 }
^1da177e4 Linus Torvalds 2005-04-16 435

:::::: The code at line 233 was first introduced by commit
:::::: a11a5442d108357d44d34407ce2ed9d77ab424a0 arcnet: com90xx: Use arcnet_readb/writeb routines

:::::: TO: Joe Perches <[email protected]>
:::::: CC: Michael Grzeschik <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (31.92 kB)
.config.gz (61.72 kB)
Download all attachments

2018-05-20 03:01:03

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

Hi Andrea,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andrea-Greco/arcnet-com20020-Add-com20020-io-mapped-version/20180520-083936
config: alpha-allmodconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha

All warnings (new ones prefixed by >>):

In file included from drivers/net/arcnet/com20020-isa.c:44:0:
drivers/net/arcnet/com20020.h: In function 'com20020_set_subaddress':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com20020.h:126:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com20020.h:128:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(val, ioaddr, COM20020_REG_W_SUBADR);
^~~~~~~~~~~
drivers/net/arcnet/com20020-isa.c: In function 'com20020isa_probe':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
>> drivers/net/arcnet/com20020-isa.c:70:6: note: in expansion of macro 'arcnet_inb'
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:88:28: note: in expansion of macro 'arcnet_inb'
netdev_warn(dev, fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
>> drivers/net/arcnet/com20020-isa.c:85:3: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:90:28: note: in expansion of macro 'arcnet_inb'
netdev_info(dev, fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
>> drivers/net/arcnet/com20020-isa.c:85:3: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
include/linux/dynamic_debug.h:144:12: note: in expansion of macro 'arcnet_inb'
##__VA_ARGS__); \
^~~~~~~~~~~
include/linux/netdevice.h:4419:2: note: in expansion of macro 'dynamic_netdev_dbg'
dynamic_netdev_dbg(__dev, format, ##args); \
^~~~~~~~~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:92:4: note: in expansion of macro 'netdev_dbg'
netdev_dbg(dev, fmt, ##__VA_ARGS__); \
^~~~~~~~~~
>> drivers/net/arcnet/com20020-isa.c:85:3: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
>> drivers/net/arcnet/com20020-isa.c:87:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com20020-isa.c:89:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com20020-isa.c:91:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com20020-isa.c:97:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com20020-isa.c:99:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
^~~~~~~~~~~

vim +/arcnet_inb +70 drivers/net/arcnet/com20020-isa.c

26c6d281 Joe Perches 2015-05-05 46
f2f0a16b Joe Perches 2015-05-05 47 /* We cannot (yet) probe for an IO mapped card, although we can check that
^1da177e Linus Torvalds 2005-04-16 48 * it's where we were told it was, and even do autoirq.
^1da177e Linus Torvalds 2005-04-16 49 */
^1da177e Linus Torvalds 2005-04-16 50 static int __init com20020isa_probe(struct net_device *dev)
^1da177e Linus Torvalds 2005-04-16 51 {
^1da177e Linus Torvalds 2005-04-16 52 int ioaddr;
^1da177e Linus Torvalds 2005-04-16 53 unsigned long airqmask;
454d7c9b Wang Chen 2008-11-12 54 struct arcnet_local *lp = netdev_priv(dev);
^1da177e Linus Torvalds 2005-04-16 55 int err;
^1da177e Linus Torvalds 2005-04-16 56
72aeea48 Joe Perches 2015-05-05 57 if (BUGLVL(D_NORMAL))
05a24b23 Joe Perches 2015-05-05 58 pr_info("%s\n", "COM20020 ISA support (by David Woodhouse et al.)");
^1da177e Linus Torvalds 2005-04-16 59
^1da177e Linus Torvalds 2005-04-16 60 ioaddr = dev->base_addr;
^1da177e Linus Torvalds 2005-04-16 61 if (!ioaddr) {
a34c0932 Joe Perches 2015-05-05 62 arc_printk(D_NORMAL, dev, "No autoprobe (yet) for IO mapped cards; you must specify the base address!\n");
^1da177e Linus Torvalds 2005-04-16 63 return -ENODEV;
^1da177e Linus Torvalds 2005-04-16 64 }
^1da177e Linus Torvalds 2005-04-16 65 if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) {
a34c0932 Joe Perches 2015-05-05 66 arc_printk(D_NORMAL, dev, "IO region %xh-%xh already allocated.\n",
^1da177e Linus Torvalds 2005-04-16 67 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
^1da177e Linus Torvalds 2005-04-16 68 return -ENXIO;
^1da177e Linus Torvalds 2005-04-16 69 }
0fec6513 Joe Perches 2015-05-05 @70 if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
a34c0932 Joe Perches 2015-05-05 71 arc_printk(D_NORMAL, dev, "IO address %x empty\n", ioaddr);
^1da177e Linus Torvalds 2005-04-16 72 err = -ENODEV;
^1da177e Linus Torvalds 2005-04-16 73 goto out;
^1da177e Linus Torvalds 2005-04-16 74 }
^1da177e Linus Torvalds 2005-04-16 75 if (com20020_check(dev)) {
^1da177e Linus Torvalds 2005-04-16 76 err = -ENODEV;
^1da177e Linus Torvalds 2005-04-16 77 goto out;
^1da177e Linus Torvalds 2005-04-16 78 }
^1da177e Linus Torvalds 2005-04-16 79
^1da177e Linus Torvalds 2005-04-16 80 if (!dev->irq) {
^1da177e Linus Torvalds 2005-04-16 81 /* if we do this, we're sure to get an IRQ since the
^1da177e Linus Torvalds 2005-04-16 82 * card has just reset and the NORXflag is on until
^1da177e Linus Torvalds 2005-04-16 83 * we tell it to start receiving.
^1da177e Linus Torvalds 2005-04-16 84 */
a34c0932 Joe Perches 2015-05-05 @85 arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
0fec6513 Joe Perches 2015-05-05 86 arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
0fec6513 Joe Perches 2015-05-05 @87 arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
^1da177e Linus Torvalds 2005-04-16 88 airqmask = probe_irq_on();
0fec6513 Joe Perches 2015-05-05 89 arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
^1da177e Linus Torvalds 2005-04-16 90 udelay(1);
0fec6513 Joe Perches 2015-05-05 91 arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
^1da177e Linus Torvalds 2005-04-16 92 dev->irq = probe_irq_off(airqmask);
^1da177e Linus Torvalds 2005-04-16 93
0a6efc78 Dan Carpenter 2010-07-17 94 if ((int)dev->irq <= 0) {
a34c0932 Joe Perches 2015-05-05 95 arc_printk(D_INIT_REASONS, dev, "Autoprobe IRQ failed first time\n");
^1da177e Linus Torvalds 2005-04-16 96 airqmask = probe_irq_on();
0fec6513 Joe Perches 2015-05-05 97 arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
^1da177e Linus Torvalds 2005-04-16 98 udelay(5);
0fec6513 Joe Perches 2015-05-05 99 arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
^1da177e Linus Torvalds 2005-04-16 100 dev->irq = probe_irq_off(airqmask);
0a6efc78 Dan Carpenter 2010-07-17 101 if ((int)dev->irq <= 0) {
a34c0932 Joe Perches 2015-05-05 102 arc_printk(D_NORMAL, dev, "Autoprobe IRQ failed.\n");
^1da177e Linus Torvalds 2005-04-16 103 err = -ENODEV;
^1da177e Linus Torvalds 2005-04-16 104 goto out;
^1da177e Linus Torvalds 2005-04-16 105 }
^1da177e Linus Torvalds 2005-04-16 106 }
^1da177e Linus Torvalds 2005-04-16 107 }
^1da177e Linus Torvalds 2005-04-16 108
^1da177e Linus Torvalds 2005-04-16 109 lp->card_name = "ISA COM20020";
97464edd Joe Perches 2015-05-05 110
97464edd Joe Perches 2015-05-05 111 err = com20020_found(dev, 0);
97464edd Joe Perches 2015-05-05 112 if (err != 0)
^1da177e Linus Torvalds 2005-04-16 113 goto out;
^1da177e Linus Torvalds 2005-04-16 114
^1da177e Linus Torvalds 2005-04-16 115 return 0;
^1da177e Linus Torvalds 2005-04-16 116
^1da177e Linus Torvalds 2005-04-16 117 out:
^1da177e Linus Torvalds 2005-04-16 118 release_region(ioaddr, ARCNET_TOTAL_SIZE);
^1da177e Linus Torvalds 2005-04-16 119 return err;
^1da177e Linus Torvalds 2005-04-16 120 }
^1da177e Linus Torvalds 2005-04-16 121

:::::: The code at line 70 was first introduced by commit
:::::: 0fec65130b9f11a73d74f47025491f97f82ba070 arcnet: com20020: Use arcnet_<I/O> routines

:::::: TO: Joe Perches <[email protected]>
:::::: CC: Michael Grzeschik <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (11.39 kB)
.config.gz (51.20 kB)
Download all attachments

2018-05-20 03:33:10

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

Hi Andrea,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andrea-Greco/arcnet-com20020-Add-com20020-io-mapped-version/20180520-083936
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

drivers/net/arcnet/com90xx.c:484:13: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:534:28: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:613:13: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:233:21: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:234:25: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:247:17: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/com90xx.c:248:21: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:391:29: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:405:33: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:428:17: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/com90xx.c:446:21: sparse: undefined identifier 'arcnet_readb'
>> drivers/net/arcnet/com90xx.c:233:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:234:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:247:30: sparse: call with no type!
drivers/net/arcnet/com90xx.c:248:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:391:41: sparse: call with no type!
drivers/net/arcnet/com90xx.c:405:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:428:30: sparse: call with no type!
drivers/net/arcnet/com90xx.c:446:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:484:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:485:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:486:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:534:40: sparse: call with no type!
drivers/net/arcnet/com90xx.c:613:25: sparse: call with no type!
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
In file included from drivers/net/arcnet/com90xx.c:40:0:
drivers/net/arcnet/com90xx.c: In function 'com90xx_probe':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:161:7: note: in expansion of macro 'arcnet_inb'
if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:171:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c:233:7: error: implicit declaration of function 'arcnet_readb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
^~~~~~~~~~~~
arcnet_outsb
drivers/net/arcnet/com90xx.c:247:3: error: implicit declaration of function 'arcnet_writeb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
^~~~~~~~~~~~~
arcnet_outsb
In file included from drivers/net/arcnet/com90xx.c:40:0:
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:312:12: note: in expansion of macro 'arcnet_inb'
status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:324:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:326:12: note: in expansion of macro 'arcnet_inb'
status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:346:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:348:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:383:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_command':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:565:2: note: in expansion of macro 'arcnet_outb'
arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_status':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:572:9: note: in expansion of macro 'arcnet_inb'
return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_setmask':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:579:2: note: in expansion of macro 'arcnet_outb'
arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_reset':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:88:28: note: in expansion of macro 'arcnet_inb'
netdev_warn(dev, fmt, ##__VA_ARGS__); 115- ^~~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:90:28: note: in expansion of macro 'arcnet_inb'
netdev_info(dev, fmt, ##__VA_ARGS__); 124- ^~~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
--
drivers/net/arcnet/arc-rimi.c:147:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:148:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:158:13: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:210:28: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:284:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:276:16: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:268:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:245:9: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:245:9: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:245:9: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:249:17: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:253:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:254:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:257:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:109:21: sparse: undefined identifier 'arcnet_readb'
>> drivers/net/arcnet/arc-rimi.c:109:33: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:147:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:148:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:158:25: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:159:25: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:160:25: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:210:40: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:245:9: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:245:9: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:245:9: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:249:30: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:253:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:254:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:257:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:268:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:276:28: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:284:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c: In function 'check_mirror':
drivers/net/arcnet/arc-rimi.c:109:7: error: implicit declaration of function 'arcnet_readb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
^~~~~~~~~~~~
arcnet_outsb
drivers/net/arcnet/arc-rimi.c: In function 'arcrimi_found':
drivers/net/arcnet/arc-rimi.c:147:2: error: implicit declaration of function 'arcnet_writeb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
arcnet_writeb(TESTvalue, p, COM9026_REG_W_INTMASK);
^~~~~~~~~~~~~
arcnet_outsb
cc1: some warnings being treated as errors

vim +233 drivers/net/arcnet/com90xx.c

^1da177e4 Linus Torvalds 2005-04-16 95
^1da177e4 Linus Torvalds 2005-04-16 96 static void __init com90xx_probe(void)
^1da177e4 Linus Torvalds 2005-04-16 97 {
^1da177e4 Linus Torvalds 2005-04-16 98 int count, status, ioaddr, numprint, airq, openparen = 0;
^1da177e4 Linus Torvalds 2005-04-16 99 unsigned long airqmask;
7f5e760c1 Joe Perches 2015-05-05 100 int ports[(0x3f0 - 0x200) / 16 + 1] = { 0 };
d0f6ecad3 Al Viro 2005-12-02 101 unsigned long *shmems;
d0f6ecad3 Al Viro 2005-12-02 102 void __iomem **iomem;
^1da177e4 Linus Torvalds 2005-04-16 103 int numports, numshmems, *port;
^1da177e4 Linus Torvalds 2005-04-16 104 u_long *p;
d0f6ecad3 Al Viro 2005-12-02 105 int index;
^1da177e4 Linus Torvalds 2005-04-16 106
^1da177e4 Linus Torvalds 2005-04-16 107 if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
^1da177e4 Linus Torvalds 2005-04-16 108 return;
^1da177e4 Linus Torvalds 2005-04-16 109
15901dc93 Andrew Morton 2006-04-01 110 shmems = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(unsigned long),
d0f6ecad3 Al Viro 2005-12-02 111 GFP_KERNEL);
d0f6ecad3 Al Viro 2005-12-02 112 if (!shmems)
d0f6ecad3 Al Viro 2005-12-02 113 return;
15901dc93 Andrew Morton 2006-04-01 114 iomem = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(void __iomem *),
d0f6ecad3 Al Viro 2005-12-02 115 GFP_KERNEL);
d0f6ecad3 Al Viro 2005-12-02 116 if (!iomem) {
d0f6ecad3 Al Viro 2005-12-02 117 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 118 return;
d0f6ecad3 Al Viro 2005-12-02 119 }
d0f6ecad3 Al Viro 2005-12-02 120
72aeea484 Joe Perches 2015-05-05 121 if (BUGLVL(D_NORMAL))
05a24b234 Joe Perches 2015-05-05 122 pr_info("%s\n", "COM90xx chipset support");
^1da177e4 Linus Torvalds 2005-04-16 123
^1da177e4 Linus Torvalds 2005-04-16 124 /* set up the arrays where we'll store the possible probe addresses */
^1da177e4 Linus Torvalds 2005-04-16 125 numports = numshmems = 0;
^1da177e4 Linus Torvalds 2005-04-16 126 if (io)
^1da177e4 Linus Torvalds 2005-04-16 127 ports[numports++] = io;
^1da177e4 Linus Torvalds 2005-04-16 128 else
^1da177e4 Linus Torvalds 2005-04-16 129 for (count = 0x200; count <= 0x3f0; count += 16)
^1da177e4 Linus Torvalds 2005-04-16 130 ports[numports++] = count;
^1da177e4 Linus Torvalds 2005-04-16 131 if (shmem)
^1da177e4 Linus Torvalds 2005-04-16 132 shmems[numshmems++] = shmem;
^1da177e4 Linus Torvalds 2005-04-16 133 else
^1da177e4 Linus Torvalds 2005-04-16 134 for (count = 0xA0000; count <= 0xFF800; count += 2048)
^1da177e4 Linus Torvalds 2005-04-16 135 shmems[numshmems++] = count;
^1da177e4 Linus Torvalds 2005-04-16 136
^1da177e4 Linus Torvalds 2005-04-16 137 /* Stage 1: abandon any reserved ports, or ones with status==0xFF
^1da177e4 Linus Torvalds 2005-04-16 138 * (empty), and reset any others by reading the reset port.
^1da177e4 Linus Torvalds 2005-04-16 139 */
^1da177e4 Linus Torvalds 2005-04-16 140 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 141 for (port = &ports[0]; port - ports < numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 142 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 143 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 144 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 145 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 146 arc_cont(D_INIT, "S1: ");
^1da177e4 Linus Torvalds 2005-04-16 147 }
a34c0932c Joe Perches 2015-05-05 148 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 149
^1da177e4 Linus Torvalds 2005-04-16 150 ioaddr = *port;
^1da177e4 Linus Torvalds 2005-04-16 151
d6d7d3ed5 Joe Perches 2015-05-05 152 if (!request_region(*port, ARCNET_TOTAL_SIZE,
d6d7d3ed5 Joe Perches 2015-05-05 153 "arcnet (90xx)")) {
a34c0932c Joe Perches 2015-05-05 154 arc_cont(D_INIT_REASONS, "(request_region)\n");
a34c0932c Joe Perches 2015-05-05 155 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 156 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 157 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 158 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 159 continue;
^1da177e4 Linus Torvalds 2005-04-16 160 }
09dfbcd5d Joe Perches 2015-05-05 161 if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
a34c0932c Joe Perches 2015-05-05 162 arc_cont(D_INIT_REASONS, "(empty)\n");
a34c0932c Joe Perches 2015-05-05 163 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 164 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 165 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 166 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 167 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 168 continue;
^1da177e4 Linus Torvalds 2005-04-16 169 }
09dfbcd5d Joe Perches 2015-05-05 170 /* begin resetting card */
09dfbcd5d Joe Perches 2015-05-05 171 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 172
a34c0932c Joe Perches 2015-05-05 173 arc_cont(D_INIT_REASONS, "\n");
a34c0932c Joe Perches 2015-05-05 174 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 175 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 176 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 177 }
a34c0932c Joe Perches 2015-05-05 178 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 179
^1da177e4 Linus Torvalds 2005-04-16 180 if (!numports) {
a34c0932c Joe Perches 2015-05-05 181 arc_cont(D_NORMAL, "S1: No ARCnet cards found.\n");
d0f6ecad3 Al Viro 2005-12-02 182 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 183 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 184 return;
^1da177e4 Linus Torvalds 2005-04-16 185 }
^1da177e4 Linus Torvalds 2005-04-16 186 /* Stage 2: we have now reset any possible ARCnet cards, so we can't
^1da177e4 Linus Torvalds 2005-04-16 187 * do anything until they finish. If D_INIT, print the list of
^1da177e4 Linus Torvalds 2005-04-16 188 * cards that are left.
^1da177e4 Linus Torvalds 2005-04-16 189 */
^1da177e4 Linus Torvalds 2005-04-16 190 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 191 for (port = &ports[0]; port < ports + numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 192 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 193 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 194 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 195 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 196 arc_cont(D_INIT, "S2: ");
^1da177e4 Linus Torvalds 2005-04-16 197 }
a34c0932c Joe Perches 2015-05-05 198 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 199 }
a34c0932c Joe Perches 2015-05-05 200 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 201 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 202
^1da177e4 Linus Torvalds 2005-04-16 203 /* Stage 3: abandon any shmem addresses that don't have the signature
^1da177e4 Linus Torvalds 2005-04-16 204 * 0xD1 byte in the right place, or are read-only.
^1da177e4 Linus Torvalds 2005-04-16 205 */
^1da177e4 Linus Torvalds 2005-04-16 206 numprint = -1;
d0f6ecad3 Al Viro 2005-12-02 207 for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
d0f6ecad3 Al Viro 2005-12-02 208 void __iomem *base;
^1da177e4 Linus Torvalds 2005-04-16 209
^1da177e4 Linus Torvalds 2005-04-16 210 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 211 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 212 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 213 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 214 arc_cont(D_INIT, "S3: ");
^1da177e4 Linus Torvalds 2005-04-16 215 }
a34c0932c Joe Perches 2015-05-05 216 arc_cont(D_INIT, "%lXh ", *p);
^1da177e4 Linus Torvalds 2005-04-16 217
d0f6ecad3 Al Viro 2005-12-02 218 if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
a34c0932c Joe Perches 2015-05-05 219 arc_cont(D_INIT_REASONS, "(request_mem_region)\n");
a34c0932c Joe Perches 2015-05-05 220 arc_cont(D_INIT_REASONS, "Stage 3: ");
72aeea484 Joe Perches 2015-05-05 221 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 222 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 223 goto out;
d0f6ecad3 Al Viro 2005-12-02 224 }
d0f6ecad3 Al Viro 2005-12-02 225 base = ioremap(*p, MIRROR_SIZE);
d0f6ecad3 Al Viro 2005-12-02 226 if (!base) {
a34c0932c Joe Perches 2015-05-05 227 arc_cont(D_INIT_REASONS, "(ioremap)\n");
a34c0932c Joe Perches 2015-05-05 228 arc_cont(D_INIT_REASONS, "Stage 3: ");
72aeea484 Joe Perches 2015-05-05 229 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 230 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 231 goto out1;
^1da177e4 Linus Torvalds 2005-04-16 232 }
a11a5442d Joe Perches 2015-05-05 @233 if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
a34c0932c Joe Perches 2015-05-05 234 arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
a11a5442d Joe Perches 2015-05-05 235 arcnet_readb(base, COM9026_REG_R_STATUS),
a11a5442d Joe Perches 2015-05-05 236 TESTvalue);
a34c0932c Joe Perches 2015-05-05 237 arc_cont(D_INIT_REASONS, "S3: ");
72aeea484 Joe Perches 2015-05-05 238 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 239 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 240 goto out2;
^1da177e4 Linus Torvalds 2005-04-16 241 }
^1da177e4 Linus Torvalds 2005-04-16 242 /* By writing 0x42 to the TESTvalue location, we also make
^1da177e4 Linus Torvalds 2005-04-16 243 * sure no "mirror" shmem areas show up - if they occur
^1da177e4 Linus Torvalds 2005-04-16 244 * in another pass through this loop, they will be discarded
^1da177e4 Linus Torvalds 2005-04-16 245 * because *cptr != TESTvalue.
^1da177e4 Linus Torvalds 2005-04-16 246 */
a11a5442d Joe Perches 2015-05-05 247 arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
a11a5442d Joe Perches 2015-05-05 248 if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
a34c0932c Joe Perches 2015-05-05 249 arc_cont(D_INIT_REASONS, "(read only)\n");
a34c0932c Joe Perches 2015-05-05 250 arc_cont(D_INIT_REASONS, "S3: ");
d0f6ecad3 Al Viro 2005-12-02 251 goto out2;
^1da177e4 Linus Torvalds 2005-04-16 252 }
a34c0932c Joe Perches 2015-05-05 253 arc_cont(D_INIT_REASONS, "\n");
a34c0932c Joe Perches 2015-05-05 254 arc_cont(D_INIT_REASONS, "S3: ");
72aeea484 Joe Perches 2015-05-05 255 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 256 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 257 iomem[index] = base;
d0f6ecad3 Al Viro 2005-12-02 258 continue;
d0f6ecad3 Al Viro 2005-12-02 259 out2:
d0f6ecad3 Al Viro 2005-12-02 260 iounmap(base);
d0f6ecad3 Al Viro 2005-12-02 261 out1:
d0f6ecad3 Al Viro 2005-12-02 262 release_mem_region(*p, MIRROR_SIZE);
d0f6ecad3 Al Viro 2005-12-02 263 out:
d0f6ecad3 Al Viro 2005-12-02 264 *p-- = shmems[--numshmems];
d0f6ecad3 Al Viro 2005-12-02 265 index--;
^1da177e4 Linus Torvalds 2005-04-16 266 }
a34c0932c Joe Perches 2015-05-05 267 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 268
^1da177e4 Linus Torvalds 2005-04-16 269 if (!numshmems) {
a34c0932c Joe Perches 2015-05-05 270 arc_cont(D_NORMAL, "S3: No ARCnet cards found.\n");
^1da177e4 Linus Torvalds 2005-04-16 271 for (port = &ports[0]; port < ports + numports; port++)
^1da177e4 Linus Torvalds 2005-04-16 272 release_region(*port, ARCNET_TOTAL_SIZE);
d0f6ecad3 Al Viro 2005-12-02 273 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 274 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 275 return;
^1da177e4 Linus Torvalds 2005-04-16 276 }
^1da177e4 Linus Torvalds 2005-04-16 277 /* Stage 4: something of a dummy, to report the shmems that are
^1da177e4 Linus Torvalds 2005-04-16 278 * still possible after stage 3.
^1da177e4 Linus Torvalds 2005-04-16 279 */
^1da177e4 Linus Torvalds 2005-04-16 280 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 281 for (p = &shmems[0]; p < shmems + numshmems; p++) {
^1da177e4 Linus Torvalds 2005-04-16 282 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 283 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 284 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 285 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 286 arc_cont(D_INIT, "S4: ");
^1da177e4 Linus Torvalds 2005-04-16 287 }
a34c0932c Joe Perches 2015-05-05 288 arc_cont(D_INIT, "%lXh ", *p);
^1da177e4 Linus Torvalds 2005-04-16 289 }
a34c0932c Joe Perches 2015-05-05 290 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 291
^1da177e4 Linus Torvalds 2005-04-16 292 /* Stage 5: for any ports that have the correct status, can disable
^1da177e4 Linus Torvalds 2005-04-16 293 * the RESET flag, and (if no irq is given) generate an autoirq,
^1da177e4 Linus Torvalds 2005-04-16 294 * register an ARCnet device.
^1da177e4 Linus Torvalds 2005-04-16 295 *
^1da177e4 Linus Torvalds 2005-04-16 296 * Currently, we can only register one device per probe, so quit
^1da177e4 Linus Torvalds 2005-04-16 297 * after the first one is found.
^1da177e4 Linus Torvalds 2005-04-16 298 */
^1da177e4 Linus Torvalds 2005-04-16 299 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 300 for (port = &ports[0]; port < ports + numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 301 int found = 0;
01a1d5ac4 Joe Perches 2015-05-05 302
^1da177e4 Linus Torvalds 2005-04-16 303 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 304 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 305 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 306 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 307 arc_cont(D_INIT, "S5: ");
^1da177e4 Linus Torvalds 2005-04-16 308 }
a34c0932c Joe Perches 2015-05-05 309 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 310
^1da177e4 Linus Torvalds 2005-04-16 311 ioaddr = *port;
09dfbcd5d Joe Perches 2015-05-05 312 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^1da177e4 Linus Torvalds 2005-04-16 313
^1da177e4 Linus Torvalds 2005-04-16 314 if ((status & 0x9D)
^1da177e4 Linus Torvalds 2005-04-16 315 != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
a34c0932c Joe Perches 2015-05-05 316 arc_cont(D_INIT_REASONS, "(status=%Xh)\n", status);
a34c0932c Joe Perches 2015-05-05 317 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 318 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 319 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 320 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 321 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 322 continue;
^1da177e4 Linus Torvalds 2005-04-16 323 }
09dfbcd5d Joe Perches 2015-05-05 324 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
09dfbcd5d Joe Perches 2015-05-05 325 ioaddr, COM9026_REG_W_COMMAND);
09dfbcd5d Joe Perches 2015-05-05 326 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^1da177e4 Linus Torvalds 2005-04-16 327 if (status & RESETflag) {
a34c0932c Joe Perches 2015-05-05 328 arc_cont(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
^1da177e4 Linus Torvalds 2005-04-16 329 status);
a34c0932c Joe Perches 2015-05-05 330 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 331 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 332 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 333 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 334 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 335 continue;
^1da177e4 Linus Torvalds 2005-04-16 336 }
^1da177e4 Linus Torvalds 2005-04-16 337 /* skip this completely if an IRQ was given, because maybe
^1da177e4 Linus Torvalds 2005-04-16 338 * we're on a machine that locks during autoirq!
^1da177e4 Linus Torvalds 2005-04-16 339 */
^1da177e4 Linus Torvalds 2005-04-16 340 if (!irq) {
^1da177e4 Linus Torvalds 2005-04-16 341 /* if we do this, we're sure to get an IRQ since the
^1da177e4 Linus Torvalds 2005-04-16 342 * card has just reset and the NORXflag is on until
^1da177e4 Linus Torvalds 2005-04-16 343 * we tell it to start receiving.
^1da177e4 Linus Torvalds 2005-04-16 344 */
^1da177e4 Linus Torvalds 2005-04-16 345 airqmask = probe_irq_on();
09dfbcd5d Joe Perches 2015-05-05 346 arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 347 udelay(1);
09dfbcd5d Joe Perches 2015-05-05 348 arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 349 airq = probe_irq_off(airqmask);
^1da177e4 Linus Torvalds 2005-04-16 350
^1da177e4 Linus Torvalds 2005-04-16 351 if (airq <= 0) {
a34c0932c Joe Perches 2015-05-05 352 arc_cont(D_INIT_REASONS, "(airq=%d)\n", airq);
a34c0932c Joe Perches 2015-05-05 353 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 354 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 355 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 356 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 357 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 358 continue;
^1da177e4 Linus Torvalds 2005-04-16 359 }
^1da177e4 Linus Torvalds 2005-04-16 360 } else {
^1da177e4 Linus Torvalds 2005-04-16 361 airq = irq;
^1da177e4 Linus Torvalds 2005-04-16 362 }
^1da177e4 Linus Torvalds 2005-04-16 363
a34c0932c Joe Perches 2015-05-05 364 arc_cont(D_INIT, "(%d,", airq);
^1da177e4 Linus Torvalds 2005-04-16 365 openparen = 1;
^1da177e4 Linus Torvalds 2005-04-16 366
^1da177e4 Linus Torvalds 2005-04-16 367 /* Everything seems okay. But which shmem, if any, puts
^1da177e4 Linus Torvalds 2005-04-16 368 * back its signature byte when the card is reset?
^1da177e4 Linus Torvalds 2005-04-16 369 *
^1da177e4 Linus Torvalds 2005-04-16 370 * If there are multiple cards installed, there might be
^1da177e4 Linus Torvalds 2005-04-16 371 * multiple shmems still in the list.
^1da177e4 Linus Torvalds 2005-04-16 372 */
^1da177e4 Linus Torvalds 2005-04-16 373 #ifdef FAST_PROBE
^1da177e4 Linus Torvalds 2005-04-16 374 if (numports > 1 || numshmems > 1) {
09dfbcd5d Joe Perches 2015-05-05 375 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 376 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 377 } else {
^1da177e4 Linus Torvalds 2005-04-16 378 /* just one shmem and port, assume they match */
a11a5442d Joe Perches 2015-05-05 379 arcnet_writeb(TESTvalue, iomem[0],
a11a5442d Joe Perches 2015-05-05 380 COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 381 }
^1da177e4 Linus Torvalds 2005-04-16 382 #else
09dfbcd5d Joe Perches 2015-05-05 383 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 384 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 385 #endif
^1da177e4 Linus Torvalds 2005-04-16 386
d0f6ecad3 Al Viro 2005-12-02 387 for (index = 0; index < numshmems; index++) {
d0f6ecad3 Al Viro 2005-12-02 388 u_long ptr = shmems[index];
d0f6ecad3 Al Viro 2005-12-02 389 void __iomem *base = iomem[index];
^1da177e4 Linus Torvalds 2005-04-16 390
a11a5442d Joe Perches 2015-05-05 @391 if (arcnet_readb(base, COM9026_REG_R_STATUS) == TESTvalue) { /* found one */
a34c0932c Joe Perches 2015-05-05 392 arc_cont(D_INIT, "%lXh)\n", *p);
^1da177e4 Linus Torvalds 2005-04-16 393 openparen = 0;
^1da177e4 Linus Torvalds 2005-04-16 394
^1da177e4 Linus Torvalds 2005-04-16 395 /* register the card */
d0f6ecad3 Al Viro 2005-12-02 396 if (com90xx_found(*port, airq, ptr, base) == 0)
^1da177e4 Linus Torvalds 2005-04-16 397 found = 1;
^1da177e4 Linus Torvalds 2005-04-16 398 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 399
^1da177e4 Linus Torvalds 2005-04-16 400 /* remove shmem from the list */
d0f6ecad3 Al Viro 2005-12-02 401 shmems[index] = shmems[--numshmems];
d0f6ecad3 Al Viro 2005-12-02 402 iomem[index] = iomem[numshmems];
^1da177e4 Linus Torvalds 2005-04-16 403 break; /* go to the next I/O port */
^1da177e4 Linus Torvalds 2005-04-16 404 } else {
a11a5442d Joe Perches 2015-05-05 405 arc_cont(D_INIT_REASONS, "%Xh-",
a11a5442d Joe Perches 2015-05-05 406 arcnet_readb(base, COM9026_REG_R_STATUS));
^1da177e4 Linus Torvalds 2005-04-16 407 }
^1da177e4 Linus Torvalds 2005-04-16 408 }
^1da177e4 Linus Torvalds 2005-04-16 409
^1da177e4 Linus Torvalds 2005-04-16 410 if (openparen) {
72aeea484 Joe Perches 2015-05-05 411 if (BUGLVL(D_INIT))
05a24b234 Joe Perches 2015-05-05 412 pr_cont("no matching shmem)\n");
72aeea484 Joe Perches 2015-05-05 413 if (BUGLVL(D_INIT_REASONS)) {
05a24b234 Joe Perches 2015-05-05 414 pr_cont("S5: ");
72aeea484 Joe Perches 2015-05-05 415 numprint = 0;
72aeea484 Joe Perches 2015-05-05 416 }
^1da177e4 Linus Torvalds 2005-04-16 417 }
^1da177e4 Linus Torvalds 2005-04-16 418 if (!found)
^1da177e4 Linus Torvalds 2005-04-16 419 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 420 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 421 }
^1da177e4 Linus Torvalds 2005-04-16 422
72aeea484 Joe Perches 2015-05-05 423 if (BUGLVL(D_INIT_REASONS))
05a24b234 Joe Perches 2015-05-05 424 pr_cont("\n");
^1da177e4 Linus Torvalds 2005-04-16 425
^1da177e4 Linus Torvalds 2005-04-16 426 /* Now put back TESTvalue on all leftover shmems. */
d0f6ecad3 Al Viro 2005-12-02 427 for (index = 0; index < numshmems; index++) {
a11a5442d Joe Perches 2015-05-05 428 arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
d0f6ecad3 Al Viro 2005-12-02 429 iounmap(iomem[index]);
d0f6ecad3 Al Viro 2005-12-02 430 release_mem_region(shmems[index], MIRROR_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 431 }
d0f6ecad3 Al Viro 2005-12-02 432 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 433 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 434 }
^1da177e4 Linus Torvalds 2005-04-16 435

:::::: The code at line 233 was first introduced by commit
:::::: a11a5442d108357d44d34407ce2ed9d77ab424a0 arcnet: com90xx: Use arcnet_readb/writeb routines

:::::: TO: Joe Perches <[email protected]>
:::::: CC: Michael Grzeschik <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

2018-05-22 14:45:17

by Andrea Greco

[permalink] [raw]
Subject: Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version

On 05/18/2018 07:51 PM, David Miller wrote:
> From: Andrea Greco <[email protected]>
> Date: Fri, 18 May 2018 14:18:41 +0200
>
>> In com20020.c found this:
>> /* FIXME: do this some other way! */
>> if (!dev->dev_addr[0])
>> dev->dev_addr[0] = arcnet_inb(ioaddr, 8);
>>
>> NODE-ID, must be univoque, for all arcnet network.
>> My previews idea was take random value but, this could create a
>> collision over network.
>>
>> A possible solution is:
>> In case of collision com20020 set a bit in status register.
>> Then peak a new NODE-ID and repeat this while correct NODE-ID is found.
>>
>> Other ideas is pass it via DTS.
>> But suppose have 2 same product in same network, same address same problem.
>> For this reason i prefer left standard driver behavior.
>>
>> Other ideas for solve this ?
>
> Is there no way to obtain a unique value from the device?
>
> If having a unique ID to talk on the ARCNET is so critical, there must
> be some way to properly allocation and use a unique ID.

Device can rise interrupt in case of Duplicate ID over the network.

> I guess this must be a general problem with this driver already.
I think arcnet network and relative NODE-ID designed during project
phase, and address is always fixed.

In fact:
Other version of this dirver: PCI, ISA friends.
Simple work as module, and Node-ID is param of modules.

My opinion is that:
Before run `ifconfig arc0 up`, user has to setup hardware address with
`ip link set dev arc0 address D2`.

All this is like a IP network with static address. If your IP address is
duplicated, is not IP problem.

> You still need to address the issue of 'dev' being leaked on probe
> error paths.
For solve this,i think all considered a random address could be a good
solution.

Regards, Andrea