diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2013-10-04 03:38:53 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2013-11-26 05:09:09 -0500 |
commit | bd9ba8f40ee30edf31cc0845d8838bc43d172ef3 (patch) | |
tree | 4c073ce3a53d7cccbc3ac7335854d424faa2c289 | |
parent | 986ea58dfb52097999cc388880505fc7a10e4779 (diff) |
zorro/UAPI: Use proper types (endianness/size) in <linux/zorro.h>
Fix member definitions for non-native userspace handling:
- All multi-byte values are big-endian, hence use __be*,
- All pointers are 32-bit pointers under AmigaOS, but unused (except for
cd_BoardAddr) under Linux, hence use __be32.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r-- | arch/m68k/amiga/config.c | 9 | ||||
-rw-r--r-- | arch/m68k/amiga/platform.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/amd/a2065.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/amd/ariadne.c | 9 | ||||
-rw-r--r-- | drivers/zorro/proc.c | 10 | ||||
-rw-r--r-- | drivers/zorro/zorro-sysfs.c | 22 | ||||
-rw-r--r-- | drivers/zorro/zorro.c | 4 | ||||
-rw-r--r-- | include/uapi/linux/zorro.h | 46 |
8 files changed, 72 insertions, 46 deletions
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index acd9c1640cfc..65b5e937ebba 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/keyboard.h> | 28 | #include <linux/keyboard.h> |
29 | 29 | ||
30 | #include <asm/bootinfo.h> | 30 | #include <asm/bootinfo.h> |
31 | #include <asm/byteorder.h> | ||
31 | #include <asm/setup.h> | 32 | #include <asm/setup.h> |
32 | #include <asm/pgtable.h> | 33 | #include <asm/pgtable.h> |
33 | #include <asm/amigahw.h> | 34 | #include <asm/amigahw.h> |
@@ -176,10 +177,10 @@ int __init amiga_parse_bootinfo(const struct bi_record *record) | |||
176 | const struct ConfigDev *cd = (struct ConfigDev *)data; | 177 | const struct ConfigDev *cd = (struct ConfigDev *)data; |
177 | struct zorro_dev_init *dev = &zorro_autocon_init[zorro_num_autocon++]; | 178 | struct zorro_dev_init *dev = &zorro_autocon_init[zorro_num_autocon++]; |
178 | dev->rom = cd->cd_Rom; | 179 | dev->rom = cd->cd_Rom; |
179 | dev->slotaddr = cd->cd_SlotAddr; | 180 | dev->slotaddr = be16_to_cpu(cd->cd_SlotAddr); |
180 | dev->slotsize = cd->cd_SlotSize; | 181 | dev->slotsize = be16_to_cpu(cd->cd_SlotSize); |
181 | dev->boardaddr = (u32)cd->cd_BoardAddr; | 182 | dev->boardaddr = be32_to_cpu(cd->cd_BoardAddr); |
182 | dev->boardsize = cd->cd_BoardSize; | 183 | dev->boardsize = be32_to_cpu(cd->cd_BoardSize); |
183 | } else | 184 | } else |
184 | printk("amiga_parse_bootinfo: too many AutoConfig devices\n"); | 185 | printk("amiga_parse_bootinfo: too many AutoConfig devices\n"); |
185 | #endif /* CONFIG_ZORRO */ | 186 | #endif /* CONFIG_ZORRO */ |
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index 7847b2b1b5b6..d34029d7b058 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <asm/amigahw.h> | 14 | #include <asm/amigahw.h> |
15 | #include <asm/amigayle.h> | 15 | #include <asm/amigayle.h> |
16 | #include <asm/byteorder.h> | ||
16 | 17 | ||
17 | 18 | ||
18 | #ifdef CONFIG_ZORRO | 19 | #ifdef CONFIG_ZORRO |
@@ -66,10 +67,12 @@ static int __init z_dev_present(zorro_id id) | |||
66 | { | 67 | { |
67 | unsigned int i; | 68 | unsigned int i; |
68 | 69 | ||
69 | for (i = 0; i < zorro_num_autocon; i++) | 70 | for (i = 0; i < zorro_num_autocon; i++) { |
70 | if (zorro_autocon_init[i].rom.er_Manufacturer == ZORRO_MANUF(id) && | 71 | const struct ExpansionRom *rom = &zorro_autocon_init[i].rom; |
71 | zorro_autocon_init[i].rom.er_Product == ZORRO_PROD(id)) | 72 | if (be16_to_cpu(rom->er_Manufacturer) == ZORRO_MANUF(id) && |
73 | rom->er_Product == ZORRO_PROD(id)) | ||
72 | return 1; | 74 | return 1; |
75 | } | ||
73 | 76 | ||
74 | return 0; | 77 | return 0; |
75 | } | 78 | } |
diff --git a/drivers/net/ethernet/amd/a2065.c b/drivers/net/ethernet/amd/a2065.c index f492a19328e5..56139184b801 100644 --- a/drivers/net/ethernet/amd/a2065.c +++ b/drivers/net/ethernet/amd/a2065.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/zorro.h> | 57 | #include <linux/zorro.h> |
58 | #include <linux/bitops.h> | 58 | #include <linux/bitops.h> |
59 | 59 | ||
60 | #include <asm/byteorder.h> | ||
60 | #include <asm/irq.h> | 61 | #include <asm/irq.h> |
61 | #include <asm/amigaints.h> | 62 | #include <asm/amigaints.h> |
62 | #include <asm/amigahw.h> | 63 | #include <asm/amigahw.h> |
@@ -678,6 +679,7 @@ static int a2065_init_one(struct zorro_dev *z, | |||
678 | unsigned long base_addr = board + A2065_LANCE; | 679 | unsigned long base_addr = board + A2065_LANCE; |
679 | unsigned long mem_start = board + A2065_RAM; | 680 | unsigned long mem_start = board + A2065_RAM; |
680 | struct resource *r1, *r2; | 681 | struct resource *r1, *r2; |
682 | u32 serial; | ||
681 | int err; | 683 | int err; |
682 | 684 | ||
683 | r1 = request_mem_region(base_addr, sizeof(struct lance_regs), | 685 | r1 = request_mem_region(base_addr, sizeof(struct lance_regs), |
@@ -702,6 +704,7 @@ static int a2065_init_one(struct zorro_dev *z, | |||
702 | r1->name = dev->name; | 704 | r1->name = dev->name; |
703 | r2->name = dev->name; | 705 | r2->name = dev->name; |
704 | 706 | ||
707 | serial = be32_to_cpu(z->rom.er_SerialNumber); | ||
705 | dev->dev_addr[0] = 0x00; | 708 | dev->dev_addr[0] = 0x00; |
706 | if (z->id != ZORRO_PROD_AMERISTAR_A2065) { /* Commodore */ | 709 | if (z->id != ZORRO_PROD_AMERISTAR_A2065) { /* Commodore */ |
707 | dev->dev_addr[1] = 0x80; | 710 | dev->dev_addr[1] = 0x80; |
@@ -710,9 +713,9 @@ static int a2065_init_one(struct zorro_dev *z, | |||
710 | dev->dev_addr[1] = 0x00; | 713 | dev->dev_addr[1] = 0x00; |
711 | dev->dev_addr[2] = 0x9f; | 714 | dev->dev_addr[2] = 0x9f; |
712 | } | 715 | } |
713 | dev->dev_addr[3] = (z->rom.er_SerialNumber >> 16) & 0xff; | 716 | dev->dev_addr[3] = (serial >> 16) & 0xff; |
714 | dev->dev_addr[4] = (z->rom.er_SerialNumber >> 8) & 0xff; | 717 | dev->dev_addr[4] = (serial >> 8) & 0xff; |
715 | dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; | 718 | dev->dev_addr[5] = serial & 0xff; |
716 | dev->base_addr = (unsigned long)ZTWO_VADDR(base_addr); | 719 | dev->base_addr = (unsigned long)ZTWO_VADDR(base_addr); |
717 | dev->mem_start = (unsigned long)ZTWO_VADDR(mem_start); | 720 | dev->mem_start = (unsigned long)ZTWO_VADDR(mem_start); |
718 | dev->mem_end = dev->mem_start + A2065_RAM_SIZE; | 721 | dev->mem_end = dev->mem_start + A2065_RAM_SIZE; |
diff --git a/drivers/net/ethernet/amd/ariadne.c b/drivers/net/ethernet/amd/ariadne.c index 33822cb69366..b08101b31b8b 100644 --- a/drivers/net/ethernet/amd/ariadne.c +++ b/drivers/net/ethernet/amd/ariadne.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/zorro.h> | 51 | #include <linux/zorro.h> |
52 | #include <linux/bitops.h> | 52 | #include <linux/bitops.h> |
53 | 53 | ||
54 | #include <asm/byteorder.h> | ||
54 | #include <asm/amigaints.h> | 55 | #include <asm/amigaints.h> |
55 | #include <asm/amigahw.h> | 56 | #include <asm/amigahw.h> |
56 | #include <asm/irq.h> | 57 | #include <asm/irq.h> |
@@ -718,6 +719,7 @@ static int ariadne_init_one(struct zorro_dev *z, | |||
718 | struct resource *r1, *r2; | 719 | struct resource *r1, *r2; |
719 | struct net_device *dev; | 720 | struct net_device *dev; |
720 | struct ariadne_private *priv; | 721 | struct ariadne_private *priv; |
722 | u32 serial; | ||
721 | int err; | 723 | int err; |
722 | 724 | ||
723 | r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960"); | 725 | r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960"); |
@@ -741,12 +743,13 @@ static int ariadne_init_one(struct zorro_dev *z, | |||
741 | r1->name = dev->name; | 743 | r1->name = dev->name; |
742 | r2->name = dev->name; | 744 | r2->name = dev->name; |
743 | 745 | ||
746 | serial = be32_to_cpu(z->rom.er_SerialNumber); | ||
744 | dev->dev_addr[0] = 0x00; | 747 | dev->dev_addr[0] = 0x00; |
745 | dev->dev_addr[1] = 0x60; | 748 | dev->dev_addr[1] = 0x60; |
746 | dev->dev_addr[2] = 0x30; | 749 | dev->dev_addr[2] = 0x30; |
747 | dev->dev_addr[3] = (z->rom.er_SerialNumber >> 16) & 0xff; | 750 | dev->dev_addr[3] = (serial >> 16) & 0xff; |
748 | dev->dev_addr[4] = (z->rom.er_SerialNumber >> 8) & 0xff; | 751 | dev->dev_addr[4] = (serial >> 8) & 0xff; |
749 | dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; | 752 | dev->dev_addr[5] = serial & 0xff; |
750 | dev->base_addr = (unsigned long)ZTWO_VADDR(base_addr); | 753 | dev->base_addr = (unsigned long)ZTWO_VADDR(base_addr); |
751 | dev->mem_start = (unsigned long)ZTWO_VADDR(mem_start); | 754 | dev->mem_start = (unsigned long)ZTWO_VADDR(mem_start); |
752 | dev->mem_end = dev->mem_start + ARIADNE_RAM_SIZE; | 755 | dev->mem_end = dev->mem_start + ARIADNE_RAM_SIZE; |
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c index ea1ce822a8e0..6ac2579da0eb 100644 --- a/drivers/zorro/proc.c +++ b/drivers/zorro/proc.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/seq_file.h> | 14 | #include <linux/seq_file.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/export.h> | 16 | #include <linux/export.h> |
17 | |||
18 | #include <asm/byteorder.h> | ||
17 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
18 | #include <asm/amigahw.h> | 20 | #include <asm/amigahw.h> |
19 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
@@ -41,10 +43,10 @@ proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t * | |||
41 | /* Construct a ConfigDev */ | 43 | /* Construct a ConfigDev */ |
42 | memset(&cd, 0, sizeof(cd)); | 44 | memset(&cd, 0, sizeof(cd)); |
43 | cd.cd_Rom = z->rom; | 45 | cd.cd_Rom = z->rom; |
44 | cd.cd_SlotAddr = z->slotaddr; | 46 | cd.cd_SlotAddr = cpu_to_be16(z->slotaddr); |
45 | cd.cd_SlotSize = z->slotsize; | 47 | cd.cd_SlotSize = cpu_to_be16(z->slotsize); |
46 | cd.cd_BoardAddr = (void *)zorro_resource_start(z); | 48 | cd.cd_BoardAddr = cpu_to_be32(zorro_resource_start(z)); |
47 | cd.cd_BoardSize = zorro_resource_len(z); | 49 | cd.cd_BoardSize = cpu_to_be32(zorro_resource_len(z)); |
48 | 50 | ||
49 | if (copy_to_user(buf, (void *)&cd + pos, nbytes)) | 51 | if (copy_to_user(buf, (void *)&cd + pos, nbytes)) |
50 | return -EFAULT; | 52 | return -EFAULT; |
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c index 26f7184ef9e1..36b210f9b6b2 100644 --- a/drivers/zorro/zorro-sysfs.c +++ b/drivers/zorro/zorro-sysfs.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/stat.h> | 16 | #include <linux/stat.h> |
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | 18 | ||
19 | #include <asm/byteorder.h> | ||
20 | |||
19 | #include "zorro.h" | 21 | #include "zorro.h" |
20 | 22 | ||
21 | 23 | ||
@@ -33,10 +35,20 @@ static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); | |||
33 | 35 | ||
34 | zorro_config_attr(id, id, "0x%08x\n"); | 36 | zorro_config_attr(id, id, "0x%08x\n"); |
35 | zorro_config_attr(type, rom.er_Type, "0x%02x\n"); | 37 | zorro_config_attr(type, rom.er_Type, "0x%02x\n"); |
36 | zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n"); | ||
37 | zorro_config_attr(slotaddr, slotaddr, "0x%04x\n"); | 38 | zorro_config_attr(slotaddr, slotaddr, "0x%04x\n"); |
38 | zorro_config_attr(slotsize, slotsize, "0x%04x\n"); | 39 | zorro_config_attr(slotsize, slotsize, "0x%04x\n"); |
39 | 40 | ||
41 | static ssize_t | ||
42 | show_serial(struct device *dev, struct device_attribute *attr, char *buf) | ||
43 | { | ||
44 | struct zorro_dev *z; | ||
45 | |||
46 | z = to_zorro_dev(dev); | ||
47 | return sprintf(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber)); | ||
48 | } | ||
49 | |||
50 | static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL); | ||
51 | |||
40 | static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *attr, char *buf) | 52 | static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *attr, char *buf) |
41 | { | 53 | { |
42 | struct zorro_dev *z = to_zorro_dev(dev); | 54 | struct zorro_dev *z = to_zorro_dev(dev); |
@@ -60,10 +72,10 @@ static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj, | |||
60 | /* Construct a ConfigDev */ | 72 | /* Construct a ConfigDev */ |
61 | memset(&cd, 0, sizeof(cd)); | 73 | memset(&cd, 0, sizeof(cd)); |
62 | cd.cd_Rom = z->rom; | 74 | cd.cd_Rom = z->rom; |
63 | cd.cd_SlotAddr = z->slotaddr; | 75 | cd.cd_SlotAddr = cpu_to_be16(z->slotaddr); |
64 | cd.cd_SlotSize = z->slotsize; | 76 | cd.cd_SlotSize = cpu_to_be16(z->slotsize); |
65 | cd.cd_BoardAddr = (void *)zorro_resource_start(z); | 77 | cd.cd_BoardAddr = cpu_to_be32(zorro_resource_start(z)); |
66 | cd.cd_BoardSize = zorro_resource_len(z); | 78 | cd.cd_BoardSize = cpu_to_be32(zorro_resource_len(z)); |
67 | 79 | ||
68 | return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd)); | 80 | return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd)); |
69 | } | 81 | } |
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c index 450abf100f06..707c1a5a0317 100644 --- a/drivers/zorro/zorro.c +++ b/drivers/zorro/zorro.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | 20 | ||
21 | #include <asm/byteorder.h> | ||
21 | #include <asm/setup.h> | 22 | #include <asm/setup.h> |
22 | #include <asm/amigahw.h> | 23 | #include <asm/amigahw.h> |
23 | 24 | ||
@@ -161,7 +162,8 @@ static int __init amiga_zorro_probe(struct platform_device *pdev) | |||
161 | z = &zorro_autocon[i]; | 162 | z = &zorro_autocon[i]; |
162 | 163 | ||
163 | z->rom = zi->rom; | 164 | z->rom = zi->rom; |
164 | z->id = (z->rom.er_Manufacturer<<16) | (z->rom.er_Product<<8); | 165 | z->id = (be16_to_cpu(z->rom.er_Manufacturer) << 16) | |
166 | (z->rom.er_Product << 8); | ||
165 | if (z->id == ZORRO_PROD_GVP_EPC_BASE) { | 167 | if (z->id == ZORRO_PROD_GVP_EPC_BASE) { |
166 | /* GVP quirk */ | 168 | /* GVP quirk */ |
167 | unsigned long magic = zi->boardaddr + 0x8000; | 169 | unsigned long magic = zi->boardaddr + 0x8000; |
diff --git a/include/uapi/linux/zorro.h b/include/uapi/linux/zorro.h index 36a033e23d31..59d021b242ed 100644 --- a/include/uapi/linux/zorro.h +++ b/include/uapi/linux/zorro.h | |||
@@ -63,26 +63,26 @@ enum GVP_flags { | |||
63 | 63 | ||
64 | 64 | ||
65 | struct Node { | 65 | struct Node { |
66 | struct Node *ln_Succ; /* Pointer to next (successor) */ | 66 | __be32 ln_Succ; /* Pointer to next (successor) */ |
67 | struct Node *ln_Pred; /* Pointer to previous (predecessor) */ | 67 | __be32 ln_Pred; /* Pointer to previous (predecessor) */ |
68 | __u8 ln_Type; | 68 | __u8 ln_Type; |
69 | __s8 ln_Pri; /* Priority, for sorting */ | 69 | __s8 ln_Pri; /* Priority, for sorting */ |
70 | __s8 *ln_Name; /* ID string, null terminated */ | 70 | __be32 ln_Name; /* ID string, null terminated */ |
71 | } __packed; | 71 | } __packed; |
72 | 72 | ||
73 | struct ExpansionRom { | 73 | struct ExpansionRom { |
74 | /* -First 16 bytes of the expansion ROM */ | 74 | /* -First 16 bytes of the expansion ROM */ |
75 | __u8 er_Type; /* Board type, size and flags */ | 75 | __u8 er_Type; /* Board type, size and flags */ |
76 | __u8 er_Product; /* Product number, assigned by manufacturer */ | 76 | __u8 er_Product; /* Product number, assigned by manufacturer */ |
77 | __u8 er_Flags; /* Flags */ | 77 | __u8 er_Flags; /* Flags */ |
78 | __u8 er_Reserved03; /* Must be zero ($ff inverted) */ | 78 | __u8 er_Reserved03; /* Must be zero ($ff inverted) */ |
79 | __u16 er_Manufacturer; /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */ | 79 | __be16 er_Manufacturer; /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */ |
80 | __u32 er_SerialNumber; /* Available for use by manufacturer */ | 80 | __be32 er_SerialNumber; /* Available for use by manufacturer */ |
81 | __u16 er_InitDiagVec; /* Offset to optional "DiagArea" structure */ | 81 | __be16 er_InitDiagVec; /* Offset to optional "DiagArea" structure */ |
82 | __u8 er_Reserved0c; | 82 | __u8 er_Reserved0c; |
83 | __u8 er_Reserved0d; | 83 | __u8 er_Reserved0d; |
84 | __u8 er_Reserved0e; | 84 | __u8 er_Reserved0e; |
85 | __u8 er_Reserved0f; | 85 | __u8 er_Reserved0f; |
86 | } __packed; | 86 | } __packed; |
87 | 87 | ||
88 | /* er_Type board type bits */ | 88 | /* er_Type board type bits */ |
@@ -99,13 +99,13 @@ struct ConfigDev { | |||
99 | __u8 cd_Flags; /* (read/write) */ | 99 | __u8 cd_Flags; /* (read/write) */ |
100 | __u8 cd_Pad; /* reserved */ | 100 | __u8 cd_Pad; /* reserved */ |
101 | struct ExpansionRom cd_Rom; /* copy of board's expansion ROM */ | 101 | struct ExpansionRom cd_Rom; /* copy of board's expansion ROM */ |
102 | void *cd_BoardAddr; /* where in memory the board was placed */ | 102 | __be32 cd_BoardAddr; /* where in memory the board was placed */ |
103 | __u32 cd_BoardSize; /* size of board in bytes */ | 103 | __be32 cd_BoardSize; /* size of board in bytes */ |
104 | __u16 cd_SlotAddr; /* which slot number (PRIVATE) */ | 104 | __be16 cd_SlotAddr; /* which slot number (PRIVATE) */ |
105 | __u16 cd_SlotSize; /* number of slots (PRIVATE) */ | 105 | __be16 cd_SlotSize; /* number of slots (PRIVATE) */ |
106 | void *cd_Driver; /* pointer to node of driver */ | 106 | __be32 cd_Driver; /* pointer to node of driver */ |
107 | struct ConfigDev *cd_NextCD; /* linked list of drivers to config */ | 107 | __be32 cd_NextCD; /* linked list of drivers to config */ |
108 | __u32 cd_Unused[4]; /* for whatever the driver wants */ | 108 | __be32 cd_Unused[4]; /* for whatever the driver wants */ |
109 | } __packed; | 109 | } __packed; |
110 | 110 | ||
111 | #define ZORRO_NUM_AUTO 16 | 111 | #define ZORRO_NUM_AUTO 16 |