diff options
227 files changed, 9377 insertions, 7842 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index afeaf6218ea2..c7a4d0faab22 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -158,13 +158,6 @@ Who: Adrian Bunk <bunk@stusta.de> | |||
158 | 158 | ||
159 | --------------------------- | 159 | --------------------------- |
160 | 160 | ||
161 | What: Legacy /proc/pci interface (PCI_LEGACY_PROC) | ||
162 | When: March 2006 | ||
163 | Why: deprecated since 2.5.53 in favor of lspci(8) | ||
164 | Who: Adrian Bunk <bunk@stusta.de> | ||
165 | |||
166 | --------------------------- | ||
167 | |||
168 | What: pci_module_init(driver) | 161 | What: pci_module_init(driver) |
169 | When: January 2007 | 162 | When: January 2007 |
170 | Why: Is replaced by pci_register_driver(pci_driver). | 163 | Why: Is replaced by pci_register_driver(pci_driver). |
diff --git a/Documentation/hwmon/w83627hf b/Documentation/hwmon/w83627hf index bbeaba680443..792231921241 100644 --- a/Documentation/hwmon/w83627hf +++ b/Documentation/hwmon/w83627hf | |||
@@ -18,6 +18,10 @@ Supported chips: | |||
18 | Prefix: 'w83637hf' | 18 | Prefix: 'w83637hf' |
19 | Addresses scanned: ISA address retrieved from Super I/O registers | 19 | Addresses scanned: ISA address retrieved from Super I/O registers |
20 | Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf | 20 | Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf |
21 | * Winbond W83687THF | ||
22 | Prefix: 'w83687thf' | ||
23 | Addresses scanned: ISA address retrieved from Super I/O registers | ||
24 | Datasheet: Provided by Winbond on request | ||
21 | 25 | ||
22 | Authors: | 26 | Authors: |
23 | Frodo Looijaard <frodol@dds.nl>, | 27 | Frodo Looijaard <frodol@dds.nl>, |
diff --git a/Documentation/hwmon/w83781d b/Documentation/hwmon/w83781d index e5459333ba68..b1e9f80098ee 100644 --- a/Documentation/hwmon/w83781d +++ b/Documentation/hwmon/w83781d | |||
@@ -36,6 +36,11 @@ Module parameters | |||
36 | Use 'init=0' to bypass initializing the chip. | 36 | Use 'init=0' to bypass initializing the chip. |
37 | Try this if your computer crashes when you load the module. | 37 | Try this if your computer crashes when you load the module. |
38 | 38 | ||
39 | * reset int | ||
40 | (default 0) | ||
41 | The driver used to reset the chip on load, but does no more. Use | ||
42 | 'reset=1' to restore the old behavior. Report if you need to do this. | ||
43 | |||
39 | force_subclients=bus,caddr,saddr,saddr | 44 | force_subclients=bus,caddr,saddr,saddr |
40 | This is used to force the i2c addresses for subclients of | 45 | This is used to force the i2c addresses for subclients of |
41 | a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' | 46 | a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' |
@@ -123,6 +128,25 @@ When an alarm goes off, you can be warned by a beeping signal through | |||
123 | your computer speaker. It is possible to enable all beeping globally, | 128 | your computer speaker. It is possible to enable all beeping globally, |
124 | or only the beeping for some alarms. | 129 | or only the beeping for some alarms. |
125 | 130 | ||
131 | Individual alarm and beep bits: | ||
132 | |||
133 | 0x000001: in0 | ||
134 | 0x000002: in1 | ||
135 | 0x000004: in2 | ||
136 | 0x000008: in3 | ||
137 | 0x000010: temp1 | ||
138 | 0x000020: temp2 (+temp3 on W83781D) | ||
139 | 0x000040: fan1 | ||
140 | 0x000080: fan2 | ||
141 | 0x000100: in4 | ||
142 | 0x000200: in5 | ||
143 | 0x000400: in6 | ||
144 | 0x000800: fan3 | ||
145 | 0x001000: chassis | ||
146 | 0x002000: temp3 (W83782D and W83627HF only) | ||
147 | 0x010000: in7 (W83782D and W83627HF only) | ||
148 | 0x020000: in8 (W83782D and W83627HF only) | ||
149 | |||
126 | If an alarm triggers, it will remain triggered until the hardware register | 150 | If an alarm triggers, it will remain triggered until the hardware register |
127 | is read at least once. This means that the cause for the alarm may | 151 | is read at least once. This means that the cause for the alarm may |
128 | already have disappeared! Note that in the current implementation, all | 152 | already have disappeared! Note that in the current implementation, all |
diff --git a/Documentation/i2c/busses/i2c-piix4 b/Documentation/i2c/busses/i2c-piix4 index 856b4b8b962c..a1c8f581afed 100644 --- a/Documentation/i2c/busses/i2c-piix4 +++ b/Documentation/i2c/busses/i2c-piix4 | |||
@@ -4,7 +4,7 @@ Supported adapters: | |||
4 | * Intel 82371AB PIIX4 and PIIX4E | 4 | * Intel 82371AB PIIX4 and PIIX4E |
5 | * Intel 82443MX (440MX) | 5 | * Intel 82443MX (440MX) |
6 | Datasheet: Publicly available at the Intel website | 6 | Datasheet: Publicly available at the Intel website |
7 | * ServerWorks OSB4, CSB5 and CSB6 southbridges | 7 | * ServerWorks OSB4, CSB5, CSB6 and HT-1000 southbridges |
8 | Datasheet: Only available via NDA from ServerWorks | 8 | Datasheet: Only available via NDA from ServerWorks |
9 | * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge | 9 | * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge |
10 | Datasheet: Publicly available at the SMSC website http://www.smsc.com | 10 | Datasheet: Publicly available at the SMSC website http://www.smsc.com |
diff --git a/Documentation/i2c/busses/scx200_acb b/Documentation/i2c/busses/scx200_acb index 08c8cd1df60c..f50e69981ec6 100644 --- a/Documentation/i2c/busses/scx200_acb +++ b/Documentation/i2c/busses/scx200_acb | |||
@@ -6,9 +6,10 @@ Module Parameters | |||
6 | ----------------- | 6 | ----------------- |
7 | 7 | ||
8 | * base: int | 8 | * base: int |
9 | Base addresses for the ACCESS.bus controllers | 9 | Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices |
10 | 10 | ||
11 | Description | 11 | Description |
12 | ----------- | 12 | ----------- |
13 | 13 | ||
14 | Enable the use of the ACCESS.bus controllers of a SCx200 processor. | 14 | Enable the use of the ACCESS.bus controller on the Geode SCx200 and |
15 | SC1100 processors and the CS5535 and CS5536 Geode companion devices. | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 7b7382d0f758..44a25f3f51d1 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -49,6 +49,7 @@ restrictions referred to are that the relevant option is valid if: | |||
49 | MCA MCA bus support is enabled. | 49 | MCA MCA bus support is enabled. |
50 | MDA MDA console support is enabled. | 50 | MDA MDA console support is enabled. |
51 | MOUSE Appropriate mouse support is enabled. | 51 | MOUSE Appropriate mouse support is enabled. |
52 | MSI Message Signaled Interrupts (PCI). | ||
52 | MTD MTD support is enabled. | 53 | MTD MTD support is enabled. |
53 | NET Appropriate network support is enabled. | 54 | NET Appropriate network support is enabled. |
54 | NUMA NUMA support is enabled. | 55 | NUMA NUMA support is enabled. |
@@ -1152,6 +1153,9 @@ running once the system is up. | |||
1152 | Mechanism 2. | 1153 | Mechanism 2. |
1153 | nommconf [IA-32,X86_64] Disable use of MMCONFIG for PCI | 1154 | nommconf [IA-32,X86_64] Disable use of MMCONFIG for PCI |
1154 | Configuration | 1155 | Configuration |
1156 | nomsi [MSI] If the PCI_MSI kernel config parameter is | ||
1157 | enabled, this kernel boot option can be used to | ||
1158 | disable the use of MSI interrupts system-wide. | ||
1155 | nosort [IA-32] Don't sort PCI devices according to | 1159 | nosort [IA-32] Don't sort PCI devices according to |
1156 | order given by the PCI BIOS. This sorting is | 1160 | order given by the PCI BIOS. This sorting is |
1157 | done to get a device order compatible with | 1161 | done to get a device order compatible with |
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt index cc4b4d04129c..278771c9ad99 100644 --- a/Documentation/networking/pktgen.txt +++ b/Documentation/networking/pktgen.txt | |||
@@ -109,6 +109,22 @@ Examples: | |||
109 | cycle through the port range. | 109 | cycle through the port range. |
110 | pgset "udp_dst_max 9" set UDP destination port max. | 110 | pgset "udp_dst_max 9" set UDP destination port max. |
111 | 111 | ||
112 | pgset "mpls 0001000a,0002000a,0000000a" set MPLS labels (in this example | ||
113 | outer label=16,middle label=32, | ||
114 | inner label=0 (IPv4 NULL)) Note that | ||
115 | there must be no spaces between the | ||
116 | arguments. Leading zeros are required. | ||
117 | Do not set the bottom of stack bit, | ||
118 | thats done automatically. If you do | ||
119 | set the bottom of stack bit, that | ||
120 | indicates that you want to randomly | ||
121 | generate that address and the flag | ||
122 | MPLS_RND will be turned on. You | ||
123 | can have any mix of random and fixed | ||
124 | labels in the label stack. | ||
125 | |||
126 | pgset "mpls 0" turn off mpls (or any invalid argument works too!) | ||
127 | |||
112 | pgset stop aborts injection. Also, ^C aborts generator. | 128 | pgset stop aborts injection. Also, ^C aborts generator. |
113 | 129 | ||
114 | 130 | ||
@@ -167,6 +183,8 @@ pkt_size | |||
167 | min_pkt_size | 183 | min_pkt_size |
168 | max_pkt_size | 184 | max_pkt_size |
169 | 185 | ||
186 | mpls | ||
187 | |||
170 | udp_src_min | 188 | udp_src_min |
171 | udp_src_max | 189 | udp_src_max |
172 | 190 | ||
@@ -211,4 +229,4 @@ Grant Grundler for testing on IA-64 and parisc, Harald Welte, Lennert Buytenhek | |||
211 | Stephen Hemminger, Andi Kleen, Dave Miller and many others. | 229 | Stephen Hemminger, Andi Kleen, Dave Miller and many others. |
212 | 230 | ||
213 | 231 | ||
214 | Good luck with the linux net-development. \ No newline at end of file | 232 | Good luck with the linux net-development. |
diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c index aeabb4196861..7ec6cfa01fb3 100644 --- a/arch/i386/kernel/efi.c +++ b/arch/i386/kernel/efi.c | |||
@@ -543,7 +543,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, | |||
543 | if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) > | 543 | if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) > |
544 | 0x100000000ULL) | 544 | 0x100000000ULL) |
545 | continue; | 545 | continue; |
546 | res = alloc_bootmem_low(sizeof(struct resource)); | 546 | res = kzalloc(sizeof(struct resource), GFP_ATOMIC); |
547 | switch (md->type) { | 547 | switch (md->type) { |
548 | case EFI_RESERVED_TYPE: | 548 | case EFI_RESERVED_TYPE: |
549 | res->name = "Reserved Memory"; | 549 | res->name = "Reserved Memory"; |
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index 2d8782960f41..d313a11acafa 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c | |||
@@ -1288,7 +1288,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat | |||
1288 | struct resource *res; | 1288 | struct resource *res; |
1289 | if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL) | 1289 | if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL) |
1290 | continue; | 1290 | continue; |
1291 | res = alloc_bootmem_low(sizeof(struct resource)); | 1291 | res = kzalloc(sizeof(struct resource), GFP_ATOMIC); |
1292 | switch (e820.map[i].type) { | 1292 | switch (e820.map[i].type) { |
1293 | case E820_RAM: res->name = "System RAM"; break; | 1293 | case E820_RAM: res->name = "System RAM"; break; |
1294 | case E820_ACPI: res->name = "ACPI Tables"; break; | 1294 | case E820_ACPI: res->name = "ACPI Tables"; break; |
@@ -1316,13 +1316,15 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat | |||
1316 | 1316 | ||
1317 | /* | 1317 | /* |
1318 | * Request address space for all standard resources | 1318 | * Request address space for all standard resources |
1319 | * | ||
1320 | * This is called just before pcibios_assign_resources(), which is also | ||
1321 | * an fs_initcall, but is linked in later (in arch/i386/pci/i386.c). | ||
1319 | */ | 1322 | */ |
1320 | static void __init register_memory(void) | 1323 | static int __init request_standard_resources(void) |
1321 | { | 1324 | { |
1322 | unsigned long gapstart, gapsize, round; | 1325 | int i; |
1323 | unsigned long long last; | ||
1324 | int i; | ||
1325 | 1326 | ||
1327 | printk("Setting up standard PCI resources\n"); | ||
1326 | if (efi_enabled) | 1328 | if (efi_enabled) |
1327 | efi_initialize_iomem_resources(&code_resource, &data_resource); | 1329 | efi_initialize_iomem_resources(&code_resource, &data_resource); |
1328 | else | 1330 | else |
@@ -1334,6 +1336,16 @@ static void __init register_memory(void) | |||
1334 | /* request I/O space for devices used on all i[345]86 PCs */ | 1336 | /* request I/O space for devices used on all i[345]86 PCs */ |
1335 | for (i = 0; i < STANDARD_IO_RESOURCES; i++) | 1337 | for (i = 0; i < STANDARD_IO_RESOURCES; i++) |
1336 | request_resource(&ioport_resource, &standard_io_resources[i]); | 1338 | request_resource(&ioport_resource, &standard_io_resources[i]); |
1339 | return 0; | ||
1340 | } | ||
1341 | |||
1342 | fs_initcall(request_standard_resources); | ||
1343 | |||
1344 | static void __init register_memory(void) | ||
1345 | { | ||
1346 | unsigned long gapstart, gapsize, round; | ||
1347 | unsigned long long last; | ||
1348 | int i; | ||
1337 | 1349 | ||
1338 | /* | 1350 | /* |
1339 | * Search for the bigest gap in the low 32 bits of the e820 | 1351 | * Search for the bigest gap in the low 32 bits of the e820 |
diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile index 5461d4d5ea1e..62ad75c57e6a 100644 --- a/arch/i386/pci/Makefile +++ b/arch/i386/pci/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | obj-y := i386.o | 1 | obj-y := i386.o init.o |
2 | 2 | ||
3 | obj-$(CONFIG_PCI_BIOS) += pcbios.o | 3 | obj-$(CONFIG_PCI_BIOS) += pcbios.o |
4 | obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o | 4 | obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o |
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c index f6bc48da4d2a..dbece776c5b2 100644 --- a/arch/i386/pci/common.c +++ b/arch/i386/pci/common.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
9 | #include <linux/ioport.h> | 9 | #include <linux/ioport.h> |
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/dmi.h> | ||
11 | 12 | ||
12 | #include <asm/acpi.h> | 13 | #include <asm/acpi.h> |
13 | #include <asm/segment.h> | 14 | #include <asm/segment.h> |
@@ -120,11 +121,42 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b) | |||
120 | pci_read_bridge_bases(b); | 121 | pci_read_bridge_bases(b); |
121 | } | 122 | } |
122 | 123 | ||
124 | /* | ||
125 | * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus) | ||
126 | */ | ||
127 | #ifdef __i386__ | ||
128 | static int __devinit assign_all_busses(struct dmi_system_id *d) | ||
129 | { | ||
130 | pci_probe |= PCI_ASSIGN_ALL_BUSSES; | ||
131 | printk(KERN_INFO "%s detected: enabling PCI bus# renumbering" | ||
132 | " (pci=assign-busses)\n", d->ident); | ||
133 | return 0; | ||
134 | } | ||
135 | #endif | ||
136 | |||
137 | /* | ||
138 | * Laptops which need pci=assign-busses to see Cardbus cards | ||
139 | */ | ||
140 | static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = { | ||
141 | #ifdef __i386__ | ||
142 | { | ||
143 | .callback = assign_all_busses, | ||
144 | .ident = "Samsung X20 Laptop", | ||
145 | .matches = { | ||
146 | DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"), | ||
147 | DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"), | ||
148 | }, | ||
149 | }, | ||
150 | #endif /* __i386__ */ | ||
151 | {} | ||
152 | }; | ||
123 | 153 | ||
124 | struct pci_bus * __devinit pcibios_scan_root(int busnum) | 154 | struct pci_bus * __devinit pcibios_scan_root(int busnum) |
125 | { | 155 | { |
126 | struct pci_bus *bus = NULL; | 156 | struct pci_bus *bus = NULL; |
127 | 157 | ||
158 | dmi_check_system(pciprobe_dmi_table); | ||
159 | |||
128 | while ((bus = pci_find_next_bus(bus)) != NULL) { | 160 | while ((bus = pci_find_next_bus(bus)) != NULL) { |
129 | if (bus->number == busnum) { | 161 | if (bus->number == busnum) { |
130 | /* Already scanned */ | 162 | /* Already scanned */ |
diff --git a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c index e3ac502bf2fb..99012b93bd12 100644 --- a/arch/i386/pci/direct.c +++ b/arch/i386/pci/direct.c | |||
@@ -245,7 +245,7 @@ static int __init pci_check_type2(void) | |||
245 | return works; | 245 | return works; |
246 | } | 246 | } |
247 | 247 | ||
248 | static int __init pci_direct_init(void) | 248 | void __init pci_direct_init(void) |
249 | { | 249 | { |
250 | struct resource *region, *region2; | 250 | struct resource *region, *region2; |
251 | 251 | ||
@@ -258,16 +258,16 @@ static int __init pci_direct_init(void) | |||
258 | if (pci_check_type1()) { | 258 | if (pci_check_type1()) { |
259 | printk(KERN_INFO "PCI: Using configuration type 1\n"); | 259 | printk(KERN_INFO "PCI: Using configuration type 1\n"); |
260 | raw_pci_ops = &pci_direct_conf1; | 260 | raw_pci_ops = &pci_direct_conf1; |
261 | return 0; | 261 | return; |
262 | } | 262 | } |
263 | release_resource(region); | 263 | release_resource(region); |
264 | 264 | ||
265 | type2: | 265 | type2: |
266 | if ((pci_probe & PCI_PROBE_CONF2) == 0) | 266 | if ((pci_probe & PCI_PROBE_CONF2) == 0) |
267 | goto out; | 267 | return; |
268 | region = request_region(0xCF8, 4, "PCI conf2"); | 268 | region = request_region(0xCF8, 4, "PCI conf2"); |
269 | if (!region) | 269 | if (!region) |
270 | goto out; | 270 | return; |
271 | region2 = request_region(0xC000, 0x1000, "PCI conf2"); | 271 | region2 = request_region(0xC000, 0x1000, "PCI conf2"); |
272 | if (!region2) | 272 | if (!region2) |
273 | goto fail2; | 273 | goto fail2; |
@@ -275,15 +275,10 @@ static int __init pci_direct_init(void) | |||
275 | if (pci_check_type2()) { | 275 | if (pci_check_type2()) { |
276 | printk(KERN_INFO "PCI: Using configuration type 2\n"); | 276 | printk(KERN_INFO "PCI: Using configuration type 2\n"); |
277 | raw_pci_ops = &pci_direct_conf2; | 277 | raw_pci_ops = &pci_direct_conf2; |
278 | return 0; | 278 | return; |
279 | } | 279 | } |
280 | 280 | ||
281 | release_resource(region2); | 281 | release_resource(region2); |
282 | fail2: | 282 | fail2: |
283 | release_resource(region); | 283 | release_resource(region); |
284 | |||
285 | out: | ||
286 | return 0; | ||
287 | } | 284 | } |
288 | |||
289 | arch_initcall(pci_direct_init); | ||
diff --git a/arch/i386/pci/init.c b/arch/i386/pci/init.c new file mode 100644 index 000000000000..f9156d3ac723 --- /dev/null +++ b/arch/i386/pci/init.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #include <linux/config.h> | ||
2 | #include <linux/pci.h> | ||
3 | #include <linux/init.h> | ||
4 | #include "pci.h" | ||
5 | |||
6 | /* arch_initcall has too random ordering, so call the initializers | ||
7 | in the right sequence from here. */ | ||
8 | static __init int pci_access_init(void) | ||
9 | { | ||
10 | #ifdef CONFIG_PCI_MMCONFIG | ||
11 | pci_mmcfg_init(); | ||
12 | #endif | ||
13 | if (raw_pci_ops) | ||
14 | return 0; | ||
15 | #ifdef CONFIG_PCI_BIOS | ||
16 | pci_pcbios_init(); | ||
17 | #endif | ||
18 | if (raw_pci_ops) | ||
19 | return 0; | ||
20 | #ifdef CONFIG_PCI_DIRECT | ||
21 | pci_direct_init(); | ||
22 | #endif | ||
23 | return 0; | ||
24 | } | ||
25 | arch_initcall(pci_access_init); | ||
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c index 0ee8a983708c..613789071f30 100644 --- a/arch/i386/pci/mmconfig.c +++ b/arch/i386/pci/mmconfig.c | |||
@@ -172,25 +172,20 @@ static __init void unreachable_devices(void) | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | static int __init pci_mmcfg_init(void) | 175 | void __init pci_mmcfg_init(void) |
176 | { | 176 | { |
177 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) | 177 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) |
178 | goto out; | 178 | return; |
179 | 179 | ||
180 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); | 180 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); |
181 | if ((pci_mmcfg_config_num == 0) || | 181 | if ((pci_mmcfg_config_num == 0) || |
182 | (pci_mmcfg_config == NULL) || | 182 | (pci_mmcfg_config == NULL) || |
183 | (pci_mmcfg_config[0].base_address == 0)) | 183 | (pci_mmcfg_config[0].base_address == 0)) |
184 | goto out; | 184 | return; |
185 | 185 | ||
186 | printk(KERN_INFO "PCI: Using MMCONFIG\n"); | 186 | printk(KERN_INFO "PCI: Using MMCONFIG\n"); |
187 | raw_pci_ops = &pci_mmcfg; | 187 | raw_pci_ops = &pci_mmcfg; |
188 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; | 188 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; |
189 | 189 | ||
190 | unreachable_devices(); | 190 | unreachable_devices(); |
191 | |||
192 | out: | ||
193 | return 0; | ||
194 | } | 191 | } |
195 | |||
196 | arch_initcall(pci_mmcfg_init); | ||
diff --git a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c index b9d65f0bc2d1..1eec0868f4b3 100644 --- a/arch/i386/pci/pcbios.c +++ b/arch/i386/pci/pcbios.c | |||
@@ -476,14 +476,12 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq) | |||
476 | } | 476 | } |
477 | EXPORT_SYMBOL(pcibios_set_irq_routing); | 477 | EXPORT_SYMBOL(pcibios_set_irq_routing); |
478 | 478 | ||
479 | static int __init pci_pcbios_init(void) | 479 | void __init pci_pcbios_init(void) |
480 | { | 480 | { |
481 | if ((pci_probe & PCI_PROBE_BIOS) | 481 | if ((pci_probe & PCI_PROBE_BIOS) |
482 | && ((raw_pci_ops = pci_find_bios()))) { | 482 | && ((raw_pci_ops = pci_find_bios()))) { |
483 | pci_probe |= PCI_BIOS_SORT; | 483 | pci_probe |= PCI_BIOS_SORT; |
484 | pci_bios_present = 1; | 484 | pci_bios_present = 1; |
485 | } | 485 | } |
486 | return 0; | ||
487 | } | 486 | } |
488 | 487 | ||
489 | arch_initcall(pci_pcbios_init); | ||
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h index f550781ec310..12035e29108b 100644 --- a/arch/i386/pci/pci.h +++ b/arch/i386/pci/pci.h | |||
@@ -80,4 +80,7 @@ extern int pci_conf1_write(unsigned int seg, unsigned int bus, | |||
80 | extern int pci_conf1_read(unsigned int seg, unsigned int bus, | 80 | extern int pci_conf1_read(unsigned int seg, unsigned int bus, |
81 | unsigned int devfn, int reg, int len, u32 *value); | 81 | unsigned int devfn, int reg, int len, u32 *value); |
82 | 82 | ||
83 | extern void pci_direct_init(void); | ||
84 | extern void pci_pcbios_init(void); | ||
85 | extern void pci_mmcfg_init(void); | ||
83 | 86 | ||
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile index a8f75a2a0f6f..a3f6ad570179 100644 --- a/arch/x86_64/pci/Makefile +++ b/arch/x86_64/pci/Makefile | |||
@@ -7,7 +7,7 @@ CFLAGS += -Iarch/i386/pci | |||
7 | 7 | ||
8 | obj-y := i386.o | 8 | obj-y := i386.o |
9 | obj-$(CONFIG_PCI_DIRECT)+= direct.o | 9 | obj-$(CONFIG_PCI_DIRECT)+= direct.o |
10 | obj-y += fixup.o | 10 | obj-y += fixup.o init.o |
11 | obj-$(CONFIG_ACPI) += acpi.o | 11 | obj-$(CONFIG_ACPI) += acpi.o |
12 | obj-y += legacy.o irq.o common.o | 12 | obj-y += legacy.o irq.o common.o |
13 | # mmconfig has a 64bit special | 13 | # mmconfig has a 64bit special |
@@ -22,3 +22,4 @@ irq-y += ../../i386/pci/irq.o | |||
22 | common-y += ../../i386/pci/common.o | 22 | common-y += ../../i386/pci/common.o |
23 | fixup-y += ../../i386/pci/fixup.o | 23 | fixup-y += ../../i386/pci/fixup.o |
24 | i386-y += ../../i386/pci/i386.o | 24 | i386-y += ../../i386/pci/i386.o |
25 | init-y += ../../i386/pci/init.o | ||
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 33e2ca847a26..82710ae39228 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -205,6 +205,18 @@ config ACPI_IBM | |||
205 | 205 | ||
206 | If you have an IBM ThinkPad laptop, say Y or M here. | 206 | If you have an IBM ThinkPad laptop, say Y or M here. |
207 | 207 | ||
208 | config ACPI_IBM_DOCK | ||
209 | bool "Legacy Docking Station Support" | ||
210 | depends on ACPI_IBM | ||
211 | default n | ||
212 | ---help--- | ||
213 | Allows the ibm_acpi driver to handle docking station events. | ||
214 | This support is obsoleted by CONFIG_HOTPLUG_PCI_ACPI. It will | ||
215 | allow locking and removing the laptop from the docking station, | ||
216 | but will not properly connect PCI devices. | ||
217 | |||
218 | If you are not sure, say N here. | ||
219 | |||
208 | config ACPI_TOSHIBA | 220 | config ACPI_TOSHIBA |
209 | tristate "Toshiba Laptop Extras" | 221 | tristate "Toshiba Laptop Extras" |
210 | depends on X86 | 222 | depends on X86 |
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index 5cc090326ddc..262b1f41335a 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c | |||
@@ -160,13 +160,13 @@ IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */ | |||
160 | "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */ | 160 | "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */ |
161 | "\\CMS", /* R40, R40e */ | 161 | "\\CMS", /* R40, R40e */ |
162 | ); /* all others */ | 162 | ); /* all others */ |
163 | 163 | #ifdef CONFIG_ACPI_IBM_DOCK | |
164 | IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ | 164 | IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ |
165 | "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */ | 165 | "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */ |
166 | "\\_SB.PCI0.PCI1.DOCK", /* all others */ | 166 | "\\_SB.PCI0.PCI1.DOCK", /* all others */ |
167 | "\\_SB.PCI.ISA.SLCE", /* 570 */ | 167 | "\\_SB.PCI.ISA.SLCE", /* 570 */ |
168 | ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ | 168 | ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ |
169 | 169 | #endif | |
170 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ | 170 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ |
171 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ | 171 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ |
172 | "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ | 172 | "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ |
@@ -844,7 +844,7 @@ static int _sta(acpi_handle handle) | |||
844 | 844 | ||
845 | return status; | 845 | return status; |
846 | } | 846 | } |
847 | 847 | #ifdef CONFIG_ACPI_IBM_DOCK | |
848 | #define dock_docked() (_sta(dock_handle) & 1) | 848 | #define dock_docked() (_sta(dock_handle) & 1) |
849 | 849 | ||
850 | static int dock_read(char *p) | 850 | static int dock_read(char *p) |
@@ -907,6 +907,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event) | |||
907 | acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ | 907 | acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ |
908 | } | 908 | } |
909 | } | 909 | } |
910 | #endif | ||
910 | 911 | ||
911 | static int bay_status_supported; | 912 | static int bay_status_supported; |
912 | static int bay_status2_supported; | 913 | static int bay_status2_supported; |
@@ -1574,6 +1575,7 @@ static struct ibm_struct ibms[] = { | |||
1574 | .read = light_read, | 1575 | .read = light_read, |
1575 | .write = light_write, | 1576 | .write = light_write, |
1576 | }, | 1577 | }, |
1578 | #ifdef CONFIG_ACPI_IBM_DOCK | ||
1577 | { | 1579 | { |
1578 | .name = "dock", | 1580 | .name = "dock", |
1579 | .read = dock_read, | 1581 | .read = dock_read, |
@@ -1589,6 +1591,7 @@ static struct ibm_struct ibms[] = { | |||
1589 | .handle = &pci_handle, | 1591 | .handle = &pci_handle, |
1590 | .type = ACPI_SYSTEM_NOTIFY, | 1592 | .type = ACPI_SYSTEM_NOTIFY, |
1591 | }, | 1593 | }, |
1594 | #endif | ||
1592 | { | 1595 | { |
1593 | .name = "bay", | 1596 | .name = "bay", |
1594 | .init = bay_init, | 1597 | .init = bay_init, |
@@ -1880,7 +1883,9 @@ IBM_PARAM(hotkey); | |||
1880 | IBM_PARAM(bluetooth); | 1883 | IBM_PARAM(bluetooth); |
1881 | IBM_PARAM(video); | 1884 | IBM_PARAM(video); |
1882 | IBM_PARAM(light); | 1885 | IBM_PARAM(light); |
1886 | #ifdef CONFIG_ACPI_IBM_DOCK | ||
1883 | IBM_PARAM(dock); | 1887 | IBM_PARAM(dock); |
1888 | #endif | ||
1884 | IBM_PARAM(bay); | 1889 | IBM_PARAM(bay); |
1885 | IBM_PARAM(cmos); | 1890 | IBM_PARAM(cmos); |
1886 | IBM_PARAM(led); | 1891 | IBM_PARAM(led); |
@@ -1927,7 +1932,9 @@ static int __init acpi_ibm_init(void) | |||
1927 | IBM_HANDLE_INIT(hkey); | 1932 | IBM_HANDLE_INIT(hkey); |
1928 | IBM_HANDLE_INIT(lght); | 1933 | IBM_HANDLE_INIT(lght); |
1929 | IBM_HANDLE_INIT(cmos); | 1934 | IBM_HANDLE_INIT(cmos); |
1935 | #ifdef CONFIG_ACPI_IBM_DOCK | ||
1930 | IBM_HANDLE_INIT(dock); | 1936 | IBM_HANDLE_INIT(dock); |
1937 | #endif | ||
1931 | IBM_HANDLE_INIT(pci); | 1938 | IBM_HANDLE_INIT(pci); |
1932 | IBM_HANDLE_INIT(bay); | 1939 | IBM_HANDLE_INIT(bay); |
1933 | if (bay_handle) | 1940 | if (bay_handle) |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 9271e5209ac1..a0ab828b2cc5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -23,7 +23,6 @@ static LIST_HEAD(acpi_device_list); | |||
23 | DEFINE_SPINLOCK(acpi_device_lock); | 23 | DEFINE_SPINLOCK(acpi_device_lock); |
24 | LIST_HEAD(acpi_wakeup_device_list); | 24 | LIST_HEAD(acpi_wakeup_device_list); |
25 | 25 | ||
26 | static int acpi_bus_trim(struct acpi_device *start, int rmdevice); | ||
27 | 26 | ||
28 | static void acpi_device_release(struct kobject *kobj) | 27 | static void acpi_device_release(struct kobject *kobj) |
29 | { | 28 | { |
@@ -1284,7 +1283,7 @@ int acpi_bus_start(struct acpi_device *device) | |||
1284 | 1283 | ||
1285 | EXPORT_SYMBOL(acpi_bus_start); | 1284 | EXPORT_SYMBOL(acpi_bus_start); |
1286 | 1285 | ||
1287 | static int acpi_bus_trim(struct acpi_device *start, int rmdevice) | 1286 | int acpi_bus_trim(struct acpi_device *start, int rmdevice) |
1288 | { | 1287 | { |
1289 | acpi_status status; | 1288 | acpi_status status; |
1290 | struct acpi_device *parent, *child; | 1289 | struct acpi_device *parent, *child; |
@@ -1337,6 +1336,8 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice) | |||
1337 | } | 1336 | } |
1338 | return err; | 1337 | return err; |
1339 | } | 1338 | } |
1339 | EXPORT_SYMBOL_GPL(acpi_bus_trim); | ||
1340 | |||
1340 | 1341 | ||
1341 | static int acpi_bus_scan_fixed(struct acpi_device *root) | 1342 | static int acpi_bus_scan_fixed(struct acpi_device *root) |
1342 | { | 1343 | { |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 7230d4e08196..99cdc612d2c6 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -406,13 +406,14 @@ config SENSORS_W83L785TS | |||
406 | will be called w83l785ts. | 406 | will be called w83l785ts. |
407 | 407 | ||
408 | config SENSORS_W83627HF | 408 | config SENSORS_W83627HF |
409 | tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF" | 409 | tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" |
410 | depends on HWMON && I2C && EXPERIMENTAL | 410 | depends on HWMON && I2C |
411 | select I2C_ISA | 411 | select I2C_ISA |
412 | select HWMON_VID | 412 | select HWMON_VID |
413 | help | 413 | help |
414 | If you say yes here you get support for the Winbond W836X7 series | 414 | If you say yes here you get support for the Winbond W836X7 series |
415 | of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF | 415 | of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and |
416 | W83697HF. | ||
416 | 417 | ||
417 | This driver can also be built as a module. If so, the module | 418 | This driver can also be built as a module. If so, the module |
418 | will be called w83627hf. | 419 | will be called w83627hf. |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 665612729cb9..2b6e74dd4a82 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/hwmon.h> | 27 | #include <linux/hwmon.h> |
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | 31 | ||
31 | /* Addresses to scan */ | 32 | /* Addresses to scan */ |
@@ -92,7 +93,7 @@ struct adm1021_data { | |||
92 | struct class_device *class_dev; | 93 | struct class_device *class_dev; |
93 | enum chips type; | 94 | enum chips type; |
94 | 95 | ||
95 | struct semaphore update_lock; | 96 | struct mutex update_lock; |
96 | char valid; /* !=0 if following fields are valid */ | 97 | char valid; /* !=0 if following fields are valid */ |
97 | unsigned long last_updated; /* In jiffies */ | 98 | unsigned long last_updated; /* In jiffies */ |
98 | 99 | ||
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
162 | struct adm1021_data *data = i2c_get_clientdata(client); \ | 163 | struct adm1021_data *data = i2c_get_clientdata(client); \ |
163 | int temp = simple_strtoul(buf, NULL, 10); \ | 164 | int temp = simple_strtoul(buf, NULL, 10); \ |
164 | \ | 165 | \ |
165 | down(&data->update_lock); \ | 166 | mutex_lock(&data->update_lock); \ |
166 | data->value = TEMP_TO_REG(temp); \ | 167 | data->value = TEMP_TO_REG(temp); \ |
167 | adm1021_write_value(client, reg, data->value); \ | 168 | adm1021_write_value(client, reg, data->value); \ |
168 | up(&data->update_lock); \ | 169 | mutex_unlock(&data->update_lock); \ |
169 | return count; \ | 170 | return count; \ |
170 | } | 171 | } |
171 | set(temp_max, ADM1021_REG_TOS_W); | 172 | set(temp_max, ADM1021_REG_TOS_W); |
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
275 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); | 276 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); |
276 | data->type = kind; | 277 | data->type = kind; |
277 | data->valid = 0; | 278 | data->valid = 0; |
278 | init_MUTEX(&data->update_lock); | 279 | mutex_init(&data->update_lock); |
279 | 280 | ||
280 | /* Tell the I2C layer a new client has arrived */ | 281 | /* Tell the I2C layer a new client has arrived */ |
281 | if ((err = i2c_attach_client(new_client))) | 282 | if ((err = i2c_attach_client(new_client))) |
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
351 | struct i2c_client *client = to_i2c_client(dev); | 352 | struct i2c_client *client = to_i2c_client(dev); |
352 | struct adm1021_data *data = i2c_get_clientdata(client); | 353 | struct adm1021_data *data = i2c_get_clientdata(client); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | 356 | ||
356 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 357 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
357 | || !data->valid) { | 358 | || !data->valid) { |
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
375 | data->valid = 1; | 376 | data->valid = 1; |
376 | } | 377 | } |
377 | 378 | ||
378 | up(&data->update_lock); | 379 | mutex_unlock(&data->update_lock); |
379 | 380 | ||
380 | return data; | 381 | return data; |
381 | } | 382 | } |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 9331c56d2ba6..a4c859c9fbf8 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/hwmon.h> | 53 | #include <linux/hwmon.h> |
54 | #include <linux/hwmon-vid.h> | 54 | #include <linux/hwmon-vid.h> |
55 | #include <linux/err.h> | 55 | #include <linux/err.h> |
56 | #include <linux/mutex.h> | ||
56 | 57 | ||
57 | /* | 58 | /* |
58 | * Addresses to scan | 59 | * Addresses to scan |
@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = { | |||
133 | struct adm1025_data { | 134 | struct adm1025_data { |
134 | struct i2c_client client; | 135 | struct i2c_client client; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | struct semaphore update_lock; | 137 | struct mutex update_lock; |
137 | char valid; /* zero until following fields are valid */ | 138 | char valid; /* zero until following fields are valid */ |
138 | unsigned long last_updated; /* in jiffies */ | 139 | unsigned long last_updated; /* in jiffies */ |
139 | 140 | ||
@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute | |||
207 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 208 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
208 | long val = simple_strtol(buf, NULL, 10); \ | 209 | long val = simple_strtol(buf, NULL, 10); \ |
209 | \ | 210 | \ |
210 | down(&data->update_lock); \ | 211 | mutex_lock(&data->update_lock); \ |
211 | data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ | 212 | data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ |
212 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ | 213 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ |
213 | data->in_min[offset]); \ | 214 | data->in_min[offset]); \ |
214 | up(&data->update_lock); \ | 215 | mutex_unlock(&data->update_lock); \ |
215 | return count; \ | 216 | return count; \ |
216 | } \ | 217 | } \ |
217 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ | 218 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute | |||
221 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 222 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
222 | long val = simple_strtol(buf, NULL, 10); \ | 223 | long val = simple_strtol(buf, NULL, 10); \ |
223 | \ | 224 | \ |
224 | down(&data->update_lock); \ | 225 | mutex_lock(&data->update_lock); \ |
225 | data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ | 226 | data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ |
226 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ | 227 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ |
227 | data->in_max[offset]); \ | 228 | data->in_max[offset]); \ |
228 | up(&data->update_lock); \ | 229 | mutex_unlock(&data->update_lock); \ |
229 | return count; \ | 230 | return count; \ |
230 | } \ | 231 | } \ |
231 | static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ | 232 | static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ |
@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut | |||
247 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 248 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
248 | long val = simple_strtol(buf, NULL, 10); \ | 249 | long val = simple_strtol(buf, NULL, 10); \ |
249 | \ | 250 | \ |
250 | down(&data->update_lock); \ | 251 | mutex_lock(&data->update_lock); \ |
251 | data->temp_min[offset-1] = TEMP_TO_REG(val); \ | 252 | data->temp_min[offset-1] = TEMP_TO_REG(val); \ |
252 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ | 253 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ |
253 | data->temp_min[offset-1]); \ | 254 | data->temp_min[offset-1]); \ |
254 | up(&data->update_lock); \ | 255 | mutex_unlock(&data->update_lock); \ |
255 | return count; \ | 256 | return count; \ |
256 | } \ | 257 | } \ |
257 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ | 258 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut | |||
261 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 262 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
262 | long val = simple_strtol(buf, NULL, 10); \ | 263 | long val = simple_strtol(buf, NULL, 10); \ |
263 | \ | 264 | \ |
264 | down(&data->update_lock); \ | 265 | mutex_lock(&data->update_lock); \ |
265 | data->temp_max[offset-1] = TEMP_TO_REG(val); \ | 266 | data->temp_max[offset-1] = TEMP_TO_REG(val); \ |
266 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ | 267 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ |
267 | data->temp_max[offset-1]); \ | 268 | data->temp_max[offset-1]); \ |
268 | up(&data->update_lock); \ | 269 | mutex_unlock(&data->update_lock); \ |
269 | return count; \ | 270 | return count; \ |
270 | } \ | 271 | } \ |
271 | static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 272 | static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ |
@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
404 | /* We can fill in the remaining client fields */ | 405 | /* We can fill in the remaining client fields */ |
405 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 406 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
406 | data->valid = 0; | 407 | data->valid = 0; |
407 | init_MUTEX(&data->update_lock); | 408 | mutex_init(&data->update_lock); |
408 | 409 | ||
409 | /* Tell the I2C layer a new client has arrived */ | 410 | /* Tell the I2C layer a new client has arrived */ |
410 | if ((err = i2c_attach_client(new_client))) | 411 | if ((err = i2c_attach_client(new_client))) |
@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) | |||
523 | struct i2c_client *client = to_i2c_client(dev); | 524 | struct i2c_client *client = to_i2c_client(dev); |
524 | struct adm1025_data *data = i2c_get_clientdata(client); | 525 | struct adm1025_data *data = i2c_get_clientdata(client); |
525 | 526 | ||
526 | down(&data->update_lock); | 527 | mutex_lock(&data->update_lock); |
527 | 528 | ||
528 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 529 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
529 | int i; | 530 | int i; |
@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) | |||
558 | data->valid = 1; | 559 | data->valid = 1; |
559 | } | 560 | } |
560 | 561 | ||
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | 563 | ||
563 | return data; | 564 | return data; |
564 | } | 565 | } |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index fefe6e74fd02..6d4f8b8d358e 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/hwmon-sysfs.h> | 32 | #include <linux/hwmon-sysfs.h> |
33 | #include <linux/hwmon-vid.h> | 33 | #include <linux/hwmon-vid.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -260,10 +261,10 @@ struct pwm_data { | |||
260 | struct adm1026_data { | 261 | struct adm1026_data { |
261 | struct i2c_client client; | 262 | struct i2c_client client; |
262 | struct class_device *class_dev; | 263 | struct class_device *class_dev; |
263 | struct semaphore lock; | 264 | struct mutex lock; |
264 | enum chips type; | 265 | enum chips type; |
265 | 266 | ||
266 | struct semaphore update_lock; | 267 | struct mutex update_lock; |
267 | int valid; /* !=0 if following fields are valid */ | 268 | int valid; /* !=0 if following fields are valid */ |
268 | unsigned long last_reading; /* In jiffies */ | 269 | unsigned long last_reading; /* In jiffies */ |
269 | unsigned long last_config; /* In jiffies */ | 270 | unsigned long last_config; /* In jiffies */ |
@@ -298,9 +299,8 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter); | |||
298 | static int adm1026_detect(struct i2c_adapter *adapter, int address, | 299 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
299 | int kind); | 300 | int kind); |
300 | static int adm1026_detach_client(struct i2c_client *client); | 301 | static int adm1026_detach_client(struct i2c_client *client); |
301 | static int adm1026_read_value(struct i2c_client *client, u8 register); | 302 | static int adm1026_read_value(struct i2c_client *client, u8 reg); |
302 | static int adm1026_write_value(struct i2c_client *client, u8 register, | 303 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); |
303 | int value); | ||
304 | static void adm1026_print_gpio(struct i2c_client *client); | 304 | static void adm1026_print_gpio(struct i2c_client *client); |
305 | static void adm1026_fixup_gpio(struct i2c_client *client); | 305 | static void adm1026_fixup_gpio(struct i2c_client *client); |
306 | static struct adm1026_data *adm1026_update_device(struct device *dev); | 306 | static struct adm1026_data *adm1026_update_device(struct device *dev); |
@@ -575,7 +575,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
575 | int i; | 575 | int i; |
576 | long value, alarms, gpio; | 576 | long value, alarms, gpio; |
577 | 577 | ||
578 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
579 | if (!data->valid | 579 | if (!data->valid |
580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { | 580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { |
581 | /* Things that change quickly */ | 581 | /* Things that change quickly */ |
@@ -710,7 +710,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); | 710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); |
711 | data->vid = (data->gpio >> 11) & 0x1f; | 711 | data->vid = (data->gpio >> 11) & 0x1f; |
712 | data->valid = 1; | 712 | data->valid = 1; |
713 | up(&data->update_lock); | 713 | mutex_unlock(&data->update_lock); |
714 | return data; | 714 | return data; |
715 | } | 715 | } |
716 | 716 | ||
@@ -739,10 +739,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
739 | struct adm1026_data *data = i2c_get_clientdata(client); | 739 | struct adm1026_data *data = i2c_get_clientdata(client); |
740 | int val = simple_strtol(buf, NULL, 10); | 740 | int val = simple_strtol(buf, NULL, 10); |
741 | 741 | ||
742 | down(&data->update_lock); | 742 | mutex_lock(&data->update_lock); |
743 | data->in_min[nr] = INS_TO_REG(nr, val); | 743 | data->in_min[nr] = INS_TO_REG(nr, val); |
744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); | 744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); |
745 | up(&data->update_lock); | 745 | mutex_unlock(&data->update_lock); |
746 | return count; | 746 | return count; |
747 | } | 747 | } |
748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | 748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
@@ -762,10 +762,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
762 | struct adm1026_data *data = i2c_get_clientdata(client); | 762 | struct adm1026_data *data = i2c_get_clientdata(client); |
763 | int val = simple_strtol(buf, NULL, 10); | 763 | int val = simple_strtol(buf, NULL, 10); |
764 | 764 | ||
765 | down(&data->update_lock); | 765 | mutex_lock(&data->update_lock); |
766 | data->in_max[nr] = INS_TO_REG(nr, val); | 766 | data->in_max[nr] = INS_TO_REG(nr, val); |
767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); | 767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); |
768 | up(&data->update_lock); | 768 | mutex_unlock(&data->update_lock); |
769 | return count; | 769 | return count; |
770 | } | 770 | } |
771 | 771 | ||
@@ -813,10 +813,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c | |||
813 | struct adm1026_data *data = i2c_get_clientdata(client); | 813 | struct adm1026_data *data = i2c_get_clientdata(client); |
814 | int val = simple_strtol(buf, NULL, 10); | 814 | int val = simple_strtol(buf, NULL, 10); |
815 | 815 | ||
816 | down(&data->update_lock); | 816 | mutex_lock(&data->update_lock); |
817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); | 817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); |
818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); | 818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); |
819 | up(&data->update_lock); | 819 | mutex_unlock(&data->update_lock); |
820 | return count; | 820 | return count; |
821 | } | 821 | } |
822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) | 822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -831,10 +831,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c | |||
831 | struct adm1026_data *data = i2c_get_clientdata(client); | 831 | struct adm1026_data *data = i2c_get_clientdata(client); |
832 | int val = simple_strtol(buf, NULL, 10); | 832 | int val = simple_strtol(buf, NULL, 10); |
833 | 833 | ||
834 | down(&data->update_lock); | 834 | mutex_lock(&data->update_lock); |
835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); | 835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); |
836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); | 836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); |
837 | up(&data->update_lock); | 837 | mutex_unlock(&data->update_lock); |
838 | return count; | 838 | return count; |
839 | } | 839 | } |
840 | 840 | ||
@@ -874,11 +874,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
874 | struct adm1026_data *data = i2c_get_clientdata(client); | 874 | struct adm1026_data *data = i2c_get_clientdata(client); |
875 | int val = simple_strtol(buf, NULL, 10); | 875 | int val = simple_strtol(buf, NULL, 10); |
876 | 876 | ||
877 | down(&data->update_lock); | 877 | mutex_lock(&data->update_lock); |
878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); | 878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); |
879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), | 879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), |
880 | data->fan_min[nr]); | 880 | data->fan_min[nr]); |
881 | up(&data->update_lock); | 881 | mutex_unlock(&data->update_lock); |
882 | return count; | 882 | return count; |
883 | } | 883 | } |
884 | 884 | ||
@@ -939,7 +939,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
939 | if (new_div == 0) { | 939 | if (new_div == 0) { |
940 | return -EINVAL; | 940 | return -EINVAL; |
941 | } | 941 | } |
942 | down(&data->update_lock); | 942 | mutex_lock(&data->update_lock); |
943 | orig_div = data->fan_div[nr]; | 943 | orig_div = data->fan_div[nr]; |
944 | data->fan_div[nr] = DIV_FROM_REG(new_div); | 944 | data->fan_div[nr] = DIV_FROM_REG(new_div); |
945 | 945 | ||
@@ -958,7 +958,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
958 | if (data->fan_div[nr] != orig_div) { | 958 | if (data->fan_div[nr] != orig_div) { |
959 | fixup_fan_min(dev,nr,orig_div); | 959 | fixup_fan_min(dev,nr,orig_div); |
960 | } | 960 | } |
961 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
962 | return count; | 962 | return count; |
963 | } | 963 | } |
964 | 964 | ||
@@ -1001,11 +1001,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
1001 | struct adm1026_data *data = i2c_get_clientdata(client); | 1001 | struct adm1026_data *data = i2c_get_clientdata(client); |
1002 | int val = simple_strtol(buf, NULL, 10); | 1002 | int val = simple_strtol(buf, NULL, 10); |
1003 | 1003 | ||
1004 | down(&data->update_lock); | 1004 | mutex_lock(&data->update_lock); |
1005 | data->temp_min[nr] = TEMP_TO_REG(val); | 1005 | data->temp_min[nr] = TEMP_TO_REG(val); |
1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], | 1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], |
1007 | data->temp_min[nr]); | 1007 | data->temp_min[nr]); |
1008 | up(&data->update_lock); | 1008 | mutex_unlock(&data->update_lock); |
1009 | return count; | 1009 | return count; |
1010 | } | 1010 | } |
1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | 1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
@@ -1025,11 +1025,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
1025 | struct adm1026_data *data = i2c_get_clientdata(client); | 1025 | struct adm1026_data *data = i2c_get_clientdata(client); |
1026 | int val = simple_strtol(buf, NULL, 10); | 1026 | int val = simple_strtol(buf, NULL, 10); |
1027 | 1027 | ||
1028 | down(&data->update_lock); | 1028 | mutex_lock(&data->update_lock); |
1029 | data->temp_max[nr] = TEMP_TO_REG(val); | 1029 | data->temp_max[nr] = TEMP_TO_REG(val); |
1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], | 1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], |
1031 | data->temp_max[nr]); | 1031 | data->temp_max[nr]); |
1032 | up(&data->update_lock); | 1032 | mutex_unlock(&data->update_lock); |
1033 | return count; | 1033 | return count; |
1034 | } | 1034 | } |
1035 | 1035 | ||
@@ -1064,11 +1064,11 @@ static ssize_t set_temp_offset(struct device *dev, | |||
1064 | struct adm1026_data *data = i2c_get_clientdata(client); | 1064 | struct adm1026_data *data = i2c_get_clientdata(client); |
1065 | int val = simple_strtol(buf, NULL, 10); | 1065 | int val = simple_strtol(buf, NULL, 10); |
1066 | 1066 | ||
1067 | down(&data->update_lock); | 1067 | mutex_lock(&data->update_lock); |
1068 | data->temp_offset[nr] = TEMP_TO_REG(val); | 1068 | data->temp_offset[nr] = TEMP_TO_REG(val); |
1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], | 1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], |
1070 | data->temp_offset[nr]); | 1070 | data->temp_offset[nr]); |
1071 | up(&data->update_lock); | 1071 | mutex_unlock(&data->update_lock); |
1072 | return count; | 1072 | return count; |
1073 | } | 1073 | } |
1074 | 1074 | ||
@@ -1115,11 +1115,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, | |||
1115 | struct adm1026_data *data = i2c_get_clientdata(client); | 1115 | struct adm1026_data *data = i2c_get_clientdata(client); |
1116 | int val = simple_strtol(buf, NULL, 10); | 1116 | int val = simple_strtol(buf, NULL, 10); |
1117 | 1117 | ||
1118 | down(&data->update_lock); | 1118 | mutex_lock(&data->update_lock); |
1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); | 1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); |
1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], | 1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], |
1121 | data->temp_tmin[nr]); | 1121 | data->temp_tmin[nr]); |
1122 | up(&data->update_lock); | 1122 | mutex_unlock(&data->update_lock); |
1123 | return count; | 1123 | return count; |
1124 | } | 1124 | } |
1125 | 1125 | ||
@@ -1150,11 +1150,11 @@ static ssize_t set_temp_crit_enable(struct device *dev, | |||
1150 | int val = simple_strtol(buf, NULL, 10); | 1150 | int val = simple_strtol(buf, NULL, 10); |
1151 | 1151 | ||
1152 | if ((val == 1) || (val==0)) { | 1152 | if ((val == 1) || (val==0)) { |
1153 | down(&data->update_lock); | 1153 | mutex_lock(&data->update_lock); |
1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); | 1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); |
1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1156 | data->config1); | 1156 | data->config1); |
1157 | up(&data->update_lock); | 1157 | mutex_unlock(&data->update_lock); |
1158 | } | 1158 | } |
1159 | return count; | 1159 | return count; |
1160 | } | 1160 | } |
@@ -1184,11 +1184,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
1184 | struct adm1026_data *data = i2c_get_clientdata(client); | 1184 | struct adm1026_data *data = i2c_get_clientdata(client); |
1185 | int val = simple_strtol(buf, NULL, 10); | 1185 | int val = simple_strtol(buf, NULL, 10); |
1186 | 1186 | ||
1187 | down(&data->update_lock); | 1187 | mutex_lock(&data->update_lock); |
1188 | data->temp_crit[nr] = TEMP_TO_REG(val); | 1188 | data->temp_crit[nr] = TEMP_TO_REG(val); |
1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], | 1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], |
1190 | data->temp_crit[nr]); | 1190 | data->temp_crit[nr]); |
1191 | up(&data->update_lock); | 1191 | mutex_unlock(&data->update_lock); |
1192 | return count; | 1192 | return count; |
1193 | } | 1193 | } |
1194 | 1194 | ||
@@ -1212,10 +1212,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a | |||
1212 | struct adm1026_data *data = i2c_get_clientdata(client); | 1212 | struct adm1026_data *data = i2c_get_clientdata(client); |
1213 | int val = simple_strtol(buf, NULL, 10); | 1213 | int val = simple_strtol(buf, NULL, 10); |
1214 | 1214 | ||
1215 | down(&data->update_lock); | 1215 | mutex_lock(&data->update_lock); |
1216 | data->analog_out = DAC_TO_REG(val); | 1216 | data->analog_out = DAC_TO_REG(val); |
1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); | 1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); |
1218 | up(&data->update_lock); | 1218 | mutex_unlock(&data->update_lock); |
1219 | return count; | 1219 | return count; |
1220 | } | 1220 | } |
1221 | 1221 | ||
@@ -1267,7 +1267,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1267 | int val = simple_strtol(buf, NULL, 10); | 1267 | int val = simple_strtol(buf, NULL, 10); |
1268 | unsigned long mask; | 1268 | unsigned long mask; |
1269 | 1269 | ||
1270 | down(&data->update_lock); | 1270 | mutex_lock(&data->update_lock); |
1271 | data->alarm_mask = val & 0x7fffffff; | 1271 | data->alarm_mask = val & 0x7fffffff; |
1272 | mask = data->alarm_mask | 1272 | mask = data->alarm_mask |
1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); | 1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); |
@@ -1282,7 +1282,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1282 | mask >>= 8; | 1282 | mask >>= 8; |
1283 | adm1026_write_value(client, ADM1026_REG_MASK4, | 1283 | adm1026_write_value(client, ADM1026_REG_MASK4, |
1284 | mask & 0xff); | 1284 | mask & 0xff); |
1285 | up(&data->update_lock); | 1285 | mutex_unlock(&data->update_lock); |
1286 | return count; | 1286 | return count; |
1287 | } | 1287 | } |
1288 | 1288 | ||
@@ -1303,7 +1303,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1303 | int val = simple_strtol(buf, NULL, 10); | 1303 | int val = simple_strtol(buf, NULL, 10); |
1304 | long gpio; | 1304 | long gpio; |
1305 | 1305 | ||
1306 | down(&data->update_lock); | 1306 | mutex_lock(&data->update_lock); |
1307 | data->gpio = val & 0x1ffff; | 1307 | data->gpio = val & 0x1ffff; |
1308 | gpio = data->gpio; | 1308 | gpio = data->gpio; |
1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); | 1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); |
@@ -1311,7 +1311,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); | 1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); |
1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); | 1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); |
1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); | 1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); |
1314 | up(&data->update_lock); | 1314 | mutex_unlock(&data->update_lock); |
1315 | return count; | 1315 | return count; |
1316 | } | 1316 | } |
1317 | 1317 | ||
@@ -1331,7 +1331,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1331 | int val = simple_strtol(buf, NULL, 10); | 1331 | int val = simple_strtol(buf, NULL, 10); |
1332 | long mask; | 1332 | long mask; |
1333 | 1333 | ||
1334 | down(&data->update_lock); | 1334 | mutex_lock(&data->update_lock); |
1335 | data->gpio_mask = val & 0x1ffff; | 1335 | data->gpio_mask = val & 0x1ffff; |
1336 | mask = data->gpio_mask; | 1336 | mask = data->gpio_mask; |
1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); | 1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); |
@@ -1339,7 +1339,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); | 1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); |
1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); | 1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); |
1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); | 1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); |
1342 | up(&data->update_lock); | 1342 | mutex_unlock(&data->update_lock); |
1343 | return count; | 1343 | return count; |
1344 | } | 1344 | } |
1345 | 1345 | ||
@@ -1359,10 +1359,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co | |||
1359 | if (data->pwm1.enable == 1) { | 1359 | if (data->pwm1.enable == 1) { |
1360 | int val = simple_strtol(buf, NULL, 10); | 1360 | int val = simple_strtol(buf, NULL, 10); |
1361 | 1361 | ||
1362 | down(&data->update_lock); | 1362 | mutex_lock(&data->update_lock); |
1363 | data->pwm1.pwm = PWM_TO_REG(val); | 1363 | data->pwm1.pwm = PWM_TO_REG(val); |
1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1365 | up(&data->update_lock); | 1365 | mutex_unlock(&data->update_lock); |
1366 | } | 1366 | } |
1367 | return count; | 1367 | return count; |
1368 | } | 1368 | } |
@@ -1378,14 +1378,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1378 | struct adm1026_data *data = i2c_get_clientdata(client); | 1378 | struct adm1026_data *data = i2c_get_clientdata(client); |
1379 | int val = simple_strtol(buf, NULL, 10); | 1379 | int val = simple_strtol(buf, NULL, 10); |
1380 | 1380 | ||
1381 | down(&data->update_lock); | 1381 | mutex_lock(&data->update_lock); |
1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); | 1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); |
1383 | if (data->pwm1.enable == 2) { /* apply immediately */ | 1383 | if (data->pwm1.enable == 2) { /* apply immediately */ |
1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1387 | } | 1387 | } |
1388 | up(&data->update_lock); | 1388 | mutex_unlock(&data->update_lock); |
1389 | return count; | 1389 | return count; |
1390 | } | 1390 | } |
1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) | 1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -1406,7 +1406,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1406 | int old_enable; | 1406 | int old_enable; |
1407 | 1407 | ||
1408 | if ((val >= 0) && (val < 3)) { | 1408 | if ((val >= 0) && (val < 3)) { |
1409 | down(&data->update_lock); | 1409 | mutex_lock(&data->update_lock); |
1410 | old_enable = data->pwm1.enable; | 1410 | old_enable = data->pwm1.enable; |
1411 | data->pwm1.enable = val; | 1411 | data->pwm1.enable = val; |
1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) | 1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) |
@@ -1424,7 +1424,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1424 | adm1026_write_value(client, ADM1026_REG_PWM, | 1424 | adm1026_write_value(client, ADM1026_REG_PWM, |
1425 | data->pwm1.pwm); | 1425 | data->pwm1.pwm); |
1426 | } | 1426 | } |
1427 | up(&data->update_lock); | 1427 | mutex_unlock(&data->update_lock); |
1428 | } | 1428 | } |
1429 | return count; | 1429 | return count; |
1430 | } | 1430 | } |
@@ -1541,7 +1541,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1541 | /* Fill in the remaining client fields */ | 1541 | /* Fill in the remaining client fields */ |
1542 | data->type = kind; | 1542 | data->type = kind; |
1543 | data->valid = 0; | 1543 | data->valid = 0; |
1544 | init_MUTEX(&data->update_lock); | 1544 | mutex_init(&data->update_lock); |
1545 | 1545 | ||
1546 | /* Tell the I2C layer a new client has arrived */ | 1546 | /* Tell the I2C layer a new client has arrived */ |
1547 | if ((err = i2c_attach_client(new_client))) | 1547 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index d06397966081..3bf2da621aed 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | 32 | ||
32 | /* Following macros takes channel parameter starting from 0 to 2 */ | 33 | /* Following macros takes channel parameter starting from 0 to 2 */ |
33 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) | 34 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) |
@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2]; | |||
70 | struct adm1031_data { | 71 | struct adm1031_data { |
71 | struct i2c_client client; | 72 | struct i2c_client client; |
72 | struct class_device *class_dev; | 73 | struct class_device *class_dev; |
73 | struct semaphore update_lock; | 74 | struct mutex update_lock; |
74 | int chip_type; | 75 | int chip_type; |
75 | char valid; /* !=0 if following fields are valid */ | 76 | char valid; /* !=0 if following fields are valid */ |
76 | unsigned long last_updated; /* In jiffies */ | 77 | unsigned long last_updated; /* In jiffies */ |
@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
262 | 263 | ||
263 | old_fan_mode = data->conf1; | 264 | old_fan_mode = data->conf1; |
264 | 265 | ||
265 | down(&data->update_lock); | 266 | mutex_lock(&data->update_lock); |
266 | 267 | ||
267 | if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®))) { | 268 | if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®))) { |
268 | up(&data->update_lock); | 269 | mutex_unlock(&data->update_lock); |
269 | return ret; | 270 | return ret; |
270 | } | 271 | } |
271 | if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ | 272 | if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ |
@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
288 | } | 289 | } |
289 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); | 290 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); |
290 | adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); | 291 | adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); |
291 | up(&data->update_lock); | 292 | mutex_unlock(&data->update_lock); |
292 | return count; | 293 | return count; |
293 | } | 294 | } |
294 | 295 | ||
@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr) | |||
329 | struct adm1031_data *data = i2c_get_clientdata(client); | 330 | struct adm1031_data *data = i2c_get_clientdata(client); |
330 | int val = simple_strtol(buf, NULL, 10); | 331 | int val = simple_strtol(buf, NULL, 10); |
331 | 332 | ||
332 | down(&data->update_lock); | 333 | mutex_lock(&data->update_lock); |
333 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); | 334 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); |
334 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 335 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
335 | data->auto_temp[nr]); | 336 | data->auto_temp[nr]); |
336 | up(&data->update_lock); | 337 | mutex_unlock(&data->update_lock); |
337 | return count; | 338 | return count; |
338 | } | 339 | } |
339 | static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) | 340 | static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) |
@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
349 | struct adm1031_data *data = i2c_get_clientdata(client); | 350 | struct adm1031_data *data = i2c_get_clientdata(client); |
350 | int val = simple_strtol(buf, NULL, 10); | 351 | int val = simple_strtol(buf, NULL, 10); |
351 | 352 | ||
352 | down(&data->update_lock); | 353 | mutex_lock(&data->update_lock); |
353 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); | 354 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); |
354 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 355 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
355 | data->temp_max[nr]); | 356 | data->temp_max[nr]); |
356 | up(&data->update_lock); | 357 | mutex_unlock(&data->update_lock); |
357 | return count; | 358 | return count; |
358 | } | 359 | } |
359 | 360 | ||
@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
405 | int val = simple_strtol(buf, NULL, 10); | 406 | int val = simple_strtol(buf, NULL, 10); |
406 | int reg; | 407 | int reg; |
407 | 408 | ||
408 | down(&data->update_lock); | 409 | mutex_lock(&data->update_lock); |
409 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && | 410 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && |
410 | (((val>>4) & 0xf) != 5)) { | 411 | (((val>>4) & 0xf) != 5)) { |
411 | /* In automatic mode, the only PWM accepted is 33% */ | 412 | /* In automatic mode, the only PWM accepted is 33% */ |
412 | up(&data->update_lock); | 413 | mutex_unlock(&data->update_lock); |
413 | return -EINVAL; | 414 | return -EINVAL; |
414 | } | 415 | } |
415 | data->pwm[nr] = PWM_TO_REG(val); | 416 | data->pwm[nr] = PWM_TO_REG(val); |
@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
417 | adm1031_write_value(client, ADM1031_REG_PWM, | 418 | adm1031_write_value(client, ADM1031_REG_PWM, |
418 | nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) | 419 | nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) |
419 | : (data->pwm[nr] & 0xf) | (reg & 0xf0)); | 420 | : (data->pwm[nr] & 0xf) | (reg & 0xf0)); |
420 | up(&data->update_lock); | 421 | mutex_unlock(&data->update_lock); |
421 | return count; | 422 | return count; |
422 | } | 423 | } |
423 | 424 | ||
@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
511 | struct adm1031_data *data = i2c_get_clientdata(client); | 512 | struct adm1031_data *data = i2c_get_clientdata(client); |
512 | int val = simple_strtol(buf, NULL, 10); | 513 | int val = simple_strtol(buf, NULL, 10); |
513 | 514 | ||
514 | down(&data->update_lock); | 515 | mutex_lock(&data->update_lock); |
515 | if (val) { | 516 | if (val) { |
516 | data->fan_min[nr] = | 517 | data->fan_min[nr] = |
517 | FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); | 518 | FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); |
@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
519 | data->fan_min[nr] = 0xff; | 520 | data->fan_min[nr] = 0xff; |
520 | } | 521 | } |
521 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); | 522 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); |
522 | up(&data->update_lock); | 523 | mutex_unlock(&data->update_lock); |
523 | return count; | 524 | return count; |
524 | } | 525 | } |
525 | static ssize_t | 526 | static ssize_t |
@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
540 | if (tmp == 0xff) | 541 | if (tmp == 0xff) |
541 | return -EINVAL; | 542 | return -EINVAL; |
542 | 543 | ||
543 | down(&data->update_lock); | 544 | mutex_lock(&data->update_lock); |
544 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); | 545 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); |
545 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); | 546 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); |
546 | new_min = data->fan_min[nr] * old_div / | 547 | new_min = data->fan_min[nr] * old_div / |
@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
553 | data->fan_div[nr]); | 554 | data->fan_div[nr]); |
554 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), | 555 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), |
555 | data->fan_min[nr]); | 556 | data->fan_min[nr]); |
556 | up(&data->update_lock); | 557 | mutex_unlock(&data->update_lock); |
557 | return count; | 558 | return count; |
558 | } | 559 | } |
559 | 560 | ||
@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr) | |||
627 | 628 | ||
628 | val = simple_strtol(buf, NULL, 10); | 629 | val = simple_strtol(buf, NULL, 10); |
629 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 630 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
630 | down(&data->update_lock); | 631 | mutex_lock(&data->update_lock); |
631 | data->temp_min[nr] = TEMP_TO_REG(val); | 632 | data->temp_min[nr] = TEMP_TO_REG(val); |
632 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), | 633 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), |
633 | data->temp_min[nr]); | 634 | data->temp_min[nr]); |
634 | up(&data->update_lock); | 635 | mutex_unlock(&data->update_lock); |
635 | return count; | 636 | return count; |
636 | } | 637 | } |
637 | static ssize_t | 638 | static ssize_t |
@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
643 | 644 | ||
644 | val = simple_strtol(buf, NULL, 10); | 645 | val = simple_strtol(buf, NULL, 10); |
645 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 646 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
646 | down(&data->update_lock); | 647 | mutex_lock(&data->update_lock); |
647 | data->temp_max[nr] = TEMP_TO_REG(val); | 648 | data->temp_max[nr] = TEMP_TO_REG(val); |
648 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), | 649 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), |
649 | data->temp_max[nr]); | 650 | data->temp_max[nr]); |
650 | up(&data->update_lock); | 651 | mutex_unlock(&data->update_lock); |
651 | return count; | 652 | return count; |
652 | } | 653 | } |
653 | static ssize_t | 654 | static ssize_t |
@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr) | |||
659 | 660 | ||
660 | val = simple_strtol(buf, NULL, 10); | 661 | val = simple_strtol(buf, NULL, 10); |
661 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 662 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
662 | down(&data->update_lock); | 663 | mutex_lock(&data->update_lock); |
663 | data->temp_crit[nr] = TEMP_TO_REG(val); | 664 | data->temp_crit[nr] = TEMP_TO_REG(val); |
664 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), | 665 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), |
665 | data->temp_crit[nr]); | 666 | data->temp_crit[nr]); |
666 | up(&data->update_lock); | 667 | mutex_unlock(&data->update_lock); |
667 | return count; | 668 | return count; |
668 | } | 669 | } |
669 | 670 | ||
@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
778 | 779 | ||
779 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 780 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
780 | data->valid = 0; | 781 | data->valid = 0; |
781 | init_MUTEX(&data->update_lock); | 782 | mutex_init(&data->update_lock); |
782 | 783 | ||
783 | /* Tell the I2C layer a new client has arrived */ | 784 | /* Tell the I2C layer a new client has arrived */ |
784 | if ((err = i2c_attach_client(new_client))) | 785 | if ((err = i2c_attach_client(new_client))) |
@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
891 | struct adm1031_data *data = i2c_get_clientdata(client); | 892 | struct adm1031_data *data = i2c_get_clientdata(client); |
892 | int chan; | 893 | int chan; |
893 | 894 | ||
894 | down(&data->update_lock); | 895 | mutex_lock(&data->update_lock); |
895 | 896 | ||
896 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 897 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
897 | || !data->valid) { | 898 | || !data->valid) { |
@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
965 | data->valid = 1; | 966 | data->valid = 1; |
966 | } | 967 | } |
967 | 968 | ||
968 | up(&data->update_lock); | 969 | mutex_unlock(&data->update_lock); |
969 | 970 | ||
970 | return data; | 971 | return data; |
971 | } | 972 | } |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 5ddc22fea4a3..43f6991b588c 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
50 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
51 | #include <linux/err.h> | 51 | #include <linux/err.h> |
52 | #include <linux/mutex.h> | ||
52 | 53 | ||
53 | /* Addresses to scan */ | 54 | /* Addresses to scan */ |
54 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | 55 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
@@ -150,7 +151,7 @@ struct adm9240_data { | |||
150 | enum chips type; | 151 | enum chips type; |
151 | struct i2c_client client; | 152 | struct i2c_client client; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | struct semaphore update_lock; | 154 | struct mutex update_lock; |
154 | char valid; | 155 | char valid; |
155 | unsigned long last_updated_measure; | 156 | unsigned long last_updated_measure; |
156 | unsigned long last_updated_config; | 157 | unsigned long last_updated_config; |
@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr, | |||
195 | struct adm9240_data *data = i2c_get_clientdata(client); | 196 | struct adm9240_data *data = i2c_get_clientdata(client); |
196 | long val = simple_strtol(buf, NULL, 10); | 197 | long val = simple_strtol(buf, NULL, 10); |
197 | 198 | ||
198 | down(&data->update_lock); | 199 | mutex_lock(&data->update_lock); |
199 | data->temp_max[attr->index] = TEMP_TO_REG(val); | 200 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), | 201 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), |
201 | data->temp_max[attr->index]); | 202 | data->temp_max[attr->index]); |
202 | up(&data->update_lock); | 203 | mutex_unlock(&data->update_lock); |
203 | return count; | 204 | return count; |
204 | } | 205 | } |
205 | 206 | ||
@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev, | |||
246 | struct adm9240_data *data = i2c_get_clientdata(client); | 247 | struct adm9240_data *data = i2c_get_clientdata(client); |
247 | unsigned long val = simple_strtoul(buf, NULL, 10); | 248 | unsigned long val = simple_strtoul(buf, NULL, 10); |
248 | 249 | ||
249 | down(&data->update_lock); | 250 | mutex_lock(&data->update_lock); |
250 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); | 251 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
251 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), | 252 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
252 | data->in_min[attr->index]); | 253 | data->in_min[attr->index]); |
253 | up(&data->update_lock); | 254 | mutex_unlock(&data->update_lock); |
254 | return count; | 255 | return count; |
255 | } | 256 | } |
256 | 257 | ||
@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev, | |||
263 | struct adm9240_data *data = i2c_get_clientdata(client); | 264 | struct adm9240_data *data = i2c_get_clientdata(client); |
264 | unsigned long val = simple_strtoul(buf, NULL, 10); | 265 | unsigned long val = simple_strtoul(buf, NULL, 10); |
265 | 266 | ||
266 | down(&data->update_lock); | 267 | mutex_lock(&data->update_lock); |
267 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); | 268 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
268 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), | 269 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
269 | data->in_max[attr->index]); | 270 | data->in_max[attr->index]); |
270 | up(&data->update_lock); | 271 | mutex_unlock(&data->update_lock); |
271 | return count; | 272 | return count; |
272 | } | 273 | } |
273 | 274 | ||
@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev, | |||
350 | int nr = attr->index; | 351 | int nr = attr->index; |
351 | u8 new_div; | 352 | u8 new_div; |
352 | 353 | ||
353 | down(&data->update_lock); | 354 | mutex_lock(&data->update_lock); |
354 | 355 | ||
355 | if (!val) { | 356 | if (!val) { |
356 | data->fan_min[nr] = 255; | 357 | data->fan_min[nr] = 255; |
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev, | |||
390 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), | 391 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), |
391 | data->fan_min[nr]); | 392 | data->fan_min[nr]); |
392 | 393 | ||
393 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
394 | return count; | 395 | return count; |
395 | } | 396 | } |
396 | 397 | ||
@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev, | |||
439 | struct adm9240_data *data = i2c_get_clientdata(client); | 440 | struct adm9240_data *data = i2c_get_clientdata(client); |
440 | unsigned long val = simple_strtol(buf, NULL, 10); | 441 | unsigned long val = simple_strtol(buf, NULL, 10); |
441 | 442 | ||
442 | down(&data->update_lock); | 443 | mutex_lock(&data->update_lock); |
443 | data->aout = AOUT_TO_REG(val); | 444 | data->aout = AOUT_TO_REG(val); |
444 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); | 445 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); |
445 | up(&data->update_lock); | 446 | mutex_unlock(&data->update_lock); |
446 | return count; | 447 | return count; |
447 | } | 448 | } |
448 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 449 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
539 | /* fill in the remaining client fields and attach */ | 540 | /* fill in the remaining client fields and attach */ |
540 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 541 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
541 | data->type = kind; | 542 | data->type = kind; |
542 | init_MUTEX(&data->update_lock); | 543 | mutex_init(&data->update_lock); |
543 | 544 | ||
544 | if ((err = i2c_attach_client(new_client))) | 545 | if ((err = i2c_attach_client(new_client))) |
545 | goto exit_free; | 546 | goto exit_free; |
@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
691 | struct adm9240_data *data = i2c_get_clientdata(client); | 692 | struct adm9240_data *data = i2c_get_clientdata(client); |
692 | int i; | 693 | int i; |
693 | 694 | ||
694 | down(&data->update_lock); | 695 | mutex_lock(&data->update_lock); |
695 | 696 | ||
696 | /* minimum measurement cycle: 1.75 seconds */ | 697 | /* minimum measurement cycle: 1.75 seconds */ |
697 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) | 698 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) |
@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
771 | data->last_updated_config = jiffies; | 772 | data->last_updated_config = jiffies; |
772 | data->valid = 1; | 773 | data->valid = 1; |
773 | } | 774 | } |
774 | up(&data->update_lock); | 775 | mutex_unlock(&data->update_lock); |
775 | return data; | 776 | return data; |
776 | } | 777 | } |
777 | 778 | ||
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index ae9de63cf2e0..65b2709f750c 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
46 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
47 | #include <linux/mutex.h> | ||
47 | #include "lm75.h" | 48 | #include "lm75.h" |
48 | 49 | ||
49 | /* | 50 | /* |
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val) | |||
182 | struct asb100_data { | 183 | struct asb100_data { |
183 | struct i2c_client client; | 184 | struct i2c_client client; |
184 | struct class_device *class_dev; | 185 | struct class_device *class_dev; |
185 | struct semaphore lock; | 186 | struct mutex lock; |
186 | enum chips type; | 187 | enum chips type; |
187 | 188 | ||
188 | struct semaphore update_lock; | 189 | struct mutex update_lock; |
189 | unsigned long last_updated; /* In jiffies */ | 190 | unsigned long last_updated; /* In jiffies */ |
190 | 191 | ||
191 | /* array of 2 pointers to subclients */ | 192 | /* array of 2 pointers to subclients */ |
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \ | |||
245 | struct asb100_data *data = i2c_get_clientdata(client); \ | 246 | struct asb100_data *data = i2c_get_clientdata(client); \ |
246 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
247 | \ | 248 | \ |
248 | down(&data->update_lock); \ | 249 | mutex_lock(&data->update_lock); \ |
249 | data->in_##reg[nr] = IN_TO_REG(val); \ | 250 | data->in_##reg[nr] = IN_TO_REG(val); \ |
250 | asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ | 251 | asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ |
251 | data->in_##reg[nr]); \ | 252 | data->in_##reg[nr]); \ |
252 | up(&data->update_lock); \ | 253 | mutex_unlock(&data->update_lock); \ |
253 | return count; \ | 254 | return count; \ |
254 | } | 255 | } |
255 | 256 | ||
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
331 | struct asb100_data *data = i2c_get_clientdata(client); | 332 | struct asb100_data *data = i2c_get_clientdata(client); |
332 | u32 val = simple_strtoul(buf, NULL, 10); | 333 | u32 val = simple_strtoul(buf, NULL, 10); |
333 | 334 | ||
334 | down(&data->update_lock); | 335 | mutex_lock(&data->update_lock); |
335 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 336 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
336 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); | 337 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); |
337 | up(&data->update_lock); | 338 | mutex_unlock(&data->update_lock); |
338 | return count; | 339 | return count; |
339 | } | 340 | } |
340 | 341 | ||
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
351 | unsigned long val = simple_strtoul(buf, NULL, 10); | 352 | unsigned long val = simple_strtoul(buf, NULL, 10); |
352 | int reg; | 353 | int reg; |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | 356 | ||
356 | min = FAN_FROM_REG(data->fan_min[nr], | 357 | min = FAN_FROM_REG(data->fan_min[nr], |
357 | DIV_FROM_REG(data->fan_div[nr])); | 358 | DIV_FROM_REG(data->fan_div[nr])); |
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
381 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 382 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
382 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); | 383 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); |
383 | 384 | ||
384 | up(&data->update_lock); | 385 | mutex_unlock(&data->update_lock); |
385 | 386 | ||
386 | return count; | 387 | return count; |
387 | } | 388 | } |
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ | |||
461 | struct asb100_data *data = i2c_get_clientdata(client); \ | 462 | struct asb100_data *data = i2c_get_clientdata(client); \ |
462 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 463 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
463 | \ | 464 | \ |
464 | down(&data->update_lock); \ | 465 | mutex_lock(&data->update_lock); \ |
465 | switch (nr) { \ | 466 | switch (nr) { \ |
466 | case 1: case 2: \ | 467 | case 1: case 2: \ |
467 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 468 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ | |||
472 | } \ | 473 | } \ |
473 | asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ | 474 | asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ |
474 | data->reg[nr]); \ | 475 | data->reg[nr]); \ |
475 | up(&data->update_lock); \ | 476 | mutex_unlock(&data->update_lock); \ |
476 | return count; \ | 477 | return count; \ |
477 | } | 478 | } |
478 | 479 | ||
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const | |||
574 | struct asb100_data *data = i2c_get_clientdata(client); | 575 | struct asb100_data *data = i2c_get_clientdata(client); |
575 | unsigned long val = simple_strtoul(buf, NULL, 10); | 576 | unsigned long val = simple_strtoul(buf, NULL, 10); |
576 | 577 | ||
577 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
578 | data->pwm &= 0x80; /* keep the enable bit */ | 579 | data->pwm &= 0x80; /* keep the enable bit */ |
579 | data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); | 580 | data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); |
580 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); | 581 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); |
581 | up(&data->update_lock); | 582 | mutex_unlock(&data->update_lock); |
582 | return count; | 583 | return count; |
583 | } | 584 | } |
584 | 585 | ||
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr | |||
595 | struct asb100_data *data = i2c_get_clientdata(client); | 596 | struct asb100_data *data = i2c_get_clientdata(client); |
596 | unsigned long val = simple_strtoul(buf, NULL, 10); | 597 | unsigned long val = simple_strtoul(buf, NULL, 10); |
597 | 598 | ||
598 | down(&data->update_lock); | 599 | mutex_lock(&data->update_lock); |
599 | data->pwm &= 0x0f; /* keep the duty cycle bits */ | 600 | data->pwm &= 0x0f; /* keep the duty cycle bits */ |
600 | data->pwm |= (val ? 0x80 : 0x00); | 601 | data->pwm |= (val ? 0x80 : 0x00); |
601 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); | 602 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); |
602 | up(&data->update_lock); | 603 | mutex_unlock(&data->update_lock); |
603 | return count; | 604 | return count; |
604 | } | 605 | } |
605 | 606 | ||
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
729 | } | 730 | } |
730 | 731 | ||
731 | new_client = &data->client; | 732 | new_client = &data->client; |
732 | init_MUTEX(&data->lock); | 733 | mutex_init(&data->lock); |
733 | i2c_set_clientdata(new_client, data); | 734 | i2c_set_clientdata(new_client, data); |
734 | new_client->addr = address; | 735 | new_client->addr = address; |
735 | new_client->adapter = adapter; | 736 | new_client->adapter = adapter; |
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
789 | data->type = kind; | 790 | data->type = kind; |
790 | 791 | ||
791 | data->valid = 0; | 792 | data->valid = 0; |
792 | init_MUTEX(&data->update_lock); | 793 | mutex_init(&data->update_lock); |
793 | 794 | ||
794 | /* Tell the I2C layer a new client has arrived */ | 795 | /* Tell the I2C layer a new client has arrived */ |
795 | if ((err = i2c_attach_client(new_client))) | 796 | if ((err = i2c_attach_client(new_client))) |
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
885 | struct i2c_client *cl; | 886 | struct i2c_client *cl; |
886 | int res, bank; | 887 | int res, bank; |
887 | 888 | ||
888 | down(&data->lock); | 889 | mutex_lock(&data->lock); |
889 | 890 | ||
890 | bank = (reg >> 8) & 0x0f; | 891 | bank = (reg >> 8) & 0x0f; |
891 | if (bank > 2) | 892 | if (bank > 2) |
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
919 | if (bank > 2) | 920 | if (bank > 2) |
920 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); | 921 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); |
921 | 922 | ||
922 | up(&data->lock); | 923 | mutex_unlock(&data->lock); |
923 | 924 | ||
924 | return res; | 925 | return res; |
925 | } | 926 | } |
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
930 | struct i2c_client *cl; | 931 | struct i2c_client *cl; |
931 | int bank; | 932 | int bank; |
932 | 933 | ||
933 | down(&data->lock); | 934 | mutex_lock(&data->lock); |
934 | 935 | ||
935 | bank = (reg >> 8) & 0x0f; | 936 | bank = (reg >> 8) & 0x0f; |
936 | if (bank > 2) | 937 | if (bank > 2) |
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
960 | if (bank > 2) | 961 | if (bank > 2) |
961 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); | 962 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); |
962 | 963 | ||
963 | up(&data->lock); | 964 | mutex_unlock(&data->lock); |
964 | } | 965 | } |
965 | 966 | ||
966 | static void asb100_init_client(struct i2c_client *client) | 967 | static void asb100_init_client(struct i2c_client *client) |
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev) | |||
984 | struct asb100_data *data = i2c_get_clientdata(client); | 985 | struct asb100_data *data = i2c_get_clientdata(client); |
985 | int i; | 986 | int i; |
986 | 987 | ||
987 | down(&data->update_lock); | 988 | mutex_lock(&data->update_lock); |
988 | 989 | ||
989 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 990 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
990 | || !data->valid) { | 991 | || !data->valid) { |
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev) | |||
1042 | dev_dbg(&client->dev, "... device update complete\n"); | 1043 | dev_dbg(&client->dev, "... device update complete\n"); |
1043 | } | 1044 | } |
1044 | 1045 | ||
1045 | up(&data->update_lock); | 1046 | mutex_unlock(&data->update_lock); |
1046 | 1047 | ||
1047 | return data; | 1048 | return data; |
1048 | } | 1049 | } |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index b0c490073c8e..728a1e8b9190 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/hwmon.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/hwmon-vid.h> | 27 | #include <linux/hwmon-vid.h> |
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | MODULE_LICENSE("GPL"); | 31 | MODULE_LICENSE("GPL"); |
31 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | 32 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); |
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = { | |||
60 | struct atxp1_data { | 61 | struct atxp1_data { |
61 | struct i2c_client client; | 62 | struct i2c_client client; |
62 | struct class_device *class_dev; | 63 | struct class_device *class_dev; |
63 | struct semaphore update_lock; | 64 | struct mutex update_lock; |
64 | unsigned long last_updated; | 65 | unsigned long last_updated; |
65 | u8 valid; | 66 | u8 valid; |
66 | struct { | 67 | struct { |
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev) | |||
80 | client = to_i2c_client(dev); | 81 | client = to_i2c_client(dev); |
81 | data = i2c_get_clientdata(client); | 82 | data = i2c_get_clientdata(client); |
82 | 83 | ||
83 | down(&data->update_lock); | 84 | mutex_lock(&data->update_lock); |
84 | 85 | ||
85 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 86 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
86 | 87 | ||
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev) | |||
93 | data->valid = 1; | 94 | data->valid = 1; |
94 | } | 95 | } |
95 | 96 | ||
96 | up(&data->update_lock); | 97 | mutex_unlock(&data->update_lock); |
97 | 98 | ||
98 | return(data); | 99 | return(data); |
99 | } | 100 | } |
@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
309 | 310 | ||
310 | data->valid = 0; | 311 | data->valid = 0; |
311 | 312 | ||
312 | init_MUTEX(&data->update_lock); | 313 | mutex_init(&data->update_lock); |
313 | 314 | ||
314 | err = i2c_attach_client(new_client); | 315 | err = i2c_attach_client(new_client); |
315 | 316 | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 203f9c7abb20..478eb4bb8570 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | #include "lm75.h" | 32 | #include "lm75.h" |
32 | 33 | ||
33 | /* Addresses to scan */ | 34 | /* Addresses to scan */ |
@@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") | |||
72 | struct ds1621_data { | 73 | struct ds1621_data { |
73 | struct i2c_client client; | 74 | struct i2c_client client; |
74 | struct class_device *class_dev; | 75 | struct class_device *class_dev; |
75 | struct semaphore update_lock; | 76 | struct mutex update_lock; |
76 | char valid; /* !=0 if following fields are valid */ | 77 | char valid; /* !=0 if following fields are valid */ |
77 | unsigned long last_updated; /* In jiffies */ | 78 | unsigned long last_updated; /* In jiffies */ |
78 | 79 | ||
@@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
156 | struct ds1621_data *data = ds1621_update_client(dev); \ | 157 | struct ds1621_data *data = ds1621_update_client(dev); \ |
157 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ | 158 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ |
158 | \ | 159 | \ |
159 | down(&data->update_lock); \ | 160 | mutex_lock(&data->update_lock); \ |
160 | data->value = val; \ | 161 | data->value = val; \ |
161 | ds1621_write_value(client, reg, data->value); \ | 162 | ds1621_write_value(client, reg, data->value); \ |
162 | up(&data->update_lock); \ | 163 | mutex_unlock(&data->update_lock); \ |
163 | return count; \ | 164 | return count; \ |
164 | } | 165 | } |
165 | 166 | ||
@@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
242 | /* Fill in remaining client fields and put it into the global list */ | 243 | /* Fill in remaining client fields and put it into the global list */ |
243 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); | 244 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); |
244 | data->valid = 0; | 245 | data->valid = 0; |
245 | init_MUTEX(&data->update_lock); | 246 | mutex_init(&data->update_lock); |
246 | 247 | ||
247 | /* Tell the I2C layer a new client has arrived */ | 248 | /* Tell the I2C layer a new client has arrived */ |
248 | if ((err = i2c_attach_client(new_client))) | 249 | if ((err = i2c_attach_client(new_client))) |
@@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
297 | struct ds1621_data *data = i2c_get_clientdata(client); | 298 | struct ds1621_data *data = i2c_get_clientdata(client); |
298 | u8 new_conf; | 299 | u8 new_conf; |
299 | 300 | ||
300 | down(&data->update_lock); | 301 | mutex_lock(&data->update_lock); |
301 | 302 | ||
302 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 303 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
303 | || !data->valid) { | 304 | || !data->valid) { |
@@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
327 | data->valid = 1; | 328 | data->valid = 1; |
328 | } | 329 | } |
329 | 330 | ||
330 | up(&data->update_lock); | 331 | mutex_unlock(&data->update_lock); |
331 | 332 | ||
332 | return data; | 333 | return data; |
333 | } | 334 | } |
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index e029e0a94ecc..885465df6e6a 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/hwmon.h> | 30 | #include <linux/hwmon.h> |
31 | #include <linux/hwmon-sysfs.h> | 31 | #include <linux/hwmon-sysfs.h> |
32 | #include <linux/err.h> | 32 | #include <linux/err.h> |
33 | #include <linux/mutex.h> | ||
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
34 | 35 | ||
35 | static struct platform_device *pdev; | 36 | static struct platform_device *pdev; |
@@ -131,10 +132,10 @@ static struct resource f71805f_resource __initdata = { | |||
131 | struct f71805f_data { | 132 | struct f71805f_data { |
132 | unsigned short addr; | 133 | unsigned short addr; |
133 | const char *name; | 134 | const char *name; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | unsigned long last_limits; /* In jiffies */ | 141 | unsigned long last_limits; /* In jiffies */ |
@@ -224,20 +225,20 @@ static u8 f71805f_read8(struct f71805f_data *data, u8 reg) | |||
224 | { | 225 | { |
225 | u8 val; | 226 | u8 val; |
226 | 227 | ||
227 | down(&data->lock); | 228 | mutex_lock(&data->lock); |
228 | outb(reg, data->addr + ADDR_REG_OFFSET); | 229 | outb(reg, data->addr + ADDR_REG_OFFSET); |
229 | val = inb(data->addr + DATA_REG_OFFSET); | 230 | val = inb(data->addr + DATA_REG_OFFSET); |
230 | up(&data->lock); | 231 | mutex_unlock(&data->lock); |
231 | 232 | ||
232 | return val; | 233 | return val; |
233 | } | 234 | } |
234 | 235 | ||
235 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) | 236 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) |
236 | { | 237 | { |
237 | down(&data->lock); | 238 | mutex_lock(&data->lock); |
238 | outb(reg, data->addr + ADDR_REG_OFFSET); | 239 | outb(reg, data->addr + ADDR_REG_OFFSET); |
239 | outb(val, data->addr + DATA_REG_OFFSET); | 240 | outb(val, data->addr + DATA_REG_OFFSET); |
240 | up(&data->lock); | 241 | mutex_unlock(&data->lock); |
241 | } | 242 | } |
242 | 243 | ||
243 | /* It is important to read the MSB first, because doing so latches the | 244 | /* It is important to read the MSB first, because doing so latches the |
@@ -246,24 +247,24 @@ static u16 f71805f_read16(struct f71805f_data *data, u8 reg) | |||
246 | { | 247 | { |
247 | u16 val; | 248 | u16 val; |
248 | 249 | ||
249 | down(&data->lock); | 250 | mutex_lock(&data->lock); |
250 | outb(reg, data->addr + ADDR_REG_OFFSET); | 251 | outb(reg, data->addr + ADDR_REG_OFFSET); |
251 | val = inb(data->addr + DATA_REG_OFFSET) << 8; | 252 | val = inb(data->addr + DATA_REG_OFFSET) << 8; |
252 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 253 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
253 | val |= inb(data->addr + DATA_REG_OFFSET); | 254 | val |= inb(data->addr + DATA_REG_OFFSET); |
254 | up(&data->lock); | 255 | mutex_unlock(&data->lock); |
255 | 256 | ||
256 | return val; | 257 | return val; |
257 | } | 258 | } |
258 | 259 | ||
259 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) | 260 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) |
260 | { | 261 | { |
261 | down(&data->lock); | 262 | mutex_lock(&data->lock); |
262 | outb(reg, data->addr + ADDR_REG_OFFSET); | 263 | outb(reg, data->addr + ADDR_REG_OFFSET); |
263 | outb(val >> 8, data->addr + DATA_REG_OFFSET); | 264 | outb(val >> 8, data->addr + DATA_REG_OFFSET); |
264 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 265 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
265 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); | 266 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); |
266 | up(&data->lock); | 267 | mutex_unlock(&data->lock); |
267 | } | 268 | } |
268 | 269 | ||
269 | static struct f71805f_data *f71805f_update_device(struct device *dev) | 270 | static struct f71805f_data *f71805f_update_device(struct device *dev) |
@@ -271,7 +272,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
271 | struct f71805f_data *data = dev_get_drvdata(dev); | 272 | struct f71805f_data *data = dev_get_drvdata(dev); |
272 | int nr; | 273 | int nr; |
273 | 274 | ||
274 | down(&data->update_lock); | 275 | mutex_lock(&data->update_lock); |
275 | 276 | ||
276 | /* Limit registers cache is refreshed after 60 seconds */ | 277 | /* Limit registers cache is refreshed after 60 seconds */ |
277 | if (time_after(jiffies, data->last_updated + 60 * HZ) | 278 | if (time_after(jiffies, data->last_updated + 60 * HZ) |
@@ -323,7 +324,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
323 | data->valid = 1; | 324 | data->valid = 1; |
324 | } | 325 | } |
325 | 326 | ||
326 | up(&data->update_lock); | 327 | mutex_unlock(&data->update_lock); |
327 | 328 | ||
328 | return data; | 329 | return data; |
329 | } | 330 | } |
@@ -362,10 +363,10 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute | |||
362 | struct f71805f_data *data = dev_get_drvdata(dev); | 363 | struct f71805f_data *data = dev_get_drvdata(dev); |
363 | long val = simple_strtol(buf, NULL, 10); | 364 | long val = simple_strtol(buf, NULL, 10); |
364 | 365 | ||
365 | down(&data->update_lock); | 366 | mutex_lock(&data->update_lock); |
366 | data->in_high[0] = in0_to_reg(val); | 367 | data->in_high[0] = in0_to_reg(val); |
367 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); | 368 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); |
368 | up(&data->update_lock); | 369 | mutex_unlock(&data->update_lock); |
369 | 370 | ||
370 | return count; | 371 | return count; |
371 | } | 372 | } |
@@ -376,18 +377,14 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute | |||
376 | struct f71805f_data *data = dev_get_drvdata(dev); | 377 | struct f71805f_data *data = dev_get_drvdata(dev); |
377 | long val = simple_strtol(buf, NULL, 10); | 378 | long val = simple_strtol(buf, NULL, 10); |
378 | 379 | ||
379 | down(&data->update_lock); | 380 | mutex_lock(&data->update_lock); |
380 | data->in_low[0] = in0_to_reg(val); | 381 | data->in_low[0] = in0_to_reg(val); |
381 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); | 382 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); |
382 | up(&data->update_lock); | 383 | mutex_unlock(&data->update_lock); |
383 | 384 | ||
384 | return count; | 385 | return count; |
385 | } | 386 | } |
386 | 387 | ||
387 | static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); | ||
388 | static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); | ||
389 | static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); | ||
390 | |||
391 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, | 388 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
392 | char *buf) | 389 | char *buf) |
393 | { | 390 | { |
@@ -426,10 +423,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute | |||
426 | int nr = attr->index; | 423 | int nr = attr->index; |
427 | long val = simple_strtol(buf, NULL, 10); | 424 | long val = simple_strtol(buf, NULL, 10); |
428 | 425 | ||
429 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
430 | data->in_high[nr] = in_to_reg(val); | 427 | data->in_high[nr] = in_to_reg(val); |
431 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); | 428 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
432 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
433 | 430 | ||
434 | return count; | 431 | return count; |
435 | } | 432 | } |
@@ -442,31 +439,14 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute | |||
442 | int nr = attr->index; | 439 | int nr = attr->index; |
443 | long val = simple_strtol(buf, NULL, 10); | 440 | long val = simple_strtol(buf, NULL, 10); |
444 | 441 | ||
445 | down(&data->update_lock); | 442 | mutex_lock(&data->update_lock); |
446 | data->in_low[nr] = in_to_reg(val); | 443 | data->in_low[nr] = in_to_reg(val); |
447 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); | 444 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
448 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
449 | 446 | ||
450 | return count; | 447 | return count; |
451 | } | 448 | } |
452 | 449 | ||
453 | #define sysfs_in(offset) \ | ||
454 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | ||
455 | show_in, NULL, offset); \ | ||
456 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
457 | show_in_max, set_in_max, offset); \ | ||
458 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
459 | show_in_min, set_in_min, offset) | ||
460 | |||
461 | sysfs_in(1); | ||
462 | sysfs_in(2); | ||
463 | sysfs_in(3); | ||
464 | sysfs_in(4); | ||
465 | sysfs_in(5); | ||
466 | sysfs_in(6); | ||
467 | sysfs_in(7); | ||
468 | sysfs_in(8); | ||
469 | |||
470 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | 450 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
471 | char *buf) | 451 | char *buf) |
472 | { | 452 | { |
@@ -495,24 +475,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute | |||
495 | int nr = attr->index; | 475 | int nr = attr->index; |
496 | long val = simple_strtol(buf, NULL, 10); | 476 | long val = simple_strtol(buf, NULL, 10); |
497 | 477 | ||
498 | down(&data->update_lock); | 478 | mutex_lock(&data->update_lock); |
499 | data->fan_low[nr] = fan_to_reg(val); | 479 | data->fan_low[nr] = fan_to_reg(val); |
500 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); | 480 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); |
501 | up(&data->update_lock); | 481 | mutex_unlock(&data->update_lock); |
502 | 482 | ||
503 | return count; | 483 | return count; |
504 | } | 484 | } |
505 | 485 | ||
506 | #define sysfs_fan(offset) \ | ||
507 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
508 | show_fan, NULL, offset - 1); \ | ||
509 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
510 | show_fan_min, set_fan_min, offset - 1) | ||
511 | |||
512 | sysfs_fan(1); | ||
513 | sysfs_fan(2); | ||
514 | sysfs_fan(3); | ||
515 | |||
516 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | 486 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
517 | char *buf) | 487 | char *buf) |
518 | { | 488 | { |
@@ -562,10 +532,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute | |||
562 | int nr = attr->index; | 532 | int nr = attr->index; |
563 | long val = simple_strtol(buf, NULL, 10); | 533 | long val = simple_strtol(buf, NULL, 10); |
564 | 534 | ||
565 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
566 | data->temp_high[nr] = temp_to_reg(val); | 536 | data->temp_high[nr] = temp_to_reg(val); |
567 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 537 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
568 | up(&data->update_lock); | 538 | mutex_unlock(&data->update_lock); |
569 | 539 | ||
570 | return count; | 540 | return count; |
571 | } | 541 | } |
@@ -578,28 +548,14 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute | |||
578 | int nr = attr->index; | 548 | int nr = attr->index; |
579 | long val = simple_strtol(buf, NULL, 10); | 549 | long val = simple_strtol(buf, NULL, 10); |
580 | 550 | ||
581 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
582 | data->temp_hyst[nr] = temp_to_reg(val); | 552 | data->temp_hyst[nr] = temp_to_reg(val); |
583 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 553 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); |
584 | up(&data->update_lock); | 554 | mutex_unlock(&data->update_lock); |
585 | 555 | ||
586 | return count; | 556 | return count; |
587 | } | 557 | } |
588 | 558 | ||
589 | #define sysfs_temp(offset) \ | ||
590 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
591 | show_temp, NULL, offset - 1); \ | ||
592 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
593 | show_temp_max, set_temp_max, offset - 1); \ | ||
594 | static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
595 | show_temp_hyst, set_temp_hyst, offset - 1); \ | ||
596 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \ | ||
597 | show_temp_type, NULL, offset - 1) | ||
598 | |||
599 | sysfs_temp(1); | ||
600 | sysfs_temp(2); | ||
601 | sysfs_temp(3); | ||
602 | |||
603 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute | 559 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute |
604 | *devattr, char *buf) | 560 | *devattr, char *buf) |
605 | { | 561 | { |
@@ -625,10 +581,6 @@ static ssize_t show_alarms_temp(struct device *dev, struct device_attribute | |||
625 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); | 581 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); |
626 | } | 582 | } |
627 | 583 | ||
628 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); | ||
629 | static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); | ||
630 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); | ||
631 | |||
632 | static ssize_t show_name(struct device *dev, struct device_attribute | 584 | static ssize_t show_name(struct device *dev, struct device_attribute |
633 | *devattr, char *buf) | 585 | *devattr, char *buf) |
634 | { | 586 | { |
@@ -637,7 +589,89 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
637 | return sprintf(buf, "%s\n", data->name); | 589 | return sprintf(buf, "%s\n", data->name); |
638 | } | 590 | } |
639 | 591 | ||
640 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 592 | static struct device_attribute f71805f_dev_attr[] = { |
593 | __ATTR(in0_input, S_IRUGO, show_in0, NULL), | ||
594 | __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max), | ||
595 | __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min), | ||
596 | __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), | ||
597 | __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL), | ||
598 | __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL), | ||
599 | __ATTR(name, S_IRUGO, show_name, NULL), | ||
600 | }; | ||
601 | |||
602 | static struct sensor_device_attribute f71805f_sensor_attr[] = { | ||
603 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | ||
604 | SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR, | ||
605 | show_in_max, set_in_max, 1), | ||
606 | SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR, | ||
607 | show_in_min, set_in_min, 1), | ||
608 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
609 | SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR, | ||
610 | show_in_max, set_in_max, 2), | ||
611 | SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR, | ||
612 | show_in_min, set_in_min, 2), | ||
613 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
614 | SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR, | ||
615 | show_in_max, set_in_max, 3), | ||
616 | SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR, | ||
617 | show_in_min, set_in_min, 3), | ||
618 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
619 | SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR, | ||
620 | show_in_max, set_in_max, 4), | ||
621 | SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR, | ||
622 | show_in_min, set_in_min, 4), | ||
623 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
624 | SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR, | ||
625 | show_in_max, set_in_max, 5), | ||
626 | SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR, | ||
627 | show_in_min, set_in_min, 5), | ||
628 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
629 | SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR, | ||
630 | show_in_max, set_in_max, 6), | ||
631 | SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR, | ||
632 | show_in_min, set_in_min, 6), | ||
633 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
634 | SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR, | ||
635 | show_in_max, set_in_max, 7), | ||
636 | SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR, | ||
637 | show_in_min, set_in_min, 7), | ||
638 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), | ||
639 | SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR, | ||
640 | show_in_max, set_in_max, 8), | ||
641 | SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR, | ||
642 | show_in_min, set_in_min, 8), | ||
643 | |||
644 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), | ||
645 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
646 | show_temp_max, set_temp_max, 0), | ||
647 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
648 | show_temp_hyst, set_temp_hyst, 0), | ||
649 | SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), | ||
650 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), | ||
651 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
652 | show_temp_max, set_temp_max, 1), | ||
653 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
654 | show_temp_hyst, set_temp_hyst, 1), | ||
655 | SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), | ||
656 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), | ||
657 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
658 | show_temp_max, set_temp_max, 2), | ||
659 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
660 | show_temp_hyst, set_temp_hyst, 2), | ||
661 | SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), | ||
662 | }; | ||
663 | |||
664 | static struct sensor_device_attribute f71805f_fan_attr[] = { | ||
665 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), | ||
666 | SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR, | ||
667 | show_fan_min, set_fan_min, 0), | ||
668 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), | ||
669 | SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR, | ||
670 | show_fan_min, set_fan_min, 1), | ||
671 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), | ||
672 | SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR, | ||
673 | show_fan_min, set_fan_min, 2), | ||
674 | }; | ||
641 | 675 | ||
642 | /* | 676 | /* |
643 | * Device registration and initialization | 677 | * Device registration and initialization |
@@ -668,7 +702,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
668 | { | 702 | { |
669 | struct f71805f_data *data; | 703 | struct f71805f_data *data; |
670 | struct resource *res; | 704 | struct resource *res; |
671 | int err; | 705 | int i, err; |
672 | 706 | ||
673 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { | 707 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { |
674 | err = -ENOMEM; | 708 | err = -ENOMEM; |
@@ -678,9 +712,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
678 | 712 | ||
679 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 713 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
680 | data->addr = res->start; | 714 | data->addr = res->start; |
681 | init_MUTEX(&data->lock); | 715 | mutex_init(&data->lock); |
682 | data->name = "f71805f"; | 716 | data->name = "f71805f"; |
683 | init_MUTEX(&data->update_lock); | 717 | mutex_init(&data->update_lock); |
684 | 718 | ||
685 | platform_set_drvdata(pdev, data); | 719 | platform_set_drvdata(pdev, data); |
686 | 720 | ||
@@ -695,76 +729,31 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
695 | f71805f_init_device(data); | 729 | f71805f_init_device(data); |
696 | 730 | ||
697 | /* Register sysfs interface files */ | 731 | /* Register sysfs interface files */ |
698 | device_create_file(&pdev->dev, &dev_attr_in0_input); | 732 | for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) { |
699 | device_create_file(&pdev->dev, &dev_attr_in0_max); | 733 | err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]); |
700 | device_create_file(&pdev->dev, &dev_attr_in0_min); | 734 | if (err) |
701 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr); | 735 | goto exit_class; |
702 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr); | ||
703 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr); | ||
704 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr); | ||
705 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr); | ||
706 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr); | ||
707 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr); | ||
708 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr); | ||
709 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
710 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
711 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
712 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
713 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
714 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
715 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
716 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
717 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
718 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
719 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
720 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
721 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
722 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
723 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
724 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
725 | if (data->fan_enabled & (1 << 0)) { | ||
726 | device_create_file(&pdev->dev, | ||
727 | &sensor_dev_attr_fan1_input.dev_attr); | ||
728 | device_create_file(&pdev->dev, | ||
729 | &sensor_dev_attr_fan1_min.dev_attr); | ||
730 | } | 736 | } |
731 | if (data->fan_enabled & (1 << 1)) { | 737 | for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) { |
732 | device_create_file(&pdev->dev, | 738 | err = device_create_file(&pdev->dev, |
733 | &sensor_dev_attr_fan2_input.dev_attr); | 739 | &f71805f_sensor_attr[i].dev_attr); |
734 | device_create_file(&pdev->dev, | 740 | if (err) |
735 | &sensor_dev_attr_fan2_min.dev_attr); | 741 | goto exit_class; |
736 | } | 742 | } |
737 | if (data->fan_enabled & (1 << 2)) { | 743 | for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) { |
738 | device_create_file(&pdev->dev, | 744 | if (!(data->fan_enabled & (1 << (i / 2)))) |
739 | &sensor_dev_attr_fan3_input.dev_attr); | 745 | continue; |
740 | device_create_file(&pdev->dev, | 746 | err = device_create_file(&pdev->dev, |
741 | &sensor_dev_attr_fan3_min.dev_attr); | 747 | &f71805f_fan_attr[i].dev_attr); |
748 | if (err) | ||
749 | goto exit_class; | ||
742 | } | 750 | } |
743 | device_create_file(&pdev->dev, | ||
744 | &sensor_dev_attr_temp1_input.dev_attr); | ||
745 | device_create_file(&pdev->dev, | ||
746 | &sensor_dev_attr_temp2_input.dev_attr); | ||
747 | device_create_file(&pdev->dev, | ||
748 | &sensor_dev_attr_temp3_input.dev_attr); | ||
749 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); | ||
750 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr); | ||
751 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
752 | device_create_file(&pdev->dev, | ||
753 | &sensor_dev_attr_temp1_max_hyst.dev_attr); | ||
754 | device_create_file(&pdev->dev, | ||
755 | &sensor_dev_attr_temp2_max_hyst.dev_attr); | ||
756 | device_create_file(&pdev->dev, | ||
757 | &sensor_dev_attr_temp3_max_hyst.dev_attr); | ||
758 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr); | ||
759 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr); | ||
760 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr); | ||
761 | device_create_file(&pdev->dev, &dev_attr_alarms_in); | ||
762 | device_create_file(&pdev->dev, &dev_attr_alarms_fan); | ||
763 | device_create_file(&pdev->dev, &dev_attr_alarms_temp); | ||
764 | device_create_file(&pdev->dev, &dev_attr_name); | ||
765 | 751 | ||
766 | return 0; | 752 | return 0; |
767 | 753 | ||
754 | exit_class: | ||
755 | dev_err(&pdev->dev, "Sysfs interface creation failed\n"); | ||
756 | hwmon_device_unregister(data->class_dev); | ||
768 | exit_free: | 757 | exit_free: |
769 | kfree(data); | 758 | kfree(data); |
770 | exit: | 759 | exit: |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 25409181d1eb..6bc76b407636 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * Addresses to scan | 39 | * Addresses to scan |
@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = { | |||
133 | struct fscher_data { | 134 | struct fscher_data { |
134 | struct i2c_client client; | 135 | struct i2c_client client; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | struct semaphore update_lock; | 137 | struct mutex update_lock; |
137 | char valid; /* zero until following fields are valid */ | 138 | char valid; /* zero until following fields are valid */ |
138 | unsigned long last_updated; /* in jiffies */ | 139 | unsigned long last_updated; /* in jiffies */ |
139 | 140 | ||
@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
332 | * global list */ | 333 | * global list */ |
333 | strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); | 334 | strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); |
334 | data->valid = 0; | 335 | data->valid = 0; |
335 | init_MUTEX(&data->update_lock); | 336 | mutex_init(&data->update_lock); |
336 | 337 | ||
337 | /* Tell the I2C layer a new client has arrived */ | 338 | /* Tell the I2C layer a new client has arrived */ |
338 | if ((err = i2c_attach_client(new_client))) | 339 | if ((err = i2c_attach_client(new_client))) |
@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev) | |||
417 | struct i2c_client *client = to_i2c_client(dev); | 418 | struct i2c_client *client = to_i2c_client(dev); |
418 | struct fscher_data *data = i2c_get_clientdata(client); | 419 | struct fscher_data *data = i2c_get_clientdata(client); |
419 | 420 | ||
420 | down(&data->update_lock); | 421 | mutex_lock(&data->update_lock); |
421 | 422 | ||
422 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 423 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
423 | 424 | ||
@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev) | |||
457 | data->valid = 1; | 458 | data->valid = 1; |
458 | } | 459 | } |
459 | 460 | ||
460 | up(&data->update_lock); | 461 | mutex_unlock(&data->update_lock); |
461 | 462 | ||
462 | return data; | 463 | return data; |
463 | } | 464 | } |
@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat | |||
472 | /* bits 0..1, 3..7 reserved => mask with 0x04 */ | 473 | /* bits 0..1, 3..7 reserved => mask with 0x04 */ |
473 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; | 474 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; |
474 | 475 | ||
475 | down(&data->update_lock); | 476 | mutex_lock(&data->update_lock); |
476 | data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; | 477 | data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; |
477 | fscher_write_value(client, reg, v); | 478 | fscher_write_value(client, reg, v); |
478 | up(&data->update_lock); | 479 | mutex_unlock(&data->update_lock); |
479 | return count; | 480 | return count; |
480 | } | 481 | } |
481 | 482 | ||
@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data, | |||
490 | { | 491 | { |
491 | unsigned long v = simple_strtoul(buf, NULL, 10); | 492 | unsigned long v = simple_strtoul(buf, NULL, 10); |
492 | 493 | ||
493 | down(&data->update_lock); | 494 | mutex_lock(&data->update_lock); |
494 | data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; | 495 | data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; |
495 | fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); | 496 | fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); |
496 | up(&data->update_lock); | 497 | mutex_unlock(&data->update_lock); |
497 | return count; | 498 | return count; |
498 | } | 499 | } |
499 | 500 | ||
@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data, | |||
518 | return -EINVAL; | 519 | return -EINVAL; |
519 | } | 520 | } |
520 | 521 | ||
521 | down(&data->update_lock); | 522 | mutex_lock(&data->update_lock); |
522 | 523 | ||
523 | /* bits 2..7 reserved => mask with 0x03 */ | 524 | /* bits 2..7 reserved => mask with 0x03 */ |
524 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; | 525 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; |
525 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; | 526 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; |
526 | 527 | ||
527 | fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); | 528 | fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); |
528 | up(&data->update_lock); | 529 | mutex_unlock(&data->update_lock); |
529 | return count; | 530 | return count; |
530 | } | 531 | } |
531 | 532 | ||
@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da | |||
552 | /* bits 2..7 reserved, 0 read only => mask with 0x02 */ | 553 | /* bits 2..7 reserved, 0 read only => mask with 0x02 */ |
553 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; | 554 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; |
554 | 555 | ||
555 | down(&data->update_lock); | 556 | mutex_lock(&data->update_lock); |
556 | data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; | 557 | data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; |
557 | fscher_write_value(client, reg, v); | 558 | fscher_write_value(client, reg, v); |
558 | up(&data->update_lock); | 559 | mutex_unlock(&data->update_lock); |
559 | return count; | 560 | return count; |
560 | } | 561 | } |
561 | 562 | ||
@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data, | |||
609 | /* bits 1..7 reserved => mask with 0x01 */ | 610 | /* bits 1..7 reserved => mask with 0x01 */ |
610 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; | 611 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; |
611 | 612 | ||
612 | down(&data->update_lock); | 613 | mutex_lock(&data->update_lock); |
613 | data->global_control &= ~v; | 614 | data->global_control &= ~v; |
614 | fscher_write_value(client, reg, v); | 615 | fscher_write_value(client, reg, v); |
615 | up(&data->update_lock); | 616 | mutex_unlock(&data->update_lock); |
616 | return count; | 617 | return count; |
617 | } | 618 | } |
618 | 619 | ||
@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct | |||
631 | /* bits 0..3 reserved => mask with 0xf0 */ | 632 | /* bits 0..3 reserved => mask with 0xf0 */ |
632 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; | 633 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; |
633 | 634 | ||
634 | down(&data->update_lock); | 635 | mutex_lock(&data->update_lock); |
635 | data->watchdog[2] &= ~0xf0; | 636 | data->watchdog[2] &= ~0xf0; |
636 | data->watchdog[2] |= v; | 637 | data->watchdog[2] |= v; |
637 | fscher_write_value(client, reg, data->watchdog[2]); | 638 | fscher_write_value(client, reg, data->watchdog[2]); |
638 | up(&data->update_lock); | 639 | mutex_unlock(&data->update_lock); |
639 | return count; | 640 | return count; |
640 | } | 641 | } |
641 | 642 | ||
@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data | |||
651 | /* bits 0, 2..7 reserved => mask with 0x02 */ | 652 | /* bits 0, 2..7 reserved => mask with 0x02 */ |
652 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; | 653 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; |
653 | 654 | ||
654 | down(&data->update_lock); | 655 | mutex_lock(&data->update_lock); |
655 | data->watchdog[1] &= ~v; | 656 | data->watchdog[1] &= ~v; |
656 | fscher_write_value(client, reg, v); | 657 | fscher_write_value(client, reg, v); |
657 | up(&data->update_lock); | 658 | mutex_unlock(&data->update_lock); |
658 | return count; | 659 | return count; |
659 | } | 660 | } |
660 | 661 | ||
@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data | |||
669 | { | 670 | { |
670 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; | 671 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; |
671 | 672 | ||
672 | down(&data->update_lock); | 673 | mutex_lock(&data->update_lock); |
673 | data->watchdog[0] = v; | 674 | data->watchdog[0] = v; |
674 | fscher_write_value(client, reg, data->watchdog[0]); | 675 | fscher_write_value(client, reg, data->watchdog[0]); |
675 | up(&data->update_lock); | 676 | mutex_unlock(&data->update_lock); |
676 | return count; | 677 | return count; |
677 | } | 678 | } |
678 | 679 | ||
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 6d0146b57020..6dc4846b9eeb 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/hwmon.h> | 38 | #include <linux/hwmon.h> |
39 | #include <linux/err.h> | 39 | #include <linux/err.h> |
40 | #include <linux/mutex.h> | ||
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Addresses to scan | 43 | * Addresses to scan |
@@ -89,8 +90,8 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter); | |||
89 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); | 90 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); |
90 | static int fscpos_detach_client(struct i2c_client *client); | 91 | static int fscpos_detach_client(struct i2c_client *client); |
91 | 92 | ||
92 | static int fscpos_read_value(struct i2c_client *client, u8 register); | 93 | static int fscpos_read_value(struct i2c_client *client, u8 reg); |
93 | static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value); | 94 | static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value); |
94 | static struct fscpos_data *fscpos_update_device(struct device *dev); | 95 | static struct fscpos_data *fscpos_update_device(struct device *dev); |
95 | static void fscpos_init_client(struct i2c_client *client); | 96 | static void fscpos_init_client(struct i2c_client *client); |
96 | 97 | ||
@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = { | |||
114 | struct fscpos_data { | 115 | struct fscpos_data { |
115 | struct i2c_client client; | 116 | struct i2c_client client; |
116 | struct class_device *class_dev; | 117 | struct class_device *class_dev; |
117 | struct semaphore update_lock; | 118 | struct mutex update_lock; |
118 | char valid; /* 0 until following fields are valid */ | 119 | char valid; /* 0 until following fields are valid */ |
119 | unsigned long last_updated; /* In jiffies */ | 120 | unsigned long last_updated; /* In jiffies */ |
120 | 121 | ||
@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data | |||
208 | return -EINVAL; | 209 | return -EINVAL; |
209 | } | 210 | } |
210 | 211 | ||
211 | down(&data->update_lock); | 212 | mutex_lock(&data->update_lock); |
212 | /* bits 2..7 reserved => mask with 0x03 */ | 213 | /* bits 2..7 reserved => mask with 0x03 */ |
213 | data->fan_ripple[nr - 1] &= ~0x03; | 214 | data->fan_ripple[nr - 1] &= ~0x03; |
214 | data->fan_ripple[nr - 1] |= v; | 215 | data->fan_ripple[nr - 1] |= v; |
215 | 216 | ||
216 | fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); | 217 | fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); |
217 | up(&data->update_lock); | 218 | mutex_unlock(&data->update_lock); |
218 | return count; | 219 | return count; |
219 | } | 220 | } |
220 | 221 | ||
@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data, | |||
232 | if (v < 0) v = 0; | 233 | if (v < 0) v = 0; |
233 | if (v > 255) v = 255; | 234 | if (v > 255) v = 255; |
234 | 235 | ||
235 | down(&data->update_lock); | 236 | mutex_lock(&data->update_lock); |
236 | data->pwm[nr - 1] = v; | 237 | data->pwm[nr - 1] = v; |
237 | fscpos_write_value(client, reg, data->pwm[nr - 1]); | 238 | fscpos_write_value(client, reg, data->pwm[nr - 1]); |
238 | up(&data->update_lock); | 239 | mutex_unlock(&data->update_lock); |
239 | return count; | 240 | return count; |
240 | } | 241 | } |
241 | 242 | ||
@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data | |||
278 | /* bits 0..3 reserved => mask with 0xf0 */ | 279 | /* bits 0..3 reserved => mask with 0xf0 */ |
279 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; | 280 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; |
280 | 281 | ||
281 | down(&data->update_lock); | 282 | mutex_lock(&data->update_lock); |
282 | data->wdog_control &= ~0xf0; | 283 | data->wdog_control &= ~0xf0; |
283 | data->wdog_control |= v; | 284 | data->wdog_control |= v; |
284 | fscpos_write_value(client, reg, data->wdog_control); | 285 | fscpos_write_value(client, reg, data->wdog_control); |
285 | up(&data->update_lock); | 286 | mutex_unlock(&data->update_lock); |
286 | return count; | 287 | return count; |
287 | } | 288 | } |
288 | 289 | ||
@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data | |||
304 | return -EINVAL; | 305 | return -EINVAL; |
305 | } | 306 | } |
306 | 307 | ||
307 | down(&data->update_lock); | 308 | mutex_lock(&data->update_lock); |
308 | data->wdog_state &= ~v; | 309 | data->wdog_state &= ~v; |
309 | fscpos_write_value(client, reg, v); | 310 | fscpos_write_value(client, reg, v); |
310 | up(&data->update_lock); | 311 | mutex_unlock(&data->update_lock); |
311 | return count; | 312 | return count; |
312 | } | 313 | } |
313 | 314 | ||
@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data | |||
321 | { | 322 | { |
322 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; | 323 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; |
323 | 324 | ||
324 | down(&data->update_lock); | 325 | mutex_lock(&data->update_lock); |
325 | data->wdog_preset = v; | 326 | data->wdog_preset = v; |
326 | fscpos_write_value(client, reg, data->wdog_preset); | 327 | fscpos_write_value(client, reg, data->wdog_preset); |
327 | up(&data->update_lock); | 328 | mutex_unlock(&data->update_lock); |
328 | return count; | 329 | return count; |
329 | } | 330 | } |
330 | 331 | ||
@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
483 | strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); | 484 | strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); |
484 | 485 | ||
485 | data->valid = 0; | 486 | data->valid = 0; |
486 | init_MUTEX(&data->update_lock); | 487 | mutex_init(&data->update_lock); |
487 | 488 | ||
488 | /* Tell the I2C layer a new client has arrived */ | 489 | /* Tell the I2C layer a new client has arrived */ |
489 | if ((err = i2c_attach_client(new_client))) | 490 | if ((err = i2c_attach_client(new_client))) |
@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) | |||
579 | struct i2c_client *client = to_i2c_client(dev); | 580 | struct i2c_client *client = to_i2c_client(dev); |
580 | struct fscpos_data *data = i2c_get_clientdata(client); | 581 | struct fscpos_data *data = i2c_get_clientdata(client); |
581 | 582 | ||
582 | down(&data->update_lock); | 583 | mutex_lock(&data->update_lock); |
583 | 584 | ||
584 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 585 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
585 | int i; | 586 | int i; |
@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) | |||
625 | data->last_updated = jiffies; | 626 | data->last_updated = jiffies; |
626 | data->valid = 1; | 627 | data->valid = 1; |
627 | } | 628 | } |
628 | up(&data->update_lock); | 629 | mutex_unlock(&data->update_lock); |
629 | return data; | 630 | return data; |
630 | } | 631 | } |
631 | 632 | ||
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 9e685e3a3bc9..6606aabdb49d 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/i2c.h> | 43 | #include <linux/i2c.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
@@ -120,7 +121,7 @@ struct gl518_data { | |||
120 | struct class_device *class_dev; | 121 | struct class_device *class_dev; |
121 | enum chips type; | 122 | enum chips type; |
122 | 123 | ||
123 | struct semaphore update_lock; | 124 | struct mutex update_lock; |
124 | char valid; /* !=0 if following fields are valid */ | 125 | char valid; /* !=0 if following fields are valid */ |
125 | unsigned long last_updated; /* In jiffies */ | 126 | unsigned long last_updated; /* In jiffies */ |
126 | 127 | ||
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c | |||
212 | struct gl518_data *data = i2c_get_clientdata(client); \ | 213 | struct gl518_data *data = i2c_get_clientdata(client); \ |
213 | long val = simple_strtol(buf, NULL, 10); \ | 214 | long val = simple_strtol(buf, NULL, 10); \ |
214 | \ | 215 | \ |
215 | down(&data->update_lock); \ | 216 | mutex_lock(&data->update_lock); \ |
216 | data->value = type##_TO_REG(val); \ | 217 | data->value = type##_TO_REG(val); \ |
217 | gl518_write_value(client, reg, data->value); \ | 218 | gl518_write_value(client, reg, data->value); \ |
218 | up(&data->update_lock); \ | 219 | mutex_unlock(&data->update_lock); \ |
219 | return count; \ | 220 | return count; \ |
220 | } | 221 | } |
221 | 222 | ||
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c | |||
228 | int regvalue; \ | 229 | int regvalue; \ |
229 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 230 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
230 | \ | 231 | \ |
231 | down(&data->update_lock); \ | 232 | mutex_lock(&data->update_lock); \ |
232 | regvalue = gl518_read_value(client, reg); \ | 233 | regvalue = gl518_read_value(client, reg); \ |
233 | data->value = type##_TO_REG(val); \ | 234 | data->value = type##_TO_REG(val); \ |
234 | regvalue = (regvalue & ~mask) | (data->value << shift); \ | 235 | regvalue = (regvalue & ~mask) | (data->value << shift); \ |
235 | gl518_write_value(client, reg, regvalue); \ | 236 | gl518_write_value(client, reg, regvalue); \ |
236 | up(&data->update_lock); \ | 237 | mutex_unlock(&data->update_lock); \ |
237 | return count; \ | 238 | return count; \ |
238 | } | 239 | } |
239 | 240 | ||
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c | |||
265 | int regvalue; | 266 | int regvalue; |
266 | unsigned long val = simple_strtoul(buf, NULL, 10); | 267 | unsigned long val = simple_strtoul(buf, NULL, 10); |
267 | 268 | ||
268 | down(&data->update_lock); | 269 | mutex_lock(&data->update_lock); |
269 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); | 270 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); |
270 | data->fan_min[0] = FAN_TO_REG(val, | 271 | data->fan_min[0] = FAN_TO_REG(val, |
271 | DIV_FROM_REG(data->fan_div[0])); | 272 | DIV_FROM_REG(data->fan_div[0])); |
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c | |||
280 | data->beep_mask &= data->alarm_mask; | 281 | data->beep_mask &= data->alarm_mask; |
281 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); | 282 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); |
282 | 283 | ||
283 | up(&data->update_lock); | 284 | mutex_unlock(&data->update_lock); |
284 | return count; | 285 | return count; |
285 | } | 286 | } |
286 | 287 | ||
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c | |||
291 | int regvalue; | 292 | int regvalue; |
292 | unsigned long val = simple_strtoul(buf, NULL, 10); | 293 | unsigned long val = simple_strtoul(buf, NULL, 10); |
293 | 294 | ||
294 | down(&data->update_lock); | 295 | mutex_lock(&data->update_lock); |
295 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); | 296 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); |
296 | data->fan_min[1] = FAN_TO_REG(val, | 297 | data->fan_min[1] = FAN_TO_REG(val, |
297 | DIV_FROM_REG(data->fan_div[1])); | 298 | DIV_FROM_REG(data->fan_div[1])); |
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c | |||
306 | data->beep_mask &= data->alarm_mask; | 307 | data->beep_mask &= data->alarm_mask; |
307 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); | 308 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); |
308 | 309 | ||
309 | up(&data->update_lock); | 310 | mutex_unlock(&data->update_lock); |
310 | return count; | 311 | return count; |
311 | } | 312 | } |
312 | 313 | ||
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
407 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); | 408 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); |
408 | data->type = kind; | 409 | data->type = kind; |
409 | data->valid = 0; | 410 | data->valid = 0; |
410 | init_MUTEX(&data->update_lock); | 411 | mutex_init(&data->update_lock); |
411 | 412 | ||
412 | /* Tell the I2C layer a new client has arrived */ | 413 | /* Tell the I2C layer a new client has arrived */ |
413 | if ((err = i2c_attach_client(new_client))) | 414 | if ((err = i2c_attach_client(new_client))) |
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev) | |||
525 | struct gl518_data *data = i2c_get_clientdata(client); | 526 | struct gl518_data *data = i2c_get_clientdata(client); |
526 | int val; | 527 | int val; |
527 | 528 | ||
528 | down(&data->update_lock); | 529 | mutex_lock(&data->update_lock); |
529 | 530 | ||
530 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 531 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
531 | || !data->valid) { | 532 | || !data->valid) { |
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev) | |||
586 | data->valid = 1; | 587 | data->valid = 1; |
587 | } | 588 | } |
588 | 589 | ||
589 | up(&data->update_lock); | 590 | mutex_unlock(&data->update_lock); |
590 | 591 | ||
591 | return data; | 592 | return data; |
592 | } | 593 | } |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index baee60e44b52..47b4d49f75c6 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/hwmon-vid.h> | 30 | #include <linux/hwmon-vid.h> |
31 | #include <linux/err.h> | 31 | #include <linux/err.h> |
32 | #include <linux/mutex.h> | ||
32 | 33 | ||
33 | /* Type of the extra sensor */ | 34 | /* Type of the extra sensor */ |
34 | static unsigned short extra_sensor_type; | 35 | static unsigned short extra_sensor_type; |
@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = { | |||
121 | struct gl520_data { | 122 | struct gl520_data { |
122 | struct i2c_client client; | 123 | struct i2c_client client; |
123 | struct class_device *class_dev; | 124 | struct class_device *class_dev; |
124 | struct semaphore update_lock; | 125 | struct mutex update_lock; |
125 | char valid; /* zero until the following fields are valid */ | 126 | char valid; /* zero until the following fields are valid */ |
126 | unsigned long last_updated; /* in jiffies */ | 127 | unsigned long last_updated; /* in jiffies */ |
127 | 128 | ||
@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co | |||
303 | long v = simple_strtol(buf, NULL, 10); | 304 | long v = simple_strtol(buf, NULL, 10); |
304 | u8 r; | 305 | u8 r; |
305 | 306 | ||
306 | down(&data->update_lock); | 307 | mutex_lock(&data->update_lock); |
307 | 308 | ||
308 | if (n == 0) | 309 | if (n == 0) |
309 | r = VDD_TO_REG(v); | 310 | r = VDD_TO_REG(v); |
@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co | |||
317 | else | 318 | else |
318 | gl520_write_value(client, reg, r); | 319 | gl520_write_value(client, reg, r); |
319 | 320 | ||
320 | up(&data->update_lock); | 321 | mutex_unlock(&data->update_lock); |
321 | return count; | 322 | return count; |
322 | } | 323 | } |
323 | 324 | ||
@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co | |||
331 | else | 332 | else |
332 | r = IN_TO_REG(v); | 333 | r = IN_TO_REG(v); |
333 | 334 | ||
334 | down(&data->update_lock); | 335 | mutex_lock(&data->update_lock); |
335 | 336 | ||
336 | data->in_max[n] = r; | 337 | data->in_max[n] = r; |
337 | 338 | ||
@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co | |||
340 | else | 341 | else |
341 | gl520_write_value(client, reg, r); | 342 | gl520_write_value(client, reg, r); |
342 | 343 | ||
343 | up(&data->update_lock); | 344 | mutex_unlock(&data->update_lock); |
344 | return count; | 345 | return count; |
345 | } | 346 | } |
346 | 347 | ||
@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c | |||
373 | unsigned long v = simple_strtoul(buf, NULL, 10); | 374 | unsigned long v = simple_strtoul(buf, NULL, 10); |
374 | u8 r; | 375 | u8 r; |
375 | 376 | ||
376 | down(&data->update_lock); | 377 | mutex_lock(&data->update_lock); |
377 | r = FAN_TO_REG(v, data->fan_div[n - 1]); | 378 | r = FAN_TO_REG(v, data->fan_div[n - 1]); |
378 | data->fan_min[n - 1] = r; | 379 | data->fan_min[n - 1] = r; |
379 | 380 | ||
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c | |||
390 | data->beep_mask &= data->alarm_mask; | 391 | data->beep_mask &= data->alarm_mask; |
391 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); | 392 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); |
392 | 393 | ||
393 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
394 | return count; | 395 | return count; |
395 | } | 396 | } |
396 | 397 | ||
@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c | |||
409 | return -EINVAL; | 410 | return -EINVAL; |
410 | } | 411 | } |
411 | 412 | ||
412 | down(&data->update_lock); | 413 | mutex_lock(&data->update_lock); |
413 | data->fan_div[n - 1] = r; | 414 | data->fan_div[n - 1] = r; |
414 | 415 | ||
415 | if (n == 1) | 416 | if (n == 1) |
@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c | |||
417 | else | 418 | else |
418 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); | 419 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); |
419 | 420 | ||
420 | up(&data->update_lock); | 421 | mutex_unlock(&data->update_lock); |
421 | return count; | 422 | return count; |
422 | } | 423 | } |
423 | 424 | ||
@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c | |||
425 | { | 426 | { |
426 | u8 r = simple_strtoul(buf, NULL, 10)?1:0; | 427 | u8 r = simple_strtoul(buf, NULL, 10)?1:0; |
427 | 428 | ||
428 | down(&data->update_lock); | 429 | mutex_lock(&data->update_lock); |
429 | data->fan_off = r; | 430 | data->fan_off = r; |
430 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); | 431 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); |
431 | up(&data->update_lock); | 432 | mutex_unlock(&data->update_lock); |
432 | return count; | 433 | return count; |
433 | } | 434 | } |
434 | 435 | ||
@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data, | |||
454 | { | 455 | { |
455 | long v = simple_strtol(buf, NULL, 10); | 456 | long v = simple_strtol(buf, NULL, 10); |
456 | 457 | ||
457 | down(&data->update_lock); | 458 | mutex_lock(&data->update_lock); |
458 | data->temp_max[n - 1] = TEMP_TO_REG(v);; | 459 | data->temp_max[n - 1] = TEMP_TO_REG(v);; |
459 | gl520_write_value(client, reg, data->temp_max[n - 1]); | 460 | gl520_write_value(client, reg, data->temp_max[n - 1]); |
460 | up(&data->update_lock); | 461 | mutex_unlock(&data->update_lock); |
461 | return count; | 462 | return count; |
462 | } | 463 | } |
463 | 464 | ||
@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d | |||
465 | { | 466 | { |
466 | long v = simple_strtol(buf, NULL, 10); | 467 | long v = simple_strtol(buf, NULL, 10); |
467 | 468 | ||
468 | down(&data->update_lock); | 469 | mutex_lock(&data->update_lock); |
469 | data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); | 470 | data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); |
470 | gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); | 471 | gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); |
471 | up(&data->update_lock); | 472 | mutex_unlock(&data->update_lock); |
472 | return count; | 473 | return count; |
473 | } | 474 | } |
474 | 475 | ||
@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat | |||
491 | { | 492 | { |
492 | u8 r = simple_strtoul(buf, NULL, 10)?0:1; | 493 | u8 r = simple_strtoul(buf, NULL, 10)?0:1; |
493 | 494 | ||
494 | down(&data->update_lock); | 495 | mutex_lock(&data->update_lock); |
495 | data->beep_enable = !r; | 496 | data->beep_enable = !r; |
496 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); | 497 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); |
497 | up(&data->update_lock); | 498 | mutex_unlock(&data->update_lock); |
498 | return count; | 499 | return count; |
499 | } | 500 | } |
500 | 501 | ||
@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data, | |||
502 | { | 503 | { |
503 | u8 r = simple_strtoul(buf, NULL, 10); | 504 | u8 r = simple_strtoul(buf, NULL, 10); |
504 | 505 | ||
505 | down(&data->update_lock); | 506 | mutex_lock(&data->update_lock); |
506 | r &= data->alarm_mask; | 507 | r &= data->alarm_mask; |
507 | data->beep_mask = r; | 508 | data->beep_mask = r; |
508 | gl520_write_value(client, reg, r); | 509 | gl520_write_value(client, reg, r); |
509 | up(&data->update_lock); | 510 | mutex_unlock(&data->update_lock); |
510 | return count; | 511 | return count; |
511 | } | 512 | } |
512 | 513 | ||
@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
561 | /* Fill in the remaining client fields */ | 562 | /* Fill in the remaining client fields */ |
562 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); | 563 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); |
563 | data->valid = 0; | 564 | data->valid = 0; |
564 | init_MUTEX(&data->update_lock); | 565 | mutex_init(&data->update_lock); |
565 | 566 | ||
566 | /* Tell the I2C layer a new client has arrived */ | 567 | /* Tell the I2C layer a new client has arrived */ |
567 | if ((err = i2c_attach_client(new_client))) | 568 | if ((err = i2c_attach_client(new_client))) |
@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev) | |||
685 | struct gl520_data *data = i2c_get_clientdata(client); | 686 | struct gl520_data *data = i2c_get_clientdata(client); |
686 | int val; | 687 | int val; |
687 | 688 | ||
688 | down(&data->update_lock); | 689 | mutex_lock(&data->update_lock); |
689 | 690 | ||
690 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 691 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
691 | 692 | ||
@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev) | |||
750 | data->valid = 1; | 751 | data->valid = 1; |
751 | } | 752 | } |
752 | 753 | ||
753 | up(&data->update_lock); | 754 | mutex_unlock(&data->update_lock); |
754 | 755 | ||
755 | return data; | 756 | return data; |
756 | } | 757 | } |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 23a9e1ea8e32..7636c1a58f9c 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/timer.h> | 34 | #include <linux/timer.h> |
35 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
36 | #include <linux/mutex.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | 38 | ||
38 | #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ | 39 | #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ |
@@ -70,10 +71,10 @@ static u8 km_activity; | |||
70 | static int rest_x; | 71 | static int rest_x; |
71 | static int rest_y; | 72 | static int rest_y; |
72 | 73 | ||
73 | static DECLARE_MUTEX(hdaps_sem); | 74 | static DEFINE_MUTEX(hdaps_mutex); |
74 | 75 | ||
75 | /* | 76 | /* |
76 | * __get_latch - Get the value from a given port. Callers must hold hdaps_sem. | 77 | * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex. |
77 | */ | 78 | */ |
78 | static inline u8 __get_latch(u16 port) | 79 | static inline u8 __get_latch(u16 port) |
79 | { | 80 | { |
@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port) | |||
82 | 83 | ||
83 | /* | 84 | /* |
84 | * __check_latch - Check a port latch for a given value. Returns zero if the | 85 | * __check_latch - Check a port latch for a given value. Returns zero if the |
85 | * port contains the given value. Callers must hold hdaps_sem. | 86 | * port contains the given value. Callers must hold hdaps_mutex. |
86 | */ | 87 | */ |
87 | static inline int __check_latch(u16 port, u8 val) | 88 | static inline int __check_latch(u16 port, u8 val) |
88 | { | 89 | { |
@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val) | |||
93 | 94 | ||
94 | /* | 95 | /* |
95 | * __wait_latch - Wait up to 100us for a port latch to get a certain value, | 96 | * __wait_latch - Wait up to 100us for a port latch to get a certain value, |
96 | * returning zero if the value is obtained. Callers must hold hdaps_sem. | 97 | * returning zero if the value is obtained. Callers must hold hdaps_mutex. |
97 | */ | 98 | */ |
98 | static int __wait_latch(u16 port, u8 val) | 99 | static int __wait_latch(u16 port, u8 val) |
99 | { | 100 | { |
@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val) | |||
110 | 111 | ||
111 | /* | 112 | /* |
112 | * __device_refresh - request a refresh from the accelerometer. Does not wait | 113 | * __device_refresh - request a refresh from the accelerometer. Does not wait |
113 | * for refresh to complete. Callers must hold hdaps_sem. | 114 | * for refresh to complete. Callers must hold hdaps_mutex. |
114 | */ | 115 | */ |
115 | static void __device_refresh(void) | 116 | static void __device_refresh(void) |
116 | { | 117 | { |
@@ -124,7 +125,7 @@ static void __device_refresh(void) | |||
124 | /* | 125 | /* |
125 | * __device_refresh_sync - request a synchronous refresh from the | 126 | * __device_refresh_sync - request a synchronous refresh from the |
126 | * accelerometer. We wait for the refresh to complete. Returns zero if | 127 | * accelerometer. We wait for the refresh to complete. Returns zero if |
127 | * successful and nonzero on error. Callers must hold hdaps_sem. | 128 | * successful and nonzero on error. Callers must hold hdaps_mutex. |
128 | */ | 129 | */ |
129 | static int __device_refresh_sync(void) | 130 | static int __device_refresh_sync(void) |
130 | { | 131 | { |
@@ -134,7 +135,7 @@ static int __device_refresh_sync(void) | |||
134 | 135 | ||
135 | /* | 136 | /* |
136 | * __device_complete - indicate to the accelerometer that we are done reading | 137 | * __device_complete - indicate to the accelerometer that we are done reading |
137 | * data, and then initiate an async refresh. Callers must hold hdaps_sem. | 138 | * data, and then initiate an async refresh. Callers must hold hdaps_mutex. |
138 | */ | 139 | */ |
139 | static inline void __device_complete(void) | 140 | static inline void __device_complete(void) |
140 | { | 141 | { |
@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val) | |||
152 | { | 153 | { |
153 | int ret; | 154 | int ret; |
154 | 155 | ||
155 | down(&hdaps_sem); | 156 | mutex_lock(&hdaps_mutex); |
156 | 157 | ||
157 | /* do a sync refresh -- we need to be sure that we read fresh data */ | 158 | /* do a sync refresh -- we need to be sure that we read fresh data */ |
158 | ret = __device_refresh_sync(); | 159 | ret = __device_refresh_sync(); |
@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val) | |||
163 | __device_complete(); | 164 | __device_complete(); |
164 | 165 | ||
165 | out: | 166 | out: |
166 | up(&hdaps_sem); | 167 | mutex_unlock(&hdaps_mutex); |
167 | return ret; | 168 | return ret; |
168 | } | 169 | } |
169 | 170 | ||
@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2, | |||
198 | { | 199 | { |
199 | int ret; | 200 | int ret; |
200 | 201 | ||
201 | down(&hdaps_sem); | 202 | mutex_lock(&hdaps_mutex); |
202 | ret = __hdaps_read_pair(port1, port2, val1, val2); | 203 | ret = __hdaps_read_pair(port1, port2, val1, val2); |
203 | up(&hdaps_sem); | 204 | mutex_unlock(&hdaps_mutex); |
204 | 205 | ||
205 | return ret; | 206 | return ret; |
206 | } | 207 | } |
@@ -213,7 +214,7 @@ static int hdaps_device_init(void) | |||
213 | { | 214 | { |
214 | int total, ret = -ENXIO; | 215 | int total, ret = -ENXIO; |
215 | 216 | ||
216 | down(&hdaps_sem); | 217 | mutex_lock(&hdaps_mutex); |
217 | 218 | ||
218 | outb(0x13, 0x1610); | 219 | outb(0x13, 0x1610); |
219 | outb(0x01, 0x161f); | 220 | outb(0x01, 0x161f); |
@@ -279,7 +280,7 @@ static int hdaps_device_init(void) | |||
279 | } | 280 | } |
280 | 281 | ||
281 | out: | 282 | out: |
282 | up(&hdaps_sem); | 283 | mutex_unlock(&hdaps_mutex); |
283 | return ret; | 284 | return ret; |
284 | } | 285 | } |
285 | 286 | ||
@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = { | |||
313 | }; | 314 | }; |
314 | 315 | ||
315 | /* | 316 | /* |
316 | * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. | 317 | * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex. |
317 | */ | 318 | */ |
318 | static void hdaps_calibrate(void) | 319 | static void hdaps_calibrate(void) |
319 | { | 320 | { |
@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
325 | int x, y; | 326 | int x, y; |
326 | 327 | ||
327 | /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ | 328 | /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ |
328 | if (down_trylock(&hdaps_sem)) { | 329 | if (!mutex_trylock(&hdaps_mutex)) { |
329 | mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); | 330 | mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); |
330 | return; | 331 | return; |
331 | } | 332 | } |
@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
340 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); | 341 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); |
341 | 342 | ||
342 | out: | 343 | out: |
343 | up(&hdaps_sem); | 344 | mutex_unlock(&hdaps_mutex); |
344 | } | 345 | } |
345 | 346 | ||
346 | 347 | ||
@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev, | |||
420 | struct device_attribute *attr, | 421 | struct device_attribute *attr, |
421 | const char *buf, size_t count) | 422 | const char *buf, size_t count) |
422 | { | 423 | { |
423 | down(&hdaps_sem); | 424 | mutex_lock(&hdaps_mutex); |
424 | hdaps_calibrate(); | 425 | hdaps_calibrate(); |
425 | up(&hdaps_sem); | 426 | mutex_unlock(&hdaps_mutex); |
426 | 427 | ||
427 | return count; | 428 | return count; |
428 | } | 429 | } |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index e497274916ce..a74a44f16f51 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
@@ -54,6 +54,10 @@ | |||
54 | (IMVP-II). You can find more information in the datasheet of Max1718 | 54 | (IMVP-II). You can find more information in the datasheet of Max1718 |
55 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 | 55 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 |
56 | 56 | ||
57 | The 13 specification corresponds to the Intel Pentium M series. There | ||
58 | doesn't seem to be any named specification for these. The conversion | ||
59 | tables are detailed directly in the various Pentium M datasheets: | ||
60 | http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm | ||
57 | */ | 61 | */ |
58 | 62 | ||
59 | /* vrm is the VRM/VRD document version multiplied by 10. | 63 | /* vrm is the VRM/VRD document version multiplied by 10. |
@@ -100,6 +104,8 @@ int vid_from_reg(int val, u8 vrm) | |||
100 | case 17: /* Intel IMVP-II */ | 104 | case 17: /* Intel IMVP-II */ |
101 | return(val & 0x10 ? 975 - (val & 0xF) * 25 : | 105 | return(val & 0x10 ? 975 - (val & 0xF) * 25 : |
102 | 1750 - val * 50); | 106 | 1750 - val * 50); |
107 | case 13: | ||
108 | return(1708 - (val & 0x3f) * 16); | ||
103 | default: /* report 0 for unknown */ | 109 | default: /* report 0 for unknown */ |
104 | printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); | 110 | printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); |
105 | return 0; | 111 | return 0; |
@@ -129,8 +135,9 @@ struct vrm_model { | |||
129 | static struct vrm_model vrm_models[] = { | 135 | static struct vrm_model vrm_models[] = { |
130 | {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ | 136 | {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ |
131 | {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ | 137 | {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ |
132 | {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */ | 138 | {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13}, /* Pentium M (130 nm) */ |
133 | {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ | 139 | {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ |
140 | {X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13}, /* Pentium M (90 nm) */ | ||
134 | {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ | 141 | {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ |
135 | {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ | 142 | {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ |
136 | {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ | 143 | {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ |
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index dddd3eb9b387..106fa01cdb60 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/idr.h> | 17 | #include <linux/idr.h> |
18 | #include <linux/hwmon.h> | 18 | #include <linux/hwmon.h> |
19 | #include <linux/gfp.h> | 19 | #include <linux/gfp.h> |
20 | #include <linux/spinlock.h> | ||
20 | 21 | ||
21 | #define HWMON_ID_PREFIX "hwmon" | 22 | #define HWMON_ID_PREFIX "hwmon" |
22 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" | 23 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" |
@@ -24,6 +25,7 @@ | |||
24 | static struct class *hwmon_class; | 25 | static struct class *hwmon_class; |
25 | 26 | ||
26 | static DEFINE_IDR(hwmon_idr); | 27 | static DEFINE_IDR(hwmon_idr); |
28 | static DEFINE_SPINLOCK(idr_lock); | ||
27 | 29 | ||
28 | /** | 30 | /** |
29 | * hwmon_device_register - register w/ hwmon sysfs class | 31 | * hwmon_device_register - register w/ hwmon sysfs class |
@@ -37,20 +39,30 @@ static DEFINE_IDR(hwmon_idr); | |||
37 | struct class_device *hwmon_device_register(struct device *dev) | 39 | struct class_device *hwmon_device_register(struct device *dev) |
38 | { | 40 | { |
39 | struct class_device *cdev; | 41 | struct class_device *cdev; |
40 | int id; | 42 | int id, err; |
41 | 43 | ||
42 | if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0) | 44 | again: |
45 | if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)) | ||
43 | return ERR_PTR(-ENOMEM); | 46 | return ERR_PTR(-ENOMEM); |
44 | 47 | ||
45 | if (idr_get_new(&hwmon_idr, NULL, &id) < 0) | 48 | spin_lock(&idr_lock); |
46 | return ERR_PTR(-ENOMEM); | 49 | err = idr_get_new(&hwmon_idr, NULL, &id); |
50 | spin_unlock(&idr_lock); | ||
51 | |||
52 | if (unlikely(err == -EAGAIN)) | ||
53 | goto again; | ||
54 | else if (unlikely(err)) | ||
55 | return ERR_PTR(err); | ||
47 | 56 | ||
48 | id = id & MAX_ID_MASK; | 57 | id = id & MAX_ID_MASK; |
49 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, | 58 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, |
50 | HWMON_ID_FORMAT, id); | 59 | HWMON_ID_FORMAT, id); |
51 | 60 | ||
52 | if (IS_ERR(cdev)) | 61 | if (IS_ERR(cdev)) { |
62 | spin_lock(&idr_lock); | ||
53 | idr_remove(&hwmon_idr, id); | 63 | idr_remove(&hwmon_idr, id); |
64 | spin_unlock(&idr_lock); | ||
65 | } | ||
54 | 66 | ||
55 | return cdev; | 67 | return cdev; |
56 | } | 68 | } |
@@ -64,9 +76,11 @@ void hwmon_device_unregister(struct class_device *cdev) | |||
64 | { | 76 | { |
65 | int id; | 77 | int id; |
66 | 78 | ||
67 | if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) { | 79 | if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) { |
68 | class_device_unregister(cdev); | 80 | class_device_unregister(cdev); |
81 | spin_lock(&idr_lock); | ||
69 | idr_remove(&hwmon_idr, id); | 82 | idr_remove(&hwmon_idr, id); |
83 | spin_unlock(&idr_lock); | ||
70 | } else | 84 | } else |
71 | dev_dbg(cdev->dev, | 85 | dev_dbg(cdev->dev, |
72 | "hwmon_device_unregister() failed: bad class ID!\n"); | 86 | "hwmon_device_unregister() failed: bad class ID!\n"); |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d7a9401600bb..06df92b3ee49 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/hwmon-sysfs.h> | 41 | #include <linux/hwmon-sysfs.h> |
42 | #include <linux/hwmon-vid.h> | 42 | #include <linux/hwmon-vid.h> |
43 | #include <linux/err.h> | 43 | #include <linux/err.h> |
44 | #include <linux/mutex.h> | ||
44 | #include <asm/io.h> | 45 | #include <asm/io.h> |
45 | 46 | ||
46 | 47 | ||
@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val) | |||
194 | struct it87_data { | 195 | struct it87_data { |
195 | struct i2c_client client; | 196 | struct i2c_client client; |
196 | struct class_device *class_dev; | 197 | struct class_device *class_dev; |
197 | struct semaphore lock; | 198 | struct mutex lock; |
198 | enum chips type; | 199 | enum chips type; |
199 | 200 | ||
200 | struct semaphore update_lock; | 201 | struct mutex update_lock; |
201 | char valid; /* !=0 if following fields are valid */ | 202 | char valid; /* !=0 if following fields are valid */ |
202 | unsigned long last_updated; /* In jiffies */ | 203 | unsigned long last_updated; /* In jiffies */ |
203 | 204 | ||
@@ -224,9 +225,8 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter); | |||
224 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); | 225 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); |
225 | static int it87_detach_client(struct i2c_client *client); | 226 | static int it87_detach_client(struct i2c_client *client); |
226 | 227 | ||
227 | static int it87_read_value(struct i2c_client *client, u8 register); | 228 | static int it87_read_value(struct i2c_client *client, u8 reg); |
228 | static int it87_write_value(struct i2c_client *client, u8 register, | 229 | static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); |
229 | u8 value); | ||
230 | static struct it87_data *it87_update_device(struct device *dev); | 230 | static struct it87_data *it87_update_device(struct device *dev); |
231 | static int it87_check_pwm(struct i2c_client *client); | 231 | static int it87_check_pwm(struct i2c_client *client); |
232 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); | 232 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); |
@@ -290,11 +290,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
290 | struct it87_data *data = i2c_get_clientdata(client); | 290 | struct it87_data *data = i2c_get_clientdata(client); |
291 | unsigned long val = simple_strtoul(buf, NULL, 10); | 291 | unsigned long val = simple_strtoul(buf, NULL, 10); |
292 | 292 | ||
293 | down(&data->update_lock); | 293 | mutex_lock(&data->update_lock); |
294 | data->in_min[nr] = IN_TO_REG(val); | 294 | data->in_min[nr] = IN_TO_REG(val); |
295 | it87_write_value(client, IT87_REG_VIN_MIN(nr), | 295 | it87_write_value(client, IT87_REG_VIN_MIN(nr), |
296 | data->in_min[nr]); | 296 | data->in_min[nr]); |
297 | up(&data->update_lock); | 297 | mutex_unlock(&data->update_lock); |
298 | return count; | 298 | return count; |
299 | } | 299 | } |
300 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | 300 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
@@ -307,11 +307,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
307 | struct it87_data *data = i2c_get_clientdata(client); | 307 | struct it87_data *data = i2c_get_clientdata(client); |
308 | unsigned long val = simple_strtoul(buf, NULL, 10); | 308 | unsigned long val = simple_strtoul(buf, NULL, 10); |
309 | 309 | ||
310 | down(&data->update_lock); | 310 | mutex_lock(&data->update_lock); |
311 | data->in_max[nr] = IN_TO_REG(val); | 311 | data->in_max[nr] = IN_TO_REG(val); |
312 | it87_write_value(client, IT87_REG_VIN_MAX(nr), | 312 | it87_write_value(client, IT87_REG_VIN_MAX(nr), |
313 | data->in_max[nr]); | 313 | data->in_max[nr]); |
314 | up(&data->update_lock); | 314 | mutex_unlock(&data->update_lock); |
315 | return count; | 315 | return count; |
316 | } | 316 | } |
317 | 317 | ||
@@ -381,10 +381,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
381 | struct it87_data *data = i2c_get_clientdata(client); | 381 | struct it87_data *data = i2c_get_clientdata(client); |
382 | int val = simple_strtol(buf, NULL, 10); | 382 | int val = simple_strtol(buf, NULL, 10); |
383 | 383 | ||
384 | down(&data->update_lock); | 384 | mutex_lock(&data->update_lock); |
385 | data->temp_high[nr] = TEMP_TO_REG(val); | 385 | data->temp_high[nr] = TEMP_TO_REG(val); |
386 | it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 386 | it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
387 | up(&data->update_lock); | 387 | mutex_unlock(&data->update_lock); |
388 | return count; | 388 | return count; |
389 | } | 389 | } |
390 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 390 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -397,10 +397,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
397 | struct it87_data *data = i2c_get_clientdata(client); | 397 | struct it87_data *data = i2c_get_clientdata(client); |
398 | int val = simple_strtol(buf, NULL, 10); | 398 | int val = simple_strtol(buf, NULL, 10); |
399 | 399 | ||
400 | down(&data->update_lock); | 400 | mutex_lock(&data->update_lock); |
401 | data->temp_low[nr] = TEMP_TO_REG(val); | 401 | data->temp_low[nr] = TEMP_TO_REG(val); |
402 | it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); | 402 | it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); |
403 | up(&data->update_lock); | 403 | mutex_unlock(&data->update_lock); |
404 | return count; | 404 | return count; |
405 | } | 405 | } |
406 | #define show_temp_offset(offset) \ | 406 | #define show_temp_offset(offset) \ |
@@ -440,7 +440,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
440 | struct it87_data *data = i2c_get_clientdata(client); | 440 | struct it87_data *data = i2c_get_clientdata(client); |
441 | int val = simple_strtol(buf, NULL, 10); | 441 | int val = simple_strtol(buf, NULL, 10); |
442 | 442 | ||
443 | down(&data->update_lock); | 443 | mutex_lock(&data->update_lock); |
444 | 444 | ||
445 | data->sensor &= ~(1 << nr); | 445 | data->sensor &= ~(1 << nr); |
446 | data->sensor &= ~(8 << nr); | 446 | data->sensor &= ~(8 << nr); |
@@ -450,11 +450,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
450 | else if (val == 2) | 450 | else if (val == 2) |
451 | data->sensor |= 8 << nr; | 451 | data->sensor |= 8 << nr; |
452 | else if (val != 0) { | 452 | else if (val != 0) { |
453 | up(&data->update_lock); | 453 | mutex_unlock(&data->update_lock); |
454 | return -EINVAL; | 454 | return -EINVAL; |
455 | } | 455 | } |
456 | it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); | 456 | it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); |
457 | up(&data->update_lock); | 457 | mutex_unlock(&data->update_lock); |
458 | return count; | 458 | return count; |
459 | } | 459 | } |
460 | #define show_sensor_offset(offset) \ | 460 | #define show_sensor_offset(offset) \ |
@@ -524,7 +524,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
524 | int val = simple_strtol(buf, NULL, 10); | 524 | int val = simple_strtol(buf, NULL, 10); |
525 | u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); | 525 | u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); |
526 | 526 | ||
527 | down(&data->update_lock); | 527 | mutex_lock(&data->update_lock); |
528 | switch (nr) { | 528 | switch (nr) { |
529 | case 0: data->fan_div[nr] = reg & 0x07; break; | 529 | case 0: data->fan_div[nr] = reg & 0x07; break; |
530 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; | 530 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; |
@@ -533,7 +533,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
533 | 533 | ||
534 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 534 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
535 | it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); | 535 | it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); |
536 | up(&data->update_lock); | 536 | mutex_unlock(&data->update_lock); |
537 | return count; | 537 | return count; |
538 | } | 538 | } |
539 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | 539 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
@@ -548,7 +548,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | int i, min[3]; | 548 | int i, min[3]; |
549 | u8 old; | 549 | u8 old; |
550 | 550 | ||
551 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
552 | old = it87_read_value(client, IT87_REG_FAN_DIV); | 552 | old = it87_read_value(client, IT87_REG_FAN_DIV); |
553 | 553 | ||
554 | for (i = 0; i < 3; i++) | 554 | for (i = 0; i < 3; i++) |
@@ -576,7 +576,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
576 | data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); | 576 | data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); |
577 | it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); | 577 | it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); |
578 | } | 578 | } |
579 | up(&data->update_lock); | 579 | mutex_unlock(&data->update_lock); |
580 | return count; | 580 | return count; |
581 | } | 581 | } |
582 | static ssize_t set_pwm_enable(struct device *dev, | 582 | static ssize_t set_pwm_enable(struct device *dev, |
@@ -589,7 +589,7 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
589 | struct it87_data *data = i2c_get_clientdata(client); | 589 | struct it87_data *data = i2c_get_clientdata(client); |
590 | int val = simple_strtol(buf, NULL, 10); | 590 | int val = simple_strtol(buf, NULL, 10); |
591 | 591 | ||
592 | down(&data->update_lock); | 592 | mutex_lock(&data->update_lock); |
593 | 593 | ||
594 | if (val == 0) { | 594 | if (val == 0) { |
595 | int tmp; | 595 | int tmp; |
@@ -606,11 +606,11 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
606 | /* set saved pwm value, clear FAN_CTLX PWM mode bit */ | 606 | /* set saved pwm value, clear FAN_CTLX PWM mode bit */ |
607 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); | 607 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); |
608 | } else { | 608 | } else { |
609 | up(&data->update_lock); | 609 | mutex_unlock(&data->update_lock); |
610 | return -EINVAL; | 610 | return -EINVAL; |
611 | } | 611 | } |
612 | 612 | ||
613 | up(&data->update_lock); | 613 | mutex_unlock(&data->update_lock); |
614 | return count; | 614 | return count; |
615 | } | 615 | } |
616 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | 616 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
@@ -626,11 +626,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
626 | if (val < 0 || val > 255) | 626 | if (val < 0 || val > 255) |
627 | return -EINVAL; | 627 | return -EINVAL; |
628 | 628 | ||
629 | down(&data->update_lock); | 629 | mutex_lock(&data->update_lock); |
630 | data->manual_pwm_ctl[nr] = val; | 630 | data->manual_pwm_ctl[nr] = val; |
631 | if (data->fan_main_ctrl & (1 << nr)) | 631 | if (data->fan_main_ctrl & (1 << nr)) |
632 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); | 632 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); |
633 | up(&data->update_lock); | 633 | mutex_unlock(&data->update_lock); |
634 | return count; | 634 | return count; |
635 | } | 635 | } |
636 | 636 | ||
@@ -776,7 +776,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
776 | 776 | ||
777 | new_client = &data->client; | 777 | new_client = &data->client; |
778 | if (is_isa) | 778 | if (is_isa) |
779 | init_MUTEX(&data->lock); | 779 | mutex_init(&data->lock); |
780 | i2c_set_clientdata(new_client, data); | 780 | i2c_set_clientdata(new_client, data); |
781 | new_client->addr = address; | 781 | new_client->addr = address; |
782 | new_client->adapter = adapter; | 782 | new_client->adapter = adapter; |
@@ -823,7 +823,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
823 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 823 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
824 | data->type = kind; | 824 | data->type = kind; |
825 | data->valid = 0; | 825 | data->valid = 0; |
826 | init_MUTEX(&data->update_lock); | 826 | mutex_init(&data->update_lock); |
827 | 827 | ||
828 | /* Tell the I2C layer a new client has arrived */ | 828 | /* Tell the I2C layer a new client has arrived */ |
829 | if ((err = i2c_attach_client(new_client))) | 829 | if ((err = i2c_attach_client(new_client))) |
@@ -950,10 +950,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg) | |||
950 | 950 | ||
951 | int res; | 951 | int res; |
952 | if (i2c_is_isa_client(client)) { | 952 | if (i2c_is_isa_client(client)) { |
953 | down(&data->lock); | 953 | mutex_lock(&data->lock); |
954 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 954 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
955 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); | 955 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); |
956 | up(&data->lock); | 956 | mutex_unlock(&data->lock); |
957 | return res; | 957 | return res; |
958 | } else | 958 | } else |
959 | return i2c_smbus_read_byte_data(client, reg); | 959 | return i2c_smbus_read_byte_data(client, reg); |
@@ -969,10 +969,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
969 | struct it87_data *data = i2c_get_clientdata(client); | 969 | struct it87_data *data = i2c_get_clientdata(client); |
970 | 970 | ||
971 | if (i2c_is_isa_client(client)) { | 971 | if (i2c_is_isa_client(client)) { |
972 | down(&data->lock); | 972 | mutex_lock(&data->lock); |
973 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 973 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
974 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); | 974 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); |
975 | up(&data->lock); | 975 | mutex_unlock(&data->lock); |
976 | return 0; | 976 | return 0; |
977 | } else | 977 | } else |
978 | return i2c_smbus_write_byte_data(client, reg, value); | 978 | return i2c_smbus_write_byte_data(client, reg, value); |
@@ -1098,7 +1098,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1098 | struct it87_data *data = i2c_get_clientdata(client); | 1098 | struct it87_data *data = i2c_get_clientdata(client); |
1099 | int i; | 1099 | int i; |
1100 | 1100 | ||
1101 | down(&data->update_lock); | 1101 | mutex_lock(&data->update_lock); |
1102 | 1102 | ||
1103 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1103 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1104 | || !data->valid) { | 1104 | || !data->valid) { |
@@ -1160,7 +1160,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1160 | data->valid = 1; | 1160 | data->valid = 1; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | up(&data->update_lock); | 1163 | mutex_unlock(&data->update_lock); |
1164 | 1164 | ||
1165 | return data; | 1165 | return data; |
1166 | } | 1166 | } |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 6b1aa7ef552e..071f0fc6adec 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/hwmon-sysfs.h> | 45 | #include <linux/hwmon-sysfs.h> |
46 | #include <linux/hwmon.h> | 46 | #include <linux/hwmon.h> |
47 | #include <linux/err.h> | 47 | #include <linux/err.h> |
48 | #include <linux/mutex.h> | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Addresses to scan | 51 | * Addresses to scan |
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = { | |||
153 | struct lm63_data { | 154 | struct lm63_data { |
154 | struct i2c_client client; | 155 | struct i2c_client client; |
155 | struct class_device *class_dev; | 156 | struct class_device *class_dev; |
156 | struct semaphore update_lock; | 157 | struct mutex update_lock; |
157 | char valid; /* zero until following fields are valid */ | 158 | char valid; /* zero until following fields are valid */ |
158 | unsigned long last_updated; /* in jiffies */ | 159 | unsigned long last_updated; /* in jiffies */ |
159 | 160 | ||
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, | |||
192 | struct lm63_data *data = i2c_get_clientdata(client); | 193 | struct lm63_data *data = i2c_get_clientdata(client); |
193 | unsigned long val = simple_strtoul(buf, NULL, 10); | 194 | unsigned long val = simple_strtoul(buf, NULL, 10); |
194 | 195 | ||
195 | down(&data->update_lock); | 196 | mutex_lock(&data->update_lock); |
196 | data->fan[1] = FAN_TO_REG(val); | 197 | data->fan[1] = FAN_TO_REG(val); |
197 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, | 198 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, |
198 | data->fan[1] & 0xFF); | 199 | data->fan[1] & 0xFF); |
199 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, | 200 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, |
200 | data->fan[1] >> 8); | 201 | data->fan[1] >> 8); |
201 | up(&data->update_lock); | 202 | mutex_unlock(&data->update_lock); |
202 | return count; | 203 | return count; |
203 | } | 204 | } |
204 | 205 | ||
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, | |||
222 | return -EPERM; | 223 | return -EPERM; |
223 | 224 | ||
224 | val = simple_strtoul(buf, NULL, 10); | 225 | val = simple_strtoul(buf, NULL, 10); |
225 | down(&data->update_lock); | 226 | mutex_lock(&data->update_lock); |
226 | data->pwm1_value = val <= 0 ? 0 : | 227 | data->pwm1_value = val <= 0 ? 0 : |
227 | val >= 255 ? 2 * data->pwm1_freq : | 228 | val >= 255 ? 2 * data->pwm1_freq : |
228 | (val * data->pwm1_freq * 2 + 127) / 255; | 229 | (val * data->pwm1_freq * 2 + 127) / 255; |
229 | i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); | 230 | i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); |
230 | up(&data->update_lock); | 231 | mutex_unlock(&data->update_lock); |
231 | return count; | 232 | return count; |
232 | } | 233 | } |
233 | 234 | ||
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, | |||
253 | struct lm63_data *data = i2c_get_clientdata(client); | 254 | struct lm63_data *data = i2c_get_clientdata(client); |
254 | long val = simple_strtol(buf, NULL, 10); | 255 | long val = simple_strtol(buf, NULL, 10); |
255 | 256 | ||
256 | down(&data->update_lock); | 257 | mutex_lock(&data->update_lock); |
257 | data->temp8[1] = TEMP8_TO_REG(val); | 258 | data->temp8[1] = TEMP8_TO_REG(val); |
258 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); | 259 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); |
259 | up(&data->update_lock); | 260 | mutex_unlock(&data->update_lock); |
260 | return count; | 261 | return count; |
261 | } | 262 | } |
262 | 263 | ||
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
284 | long val = simple_strtol(buf, NULL, 10); | 285 | long val = simple_strtol(buf, NULL, 10); |
285 | int nr = attr->index; | 286 | int nr = attr->index; |
286 | 287 | ||
287 | down(&data->update_lock); | 288 | mutex_lock(&data->update_lock); |
288 | data->temp11[nr] = TEMP11_TO_REG(val); | 289 | data->temp11[nr] = TEMP11_TO_REG(val); |
289 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | 290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], |
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute * | |||
314 | long val = simple_strtol(buf, NULL, 10); | 315 | long val = simple_strtol(buf, NULL, 10); |
315 | long hyst; | 316 | long hyst; |
316 | 317 | ||
317 | down(&data->update_lock); | 318 | mutex_lock(&data->update_lock); |
318 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; | 319 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; |
319 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, | 320 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, |
320 | HYST_TO_REG(hyst)); | 321 | HYST_TO_REG(hyst)); |
321 | up(&data->update_lock); | 322 | mutex_unlock(&data->update_lock); |
322 | return count; | 323 | return count; |
323 | } | 324 | } |
324 | 325 | ||
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
427 | 428 | ||
428 | strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); | 429 | strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); |
429 | data->valid = 0; | 430 | data->valid = 0; |
430 | init_MUTEX(&data->update_lock); | 431 | mutex_init(&data->update_lock); |
431 | 432 | ||
432 | /* Tell the I2C layer a new client has arrived */ | 433 | /* Tell the I2C layer a new client has arrived */ |
433 | if ((err = i2c_attach_client(new_client))) | 434 | if ((err = i2c_attach_client(new_client))) |
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
530 | struct i2c_client *client = to_i2c_client(dev); | 531 | struct i2c_client *client = to_i2c_client(dev); |
531 | struct lm63_data *data = i2c_get_clientdata(client); | 532 | struct lm63_data *data = i2c_get_clientdata(client); |
532 | 533 | ||
533 | down(&data->update_lock); | 534 | mutex_lock(&data->update_lock); |
534 | 535 | ||
535 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 536 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
536 | if (data->config & 0x04) { /* tachometer enabled */ | 537 | if (data->config & 0x04) { /* tachometer enabled */ |
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
582 | data->valid = 1; | 583 | data->valid = 1; |
583 | } | 584 | } |
584 | 585 | ||
585 | up(&data->update_lock); | 586 | mutex_unlock(&data->update_lock); |
586 | 587 | ||
587 | return data; | 588 | return data; |
588 | } | 589 | } |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 74ca2c8c61c3..fc25b90ec24a 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/hwmon.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <linux/mutex.h> | ||
28 | #include "lm75.h" | 29 | #include "lm75.h" |
29 | 30 | ||
30 | 31 | ||
@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75); | |||
47 | struct lm75_data { | 48 | struct lm75_data { |
48 | struct i2c_client client; | 49 | struct i2c_client client; |
49 | struct class_device *class_dev; | 50 | struct class_device *class_dev; |
50 | struct semaphore update_lock; | 51 | struct mutex update_lock; |
51 | char valid; /* !=0 if following fields are valid */ | 52 | char valid; /* !=0 if following fields are valid */ |
52 | unsigned long last_updated; /* In jiffies */ | 53 | unsigned long last_updated; /* In jiffies */ |
53 | u16 temp_input; /* Register values */ | 54 | u16 temp_input; /* Register values */ |
@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
91 | struct lm75_data *data = i2c_get_clientdata(client); \ | 92 | struct lm75_data *data = i2c_get_clientdata(client); \ |
92 | int temp = simple_strtoul(buf, NULL, 10); \ | 93 | int temp = simple_strtoul(buf, NULL, 10); \ |
93 | \ | 94 | \ |
94 | down(&data->update_lock); \ | 95 | mutex_lock(&data->update_lock); \ |
95 | data->value = LM75_TEMP_TO_REG(temp); \ | 96 | data->value = LM75_TEMP_TO_REG(temp); \ |
96 | lm75_write_value(client, reg, data->value); \ | 97 | lm75_write_value(client, reg, data->value); \ |
97 | up(&data->update_lock); \ | 98 | mutex_unlock(&data->update_lock); \ |
98 | return count; \ | 99 | return count; \ |
99 | } | 100 | } |
100 | set(temp_max, LM75_REG_TEMP_OS); | 101 | set(temp_max, LM75_REG_TEMP_OS); |
@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
188 | /* Fill in the remaining client fields and put it into the global list */ | 189 | /* Fill in the remaining client fields and put it into the global list */ |
189 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 190 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
190 | data->valid = 0; | 191 | data->valid = 0; |
191 | init_MUTEX(&data->update_lock); | 192 | mutex_init(&data->update_lock); |
192 | 193 | ||
193 | /* Tell the I2C layer a new client has arrived */ | 194 | /* Tell the I2C layer a new client has arrived */ |
194 | if ((err = i2c_attach_client(new_client))) | 195 | if ((err = i2c_attach_client(new_client))) |
@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
264 | struct i2c_client *client = to_i2c_client(dev); | 265 | struct i2c_client *client = to_i2c_client(dev); |
265 | struct lm75_data *data = i2c_get_clientdata(client); | 266 | struct lm75_data *data = i2c_get_clientdata(client); |
266 | 267 | ||
267 | down(&data->update_lock); | 268 | mutex_lock(&data->update_lock); |
268 | 269 | ||
269 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 270 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
270 | || !data->valid) { | 271 | || !data->valid) { |
@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
277 | data->valid = 1; | 278 | data->valid = 1; |
278 | } | 279 | } |
279 | 280 | ||
280 | up(&data->update_lock); | 281 | mutex_unlock(&data->update_lock); |
281 | 282 | ||
282 | return data; | 283 | return data; |
283 | } | 284 | } |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index df9e02aaa70a..459cc977380a 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/hwmon.h> | 33 | #include <linux/hwmon.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; |
@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77); | |||
51 | struct lm77_data { | 52 | struct lm77_data { |
52 | struct i2c_client client; | 53 | struct i2c_client client; |
53 | struct class_device *class_dev; | 54 | struct class_device *class_dev; |
54 | struct semaphore update_lock; | 55 | struct mutex update_lock; |
55 | char valid; | 56 | char valid; |
56 | unsigned long last_updated; /* In jiffies */ | 57 | unsigned long last_updated; /* In jiffies */ |
57 | int temp_input; /* Temperatures */ | 58 | int temp_input; /* Temperatures */ |
@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
139 | struct lm77_data *data = i2c_get_clientdata(client); \ | 140 | struct lm77_data *data = i2c_get_clientdata(client); \ |
140 | long val = simple_strtoul(buf, NULL, 10); \ | 141 | long val = simple_strtoul(buf, NULL, 10); \ |
141 | \ | 142 | \ |
142 | down(&data->update_lock); \ | 143 | mutex_lock(&data->update_lock); \ |
143 | data->value = val; \ | 144 | data->value = val; \ |
144 | lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ | 145 | lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ |
145 | up(&data->update_lock); \ | 146 | mutex_unlock(&data->update_lock); \ |
146 | return count; \ | 147 | return count; \ |
147 | } | 148 | } |
148 | 149 | ||
@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a | |||
157 | struct lm77_data *data = i2c_get_clientdata(client); | 158 | struct lm77_data *data = i2c_get_clientdata(client); |
158 | unsigned long val = simple_strtoul(buf, NULL, 10); | 159 | unsigned long val = simple_strtoul(buf, NULL, 10); |
159 | 160 | ||
160 | down(&data->update_lock); | 161 | mutex_lock(&data->update_lock); |
161 | data->temp_hyst = data->temp_crit - val; | 162 | data->temp_hyst = data->temp_crit - val; |
162 | lm77_write_value(client, LM77_REG_TEMP_HYST, | 163 | lm77_write_value(client, LM77_REG_TEMP_HYST, |
163 | LM77_TEMP_TO_REG(data->temp_hyst)); | 164 | LM77_TEMP_TO_REG(data->temp_hyst)); |
164 | up(&data->update_lock); | 165 | mutex_unlock(&data->update_lock); |
165 | return count; | 166 | return count; |
166 | } | 167 | } |
167 | 168 | ||
@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
173 | long val = simple_strtoul(buf, NULL, 10); | 174 | long val = simple_strtoul(buf, NULL, 10); |
174 | int oldcrithyst; | 175 | int oldcrithyst; |
175 | 176 | ||
176 | down(&data->update_lock); | 177 | mutex_lock(&data->update_lock); |
177 | oldcrithyst = data->temp_crit - data->temp_hyst; | 178 | oldcrithyst = data->temp_crit - data->temp_hyst; |
178 | data->temp_crit = val; | 179 | data->temp_crit = val; |
179 | data->temp_hyst = data->temp_crit - oldcrithyst; | 180 | data->temp_hyst = data->temp_crit - oldcrithyst; |
@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
181 | LM77_TEMP_TO_REG(data->temp_crit)); | 182 | LM77_TEMP_TO_REG(data->temp_crit)); |
182 | lm77_write_value(client, LM77_REG_TEMP_HYST, | 183 | lm77_write_value(client, LM77_REG_TEMP_HYST, |
183 | LM77_TEMP_TO_REG(data->temp_hyst)); | 184 | LM77_TEMP_TO_REG(data->temp_hyst)); |
184 | up(&data->update_lock); | 185 | mutex_unlock(&data->update_lock); |
185 | return count; | 186 | return count; |
186 | } | 187 | } |
187 | 188 | ||
@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
306 | /* Fill in the remaining client fields and put it into the global list */ | 307 | /* Fill in the remaining client fields and put it into the global list */ |
307 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 308 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
308 | data->valid = 0; | 309 | data->valid = 0; |
309 | init_MUTEX(&data->update_lock); | 310 | mutex_init(&data->update_lock); |
310 | 311 | ||
311 | /* Tell the I2C layer a new client has arrived */ | 312 | /* Tell the I2C layer a new client has arrived */ |
312 | if ((err = i2c_attach_client(new_client))) | 313 | if ((err = i2c_attach_client(new_client))) |
@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev) | |||
380 | struct i2c_client *client = to_i2c_client(dev); | 381 | struct i2c_client *client = to_i2c_client(dev); |
381 | struct lm77_data *data = i2c_get_clientdata(client); | 382 | struct lm77_data *data = i2c_get_clientdata(client); |
382 | 383 | ||
383 | down(&data->update_lock); | 384 | mutex_lock(&data->update_lock); |
384 | 385 | ||
385 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 386 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
386 | || !data->valid) { | 387 | || !data->valid) { |
@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev) | |||
406 | data->valid = 1; | 407 | data->valid = 1; |
407 | } | 408 | } |
408 | 409 | ||
409 | up(&data->update_lock); | 410 | mutex_unlock(&data->update_lock); |
410 | 411 | ||
411 | return data; | 412 | return data; |
412 | } | 413 | } |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index e404001e20da..94be3d797e61 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/hwmon.h> | 27 | #include <linux/hwmon.h> |
28 | #include <linux/hwmon-vid.h> | 28 | #include <linux/hwmon-vid.h> |
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <asm/io.h> | 31 | #include <asm/io.h> |
31 | 32 | ||
32 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val) | |||
131 | struct lm78_data { | 132 | struct lm78_data { |
132 | struct i2c_client client; | 133 | struct i2c_client client; |
133 | struct class_device *class_dev; | 134 | struct class_device *class_dev; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | enum chips type; | 136 | enum chips type; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | 141 | ||
@@ -157,8 +158,8 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter); | |||
157 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); | 158 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); |
158 | static int lm78_detach_client(struct i2c_client *client); | 159 | static int lm78_detach_client(struct i2c_client *client); |
159 | 160 | ||
160 | static int lm78_read_value(struct i2c_client *client, u8 register); | 161 | static int lm78_read_value(struct i2c_client *client, u8 reg); |
161 | static int lm78_write_value(struct i2c_client *client, u8 register, u8 value); | 162 | static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value); |
162 | static struct lm78_data *lm78_update_device(struct device *dev); | 163 | static struct lm78_data *lm78_update_device(struct device *dev); |
163 | static void lm78_init_client(struct i2c_client *client); | 164 | static void lm78_init_client(struct i2c_client *client); |
164 | 165 | ||
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
207 | struct lm78_data *data = i2c_get_clientdata(client); | 208 | struct lm78_data *data = i2c_get_clientdata(client); |
208 | unsigned long val = simple_strtoul(buf, NULL, 10); | 209 | unsigned long val = simple_strtoul(buf, NULL, 10); |
209 | 210 | ||
210 | down(&data->update_lock); | 211 | mutex_lock(&data->update_lock); |
211 | data->in_min[nr] = IN_TO_REG(val); | 212 | data->in_min[nr] = IN_TO_REG(val); |
212 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); | 213 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); |
213 | up(&data->update_lock); | 214 | mutex_unlock(&data->update_lock); |
214 | return count; | 215 | return count; |
215 | } | 216 | } |
216 | 217 | ||
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
221 | struct lm78_data *data = i2c_get_clientdata(client); | 222 | struct lm78_data *data = i2c_get_clientdata(client); |
222 | unsigned long val = simple_strtoul(buf, NULL, 10); | 223 | unsigned long val = simple_strtoul(buf, NULL, 10); |
223 | 224 | ||
224 | down(&data->update_lock); | 225 | mutex_lock(&data->update_lock); |
225 | data->in_max[nr] = IN_TO_REG(val); | 226 | data->in_max[nr] = IN_TO_REG(val); |
226 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); | 227 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); |
227 | up(&data->update_lock); | 228 | mutex_unlock(&data->update_lock); |
228 | return count; | 229 | return count; |
229 | } | 230 | } |
230 | 231 | ||
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, | |||
288 | struct lm78_data *data = i2c_get_clientdata(client); | 289 | struct lm78_data *data = i2c_get_clientdata(client); |
289 | long val = simple_strtol(buf, NULL, 10); | 290 | long val = simple_strtol(buf, NULL, 10); |
290 | 291 | ||
291 | down(&data->update_lock); | 292 | mutex_lock(&data->update_lock); |
292 | data->temp_over = TEMP_TO_REG(val); | 293 | data->temp_over = TEMP_TO_REG(val); |
293 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); | 294 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); |
294 | up(&data->update_lock); | 295 | mutex_unlock(&data->update_lock); |
295 | return count; | 296 | return count; |
296 | } | 297 | } |
297 | 298 | ||
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, | |||
307 | struct lm78_data *data = i2c_get_clientdata(client); | 308 | struct lm78_data *data = i2c_get_clientdata(client); |
308 | long val = simple_strtol(buf, NULL, 10); | 309 | long val = simple_strtol(buf, NULL, 10); |
309 | 310 | ||
310 | down(&data->update_lock); | 311 | mutex_lock(&data->update_lock); |
311 | data->temp_hyst = TEMP_TO_REG(val); | 312 | data->temp_hyst = TEMP_TO_REG(val); |
312 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); | 313 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); |
313 | up(&data->update_lock); | 314 | mutex_unlock(&data->update_lock); |
314 | return count; | 315 | return count; |
315 | } | 316 | } |
316 | 317 | ||
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
342 | struct lm78_data *data = i2c_get_clientdata(client); | 343 | struct lm78_data *data = i2c_get_clientdata(client); |
343 | unsigned long val = simple_strtoul(buf, NULL, 10); | 344 | unsigned long val = simple_strtoul(buf, NULL, 10); |
344 | 345 | ||
345 | down(&data->update_lock); | 346 | mutex_lock(&data->update_lock); |
346 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 347 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
347 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); | 348 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
348 | up(&data->update_lock); | 349 | mutex_unlock(&data->update_lock); |
349 | return count; | 350 | return count; |
350 | } | 351 | } |
351 | 352 | ||
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
368 | unsigned long min; | 369 | unsigned long min; |
369 | u8 reg; | 370 | u8 reg; |
370 | 371 | ||
371 | down(&data->update_lock); | 372 | mutex_lock(&data->update_lock); |
372 | min = FAN_FROM_REG(data->fan_min[nr], | 373 | min = FAN_FROM_REG(data->fan_min[nr], |
373 | DIV_FROM_REG(data->fan_div[nr])); | 374 | DIV_FROM_REG(data->fan_div[nr])); |
374 | 375 | ||
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
380 | default: | 381 | default: |
381 | dev_err(&client->dev, "fan_div value %ld not " | 382 | dev_err(&client->dev, "fan_div value %ld not " |
382 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 383 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
383 | up(&data->update_lock); | 384 | mutex_unlock(&data->update_lock); |
384 | return -EINVAL; | 385 | return -EINVAL; |
385 | } | 386 | } |
386 | 387 | ||
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
398 | data->fan_min[nr] = | 399 | data->fan_min[nr] = |
399 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 400 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
400 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); | 401 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
401 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
402 | 403 | ||
403 | return count; | 404 | return count; |
404 | } | 405 | } |
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
548 | 549 | ||
549 | new_client = &data->client; | 550 | new_client = &data->client; |
550 | if (is_isa) | 551 | if (is_isa) |
551 | init_MUTEX(&data->lock); | 552 | mutex_init(&data->lock); |
552 | i2c_set_clientdata(new_client, data); | 553 | i2c_set_clientdata(new_client, data); |
553 | new_client->addr = address; | 554 | new_client->addr = address; |
554 | new_client->adapter = adapter; | 555 | new_client->adapter = adapter; |
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
598 | data->type = kind; | 599 | data->type = kind; |
599 | 600 | ||
600 | data->valid = 0; | 601 | data->valid = 0; |
601 | init_MUTEX(&data->update_lock); | 602 | mutex_init(&data->update_lock); |
602 | 603 | ||
603 | /* Tell the I2C layer a new client has arrived */ | 604 | /* Tell the I2C layer a new client has arrived */ |
604 | if ((err = i2c_attach_client(new_client))) | 605 | if ((err = i2c_attach_client(new_client))) |
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg) | |||
697 | int res; | 698 | int res; |
698 | if (i2c_is_isa_client(client)) { | 699 | if (i2c_is_isa_client(client)) { |
699 | struct lm78_data *data = i2c_get_clientdata(client); | 700 | struct lm78_data *data = i2c_get_clientdata(client); |
700 | down(&data->lock); | 701 | mutex_lock(&data->lock); |
701 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); | 702 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
702 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); | 703 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); |
703 | up(&data->lock); | 704 | mutex_unlock(&data->lock); |
704 | return res; | 705 | return res; |
705 | } else | 706 | } else |
706 | return i2c_smbus_read_byte_data(client, reg); | 707 | return i2c_smbus_read_byte_data(client, reg); |
@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
717 | { | 718 | { |
718 | if (i2c_is_isa_client(client)) { | 719 | if (i2c_is_isa_client(client)) { |
719 | struct lm78_data *data = i2c_get_clientdata(client); | 720 | struct lm78_data *data = i2c_get_clientdata(client); |
720 | down(&data->lock); | 721 | mutex_lock(&data->lock); |
721 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); | 722 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
722 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); | 723 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); |
723 | up(&data->lock); | 724 | mutex_unlock(&data->lock); |
724 | return 0; | 725 | return 0; |
725 | } else | 726 | } else |
726 | return i2c_smbus_write_byte_data(client, reg, value); | 727 | return i2c_smbus_write_byte_data(client, reg, value); |
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev) | |||
742 | struct lm78_data *data = i2c_get_clientdata(client); | 743 | struct lm78_data *data = i2c_get_clientdata(client); |
743 | int i; | 744 | int i; |
744 | 745 | ||
745 | down(&data->update_lock); | 746 | mutex_lock(&data->update_lock); |
746 | 747 | ||
747 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 748 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
748 | || !data->valid) { | 749 | || !data->valid) { |
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev) | |||
786 | data->fan_div[2] = 1; | 787 | data->fan_div[2] = 1; |
787 | } | 788 | } |
788 | 789 | ||
789 | up(&data->update_lock); | 790 | mutex_unlock(&data->update_lock); |
790 | 791 | ||
791 | return data; | 792 | return data; |
792 | } | 793 | } |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index c9a7cdea7bd7..f72120d08c4c 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | 32 | ||
32 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
33 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, | 34 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, |
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp) | |||
108 | struct lm80_data { | 109 | struct lm80_data { |
109 | struct i2c_client client; | 110 | struct i2c_client client; |
110 | struct class_device *class_dev; | 111 | struct class_device *class_dev; |
111 | struct semaphore update_lock; | 112 | struct mutex update_lock; |
112 | char valid; /* !=0 if following fields are valid */ | 113 | char valid; /* !=0 if following fields are valid */ |
113 | unsigned long last_updated; /* In jiffies */ | 114 | unsigned long last_updated; /* In jiffies */ |
114 | 115 | ||
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr | |||
191 | struct lm80_data *data = i2c_get_clientdata(client); \ | 192 | struct lm80_data *data = i2c_get_clientdata(client); \ |
192 | long val = simple_strtol(buf, NULL, 10); \ | 193 | long val = simple_strtol(buf, NULL, 10); \ |
193 | \ | 194 | \ |
194 | down(&data->update_lock);\ | 195 | mutex_lock(&data->update_lock);\ |
195 | data->value = IN_TO_REG(val); \ | 196 | data->value = IN_TO_REG(val); \ |
196 | lm80_write_value(client, reg, data->value); \ | 197 | lm80_write_value(client, reg, data->value); \ |
197 | up(&data->update_lock);\ | 198 | mutex_unlock(&data->update_lock);\ |
198 | return count; \ | 199 | return count; \ |
199 | } | 200 | } |
200 | set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); | 201 | set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); |
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att | |||
241 | struct lm80_data *data = i2c_get_clientdata(client); \ | 242 | struct lm80_data *data = i2c_get_clientdata(client); \ |
242 | long val = simple_strtoul(buf, NULL, 10); \ | 243 | long val = simple_strtoul(buf, NULL, 10); \ |
243 | \ | 244 | \ |
244 | down(&data->update_lock);\ | 245 | mutex_lock(&data->update_lock);\ |
245 | data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ | 246 | data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ |
246 | lm80_write_value(client, reg, data->value); \ | 247 | lm80_write_value(client, reg, data->value); \ |
247 | up(&data->update_lock);\ | 248 | mutex_unlock(&data->update_lock);\ |
248 | return count; \ | 249 | return count; \ |
249 | } | 250 | } |
250 | set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); | 251 | set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); |
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
263 | u8 reg; | 264 | u8 reg; |
264 | 265 | ||
265 | /* Save fan_min */ | 266 | /* Save fan_min */ |
266 | down(&data->update_lock); | 267 | mutex_lock(&data->update_lock); |
267 | min = FAN_FROM_REG(data->fan_min[nr], | 268 | min = FAN_FROM_REG(data->fan_min[nr], |
268 | DIV_FROM_REG(data->fan_div[nr])); | 269 | DIV_FROM_REG(data->fan_div[nr])); |
269 | 270 | ||
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
275 | default: | 276 | default: |
276 | dev_err(&client->dev, "fan_div value %ld not " | 277 | dev_err(&client->dev, "fan_div value %ld not " |
277 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 278 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
278 | up(&data->update_lock); | 279 | mutex_unlock(&data->update_lock); |
279 | return -EINVAL; | 280 | return -EINVAL; |
280 | } | 281 | } |
281 | 282 | ||
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
286 | /* Restore fan_min */ | 287 | /* Restore fan_min */ |
287 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 288 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
288 | lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); | 289 | lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); |
289 | up(&data->update_lock); | 290 | mutex_unlock(&data->update_lock); |
290 | 291 | ||
291 | return count; | 292 | return count; |
292 | } | 293 | } |
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
325 | struct lm80_data *data = i2c_get_clientdata(client); \ | 326 | struct lm80_data *data = i2c_get_clientdata(client); \ |
326 | long val = simple_strtoul(buf, NULL, 10); \ | 327 | long val = simple_strtoul(buf, NULL, 10); \ |
327 | \ | 328 | \ |
328 | down(&data->update_lock); \ | 329 | mutex_lock(&data->update_lock); \ |
329 | data->value = TEMP_LIMIT_TO_REG(val); \ | 330 | data->value = TEMP_LIMIT_TO_REG(val); \ |
330 | lm80_write_value(client, reg, data->value); \ | 331 | lm80_write_value(client, reg, data->value); \ |
331 | up(&data->update_lock); \ | 332 | mutex_unlock(&data->update_lock); \ |
332 | return count; \ | 333 | return count; \ |
333 | } | 334 | } |
334 | set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); | 335 | set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); |
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | /* Fill in the remaining client fields and put it into the global list */ | 438 | /* Fill in the remaining client fields and put it into the global list */ |
438 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 439 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
439 | data->valid = 0; | 440 | data->valid = 0; |
440 | init_MUTEX(&data->update_lock); | 441 | mutex_init(&data->update_lock); |
441 | 442 | ||
442 | /* Tell the I2C layer a new client has arrived */ | 443 | /* Tell the I2C layer a new client has arrived */ |
443 | if ((err = i2c_attach_client(new_client))) | 444 | if ((err = i2c_attach_client(new_client))) |
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
545 | struct lm80_data *data = i2c_get_clientdata(client); | 546 | struct lm80_data *data = i2c_get_clientdata(client); |
546 | int i; | 547 | int i; |
547 | 548 | ||
548 | down(&data->update_lock); | 549 | mutex_lock(&data->update_lock); |
549 | 550 | ||
550 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 551 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
551 | dev_dbg(&client->dev, "Starting lm80 update\n"); | 552 | dev_dbg(&client->dev, "Starting lm80 update\n"); |
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
585 | data->valid = 1; | 586 | data->valid = 1; |
586 | } | 587 | } |
587 | 588 | ||
588 | up(&data->update_lock); | 589 | mutex_unlock(&data->update_lock); |
589 | 590 | ||
590 | return data; | 591 | return data; |
591 | } | 592 | } |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 26dfa9e216c2..aac4ec2bf694 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon.h> | 36 | #include <linux/hwmon.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Addresses to scan | 41 | * Addresses to scan |
@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = { | |||
139 | struct lm83_data { | 140 | struct lm83_data { |
140 | struct i2c_client client; | 141 | struct i2c_client client; |
141 | struct class_device *class_dev; | 142 | struct class_device *class_dev; |
142 | struct semaphore update_lock; | 143 | struct mutex update_lock; |
143 | char valid; /* zero until following fields are valid */ | 144 | char valid; /* zero until following fields are valid */ |
144 | unsigned long last_updated; /* in jiffies */ | 145 | unsigned long last_updated; /* in jiffies */ |
145 | 146 | ||
@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, | |||
171 | long val = simple_strtol(buf, NULL, 10); | 172 | long val = simple_strtol(buf, NULL, 10); |
172 | int nr = attr->index; | 173 | int nr = attr->index; |
173 | 174 | ||
174 | down(&data->update_lock); | 175 | mutex_lock(&data->update_lock); |
175 | data->temp[nr] = TEMP_TO_REG(val); | 176 | data->temp[nr] = TEMP_TO_REG(val); |
176 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], | 177 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], |
177 | data->temp[nr]); | 178 | data->temp[nr]); |
178 | up(&data->update_lock); | 179 | mutex_unlock(&data->update_lock); |
179 | return count; | 180 | return count; |
180 | } | 181 | } |
181 | 182 | ||
@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
300 | /* We can fill in the remaining client fields */ | 301 | /* We can fill in the remaining client fields */ |
301 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 302 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
302 | data->valid = 0; | 303 | data->valid = 0; |
303 | init_MUTEX(&data->update_lock); | 304 | mutex_init(&data->update_lock); |
304 | 305 | ||
305 | /* Tell the I2C layer a new client has arrived */ | 306 | /* Tell the I2C layer a new client has arrived */ |
306 | if ((err = i2c_attach_client(new_client))) | 307 | if ((err = i2c_attach_client(new_client))) |
@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
373 | struct i2c_client *client = to_i2c_client(dev); | 374 | struct i2c_client *client = to_i2c_client(dev); |
374 | struct lm83_data *data = i2c_get_clientdata(client); | 375 | struct lm83_data *data = i2c_get_clientdata(client); |
375 | 376 | ||
376 | down(&data->update_lock); | 377 | mutex_lock(&data->update_lock); |
377 | 378 | ||
378 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 379 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
379 | int nr; | 380 | int nr; |
@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
393 | data->valid = 1; | 394 | data->valid = 1; |
394 | } | 395 | } |
395 | 396 | ||
396 | up(&data->update_lock); | 397 | mutex_unlock(&data->update_lock); |
397 | 398 | ||
398 | return data; | 399 | return data; |
399 | } | 400 | } |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 7389a0127547..342e9663119d 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/hwmon.h> | 31 | #include <linux/hwmon.h> |
32 | #include <linux/hwmon-vid.h> | 32 | #include <linux/hwmon-vid.h> |
33 | #include <linux/err.h> | 33 | #include <linux/err.h> |
34 | #include <linux/mutex.h> | ||
34 | 35 | ||
35 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -331,10 +332,10 @@ struct lm85_autofan { | |||
331 | struct lm85_data { | 332 | struct lm85_data { |
332 | struct i2c_client client; | 333 | struct i2c_client client; |
333 | struct class_device *class_dev; | 334 | struct class_device *class_dev; |
334 | struct semaphore lock; | 335 | struct mutex lock; |
335 | enum chips type; | 336 | enum chips type; |
336 | 337 | ||
337 | struct semaphore update_lock; | 338 | struct mutex update_lock; |
338 | int valid; /* !=0 if following fields are valid */ | 339 | int valid; /* !=0 if following fields are valid */ |
339 | unsigned long last_reading; /* In jiffies */ | 340 | unsigned long last_reading; /* In jiffies */ |
340 | unsigned long last_config; /* In jiffies */ | 341 | unsigned long last_config; /* In jiffies */ |
@@ -373,8 +374,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
373 | int kind); | 374 | int kind); |
374 | static int lm85_detach_client(struct i2c_client *client); | 375 | static int lm85_detach_client(struct i2c_client *client); |
375 | 376 | ||
376 | static int lm85_read_value(struct i2c_client *client, u8 register); | 377 | static int lm85_read_value(struct i2c_client *client, u8 reg); |
377 | static int lm85_write_value(struct i2c_client *client, u8 register, int value); | 378 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value); |
378 | static struct lm85_data *lm85_update_device(struct device *dev); | 379 | static struct lm85_data *lm85_update_device(struct device *dev); |
379 | static void lm85_init_client(struct i2c_client *client); | 380 | static void lm85_init_client(struct i2c_client *client); |
380 | 381 | ||
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
407 | struct lm85_data *data = i2c_get_clientdata(client); | 408 | struct lm85_data *data = i2c_get_clientdata(client); |
408 | long val = simple_strtol(buf, NULL, 10); | 409 | long val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->fan_min[nr] = FAN_TO_REG(val); | 412 | data->fan_min[nr] = FAN_TO_REG(val); |
412 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); | 413 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | 417 | ||
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
499 | struct lm85_data *data = i2c_get_clientdata(client); | 500 | struct lm85_data *data = i2c_get_clientdata(client); |
500 | long val = simple_strtol(buf, NULL, 10); | 501 | long val = simple_strtol(buf, NULL, 10); |
501 | 502 | ||
502 | down(&data->update_lock); | 503 | mutex_lock(&data->update_lock); |
503 | data->pwm[nr] = PWM_TO_REG(val); | 504 | data->pwm[nr] = PWM_TO_REG(val); |
504 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); | 505 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); |
505 | up(&data->update_lock); | 506 | mutex_unlock(&data->update_lock); |
506 | return count; | 507 | return count; |
507 | } | 508 | } |
508 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | 509 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) |
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
559 | struct lm85_data *data = i2c_get_clientdata(client); | 560 | struct lm85_data *data = i2c_get_clientdata(client); |
560 | long val = simple_strtol(buf, NULL, 10); | 561 | long val = simple_strtol(buf, NULL, 10); |
561 | 562 | ||
562 | down(&data->update_lock); | 563 | mutex_lock(&data->update_lock); |
563 | data->in_min[nr] = INS_TO_REG(nr, val); | 564 | data->in_min[nr] = INS_TO_REG(nr, val); |
564 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); | 565 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); |
565 | up(&data->update_lock); | 566 | mutex_unlock(&data->update_lock); |
566 | return count; | 567 | return count; |
567 | } | 568 | } |
568 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 569 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) |
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
577 | struct lm85_data *data = i2c_get_clientdata(client); | 578 | struct lm85_data *data = i2c_get_clientdata(client); |
578 | long val = simple_strtol(buf, NULL, 10); | 579 | long val = simple_strtol(buf, NULL, 10); |
579 | 580 | ||
580 | down(&data->update_lock); | 581 | mutex_lock(&data->update_lock); |
581 | data->in_max[nr] = INS_TO_REG(nr, val); | 582 | data->in_max[nr] = INS_TO_REG(nr, val); |
582 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); | 583 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); |
583 | up(&data->update_lock); | 584 | mutex_unlock(&data->update_lock); |
584 | return count; | 585 | return count; |
585 | } | 586 | } |
586 | #define show_in_reg(offset) \ | 587 | #define show_in_reg(offset) \ |
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
640 | struct lm85_data *data = i2c_get_clientdata(client); | 641 | struct lm85_data *data = i2c_get_clientdata(client); |
641 | long val = simple_strtol(buf, NULL, 10); | 642 | long val = simple_strtol(buf, NULL, 10); |
642 | 643 | ||
643 | down(&data->update_lock); | 644 | mutex_lock(&data->update_lock); |
644 | data->temp_min[nr] = TEMP_TO_REG(val); | 645 | data->temp_min[nr] = TEMP_TO_REG(val); |
645 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); | 646 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); |
646 | up(&data->update_lock); | 647 | mutex_unlock(&data->update_lock); |
647 | return count; | 648 | return count; |
648 | } | 649 | } |
649 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 650 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) |
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
658 | struct lm85_data *data = i2c_get_clientdata(client); | 659 | struct lm85_data *data = i2c_get_clientdata(client); |
659 | long val = simple_strtol(buf, NULL, 10); | 660 | long val = simple_strtol(buf, NULL, 10); |
660 | 661 | ||
661 | down(&data->update_lock); | 662 | mutex_lock(&data->update_lock); |
662 | data->temp_max[nr] = TEMP_TO_REG(val); | 663 | data->temp_max[nr] = TEMP_TO_REG(val); |
663 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); | 664 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); |
664 | up(&data->update_lock); | 665 | mutex_unlock(&data->update_lock); |
665 | return count; | 666 | return count; |
666 | } | 667 | } |
667 | #define show_temp_reg(offset) \ | 668 | #define show_temp_reg(offset) \ |
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf, | |||
713 | struct lm85_data *data = i2c_get_clientdata(client); | 714 | struct lm85_data *data = i2c_get_clientdata(client); |
714 | long val = simple_strtol(buf, NULL, 10); | 715 | long val = simple_strtol(buf, NULL, 10); |
715 | 716 | ||
716 | down(&data->update_lock); | 717 | mutex_lock(&data->update_lock); |
717 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) | 718 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) |
718 | | ZONE_TO_REG(val) ; | 719 | | ZONE_TO_REG(val) ; |
719 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), | 720 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
720 | data->autofan[nr].config); | 721 | data->autofan[nr].config); |
721 | up(&data->update_lock); | 722 | mutex_unlock(&data->update_lock); |
722 | return count; | 723 | return count; |
723 | } | 724 | } |
724 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) | 725 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) |
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf, | |||
733 | struct lm85_data *data = i2c_get_clientdata(client); | 734 | struct lm85_data *data = i2c_get_clientdata(client); |
734 | long val = simple_strtol(buf, NULL, 10); | 735 | long val = simple_strtol(buf, NULL, 10); |
735 | 736 | ||
736 | down(&data->update_lock); | 737 | mutex_lock(&data->update_lock); |
737 | data->autofan[nr].min_pwm = PWM_TO_REG(val); | 738 | data->autofan[nr].min_pwm = PWM_TO_REG(val); |
738 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), | 739 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), |
739 | data->autofan[nr].min_pwm); | 740 | data->autofan[nr].min_pwm); |
740 | up(&data->update_lock); | 741 | mutex_unlock(&data->update_lock); |
741 | return count; | 742 | return count; |
742 | } | 743 | } |
743 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) | 744 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) |
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf, | |||
752 | struct lm85_data *data = i2c_get_clientdata(client); | 753 | struct lm85_data *data = i2c_get_clientdata(client); |
753 | long val = simple_strtol(buf, NULL, 10); | 754 | long val = simple_strtol(buf, NULL, 10); |
754 | 755 | ||
755 | down(&data->update_lock); | 756 | mutex_lock(&data->update_lock); |
756 | data->autofan[nr].min_off = val; | 757 | data->autofan[nr].min_off = val; |
757 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] | 758 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] |
758 | | data->syncpwm3 | 759 | | data->syncpwm3 |
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf, | |||
760 | | (data->autofan[1].min_off ? 0x40 : 0) | 761 | | (data->autofan[1].min_off ? 0x40 : 0) |
761 | | (data->autofan[2].min_off ? 0x80 : 0) | 762 | | (data->autofan[2].min_off ? 0x80 : 0) |
762 | ); | 763 | ); |
763 | up(&data->update_lock); | 764 | mutex_unlock(&data->update_lock); |
764 | return count; | 765 | return count; |
765 | } | 766 | } |
766 | static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) | 767 | static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) |
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf, | |||
775 | struct lm85_data *data = i2c_get_clientdata(client); | 776 | struct lm85_data *data = i2c_get_clientdata(client); |
776 | long val = simple_strtol(buf, NULL, 10); | 777 | long val = simple_strtol(buf, NULL, 10); |
777 | 778 | ||
778 | down(&data->update_lock); | 779 | mutex_lock(&data->update_lock); |
779 | data->autofan[nr].freq = FREQ_TO_REG(val); | 780 | data->autofan[nr].freq = FREQ_TO_REG(val); |
780 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 781 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
781 | (data->zone[nr].range << 4) | 782 | (data->zone[nr].range << 4) |
782 | | data->autofan[nr].freq | 783 | | data->autofan[nr].freq |
783 | ); | 784 | ); |
784 | up(&data->update_lock); | 785 | mutex_unlock(&data->update_lock); |
785 | return count; | 786 | return count; |
786 | } | 787 | } |
787 | #define pwm_auto(offset) \ | 788 | #define pwm_auto(offset) \ |
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf, | |||
857 | int min; | 858 | int min; |
858 | long val = simple_strtol(buf, NULL, 10); | 859 | long val = simple_strtol(buf, NULL, 10); |
859 | 860 | ||
860 | down(&data->update_lock); | 861 | mutex_lock(&data->update_lock); |
861 | min = TEMP_FROM_REG(data->zone[nr].limit); | 862 | min = TEMP_FROM_REG(data->zone[nr].limit); |
862 | data->zone[nr].off_desired = TEMP_TO_REG(val); | 863 | data->zone[nr].off_desired = TEMP_TO_REG(val); |
863 | data->zone[nr].hyst = HYST_TO_REG(min - val); | 864 | data->zone[nr].hyst = HYST_TO_REG(min - val); |
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf, | |||
871 | (data->zone[2].hyst << 4) | 872 | (data->zone[2].hyst << 4) |
872 | ); | 873 | ); |
873 | } | 874 | } |
874 | up(&data->update_lock); | 875 | mutex_unlock(&data->update_lock); |
875 | return count; | 876 | return count; |
876 | } | 877 | } |
877 | static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) | 878 | static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) |
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf, | |||
886 | struct lm85_data *data = i2c_get_clientdata(client); | 887 | struct lm85_data *data = i2c_get_clientdata(client); |
887 | long val = simple_strtol(buf, NULL, 10); | 888 | long val = simple_strtol(buf, NULL, 10); |
888 | 889 | ||
889 | down(&data->update_lock); | 890 | mutex_lock(&data->update_lock); |
890 | data->zone[nr].limit = TEMP_TO_REG(val); | 891 | data->zone[nr].limit = TEMP_TO_REG(val); |
891 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), | 892 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), |
892 | data->zone[nr].limit); | 893 | data->zone[nr].limit); |
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf, | |||
913 | (data->zone[2].hyst << 4) | 914 | (data->zone[2].hyst << 4) |
914 | ); | 915 | ); |
915 | } | 916 | } |
916 | up(&data->update_lock); | 917 | mutex_unlock(&data->update_lock); |
917 | return count; | 918 | return count; |
918 | } | 919 | } |
919 | static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) | 920 | static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) |
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf, | |||
930 | int min; | 931 | int min; |
931 | long val = simple_strtol(buf, NULL, 10); | 932 | long val = simple_strtol(buf, NULL, 10); |
932 | 933 | ||
933 | down(&data->update_lock); | 934 | mutex_lock(&data->update_lock); |
934 | min = TEMP_FROM_REG(data->zone[nr].limit); | 935 | min = TEMP_FROM_REG(data->zone[nr].limit); |
935 | data->zone[nr].max_desired = TEMP_TO_REG(val); | 936 | data->zone[nr].max_desired = TEMP_TO_REG(val); |
936 | data->zone[nr].range = RANGE_TO_REG( | 937 | data->zone[nr].range = RANGE_TO_REG( |
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf, | |||
938 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 939 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
939 | ((data->zone[nr].range & 0x0f) << 4) | 940 | ((data->zone[nr].range & 0x0f) << 4) |
940 | | (data->autofan[nr].freq & 0x07)); | 941 | | (data->autofan[nr].freq & 0x07)); |
941 | up(&data->update_lock); | 942 | mutex_unlock(&data->update_lock); |
942 | return count; | 943 | return count; |
943 | } | 944 | } |
944 | static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) | 945 | static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) |
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf, | |||
953 | struct lm85_data *data = i2c_get_clientdata(client); | 954 | struct lm85_data *data = i2c_get_clientdata(client); |
954 | long val = simple_strtol(buf, NULL, 10); | 955 | long val = simple_strtol(buf, NULL, 10); |
955 | 956 | ||
956 | down(&data->update_lock); | 957 | mutex_lock(&data->update_lock); |
957 | data->zone[nr].critical = TEMP_TO_REG(val); | 958 | data->zone[nr].critical = TEMP_TO_REG(val); |
958 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), | 959 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), |
959 | data->zone[nr].critical); | 960 | data->zone[nr].critical); |
960 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
961 | return count; | 962 | return count; |
962 | } | 963 | } |
963 | #define temp_auto(offset) \ | 964 | #define temp_auto(offset) \ |
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1149 | /* Fill in the remaining client fields */ | 1150 | /* Fill in the remaining client fields */ |
1150 | data->type = kind; | 1151 | data->type = kind; |
1151 | data->valid = 0; | 1152 | data->valid = 0; |
1152 | init_MUTEX(&data->update_lock); | 1153 | mutex_init(&data->update_lock); |
1153 | 1154 | ||
1154 | /* Tell the I2C layer a new client has arrived */ | 1155 | /* Tell the I2C layer a new client has arrived */ |
1155 | if ((err = i2c_attach_client(new_client))) | 1156 | if ((err = i2c_attach_client(new_client))) |
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1368 | struct lm85_data *data = i2c_get_clientdata(client); | 1369 | struct lm85_data *data = i2c_get_clientdata(client); |
1369 | int i; | 1370 | int i; |
1370 | 1371 | ||
1371 | down(&data->update_lock); | 1372 | mutex_lock(&data->update_lock); |
1372 | 1373 | ||
1373 | if ( !data->valid || | 1374 | if ( !data->valid || |
1374 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { | 1375 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { |
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1571 | 1572 | ||
1572 | data->valid = 1; | 1573 | data->valid = 1; |
1573 | 1574 | ||
1574 | up(&data->update_lock); | 1575 | mutex_unlock(&data->update_lock); |
1575 | 1576 | ||
1576 | return data; | 1577 | return data; |
1577 | } | 1578 | } |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 6ba34c302d8d..e229daf666de 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/hwmon.h> | 60 | #include <linux/hwmon.h> |
61 | #include <linux/hwmon-vid.h> | 61 | #include <linux/hwmon-vid.h> |
62 | #include <linux/err.h> | 62 | #include <linux/err.h> |
63 | #include <linux/mutex.h> | ||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * Addresses to scan | 66 | * Addresses to scan |
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = { | |||
176 | struct lm87_data { | 177 | struct lm87_data { |
177 | struct i2c_client client; | 178 | struct i2c_client client; |
178 | struct class_device *class_dev; | 179 | struct class_device *class_dev; |
179 | struct semaphore update_lock; | 180 | struct mutex update_lock; |
180 | char valid; /* zero until following fields are valid */ | 181 | char valid; /* zero until following fields are valid */ |
181 | unsigned long last_updated; /* In jiffies */ | 182 | unsigned long last_updated; /* In jiffies */ |
182 | 183 | ||
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr) | |||
253 | struct lm87_data *data = i2c_get_clientdata(client); | 254 | struct lm87_data *data = i2c_get_clientdata(client); |
254 | long val = simple_strtol(buf, NULL, 10); | 255 | long val = simple_strtol(buf, NULL, 10); |
255 | 256 | ||
256 | down(&data->update_lock); | 257 | mutex_lock(&data->update_lock); |
257 | data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); | 258 | data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); |
258 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : | 259 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : |
259 | LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); | 260 | LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); |
260 | up(&data->update_lock); | 261 | mutex_unlock(&data->update_lock); |
261 | } | 262 | } |
262 | 263 | ||
263 | static void set_in_max(struct device *dev, const char *buf, int nr) | 264 | static void set_in_max(struct device *dev, const char *buf, int nr) |
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr) | |||
266 | struct lm87_data *data = i2c_get_clientdata(client); | 267 | struct lm87_data *data = i2c_get_clientdata(client); |
267 | long val = simple_strtol(buf, NULL, 10); | 268 | long val = simple_strtol(buf, NULL, 10); |
268 | 269 | ||
269 | down(&data->update_lock); | 270 | mutex_lock(&data->update_lock); |
270 | data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); | 271 | data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); |
271 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : | 272 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : |
272 | LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); | 273 | LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); |
273 | up(&data->update_lock); | 274 | mutex_unlock(&data->update_lock); |
274 | } | 275 | } |
275 | 276 | ||
276 | #define set_in(offset) \ | 277 | #define set_in(offset) \ |
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr) | |||
327 | struct lm87_data *data = i2c_get_clientdata(client); | 328 | struct lm87_data *data = i2c_get_clientdata(client); |
328 | long val = simple_strtol(buf, NULL, 10); | 329 | long val = simple_strtol(buf, NULL, 10); |
329 | 330 | ||
330 | down(&data->update_lock); | 331 | mutex_lock(&data->update_lock); |
331 | data->temp_low[nr] = TEMP_TO_REG(val); | 332 | data->temp_low[nr] = TEMP_TO_REG(val); |
332 | lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); | 333 | lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); |
333 | up(&data->update_lock); | 334 | mutex_unlock(&data->update_lock); |
334 | } | 335 | } |
335 | 336 | ||
336 | static void set_temp_high(struct device *dev, const char *buf, int nr) | 337 | static void set_temp_high(struct device *dev, const char *buf, int nr) |
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr) | |||
339 | struct lm87_data *data = i2c_get_clientdata(client); | 340 | struct lm87_data *data = i2c_get_clientdata(client); |
340 | long val = simple_strtol(buf, NULL, 10); | 341 | long val = simple_strtol(buf, NULL, 10); |
341 | 342 | ||
342 | down(&data->update_lock); | 343 | mutex_lock(&data->update_lock); |
343 | data->temp_high[nr] = TEMP_TO_REG(val); | 344 | data->temp_high[nr] = TEMP_TO_REG(val); |
344 | lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); | 345 | lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); |
345 | up(&data->update_lock); | 346 | mutex_unlock(&data->update_lock); |
346 | } | 347 | } |
347 | 348 | ||
348 | #define set_temp(offset) \ | 349 | #define set_temp(offset) \ |
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr) | |||
411 | struct lm87_data *data = i2c_get_clientdata(client); | 412 | struct lm87_data *data = i2c_get_clientdata(client); |
412 | long val = simple_strtol(buf, NULL, 10); | 413 | long val = simple_strtol(buf, NULL, 10); |
413 | 414 | ||
414 | down(&data->update_lock); | 415 | mutex_lock(&data->update_lock); |
415 | data->fan_min[nr] = FAN_TO_REG(val, | 416 | data->fan_min[nr] = FAN_TO_REG(val, |
416 | FAN_DIV_FROM_REG(data->fan_div[nr])); | 417 | FAN_DIV_FROM_REG(data->fan_div[nr])); |
417 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); | 418 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); |
418 | up(&data->update_lock); | 419 | mutex_unlock(&data->update_lock); |
419 | } | 420 | } |
420 | 421 | ||
421 | /* Note: we save and restore the fan minimum here, because its value is | 422 | /* Note: we save and restore the fan minimum here, because its value is |
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
431 | unsigned long min; | 432 | unsigned long min; |
432 | u8 reg; | 433 | u8 reg; |
433 | 434 | ||
434 | down(&data->update_lock); | 435 | mutex_lock(&data->update_lock); |
435 | min = FAN_FROM_REG(data->fan_min[nr], | 436 | min = FAN_FROM_REG(data->fan_min[nr], |
436 | FAN_DIV_FROM_REG(data->fan_div[nr])); | 437 | FAN_DIV_FROM_REG(data->fan_div[nr])); |
437 | 438 | ||
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
441 | case 4: data->fan_div[nr] = 2; break; | 442 | case 4: data->fan_div[nr] = 2; break; |
442 | case 8: data->fan_div[nr] = 3; break; | 443 | case 8: data->fan_div[nr] = 3; break; |
443 | default: | 444 | default: |
444 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
445 | return -EINVAL; | 446 | return -EINVAL; |
446 | } | 447 | } |
447 | 448 | ||
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
459 | data->fan_min[nr] = FAN_TO_REG(min, val); | 460 | data->fan_min[nr] = FAN_TO_REG(min, val); |
460 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), | 461 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), |
461 | data->fan_min[nr]); | 462 | data->fan_min[nr]); |
462 | up(&data->update_lock); | 463 | mutex_unlock(&data->update_lock); |
463 | 464 | ||
464 | return count; | 465 | return count; |
465 | } | 466 | } |
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const | |||
522 | struct lm87_data *data = i2c_get_clientdata(client); | 523 | struct lm87_data *data = i2c_get_clientdata(client); |
523 | long val = simple_strtol(buf, NULL, 10); | 524 | long val = simple_strtol(buf, NULL, 10); |
524 | 525 | ||
525 | down(&data->update_lock); | 526 | mutex_lock(&data->update_lock); |
526 | data->aout = AOUT_TO_REG(val); | 527 | data->aout = AOUT_TO_REG(val); |
527 | lm87_write_value(client, LM87_REG_AOUT, data->aout); | 528 | lm87_write_value(client, LM87_REG_AOUT, data->aout); |
528 | up(&data->update_lock); | 529 | mutex_unlock(&data->update_lock); |
529 | return count; | 530 | return count; |
530 | } | 531 | } |
531 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 532 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
589 | /* We can fill in the remaining client fields */ | 590 | /* We can fill in the remaining client fields */ |
590 | strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); | 591 | strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); |
591 | data->valid = 0; | 592 | data->valid = 0; |
592 | init_MUTEX(&data->update_lock); | 593 | mutex_init(&data->update_lock); |
593 | 594 | ||
594 | /* Tell the I2C layer a new client has arrived */ | 595 | /* Tell the I2C layer a new client has arrived */ |
595 | if ((err = i2c_attach_client(new_client))) | 596 | if ((err = i2c_attach_client(new_client))) |
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev) | |||
744 | struct i2c_client *client = to_i2c_client(dev); | 745 | struct i2c_client *client = to_i2c_client(dev); |
745 | struct lm87_data *data = i2c_get_clientdata(client); | 746 | struct lm87_data *data = i2c_get_clientdata(client); |
746 | 747 | ||
747 | down(&data->update_lock); | 748 | mutex_lock(&data->update_lock); |
748 | 749 | ||
749 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 750 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
750 | int i, j; | 751 | int i, j; |
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev) | |||
813 | data->valid = 1; | 814 | data->valid = 1; |
814 | } | 815 | } |
815 | 816 | ||
816 | up(&data->update_lock); | 817 | mutex_unlock(&data->update_lock); |
817 | 818 | ||
818 | return data; | 819 | return data; |
819 | } | 820 | } |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 5679464447cc..d9eeaf7585bd 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include <linux/hwmon-sysfs.h> | 78 | #include <linux/hwmon-sysfs.h> |
79 | #include <linux/hwmon.h> | 79 | #include <linux/hwmon.h> |
80 | #include <linux/err.h> | 80 | #include <linux/err.h> |
81 | #include <linux/mutex.h> | ||
81 | 82 | ||
82 | /* | 83 | /* |
83 | * Addresses to scan | 84 | * Addresses to scan |
@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = { | |||
201 | struct lm90_data { | 202 | struct lm90_data { |
202 | struct i2c_client client; | 203 | struct i2c_client client; |
203 | struct class_device *class_dev; | 204 | struct class_device *class_dev; |
204 | struct semaphore update_lock; | 205 | struct mutex update_lock; |
205 | char valid; /* zero until following fields are valid */ | 206 | char valid; /* zero until following fields are valid */ |
206 | unsigned long last_updated; /* in jiffies */ | 207 | unsigned long last_updated; /* in jiffies */ |
207 | int kind; | 208 | int kind; |
@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
247 | long val = simple_strtol(buf, NULL, 10); | 248 | long val = simple_strtol(buf, NULL, 10); |
248 | int nr = attr->index; | 249 | int nr = attr->index; |
249 | 250 | ||
250 | down(&data->update_lock); | 251 | mutex_lock(&data->update_lock); |
251 | if (data->kind == adt7461) | 252 | if (data->kind == adt7461) |
252 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | 253 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); |
253 | else | 254 | else |
254 | data->temp8[nr] = TEMP1_TO_REG(val); | 255 | data->temp8[nr] = TEMP1_TO_REG(val); |
255 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | 256 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); |
256 | up(&data->update_lock); | 257 | mutex_unlock(&data->update_lock); |
257 | return count; | 258 | return count; |
258 | } | 259 | } |
259 | 260 | ||
@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
281 | long val = simple_strtol(buf, NULL, 10); | 282 | long val = simple_strtol(buf, NULL, 10); |
282 | int nr = attr->index; | 283 | int nr = attr->index; |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | if (data->kind == adt7461) | 286 | if (data->kind == adt7461) |
286 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | 287 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); |
287 | else | 288 | else |
@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, | |||
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | long hyst; | 313 | long hyst; |
313 | 314 | ||
314 | down(&data->update_lock); | 315 | mutex_lock(&data->update_lock); |
315 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; | 316 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
316 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 317 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
317 | HYST_TO_REG(hyst)); | 318 | HYST_TO_REG(hyst)); |
318 | up(&data->update_lock); | 319 | mutex_unlock(&data->update_lock); |
319 | return count; | 320 | return count; |
320 | } | 321 | } |
321 | 322 | ||
@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
558 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 559 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
559 | data->valid = 0; | 560 | data->valid = 0; |
560 | data->kind = kind; | 561 | data->kind = kind; |
561 | init_MUTEX(&data->update_lock); | 562 | mutex_init(&data->update_lock); |
562 | 563 | ||
563 | /* Tell the I2C layer a new client has arrived */ | 564 | /* Tell the I2C layer a new client has arrived */ |
564 | if ((err = i2c_attach_client(new_client))) | 565 | if ((err = i2c_attach_client(new_client))) |
@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
646 | struct i2c_client *client = to_i2c_client(dev); | 647 | struct i2c_client *client = to_i2c_client(dev); |
647 | struct lm90_data *data = i2c_get_clientdata(client); | 648 | struct lm90_data *data = i2c_get_clientdata(client); |
648 | 649 | ||
649 | down(&data->update_lock); | 650 | mutex_lock(&data->update_lock); |
650 | 651 | ||
651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 652 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
652 | u8 oldh, newh, l; | 653 | u8 oldh, newh, l; |
@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
692 | data->valid = 1; | 693 | data->valid = 1; |
693 | } | 694 | } |
694 | 695 | ||
695 | up(&data->update_lock); | 696 | mutex_unlock(&data->update_lock); |
696 | 697 | ||
697 | return data; | 698 | return data; |
698 | } | 699 | } |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index b0c4cb730a7e..197f77226dc4 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
47 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
48 | #include <linux/err.h> | 48 | #include <linux/err.h> |
49 | #include <linux/mutex.h> | ||
49 | 50 | ||
50 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, | 51 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, |
51 | resulting in 4 possible addresses. */ | 52 | resulting in 4 possible addresses. */ |
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver; | |||
96 | struct lm92_data { | 97 | struct lm92_data { |
97 | struct i2c_client client; | 98 | struct i2c_client client; |
98 | struct class_device *class_dev; | 99 | struct class_device *class_dev; |
99 | struct semaphore update_lock; | 100 | struct mutex update_lock; |
100 | char valid; /* zero until following fields are valid */ | 101 | char valid; /* zero until following fields are valid */ |
101 | unsigned long last_updated; /* in jiffies */ | 102 | unsigned long last_updated; /* in jiffies */ |
102 | 103 | ||
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
114 | struct i2c_client *client = to_i2c_client(dev); | 115 | struct i2c_client *client = to_i2c_client(dev); |
115 | struct lm92_data *data = i2c_get_clientdata(client); | 116 | struct lm92_data *data = i2c_get_clientdata(client); |
116 | 117 | ||
117 | down(&data->update_lock); | 118 | mutex_lock(&data->update_lock); |
118 | 119 | ||
119 | if (time_after(jiffies, data->last_updated + HZ) | 120 | if (time_after(jiffies, data->last_updated + HZ) |
120 | || !data->valid) { | 121 | || !data->valid) { |
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
134 | data->valid = 1; | 135 | data->valid = 1; |
135 | } | 136 | } |
136 | 137 | ||
137 | up(&data->update_lock); | 138 | mutex_unlock(&data->update_lock); |
138 | 139 | ||
139 | return data; | 140 | return data; |
140 | } | 141 | } |
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
158 | struct lm92_data *data = i2c_get_clientdata(client); \ | 159 | struct lm92_data *data = i2c_get_clientdata(client); \ |
159 | long val = simple_strtol(buf, NULL, 10); \ | 160 | long val = simple_strtol(buf, NULL, 10); \ |
160 | \ | 161 | \ |
161 | down(&data->update_lock); \ | 162 | mutex_lock(&data->update_lock); \ |
162 | data->value = TEMP_TO_REG(val); \ | 163 | data->value = TEMP_TO_REG(val); \ |
163 | i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ | 164 | i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ |
164 | up(&data->update_lock); \ | 165 | mutex_unlock(&data->update_lock); \ |
165 | return count; \ | 166 | return count; \ |
166 | } | 167 | } |
167 | set_temp(temp1_crit, LM92_REG_TEMP_CRIT); | 168 | set_temp(temp1_crit, LM92_REG_TEMP_CRIT); |
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute * | |||
194 | struct lm92_data *data = i2c_get_clientdata(client); | 195 | struct lm92_data *data = i2c_get_clientdata(client); |
195 | long val = simple_strtol(buf, NULL, 10); | 196 | long val = simple_strtol(buf, NULL, 10); |
196 | 197 | ||
197 | down(&data->update_lock); | 198 | mutex_lock(&data->update_lock); |
198 | data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; | 199 | data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; |
199 | i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, | 200 | i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, |
200 | swab16(TEMP_TO_REG(data->temp1_hyst))); | 201 | swab16(TEMP_TO_REG(data->temp1_hyst))); |
201 | up(&data->update_lock); | 202 | mutex_unlock(&data->update_lock); |
202 | return count; | 203 | return count; |
203 | } | 204 | } |
204 | 205 | ||
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | |||
348 | /* Fill in the remaining client fields */ | 349 | /* Fill in the remaining client fields */ |
349 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 350 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
350 | data->valid = 0; | 351 | data->valid = 0; |
351 | init_MUTEX(&data->update_lock); | 352 | mutex_init(&data->update_lock); |
352 | 353 | ||
353 | /* Tell the i2c subsystem a new client has arrived */ | 354 | /* Tell the i2c subsystem a new client has arrived */ |
354 | if ((err = i2c_attach_client(new_client))) | 355 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 3abe330b22ce..b4135b5971f4 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 38 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, |
38 | 0x29, 0x2a, 0x2b, | 39 | 0x29, 0x2a, 0x2b, |
@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = { | |||
104 | struct max1619_data { | 105 | struct max1619_data { |
105 | struct i2c_client client; | 106 | struct i2c_client client; |
106 | struct class_device *class_dev; | 107 | struct class_device *class_dev; |
107 | struct semaphore update_lock; | 108 | struct mutex update_lock; |
108 | char valid; /* zero until following fields are valid */ | 109 | char valid; /* zero until following fields are valid */ |
109 | unsigned long last_updated; /* in jiffies */ | 110 | unsigned long last_updated; /* in jiffies */ |
110 | 111 | ||
@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
141 | struct max1619_data *data = i2c_get_clientdata(client); \ | 142 | struct max1619_data *data = i2c_get_clientdata(client); \ |
142 | long val = simple_strtol(buf, NULL, 10); \ | 143 | long val = simple_strtol(buf, NULL, 10); \ |
143 | \ | 144 | \ |
144 | down(&data->update_lock); \ | 145 | mutex_lock(&data->update_lock); \ |
145 | data->value = TEMP_TO_REG(val); \ | 146 | data->value = TEMP_TO_REG(val); \ |
146 | i2c_smbus_write_byte_data(client, reg, data->value); \ | 147 | i2c_smbus_write_byte_data(client, reg, data->value); \ |
147 | up(&data->update_lock); \ | 148 | mutex_unlock(&data->update_lock); \ |
148 | return count; \ | 149 | return count; \ |
149 | } | 150 | } |
150 | 151 | ||
@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) | |||
262 | /* We can fill in the remaining client fields */ | 263 | /* We can fill in the remaining client fields */ |
263 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 264 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
264 | data->valid = 0; | 265 | data->valid = 0; |
265 | init_MUTEX(&data->update_lock); | 266 | mutex_init(&data->update_lock); |
266 | 267 | ||
267 | /* Tell the I2C layer a new client has arrived */ | 268 | /* Tell the I2C layer a new client has arrived */ |
268 | if ((err = i2c_attach_client(new_client))) | 269 | if ((err = i2c_attach_client(new_client))) |
@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev) | |||
330 | struct i2c_client *client = to_i2c_client(dev); | 331 | struct i2c_client *client = to_i2c_client(dev); |
331 | struct max1619_data *data = i2c_get_clientdata(client); | 332 | struct max1619_data *data = i2c_get_clientdata(client); |
332 | 333 | ||
333 | down(&data->update_lock); | 334 | mutex_lock(&data->update_lock); |
334 | 335 | ||
335 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 336 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
336 | dev_dbg(&client->dev, "Updating max1619 data.\n"); | 337 | dev_dbg(&client->dev, "Updating max1619 data.\n"); |
@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev) | |||
353 | data->valid = 1; | 354 | data->valid = 1; |
354 | } | 355 | } |
355 | 356 | ||
356 | up(&data->update_lock); | 357 | mutex_unlock(&data->update_lock); |
357 | 358 | ||
358 | return data; | 359 | return data; |
359 | } | 360 | } |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index f161e88e3bb6..ae05e483a778 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon-sysfs.h> | 43 | #include <linux/hwmon-sysfs.h> |
44 | #include <linux/hwmon-vid.h> | 44 | #include <linux/hwmon-vid.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 47 | #include <asm/io.h> |
47 | 48 | ||
48 | static u8 devid; | 49 | static u8 devid; |
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv) | |||
183 | struct pc87360_data { | 184 | struct pc87360_data { |
184 | struct i2c_client client; | 185 | struct i2c_client client; |
185 | struct class_device *class_dev; | 186 | struct class_device *class_dev; |
186 | struct semaphore lock; | 187 | struct mutex lock; |
187 | struct semaphore update_lock; | 188 | struct mutex update_lock; |
188 | char valid; /* !=0 if following fields are valid */ | 189 | char valid; /* !=0 if following fields are valid */ |
189 | unsigned long last_updated; /* In jiffies */ | 190 | unsigned long last_updated; /* In jiffies */ |
190 | 191 | ||
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
283 | struct pc87360_data *data = i2c_get_clientdata(client); | 284 | struct pc87360_data *data = i2c_get_clientdata(client); |
284 | long fan_min = simple_strtol(buf, NULL, 10); | 285 | long fan_min = simple_strtol(buf, NULL, 10); |
285 | 286 | ||
286 | down(&data->update_lock); | 287 | mutex_lock(&data->update_lock); |
287 | fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); | 288 | fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); |
288 | 289 | ||
289 | /* If it wouldn't fit, change clock divisor */ | 290 | /* If it wouldn't fit, change clock divisor */ |
@@ -300,23 +301,31 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
300 | /* Write new divider, preserve alarm bits */ | 301 | /* Write new divider, preserve alarm bits */ |
301 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), | 302 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), |
302 | data->fan_status[attr->index] & 0xF9); | 303 | data->fan_status[attr->index] & 0xF9); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | 305 | ||
305 | return count; | 306 | return count; |
306 | } | 307 | } |
307 | 308 | ||
308 | #define show_and_set_fan(offset) \ | 309 | static struct sensor_device_attribute fan_input[] = { |
309 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | 310 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0), |
310 | show_fan_input, NULL, offset-1); \ | 311 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1), |
311 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ | 312 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2), |
312 | show_fan_min, set_fan_min, offset-1); \ | 313 | }; |
313 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 314 | static struct sensor_device_attribute fan_status[] = { |
314 | show_fan_div, NULL, offset-1); \ | 315 | SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0), |
315 | static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ | 316 | SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1), |
316 | show_fan_status, NULL, offset-1); | 317 | SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2), |
317 | show_and_set_fan(1) | 318 | }; |
318 | show_and_set_fan(2) | 319 | static struct sensor_device_attribute fan_div[] = { |
319 | show_and_set_fan(3) | 320 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
321 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), | ||
322 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), | ||
323 | }; | ||
324 | static struct sensor_device_attribute fan_min[] = { | ||
325 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0), | ||
326 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1), | ||
327 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), | ||
328 | }; | ||
320 | 329 | ||
321 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) | 330 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) |
322 | { | 331 | { |
@@ -335,21 +344,20 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con | |||
335 | struct pc87360_data *data = i2c_get_clientdata(client); | 344 | struct pc87360_data *data = i2c_get_clientdata(client); |
336 | long val = simple_strtol(buf, NULL, 10); | 345 | long val = simple_strtol(buf, NULL, 10); |
337 | 346 | ||
338 | down(&data->update_lock); | 347 | mutex_lock(&data->update_lock); |
339 | data->pwm[attr->index] = PWM_TO_REG(val, | 348 | data->pwm[attr->index] = PWM_TO_REG(val, |
340 | FAN_CONFIG_INVERT(data->fan_conf, attr->index)); | 349 | FAN_CONFIG_INVERT(data->fan_conf, attr->index)); |
341 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), | 350 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), |
342 | data->pwm[attr->index]); | 351 | data->pwm[attr->index]); |
343 | up(&data->update_lock); | 352 | mutex_unlock(&data->update_lock); |
344 | return count; | 353 | return count; |
345 | } | 354 | } |
346 | 355 | ||
347 | #define show_and_set_pwm(offset) \ | 356 | static struct sensor_device_attribute pwm[] = { |
348 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ | 357 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0), |
349 | show_pwm, set_pwm, offset-1); | 358 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1), |
350 | show_and_set_pwm(1) | 359 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), |
351 | show_and_set_pwm(2) | 360 | }; |
352 | show_and_set_pwm(3) | ||
353 | 361 | ||
354 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) | 362 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) |
355 | { | 363 | { |
@@ -386,11 +394,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, | |||
386 | struct pc87360_data *data = i2c_get_clientdata(client); | 394 | struct pc87360_data *data = i2c_get_clientdata(client); |
387 | long val = simple_strtol(buf, NULL, 10); | 395 | long val = simple_strtol(buf, NULL, 10); |
388 | 396 | ||
389 | down(&data->update_lock); | 397 | mutex_lock(&data->update_lock); |
390 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | 398 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); |
391 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, | 399 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, |
392 | data->in_min[attr->index]); | 400 | data->in_min[attr->index]); |
393 | up(&data->update_lock); | 401 | mutex_unlock(&data->update_lock); |
394 | return count; | 402 | return count; |
395 | } | 403 | } |
396 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 404 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -401,35 +409,67 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, | |||
401 | struct pc87360_data *data = i2c_get_clientdata(client); | 409 | struct pc87360_data *data = i2c_get_clientdata(client); |
402 | long val = simple_strtol(buf, NULL, 10); | 410 | long val = simple_strtol(buf, NULL, 10); |
403 | 411 | ||
404 | down(&data->update_lock); | 412 | mutex_lock(&data->update_lock); |
405 | data->in_max[attr->index] = IN_TO_REG(val, | 413 | data->in_max[attr->index] = IN_TO_REG(val, |
406 | data->in_vref); | 414 | data->in_vref); |
407 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, | 415 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, |
408 | data->in_max[attr->index]); | 416 | data->in_max[attr->index]); |
409 | up(&data->update_lock); | 417 | mutex_unlock(&data->update_lock); |
410 | return count; | 418 | return count; |
411 | } | 419 | } |
412 | 420 | ||
413 | #define show_and_set_in(offset) \ | 421 | static struct sensor_device_attribute in_input[] = { |
414 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 422 | SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0), |
415 | show_in_input, NULL, offset); \ | 423 | SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1), |
416 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ | 424 | SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2), |
417 | show_in_min, set_in_min, offset); \ | 425 | SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3), |
418 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ | 426 | SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4), |
419 | show_in_max, set_in_max, offset); \ | 427 | SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5), |
420 | static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \ | 428 | SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6), |
421 | show_in_status, NULL, offset); | 429 | SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7), |
422 | show_and_set_in(0) | 430 | SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8), |
423 | show_and_set_in(1) | 431 | SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9), |
424 | show_and_set_in(2) | 432 | SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10), |
425 | show_and_set_in(3) | 433 | }; |
426 | show_and_set_in(4) | 434 | static struct sensor_device_attribute in_status[] = { |
427 | show_and_set_in(5) | 435 | SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0), |
428 | show_and_set_in(6) | 436 | SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1), |
429 | show_and_set_in(7) | 437 | SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2), |
430 | show_and_set_in(8) | 438 | SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3), |
431 | show_and_set_in(9) | 439 | SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4), |
432 | show_and_set_in(10) | 440 | SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5), |
441 | SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6), | ||
442 | SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7), | ||
443 | SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8), | ||
444 | SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9), | ||
445 | SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10), | ||
446 | }; | ||
447 | static struct sensor_device_attribute in_min[] = { | ||
448 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0), | ||
449 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1), | ||
450 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2), | ||
451 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3), | ||
452 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4), | ||
453 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5), | ||
454 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6), | ||
455 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7), | ||
456 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8), | ||
457 | SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9), | ||
458 | SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10), | ||
459 | }; | ||
460 | static struct sensor_device_attribute in_max[] = { | ||
461 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0), | ||
462 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1), | ||
463 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2), | ||
464 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3), | ||
465 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4), | ||
466 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5), | ||
467 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6), | ||
468 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7), | ||
469 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8), | ||
470 | SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9), | ||
471 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), | ||
472 | }; | ||
433 | 473 | ||
434 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) | 474 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) |
435 | { | 475 | { |
@@ -473,11 +513,11 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt | |||
473 | struct pc87360_data *data = i2c_get_clientdata(client); | 513 | struct pc87360_data *data = i2c_get_clientdata(client); |
474 | long val = simple_strtol(buf, NULL, 10); | 514 | long val = simple_strtol(buf, NULL, 10); |
475 | 515 | ||
476 | down(&data->update_lock); | 516 | mutex_lock(&data->update_lock); |
477 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | 517 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); |
478 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, | 518 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, |
479 | data->in_min[attr->index]); | 519 | data->in_min[attr->index]); |
480 | up(&data->update_lock); | 520 | mutex_unlock(&data->update_lock); |
481 | return count; | 521 | return count; |
482 | } | 522 | } |
483 | static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 523 | static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -488,11 +528,11 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt | |||
488 | struct pc87360_data *data = i2c_get_clientdata(client); | 528 | struct pc87360_data *data = i2c_get_clientdata(client); |
489 | long val = simple_strtol(buf, NULL, 10); | 529 | long val = simple_strtol(buf, NULL, 10); |
490 | 530 | ||
491 | down(&data->update_lock); | 531 | mutex_lock(&data->update_lock); |
492 | data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); | 532 | data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); |
493 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, | 533 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, |
494 | data->in_max[attr->index]); | 534 | data->in_max[attr->index]); |
495 | up(&data->update_lock); | 535 | mutex_unlock(&data->update_lock); |
496 | return count; | 536 | return count; |
497 | } | 537 | } |
498 | static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | 538 | static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -503,28 +543,51 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat | |||
503 | struct pc87360_data *data = i2c_get_clientdata(client); | 543 | struct pc87360_data *data = i2c_get_clientdata(client); |
504 | long val = simple_strtol(buf, NULL, 10); | 544 | long val = simple_strtol(buf, NULL, 10); |
505 | 545 | ||
506 | down(&data->update_lock); | 546 | mutex_lock(&data->update_lock); |
507 | data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); | 547 | data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); |
508 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, | 548 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, |
509 | data->in_crit[attr->index-11]); | 549 | data->in_crit[attr->index-11]); |
510 | up(&data->update_lock); | 550 | mutex_unlock(&data->update_lock); |
511 | return count; | 551 | return count; |
512 | } | 552 | } |
513 | 553 | ||
514 | #define show_and_set_therm(offset) \ | 554 | /* the +11 term below reflects the fact that VLM units 11,12,13 are |
515 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 555 | used in the chip to measure voltage across the thermistors |
516 | show_therm_input, NULL, 11+offset-4); \ | 556 | */ |
517 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 557 | static struct sensor_device_attribute therm_input[] = { |
518 | show_therm_min, set_therm_min, 11+offset-4); \ | 558 | SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11), |
519 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | 559 | SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11), |
520 | show_therm_max, set_therm_max, 11+offset-4); \ | 560 | SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11), |
521 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ | 561 | }; |
522 | show_therm_crit, set_therm_crit, 11+offset-4); \ | 562 | static struct sensor_device_attribute therm_status[] = { |
523 | static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ | 563 | SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11), |
524 | show_therm_status, NULL, 11+offset-4); | 564 | SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11), |
525 | show_and_set_therm(4) | 565 | SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11), |
526 | show_and_set_therm(5) | 566 | }; |
527 | show_and_set_therm(6) | 567 | static struct sensor_device_attribute therm_min[] = { |
568 | SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR, | ||
569 | show_therm_min, set_therm_min, 0+11), | ||
570 | SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR, | ||
571 | show_therm_min, set_therm_min, 1+11), | ||
572 | SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR, | ||
573 | show_therm_min, set_therm_min, 2+11), | ||
574 | }; | ||
575 | static struct sensor_device_attribute therm_max[] = { | ||
576 | SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR, | ||
577 | show_therm_max, set_therm_max, 0+11), | ||
578 | SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR, | ||
579 | show_therm_max, set_therm_max, 1+11), | ||
580 | SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR, | ||
581 | show_therm_max, set_therm_max, 2+11), | ||
582 | }; | ||
583 | static struct sensor_device_attribute therm_crit[] = { | ||
584 | SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR, | ||
585 | show_therm_crit, set_therm_crit, 0+11), | ||
586 | SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR, | ||
587 | show_therm_crit, set_therm_crit, 1+11), | ||
588 | SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR, | ||
589 | show_therm_crit, set_therm_crit, 2+11), | ||
590 | }; | ||
528 | 591 | ||
529 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 592 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
530 | { | 593 | { |
@@ -592,11 +655,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr | |||
592 | struct pc87360_data *data = i2c_get_clientdata(client); | 655 | struct pc87360_data *data = i2c_get_clientdata(client); |
593 | long val = simple_strtol(buf, NULL, 10); | 656 | long val = simple_strtol(buf, NULL, 10); |
594 | 657 | ||
595 | down(&data->update_lock); | 658 | mutex_lock(&data->update_lock); |
596 | data->temp_min[attr->index] = TEMP_TO_REG(val); | 659 | data->temp_min[attr->index] = TEMP_TO_REG(val); |
597 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, | 660 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, |
598 | data->temp_min[attr->index]); | 661 | data->temp_min[attr->index]); |
599 | up(&data->update_lock); | 662 | mutex_unlock(&data->update_lock); |
600 | return count; | 663 | return count; |
601 | } | 664 | } |
602 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 665 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -607,11 +670,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr | |||
607 | struct pc87360_data *data = i2c_get_clientdata(client); | 670 | struct pc87360_data *data = i2c_get_clientdata(client); |
608 | long val = simple_strtol(buf, NULL, 10); | 671 | long val = simple_strtol(buf, NULL, 10); |
609 | 672 | ||
610 | down(&data->update_lock); | 673 | mutex_lock(&data->update_lock); |
611 | data->temp_max[attr->index] = TEMP_TO_REG(val); | 674 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
612 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, | 675 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, |
613 | data->temp_max[attr->index]); | 676 | data->temp_max[attr->index]); |
614 | up(&data->update_lock); | 677 | mutex_unlock(&data->update_lock); |
615 | return count; | 678 | return count; |
616 | } | 679 | } |
617 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | 680 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -622,28 +685,48 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt | |||
622 | struct pc87360_data *data = i2c_get_clientdata(client); | 685 | struct pc87360_data *data = i2c_get_clientdata(client); |
623 | long val = simple_strtol(buf, NULL, 10); | 686 | long val = simple_strtol(buf, NULL, 10); |
624 | 687 | ||
625 | down(&data->update_lock); | 688 | mutex_lock(&data->update_lock); |
626 | data->temp_crit[attr->index] = TEMP_TO_REG(val); | 689 | data->temp_crit[attr->index] = TEMP_TO_REG(val); |
627 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, | 690 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, |
628 | data->temp_crit[attr->index]); | 691 | data->temp_crit[attr->index]); |
629 | up(&data->update_lock); | 692 | mutex_unlock(&data->update_lock); |
630 | return count; | 693 | return count; |
631 | } | 694 | } |
632 | 695 | ||
633 | #define show_and_set_temp(offset) \ | 696 | static struct sensor_device_attribute temp_input[] = { |
634 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 697 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0), |
635 | show_temp_input, NULL, offset-1); \ | 698 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1), |
636 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 699 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2), |
637 | show_temp_min, set_temp_min, offset-1); \ | 700 | }; |
638 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | 701 | static struct sensor_device_attribute temp_status[] = { |
639 | show_temp_max, set_temp_max, offset-1); \ | 702 | SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0), |
640 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ | 703 | SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1), |
641 | show_temp_crit, set_temp_crit, offset-1); \ | 704 | SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2), |
642 | static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ | 705 | }; |
643 | show_temp_status, NULL, offset-1); | 706 | static struct sensor_device_attribute temp_min[] = { |
644 | show_and_set_temp(1) | 707 | SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR, |
645 | show_and_set_temp(2) | 708 | show_temp_min, set_temp_min, 0), |
646 | show_and_set_temp(3) | 709 | SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR, |
710 | show_temp_min, set_temp_min, 1), | ||
711 | SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR, | ||
712 | show_temp_min, set_temp_min, 2), | ||
713 | }; | ||
714 | static struct sensor_device_attribute temp_max[] = { | ||
715 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
716 | show_temp_max, set_temp_max, 0), | ||
717 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
718 | show_temp_max, set_temp_max, 1), | ||
719 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
720 | show_temp_max, set_temp_max, 2), | ||
721 | }; | ||
722 | static struct sensor_device_attribute temp_crit[] = { | ||
723 | SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR, | ||
724 | show_temp_crit, set_temp_crit, 0), | ||
725 | SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR, | ||
726 | show_temp_crit, set_temp_crit, 1), | ||
727 | SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR, | ||
728 | show_temp_crit, set_temp_crit, 2), | ||
729 | }; | ||
647 | 730 | ||
648 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 731 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
649 | { | 732 | { |
@@ -749,22 +832,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses | |||
749 | static int pc87360_detect(struct i2c_adapter *adapter) | 832 | static int pc87360_detect(struct i2c_adapter *adapter) |
750 | { | 833 | { |
751 | int i; | 834 | int i; |
752 | struct i2c_client *new_client; | 835 | struct i2c_client *client; |
753 | struct pc87360_data *data; | 836 | struct pc87360_data *data; |
754 | int err = 0; | 837 | int err = 0; |
755 | const char *name = "pc87360"; | 838 | const char *name = "pc87360"; |
756 | int use_thermistors = 0; | 839 | int use_thermistors = 0; |
840 | struct device *dev; | ||
757 | 841 | ||
758 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | 842 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) |
759 | return -ENOMEM; | 843 | return -ENOMEM; |
760 | 844 | ||
761 | new_client = &data->client; | 845 | client = &data->client; |
762 | i2c_set_clientdata(new_client, data); | 846 | dev = &client->dev; |
763 | new_client->addr = address; | 847 | i2c_set_clientdata(client, data); |
764 | init_MUTEX(&data->lock); | 848 | client->addr = address; |
765 | new_client->adapter = adapter; | 849 | mutex_init(&data->lock); |
766 | new_client->driver = &pc87360_driver; | 850 | client->adapter = adapter; |
767 | new_client->flags = 0; | 851 | client->driver = &pc87360_driver; |
852 | client->flags = 0; | ||
768 | 853 | ||
769 | data->fannr = 2; | 854 | data->fannr = 2; |
770 | data->innr = 0; | 855 | data->innr = 0; |
@@ -792,15 +877,15 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
792 | break; | 877 | break; |
793 | } | 878 | } |
794 | 879 | ||
795 | strcpy(new_client->name, name); | 880 | strlcpy(client->name, name, sizeof(client->name)); |
796 | data->valid = 0; | 881 | data->valid = 0; |
797 | init_MUTEX(&data->update_lock); | 882 | mutex_init(&data->update_lock); |
798 | 883 | ||
799 | for (i = 0; i < 3; i++) { | 884 | for (i = 0; i < 3; i++) { |
800 | if (((data->address[i] = extra_isa[i])) | 885 | if (((data->address[i] = extra_isa[i])) |
801 | && !request_region(extra_isa[i], PC87360_EXTENT, | 886 | && !request_region(extra_isa[i], PC87360_EXTENT, |
802 | pc87360_driver.driver.name)) { | 887 | pc87360_driver.driver.name)) { |
803 | dev_err(&new_client->dev, "Region 0x%x-0x%x already " | 888 | dev_err(&client->dev, "Region 0x%x-0x%x already " |
804 | "in use!\n", extra_isa[i], | 889 | "in use!\n", extra_isa[i], |
805 | extra_isa[i]+PC87360_EXTENT-1); | 890 | extra_isa[i]+PC87360_EXTENT-1); |
806 | for (i--; i >= 0; i--) | 891 | for (i--; i >= 0; i--) |
@@ -814,7 +899,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
814 | if (data->fannr) | 899 | if (data->fannr) |
815 | data->fan_conf = confreg[0] | (confreg[1] << 8); | 900 | data->fan_conf = confreg[0] | (confreg[1] << 8); |
816 | 901 | ||
817 | if ((err = i2c_attach_client(new_client))) | 902 | if ((err = i2c_attach_client(client))) |
818 | goto ERROR2; | 903 | goto ERROR2; |
819 | 904 | ||
820 | /* Use the correct reference voltage | 905 | /* Use the correct reference voltage |
@@ -828,7 +913,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
828 | PC87365_REG_TEMP_CONFIG); | 913 | PC87365_REG_TEMP_CONFIG); |
829 | } | 914 | } |
830 | data->in_vref = (i&0x02) ? 3025 : 2966; | 915 | data->in_vref = (i&0x02) ? 3025 : 2966; |
831 | dev_dbg(&new_client->dev, "Using %s reference voltage\n", | 916 | dev_dbg(&client->dev, "Using %s reference voltage\n", |
832 | (i&0x02) ? "external" : "internal"); | 917 | (i&0x02) ? "external" : "internal"); |
833 | 918 | ||
834 | data->vid_conf = confreg[3]; | 919 | data->vid_conf = confreg[3]; |
@@ -847,154 +932,64 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
847 | if (devid == 0xe9 && data->address[1]) /* PC87366 */ | 932 | if (devid == 0xe9 && data->address[1]) /* PC87366 */ |
848 | use_thermistors = confreg[2] & 0x40; | 933 | use_thermistors = confreg[2] & 0x40; |
849 | 934 | ||
850 | pc87360_init_client(new_client, use_thermistors); | 935 | pc87360_init_client(client, use_thermistors); |
851 | } | 936 | } |
852 | 937 | ||
853 | /* Register sysfs hooks */ | 938 | /* Register sysfs hooks */ |
854 | data->class_dev = hwmon_device_register(&new_client->dev); | 939 | data->class_dev = hwmon_device_register(&client->dev); |
855 | if (IS_ERR(data->class_dev)) { | 940 | if (IS_ERR(data->class_dev)) { |
856 | err = PTR_ERR(data->class_dev); | 941 | err = PTR_ERR(data->class_dev); |
857 | goto ERROR3; | 942 | goto ERROR3; |
858 | } | 943 | } |
859 | 944 | ||
860 | if (data->innr) { | 945 | if (data->innr) { |
861 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); | 946 | for (i = 0; i < 11; i++) { |
862 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); | 947 | device_create_file(dev, &in_input[i].dev_attr); |
863 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); | 948 | device_create_file(dev, &in_min[i].dev_attr); |
864 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); | 949 | device_create_file(dev, &in_max[i].dev_attr); |
865 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); | 950 | device_create_file(dev, &in_status[i].dev_attr); |
866 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); | 951 | } |
867 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); | 952 | device_create_file(dev, &dev_attr_cpu0_vid); |
868 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); | 953 | device_create_file(dev, &dev_attr_vrm); |
869 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); | 954 | device_create_file(dev, &dev_attr_alarms_in); |
870 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr); | ||
871 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr); | ||
872 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); | ||
873 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
874 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
875 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
876 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
877 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
878 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
879 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
880 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
881 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr); | ||
882 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr); | ||
883 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); | ||
884 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
885 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
886 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
887 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
888 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
889 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
890 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
891 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
892 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr); | ||
893 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr); | ||
894 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr); | ||
895 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr); | ||
896 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr); | ||
897 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr); | ||
898 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr); | ||
899 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr); | ||
900 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr); | ||
901 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr); | ||
902 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr); | ||
903 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr); | ||
904 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr); | ||
905 | |||
906 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
907 | device_create_file(&new_client->dev, &dev_attr_vrm); | ||
908 | device_create_file(&new_client->dev, &dev_attr_alarms_in); | ||
909 | } | 955 | } |
910 | 956 | ||
911 | if (data->tempnr) { | 957 | if (data->tempnr) { |
912 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); | 958 | for (i = 0; i < data->tempnr; i++) { |
913 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); | 959 | device_create_file(dev, &temp_input[i].dev_attr); |
914 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); | 960 | device_create_file(dev, &temp_min[i].dev_attr); |
915 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); | 961 | device_create_file(dev, &temp_max[i].dev_attr); |
916 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); | 962 | device_create_file(dev, &temp_crit[i].dev_attr); |
917 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); | 963 | device_create_file(dev, &temp_status[i].dev_attr); |
918 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr); | ||
919 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr); | ||
920 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr); | ||
921 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr); | ||
922 | |||
923 | device_create_file(&new_client->dev, &dev_attr_alarms_temp); | ||
924 | } | ||
925 | if (data->tempnr == 3) { | ||
926 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); | ||
927 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); | ||
928 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
929 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr); | ||
930 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr); | ||
931 | } | ||
932 | if (data->innr == 14) { | ||
933 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr); | ||
934 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr); | ||
935 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr); | ||
936 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr); | ||
937 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr); | ||
938 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr); | ||
939 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr); | ||
940 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr); | ||
941 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr); | ||
942 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr); | ||
943 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr); | ||
944 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr); | ||
945 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr); | ||
946 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr); | ||
947 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr); | ||
948 | } | ||
949 | |||
950 | if (data->fannr) { | ||
951 | if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) { | ||
952 | device_create_file(&new_client->dev, | ||
953 | &sensor_dev_attr_fan1_input.dev_attr); | ||
954 | device_create_file(&new_client->dev, | ||
955 | &sensor_dev_attr_fan1_min.dev_attr); | ||
956 | device_create_file(&new_client->dev, | ||
957 | &sensor_dev_attr_fan1_div.dev_attr); | ||
958 | device_create_file(&new_client->dev, | ||
959 | &sensor_dev_attr_fan1_status.dev_attr); | ||
960 | } | 964 | } |
965 | device_create_file(dev, &dev_attr_alarms_temp); | ||
966 | } | ||
961 | 967 | ||
962 | if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { | 968 | if (data->innr == 14) { |
963 | device_create_file(&new_client->dev, | 969 | for (i = 0; i < 3; i++) { |
964 | &sensor_dev_attr_fan2_input.dev_attr); | 970 | device_create_file(dev, &therm_input[i].dev_attr); |
965 | device_create_file(&new_client->dev, | 971 | device_create_file(dev, &therm_min[i].dev_attr); |
966 | &sensor_dev_attr_fan2_min.dev_attr); | 972 | device_create_file(dev, &therm_max[i].dev_attr); |
967 | device_create_file(&new_client->dev, | 973 | device_create_file(dev, &therm_crit[i].dev_attr); |
968 | &sensor_dev_attr_fan2_div.dev_attr); | 974 | device_create_file(dev, &therm_status[i].dev_attr); |
969 | device_create_file(&new_client->dev, | ||
970 | &sensor_dev_attr_fan2_status.dev_attr); | ||
971 | } | 975 | } |
972 | |||
973 | if (FAN_CONFIG_CONTROL(data->fan_conf, 0)) | ||
974 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); | ||
975 | if (FAN_CONFIG_CONTROL(data->fan_conf, 1)) | ||
976 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); | ||
977 | } | 976 | } |
978 | if (data->fannr == 3) { | ||
979 | if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) { | ||
980 | device_create_file(&new_client->dev, | ||
981 | &sensor_dev_attr_fan3_input.dev_attr); | ||
982 | device_create_file(&new_client->dev, | ||
983 | &sensor_dev_attr_fan3_min.dev_attr); | ||
984 | device_create_file(&new_client->dev, | ||
985 | &sensor_dev_attr_fan3_div.dev_attr); | ||
986 | device_create_file(&new_client->dev, | ||
987 | &sensor_dev_attr_fan3_status.dev_attr); | ||
988 | } | ||
989 | 977 | ||
990 | if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) | 978 | for (i = 0; i < data->fannr; i++) { |
991 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); | 979 | if (FAN_CONFIG_MONITOR(data->fan_conf, i)) { |
980 | device_create_file(dev, &fan_input[i].dev_attr); | ||
981 | device_create_file(dev, &fan_min[i].dev_attr); | ||
982 | device_create_file(dev, &fan_div[i].dev_attr); | ||
983 | device_create_file(dev, &fan_status[i].dev_attr); | ||
984 | } | ||
985 | if (FAN_CONFIG_CONTROL(data->fan_conf, i)) | ||
986 | device_create_file(dev, &pwm[i].dev_attr); | ||
992 | } | 987 | } |
993 | 988 | ||
994 | return 0; | 989 | return 0; |
995 | 990 | ||
996 | ERROR3: | 991 | ERROR3: |
997 | i2c_detach_client(new_client); | 992 | i2c_detach_client(client); |
998 | ERROR2: | 993 | ERROR2: |
999 | for (i = 0; i < 3; i++) { | 994 | for (i = 0; i < 3; i++) { |
1000 | if (data->address[i]) { | 995 | if (data->address[i]) { |
@@ -1033,11 +1028,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1033 | { | 1028 | { |
1034 | int res; | 1029 | int res; |
1035 | 1030 | ||
1036 | down(&(data->lock)); | 1031 | mutex_lock(&(data->lock)); |
1037 | if (bank != NO_BANK) | 1032 | if (bank != NO_BANK) |
1038 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); | 1033 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); |
1039 | res = inb_p(data->address[ldi] + reg); | 1034 | res = inb_p(data->address[ldi] + reg); |
1040 | up(&(data->lock)); | 1035 | mutex_unlock(&(data->lock)); |
1041 | 1036 | ||
1042 | return res; | 1037 | return res; |
1043 | } | 1038 | } |
@@ -1045,11 +1040,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1045 | static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, | 1040 | static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, |
1046 | u8 reg, u8 value) | 1041 | u8 reg, u8 value) |
1047 | { | 1042 | { |
1048 | down(&(data->lock)); | 1043 | mutex_lock(&(data->lock)); |
1049 | if (bank != NO_BANK) | 1044 | if (bank != NO_BANK) |
1050 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); | 1045 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); |
1051 | outb_p(value, data->address[ldi] + reg); | 1046 | outb_p(value, data->address[ldi] + reg); |
1052 | up(&(data->lock)); | 1047 | mutex_unlock(&(data->lock)); |
1053 | } | 1048 | } |
1054 | 1049 | ||
1055 | static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | 1050 | static void pc87360_init_client(struct i2c_client *client, int use_thermistors) |
@@ -1071,7 +1066,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1071 | } | 1066 | } |
1072 | 1067 | ||
1073 | nr = data->innr < 11 ? data->innr : 11; | 1068 | nr = data->innr < 11 ? data->innr : 11; |
1074 | for (i=0; i<nr; i++) { | 1069 | for (i = 0; i < nr; i++) { |
1075 | if (init >= init_in[i]) { | 1070 | if (init >= init_in[i]) { |
1076 | /* Forcibly enable voltage channel */ | 1071 | /* Forcibly enable voltage channel */ |
1077 | reg = pc87360_read_value(data, LD_IN, i, | 1072 | reg = pc87360_read_value(data, LD_IN, i, |
@@ -1088,14 +1083,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1088 | 1083 | ||
1089 | /* We can't blindly trust the Super-I/O space configuration bit, | 1084 | /* We can't blindly trust the Super-I/O space configuration bit, |
1090 | most BIOS won't set it properly */ | 1085 | most BIOS won't set it properly */ |
1091 | for (i=11; i<data->innr; i++) { | 1086 | for (i = 11; i < data->innr; i++) { |
1092 | reg = pc87360_read_value(data, LD_IN, i, | 1087 | reg = pc87360_read_value(data, LD_IN, i, |
1093 | PC87365_REG_TEMP_STATUS); | 1088 | PC87365_REG_TEMP_STATUS); |
1094 | use_thermistors = use_thermistors || (reg & 0x01); | 1089 | use_thermistors = use_thermistors || (reg & 0x01); |
1095 | } | 1090 | } |
1096 | 1091 | ||
1097 | i = use_thermistors ? 2 : 0; | 1092 | i = use_thermistors ? 2 : 0; |
1098 | for (; i<data->tempnr; i++) { | 1093 | for (; i < data->tempnr; i++) { |
1099 | if (init >= init_temp[i]) { | 1094 | if (init >= init_temp[i]) { |
1100 | /* Forcibly enable temperature channel */ | 1095 | /* Forcibly enable temperature channel */ |
1101 | reg = pc87360_read_value(data, LD_TEMP, i, | 1096 | reg = pc87360_read_value(data, LD_TEMP, i, |
@@ -1111,7 +1106,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1111 | } | 1106 | } |
1112 | 1107 | ||
1113 | if (use_thermistors) { | 1108 | if (use_thermistors) { |
1114 | for (i=11; i<data->innr; i++) { | 1109 | for (i = 11; i < data->innr; i++) { |
1115 | if (init >= init_in[i]) { | 1110 | if (init >= init_in[i]) { |
1116 | /* The pin may already be used by thermal | 1111 | /* The pin may already be used by thermal |
1117 | diodes */ | 1112 | diodes */ |
@@ -1221,7 +1216,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1221 | struct pc87360_data *data = i2c_get_clientdata(client); | 1216 | struct pc87360_data *data = i2c_get_clientdata(client); |
1222 | u8 i; | 1217 | u8 i; |
1223 | 1218 | ||
1224 | down(&data->update_lock); | 1219 | mutex_lock(&data->update_lock); |
1225 | 1220 | ||
1226 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 1221 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
1227 | dev_dbg(&client->dev, "Data update\n"); | 1222 | dev_dbg(&client->dev, "Data update\n"); |
@@ -1321,7 +1316,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1321 | data->valid = 1; | 1316 | data->valid = 1; |
1322 | } | 1317 | } |
1323 | 1318 | ||
1324 | up(&data->update_lock); | 1319 | mutex_unlock(&data->update_lock); |
1325 | 1320 | ||
1326 | return data; | 1321 | return data; |
1327 | } | 1322 | } |
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 8be5189d9bd9..6f3fda73f70c 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/err.h> | 60 | #include <linux/err.h> |
61 | #include <linux/init.h> | 61 | #include <linux/init.h> |
62 | #include <linux/jiffies.h> | 62 | #include <linux/jiffies.h> |
63 | #include <linux/mutex.h> | ||
63 | #include <asm/io.h> | 64 | #include <asm/io.h> |
64 | 65 | ||
65 | 66 | ||
@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val) | |||
167 | struct sis5595_data { | 168 | struct sis5595_data { |
168 | struct i2c_client client; | 169 | struct i2c_client client; |
169 | struct class_device *class_dev; | 170 | struct class_device *class_dev; |
170 | struct semaphore lock; | 171 | struct mutex lock; |
171 | 172 | ||
172 | struct semaphore update_lock; | 173 | struct mutex update_lock; |
173 | char valid; /* !=0 if following fields are valid */ | 174 | char valid; /* !=0 if following fields are valid */ |
174 | unsigned long last_updated; /* In jiffies */ | 175 | unsigned long last_updated; /* In jiffies */ |
175 | char maxins; /* == 3 if temp enabled, otherwise == 4 */ | 176 | char maxins; /* == 3 if temp enabled, otherwise == 4 */ |
@@ -192,8 +193,8 @@ static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ | |||
192 | static int sis5595_detect(struct i2c_adapter *adapter); | 193 | static int sis5595_detect(struct i2c_adapter *adapter); |
193 | static int sis5595_detach_client(struct i2c_client *client); | 194 | static int sis5595_detach_client(struct i2c_client *client); |
194 | 195 | ||
195 | static int sis5595_read_value(struct i2c_client *client, u8 register); | 196 | static int sis5595_read_value(struct i2c_client *client, u8 reg); |
196 | static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); | 197 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value); |
197 | static struct sis5595_data *sis5595_update_device(struct device *dev); | 198 | static struct sis5595_data *sis5595_update_device(struct device *dev); |
198 | static void sis5595_init_client(struct i2c_client *client); | 199 | static void sis5595_init_client(struct i2c_client *client); |
199 | 200 | ||
@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
231 | struct sis5595_data *data = i2c_get_clientdata(client); | 232 | struct sis5595_data *data = i2c_get_clientdata(client); |
232 | unsigned long val = simple_strtoul(buf, NULL, 10); | 233 | unsigned long val = simple_strtoul(buf, NULL, 10); |
233 | 234 | ||
234 | down(&data->update_lock); | 235 | mutex_lock(&data->update_lock); |
235 | data->in_min[nr] = IN_TO_REG(val); | 236 | data->in_min[nr] = IN_TO_REG(val); |
236 | sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); | 237 | sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); |
237 | up(&data->update_lock); | 238 | mutex_unlock(&data->update_lock); |
238 | return count; | 239 | return count; |
239 | } | 240 | } |
240 | 241 | ||
@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
245 | struct sis5595_data *data = i2c_get_clientdata(client); | 246 | struct sis5595_data *data = i2c_get_clientdata(client); |
246 | unsigned long val = simple_strtoul(buf, NULL, 10); | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); |
247 | 248 | ||
248 | down(&data->update_lock); | 249 | mutex_lock(&data->update_lock); |
249 | data->in_max[nr] = IN_TO_REG(val); | 250 | data->in_max[nr] = IN_TO_REG(val); |
250 | sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); | 251 | sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); |
251 | up(&data->update_lock); | 252 | mutex_unlock(&data->update_lock); |
252 | return count; | 253 | return count; |
253 | } | 254 | } |
254 | 255 | ||
@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, | |||
310 | struct sis5595_data *data = i2c_get_clientdata(client); | 311 | struct sis5595_data *data = i2c_get_clientdata(client); |
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | 313 | ||
313 | down(&data->update_lock); | 314 | mutex_lock(&data->update_lock); |
314 | data->temp_over = TEMP_TO_REG(val); | 315 | data->temp_over = TEMP_TO_REG(val); |
315 | sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); | 316 | sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); |
316 | up(&data->update_lock); | 317 | mutex_unlock(&data->update_lock); |
317 | return count; | 318 | return count; |
318 | } | 319 | } |
319 | 320 | ||
@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, | |||
329 | struct sis5595_data *data = i2c_get_clientdata(client); | 330 | struct sis5595_data *data = i2c_get_clientdata(client); |
330 | long val = simple_strtol(buf, NULL, 10); | 331 | long val = simple_strtol(buf, NULL, 10); |
331 | 332 | ||
332 | down(&data->update_lock); | 333 | mutex_lock(&data->update_lock); |
333 | data->temp_hyst = TEMP_TO_REG(val); | 334 | data->temp_hyst = TEMP_TO_REG(val); |
334 | sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); | 335 | sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); |
335 | up(&data->update_lock); | 336 | mutex_unlock(&data->update_lock); |
336 | return count; | 337 | return count; |
337 | } | 338 | } |
338 | 339 | ||
@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
364 | struct sis5595_data *data = i2c_get_clientdata(client); | 365 | struct sis5595_data *data = i2c_get_clientdata(client); |
365 | unsigned long val = simple_strtoul(buf, NULL, 10); | 366 | unsigned long val = simple_strtoul(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 369 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
369 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); | 370 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
390 | unsigned long val = simple_strtoul(buf, NULL, 10); | 391 | unsigned long val = simple_strtoul(buf, NULL, 10); |
391 | int reg; | 392 | int reg; |
392 | 393 | ||
393 | down(&data->update_lock); | 394 | mutex_lock(&data->update_lock); |
394 | min = FAN_FROM_REG(data->fan_min[nr], | 395 | min = FAN_FROM_REG(data->fan_min[nr], |
395 | DIV_FROM_REG(data->fan_div[nr])); | 396 | DIV_FROM_REG(data->fan_div[nr])); |
396 | reg = sis5595_read_value(client, SIS5595_REG_FANDIV); | 397 | reg = sis5595_read_value(client, SIS5595_REG_FANDIV); |
@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
403 | default: | 404 | default: |
404 | dev_err(&client->dev, "fan_div value %ld not " | 405 | dev_err(&client->dev, "fan_div value %ld not " |
405 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 406 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
406 | up(&data->update_lock); | 407 | mutex_unlock(&data->update_lock); |
407 | return -EINVAL; | 408 | return -EINVAL; |
408 | } | 409 | } |
409 | 410 | ||
@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
419 | data->fan_min[nr] = | 420 | data->fan_min[nr] = |
420 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 421 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
421 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); | 422 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); |
422 | up(&data->update_lock); | 423 | mutex_unlock(&data->update_lock); |
423 | return count; | 424 | return count; |
424 | } | 425 | } |
425 | 426 | ||
@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
527 | 528 | ||
528 | new_client = &data->client; | 529 | new_client = &data->client; |
529 | new_client->addr = address; | 530 | new_client->addr = address; |
530 | init_MUTEX(&data->lock); | 531 | mutex_init(&data->lock); |
531 | i2c_set_clientdata(new_client, data); | 532 | i2c_set_clientdata(new_client, data); |
532 | new_client->adapter = adapter; | 533 | new_client->adapter = adapter; |
533 | new_client->driver = &sis5595_driver; | 534 | new_client->driver = &sis5595_driver; |
@@ -548,7 +549,7 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
548 | strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); | 549 | strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); |
549 | 550 | ||
550 | data->valid = 0; | 551 | data->valid = 0; |
551 | init_MUTEX(&data->update_lock); | 552 | mutex_init(&data->update_lock); |
552 | 553 | ||
553 | /* Tell the I2C layer a new client has arrived */ | 554 | /* Tell the I2C layer a new client has arrived */ |
554 | if ((err = i2c_attach_client(new_client))) | 555 | if ((err = i2c_attach_client(new_client))) |
@@ -635,20 +636,20 @@ static int sis5595_read_value(struct i2c_client *client, u8 reg) | |||
635 | int res; | 636 | int res; |
636 | 637 | ||
637 | struct sis5595_data *data = i2c_get_clientdata(client); | 638 | struct sis5595_data *data = i2c_get_clientdata(client); |
638 | down(&data->lock); | 639 | mutex_lock(&data->lock); |
639 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); | 640 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); |
640 | res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); | 641 | res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); |
641 | up(&data->lock); | 642 | mutex_unlock(&data->lock); |
642 | return res; | 643 | return res; |
643 | } | 644 | } |
644 | 645 | ||
645 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) | 646 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) |
646 | { | 647 | { |
647 | struct sis5595_data *data = i2c_get_clientdata(client); | 648 | struct sis5595_data *data = i2c_get_clientdata(client); |
648 | down(&data->lock); | 649 | mutex_lock(&data->lock); |
649 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); | 650 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); |
650 | outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); | 651 | outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); |
651 | up(&data->lock); | 652 | mutex_unlock(&data->lock); |
652 | return 0; | 653 | return 0; |
653 | } | 654 | } |
654 | 655 | ||
@@ -667,7 +668,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev) | |||
667 | struct sis5595_data *data = i2c_get_clientdata(client); | 668 | struct sis5595_data *data = i2c_get_clientdata(client); |
668 | int i; | 669 | int i; |
669 | 670 | ||
670 | down(&data->update_lock); | 671 | mutex_lock(&data->update_lock); |
671 | 672 | ||
672 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 673 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
673 | || !data->valid) { | 674 | || !data->valid) { |
@@ -707,7 +708,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev) | |||
707 | data->valid = 1; | 708 | data->valid = 1; |
708 | } | 709 | } |
709 | 710 | ||
710 | up(&data->update_lock); | 711 | mutex_unlock(&data->update_lock); |
711 | 712 | ||
712 | return data; | 713 | return data; |
713 | } | 714 | } |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 8663bbbe97f5..b6086186d225 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon.h> | 35 | #include <linux/hwmon.h> |
36 | #include <linux/err.h> | 36 | #include <linux/err.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | /* Address is autodetected, there is no default value */ | 41 | /* Address is autodetected, there is no default value */ |
@@ -92,9 +93,9 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80}; | |||
92 | struct smsc47b397_data { | 93 | struct smsc47b397_data { |
93 | struct i2c_client client; | 94 | struct i2c_client client; |
94 | struct class_device *class_dev; | 95 | struct class_device *class_dev; |
95 | struct semaphore lock; | 96 | struct mutex lock; |
96 | 97 | ||
97 | struct semaphore update_lock; | 98 | struct mutex update_lock; |
98 | unsigned long last_updated; /* in jiffies */ | 99 | unsigned long last_updated; /* in jiffies */ |
99 | int valid; | 100 | int valid; |
100 | 101 | ||
@@ -108,10 +109,10 @@ static int smsc47b397_read_value(struct i2c_client *client, u8 reg) | |||
108 | struct smsc47b397_data *data = i2c_get_clientdata(client); | 109 | struct smsc47b397_data *data = i2c_get_clientdata(client); |
109 | int res; | 110 | int res; |
110 | 111 | ||
111 | down(&data->lock); | 112 | mutex_lock(&data->lock); |
112 | outb(reg, client->addr); | 113 | outb(reg, client->addr); |
113 | res = inb_p(client->addr + 1); | 114 | res = inb_p(client->addr + 1); |
114 | up(&data->lock); | 115 | mutex_unlock(&data->lock); |
115 | return res; | 116 | return res; |
116 | } | 117 | } |
117 | 118 | ||
@@ -121,7 +122,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) | |||
121 | struct smsc47b397_data *data = i2c_get_clientdata(client); | 122 | struct smsc47b397_data *data = i2c_get_clientdata(client); |
122 | int i; | 123 | int i; |
123 | 124 | ||
124 | down(&data->update_lock); | 125 | mutex_lock(&data->update_lock); |
125 | 126 | ||
126 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 127 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
127 | dev_dbg(&client->dev, "starting device update...\n"); | 128 | dev_dbg(&client->dev, "starting device update...\n"); |
@@ -144,7 +145,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) | |||
144 | dev_dbg(&client->dev, "... device update complete\n"); | 145 | dev_dbg(&client->dev, "... device update complete\n"); |
145 | } | 146 | } |
146 | 147 | ||
147 | up(&data->update_lock); | 148 | mutex_unlock(&data->update_lock); |
148 | 149 | ||
149 | return data; | 150 | return data; |
150 | } | 151 | } |
@@ -254,14 +255,14 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) | |||
254 | new_client = &data->client; | 255 | new_client = &data->client; |
255 | i2c_set_clientdata(new_client, data); | 256 | i2c_set_clientdata(new_client, data); |
256 | new_client->addr = address; | 257 | new_client->addr = address; |
257 | init_MUTEX(&data->lock); | 258 | mutex_init(&data->lock); |
258 | new_client->adapter = adapter; | 259 | new_client->adapter = adapter; |
259 | new_client->driver = &smsc47b397_driver; | 260 | new_client->driver = &smsc47b397_driver; |
260 | new_client->flags = 0; | 261 | new_client->flags = 0; |
261 | 262 | ||
262 | strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); | 263 | strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); |
263 | 264 | ||
264 | init_MUTEX(&data->update_lock); | 265 | mutex_init(&data->update_lock); |
265 | 266 | ||
266 | if ((err = i2c_attach_client(new_client))) | 267 | if ((err = i2c_attach_client(new_client))) |
267 | goto error_free; | 268 | goto error_free; |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index d1e3ec0fe4df..7732aec54594 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <asm/io.h> | 38 | #include <asm/io.h> |
38 | 39 | ||
39 | /* Address is autodetected, there is no default value */ | 40 | /* Address is autodetected, there is no default value */ |
@@ -102,9 +103,9 @@ superio_exit(void) | |||
102 | struct smsc47m1_data { | 103 | struct smsc47m1_data { |
103 | struct i2c_client client; | 104 | struct i2c_client client; |
104 | struct class_device *class_dev; | 105 | struct class_device *class_dev; |
105 | struct semaphore lock; | 106 | struct mutex lock; |
106 | 107 | ||
107 | struct semaphore update_lock; | 108 | struct mutex update_lock; |
108 | unsigned long last_updated; /* In jiffies */ | 109 | unsigned long last_updated; /* In jiffies */ |
109 | 110 | ||
110 | u8 fan[2]; /* Register value */ | 111 | u8 fan[2]; /* Register value */ |
@@ -188,18 +189,18 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
188 | struct smsc47m1_data *data = i2c_get_clientdata(client); | 189 | struct smsc47m1_data *data = i2c_get_clientdata(client); |
189 | long rpmdiv, val = simple_strtol(buf, NULL, 10); | 190 | long rpmdiv, val = simple_strtol(buf, NULL, 10); |
190 | 191 | ||
191 | down(&data->update_lock); | 192 | mutex_lock(&data->update_lock); |
192 | rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); | 193 | rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); |
193 | 194 | ||
194 | if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { | 195 | if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { |
195 | up(&data->update_lock); | 196 | mutex_unlock(&data->update_lock); |
196 | return -EINVAL; | 197 | return -EINVAL; |
197 | } | 198 | } |
198 | 199 | ||
199 | data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); | 200 | data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); |
200 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), | 201 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), |
201 | data->fan_preload[nr]); | 202 | data->fan_preload[nr]); |
202 | up(&data->update_lock); | 203 | mutex_unlock(&data->update_lock); |
203 | 204 | ||
204 | return count; | 205 | return count; |
205 | } | 206 | } |
@@ -220,14 +221,14 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
220 | if (new_div == old_div) /* No change */ | 221 | if (new_div == old_div) /* No change */ |
221 | return count; | 222 | return count; |
222 | 223 | ||
223 | down(&data->update_lock); | 224 | mutex_lock(&data->update_lock); |
224 | switch (new_div) { | 225 | switch (new_div) { |
225 | case 1: data->fan_div[nr] = 0; break; | 226 | case 1: data->fan_div[nr] = 0; break; |
226 | case 2: data->fan_div[nr] = 1; break; | 227 | case 2: data->fan_div[nr] = 1; break; |
227 | case 4: data->fan_div[nr] = 2; break; | 228 | case 4: data->fan_div[nr] = 2; break; |
228 | case 8: data->fan_div[nr] = 3; break; | 229 | case 8: data->fan_div[nr] = 3; break; |
229 | default: | 230 | default: |
230 | up(&data->update_lock); | 231 | mutex_unlock(&data->update_lock); |
231 | return -EINVAL; | 232 | return -EINVAL; |
232 | } | 233 | } |
233 | 234 | ||
@@ -241,7 +242,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
241 | data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); | 242 | data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); |
242 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), | 243 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), |
243 | data->fan_preload[nr]); | 244 | data->fan_preload[nr]); |
244 | up(&data->update_lock); | 245 | mutex_unlock(&data->update_lock); |
245 | 246 | ||
246 | return count; | 247 | return count; |
247 | } | 248 | } |
@@ -257,12 +258,12 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
257 | if (val < 0 || val > 255) | 258 | if (val < 0 || val > 255) |
258 | return -EINVAL; | 259 | return -EINVAL; |
259 | 260 | ||
260 | down(&data->update_lock); | 261 | mutex_lock(&data->update_lock); |
261 | data->pwm[nr] &= 0x81; /* Preserve additional bits */ | 262 | data->pwm[nr] &= 0x81; /* Preserve additional bits */ |
262 | data->pwm[nr] |= PWM_TO_REG(val); | 263 | data->pwm[nr] |= PWM_TO_REG(val); |
263 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), | 264 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), |
264 | data->pwm[nr]); | 265 | data->pwm[nr]); |
265 | up(&data->update_lock); | 266 | mutex_unlock(&data->update_lock); |
266 | 267 | ||
267 | return count; | 268 | return count; |
268 | } | 269 | } |
@@ -278,12 +279,12 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf, | |||
278 | if (val != 0 && val != 1) | 279 | if (val != 0 && val != 1) |
279 | return -EINVAL; | 280 | return -EINVAL; |
280 | 281 | ||
281 | down(&data->update_lock); | 282 | mutex_lock(&data->update_lock); |
282 | data->pwm[nr] &= 0xFE; /* preserve the other bits */ | 283 | data->pwm[nr] &= 0xFE; /* preserve the other bits */ |
283 | data->pwm[nr] |= !val; | 284 | data->pwm[nr] |= !val; |
284 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), | 285 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), |
285 | data->pwm[nr]); | 286 | data->pwm[nr]); |
286 | up(&data->update_lock); | 287 | mutex_unlock(&data->update_lock); |
287 | 288 | ||
288 | return count; | 289 | return count; |
289 | } | 290 | } |
@@ -408,13 +409,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) | |||
408 | new_client = &data->client; | 409 | new_client = &data->client; |
409 | i2c_set_clientdata(new_client, data); | 410 | i2c_set_clientdata(new_client, data); |
410 | new_client->addr = address; | 411 | new_client->addr = address; |
411 | init_MUTEX(&data->lock); | 412 | mutex_init(&data->lock); |
412 | new_client->adapter = adapter; | 413 | new_client->adapter = adapter; |
413 | new_client->driver = &smsc47m1_driver; | 414 | new_client->driver = &smsc47m1_driver; |
414 | new_client->flags = 0; | 415 | new_client->flags = 0; |
415 | 416 | ||
416 | strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); | 417 | strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); |
417 | init_MUTEX(&data->update_lock); | 418 | mutex_init(&data->update_lock); |
418 | 419 | ||
419 | /* If no function is properly configured, there's no point in | 420 | /* If no function is properly configured, there's no point in |
420 | actually registering the chip. */ | 421 | actually registering the chip. */ |
@@ -512,17 +513,17 @@ static int smsc47m1_read_value(struct i2c_client *client, u8 reg) | |||
512 | { | 513 | { |
513 | int res; | 514 | int res; |
514 | 515 | ||
515 | down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 516 | mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
516 | res = inb_p(client->addr + reg); | 517 | res = inb_p(client->addr + reg); |
517 | up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 518 | mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
518 | return res; | 519 | return res; |
519 | } | 520 | } |
520 | 521 | ||
521 | static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) | 522 | static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) |
522 | { | 523 | { |
523 | down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 524 | mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
524 | outb_p(value, client->addr + reg); | 525 | outb_p(value, client->addr + reg); |
525 | up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 526 | mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
526 | } | 527 | } |
527 | 528 | ||
528 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | 529 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, |
@@ -531,7 +532,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | |||
531 | struct i2c_client *client = to_i2c_client(dev); | 532 | struct i2c_client *client = to_i2c_client(dev); |
532 | struct smsc47m1_data *data = i2c_get_clientdata(client); | 533 | struct smsc47m1_data *data = i2c_get_clientdata(client); |
533 | 534 | ||
534 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
535 | 536 | ||
536 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { | 537 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { |
537 | int i; | 538 | int i; |
@@ -558,7 +559,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | |||
558 | data->last_updated = jiffies; | 559 | data->last_updated = jiffies; |
559 | } | 560 | } |
560 | 561 | ||
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return data; | 563 | return data; |
563 | } | 564 | } |
564 | 565 | ||
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index cb01848729b5..166298f1f190 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/err.h> | 40 | #include <linux/err.h> |
41 | #include <linux/init.h> | 41 | #include <linux/init.h> |
42 | #include <linux/mutex.h> | ||
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
43 | 44 | ||
44 | 45 | ||
@@ -296,7 +297,7 @@ static inline long TEMP_FROM_REG10(u16 val) | |||
296 | struct via686a_data { | 297 | struct via686a_data { |
297 | struct i2c_client client; | 298 | struct i2c_client client; |
298 | struct class_device *class_dev; | 299 | struct class_device *class_dev; |
299 | struct semaphore update_lock; | 300 | struct mutex update_lock; |
300 | char valid; /* !=0 if following fields are valid */ | 301 | char valid; /* !=0 if following fields are valid */ |
301 | unsigned long last_updated; /* In jiffies */ | 302 | unsigned long last_updated; /* In jiffies */ |
302 | 303 | ||
@@ -355,11 +356,11 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
355 | struct via686a_data *data = i2c_get_clientdata(client); | 356 | struct via686a_data *data = i2c_get_clientdata(client); |
356 | unsigned long val = simple_strtoul(buf, NULL, 10); | 357 | unsigned long val = simple_strtoul(buf, NULL, 10); |
357 | 358 | ||
358 | down(&data->update_lock); | 359 | mutex_lock(&data->update_lock); |
359 | data->in_min[nr] = IN_TO_REG(val, nr); | 360 | data->in_min[nr] = IN_TO_REG(val, nr); |
360 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), | 361 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), |
361 | data->in_min[nr]); | 362 | data->in_min[nr]); |
362 | up(&data->update_lock); | 363 | mutex_unlock(&data->update_lock); |
363 | return count; | 364 | return count; |
364 | } | 365 | } |
365 | static ssize_t set_in_max(struct device *dev, const char *buf, | 366 | static ssize_t set_in_max(struct device *dev, const char *buf, |
@@ -368,11 +369,11 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
368 | struct via686a_data *data = i2c_get_clientdata(client); | 369 | struct via686a_data *data = i2c_get_clientdata(client); |
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | 370 | unsigned long val = simple_strtoul(buf, NULL, 10); |
370 | 371 | ||
371 | down(&data->update_lock); | 372 | mutex_lock(&data->update_lock); |
372 | data->in_max[nr] = IN_TO_REG(val, nr); | 373 | data->in_max[nr] = IN_TO_REG(val, nr); |
373 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), | 374 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), |
374 | data->in_max[nr]); | 375 | data->in_max[nr]); |
375 | up(&data->update_lock); | 376 | mutex_unlock(&data->update_lock); |
376 | return count; | 377 | return count; |
377 | } | 378 | } |
378 | #define show_in_offset(offset) \ | 379 | #define show_in_offset(offset) \ |
@@ -432,11 +433,11 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, | |||
432 | struct via686a_data *data = i2c_get_clientdata(client); | 433 | struct via686a_data *data = i2c_get_clientdata(client); |
433 | int val = simple_strtol(buf, NULL, 10); | 434 | int val = simple_strtol(buf, NULL, 10); |
434 | 435 | ||
435 | down(&data->update_lock); | 436 | mutex_lock(&data->update_lock); |
436 | data->temp_over[nr] = TEMP_TO_REG(val); | 437 | data->temp_over[nr] = TEMP_TO_REG(val); |
437 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], | 438 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], |
438 | data->temp_over[nr]); | 439 | data->temp_over[nr]); |
439 | up(&data->update_lock); | 440 | mutex_unlock(&data->update_lock); |
440 | return count; | 441 | return count; |
441 | } | 442 | } |
442 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, | 443 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, |
@@ -445,11 +446,11 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf, | |||
445 | struct via686a_data *data = i2c_get_clientdata(client); | 446 | struct via686a_data *data = i2c_get_clientdata(client); |
446 | int val = simple_strtol(buf, NULL, 10); | 447 | int val = simple_strtol(buf, NULL, 10); |
447 | 448 | ||
448 | down(&data->update_lock); | 449 | mutex_lock(&data->update_lock); |
449 | data->temp_hyst[nr] = TEMP_TO_REG(val); | 450 | data->temp_hyst[nr] = TEMP_TO_REG(val); |
450 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], | 451 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], |
451 | data->temp_hyst[nr]); | 452 | data->temp_hyst[nr]); |
452 | up(&data->update_lock); | 453 | mutex_unlock(&data->update_lock); |
453 | return count; | 454 | return count; |
454 | } | 455 | } |
455 | #define show_temp_offset(offset) \ | 456 | #define show_temp_offset(offset) \ |
@@ -508,10 +509,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
508 | struct via686a_data *data = i2c_get_clientdata(client); | 509 | struct via686a_data *data = i2c_get_clientdata(client); |
509 | int val = simple_strtol(buf, NULL, 10); | 510 | int val = simple_strtol(buf, NULL, 10); |
510 | 511 | ||
511 | down(&data->update_lock); | 512 | mutex_lock(&data->update_lock); |
512 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 513 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
513 | via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 514 | via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
514 | up(&data->update_lock); | 515 | mutex_unlock(&data->update_lock); |
515 | return count; | 516 | return count; |
516 | } | 517 | } |
517 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 518 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
@@ -521,12 +522,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
521 | int val = simple_strtol(buf, NULL, 10); | 522 | int val = simple_strtol(buf, NULL, 10); |
522 | int old; | 523 | int old; |
523 | 524 | ||
524 | down(&data->update_lock); | 525 | mutex_lock(&data->update_lock); |
525 | old = via686a_read_value(client, VIA686A_REG_FANDIV); | 526 | old = via686a_read_value(client, VIA686A_REG_FANDIV); |
526 | data->fan_div[nr] = DIV_TO_REG(val); | 527 | data->fan_div[nr] = DIV_TO_REG(val); |
527 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 528 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
528 | via686a_write_value(client, VIA686A_REG_FANDIV, old); | 529 | via686a_write_value(client, VIA686A_REG_FANDIV, old); |
529 | up(&data->update_lock); | 530 | mutex_unlock(&data->update_lock); |
530 | return count; | 531 | return count; |
531 | } | 532 | } |
532 | 533 | ||
@@ -639,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
639 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 640 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
640 | 641 | ||
641 | data->valid = 0; | 642 | data->valid = 0; |
642 | init_MUTEX(&data->update_lock); | 643 | mutex_init(&data->update_lock); |
643 | /* Tell the I2C layer a new client has arrived */ | 644 | /* Tell the I2C layer a new client has arrived */ |
644 | if ((err = i2c_attach_client(new_client))) | 645 | if ((err = i2c_attach_client(new_client))) |
645 | goto exit_free; | 646 | goto exit_free; |
@@ -733,7 +734,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
733 | struct via686a_data *data = i2c_get_clientdata(client); | 734 | struct via686a_data *data = i2c_get_clientdata(client); |
734 | int i; | 735 | int i; |
735 | 736 | ||
736 | down(&data->update_lock); | 737 | mutex_lock(&data->update_lock); |
737 | 738 | ||
738 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 739 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
739 | || !data->valid) { | 740 | || !data->valid) { |
@@ -788,7 +789,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
788 | data->valid = 1; | 789 | data->valid = 1; |
789 | } | 790 | } |
790 | 791 | ||
791 | up(&data->update_lock); | 792 | mutex_unlock(&data->update_lock); |
792 | 793 | ||
793 | return data; | 794 | return data; |
794 | } | 795 | } |
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 271e9cb9532c..686f3deb3093 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon-vid.h> | 36 | #include <linux/hwmon-vid.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | static int force_addr; | 41 | static int force_addr; |
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
148 | 149 | ||
149 | struct vt8231_data { | 150 | struct vt8231_data { |
150 | struct i2c_client client; | 151 | struct i2c_client client; |
151 | struct semaphore update_lock; | 152 | struct mutex update_lock; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | char valid; /* !=0 if following fields are valid */ | 154 | char valid; /* !=0 if following fields are valid */ |
154 | unsigned long last_updated; /* In jiffies */ | 155 | unsigned long last_updated; /* In jiffies */ |
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
223 | struct vt8231_data *data = i2c_get_clientdata(client); | 224 | struct vt8231_data *data = i2c_get_clientdata(client); |
224 | unsigned long val = simple_strtoul(buf, NULL, 10); | 225 | unsigned long val = simple_strtoul(buf, NULL, 10); |
225 | 226 | ||
226 | down(&data->update_lock); | 227 | mutex_lock(&data->update_lock); |
227 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 228 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
228 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); | 229 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); |
229 | up(&data->update_lock); | 230 | mutex_unlock(&data->update_lock); |
230 | return count; | 231 | return count; |
231 | } | 232 | } |
232 | 233 | ||
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
239 | struct vt8231_data *data = i2c_get_clientdata(client); | 240 | struct vt8231_data *data = i2c_get_clientdata(client); |
240 | unsigned long val = simple_strtoul(buf, NULL, 10); | 241 | unsigned long val = simple_strtoul(buf, NULL, 10); |
241 | 242 | ||
242 | down(&data->update_lock); | 243 | mutex_lock(&data->update_lock); |
243 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 244 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
244 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); | 245 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); |
245 | up(&data->update_lock); | 246 | mutex_unlock(&data->update_lock); |
246 | return count; | 247 | return count; |
247 | } | 248 | } |
248 | 249 | ||
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, | |||
281 | struct vt8231_data *data = i2c_get_clientdata(client); | 282 | struct vt8231_data *data = i2c_get_clientdata(client); |
282 | unsigned long val = simple_strtoul(buf, NULL, 10); | 283 | unsigned long val = simple_strtoul(buf, NULL, 10); |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 286 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
286 | 0, 255); | 287 | 0, 255); |
287 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); | 288 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); |
288 | up(&data->update_lock); | 289 | mutex_unlock(&data->update_lock); |
289 | return count; | 290 | return count; |
290 | } | 291 | } |
291 | 292 | ||
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, | |||
296 | struct vt8231_data *data = i2c_get_clientdata(client); | 297 | struct vt8231_data *data = i2c_get_clientdata(client); |
297 | unsigned long val = simple_strtoul(buf, NULL, 10); | 298 | unsigned long val = simple_strtoul(buf, NULL, 10); |
298 | 299 | ||
299 | down(&data->update_lock); | 300 | mutex_lock(&data->update_lock); |
300 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 301 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
301 | 0, 255); | 302 | 0, 255); |
302 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); | 303 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | return count; | 305 | return count; |
305 | } | 306 | } |
306 | 307 | ||
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, | |||
351 | struct vt8231_data *data = i2c_get_clientdata(client); | 352 | struct vt8231_data *data = i2c_get_clientdata(client); |
352 | int val = simple_strtol(buf, NULL, 10); | 353 | int val = simple_strtol(buf, NULL, 10); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 356 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
356 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); | 357 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); |
357 | up(&data->update_lock); | 358 | mutex_unlock(&data->update_lock); |
358 | return count; | 359 | return count; |
359 | } | 360 | } |
360 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | 361 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, |
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | |||
364 | struct vt8231_data *data = i2c_get_clientdata(client); | 365 | struct vt8231_data *data = i2c_get_clientdata(client); |
365 | int val = simple_strtol(buf, NULL, 10); | 366 | int val = simple_strtol(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 369 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
369 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); | 370 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
407 | struct vt8231_data *data = i2c_get_clientdata(client); | 408 | struct vt8231_data *data = i2c_get_clientdata(client); |
408 | int val = simple_strtol(buf, NULL, 10); | 409 | int val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 412 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
412 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); | 413 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 417 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
422 | struct vt8231_data *data = i2c_get_clientdata(client); | 423 | struct vt8231_data *data = i2c_get_clientdata(client); |
423 | int val = simple_strtol(buf, NULL, 10); | 424 | int val = simple_strtol(buf, NULL, 10); |
424 | 425 | ||
425 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
426 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 427 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
427 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); | 428 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); |
428 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
429 | return count; | 430 | return count; |
430 | } | 431 | } |
431 | 432 | ||
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
520 | struct vt8231_data *data = i2c_get_clientdata(client); | 521 | struct vt8231_data *data = i2c_get_clientdata(client); |
521 | int val = simple_strtoul(buf, NULL, 10); | 522 | int val = simple_strtoul(buf, NULL, 10); |
522 | 523 | ||
523 | down(&data->update_lock); | 524 | mutex_lock(&data->update_lock); |
524 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 525 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
525 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); | 526 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); |
526 | up(&data->update_lock); | 527 | mutex_unlock(&data->update_lock); |
527 | return count; | 528 | return count; |
528 | } | 529 | } |
529 | 530 | ||
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
539 | long min = FAN_FROM_REG(data->fan_min[nr], | 540 | long min = FAN_FROM_REG(data->fan_min[nr], |
540 | DIV_FROM_REG(data->fan_div[nr])); | 541 | DIV_FROM_REG(data->fan_div[nr])); |
541 | 542 | ||
542 | down(&data->update_lock); | 543 | mutex_lock(&data->update_lock); |
543 | switch (val) { | 544 | switch (val) { |
544 | case 1: data->fan_div[nr] = 0; break; | 545 | case 1: data->fan_div[nr] = 0; break; |
545 | case 2: data->fan_div[nr] = 1; break; | 546 | case 2: data->fan_div[nr] = 1; break; |
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | default: | 549 | default: |
549 | dev_err(&client->dev, "fan_div value %ld not supported." | 550 | dev_err(&client->dev, "fan_div value %ld not supported." |
550 | "Choose one of 1, 2, 4 or 8!\n", val); | 551 | "Choose one of 1, 2, 4 or 8!\n", val); |
551 | up(&data->update_lock); | 552 | mutex_unlock(&data->update_lock); |
552 | return -EINVAL; | 553 | return -EINVAL; |
553 | } | 554 | } |
554 | 555 | ||
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
558 | 559 | ||
559 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 560 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
560 | vt8231_write_value(client, VT8231_REG_FANDIV, old); | 561 | vt8231_write_value(client, VT8231_REG_FANDIV, old); |
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return count; | 563 | return count; |
563 | } | 564 | } |
564 | 565 | ||
@@ -660,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter) | |||
660 | /* Fill in the remaining client fields and put into the global list */ | 661 | /* Fill in the remaining client fields and put into the global list */ |
661 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); | 662 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); |
662 | 663 | ||
663 | init_MUTEX(&data->update_lock); | 664 | mutex_init(&data->update_lock); |
664 | 665 | ||
665 | /* Tell the I2C layer a new client has arrived */ | 666 | /* Tell the I2C layer a new client has arrived */ |
666 | if ((err = i2c_attach_client(client))) | 667 | if ((err = i2c_attach_client(client))) |
@@ -745,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
745 | int i; | 746 | int i; |
746 | u16 low; | 747 | u16 low; |
747 | 748 | ||
748 | down(&data->update_lock); | 749 | mutex_lock(&data->update_lock); |
749 | 750 | ||
750 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 751 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
751 | || !data->valid) { | 752 | || !data->valid) { |
@@ -804,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
804 | data->valid = 1; | 805 | data->valid = 1; |
805 | } | 806 | } |
806 | 807 | ||
807 | up(&data->update_lock); | 808 | mutex_unlock(&data->update_lock); |
808 | 809 | ||
809 | return data; | 810 | return data; |
810 | } | 811 | } |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 12d79f5e4900..b6bd5685fd38 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -42,7 +42,9 @@ | |||
42 | #include <linux/i2c.h> | 42 | #include <linux/i2c.h> |
43 | #include <linux/i2c-isa.h> | 43 | #include <linux/i2c-isa.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/hwmon-sysfs.h> | ||
45 | #include <linux/err.h> | 46 | #include <linux/err.h> |
47 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 48 | #include <asm/io.h> |
47 | #include "lm75.h" | 49 | #include "lm75.h" |
48 | 50 | ||
@@ -177,9 +179,9 @@ temp1_to_reg(int temp) | |||
177 | struct w83627ehf_data { | 179 | struct w83627ehf_data { |
178 | struct i2c_client client; | 180 | struct i2c_client client; |
179 | struct class_device *class_dev; | 181 | struct class_device *class_dev; |
180 | struct semaphore lock; | 182 | struct mutex lock; |
181 | 183 | ||
182 | struct semaphore update_lock; | 184 | struct mutex update_lock; |
183 | char valid; /* !=0 if following fields are valid */ | 185 | char valid; /* !=0 if following fields are valid */ |
184 | unsigned long last_updated; /* In jiffies */ | 186 | unsigned long last_updated; /* In jiffies */ |
185 | 187 | ||
@@ -230,7 +232,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
230 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 232 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
231 | int res, word_sized = is_word_sized(reg); | 233 | int res, word_sized = is_word_sized(reg); |
232 | 234 | ||
233 | down(&data->lock); | 235 | mutex_lock(&data->lock); |
234 | 236 | ||
235 | w83627ehf_set_bank(client, reg); | 237 | w83627ehf_set_bank(client, reg); |
236 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 238 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -242,7 +244,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
242 | } | 244 | } |
243 | w83627ehf_reset_bank(client, reg); | 245 | w83627ehf_reset_bank(client, reg); |
244 | 246 | ||
245 | up(&data->lock); | 247 | mutex_unlock(&data->lock); |
246 | 248 | ||
247 | return res; | 249 | return res; |
248 | } | 250 | } |
@@ -252,7 +254,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
252 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 254 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
253 | int word_sized = is_word_sized(reg); | 255 | int word_sized = is_word_sized(reg); |
254 | 256 | ||
255 | down(&data->lock); | 257 | mutex_lock(&data->lock); |
256 | 258 | ||
257 | w83627ehf_set_bank(client, reg); | 259 | w83627ehf_set_bank(client, reg); |
258 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 260 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -264,7 +266,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
264 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | 266 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); |
265 | w83627ehf_reset_bank(client, reg); | 267 | w83627ehf_reset_bank(client, reg); |
266 | 268 | ||
267 | up(&data->lock); | 269 | mutex_unlock(&data->lock); |
268 | return 0; | 270 | return 0; |
269 | } | 271 | } |
270 | 272 | ||
@@ -322,7 +324,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
322 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 324 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
323 | int i; | 325 | int i; |
324 | 326 | ||
325 | down(&data->update_lock); | 327 | mutex_lock(&data->update_lock); |
326 | 328 | ||
327 | if (time_after(jiffies, data->last_updated + HZ) | 329 | if (time_after(jiffies, data->last_updated + HZ) |
328 | || !data->valid) { | 330 | || !data->valid) { |
@@ -397,7 +399,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
397 | data->valid = 1; | 399 | data->valid = 1; |
398 | } | 400 | } |
399 | 401 | ||
400 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
401 | return data; | 403 | return data; |
402 | } | 404 | } |
403 | 405 | ||
@@ -407,9 +409,12 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
407 | 409 | ||
408 | #define show_fan_reg(reg) \ | 410 | #define show_fan_reg(reg) \ |
409 | static ssize_t \ | 411 | static ssize_t \ |
410 | show_##reg(struct device *dev, char *buf, int nr) \ | 412 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
413 | char *buf) \ | ||
411 | { \ | 414 | { \ |
412 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 415 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
416 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
417 | int nr = sensor_attr->index; \ | ||
413 | return sprintf(buf, "%d\n", \ | 418 | return sprintf(buf, "%d\n", \ |
414 | fan_from_reg(data->reg[nr], \ | 419 | fan_from_reg(data->reg[nr], \ |
415 | div_from_reg(data->fan_div[nr]))); \ | 420 | div_from_reg(data->fan_div[nr]))); \ |
@@ -418,23 +423,28 @@ show_fan_reg(fan); | |||
418 | show_fan_reg(fan_min); | 423 | show_fan_reg(fan_min); |
419 | 424 | ||
420 | static ssize_t | 425 | static ssize_t |
421 | show_fan_div(struct device *dev, char *buf, int nr) | 426 | show_fan_div(struct device *dev, struct device_attribute *attr, |
427 | char *buf) | ||
422 | { | 428 | { |
423 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | 429 | struct w83627ehf_data *data = w83627ehf_update_device(dev); |
424 | return sprintf(buf, "%u\n", | 430 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
425 | div_from_reg(data->fan_div[nr])); | 431 | int nr = sensor_attr->index; |
432 | return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr])); | ||
426 | } | 433 | } |
427 | 434 | ||
428 | static ssize_t | 435 | static ssize_t |
429 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | 436 | store_fan_min(struct device *dev, struct device_attribute *attr, |
437 | const char *buf, size_t count) | ||
430 | { | 438 | { |
431 | struct i2c_client *client = to_i2c_client(dev); | 439 | struct i2c_client *client = to_i2c_client(dev); |
432 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 440 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
441 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
442 | int nr = sensor_attr->index; | ||
433 | unsigned int val = simple_strtoul(buf, NULL, 10); | 443 | unsigned int val = simple_strtoul(buf, NULL, 10); |
434 | unsigned int reg; | 444 | unsigned int reg; |
435 | u8 new_div; | 445 | u8 new_div; |
436 | 446 | ||
437 | down(&data->update_lock); | 447 | mutex_lock(&data->update_lock); |
438 | if (!val) { | 448 | if (!val) { |
439 | /* No min limit, alarm disabled */ | 449 | /* No min limit, alarm disabled */ |
440 | data->fan_min[nr] = 255; | 450 | data->fan_min[nr] = 255; |
@@ -482,63 +492,46 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
482 | } | 492 | } |
483 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | 493 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], |
484 | data->fan_min[nr]); | 494 | data->fan_min[nr]); |
485 | up(&data->update_lock); | 495 | mutex_unlock(&data->update_lock); |
486 | 496 | ||
487 | return count; | 497 | return count; |
488 | } | 498 | } |
489 | 499 | ||
490 | #define sysfs_fan_offset(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
491 | static ssize_t \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), |
492 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), |
493 | char *buf) \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), |
494 | { \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3), |
495 | return show_fan(dev, buf, offset-1); \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4), |
496 | } \ | 506 | }; |
497 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
498 | show_reg_fan_##offset, NULL); | ||
499 | 507 | ||
500 | #define sysfs_fan_min_offset(offset) \ | 508 | static struct sensor_device_attribute sda_fan_min[] = { |
501 | static ssize_t \ | 509 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, |
502 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 510 | store_fan_min, 0), |
503 | char *buf) \ | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, |
504 | { \ | 512 | store_fan_min, 1), |
505 | return show_fan_min(dev, buf, offset-1); \ | 513 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, |
506 | } \ | 514 | store_fan_min, 2), |
507 | static ssize_t \ | 515 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, |
508 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 516 | store_fan_min, 3), |
509 | const char *buf, size_t count) \ | 517 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, |
510 | { \ | 518 | store_fan_min, 4), |
511 | return store_fan_min(dev, buf, count, offset-1); \ | 519 | }; |
512 | } \ | ||
513 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
514 | show_reg_fan##offset##_min, \ | ||
515 | store_reg_fan##offset##_min); | ||
516 | 520 | ||
517 | #define sysfs_fan_div_offset(offset) \ | 521 | static struct sensor_device_attribute sda_fan_div[] = { |
518 | static ssize_t \ | 522 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
519 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | 523 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), |
520 | char *buf) \ | 524 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), |
521 | { \ | 525 | SENSOR_ATTR(fan4_div, S_IRUGO, show_fan_div, NULL, 3), |
522 | return show_fan_div(dev, buf, offset - 1); \ | 526 | SENSOR_ATTR(fan5_div, S_IRUGO, show_fan_div, NULL, 4), |
523 | } \ | 527 | }; |
524 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 528 | |
525 | show_reg_fan##offset##_div, NULL); | 529 | static void device_create_file_fan(struct device *dev, int i) |
526 | 530 | { | |
527 | sysfs_fan_offset(1); | 531 | device_create_file(dev, &sda_fan_input[i].dev_attr); |
528 | sysfs_fan_min_offset(1); | 532 | device_create_file(dev, &sda_fan_div[i].dev_attr); |
529 | sysfs_fan_div_offset(1); | 533 | device_create_file(dev, &sda_fan_min[i].dev_attr); |
530 | sysfs_fan_offset(2); | 534 | } |
531 | sysfs_fan_min_offset(2); | ||
532 | sysfs_fan_div_offset(2); | ||
533 | sysfs_fan_offset(3); | ||
534 | sysfs_fan_min_offset(3); | ||
535 | sysfs_fan_div_offset(3); | ||
536 | sysfs_fan_offset(4); | ||
537 | sysfs_fan_min_offset(4); | ||
538 | sysfs_fan_div_offset(4); | ||
539 | sysfs_fan_offset(5); | ||
540 | sysfs_fan_min_offset(5); | ||
541 | sysfs_fan_div_offset(5); | ||
542 | 535 | ||
543 | #define show_temp1_reg(reg) \ | 536 | #define show_temp1_reg(reg) \ |
544 | static ssize_t \ | 537 | static ssize_t \ |
@@ -561,27 +554,24 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | |||
561 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 554 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
562 | u32 val = simple_strtoul(buf, NULL, 10); \ | 555 | u32 val = simple_strtoul(buf, NULL, 10); \ |
563 | \ | 556 | \ |
564 | down(&data->update_lock); \ | 557 | mutex_lock(&data->update_lock); \ |
565 | data->temp1_##reg = temp1_to_reg(val); \ | 558 | data->temp1_##reg = temp1_to_reg(val); \ |
566 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | 559 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ |
567 | data->temp1_##reg); \ | 560 | data->temp1_##reg); \ |
568 | up(&data->update_lock); \ | 561 | mutex_unlock(&data->update_lock); \ |
569 | return count; \ | 562 | return count; \ |
570 | } | 563 | } |
571 | store_temp1_reg(OVER, max); | 564 | store_temp1_reg(OVER, max); |
572 | store_temp1_reg(HYST, max_hyst); | 565 | store_temp1_reg(HYST, max_hyst); |
573 | 566 | ||
574 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
575 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
576 | show_temp1_max, store_temp1_max); | ||
577 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
578 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
579 | |||
580 | #define show_temp_reg(reg) \ | 567 | #define show_temp_reg(reg) \ |
581 | static ssize_t \ | 568 | static ssize_t \ |
582 | show_##reg (struct device *dev, char *buf, int nr) \ | 569 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
570 | char *buf) \ | ||
583 | { \ | 571 | { \ |
584 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 572 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
573 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
574 | int nr = sensor_attr->index; \ | ||
585 | return sprintf(buf, "%d\n", \ | 575 | return sprintf(buf, "%d\n", \ |
586 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | 576 | LM75_TEMP_FROM_REG(data->reg[nr])); \ |
587 | } | 577 | } |
@@ -591,55 +581,42 @@ show_temp_reg(temp_max_hyst); | |||
591 | 581 | ||
592 | #define store_temp_reg(REG, reg) \ | 582 | #define store_temp_reg(REG, reg) \ |
593 | static ssize_t \ | 583 | static ssize_t \ |
594 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | 584 | store_##reg(struct device *dev, struct device_attribute *attr, \ |
585 | const char *buf, size_t count) \ | ||
595 | { \ | 586 | { \ |
596 | struct i2c_client *client = to_i2c_client(dev); \ | 587 | struct i2c_client *client = to_i2c_client(dev); \ |
597 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 588 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
589 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
590 | int nr = sensor_attr->index; \ | ||
598 | u32 val = simple_strtoul(buf, NULL, 10); \ | 591 | u32 val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 592 | \ |
600 | down(&data->update_lock); \ | 593 | mutex_lock(&data->update_lock); \ |
601 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 594 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
602 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | 595 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ |
603 | data->reg[nr]); \ | 596 | data->reg[nr]); \ |
604 | up(&data->update_lock); \ | 597 | mutex_unlock(&data->update_lock); \ |
605 | return count; \ | 598 | return count; \ |
606 | } | 599 | } |
607 | store_temp_reg(OVER, temp_max); | 600 | store_temp_reg(OVER, temp_max); |
608 | store_temp_reg(HYST, temp_max_hyst); | 601 | store_temp_reg(HYST, temp_max_hyst); |
609 | 602 | ||
610 | #define sysfs_temp_offset(offset) \ | 603 | static struct sensor_device_attribute sda_temp[] = { |
611 | static ssize_t \ | 604 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0), |
612 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | 605 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0), |
613 | char *buf) \ | 606 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1), |
614 | { \ | 607 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max, |
615 | return show_temp(dev, buf, offset - 2); \ | 608 | store_temp1_max, 0), |
616 | } \ | 609 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, |
617 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 610 | store_temp_max, 0), |
618 | show_reg_temp##offset, NULL); | 611 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, |
619 | 612 | store_temp_max, 1), | |
620 | #define sysfs_temp_reg_offset(reg, offset) \ | 613 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst, |
621 | static ssize_t \ | 614 | store_temp1_max_hyst, 0), |
622 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | 615 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
623 | char *buf) \ | 616 | store_temp_max_hyst, 0), |
624 | { \ | 617 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
625 | return show_temp_##reg(dev, buf, offset - 2); \ | 618 | store_temp_max_hyst, 1), |
626 | } \ | 619 | }; |
627 | static ssize_t \ | ||
628 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
629 | const char *buf, size_t count) \ | ||
630 | { \ | ||
631 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
632 | } \ | ||
633 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
634 | show_reg_temp##offset##_##reg, \ | ||
635 | store_reg_temp##offset##_##reg); | ||
636 | |||
637 | sysfs_temp_offset(2); | ||
638 | sysfs_temp_reg_offset(max, 2); | ||
639 | sysfs_temp_reg_offset(max_hyst, 2); | ||
640 | sysfs_temp_offset(3); | ||
641 | sysfs_temp_reg_offset(max, 3); | ||
642 | sysfs_temp_reg_offset(max_hyst, 3); | ||
643 | 620 | ||
644 | /* | 621 | /* |
645 | * Driver and client management | 622 | * Driver and client management |
@@ -673,6 +650,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | { | 650 | { |
674 | struct i2c_client *client; | 651 | struct i2c_client *client; |
675 | struct w83627ehf_data *data; | 652 | struct w83627ehf_data *data; |
653 | struct device *dev; | ||
676 | int i, err = 0; | 654 | int i, err = 0; |
677 | 655 | ||
678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, | 656 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
@@ -689,14 +667,15 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
689 | client = &data->client; | 667 | client = &data->client; |
690 | i2c_set_clientdata(client, data); | 668 | i2c_set_clientdata(client, data); |
691 | client->addr = address; | 669 | client->addr = address; |
692 | init_MUTEX(&data->lock); | 670 | mutex_init(&data->lock); |
693 | client->adapter = adapter; | 671 | client->adapter = adapter; |
694 | client->driver = &w83627ehf_driver; | 672 | client->driver = &w83627ehf_driver; |
695 | client->flags = 0; | 673 | client->flags = 0; |
674 | dev = &client->dev; | ||
696 | 675 | ||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | 676 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); |
698 | data->valid = 0; | 677 | data->valid = 0; |
699 | init_MUTEX(&data->update_lock); | 678 | mutex_init(&data->update_lock); |
700 | 679 | ||
701 | /* Tell the i2c layer a new client has arrived */ | 680 | /* Tell the i2c layer a new client has arrived */ |
702 | if ((err = i2c_attach_client(client))) | 681 | if ((err = i2c_attach_client(client))) |
@@ -720,42 +699,18 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
720 | data->has_fan |= (1 << 4); | 699 | data->has_fan |= (1 << 4); |
721 | 700 | ||
722 | /* Register sysfs hooks */ | 701 | /* Register sysfs hooks */ |
723 | data->class_dev = hwmon_device_register(&client->dev); | 702 | data->class_dev = hwmon_device_register(dev); |
724 | if (IS_ERR(data->class_dev)) { | 703 | if (IS_ERR(data->class_dev)) { |
725 | err = PTR_ERR(data->class_dev); | 704 | err = PTR_ERR(data->class_dev); |
726 | goto exit_detach; | 705 | goto exit_detach; |
727 | } | 706 | } |
728 | 707 | ||
729 | device_create_file(&client->dev, &dev_attr_fan1_input); | 708 | for (i = 0; i < 5; i++) { |
730 | device_create_file(&client->dev, &dev_attr_fan1_min); | 709 | if (data->has_fan & (1 << i)) |
731 | device_create_file(&client->dev, &dev_attr_fan1_div); | 710 | device_create_file_fan(dev, i); |
732 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
733 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
734 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
735 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
736 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
737 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
738 | |||
739 | if (data->has_fan & (1 << 3)) { | ||
740 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
741 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
742 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
743 | } | ||
744 | if (data->has_fan & (1 << 4)) { | ||
745 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
746 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
747 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
748 | } | 711 | } |
749 | 712 | for (i = 0; i < ARRAY_SIZE(sda_temp); i++) | |
750 | device_create_file(&client->dev, &dev_attr_temp1_input); | 713 | device_create_file(dev, &sda_temp[i].dev_attr); |
751 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
753 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
754 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
755 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
756 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
757 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
758 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
759 | 714 | ||
760 | return 0; | 715 | return 0; |
761 | 716 | ||
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 7ea441d4da63..71fb7f1af8f5 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -28,6 +28,7 @@ | |||
28 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) | 28 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) |
29 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | 29 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) |
30 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) | 30 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) |
31 | w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | ||
31 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | 32 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) |
32 | 33 | ||
33 | For other winbond chips, and for i2c support in the above chips, | 34 | For other winbond chips, and for i2c support in the above chips, |
@@ -46,6 +47,7 @@ | |||
46 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
47 | #include <linux/hwmon-vid.h> | 48 | #include <linux/hwmon-vid.h> |
48 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/mutex.h> | ||
49 | #include <asm/io.h> | 51 | #include <asm/io.h> |
50 | #include "lm75.h" | 52 | #include "lm75.h" |
51 | 53 | ||
@@ -62,7 +64,7 @@ MODULE_PARM_DESC(force_i2c, | |||
62 | static unsigned short address; | 64 | static unsigned short address; |
63 | 65 | ||
64 | /* Insmod parameters */ | 66 | /* Insmod parameters */ |
65 | enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf }; | 67 | enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf, w83687thf }; |
66 | 68 | ||
67 | static int reset; | 69 | static int reset; |
68 | module_param(reset, bool, 0); | 70 | module_param(reset, bool, 0); |
@@ -100,6 +102,10 @@ static int VAL; /* The value to read/write */ | |||
100 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ | 102 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ |
101 | #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ | 103 | #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ |
102 | 104 | ||
105 | #define W83687THF_VID_EN 0x29 /* w83687thf only */ | ||
106 | #define W83687THF_VID_CFG 0xF0 /* w83687thf only */ | ||
107 | #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ | ||
108 | |||
103 | static inline void | 109 | static inline void |
104 | superio_outb(int reg, int val) | 110 | superio_outb(int reg, int val) |
105 | { | 111 | { |
@@ -138,6 +144,7 @@ superio_exit(void) | |||
138 | #define W627THF_DEVID 0x82 | 144 | #define W627THF_DEVID 0x82 |
139 | #define W697_DEVID 0x60 | 145 | #define W697_DEVID 0x60 |
140 | #define W637_DEVID 0x70 | 146 | #define W637_DEVID 0x70 |
147 | #define W687THF_DEVID 0x85 | ||
141 | #define WINB_ACT_REG 0x30 | 148 | #define WINB_ACT_REG 0x30 |
142 | #define WINB_BASE_REG 0x60 | 149 | #define WINB_BASE_REG 0x60 |
143 | /* Constants specified below */ | 150 | /* Constants specified below */ |
@@ -201,11 +208,11 @@ superio_exit(void) | |||
201 | #define W83627HF_REG_PWM1 0x5A | 208 | #define W83627HF_REG_PWM1 0x5A |
202 | #define W83627HF_REG_PWM2 0x5B | 209 | #define W83627HF_REG_PWM2 0x5B |
203 | 210 | ||
204 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ | 211 | #define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */ |
205 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ | 212 | #define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */ |
206 | #define W83627THF_REG_PWM3 0x11 /* 637HF too */ | 213 | #define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */ |
207 | 214 | ||
208 | #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */ | 215 | #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF/687THF too */ |
209 | 216 | ||
210 | static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; | 217 | static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; |
211 | static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, | 218 | static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, |
@@ -285,10 +292,10 @@ static inline u8 DIV_TO_REG(long val) | |||
285 | struct w83627hf_data { | 292 | struct w83627hf_data { |
286 | struct i2c_client client; | 293 | struct i2c_client client; |
287 | struct class_device *class_dev; | 294 | struct class_device *class_dev; |
288 | struct semaphore lock; | 295 | struct mutex lock; |
289 | enum chips type; | 296 | enum chips type; |
290 | 297 | ||
291 | struct semaphore update_lock; | 298 | struct mutex update_lock; |
292 | char valid; /* !=0 if following fields are valid */ | 299 | char valid; /* !=0 if following fields are valid */ |
293 | unsigned long last_updated; /* In jiffies */ | 300 | unsigned long last_updated; /* In jiffies */ |
294 | 301 | ||
@@ -318,16 +325,15 @@ struct w83627hf_data { | |||
318 | Default = 3435. | 325 | Default = 3435. |
319 | Other Betas unimplemented */ | 326 | Other Betas unimplemented */ |
320 | u8 vrm; | 327 | u8 vrm; |
321 | u8 vrm_ovt; /* Register value, 627thf & 637hf only */ | 328 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ |
322 | }; | 329 | }; |
323 | 330 | ||
324 | 331 | ||
325 | static int w83627hf_detect(struct i2c_adapter *adapter); | 332 | static int w83627hf_detect(struct i2c_adapter *adapter); |
326 | static int w83627hf_detach_client(struct i2c_client *client); | 333 | static int w83627hf_detach_client(struct i2c_client *client); |
327 | 334 | ||
328 | static int w83627hf_read_value(struct i2c_client *client, u16 register); | 335 | static int w83627hf_read_value(struct i2c_client *client, u16 reg); |
329 | static int w83627hf_write_value(struct i2c_client *client, u16 register, | 336 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value); |
330 | u16 value); | ||
331 | static struct w83627hf_data *w83627hf_update_device(struct device *dev); | 337 | static struct w83627hf_data *w83627hf_update_device(struct device *dev); |
332 | static void w83627hf_init_client(struct i2c_client *client); | 338 | static void w83627hf_init_client(struct i2c_client *client); |
333 | 339 | ||
@@ -360,12 +366,12 @@ store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
360 | \ | 366 | \ |
361 | val = simple_strtoul(buf, NULL, 10); \ | 367 | val = simple_strtoul(buf, NULL, 10); \ |
362 | \ | 368 | \ |
363 | down(&data->update_lock); \ | 369 | mutex_lock(&data->update_lock); \ |
364 | data->in_##reg[nr] = IN_TO_REG(val); \ | 370 | data->in_##reg[nr] = IN_TO_REG(val); \ |
365 | w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ | 371 | w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ |
366 | data->in_##reg[nr]); \ | 372 | data->in_##reg[nr]); \ |
367 | \ | 373 | \ |
368 | up(&data->update_lock); \ | 374 | mutex_unlock(&data->update_lock); \ |
369 | return count; \ | 375 | return count; \ |
370 | } | 376 | } |
371 | store_in_reg(MIN, min) | 377 | store_in_reg(MIN, min) |
@@ -413,7 +419,8 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg) | |||
413 | long in0; | 419 | long in0; |
414 | 420 | ||
415 | if ((data->vrm_ovt & 0x01) && | 421 | if ((data->vrm_ovt & 0x01) && |
416 | (w83627thf == data->type || w83637hf == data->type)) | 422 | (w83627thf == data->type || w83637hf == data->type |
423 | || w83687thf == data->type)) | ||
417 | 424 | ||
418 | /* use VRM9 calculation */ | 425 | /* use VRM9 calculation */ |
419 | in0 = (long)((reg * 488 + 70000 + 50) / 100); | 426 | in0 = (long)((reg * 488 + 70000 + 50) / 100); |
@@ -451,10 +458,11 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
451 | 458 | ||
452 | val = simple_strtoul(buf, NULL, 10); | 459 | val = simple_strtoul(buf, NULL, 10); |
453 | 460 | ||
454 | down(&data->update_lock); | 461 | mutex_lock(&data->update_lock); |
455 | 462 | ||
456 | if ((data->vrm_ovt & 0x01) && | 463 | if ((data->vrm_ovt & 0x01) && |
457 | (w83627thf == data->type || w83637hf == data->type)) | 464 | (w83627thf == data->type || w83637hf == data->type |
465 | || w83687thf == data->type)) | ||
458 | 466 | ||
459 | /* use VRM9 calculation */ | 467 | /* use VRM9 calculation */ |
460 | data->in_min[0] = | 468 | data->in_min[0] = |
@@ -465,7 +473,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
465 | data->in_min[0] = IN_TO_REG(val); | 473 | data->in_min[0] = IN_TO_REG(val); |
466 | 474 | ||
467 | w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); | 475 | w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); |
468 | up(&data->update_lock); | 476 | mutex_unlock(&data->update_lock); |
469 | return count; | 477 | return count; |
470 | } | 478 | } |
471 | 479 | ||
@@ -478,10 +486,11 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
478 | 486 | ||
479 | val = simple_strtoul(buf, NULL, 10); | 487 | val = simple_strtoul(buf, NULL, 10); |
480 | 488 | ||
481 | down(&data->update_lock); | 489 | mutex_lock(&data->update_lock); |
482 | 490 | ||
483 | if ((data->vrm_ovt & 0x01) && | 491 | if ((data->vrm_ovt & 0x01) && |
484 | (w83627thf == data->type || w83637hf == data->type)) | 492 | (w83627thf == data->type || w83637hf == data->type |
493 | || w83687thf == data->type)) | ||
485 | 494 | ||
486 | /* use VRM9 calculation */ | 495 | /* use VRM9 calculation */ |
487 | data->in_max[0] = | 496 | data->in_max[0] = |
@@ -492,7 +501,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
492 | data->in_max[0] = IN_TO_REG(val); | 501 | data->in_max[0] = IN_TO_REG(val); |
493 | 502 | ||
494 | w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); | 503 | w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); |
495 | up(&data->update_lock); | 504 | mutex_unlock(&data->update_lock); |
496 | return count; | 505 | return count; |
497 | } | 506 | } |
498 | 507 | ||
@@ -529,13 +538,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
529 | 538 | ||
530 | val = simple_strtoul(buf, NULL, 10); | 539 | val = simple_strtoul(buf, NULL, 10); |
531 | 540 | ||
532 | down(&data->update_lock); | 541 | mutex_lock(&data->update_lock); |
533 | data->fan_min[nr - 1] = | 542 | data->fan_min[nr - 1] = |
534 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); | 543 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); |
535 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), | 544 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), |
536 | data->fan_min[nr - 1]); | 545 | data->fan_min[nr - 1]); |
537 | 546 | ||
538 | up(&data->update_lock); | 547 | mutex_unlock(&data->update_lock); |
539 | return count; | 548 | return count; |
540 | } | 549 | } |
541 | 550 | ||
@@ -597,7 +606,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
597 | \ | 606 | \ |
598 | val = simple_strtoul(buf, NULL, 10); \ | 607 | val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 608 | \ |
600 | down(&data->update_lock); \ | 609 | mutex_lock(&data->update_lock); \ |
601 | \ | 610 | \ |
602 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ | 611 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ |
603 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ | 612 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ |
@@ -609,7 +618,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
609 | data->temp_##reg); \ | 618 | data->temp_##reg); \ |
610 | } \ | 619 | } \ |
611 | \ | 620 | \ |
612 | up(&data->update_lock); \ | 621 | mutex_unlock(&data->update_lock); \ |
613 | return count; \ | 622 | return count; \ |
614 | } | 623 | } |
615 | store_temp_reg(OVER, max); | 624 | store_temp_reg(OVER, max); |
@@ -718,7 +727,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
718 | 727 | ||
719 | val = simple_strtoul(buf, NULL, 10); | 728 | val = simple_strtoul(buf, NULL, 10); |
720 | 729 | ||
721 | down(&data->update_lock); | 730 | mutex_lock(&data->update_lock); |
722 | 731 | ||
723 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ | 732 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ |
724 | data->beep_mask = BEEP_MASK_TO_REG(val); | 733 | data->beep_mask = BEEP_MASK_TO_REG(val); |
@@ -736,7 +745,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
736 | w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, | 745 | w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, |
737 | val2 | data->beep_enable << 7); | 746 | val2 | data->beep_enable << 7); |
738 | 747 | ||
739 | up(&data->update_lock); | 748 | mutex_unlock(&data->update_lock); |
740 | return count; | 749 | return count; |
741 | } | 750 | } |
742 | 751 | ||
@@ -783,7 +792,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
783 | u8 reg; | 792 | u8 reg; |
784 | unsigned long val = simple_strtoul(buf, NULL, 10); | 793 | unsigned long val = simple_strtoul(buf, NULL, 10); |
785 | 794 | ||
786 | down(&data->update_lock); | 795 | mutex_lock(&data->update_lock); |
787 | 796 | ||
788 | /* Save fan_min */ | 797 | /* Save fan_min */ |
789 | min = FAN_FROM_REG(data->fan_min[nr], | 798 | min = FAN_FROM_REG(data->fan_min[nr], |
@@ -805,7 +814,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
805 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 814 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
806 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 815 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
807 | 816 | ||
808 | up(&data->update_lock); | 817 | mutex_unlock(&data->update_lock); |
809 | return count; | 818 | return count; |
810 | } | 819 | } |
811 | 820 | ||
@@ -848,7 +857,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
848 | 857 | ||
849 | val = simple_strtoul(buf, NULL, 10); | 858 | val = simple_strtoul(buf, NULL, 10); |
850 | 859 | ||
851 | down(&data->update_lock); | 860 | mutex_lock(&data->update_lock); |
852 | 861 | ||
853 | if (data->type == w83627thf) { | 862 | if (data->type == w83627thf) { |
854 | /* bits 0-3 are reserved in 627THF */ | 863 | /* bits 0-3 are reserved in 627THF */ |
@@ -865,7 +874,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
865 | data->pwm[nr - 1]); | 874 | data->pwm[nr - 1]); |
866 | } | 875 | } |
867 | 876 | ||
868 | up(&data->update_lock); | 877 | mutex_unlock(&data->update_lock); |
869 | return count; | 878 | return count; |
870 | } | 879 | } |
871 | 880 | ||
@@ -907,7 +916,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
907 | 916 | ||
908 | val = simple_strtoul(buf, NULL, 10); | 917 | val = simple_strtoul(buf, NULL, 10); |
909 | 918 | ||
910 | down(&data->update_lock); | 919 | mutex_lock(&data->update_lock); |
911 | 920 | ||
912 | switch (val) { | 921 | switch (val) { |
913 | case 1: /* PII/Celeron diode */ | 922 | case 1: /* PII/Celeron diode */ |
@@ -941,7 +950,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
941 | break; | 950 | break; |
942 | } | 951 | } |
943 | 952 | ||
944 | up(&data->update_lock); | 953 | mutex_unlock(&data->update_lock); |
945 | return count; | 954 | return count; |
946 | } | 955 | } |
947 | 956 | ||
@@ -980,7 +989,8 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) | |||
980 | if(val != W627_DEVID && | 989 | if(val != W627_DEVID && |
981 | val != W627THF_DEVID && | 990 | val != W627THF_DEVID && |
982 | val != W697_DEVID && | 991 | val != W697_DEVID && |
983 | val != W637_DEVID) { | 992 | val != W637_DEVID && |
993 | val != W687THF_DEVID) { | ||
984 | superio_exit(); | 994 | superio_exit(); |
985 | return -ENODEV; | 995 | return -ENODEV; |
986 | } | 996 | } |
@@ -1034,6 +1044,8 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1034 | kind = w83627thf; | 1044 | kind = w83627thf; |
1035 | else if(val == W637_DEVID) | 1045 | else if(val == W637_DEVID) |
1036 | kind = w83637hf; | 1046 | kind = w83637hf; |
1047 | else if (val == W687THF_DEVID) | ||
1048 | kind = w83687thf; | ||
1037 | else { | 1049 | else { |
1038 | dev_info(&adapter->dev, | 1050 | dev_info(&adapter->dev, |
1039 | "Unsupported chip (dev_id=0x%02X).\n", val); | 1051 | "Unsupported chip (dev_id=0x%02X).\n", val); |
@@ -1057,7 +1069,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1057 | new_client = &data->client; | 1069 | new_client = &data->client; |
1058 | i2c_set_clientdata(new_client, data); | 1070 | i2c_set_clientdata(new_client, data); |
1059 | new_client->addr = address; | 1071 | new_client->addr = address; |
1060 | init_MUTEX(&data->lock); | 1072 | mutex_init(&data->lock); |
1061 | new_client->adapter = adapter; | 1073 | new_client->adapter = adapter; |
1062 | new_client->driver = &w83627hf_driver; | 1074 | new_client->driver = &w83627hf_driver; |
1063 | new_client->flags = 0; | 1075 | new_client->flags = 0; |
@@ -1071,13 +1083,15 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1071 | client_name = "w83697hf"; | 1083 | client_name = "w83697hf"; |
1072 | } else if (kind == w83637hf) { | 1084 | } else if (kind == w83637hf) { |
1073 | client_name = "w83637hf"; | 1085 | client_name = "w83637hf"; |
1086 | } else if (kind == w83687thf) { | ||
1087 | client_name = "w83687thf"; | ||
1074 | } | 1088 | } |
1075 | 1089 | ||
1076 | /* Fill in the remaining client fields and put into the global list */ | 1090 | /* Fill in the remaining client fields and put into the global list */ |
1077 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 1091 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
1078 | data->type = kind; | 1092 | data->type = kind; |
1079 | data->valid = 0; | 1093 | data->valid = 0; |
1080 | init_MUTEX(&data->update_lock); | 1094 | mutex_init(&data->update_lock); |
1081 | 1095 | ||
1082 | /* Tell the I2C layer a new client has arrived */ | 1096 | /* Tell the I2C layer a new client has arrived */ |
1083 | if ((err = i2c_attach_client(new_client))) | 1097 | if ((err = i2c_attach_client(new_client))) |
@@ -1106,7 +1120,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1106 | device_create_file_in(new_client, 2); | 1120 | device_create_file_in(new_client, 2); |
1107 | device_create_file_in(new_client, 3); | 1121 | device_create_file_in(new_client, 3); |
1108 | device_create_file_in(new_client, 4); | 1122 | device_create_file_in(new_client, 4); |
1109 | if (kind != w83627thf && kind != w83637hf) { | 1123 | if (kind == w83627hf || kind == w83697hf) { |
1110 | device_create_file_in(new_client, 5); | 1124 | device_create_file_in(new_client, 5); |
1111 | device_create_file_in(new_client, 6); | 1125 | device_create_file_in(new_client, 6); |
1112 | } | 1126 | } |
@@ -1139,7 +1153,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1139 | 1153 | ||
1140 | device_create_file_pwm(new_client, 1); | 1154 | device_create_file_pwm(new_client, 1); |
1141 | device_create_file_pwm(new_client, 2); | 1155 | device_create_file_pwm(new_client, 2); |
1142 | if (kind == w83627thf || kind == w83637hf) | 1156 | if (kind == w83627thf || kind == w83637hf || kind == w83687thf) |
1143 | device_create_file_pwm(new_client, 3); | 1157 | device_create_file_pwm(new_client, 3); |
1144 | 1158 | ||
1145 | device_create_file_sensor(new_client, 1); | 1159 | device_create_file_sensor(new_client, 1); |
@@ -1187,7 +1201,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg) | |||
1187 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1201 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1188 | int res, word_sized; | 1202 | int res, word_sized; |
1189 | 1203 | ||
1190 | down(&data->lock); | 1204 | mutex_lock(&data->lock); |
1191 | word_sized = (((reg & 0xff00) == 0x100) | 1205 | word_sized = (((reg & 0xff00) == 0x100) |
1192 | || ((reg & 0xff00) == 0x200)) | 1206 | || ((reg & 0xff00) == 0x200)) |
1193 | && (((reg & 0x00ff) == 0x50) | 1207 | && (((reg & 0x00ff) == 0x50) |
@@ -1213,7 +1227,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg) | |||
1213 | client->addr + W83781D_ADDR_REG_OFFSET); | 1227 | client->addr + W83781D_ADDR_REG_OFFSET); |
1214 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); | 1228 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); |
1215 | } | 1229 | } |
1216 | up(&data->lock); | 1230 | mutex_unlock(&data->lock); |
1217 | return res; | 1231 | return res; |
1218 | } | 1232 | } |
1219 | 1233 | ||
@@ -1247,12 +1261,39 @@ exit: | |||
1247 | return res; | 1261 | return res; |
1248 | } | 1262 | } |
1249 | 1263 | ||
1264 | static int w83687thf_read_vid(struct i2c_client *client) | ||
1265 | { | ||
1266 | int res = 0xff; | ||
1267 | |||
1268 | superio_enter(); | ||
1269 | superio_select(W83627HF_LD_HWM); | ||
1270 | |||
1271 | /* Make sure these GPIO pins are enabled */ | ||
1272 | if (!(superio_inb(W83687THF_VID_EN) & (1 << 2))) { | ||
1273 | dev_dbg(&client->dev, "VID disabled, no VID function\n"); | ||
1274 | goto exit; | ||
1275 | } | ||
1276 | |||
1277 | /* Make sure the pins are configured for input */ | ||
1278 | if (!(superio_inb(W83687THF_VID_CFG) & (1 << 4))) { | ||
1279 | dev_dbg(&client->dev, "VID configured as output, " | ||
1280 | "no VID function\n"); | ||
1281 | goto exit; | ||
1282 | } | ||
1283 | |||
1284 | res = superio_inb(W83687THF_VID_DATA) & 0x3f; | ||
1285 | |||
1286 | exit: | ||
1287 | superio_exit(); | ||
1288 | return res; | ||
1289 | } | ||
1290 | |||
1250 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | 1291 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) |
1251 | { | 1292 | { |
1252 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1293 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1253 | int word_sized; | 1294 | int word_sized; |
1254 | 1295 | ||
1255 | down(&data->lock); | 1296 | mutex_lock(&data->lock); |
1256 | word_sized = (((reg & 0xff00) == 0x100) | 1297 | word_sized = (((reg & 0xff00) == 0x100) |
1257 | || ((reg & 0xff00) == 0x200)) | 1298 | || ((reg & 0xff00) == 0x200)) |
1258 | && (((reg & 0x00ff) == 0x53) | 1299 | && (((reg & 0x00ff) == 0x53) |
@@ -1277,7 +1318,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1277 | client->addr + W83781D_ADDR_REG_OFFSET); | 1318 | client->addr + W83781D_ADDR_REG_OFFSET); |
1278 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); | 1319 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); |
1279 | } | 1320 | } |
1280 | up(&data->lock); | 1321 | mutex_unlock(&data->lock); |
1281 | return 0; | 1322 | return 0; |
1282 | } | 1323 | } |
1283 | 1324 | ||
@@ -1324,10 +1365,13 @@ static void w83627hf_init_client(struct i2c_client *client) | |||
1324 | data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); | 1365 | data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); |
1325 | } else if (w83627thf == data->type) { | 1366 | } else if (w83627thf == data->type) { |
1326 | data->vid = w83627thf_read_gpio5(client); | 1367 | data->vid = w83627thf_read_gpio5(client); |
1368 | } else if (w83687thf == data->type) { | ||
1369 | data->vid = w83687thf_read_vid(client); | ||
1327 | } | 1370 | } |
1328 | 1371 | ||
1329 | /* Read VRM & OVT Config only once */ | 1372 | /* Read VRM & OVT Config only once */ |
1330 | if (w83627thf == data->type || w83637hf == data->type) { | 1373 | if (w83627thf == data->type || w83637hf == data->type |
1374 | || w83687thf == data->type) { | ||
1331 | data->vrm_ovt = | 1375 | data->vrm_ovt = |
1332 | w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); | 1376 | w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); |
1333 | } | 1377 | } |
@@ -1387,14 +1431,14 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1387 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1431 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1388 | int i; | 1432 | int i; |
1389 | 1433 | ||
1390 | down(&data->update_lock); | 1434 | mutex_lock(&data->update_lock); |
1391 | 1435 | ||
1392 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1436 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1393 | || !data->valid) { | 1437 | || !data->valid) { |
1394 | for (i = 0; i <= 8; i++) { | 1438 | for (i = 0; i <= 8; i++) { |
1395 | /* skip missing sensors */ | 1439 | /* skip missing sensors */ |
1396 | if (((data->type == w83697hf) && (i == 1)) || | 1440 | if (((data->type == w83697hf) && (i == 1)) || |
1397 | ((data->type == w83627thf || data->type == w83637hf) | 1441 | ((data->type != w83627hf && data->type != w83697hf) |
1398 | && (i == 5 || i == 6))) | 1442 | && (i == 5 || i == 6))) |
1399 | continue; | 1443 | continue; |
1400 | data->in[i] = | 1444 | data->in[i] = |
@@ -1470,7 +1514,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1470 | data->valid = 1; | 1514 | data->valid = 1; |
1471 | } | 1515 | } |
1472 | 1516 | ||
1473 | up(&data->update_lock); | 1517 | mutex_unlock(&data->update_lock); |
1474 | 1518 | ||
1475 | return data; | 1519 | return data; |
1476 | } | 1520 | } |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 64c1f8af5bb2..e4c700356c44 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/hwmon.h> | 42 | #include <linux/hwmon.h> |
43 | #include <linux/hwmon-vid.h> | 43 | #include <linux/hwmon-vid.h> |
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/mutex.h> | ||
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include "lm75.h" | 47 | #include "lm75.h" |
47 | 48 | ||
@@ -56,6 +57,10 @@ I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); | |||
56 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 57 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
57 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 58 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
58 | 59 | ||
60 | static int reset; | ||
61 | module_param(reset, bool, 0); | ||
62 | MODULE_PARM_DESC(reset, "Set to one to reset chip on load"); | ||
63 | |||
59 | static int init = 1; | 64 | static int init = 1; |
60 | module_param(init, bool, 0); | 65 | module_param(init, bool, 0); |
61 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); | 66 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); |
@@ -226,10 +231,10 @@ DIV_TO_REG(long val, enum chips type) | |||
226 | struct w83781d_data { | 231 | struct w83781d_data { |
227 | struct i2c_client client; | 232 | struct i2c_client client; |
228 | struct class_device *class_dev; | 233 | struct class_device *class_dev; |
229 | struct semaphore lock; | 234 | struct mutex lock; |
230 | enum chips type; | 235 | enum chips type; |
231 | 236 | ||
232 | struct semaphore update_lock; | 237 | struct mutex update_lock; |
233 | char valid; /* !=0 if following fields are valid */ | 238 | char valid; /* !=0 if following fields are valid */ |
234 | unsigned long last_updated; /* In jiffies */ | 239 | unsigned long last_updated; /* In jiffies */ |
235 | 240 | ||
@@ -267,9 +272,8 @@ static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter); | |||
267 | static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); | 272 | static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); |
268 | static int w83781d_detach_client(struct i2c_client *client); | 273 | static int w83781d_detach_client(struct i2c_client *client); |
269 | 274 | ||
270 | static int w83781d_read_value(struct i2c_client *client, u16 register); | 275 | static int w83781d_read_value(struct i2c_client *client, u16 reg); |
271 | static int w83781d_write_value(struct i2c_client *client, u16 register, | 276 | static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value); |
272 | u16 value); | ||
273 | static struct w83781d_data *w83781d_update_device(struct device *dev); | 277 | static struct w83781d_data *w83781d_update_device(struct device *dev); |
274 | static void w83781d_init_client(struct i2c_client *client); | 278 | static void w83781d_init_client(struct i2c_client *client); |
275 | 279 | ||
@@ -311,11 +315,11 @@ static ssize_t store_in_##reg (struct device *dev, const char *buf, size_t count | |||
311 | \ | 315 | \ |
312 | val = simple_strtoul(buf, NULL, 10) / 10; \ | 316 | val = simple_strtoul(buf, NULL, 10) / 10; \ |
313 | \ | 317 | \ |
314 | down(&data->update_lock); \ | 318 | mutex_lock(&data->update_lock); \ |
315 | data->in_##reg[nr] = IN_TO_REG(val); \ | 319 | data->in_##reg[nr] = IN_TO_REG(val); \ |
316 | w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ | 320 | w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ |
317 | \ | 321 | \ |
318 | up(&data->update_lock); \ | 322 | mutex_unlock(&data->update_lock); \ |
319 | return count; \ | 323 | return count; \ |
320 | } | 324 | } |
321 | store_in_reg(MIN, min); | 325 | store_in_reg(MIN, min); |
@@ -381,13 +385,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
381 | 385 | ||
382 | val = simple_strtoul(buf, NULL, 10); | 386 | val = simple_strtoul(buf, NULL, 10); |
383 | 387 | ||
384 | down(&data->update_lock); | 388 | mutex_lock(&data->update_lock); |
385 | data->fan_min[nr - 1] = | 389 | data->fan_min[nr - 1] = |
386 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); | 390 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); |
387 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), | 391 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), |
388 | data->fan_min[nr - 1]); | 392 | data->fan_min[nr - 1]); |
389 | 393 | ||
390 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
391 | return count; | 395 | return count; |
392 | } | 396 | } |
393 | 397 | ||
@@ -446,7 +450,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou | |||
446 | \ | 450 | \ |
447 | val = simple_strtol(buf, NULL, 10); \ | 451 | val = simple_strtol(buf, NULL, 10); \ |
448 | \ | 452 | \ |
449 | down(&data->update_lock); \ | 453 | mutex_lock(&data->update_lock); \ |
450 | \ | 454 | \ |
451 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ | 455 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ |
452 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ | 456 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ |
@@ -458,7 +462,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou | |||
458 | data->temp_##reg); \ | 462 | data->temp_##reg); \ |
459 | } \ | 463 | } \ |
460 | \ | 464 | \ |
461 | up(&data->update_lock); \ | 465 | mutex_unlock(&data->update_lock); \ |
462 | return count; \ | 466 | return count; \ |
463 | } | 467 | } |
464 | store_temp_reg(OVER, max); | 468 | store_temp_reg(OVER, max); |
@@ -571,7 +575,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
571 | 575 | ||
572 | val = simple_strtoul(buf, NULL, 10); | 576 | val = simple_strtoul(buf, NULL, 10); |
573 | 577 | ||
574 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
575 | 579 | ||
576 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ | 580 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ |
577 | data->beep_mask = BEEP_MASK_TO_REG(val, data->type); | 581 | data->beep_mask = BEEP_MASK_TO_REG(val, data->type); |
@@ -592,7 +596,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
592 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, | 596 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, |
593 | val2 | data->beep_enable << 7); | 597 | val2 | data->beep_enable << 7); |
594 | 598 | ||
595 | up(&data->update_lock); | 599 | mutex_unlock(&data->update_lock); |
596 | return count; | 600 | return count; |
597 | } | 601 | } |
598 | 602 | ||
@@ -637,7 +641,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
637 | u8 reg; | 641 | u8 reg; |
638 | unsigned long val = simple_strtoul(buf, NULL, 10); | 642 | unsigned long val = simple_strtoul(buf, NULL, 10); |
639 | 643 | ||
640 | down(&data->update_lock); | 644 | mutex_lock(&data->update_lock); |
641 | 645 | ||
642 | /* Save fan_min */ | 646 | /* Save fan_min */ |
643 | min = FAN_FROM_REG(data->fan_min[nr], | 647 | min = FAN_FROM_REG(data->fan_min[nr], |
@@ -662,7 +666,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
662 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 666 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
663 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 667 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
664 | 668 | ||
665 | up(&data->update_lock); | 669 | mutex_unlock(&data->update_lock); |
666 | return count; | 670 | return count; |
667 | } | 671 | } |
668 | 672 | ||
@@ -709,10 +713,10 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
709 | 713 | ||
710 | val = simple_strtoul(buf, NULL, 10); | 714 | val = simple_strtoul(buf, NULL, 10); |
711 | 715 | ||
712 | down(&data->update_lock); | 716 | mutex_lock(&data->update_lock); |
713 | data->pwm[nr - 1] = PWM_TO_REG(val); | 717 | data->pwm[nr - 1] = PWM_TO_REG(val); |
714 | w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); | 718 | w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); |
715 | up(&data->update_lock); | 719 | mutex_unlock(&data->update_lock); |
716 | return count; | 720 | return count; |
717 | } | 721 | } |
718 | 722 | ||
@@ -725,7 +729,7 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
725 | 729 | ||
726 | val = simple_strtoul(buf, NULL, 10); | 730 | val = simple_strtoul(buf, NULL, 10); |
727 | 731 | ||
728 | down(&data->update_lock); | 732 | mutex_lock(&data->update_lock); |
729 | 733 | ||
730 | switch (val) { | 734 | switch (val) { |
731 | case 0: | 735 | case 0: |
@@ -742,11 +746,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
742 | break; | 746 | break; |
743 | 747 | ||
744 | default: | 748 | default: |
745 | up(&data->update_lock); | 749 | mutex_unlock(&data->update_lock); |
746 | return -EINVAL; | 750 | return -EINVAL; |
747 | } | 751 | } |
748 | 752 | ||
749 | up(&data->update_lock); | 753 | mutex_unlock(&data->update_lock); |
750 | return count; | 754 | return count; |
751 | } | 755 | } |
752 | 756 | ||
@@ -808,7 +812,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
808 | 812 | ||
809 | val = simple_strtoul(buf, NULL, 10); | 813 | val = simple_strtoul(buf, NULL, 10); |
810 | 814 | ||
811 | down(&data->update_lock); | 815 | mutex_lock(&data->update_lock); |
812 | 816 | ||
813 | switch (val) { | 817 | switch (val) { |
814 | case 1: /* PII/Celeron diode */ | 818 | case 1: /* PII/Celeron diode */ |
@@ -841,7 +845,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
841 | break; | 845 | break; |
842 | } | 846 | } |
843 | 847 | ||
844 | up(&data->update_lock); | 848 | mutex_unlock(&data->update_lock); |
845 | return count; | 849 | return count; |
846 | } | 850 | } |
847 | 851 | ||
@@ -1073,7 +1077,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1073 | new_client = &data->client; | 1077 | new_client = &data->client; |
1074 | i2c_set_clientdata(new_client, data); | 1078 | i2c_set_clientdata(new_client, data); |
1075 | new_client->addr = address; | 1079 | new_client->addr = address; |
1076 | init_MUTEX(&data->lock); | 1080 | mutex_init(&data->lock); |
1077 | new_client->adapter = adapter; | 1081 | new_client->adapter = adapter; |
1078 | new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; | 1082 | new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; |
1079 | new_client->flags = 0; | 1083 | new_client->flags = 0; |
@@ -1178,7 +1182,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1178 | data->type = kind; | 1182 | data->type = kind; |
1179 | 1183 | ||
1180 | data->valid = 0; | 1184 | data->valid = 0; |
1181 | init_MUTEX(&data->update_lock); | 1185 | mutex_init(&data->update_lock); |
1182 | 1186 | ||
1183 | /* Tell the I2C layer a new client has arrived */ | 1187 | /* Tell the I2C layer a new client has arrived */ |
1184 | if ((err = i2c_attach_client(new_client))) | 1188 | if ((err = i2c_attach_client(new_client))) |
@@ -1325,7 +1329,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg) | |||
1325 | int res, word_sized, bank; | 1329 | int res, word_sized, bank; |
1326 | struct i2c_client *cl; | 1330 | struct i2c_client *cl; |
1327 | 1331 | ||
1328 | down(&data->lock); | 1332 | mutex_lock(&data->lock); |
1329 | if (i2c_is_isa_client(client)) { | 1333 | if (i2c_is_isa_client(client)) { |
1330 | word_sized = (((reg & 0xff00) == 0x100) | 1334 | word_sized = (((reg & 0xff00) == 0x100) |
1331 | || ((reg & 0xff00) == 0x200)) | 1335 | || ((reg & 0xff00) == 0x200)) |
@@ -1383,7 +1387,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg) | |||
1383 | if (bank > 2) | 1387 | if (bank > 2) |
1384 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); | 1388 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); |
1385 | } | 1389 | } |
1386 | up(&data->lock); | 1390 | mutex_unlock(&data->lock); |
1387 | return res; | 1391 | return res; |
1388 | } | 1392 | } |
1389 | 1393 | ||
@@ -1394,7 +1398,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1394 | int word_sized, bank; | 1398 | int word_sized, bank; |
1395 | struct i2c_client *cl; | 1399 | struct i2c_client *cl; |
1396 | 1400 | ||
1397 | down(&data->lock); | 1401 | mutex_lock(&data->lock); |
1398 | if (i2c_is_isa_client(client)) { | 1402 | if (i2c_is_isa_client(client)) { |
1399 | word_sized = (((reg & 0xff00) == 0x100) | 1403 | word_sized = (((reg & 0xff00) == 0x100) |
1400 | || ((reg & 0xff00) == 0x200)) | 1404 | || ((reg & 0xff00) == 0x200)) |
@@ -1447,7 +1451,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1447 | if (bank > 2) | 1451 | if (bank > 2) |
1448 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); | 1452 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); |
1449 | } | 1453 | } |
1450 | up(&data->lock); | 1454 | mutex_unlock(&data->lock); |
1451 | return 0; | 1455 | return 0; |
1452 | } | 1456 | } |
1453 | 1457 | ||
@@ -1459,8 +1463,17 @@ w83781d_init_client(struct i2c_client *client) | |||
1459 | int type = data->type; | 1463 | int type = data->type; |
1460 | u8 tmp; | 1464 | u8 tmp; |
1461 | 1465 | ||
1462 | if (init && type != as99127f) { /* this resets registers we don't have | 1466 | if (reset && type != as99127f) { /* this resets registers we don't have |
1463 | documentation for on the as99127f */ | 1467 | documentation for on the as99127f */ |
1468 | /* Resetting the chip has been the default for a long time, | ||
1469 | but it causes the BIOS initializations (fan clock dividers, | ||
1470 | thermal sensor types...) to be lost, so it is now optional. | ||
1471 | It might even go away if nobody reports it as being useful, | ||
1472 | as I see very little reason why this would be needed at | ||
1473 | all. */ | ||
1474 | dev_info(&client->dev, "If reset=1 solved a problem you were " | ||
1475 | "having, please report!\n"); | ||
1476 | |||
1464 | /* save these registers */ | 1477 | /* save these registers */ |
1465 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); | 1478 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); |
1466 | p = w83781d_read_value(client, W83781D_REG_PWMCLK12); | 1479 | p = w83781d_read_value(client, W83781D_REG_PWMCLK12); |
@@ -1477,6 +1490,13 @@ w83781d_init_client(struct i2c_client *client) | |||
1477 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); | 1490 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); |
1478 | } | 1491 | } |
1479 | 1492 | ||
1493 | /* Disable power-on abnormal beep, as advised by the datasheet. | ||
1494 | Already done if reset=1. */ | ||
1495 | if (init && !reset && type != as99127f) { | ||
1496 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); | ||
1497 | w83781d_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80); | ||
1498 | } | ||
1499 | |||
1480 | data->vrm = vid_which_vrm(); | 1500 | data->vrm = vid_which_vrm(); |
1481 | 1501 | ||
1482 | if ((type != w83781d) && (type != as99127f)) { | 1502 | if ((type != w83781d) && (type != as99127f)) { |
@@ -1533,7 +1553,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1533 | struct w83781d_data *data = i2c_get_clientdata(client); | 1553 | struct w83781d_data *data = i2c_get_clientdata(client); |
1534 | int i; | 1554 | int i; |
1535 | 1555 | ||
1536 | down(&data->update_lock); | 1556 | mutex_lock(&data->update_lock); |
1537 | 1557 | ||
1538 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1558 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1539 | || !data->valid) { | 1559 | || !data->valid) { |
@@ -1641,7 +1661,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1641 | data->valid = 1; | 1661 | data->valid = 1; |
1642 | } | 1662 | } |
1643 | 1663 | ||
1644 | up(&data->update_lock); | 1664 | mutex_unlock(&data->update_lock); |
1645 | 1665 | ||
1646 | return data; | 1666 | return data; |
1647 | } | 1667 | } |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index a2f6bb676235..6865c64d8a51 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon.h> | 43 | #include <linux/hwmon.h> |
44 | #include <linux/hwmon-sysfs.h> | 44 | #include <linux/hwmon-sysfs.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; |
@@ -271,7 +272,7 @@ struct w83792d_data { | |||
271 | struct class_device *class_dev; | 272 | struct class_device *class_dev; |
272 | enum chips type; | 273 | enum chips type; |
273 | 274 | ||
274 | struct semaphore update_lock; | 275 | struct mutex update_lock; |
275 | char valid; /* !=0 if following fields are valid */ | 276 | char valid; /* !=0 if following fields are valid */ |
276 | unsigned long last_updated; /* In jiffies */ | 277 | unsigned long last_updated; /* In jiffies */ |
277 | 278 | ||
@@ -382,30 +383,40 @@ static ssize_t store_in_##reg (struct device *dev, \ | |||
382 | store_in_reg(MIN, min); | 383 | store_in_reg(MIN, min); |
383 | store_in_reg(MAX, max); | 384 | store_in_reg(MAX, max); |
384 | 385 | ||
385 | #define sysfs_in_reg(offset) \ | 386 | static struct sensor_device_attribute sda_in_input[] = { |
386 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ | 387 | SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), |
387 | NULL, offset); \ | 388 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), |
388 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | 389 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), |
389 | show_in_min, store_in_min, offset); \ | 390 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), |
390 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | 391 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), |
391 | show_in_max, store_in_max, offset); | 392 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), |
392 | 393 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | |
393 | sysfs_in_reg(0); | 394 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), |
394 | sysfs_in_reg(1); | 395 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), |
395 | sysfs_in_reg(2); | 396 | }; |
396 | sysfs_in_reg(3); | 397 | static struct sensor_device_attribute sda_in_min[] = { |
397 | sysfs_in_reg(4); | 398 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0), |
398 | sysfs_in_reg(5); | 399 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1), |
399 | sysfs_in_reg(6); | 400 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2), |
400 | sysfs_in_reg(7); | 401 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3), |
401 | sysfs_in_reg(8); | 402 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4), |
402 | 403 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5), | |
403 | #define device_create_file_in(client, offset) \ | 404 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6), |
404 | do { \ | 405 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7), |
405 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \ | 406 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8), |
406 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \ | 407 | }; |
407 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \ | 408 | static struct sensor_device_attribute sda_in_max[] = { |
408 | } while (0) | 409 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0), |
410 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1), | ||
411 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2), | ||
412 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3), | ||
413 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4), | ||
414 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5), | ||
415 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6), | ||
416 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7), | ||
417 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8), | ||
418 | }; | ||
419 | |||
409 | 420 | ||
410 | #define show_fan_reg(reg) \ | 421 | #define show_fan_reg(reg) \ |
411 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ | 422 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ |
@@ -486,28 +497,33 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
486 | return count; | 497 | return count; |
487 | } | 498 | } |
488 | 499 | ||
489 | #define sysfs_fan(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
490 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1), |
491 | offset); \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2), |
492 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3), |
493 | show_fan_div, store_fan_div, offset); \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4), |
494 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5), |
495 | show_fan_min, store_fan_min, offset); | 506 | SENSOR_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6), |
496 | 507 | SENSOR_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7), | |
497 | sysfs_fan(1); | 508 | }; |
498 | sysfs_fan(2); | 509 | static struct sensor_device_attribute sda_fan_min[] = { |
499 | sysfs_fan(3); | 510 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 1), |
500 | sysfs_fan(4); | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 2), |
501 | sysfs_fan(5); | 512 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 3), |
502 | sysfs_fan(6); | 513 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 4), |
503 | sysfs_fan(7); | 514 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 5), |
504 | 515 | SENSOR_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 6), | |
505 | #define device_create_file_fan(client, offset) \ | 516 | SENSOR_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 7), |
506 | do { \ | 517 | }; |
507 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \ | 518 | static struct sensor_device_attribute sda_fan_div[] = { |
508 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \ | 519 | SENSOR_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 1), |
509 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \ | 520 | SENSOR_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 2), |
510 | } while (0) | 521 | SENSOR_ATTR(fan3_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 3), |
522 | SENSOR_ATTR(fan4_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 4), | ||
523 | SENSOR_ATTR(fan5_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 5), | ||
524 | SENSOR_ATTR(fan6_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 6), | ||
525 | SENSOR_ATTR(fan7_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 7), | ||
526 | }; | ||
511 | 527 | ||
512 | 528 | ||
513 | /* read/write the temperature1, includes measured value and limits */ | 529 | /* read/write the temperature1, includes measured value and limits */ |
@@ -539,21 +555,6 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, | |||
539 | return count; | 555 | return count; |
540 | } | 556 | } |
541 | 557 | ||
542 | |||
543 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0); | ||
544 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1, | ||
545 | store_temp1, 1); | ||
546 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, | ||
547 | store_temp1, 2); | ||
548 | |||
549 | #define device_create_file_temp1(client) \ | ||
550 | do { \ | ||
551 | device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \ | ||
552 | device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \ | ||
553 | device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \ | ||
554 | } while (0) | ||
555 | |||
556 | |||
557 | /* read/write the temperature2-3, includes measured value and limits */ | 558 | /* read/write the temperature2-3, includes measured value and limits */ |
558 | 559 | ||
559 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, | 560 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, |
@@ -590,25 +591,23 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, | |||
590 | return count; | 591 | return count; |
591 | } | 592 | } |
592 | 593 | ||
593 | #define sysfs_temp23(name,idx) \ | 594 | static struct sensor_device_attribute_2 sda_temp_input[] = { |
594 | static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \ | 595 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0), |
595 | idx, 0); \ | 596 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0), |
596 | static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \ | 597 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0), |
597 | show_temp23, store_temp23, idx, 2); \ | 598 | }; |
598 | static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
599 | show_temp23, store_temp23, idx, 4); | ||
600 | |||
601 | sysfs_temp23(temp2,0) | ||
602 | sysfs_temp23(temp3,1) | ||
603 | 599 | ||
604 | #define device_create_file_temp_add(client, offset) \ | 600 | static struct sensor_device_attribute_2 sda_temp_max[] = { |
605 | do { \ | 601 | SENSOR_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 1), |
606 | device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \ | 602 | SENSOR_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 2), |
607 | device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \ | 603 | SENSOR_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 2), |
608 | device_create_file(&client->dev, \ | 604 | }; |
609 | &sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \ | ||
610 | } while (0) | ||
611 | 605 | ||
606 | static struct sensor_device_attribute_2 sda_temp_max_hyst[] = { | ||
607 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 2), | ||
608 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4), | ||
609 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4), | ||
610 | }; | ||
612 | 611 | ||
613 | /* get reatime status of all sensors items: voltage, temp, fan */ | 612 | /* get reatime status of all sensors items: voltage, temp, fan */ |
614 | static ssize_t | 613 | static ssize_t |
@@ -620,10 +619,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | |||
620 | 619 | ||
621 | static | 620 | static |
622 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 621 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
623 | #define device_create_file_alarms(client) \ | ||
624 | device_create_file(&client->dev, &dev_attr_alarms); | ||
625 | |||
626 | |||
627 | 622 | ||
628 | static ssize_t | 623 | static ssize_t |
629 | show_pwm(struct device *dev, struct device_attribute *attr, | 624 | show_pwm(struct device *dev, struct device_attribute *attr, |
@@ -711,26 +706,19 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
711 | return count; | 706 | return count; |
712 | } | 707 | } |
713 | 708 | ||
714 | #define sysfs_pwm(offset) \ | 709 | static struct sensor_device_attribute sda_pwm[] = { |
715 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | 710 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), |
716 | show_pwm, store_pwm, offset); \ | 711 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), |
717 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | 712 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 3), |
718 | show_pwmenable, store_pwmenable, offset); \ | 713 | }; |
719 | 714 | static struct sensor_device_attribute sda_pwm_enable[] = { | |
720 | sysfs_pwm(1); | 715 | SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, |
721 | sysfs_pwm(2); | 716 | show_pwmenable, store_pwmenable, 1), |
722 | sysfs_pwm(3); | 717 | SENSOR_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, |
723 | 718 | show_pwmenable, store_pwmenable, 2), | |
724 | 719 | SENSOR_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, | |
725 | #define device_create_file_pwm(client, offset) \ | 720 | show_pwmenable, store_pwmenable, 3), |
726 | do { \ | 721 | }; |
727 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \ | ||
728 | } while (0) | ||
729 | |||
730 | #define device_create_file_pwmenable(client, offset) \ | ||
731 | do { \ | ||
732 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \ | ||
733 | } while (0) | ||
734 | 722 | ||
735 | 723 | ||
736 | static ssize_t | 724 | static ssize_t |
@@ -764,18 +752,14 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
764 | return count; | 752 | return count; |
765 | } | 753 | } |
766 | 754 | ||
767 | #define sysfs_pwm_mode(offset) \ | 755 | static struct sensor_device_attribute sda_pwm_mode[] = { |
768 | static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \ | 756 | SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, |
769 | show_pwm_mode, store_pwm_mode, offset); | 757 | show_pwm_mode, store_pwm_mode, 1), |
770 | 758 | SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, | |
771 | sysfs_pwm_mode(1); | 759 | show_pwm_mode, store_pwm_mode, 2), |
772 | sysfs_pwm_mode(2); | 760 | SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, |
773 | sysfs_pwm_mode(3); | 761 | show_pwm_mode, store_pwm_mode, 3), |
774 | 762 | }; | |
775 | #define device_create_file_pwm_mode(client, offset) \ | ||
776 | do { \ | ||
777 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \ | ||
778 | } while (0) | ||
779 | 763 | ||
780 | 764 | ||
781 | static ssize_t | 765 | static ssize_t |
@@ -788,12 +772,6 @@ show_regs_chassis(struct device *dev, struct device_attribute *attr, | |||
788 | 772 | ||
789 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); | 773 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); |
790 | 774 | ||
791 | #define device_create_file_chassis(client) \ | ||
792 | do { \ | ||
793 | device_create_file(&client->dev, &dev_attr_chassis); \ | ||
794 | } while (0) | ||
795 | |||
796 | |||
797 | static ssize_t | 775 | static ssize_t |
798 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) | 776 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) |
799 | { | 777 | { |
@@ -824,13 +802,6 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr, | |||
824 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, | 802 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, |
825 | show_chassis_clear, store_chassis_clear); | 803 | show_chassis_clear, store_chassis_clear); |
826 | 804 | ||
827 | #define device_create_file_chassis_clear(client) \ | ||
828 | do { \ | ||
829 | device_create_file(&client->dev, &dev_attr_chassis_clear); \ | ||
830 | } while (0) | ||
831 | |||
832 | |||
833 | |||
834 | /* For Smart Fan I / Thermal Cruise */ | 805 | /* For Smart Fan I / Thermal Cruise */ |
835 | static ssize_t | 806 | static ssize_t |
836 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, | 807 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, |
@@ -864,20 +835,14 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr, | |||
864 | return count; | 835 | return count; |
865 | } | 836 | } |
866 | 837 | ||
867 | #define sysfs_thermal_cruise(offset) \ | 838 | static struct sensor_device_attribute sda_thermal_cruise[] = { |
868 | static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \ | 839 | SENSOR_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO, |
869 | show_thermal_cruise, store_thermal_cruise, offset); | 840 | show_thermal_cruise, store_thermal_cruise, 1), |
870 | 841 | SENSOR_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO, | |
871 | sysfs_thermal_cruise(1); | 842 | show_thermal_cruise, store_thermal_cruise, 2), |
872 | sysfs_thermal_cruise(2); | 843 | SENSOR_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO, |
873 | sysfs_thermal_cruise(3); | 844 | show_thermal_cruise, store_thermal_cruise, 3), |
874 | 845 | }; | |
875 | #define device_create_file_thermal_cruise(client, offset) \ | ||
876 | do { \ | ||
877 | device_create_file(&client->dev, \ | ||
878 | &sensor_dev_attr_thermal_cruise##offset.dev_attr); \ | ||
879 | } while (0) | ||
880 | |||
881 | 846 | ||
882 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ | 847 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ |
883 | static ssize_t | 848 | static ssize_t |
@@ -916,19 +881,14 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
916 | return count; | 881 | return count; |
917 | } | 882 | } |
918 | 883 | ||
919 | #define sysfs_tolerance(offset) \ | 884 | static struct sensor_device_attribute sda_tolerance[] = { |
920 | static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \ | 885 | SENSOR_ATTR(tolerance1, S_IWUSR | S_IRUGO, |
921 | show_tolerance, store_tolerance, offset); | 886 | show_tolerance, store_tolerance, 1), |
922 | 887 | SENSOR_ATTR(tolerance2, S_IWUSR | S_IRUGO, | |
923 | sysfs_tolerance(1); | 888 | show_tolerance, store_tolerance, 2), |
924 | sysfs_tolerance(2); | 889 | SENSOR_ATTR(tolerance3, S_IWUSR | S_IRUGO, |
925 | sysfs_tolerance(3); | 890 | show_tolerance, store_tolerance, 3), |
926 | 891 | }; | |
927 | #define device_create_file_tolerance(client, offset) \ | ||
928 | do { \ | ||
929 | device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \ | ||
930 | } while (0) | ||
931 | |||
932 | 892 | ||
933 | /* For Smart Fan II */ | 893 | /* For Smart Fan II */ |
934 | static ssize_t | 894 | static ssize_t |
@@ -964,28 +924,34 @@ store_sf2_point(struct device *dev, struct device_attribute *attr, | |||
964 | return count; | 924 | return count; |
965 | } | 925 | } |
966 | 926 | ||
967 | #define sysfs_sf2_point(offset, index) \ | 927 | static struct sensor_device_attribute_2 sda_sf2_point[] = { |
968 | static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \ | 928 | SENSOR_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR, |
969 | show_sf2_point, store_sf2_point, offset, index); | 929 | show_sf2_point, store_sf2_point, 1, 1), |
970 | 930 | SENSOR_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR, | |
971 | sysfs_sf2_point(1, 1); /* Fan1 */ | 931 | show_sf2_point, store_sf2_point, 2, 1), |
972 | sysfs_sf2_point(2, 1); /* Fan1 */ | 932 | SENSOR_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR, |
973 | sysfs_sf2_point(3, 1); /* Fan1 */ | 933 | show_sf2_point, store_sf2_point, 3, 1), |
974 | sysfs_sf2_point(4, 1); /* Fan1 */ | 934 | SENSOR_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR, |
975 | sysfs_sf2_point(1, 2); /* Fan2 */ | 935 | show_sf2_point, store_sf2_point, 4, 1), |
976 | sysfs_sf2_point(2, 2); /* Fan2 */ | 936 | |
977 | sysfs_sf2_point(3, 2); /* Fan2 */ | 937 | SENSOR_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR, |
978 | sysfs_sf2_point(4, 2); /* Fan2 */ | 938 | show_sf2_point, store_sf2_point, 1, 2), |
979 | sysfs_sf2_point(1, 3); /* Fan3 */ | 939 | SENSOR_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR, |
980 | sysfs_sf2_point(2, 3); /* Fan3 */ | 940 | show_sf2_point, store_sf2_point, 2, 2), |
981 | sysfs_sf2_point(3, 3); /* Fan3 */ | 941 | SENSOR_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR, |
982 | sysfs_sf2_point(4, 3); /* Fan3 */ | 942 | show_sf2_point, store_sf2_point, 3, 2), |
983 | 943 | SENSOR_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR, | |
984 | #define device_create_file_sf2_point(client, offset, index) \ | 944 | show_sf2_point, store_sf2_point, 4, 2), |
985 | do { \ | 945 | |
986 | device_create_file(&client->dev, \ | 946 | SENSOR_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR, |
987 | &sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \ | 947 | show_sf2_point, store_sf2_point, 1, 3), |
988 | } while (0) | 948 | SENSOR_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR, |
949 | show_sf2_point, store_sf2_point, 2, 3), | ||
950 | SENSOR_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR, | ||
951 | show_sf2_point, store_sf2_point, 3, 3), | ||
952 | SENSOR_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR, | ||
953 | show_sf2_point, store_sf2_point, 4, 3), | ||
954 | }; | ||
989 | 955 | ||
990 | 956 | ||
991 | static ssize_t | 957 | static ssize_t |
@@ -1026,26 +992,28 @@ store_sf2_level(struct device *dev, struct device_attribute *attr, | |||
1026 | return count; | 992 | return count; |
1027 | } | 993 | } |
1028 | 994 | ||
1029 | #define sysfs_sf2_level(offset, index) \ | 995 | static struct sensor_device_attribute_2 sda_sf2_level[] = { |
1030 | static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \ | 996 | SENSOR_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR, |
1031 | show_sf2_level, store_sf2_level, offset, index); | 997 | show_sf2_level, store_sf2_level, 1, 1), |
1032 | 998 | SENSOR_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR, | |
1033 | sysfs_sf2_level(1, 1); /* Fan1 */ | 999 | show_sf2_level, store_sf2_level, 2, 1), |
1034 | sysfs_sf2_level(2, 1); /* Fan1 */ | 1000 | SENSOR_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR, |
1035 | sysfs_sf2_level(3, 1); /* Fan1 */ | 1001 | show_sf2_level, store_sf2_level, 3, 1), |
1036 | sysfs_sf2_level(1, 2); /* Fan2 */ | 1002 | |
1037 | sysfs_sf2_level(2, 2); /* Fan2 */ | 1003 | SENSOR_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR, |
1038 | sysfs_sf2_level(3, 2); /* Fan2 */ | 1004 | show_sf2_level, store_sf2_level, 1, 2), |
1039 | sysfs_sf2_level(1, 3); /* Fan3 */ | 1005 | SENSOR_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR, |
1040 | sysfs_sf2_level(2, 3); /* Fan3 */ | 1006 | show_sf2_level, store_sf2_level, 2, 2), |
1041 | sysfs_sf2_level(3, 3); /* Fan3 */ | 1007 | SENSOR_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR, |
1042 | 1008 | show_sf2_level, store_sf2_level, 3, 2), | |
1043 | #define device_create_file_sf2_level(client, offset, index) \ | 1009 | |
1044 | do { \ | 1010 | SENSOR_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR, |
1045 | device_create_file(&client->dev, \ | 1011 | show_sf2_level, store_sf2_level, 1, 3), |
1046 | &sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \ | 1012 | SENSOR_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR, |
1047 | } while (0) | 1013 | show_sf2_level, store_sf2_level, 2, 3), |
1048 | 1014 | SENSOR_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR, | |
1015 | show_sf2_level, store_sf2_level, 3, 3), | ||
1016 | }; | ||
1049 | 1017 | ||
1050 | /* This function is called when: | 1018 | /* This function is called when: |
1051 | * w83792d_driver is inserted (when this module is loaded), for each | 1019 | * w83792d_driver is inserted (when this module is loaded), for each |
@@ -1147,12 +1115,19 @@ ERROR_SC_0: | |||
1147 | return err; | 1115 | return err; |
1148 | } | 1116 | } |
1149 | 1117 | ||
1118 | static void device_create_file_fan(struct device *dev, int i) | ||
1119 | { | ||
1120 | device_create_file(dev, &sda_fan_input[i].dev_attr); | ||
1121 | device_create_file(dev, &sda_fan_div[i].dev_attr); | ||
1122 | device_create_file(dev, &sda_fan_min[i].dev_attr); | ||
1123 | } | ||
1150 | 1124 | ||
1151 | static int | 1125 | static int |
1152 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | 1126 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) |
1153 | { | 1127 | { |
1154 | int i = 0, val1 = 0, val2; | 1128 | int i = 0, val1 = 0, val2; |
1155 | struct i2c_client *new_client; | 1129 | struct i2c_client *client; |
1130 | struct device *dev; | ||
1156 | struct w83792d_data *data; | 1131 | struct w83792d_data *data; |
1157 | int err = 0; | 1132 | int err = 0; |
1158 | const char *client_name = ""; | 1133 | const char *client_name = ""; |
@@ -1170,12 +1145,13 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1170 | goto ERROR0; | 1145 | goto ERROR0; |
1171 | } | 1146 | } |
1172 | 1147 | ||
1173 | new_client = &data->client; | 1148 | client = &data->client; |
1174 | i2c_set_clientdata(new_client, data); | 1149 | dev = &client->dev; |
1175 | new_client->addr = address; | 1150 | i2c_set_clientdata(client, data); |
1176 | new_client->adapter = adapter; | 1151 | client->addr = address; |
1177 | new_client->driver = &w83792d_driver; | 1152 | client->adapter = adapter; |
1178 | new_client->flags = 0; | 1153 | client->driver = &w83792d_driver; |
1154 | client->flags = 0; | ||
1179 | 1155 | ||
1180 | /* Now, we do the remaining detection. */ | 1156 | /* Now, we do the remaining detection. */ |
1181 | 1157 | ||
@@ -1184,13 +1160,12 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1184 | force_*=... parameter, and the Winbond will be reset to the right | 1160 | force_*=... parameter, and the Winbond will be reset to the right |
1185 | bank. */ | 1161 | bank. */ |
1186 | if (kind < 0) { | 1162 | if (kind < 0) { |
1187 | if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) { | 1163 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) { |
1188 | dev_warn(&new_client->dev, "Detection failed at step " | 1164 | dev_warn(dev, "Detection failed at step 3\n"); |
1189 | "3\n"); | ||
1190 | goto ERROR1; | 1165 | goto ERROR1; |
1191 | } | 1166 | } |
1192 | val1 = w83792d_read_value(new_client, W83792D_REG_BANK); | 1167 | val1 = w83792d_read_value(client, W83792D_REG_BANK); |
1193 | val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); | 1168 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1194 | /* Check for Winbond ID if in bank 0 */ | 1169 | /* Check for Winbond ID if in bank 0 */ |
1195 | if (!(val1 & 0x07)) { /* is Bank0 */ | 1170 | if (!(val1 & 0x07)) { /* is Bank0 */ |
1196 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || | 1171 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || |
@@ -1200,34 +1175,33 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1200 | } | 1175 | } |
1201 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR | 1176 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR |
1202 | should match */ | 1177 | should match */ |
1203 | if (w83792d_read_value(new_client, | 1178 | if (w83792d_read_value(client, |
1204 | W83792D_REG_I2C_ADDR) != address) { | 1179 | W83792D_REG_I2C_ADDR) != address) { |
1205 | dev_warn(&new_client->dev, "Detection failed " | 1180 | dev_warn(dev, "Detection failed at step 5\n"); |
1206 | "at step 5\n"); | ||
1207 | goto ERROR1; | 1181 | goto ERROR1; |
1208 | } | 1182 | } |
1209 | } | 1183 | } |
1210 | 1184 | ||
1211 | /* We have either had a force parameter, or we have already detected the | 1185 | /* We have either had a force parameter, or we have already detected the |
1212 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | 1186 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ |
1213 | w83792d_write_value(new_client, | 1187 | w83792d_write_value(client, |
1214 | W83792D_REG_BANK, | 1188 | W83792D_REG_BANK, |
1215 | (w83792d_read_value(new_client, | 1189 | (w83792d_read_value(client, |
1216 | W83792D_REG_BANK) & 0x78) | 0x80); | 1190 | W83792D_REG_BANK) & 0x78) | 0x80); |
1217 | 1191 | ||
1218 | /* Determine the chip type. */ | 1192 | /* Determine the chip type. */ |
1219 | if (kind <= 0) { | 1193 | if (kind <= 0) { |
1220 | /* get vendor ID */ | 1194 | /* get vendor ID */ |
1221 | val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); | 1195 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1222 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ | 1196 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ |
1223 | goto ERROR1; | 1197 | goto ERROR1; |
1224 | } | 1198 | } |
1225 | val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); | 1199 | val1 = w83792d_read_value(client, W83792D_REG_WCHIPID); |
1226 | if (val1 == 0x7a) { | 1200 | if (val1 == 0x7a) { |
1227 | kind = w83792d; | 1201 | kind = w83792d; |
1228 | } else { | 1202 | } else { |
1229 | if (kind == 0) | 1203 | if (kind == 0) |
1230 | dev_warn(&new_client->dev, | 1204 | dev_warn(dev, |
1231 | "w83792d: Ignoring 'force' parameter for" | 1205 | "w83792d: Ignoring 'force' parameter for" |
1232 | " unknown chip at adapter %d, address" | 1206 | " unknown chip at adapter %d, address" |
1233 | " 0x%02x\n", i2c_adapter_id(adapter), | 1207 | " 0x%02x\n", i2c_adapter_id(adapter), |
@@ -1239,120 +1213,86 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1239 | if (kind == w83792d) { | 1213 | if (kind == w83792d) { |
1240 | client_name = "w83792d"; | 1214 | client_name = "w83792d"; |
1241 | } else { | 1215 | } else { |
1242 | dev_err(&new_client->dev, "w83792d: Internal error: unknown" | 1216 | dev_err(dev, "w83792d: Internal error: unknown" |
1243 | " kind (%d)?!?", kind); | 1217 | " kind (%d)?!?", kind); |
1244 | goto ERROR1; | 1218 | goto ERROR1; |
1245 | } | 1219 | } |
1246 | 1220 | ||
1247 | /* Fill in the remaining client fields and put into the global list */ | 1221 | /* Fill in the remaining client fields and put into the global list */ |
1248 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 1222 | strlcpy(client->name, client_name, I2C_NAME_SIZE); |
1249 | data->type = kind; | 1223 | data->type = kind; |
1250 | 1224 | ||
1251 | data->valid = 0; | 1225 | data->valid = 0; |
1252 | init_MUTEX(&data->update_lock); | 1226 | mutex_init(&data->update_lock); |
1253 | 1227 | ||
1254 | /* Tell the I2C layer a new client has arrived */ | 1228 | /* Tell the I2C layer a new client has arrived */ |
1255 | if ((err = i2c_attach_client(new_client))) | 1229 | if ((err = i2c_attach_client(client))) |
1256 | goto ERROR1; | 1230 | goto ERROR1; |
1257 | 1231 | ||
1258 | if ((err = w83792d_detect_subclients(adapter, address, | 1232 | if ((err = w83792d_detect_subclients(adapter, address, |
1259 | kind, new_client))) | 1233 | kind, client))) |
1260 | goto ERROR2; | 1234 | goto ERROR2; |
1261 | 1235 | ||
1262 | /* Initialize the chip */ | 1236 | /* Initialize the chip */ |
1263 | w83792d_init_client(new_client); | 1237 | w83792d_init_client(client); |
1264 | 1238 | ||
1265 | /* A few vars need to be filled upon startup */ | 1239 | /* A few vars need to be filled upon startup */ |
1266 | for (i = 0; i < 7; i++) { | 1240 | for (i = 0; i < 7; i++) { |
1267 | data->fan_min[i] = w83792d_read_value(new_client, | 1241 | data->fan_min[i] = w83792d_read_value(client, |
1268 | W83792D_REG_FAN_MIN[i]); | 1242 | W83792D_REG_FAN_MIN[i]); |
1269 | } | 1243 | } |
1270 | 1244 | ||
1271 | /* Register sysfs hooks */ | 1245 | /* Register sysfs hooks */ |
1272 | data->class_dev = hwmon_device_register(&new_client->dev); | 1246 | data->class_dev = hwmon_device_register(dev); |
1273 | if (IS_ERR(data->class_dev)) { | 1247 | if (IS_ERR(data->class_dev)) { |
1274 | err = PTR_ERR(data->class_dev); | 1248 | err = PTR_ERR(data->class_dev); |
1275 | goto ERROR3; | 1249 | goto ERROR3; |
1276 | } | 1250 | } |
1277 | device_create_file_in(new_client, 0); | 1251 | for (i = 0; i < 9; i++) { |
1278 | device_create_file_in(new_client, 1); | 1252 | device_create_file(dev, &sda_in_input[i].dev_attr); |
1279 | device_create_file_in(new_client, 2); | 1253 | device_create_file(dev, &sda_in_max[i].dev_attr); |
1280 | device_create_file_in(new_client, 3); | 1254 | device_create_file(dev, &sda_in_min[i].dev_attr); |
1281 | device_create_file_in(new_client, 4); | 1255 | } |
1282 | device_create_file_in(new_client, 5); | 1256 | for (i = 0; i < 3; i++) |
1283 | device_create_file_in(new_client, 6); | 1257 | device_create_file_fan(dev, i); |
1284 | device_create_file_in(new_client, 7); | ||
1285 | device_create_file_in(new_client, 8); | ||
1286 | |||
1287 | device_create_file_fan(new_client, 1); | ||
1288 | device_create_file_fan(new_client, 2); | ||
1289 | device_create_file_fan(new_client, 3); | ||
1290 | 1258 | ||
1291 | /* Read GPIO enable register to check if pins for fan 4,5 are used as | 1259 | /* Read GPIO enable register to check if pins for fan 4,5 are used as |
1292 | GPIO */ | 1260 | GPIO */ |
1293 | val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN); | 1261 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); |
1294 | if (!(val1 & 0x40)) | 1262 | if (!(val1 & 0x40)) |
1295 | device_create_file_fan(new_client, 4); | 1263 | device_create_file_fan(dev, 3); |
1296 | if (!(val1 & 0x20)) | 1264 | if (!(val1 & 0x20)) |
1297 | device_create_file_fan(new_client, 5); | 1265 | device_create_file_fan(dev, 4); |
1298 | 1266 | ||
1299 | val1 = w83792d_read_value(new_client, W83792D_REG_PIN); | 1267 | val1 = w83792d_read_value(client, W83792D_REG_PIN); |
1300 | if (val1 & 0x40) | 1268 | if (val1 & 0x40) |
1301 | device_create_file_fan(new_client, 6); | 1269 | device_create_file_fan(dev, 5); |
1302 | if (val1 & 0x04) | 1270 | if (val1 & 0x04) |
1303 | device_create_file_fan(new_client, 7); | 1271 | device_create_file_fan(dev, 6); |
1304 | 1272 | ||
1305 | device_create_file_temp1(new_client); /* Temp1 */ | 1273 | for (i = 0; i < 3; i++) { |
1306 | device_create_file_temp_add(new_client, 2); /* Temp2 */ | 1274 | device_create_file(dev, &sda_temp_input[i].dev_attr); |
1307 | device_create_file_temp_add(new_client, 3); /* Temp3 */ | 1275 | device_create_file(dev, &sda_temp_max[i].dev_attr); |
1308 | 1276 | device_create_file(dev, &sda_temp_max_hyst[i].dev_attr); | |
1309 | device_create_file_alarms(new_client); | 1277 | device_create_file(dev, &sda_thermal_cruise[i].dev_attr); |
1310 | 1278 | device_create_file(dev, &sda_tolerance[i].dev_attr); | |
1311 | device_create_file_pwm(new_client, 1); | 1279 | } |
1312 | device_create_file_pwm(new_client, 2); | 1280 | |
1313 | device_create_file_pwm(new_client, 3); | 1281 | for (i = 0; i < ARRAY_SIZE(sda_pwm); i++) { |
1314 | 1282 | device_create_file(dev, &sda_pwm[i].dev_attr); | |
1315 | device_create_file_pwmenable(new_client, 1); | 1283 | device_create_file(dev, &sda_pwm_enable[i].dev_attr); |
1316 | device_create_file_pwmenable(new_client, 2); | 1284 | device_create_file(dev, &sda_pwm_mode[i].dev_attr); |
1317 | device_create_file_pwmenable(new_client, 3); | 1285 | } |
1318 | 1286 | ||
1319 | device_create_file_pwm_mode(new_client, 1); | 1287 | device_create_file(dev, &dev_attr_alarms); |
1320 | device_create_file_pwm_mode(new_client, 2); | 1288 | device_create_file(dev, &dev_attr_chassis); |
1321 | device_create_file_pwm_mode(new_client, 3); | 1289 | device_create_file(dev, &dev_attr_chassis_clear); |
1322 | 1290 | ||
1323 | device_create_file_chassis(new_client); | 1291 | for (i = 0; i < ARRAY_SIZE(sda_sf2_point); i++) |
1324 | device_create_file_chassis_clear(new_client); | 1292 | device_create_file(dev, &sda_sf2_point[i].dev_attr); |
1325 | 1293 | ||
1326 | device_create_file_thermal_cruise(new_client, 1); | 1294 | for (i = 0; i < ARRAY_SIZE(sda_sf2_level); i++) |
1327 | device_create_file_thermal_cruise(new_client, 2); | 1295 | device_create_file(dev, &sda_sf2_level[i].dev_attr); |
1328 | device_create_file_thermal_cruise(new_client, 3); | ||
1329 | |||
1330 | device_create_file_tolerance(new_client, 1); | ||
1331 | device_create_file_tolerance(new_client, 2); | ||
1332 | device_create_file_tolerance(new_client, 3); | ||
1333 | |||
1334 | device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */ | ||
1335 | device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */ | ||
1336 | device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */ | ||
1337 | device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */ | ||
1338 | device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */ | ||
1339 | device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */ | ||
1340 | device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */ | ||
1341 | device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */ | ||
1342 | device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */ | ||
1343 | device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */ | ||
1344 | device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */ | ||
1345 | device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */ | ||
1346 | |||
1347 | device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */ | ||
1348 | device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */ | ||
1349 | device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */ | ||
1350 | device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */ | ||
1351 | device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */ | ||
1352 | device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */ | ||
1353 | device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */ | ||
1354 | device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */ | ||
1355 | device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */ | ||
1356 | 1296 | ||
1357 | return 0; | 1297 | return 0; |
1358 | 1298 | ||
@@ -1366,7 +1306,7 @@ ERROR3: | |||
1366 | kfree(data->lm75[1]); | 1306 | kfree(data->lm75[1]); |
1367 | } | 1307 | } |
1368 | ERROR2: | 1308 | ERROR2: |
1369 | i2c_detach_client(new_client); | 1309 | i2c_detach_client(client); |
1370 | ERROR1: | 1310 | ERROR1: |
1371 | kfree(data); | 1311 | kfree(data); |
1372 | ERROR0: | 1312 | ERROR0: |
@@ -1434,7 +1374,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1434 | int i, j; | 1374 | int i, j; |
1435 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; | 1375 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; |
1436 | 1376 | ||
1437 | down(&data->update_lock); | 1377 | mutex_lock(&data->update_lock); |
1438 | 1378 | ||
1439 | if (time_after | 1379 | if (time_after |
1440 | (jiffies - data->last_updated, (unsigned long) (HZ * 3)) | 1380 | (jiffies - data->last_updated, (unsigned long) (HZ * 3)) |
@@ -1545,7 +1485,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1545 | data->valid = 1; | 1485 | data->valid = 1; |
1546 | } | 1486 | } |
1547 | 1487 | ||
1548 | up(&data->update_lock); | 1488 | mutex_unlock(&data->update_lock); |
1549 | 1489 | ||
1550 | #ifdef DEBUG | 1490 | #ifdef DEBUG |
1551 | w83792d_print_debug(data, dev); | 1491 | w83792d_print_debug(data, dev); |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index f66c0cfdeda7..3f2bac125fb1 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/hwmon-sysfs.h> | 40 | #include <linux/hwmon-sysfs.h> |
41 | #include <linux/err.h> | 41 | #include <linux/err.h> |
42 | #include <linux/mutex.h> | ||
42 | 43 | ||
43 | /* How many retries on register read error */ | 44 | /* How many retries on register read error */ |
44 | #define MAX_RETRIES 5 | 45 | #define MAX_RETRIES 5 |
@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = { | |||
107 | struct w83l785ts_data { | 108 | struct w83l785ts_data { |
108 | struct i2c_client client; | 109 | struct i2c_client client; |
109 | struct class_device *class_dev; | 110 | struct class_device *class_dev; |
110 | struct semaphore update_lock; | 111 | struct mutex update_lock; |
111 | char valid; /* zero until following fields are valid */ | 112 | char valid; /* zero until following fields are valid */ |
112 | unsigned long last_updated; /* in jiffies */ | 113 | unsigned long last_updated; /* in jiffies */ |
113 | 114 | ||
@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
221 | /* We can fill in the remaining client fields. */ | 222 | /* We can fill in the remaining client fields. */ |
222 | strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); | 223 | strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); |
223 | data->valid = 0; | 224 | data->valid = 0; |
224 | init_MUTEX(&data->update_lock); | 225 | mutex_init(&data->update_lock); |
225 | 226 | ||
226 | /* Default values in case the first read fails (unlikely). */ | 227 | /* Default values in case the first read fails (unlikely). */ |
227 | data->temp[1] = data->temp[0] = 0; | 228 | data->temp[1] = data->temp[0] = 0; |
@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
299 | struct i2c_client *client = to_i2c_client(dev); | 300 | struct i2c_client *client = to_i2c_client(dev); |
300 | struct w83l785ts_data *data = i2c_get_clientdata(client); | 301 | struct w83l785ts_data *data = i2c_get_clientdata(client); |
301 | 302 | ||
302 | down(&data->update_lock); | 303 | mutex_lock(&data->update_lock); |
303 | 304 | ||
304 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { | 305 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { |
305 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); | 306 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); |
@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
312 | data->valid = 1; | 313 | data->valid = 1; |
313 | } | 314 | } |
314 | 315 | ||
315 | up(&data->update_lock); | 316 | mutex_unlock(&data->update_lock); |
316 | 317 | ||
317 | return data; | 318 | return data; |
318 | } | 319 | } |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index ff92735c7c85..089c6f5b24de 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -168,12 +168,14 @@ config I2C_PIIX4 | |||
168 | help | 168 | help |
169 | If you say yes to this option, support will be included for the Intel | 169 | If you say yes to this option, support will be included for the Intel |
170 | PIIX4 family of mainboard I2C interfaces. Specifically, the following | 170 | PIIX4 family of mainboard I2C interfaces. Specifically, the following |
171 | versions of the chipset are supported: | 171 | versions of the chipset are supported (note that Serverworks is part |
172 | of Broadcom): | ||
172 | Intel PIIX4 | 173 | Intel PIIX4 |
173 | Intel 440MX | 174 | Intel 440MX |
174 | Serverworks OSB4 | 175 | Serverworks OSB4 |
175 | Serverworks CSB5 | 176 | Serverworks CSB5 |
176 | Serverworks CSB6 | 177 | Serverworks CSB6 |
178 | Serverworks HT-1000 | ||
177 | SMSC Victory66 | 179 | SMSC Victory66 |
178 | 180 | ||
179 | This driver can also be built as a module. If so, the module | 181 | This driver can also be built as a module. If so, the module |
@@ -389,10 +391,11 @@ config SCx200_I2C_SDA | |||
389 | also be specified with a module parameter. | 391 | also be specified with a module parameter. |
390 | 392 | ||
391 | config SCx200_ACB | 393 | config SCx200_ACB |
392 | tristate "NatSemi SCx200 ACCESS.bus" | 394 | tristate "Geode ACCESS.bus support" |
393 | depends on I2C && PCI | 395 | depends on X86_32 && I2C && PCI |
394 | help | 396 | help |
395 | Enable the use of the ACCESS.bus controllers of a SCx200 processor. | 397 | Enable the use of the ACCESS.bus controllers on the Geode SCx200 and |
398 | SC1100 processors and the CS5535 and CS5536 Geode companion devices. | ||
396 | 399 | ||
397 | If you don't know what to do here, say N. | 400 | If you don't know what to do here, say N. |
398 | 401 | ||
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index 3eb47890db40..d3ef46aeeb3c 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -63,7 +63,6 @@ | |||
63 | #include <linux/i2c.h> | 63 | #include <linux/i2c.h> |
64 | #include <linux/init.h> | 64 | #include <linux/init.h> |
65 | #include <asm/io.h> | 65 | #include <asm/io.h> |
66 | #include <asm/semaphore.h> | ||
67 | 66 | ||
68 | 67 | ||
69 | /* ALI1535 SMBus address offsets */ | 68 | /* ALI1535 SMBus address offsets */ |
@@ -136,7 +135,6 @@ | |||
136 | 135 | ||
137 | static struct pci_driver ali1535_driver; | 136 | static struct pci_driver ali1535_driver; |
138 | static unsigned short ali1535_smba; | 137 | static unsigned short ali1535_smba; |
139 | static DECLARE_MUTEX(i2c_ali1535_sem); | ||
140 | 138 | ||
141 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. | 139 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. |
142 | Note the differences between kernels with the old PCI BIOS interface and | 140 | Note the differences between kernels with the old PCI BIOS interface and |
@@ -345,7 +343,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
345 | int timeout; | 343 | int timeout; |
346 | s32 result = 0; | 344 | s32 result = 0; |
347 | 345 | ||
348 | down(&i2c_ali1535_sem); | ||
349 | /* make sure SMBus is idle */ | 346 | /* make sure SMBus is idle */ |
350 | temp = inb_p(SMBHSTSTS); | 347 | temp = inb_p(SMBHSTSTS); |
351 | for (timeout = 0; | 348 | for (timeout = 0; |
@@ -460,7 +457,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
460 | break; | 457 | break; |
461 | } | 458 | } |
462 | EXIT: | 459 | EXIT: |
463 | up(&i2c_ali1535_sem); | ||
464 | return result; | 460 | return result; |
465 | } | 461 | } |
466 | 462 | ||
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 56c7d987590f..08e915730caf 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
41 | #include <linux/mutex.h> | ||
41 | 42 | ||
42 | extern struct i2c_adapter amd756_smbus; | 43 | extern struct i2c_adapter amd756_smbus; |
43 | 44 | ||
@@ -45,7 +46,7 @@ static struct i2c_adapter *s4882_adapter; | |||
45 | static struct i2c_algorithm *s4882_algo; | 46 | static struct i2c_algorithm *s4882_algo; |
46 | 47 | ||
47 | /* Wrapper access functions for multiplexed SMBus */ | 48 | /* Wrapper access functions for multiplexed SMBus */ |
48 | static struct semaphore amd756_lock; | 49 | static DEFINE_MUTEX(amd756_lock); |
49 | 50 | ||
50 | static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, | 51 | static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, |
51 | unsigned short flags, char read_write, | 52 | unsigned short flags, char read_write, |
@@ -59,12 +60,12 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, | |||
59 | || addr == 0x18) | 60 | || addr == 0x18) |
60 | return -1; | 61 | return -1; |
61 | 62 | ||
62 | down(&amd756_lock); | 63 | mutex_lock(&amd756_lock); |
63 | 64 | ||
64 | error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, | 65 | error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, |
65 | command, size, data); | 66 | command, size, data); |
66 | 67 | ||
67 | up(&amd756_lock); | 68 | mutex_unlock(&amd756_lock); |
68 | 69 | ||
69 | return error; | 70 | return error; |
70 | } | 71 | } |
@@ -87,7 +88,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr, | |||
87 | if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) | 88 | if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) |
88 | return -1; | 89 | return -1; |
89 | 90 | ||
90 | down(&amd756_lock); | 91 | mutex_lock(&amd756_lock); |
91 | 92 | ||
92 | if (last_channels != channels) { | 93 | if (last_channels != channels) { |
93 | union i2c_smbus_data mplxdata; | 94 | union i2c_smbus_data mplxdata; |
@@ -105,7 +106,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr, | |||
105 | command, size, data); | 106 | command, size, data); |
106 | 107 | ||
107 | UNLOCK: | 108 | UNLOCK: |
108 | up(&amd756_lock); | 109 | mutex_unlock(&amd756_lock); |
109 | return error; | 110 | return error; |
110 | } | 111 | } |
111 | 112 | ||
@@ -166,8 +167,6 @@ static int __init amd756_s4882_init(void) | |||
166 | } | 167 | } |
167 | 168 | ||
168 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); | 169 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); |
169 | init_MUTEX(&amd756_lock); | ||
170 | |||
171 | /* Define the 5 virtual adapters and algorithms structures */ | 170 | /* Define the 5 virtual adapters and algorithms structures */ |
172 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), | 171 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), |
173 | GFP_KERNEL))) { | 172 | GFP_KERNEL))) { |
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c deleted file mode 100644 index b6f52f5a4138..000000000000 --- a/drivers/i2c/busses/i2c-frodo.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | |||
2 | /* | ||
3 | * linux/drivers/i2c/i2c-frodo.c | ||
4 | * | ||
5 | * Author: Abraham van der Merwe <abraham@2d3d.co.za> | ||
6 | * | ||
7 | * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110 | ||
8 | * Development board (Frodo). | ||
9 | * | ||
10 | * This source code is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/i2c-algo-bit.h> | ||
21 | #include <asm/hardware.h> | ||
22 | |||
23 | |||
24 | static void frodo_setsda (void *data,int state) | ||
25 | { | ||
26 | if (state) | ||
27 | FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT; | ||
28 | else | ||
29 | FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT; | ||
30 | } | ||
31 | |||
32 | static void frodo_setscl (void *data,int state) | ||
33 | { | ||
34 | if (state) | ||
35 | FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT; | ||
36 | else | ||
37 | FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT; | ||
38 | } | ||
39 | |||
40 | static int frodo_getsda (void *data) | ||
41 | { | ||
42 | return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0); | ||
43 | } | ||
44 | |||
45 | static int frodo_getscl (void *data) | ||
46 | { | ||
47 | return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0); | ||
48 | } | ||
49 | |||
50 | static struct i2c_algo_bit_data bit_frodo_data = { | ||
51 | .setsda = frodo_setsda, | ||
52 | .setscl = frodo_setscl, | ||
53 | .getsda = frodo_getsda, | ||
54 | .getscl = frodo_getscl, | ||
55 | .udelay = 80, | ||
56 | .mdelay = 80, | ||
57 | .timeout = HZ | ||
58 | }; | ||
59 | |||
60 | static struct i2c_adapter frodo_ops = { | ||
61 | .owner = THIS_MODULE, | ||
62 | .id = I2C_HW_B_FRODO, | ||
63 | .algo_data = &bit_frodo_data, | ||
64 | .dev = { | ||
65 | .name = "Frodo adapter driver", | ||
66 | }, | ||
67 | }; | ||
68 | |||
69 | static int __init i2c_frodo_init (void) | ||
70 | { | ||
71 | return i2c_bit_add_bus(&frodo_ops); | ||
72 | } | ||
73 | |||
74 | static void __exit i2c_frodo_exit (void) | ||
75 | { | ||
76 | i2c_bit_del_bus(&frodo_ops); | ||
77 | } | ||
78 | |||
79 | MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>"); | ||
80 | MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo"); | ||
81 | MODULE_LICENSE ("GPL"); | ||
82 | |||
83 | module_init (i2c_frodo_init); | ||
84 | module_exit (i2c_frodo_exit); | ||
85 | |||
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 4344ae6b1fcb..c3e1d3e888d7 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -125,7 +125,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver) | |||
125 | 125 | ||
126 | static int __init i2c_isa_init(void) | 126 | static int __init i2c_isa_init(void) |
127 | { | 127 | { |
128 | init_MUTEX(&isa_adapter.clist_lock); | 128 | mutex_init(&isa_adapter.clist_lock); |
129 | INIT_LIST_HEAD(&isa_adapter.clients); | 129 | INIT_LIST_HEAD(&isa_adapter.clients); |
130 | 130 | ||
131 | isa_adapter.nr = ANY_I2C_ISA_BUS; | 131 | isa_adapter.nr = ANY_I2C_ISA_BUS; |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c index 5f5d2944808b..d82e6dae8407 100644 --- a/drivers/i2c/busses/i2c-ite.c +++ b/drivers/i2c/busses/i2c-ite.c | |||
@@ -200,9 +200,7 @@ static struct i2c_adapter iic_ite_ops = { | |||
200 | .owner = THIS_MODULE, | 200 | .owner = THIS_MODULE, |
201 | .id = I2C_HW_I_IIC, | 201 | .id = I2C_HW_I_IIC, |
202 | .algo_data = &iic_ite_data, | 202 | .algo_data = &iic_ite_data, |
203 | .dev = { | 203 | .name = "ITE IIC adapter", |
204 | .name = "ITE IIC adapter", | ||
205 | }, | ||
206 | }; | 204 | }; |
207 | 205 | ||
208 | /* Called when the module is loaded. This function starts the | 206 | /* Called when the module is loaded. This function starts the |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index e422d8b2d4d6..2ed07112d683 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -126,6 +126,7 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev) | |||
126 | drv_data->algo_data.timeout = 100; | 126 | drv_data->algo_data.timeout = 100; |
127 | 127 | ||
128 | drv_data->adapter.id = I2C_HW_B_IXP4XX; | 128 | drv_data->adapter.id = I2C_HW_B_IXP4XX; |
129 | drv_data->adapter.class = I2C_CLASS_HWMON; | ||
129 | strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, | 130 | strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, |
130 | I2C_NAME_SIZE); | 131 | I2C_NAME_SIZE); |
131 | drv_data->adapter.algo_data = &drv_data->algo_data; | 132 | drv_data->adapter.algo_data = &drv_data->algo_data; |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 692f47345481..d9c7c00e71f9 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -22,7 +22,7 @@ | |||
22 | /* | 22 | /* |
23 | Supports: | 23 | Supports: |
24 | Intel PIIX4, 440MX | 24 | Intel PIIX4, 440MX |
25 | Serverworks OSB4, CSB5, CSB6 | 25 | Serverworks OSB4, CSB5, CSB6, HT-1000 |
26 | SMSC Victory66 | 26 | SMSC Victory66 |
27 | 27 | ||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one SMBus interface. |
@@ -419,6 +419,8 @@ static struct pci_device_id piix4_ids[] = { | |||
419 | .driver_data = 0 }, | 419 | .driver_data = 0 }, |
420 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), | 420 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), |
421 | .driver_data = 0 }, | 421 | .driver_data = 0 }, |
422 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB), | ||
423 | .driver_data = 0 }, | ||
422 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), | 424 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), |
423 | .driver_data = 3 }, | 425 | .driver_data = 3 }, |
424 | { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), | 426 | { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 7579f4b256a8..5155010b455e 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -647,7 +647,7 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c) | |||
647 | } | 647 | } |
648 | 648 | ||
649 | /* | 649 | /* |
650 | * We are protected by the adapter bus semaphore. | 650 | * We are protected by the adapter bus mutex. |
651 | */ | 651 | */ |
652 | static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) | 652 | static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) |
653 | { | 653 | { |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index d3478e084522..8bd305e47f0d 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -1,27 +1,26 @@ | |||
1 | /* linux/drivers/i2c/scx200_acb.c | 1 | /* |
2 | |||
3 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> | 2 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> |
4 | 3 | ||
5 | National Semiconductor SCx200 ACCESS.bus support | 4 | National Semiconductor SCx200 ACCESS.bus support |
6 | 5 | Also supports the AMD CS5535 and AMD CS5536 | |
6 | |||
7 | Based on i2c-keywest.c which is: | 7 | Based on i2c-keywest.c which is: |
8 | Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> | 8 | Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> |
9 | Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> | 9 | Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> |
10 | 10 | ||
11 | This program is free software; you can redistribute it and/or | 11 | This program is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU General Public License as | 12 | modify it under the terms of the GNU General Public License as |
13 | published by the Free Software Foundation; either version 2 of the | 13 | published by the Free Software Foundation; either version 2 of the |
14 | License, or (at your option) any later version. | 14 | License, or (at your option) any later version. |
15 | 15 | ||
16 | This program is distributed in the hope that it will be useful, | 16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | General Public License for more details. | 19 | General Public License for more details. |
20 | 20 | ||
21 | You should have received a copy of the GNU General Public License | 21 | You should have received a copy of the GNU General Public License |
22 | along with this program; if not, write to the Free Software | 22 | along with this program; if not, write to the Free Software |
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | |||
25 | */ | 24 | */ |
26 | 25 | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
@@ -32,7 +31,9 @@ | |||
32 | #include <linux/smp_lock.h> | 31 | #include <linux/smp_lock.h> |
33 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/mutex.h> | ||
35 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/msr.h> | ||
36 | 37 | ||
37 | #include <linux/scx200.h> | 38 | #include <linux/scx200.h> |
38 | 39 | ||
@@ -47,16 +48,7 @@ static int base[MAX_DEVICES] = { 0x820, 0x840 }; | |||
47 | module_param_array(base, int, NULL, 0); | 48 | module_param_array(base, int, NULL, 0); |
48 | MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); | 49 | MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); |
49 | 50 | ||
50 | #ifdef DEBUG | 51 | #define POLL_TIMEOUT (HZ/5) |
51 | #define DBG(x...) printk(KERN_DEBUG NAME ": " x) | ||
52 | #else | ||
53 | #define DBG(x...) | ||
54 | #endif | ||
55 | |||
56 | /* The hardware supports interrupt driven mode too, but I haven't | ||
57 | implemented that. */ | ||
58 | #define POLLED_MODE 1 | ||
59 | #define POLL_TIMEOUT (HZ) | ||
60 | 52 | ||
61 | enum scx200_acb_state { | 53 | enum scx200_acb_state { |
62 | state_idle, | 54 | state_idle, |
@@ -79,12 +71,11 @@ static const char *scx200_acb_state_name[] = { | |||
79 | }; | 71 | }; |
80 | 72 | ||
81 | /* Physical interface */ | 73 | /* Physical interface */ |
82 | struct scx200_acb_iface | 74 | struct scx200_acb_iface { |
83 | { | ||
84 | struct scx200_acb_iface *next; | 75 | struct scx200_acb_iface *next; |
85 | struct i2c_adapter adapter; | 76 | struct i2c_adapter adapter; |
86 | unsigned base; | 77 | unsigned base; |
87 | struct semaphore sem; | 78 | struct mutex mutex; |
88 | 79 | ||
89 | /* State machine data */ | 80 | /* State machine data */ |
90 | enum scx200_acb_state state; | 81 | enum scx200_acb_state state; |
@@ -100,7 +91,7 @@ struct scx200_acb_iface | |||
100 | #define ACBSDA (iface->base + 0) | 91 | #define ACBSDA (iface->base + 0) |
101 | #define ACBST (iface->base + 1) | 92 | #define ACBST (iface->base + 1) |
102 | #define ACBST_SDAST 0x40 /* SDA Status */ | 93 | #define ACBST_SDAST 0x40 /* SDA Status */ |
103 | #define ACBST_BER 0x20 | 94 | #define ACBST_BER 0x20 |
104 | #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ | 95 | #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ |
105 | #define ACBST_STASTR 0x08 /* Stall After Start */ | 96 | #define ACBST_STASTR 0x08 /* Stall After Start */ |
106 | #define ACBST_MASTER 0x02 | 97 | #define ACBST_MASTER 0x02 |
@@ -109,9 +100,9 @@ struct scx200_acb_iface | |||
109 | #define ACBCTL1 (iface->base + 3) | 100 | #define ACBCTL1 (iface->base + 3) |
110 | #define ACBCTL1_STASTRE 0x80 | 101 | #define ACBCTL1_STASTRE 0x80 |
111 | #define ACBCTL1_NMINTE 0x40 | 102 | #define ACBCTL1_NMINTE 0x40 |
112 | #define ACBCTL1_ACK 0x10 | 103 | #define ACBCTL1_ACK 0x10 |
113 | #define ACBCTL1_STOP 0x02 | 104 | #define ACBCTL1_STOP 0x02 |
114 | #define ACBCTL1_START 0x01 | 105 | #define ACBCTL1_START 0x01 |
115 | #define ACBADDR (iface->base + 4) | 106 | #define ACBADDR (iface->base + 4) |
116 | #define ACBCTL2 (iface->base + 5) | 107 | #define ACBCTL2 (iface->base + 5) |
117 | #define ACBCTL2_ENABLE 0x01 | 108 | #define ACBCTL2_ENABLE 0x01 |
@@ -122,8 +113,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
122 | { | 113 | { |
123 | const char *errmsg; | 114 | const char *errmsg; |
124 | 115 | ||
125 | DBG("state %s, status = 0x%02x\n", | 116 | dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n", |
126 | scx200_acb_state_name[iface->state], status); | 117 | scx200_acb_state_name[iface->state], status); |
127 | 118 | ||
128 | if (status & ACBST_BER) { | 119 | if (status & ACBST_BER) { |
129 | errmsg = "bus error"; | 120 | errmsg = "bus error"; |
@@ -133,8 +124,17 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
133 | errmsg = "not master"; | 124 | errmsg = "not master"; |
134 | goto error; | 125 | goto error; |
135 | } | 126 | } |
136 | if (status & ACBST_NEGACK) | 127 | if (status & ACBST_NEGACK) { |
137 | goto negack; | 128 | dev_dbg(&iface->adapter.dev, "negative ack in state %s\n", |
129 | scx200_acb_state_name[iface->state]); | ||
130 | |||
131 | iface->state = state_idle; | ||
132 | iface->result = -ENXIO; | ||
133 | |||
134 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | ||
135 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); | ||
136 | return; | ||
137 | } | ||
138 | 138 | ||
139 | switch (iface->state) { | 139 | switch (iface->state) { |
140 | case state_idle: | 140 | case state_idle: |
@@ -160,10 +160,10 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
160 | case state_repeat_start: | 160 | case state_repeat_start: |
161 | outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); | 161 | outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); |
162 | /* fallthrough */ | 162 | /* fallthrough */ |
163 | 163 | ||
164 | case state_quick: | 164 | case state_quick: |
165 | if (iface->address_byte & 1) { | 165 | if (iface->address_byte & 1) { |
166 | if (iface->len == 1) | 166 | if (iface->len == 1) |
167 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); | 167 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); |
168 | else | 168 | else |
169 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); | 169 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); |
@@ -202,26 +202,15 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
202 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | 202 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); |
203 | break; | 203 | break; |
204 | } | 204 | } |
205 | 205 | ||
206 | outb(*iface->ptr++, ACBSDA); | 206 | outb(*iface->ptr++, ACBSDA); |
207 | --iface->len; | 207 | --iface->len; |
208 | 208 | ||
209 | break; | 209 | break; |
210 | } | 210 | } |
211 | 211 | ||
212 | return; | 212 | return; |
213 | 213 | ||
214 | negack: | ||
215 | DBG("negative acknowledge in state %s\n", | ||
216 | scx200_acb_state_name[iface->state]); | ||
217 | |||
218 | iface->state = state_idle; | ||
219 | iface->result = -ENXIO; | ||
220 | |||
221 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | ||
222 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); | ||
223 | return; | ||
224 | |||
225 | error: | 214 | error: |
226 | dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, | 215 | dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, |
227 | scx200_acb_state_name[iface->state]); | 216 | scx200_acb_state_name[iface->state]); |
@@ -231,20 +220,9 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
231 | iface->needs_reset = 1; | 220 | iface->needs_reset = 1; |
232 | } | 221 | } |
233 | 222 | ||
234 | static void scx200_acb_timeout(struct scx200_acb_iface *iface) | ||
235 | { | ||
236 | dev_err(&iface->adapter.dev, "timeout in state %s\n", | ||
237 | scx200_acb_state_name[iface->state]); | ||
238 | |||
239 | iface->state = state_idle; | ||
240 | iface->result = -EIO; | ||
241 | iface->needs_reset = 1; | ||
242 | } | ||
243 | |||
244 | #ifdef POLLED_MODE | ||
245 | static void scx200_acb_poll(struct scx200_acb_iface *iface) | 223 | static void scx200_acb_poll(struct scx200_acb_iface *iface) |
246 | { | 224 | { |
247 | u8 status = 0; | 225 | u8 status; |
248 | unsigned long timeout; | 226 | unsigned long timeout; |
249 | 227 | ||
250 | timeout = jiffies + POLL_TIMEOUT; | 228 | timeout = jiffies + POLL_TIMEOUT; |
@@ -254,17 +232,21 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface) | |||
254 | scx200_acb_machine(iface, status); | 232 | scx200_acb_machine(iface, status); |
255 | return; | 233 | return; |
256 | } | 234 | } |
257 | msleep(10); | 235 | yield(); |
258 | } | 236 | } |
259 | 237 | ||
260 | scx200_acb_timeout(iface); | 238 | dev_err(&iface->adapter.dev, "timeout in state %s\n", |
239 | scx200_acb_state_name[iface->state]); | ||
240 | |||
241 | iface->state = state_idle; | ||
242 | iface->result = -EIO; | ||
243 | iface->needs_reset = 1; | ||
261 | } | 244 | } |
262 | #endif /* POLLED_MODE */ | ||
263 | 245 | ||
264 | static void scx200_acb_reset(struct scx200_acb_iface *iface) | 246 | static void scx200_acb_reset(struct scx200_acb_iface *iface) |
265 | { | 247 | { |
266 | /* Disable the ACCESS.bus device and Configure the SCL | 248 | /* Disable the ACCESS.bus device and Configure the SCL |
267 | frequency: 16 clock cycles */ | 249 | frequency: 16 clock cycles */ |
268 | outb(0x70, ACBCTL2); | 250 | outb(0x70, ACBCTL2); |
269 | /* Polling mode */ | 251 | /* Polling mode */ |
270 | outb(0, ACBCTL1); | 252 | outb(0, ACBCTL1); |
@@ -283,9 +265,9 @@ static void scx200_acb_reset(struct scx200_acb_iface *iface) | |||
283 | } | 265 | } |
284 | 266 | ||
285 | static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | 267 | static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, |
286 | u16 address, unsigned short flags, | 268 | u16 address, unsigned short flags, |
287 | char rw, u8 command, int size, | 269 | char rw, u8 command, int size, |
288 | union i2c_smbus_data *data) | 270 | union i2c_smbus_data *data) |
289 | { | 271 | { |
290 | struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); | 272 | struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); |
291 | int len; | 273 | int len; |
@@ -295,53 +277,47 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | |||
295 | 277 | ||
296 | switch (size) { | 278 | switch (size) { |
297 | case I2C_SMBUS_QUICK: | 279 | case I2C_SMBUS_QUICK: |
298 | len = 0; | 280 | len = 0; |
299 | buffer = NULL; | 281 | buffer = NULL; |
300 | break; | 282 | break; |
283 | |||
301 | case I2C_SMBUS_BYTE: | 284 | case I2C_SMBUS_BYTE: |
302 | if (rw == I2C_SMBUS_READ) { | 285 | len = 1; |
303 | len = 1; | 286 | buffer = rw ? &data->byte : &command; |
304 | buffer = &data->byte; | 287 | break; |
305 | } else { | 288 | |
306 | len = 1; | ||
307 | buffer = &command; | ||
308 | } | ||
309 | break; | ||
310 | case I2C_SMBUS_BYTE_DATA: | 289 | case I2C_SMBUS_BYTE_DATA: |
311 | len = 1; | 290 | len = 1; |
312 | buffer = &data->byte; | 291 | buffer = &data->byte; |
313 | break; | 292 | break; |
293 | |||
314 | case I2C_SMBUS_WORD_DATA: | 294 | case I2C_SMBUS_WORD_DATA: |
315 | len = 2; | 295 | len = 2; |
316 | cur_word = cpu_to_le16(data->word); | 296 | cur_word = cpu_to_le16(data->word); |
317 | buffer = (u8 *)&cur_word; | 297 | buffer = (u8 *)&cur_word; |
318 | break; | 298 | break; |
299 | |||
319 | case I2C_SMBUS_BLOCK_DATA: | 300 | case I2C_SMBUS_BLOCK_DATA: |
320 | len = data->block[0]; | 301 | len = data->block[0]; |
321 | buffer = &data->block[1]; | 302 | buffer = &data->block[1]; |
322 | break; | 303 | break; |
304 | |||
323 | default: | 305 | default: |
324 | return -EINVAL; | 306 | return -EINVAL; |
325 | } | 307 | } |
326 | 308 | ||
327 | DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", | 309 | dev_dbg(&adapter->dev, |
328 | size, address, command, len, rw == I2C_SMBUS_READ); | 310 | "size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", |
311 | size, address, command, len, rw); | ||
329 | 312 | ||
330 | if (!len && rw == I2C_SMBUS_READ) { | 313 | if (!len && rw == I2C_SMBUS_READ) { |
331 | dev_warn(&adapter->dev, "zero length read\n"); | 314 | dev_dbg(&adapter->dev, "zero length read\n"); |
332 | return -EINVAL; | 315 | return -EINVAL; |
333 | } | 316 | } |
334 | 317 | ||
335 | if (len && !buffer) { | 318 | mutex_lock(&iface->mutex); |
336 | dev_warn(&adapter->dev, "nonzero length but no buffer\n"); | ||
337 | return -EFAULT; | ||
338 | } | ||
339 | |||
340 | down(&iface->sem); | ||
341 | 319 | ||
342 | iface->address_byte = address<<1; | 320 | iface->address_byte = (address << 1) | rw; |
343 | if (rw == I2C_SMBUS_READ) | ||
344 | iface->address_byte |= 1; | ||
345 | iface->command = command; | 321 | iface->command = command; |
346 | iface->ptr = buffer; | 322 | iface->ptr = buffer; |
347 | iface->len = len; | 323 | iface->len = len; |
@@ -355,25 +331,21 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | |||
355 | else | 331 | else |
356 | iface->state = state_address; | 332 | iface->state = state_address; |
357 | 333 | ||
358 | #ifdef POLLED_MODE | ||
359 | while (iface->state != state_idle) | 334 | while (iface->state != state_idle) |
360 | scx200_acb_poll(iface); | 335 | scx200_acb_poll(iface); |
361 | #else /* POLLED_MODE */ | ||
362 | #error Interrupt driven mode not implemented | ||
363 | #endif /* POLLED_MODE */ | ||
364 | 336 | ||
365 | if (iface->needs_reset) | 337 | if (iface->needs_reset) |
366 | scx200_acb_reset(iface); | 338 | scx200_acb_reset(iface); |
367 | 339 | ||
368 | rc = iface->result; | 340 | rc = iface->result; |
369 | 341 | ||
370 | up(&iface->sem); | 342 | mutex_unlock(&iface->mutex); |
371 | 343 | ||
372 | if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) | 344 | if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) |
373 | data->word = le16_to_cpu(cur_word); | 345 | data->word = le16_to_cpu(cur_word); |
374 | 346 | ||
375 | #ifdef DEBUG | 347 | #ifdef DEBUG |
376 | DBG(": transfer done, result: %d", rc); | 348 | dev_dbg(&adapter->dev, "transfer done, result: %d", rc); |
377 | if (buffer) { | 349 | if (buffer) { |
378 | int i; | 350 | int i; |
379 | printk(" data:"); | 351 | printk(" data:"); |
@@ -400,17 +372,18 @@ static struct i2c_algorithm scx200_acb_algorithm = { | |||
400 | }; | 372 | }; |
401 | 373 | ||
402 | static struct scx200_acb_iface *scx200_acb_list; | 374 | static struct scx200_acb_iface *scx200_acb_list; |
375 | static DECLARE_MUTEX(scx200_acb_list_mutex); | ||
403 | 376 | ||
404 | static int scx200_acb_probe(struct scx200_acb_iface *iface) | 377 | static int scx200_acb_probe(struct scx200_acb_iface *iface) |
405 | { | 378 | { |
406 | u8 val; | 379 | u8 val; |
407 | 380 | ||
408 | /* Disable the ACCESS.bus device and Configure the SCL | 381 | /* Disable the ACCESS.bus device and Configure the SCL |
409 | frequency: 16 clock cycles */ | 382 | frequency: 16 clock cycles */ |
410 | outb(0x70, ACBCTL2); | 383 | outb(0x70, ACBCTL2); |
411 | 384 | ||
412 | if (inb(ACBCTL2) != 0x70) { | 385 | if (inb(ACBCTL2) != 0x70) { |
413 | DBG("ACBCTL2 readback failed\n"); | 386 | pr_debug(NAME ": ACBCTL2 readback failed\n"); |
414 | return -ENXIO; | 387 | return -ENXIO; |
415 | } | 388 | } |
416 | 389 | ||
@@ -418,7 +391,8 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
418 | 391 | ||
419 | val = inb(ACBCTL1); | 392 | val = inb(ACBCTL1); |
420 | if (val) { | 393 | if (val) { |
421 | DBG("disabled, but ACBCTL1=0x%02x\n", val); | 394 | pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n", |
395 | val); | ||
422 | return -ENXIO; | 396 | return -ENXIO; |
423 | } | 397 | } |
424 | 398 | ||
@@ -428,18 +402,19 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
428 | 402 | ||
429 | val = inb(ACBCTL1); | 403 | val = inb(ACBCTL1); |
430 | if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { | 404 | if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { |
431 | DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val); | 405 | pr_debug(NAME ": enabled, but NMINTE won't be set, " |
406 | "ACBCTL1=0x%02x\n", val); | ||
432 | return -ENXIO; | 407 | return -ENXIO; |
433 | } | 408 | } |
434 | 409 | ||
435 | return 0; | 410 | return 0; |
436 | } | 411 | } |
437 | 412 | ||
438 | static int __init scx200_acb_create(int base, int index) | 413 | static int __init scx200_acb_create(const char *text, int base, int index) |
439 | { | 414 | { |
440 | struct scx200_acb_iface *iface; | 415 | struct scx200_acb_iface *iface; |
441 | struct i2c_adapter *adapter; | 416 | struct i2c_adapter *adapter; |
442 | int rc = 0; | 417 | int rc; |
443 | char description[64]; | 418 | char description[64]; |
444 | 419 | ||
445 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); | 420 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); |
@@ -451,50 +426,51 @@ static int __init scx200_acb_create(int base, int index) | |||
451 | 426 | ||
452 | adapter = &iface->adapter; | 427 | adapter = &iface->adapter; |
453 | i2c_set_adapdata(adapter, iface); | 428 | i2c_set_adapdata(adapter, iface); |
454 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); | 429 | snprintf(adapter->name, I2C_NAME_SIZE, "%s ACB%d", text, index); |
455 | adapter->owner = THIS_MODULE; | 430 | adapter->owner = THIS_MODULE; |
456 | adapter->id = I2C_HW_SMBUS_SCX200; | 431 | adapter->id = I2C_HW_SMBUS_SCX200; |
457 | adapter->algo = &scx200_acb_algorithm; | 432 | adapter->algo = &scx200_acb_algorithm; |
458 | adapter->class = I2C_CLASS_HWMON; | 433 | adapter->class = I2C_CLASS_HWMON; |
459 | 434 | ||
460 | init_MUTEX(&iface->sem); | 435 | mutex_init(&iface->mutex); |
436 | |||
437 | snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", | ||
438 | text, adapter->name); | ||
461 | 439 | ||
462 | snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name); | ||
463 | if (request_region(base, 8, description) == 0) { | 440 | if (request_region(base, 8, description) == 0) { |
464 | dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n", | 441 | printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", |
465 | base, base + 8-1); | 442 | base, base + 8-1); |
466 | rc = -EBUSY; | 443 | rc = -EBUSY; |
467 | goto errout; | 444 | goto errout_free; |
468 | } | 445 | } |
469 | iface->base = base; | 446 | iface->base = base; |
470 | 447 | ||
471 | rc = scx200_acb_probe(iface); | 448 | rc = scx200_acb_probe(iface); |
472 | if (rc) { | 449 | if (rc) { |
473 | dev_warn(&adapter->dev, "probe failed\n"); | 450 | printk(KERN_WARNING NAME ": probe failed\n"); |
474 | goto errout; | 451 | goto errout_release; |
475 | } | 452 | } |
476 | 453 | ||
477 | scx200_acb_reset(iface); | 454 | scx200_acb_reset(iface); |
478 | 455 | ||
479 | if (i2c_add_adapter(adapter) < 0) { | 456 | if (i2c_add_adapter(adapter) < 0) { |
480 | dev_err(&adapter->dev, "failed to register\n"); | 457 | printk(KERN_ERR NAME ": failed to register\n"); |
481 | rc = -ENODEV; | 458 | rc = -ENODEV; |
482 | goto errout; | 459 | goto errout_release; |
483 | } | 460 | } |
484 | 461 | ||
485 | lock_kernel(); | 462 | down(&scx200_acb_list_mutex); |
486 | iface->next = scx200_acb_list; | 463 | iface->next = scx200_acb_list; |
487 | scx200_acb_list = iface; | 464 | scx200_acb_list = iface; |
488 | unlock_kernel(); | 465 | up(&scx200_acb_list_mutex); |
489 | 466 | ||
490 | return 0; | 467 | return 0; |
491 | 468 | ||
469 | errout_release: | ||
470 | release_region(iface->base, 8); | ||
471 | errout_free: | ||
472 | kfree(iface); | ||
492 | errout: | 473 | errout: |
493 | if (iface) { | ||
494 | if (iface->base) | ||
495 | release_region(iface->base, 8); | ||
496 | kfree(iface); | ||
497 | } | ||
498 | return rc; | 474 | return rc; |
499 | } | 475 | } |
500 | 476 | ||
@@ -504,50 +480,69 @@ static struct pci_device_id scx200[] = { | |||
504 | { }, | 480 | { }, |
505 | }; | 481 | }; |
506 | 482 | ||
483 | static struct pci_device_id divil_pci[] = { | ||
484 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, | ||
485 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, | ||
486 | { } /* NULL entry */ | ||
487 | }; | ||
488 | |||
489 | #define MSR_LBAR_SMB 0x5140000B | ||
490 | |||
491 | static int scx200_add_cs553x(void) | ||
492 | { | ||
493 | u32 low, hi; | ||
494 | u32 smb_base; | ||
495 | |||
496 | /* Grab & reserve the SMB I/O range */ | ||
497 | rdmsr(MSR_LBAR_SMB, low, hi); | ||
498 | |||
499 | /* Check the IO mask and whether SMB is enabled */ | ||
500 | if (hi != 0x0000F001) { | ||
501 | printk(KERN_WARNING NAME ": SMBus not enabled\n"); | ||
502 | return -ENODEV; | ||
503 | } | ||
504 | |||
505 | /* SMBus IO size is 8 bytes */ | ||
506 | smb_base = low & 0x0000FFF8; | ||
507 | |||
508 | return scx200_acb_create("CS5535", smb_base, 0); | ||
509 | } | ||
510 | |||
507 | static int __init scx200_acb_init(void) | 511 | static int __init scx200_acb_init(void) |
508 | { | 512 | { |
509 | int i; | 513 | int i; |
510 | int rc; | 514 | int rc = -ENODEV; |
511 | 515 | ||
512 | pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); | 516 | pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); |
513 | 517 | ||
514 | /* Verify that this really is a SCx200 processor */ | 518 | /* Verify that this really is a SCx200 processor */ |
515 | if (pci_dev_present(scx200) == 0) | 519 | if (pci_dev_present(scx200)) { |
516 | return -ENODEV; | 520 | for (i = 0; i < MAX_DEVICES; ++i) { |
521 | if (base[i] > 0) | ||
522 | rc = scx200_acb_create("SCx200", base[i], i); | ||
523 | } | ||
524 | } else if (pci_dev_present(divil_pci)) | ||
525 | rc = scx200_add_cs553x(); | ||
517 | 526 | ||
518 | rc = -ENXIO; | ||
519 | for (i = 0; i < MAX_DEVICES; ++i) { | ||
520 | if (base[i] > 0) | ||
521 | rc = scx200_acb_create(base[i], i); | ||
522 | } | ||
523 | if (scx200_acb_list) | ||
524 | return 0; | ||
525 | return rc; | 527 | return rc; |
526 | } | 528 | } |
527 | 529 | ||
528 | static void __exit scx200_acb_cleanup(void) | 530 | static void __exit scx200_acb_cleanup(void) |
529 | { | 531 | { |
530 | struct scx200_acb_iface *iface; | 532 | struct scx200_acb_iface *iface; |
531 | lock_kernel(); | 533 | |
534 | down(&scx200_acb_list_mutex); | ||
532 | while ((iface = scx200_acb_list) != NULL) { | 535 | while ((iface = scx200_acb_list) != NULL) { |
533 | scx200_acb_list = iface->next; | 536 | scx200_acb_list = iface->next; |
534 | unlock_kernel(); | 537 | up(&scx200_acb_list_mutex); |
535 | 538 | ||
536 | i2c_del_adapter(&iface->adapter); | 539 | i2c_del_adapter(&iface->adapter); |
537 | release_region(iface->base, 8); | 540 | release_region(iface->base, 8); |
538 | kfree(iface); | 541 | kfree(iface); |
539 | lock_kernel(); | 542 | down(&scx200_acb_list_mutex); |
540 | } | 543 | } |
541 | unlock_kernel(); | 544 | up(&scx200_acb_list_mutex); |
542 | } | 545 | } |
543 | 546 | ||
544 | module_init(scx200_acb_init); | 547 | module_init(scx200_acb_init); |
545 | module_exit(scx200_acb_cleanup); | 548 | module_exit(scx200_acb_cleanup); |
546 | |||
547 | /* | ||
548 | Local variables: | ||
549 | compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules" | ||
550 | c-basic-offset: 8 | ||
551 | End: | ||
552 | */ | ||
553 | |||
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0710b9da9d54..03d09ed5ec2c 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
28 | #include <linux/bcd.h> | 28 | #include <linux/bcd.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #define DS1374_REG_TOD0 0x00 | 31 | #define DS1374_REG_TOD0 0x00 |
31 | #define DS1374_REG_TOD1 0x01 | 32 | #define DS1374_REG_TOD1 0x01 |
@@ -41,7 +42,7 @@ | |||
41 | 42 | ||
42 | #define DS1374_DRV_NAME "ds1374" | 43 | #define DS1374_DRV_NAME "ds1374" |
43 | 44 | ||
44 | static DECLARE_MUTEX(ds1374_mutex); | 45 | static DEFINE_MUTEX(ds1374_mutex); |
45 | 46 | ||
46 | static struct i2c_driver ds1374_driver; | 47 | static struct i2c_driver ds1374_driver; |
47 | static struct i2c_client *save_client; | 48 | static struct i2c_client *save_client; |
@@ -114,7 +115,7 @@ ulong ds1374_get_rtc_time(void) | |||
114 | ulong t1, t2; | 115 | ulong t1, t2; |
115 | int limit = 10; /* arbitrary retry limit */ | 116 | int limit = 10; /* arbitrary retry limit */ |
116 | 117 | ||
117 | down(&ds1374_mutex); | 118 | mutex_lock(&ds1374_mutex); |
118 | 119 | ||
119 | /* | 120 | /* |
120 | * Since the reads are being performed one byte at a time using | 121 | * Since the reads are being performed one byte at a time using |
@@ -127,7 +128,7 @@ ulong ds1374_get_rtc_time(void) | |||
127 | t2 = ds1374_read_rtc(); | 128 | t2 = ds1374_read_rtc(); |
128 | } while (t1 != t2 && limit--); | 129 | } while (t1 != t2 && limit--); |
129 | 130 | ||
130 | up(&ds1374_mutex); | 131 | mutex_unlock(&ds1374_mutex); |
131 | 132 | ||
132 | if (t1 != t2) { | 133 | if (t1 != t2) { |
133 | dev_warn(&save_client->dev, | 134 | dev_warn(&save_client->dev, |
@@ -145,7 +146,7 @@ static void ds1374_set_tlet(ulong arg) | |||
145 | 146 | ||
146 | t1 = *(ulong *) arg; | 147 | t1 = *(ulong *) arg; |
147 | 148 | ||
148 | down(&ds1374_mutex); | 149 | mutex_lock(&ds1374_mutex); |
149 | 150 | ||
150 | /* | 151 | /* |
151 | * Since the writes are being performed one byte at a time using | 152 | * Since the writes are being performed one byte at a time using |
@@ -158,7 +159,7 @@ static void ds1374_set_tlet(ulong arg) | |||
158 | t2 = ds1374_read_rtc(); | 159 | t2 = ds1374_read_rtc(); |
159 | } while (t1 != t2 && limit--); | 160 | } while (t1 != t2 && limit--); |
160 | 161 | ||
161 | up(&ds1374_mutex); | 162 | mutex_unlock(&ds1374_mutex); |
162 | 163 | ||
163 | if (t1 != t2) | 164 | if (t1 != t2) |
164 | dev_warn(&save_client->dev, | 165 | dev_warn(&save_client->dev, |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 41116b7947f6..13c108269a6d 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/jiffies.h> | 34 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | /* Addresses to scan */ | 38 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, | 39 | static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, |
@@ -54,7 +55,7 @@ enum eeprom_nature { | |||
54 | /* Each client has this additional data */ | 55 | /* Each client has this additional data */ |
55 | struct eeprom_data { | 56 | struct eeprom_data { |
56 | struct i2c_client client; | 57 | struct i2c_client client; |
57 | struct semaphore update_lock; | 58 | struct mutex update_lock; |
58 | u8 valid; /* bitfield, bit!=0 if slice is valid */ | 59 | u8 valid; /* bitfield, bit!=0 if slice is valid */ |
59 | unsigned long last_updated[8]; /* In jiffies, 8 slices */ | 60 | unsigned long last_updated[8]; /* In jiffies, 8 slices */ |
60 | u8 data[EEPROM_SIZE]; /* Register values */ | 61 | u8 data[EEPROM_SIZE]; /* Register values */ |
@@ -81,7 +82,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
81 | struct eeprom_data *data = i2c_get_clientdata(client); | 82 | struct eeprom_data *data = i2c_get_clientdata(client); |
82 | int i, j; | 83 | int i, j; |
83 | 84 | ||
84 | down(&data->update_lock); | 85 | mutex_lock(&data->update_lock); |
85 | 86 | ||
86 | if (!(data->valid & (1 << slice)) || | 87 | if (!(data->valid & (1 << slice)) || |
87 | time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { | 88 | time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { |
@@ -107,7 +108,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
107 | data->valid |= (1 << slice); | 108 | data->valid |= (1 << slice); |
108 | } | 109 | } |
109 | exit: | 110 | exit: |
110 | up(&data->update_lock); | 111 | mutex_unlock(&data->update_lock); |
111 | } | 112 | } |
112 | 113 | ||
113 | static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | 114 | static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) |
@@ -187,7 +188,7 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
187 | /* Fill in the remaining client fields */ | 188 | /* Fill in the remaining client fields */ |
188 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); | 189 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); |
189 | data->valid = 0; | 190 | data->valid = 0; |
190 | init_MUTEX(&data->update_lock); | 191 | mutex_init(&data->update_lock); |
191 | data->nature = UNKNOWN; | 192 | data->nature = UNKNOWN; |
192 | 193 | ||
193 | /* Tell the I2C layer a new client has arrived */ | 194 | /* Tell the I2C layer a new client has arrived */ |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 1251c7fc18d5..e6f1ab7b913c 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -1635,8 +1635,6 @@ static struct i2c_driver isp1301_driver = { | |||
1635 | .driver = { | 1635 | .driver = { |
1636 | .name = "isp1301_omap", | 1636 | .name = "isp1301_omap", |
1637 | }, | 1637 | }, |
1638 | .id = 1301, /* FIXME "official", i2c-ids.h */ | ||
1639 | .class = I2C_CLASS_HWMON, | ||
1640 | .attach_adapter = isp1301_scan_bus, | 1638 | .attach_adapter = isp1301_scan_bus, |
1641 | .detach_client = isp1301_detach_client, | 1639 | .detach_client = isp1301_detach_client, |
1642 | }; | 1640 | }; |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 2dc3d48375fc..b5aabe7cf792 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -24,13 +24,14 @@ | |||
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/rtc.h> | 25 | #include <linux/rtc.h> |
26 | #include <linux/bcd.h> | 26 | #include <linux/bcd.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | #include <asm/time.h> | 29 | #include <asm/time.h> |
29 | #include <asm/rtc.h> | 30 | #include <asm/rtc.h> |
30 | 31 | ||
31 | #define M41T00_DRV_NAME "m41t00" | 32 | #define M41T00_DRV_NAME "m41t00" |
32 | 33 | ||
33 | static DECLARE_MUTEX(m41t00_mutex); | 34 | static DEFINE_MUTEX(m41t00_mutex); |
34 | 35 | ||
35 | static struct i2c_driver m41t00_driver; | 36 | static struct i2c_driver m41t00_driver; |
36 | static struct i2c_client *save_client; | 37 | static struct i2c_client *save_client; |
@@ -54,7 +55,7 @@ m41t00_get_rtc_time(void) | |||
54 | sec = min = hour = day = mon = year = 0; | 55 | sec = min = hour = day = mon = year = 0; |
55 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; | 56 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; |
56 | 57 | ||
57 | down(&m41t00_mutex); | 58 | mutex_lock(&m41t00_mutex); |
58 | do { | 59 | do { |
59 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) | 60 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) |
60 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) | 61 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) |
@@ -80,7 +81,7 @@ m41t00_get_rtc_time(void) | |||
80 | mon1 = mon; | 81 | mon1 = mon; |
81 | year1 = year; | 82 | year1 = year; |
82 | } while (--limit > 0); | 83 | } while (--limit > 0); |
83 | up(&m41t00_mutex); | 84 | mutex_unlock(&m41t00_mutex); |
84 | 85 | ||
85 | if (limit == 0) { | 86 | if (limit == 0) { |
86 | dev_warn(&save_client->dev, | 87 | dev_warn(&save_client->dev, |
@@ -125,7 +126,7 @@ m41t00_set_tlet(ulong arg) | |||
125 | BIN_TO_BCD(tm.tm_mday); | 126 | BIN_TO_BCD(tm.tm_mday); |
126 | BIN_TO_BCD(tm.tm_year); | 127 | BIN_TO_BCD(tm.tm_year); |
127 | 128 | ||
128 | down(&m41t00_mutex); | 129 | mutex_lock(&m41t00_mutex); |
129 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) | 130 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) |
130 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) | 131 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) |
131 | < 0) | 132 | < 0) |
@@ -140,7 +141,7 @@ m41t00_set_tlet(ulong arg) | |||
140 | 141 | ||
141 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); | 142 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); |
142 | 143 | ||
143 | up(&m41t00_mutex); | 144 | mutex_unlock(&m41t00_mutex); |
144 | return; | 145 | return; |
145 | } | 146 | } |
146 | 147 | ||
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 6d3ff584155e..88d2ddee4490 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <asm/semaphore.h> | 34 | #include <linux/mutex.h> |
35 | 35 | ||
36 | /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ | 36 | /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ |
37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; |
@@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875); | |||
54 | /* Each client has this additional data */ | 54 | /* Each client has this additional data */ |
55 | struct max6875_data { | 55 | struct max6875_data { |
56 | struct i2c_client client; | 56 | struct i2c_client client; |
57 | struct semaphore update_lock; | 57 | struct mutex update_lock; |
58 | 58 | ||
59 | u32 valid; | 59 | u32 valid; |
60 | u8 data[USER_EEPROM_SIZE]; | 60 | u8 data[USER_EEPROM_SIZE]; |
@@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) | |||
83 | if (slice >= USER_EEPROM_SLICES) | 83 | if (slice >= USER_EEPROM_SLICES) |
84 | return; | 84 | return; |
85 | 85 | ||
86 | down(&data->update_lock); | 86 | mutex_lock(&data->update_lock); |
87 | 87 | ||
88 | buf = &data->data[slice << SLICE_BITS]; | 88 | buf = &data->data[slice << SLICE_BITS]; |
89 | 89 | ||
@@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) | |||
122 | data->valid |= (1 << slice); | 122 | data->valid |= (1 << slice); |
123 | } | 123 | } |
124 | exit_up: | 124 | exit_up: |
125 | up(&data->update_lock); | 125 | mutex_unlock(&data->update_lock); |
126 | } | 126 | } |
127 | 127 | ||
128 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, | 128 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, |
@@ -196,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
196 | real_client->driver = &max6875_driver; | 196 | real_client->driver = &max6875_driver; |
197 | real_client->flags = 0; | 197 | real_client->flags = 0; |
198 | strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); | 198 | strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); |
199 | init_MUTEX(&data->update_lock); | 199 | mutex_init(&data->update_lock); |
200 | 200 | ||
201 | /* Init fake client data */ | 201 | /* Init fake client data */ |
202 | /* set the client data to the i2c_client so that it will get freed */ | 202 | /* set the client data to the i2c_client so that it will get freed */ |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 36cff09c678d..925a6b371fd2 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | /* Addresses to scan */ | 29 | /* Addresses to scan */ |
29 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 30 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
@@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode, | |||
74 | 75 | ||
75 | struct pcf8591_data { | 76 | struct pcf8591_data { |
76 | struct i2c_client client; | 77 | struct i2c_client client; |
77 | struct semaphore update_lock; | 78 | struct mutex update_lock; |
78 | 79 | ||
79 | u8 control; | 80 | u8 control; |
80 | u8 aout; | 81 | u8 aout; |
@@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr | |||
144 | struct pcf8591_data *data = i2c_get_clientdata(client); | 145 | struct pcf8591_data *data = i2c_get_clientdata(client); |
145 | unsigned long val = simple_strtoul(buf, NULL, 10); | 146 | unsigned long val = simple_strtoul(buf, NULL, 10); |
146 | 147 | ||
147 | down(&data->update_lock); | 148 | mutex_lock(&data->update_lock); |
148 | if (val) | 149 | if (val) |
149 | data->control |= PCF8591_CONTROL_AOEF; | 150 | data->control |= PCF8591_CONTROL_AOEF; |
150 | else | 151 | else |
151 | data->control &= ~PCF8591_CONTROL_AOEF; | 152 | data->control &= ~PCF8591_CONTROL_AOEF; |
152 | i2c_smbus_write_byte(client, data->control); | 153 | i2c_smbus_write_byte(client, data->control); |
153 | up(&data->update_lock); | 154 | mutex_unlock(&data->update_lock); |
154 | return count; | 155 | return count; |
155 | } | 156 | } |
156 | 157 | ||
@@ -200,7 +201,7 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
200 | /* Fill in the remaining client fields and put it into the global | 201 | /* Fill in the remaining client fields and put it into the global |
201 | list */ | 202 | list */ |
202 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); | 203 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); |
203 | init_MUTEX(&data->update_lock); | 204 | mutex_init(&data->update_lock); |
204 | 205 | ||
205 | /* Tell the I2C layer a new client has arrived */ | 206 | /* Tell the I2C layer a new client has arrived */ |
206 | if ((err = i2c_attach_client(new_client))) | 207 | if ((err = i2c_attach_client(new_client))) |
@@ -265,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel) | |||
265 | struct i2c_client *client = to_i2c_client(dev); | 266 | struct i2c_client *client = to_i2c_client(dev); |
266 | struct pcf8591_data *data = i2c_get_clientdata(client); | 267 | struct pcf8591_data *data = i2c_get_clientdata(client); |
267 | 268 | ||
268 | down(&data->update_lock); | 269 | mutex_lock(&data->update_lock); |
269 | 270 | ||
270 | if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { | 271 | if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { |
271 | data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) | 272 | data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) |
@@ -278,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel) | |||
278 | } | 279 | } |
279 | value = i2c_smbus_read_byte(client); | 280 | value = i2c_smbus_read_byte(client); |
280 | 281 | ||
281 | up(&data->update_lock); | 282 | mutex_unlock(&data->update_lock); |
282 | 283 | ||
283 | if ((channel == 2 && input_mode == 2) || | 284 | if ((channel == 2 && input_mode == 2) || |
284 | (channel != 3 && (input_mode == 1 || input_mode == 3))) | 285 | (channel != 3 && (input_mode == 1 || input_mode == 3))) |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 1af3dfbb8086..179b1e022d80 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/suspend.h> | 32 | #include <linux/suspend.h> |
33 | #include <linux/debugfs.h> | 33 | #include <linux/debugfs.h> |
34 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | #include <asm/irq.h> | 37 | #include <asm/irq.h> |
37 | #include <asm/mach-types.h> | 38 | #include <asm/mach-types.h> |
@@ -81,7 +82,7 @@ enum tps_model { | |||
81 | 82 | ||
82 | struct tps65010 { | 83 | struct tps65010 { |
83 | struct i2c_client client; | 84 | struct i2c_client client; |
84 | struct semaphore lock; | 85 | struct mutex lock; |
85 | int irq; | 86 | int irq; |
86 | struct work_struct work; | 87 | struct work_struct work; |
87 | struct dentry *file; | 88 | struct dentry *file; |
@@ -218,7 +219,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
218 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", | 219 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", |
219 | DRIVER_NAME, DRIVER_VERSION, chip); | 220 | DRIVER_NAME, DRIVER_VERSION, chip); |
220 | 221 | ||
221 | down(&tps->lock); | 222 | mutex_lock(&tps->lock); |
222 | 223 | ||
223 | /* FIXME how can we tell whether a battery is present? | 224 | /* FIXME how can we tell whether a battery is present? |
224 | * likely involves a charge gauging chip (like BQ26501). | 225 | * likely involves a charge gauging chip (like BQ26501). |
@@ -300,7 +301,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
300 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); | 301 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); |
301 | } | 302 | } |
302 | 303 | ||
303 | up(&tps->lock); | 304 | mutex_unlock(&tps->lock); |
304 | return 0; | 305 | return 0; |
305 | } | 306 | } |
306 | 307 | ||
@@ -416,7 +417,7 @@ static void tps65010_work(void *_tps) | |||
416 | { | 417 | { |
417 | struct tps65010 *tps = _tps; | 418 | struct tps65010 *tps = _tps; |
418 | 419 | ||
419 | down(&tps->lock); | 420 | mutex_lock(&tps->lock); |
420 | 421 | ||
421 | tps65010_interrupt(tps); | 422 | tps65010_interrupt(tps); |
422 | 423 | ||
@@ -444,7 +445,7 @@ static void tps65010_work(void *_tps) | |||
444 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) | 445 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) |
445 | enable_irq(tps->irq); | 446 | enable_irq(tps->irq); |
446 | 447 | ||
447 | up(&tps->lock); | 448 | mutex_unlock(&tps->lock); |
448 | } | 449 | } |
449 | 450 | ||
450 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) | 451 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) |
@@ -505,7 +506,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
505 | if (!tps) | 506 | if (!tps) |
506 | return 0; | 507 | return 0; |
507 | 508 | ||
508 | init_MUTEX(&tps->lock); | 509 | mutex_init(&tps->lock); |
509 | INIT_WORK(&tps->work, tps65010_work, tps); | 510 | INIT_WORK(&tps->work, tps65010_work, tps); |
510 | tps->irq = -1; | 511 | tps->irq = -1; |
511 | tps->client.addr = address; | 512 | tps->client.addr = address; |
@@ -695,7 +696,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | |||
695 | if ((gpio < GPIO1) || (gpio > GPIO4)) | 696 | if ((gpio < GPIO1) || (gpio > GPIO4)) |
696 | return -EINVAL; | 697 | return -EINVAL; |
697 | 698 | ||
698 | down(&the_tps->lock); | 699 | mutex_lock(&the_tps->lock); |
699 | 700 | ||
700 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); | 701 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); |
701 | 702 | ||
@@ -720,7 +721,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | |||
720 | gpio, value ? "high" : "low", | 721 | gpio, value ? "high" : "low", |
721 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); | 722 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); |
722 | 723 | ||
723 | up(&the_tps->lock); | 724 | mutex_unlock(&the_tps->lock); |
724 | return status; | 725 | return status; |
725 | } | 726 | } |
726 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); | 727 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); |
@@ -745,7 +746,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
745 | led = LED2; | 746 | led = LED2; |
746 | } | 747 | } |
747 | 748 | ||
748 | down(&the_tps->lock); | 749 | mutex_lock(&the_tps->lock); |
749 | 750 | ||
750 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, | 751 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, |
751 | i2c_smbus_read_byte_data(&the_tps->client, | 752 | i2c_smbus_read_byte_data(&the_tps->client, |
@@ -771,7 +772,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
771 | default: | 772 | default: |
772 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", | 773 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", |
773 | DRIVER_NAME); | 774 | DRIVER_NAME); |
774 | up(&the_tps->lock); | 775 | mutex_unlock(&the_tps->lock); |
775 | return -EINVAL; | 776 | return -EINVAL; |
776 | } | 777 | } |
777 | 778 | ||
@@ -781,7 +782,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
781 | if (status != 0) { | 782 | if (status != 0) { |
782 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", | 783 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", |
783 | DRIVER_NAME, led); | 784 | DRIVER_NAME, led); |
784 | up(&the_tps->lock); | 785 | mutex_unlock(&the_tps->lock); |
785 | return status; | 786 | return status; |
786 | } | 787 | } |
787 | 788 | ||
@@ -794,7 +795,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
794 | if (status != 0) { | 795 | if (status != 0) { |
795 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", | 796 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", |
796 | DRIVER_NAME, led); | 797 | DRIVER_NAME, led); |
797 | up(&the_tps->lock); | 798 | mutex_unlock(&the_tps->lock); |
798 | return status; | 799 | return status; |
799 | } | 800 | } |
800 | 801 | ||
@@ -802,7 +803,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
802 | i2c_smbus_read_byte_data(&the_tps->client, | 803 | i2c_smbus_read_byte_data(&the_tps->client, |
803 | TPS_LED1_PER + offs)); | 804 | TPS_LED1_PER + offs)); |
804 | 805 | ||
805 | up(&the_tps->lock); | 806 | mutex_unlock(&the_tps->lock); |
806 | 807 | ||
807 | return status; | 808 | return status; |
808 | } | 809 | } |
@@ -820,7 +821,7 @@ int tps65010_set_vib(unsigned value) | |||
820 | if (!the_tps) | 821 | if (!the_tps) |
821 | return -ENODEV; | 822 | return -ENODEV; |
822 | 823 | ||
823 | down(&the_tps->lock); | 824 | mutex_lock(&the_tps->lock); |
824 | 825 | ||
825 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); | 826 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); |
826 | vdcdc2 &= ~(1 << 1); | 827 | vdcdc2 &= ~(1 << 1); |
@@ -831,7 +832,7 @@ int tps65010_set_vib(unsigned value) | |||
831 | 832 | ||
832 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); | 833 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); |
833 | 834 | ||
834 | up(&the_tps->lock); | 835 | mutex_unlock(&the_tps->lock); |
835 | return status; | 836 | return status; |
836 | } | 837 | } |
837 | EXPORT_SYMBOL(tps65010_set_vib); | 838 | EXPORT_SYMBOL(tps65010_set_vib); |
@@ -848,7 +849,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
848 | if (!the_tps) | 849 | if (!the_tps) |
849 | return -ENODEV; | 850 | return -ENODEV; |
850 | 851 | ||
851 | down(&the_tps->lock); | 852 | mutex_lock(&the_tps->lock); |
852 | 853 | ||
853 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, | 854 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, |
854 | mode ? "enable" : "disable", | 855 | mode ? "enable" : "disable", |
@@ -876,7 +877,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
876 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 877 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
877 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 878 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
878 | 879 | ||
879 | up(&the_tps->lock); | 880 | mutex_unlock(&the_tps->lock); |
880 | 881 | ||
881 | return status; | 882 | return status; |
882 | } | 883 | } |
@@ -894,7 +895,7 @@ int tps65010_config_vregs1(unsigned value) | |||
894 | if (!the_tps) | 895 | if (!the_tps) |
895 | return -ENODEV; | 896 | return -ENODEV; |
896 | 897 | ||
897 | down(&the_tps->lock); | 898 | mutex_lock(&the_tps->lock); |
898 | 899 | ||
899 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 900 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
900 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 901 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
@@ -909,7 +910,7 @@ int tps65010_config_vregs1(unsigned value) | |||
909 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 910 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
910 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 911 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
911 | 912 | ||
912 | up(&the_tps->lock); | 913 | mutex_unlock(&the_tps->lock); |
913 | 914 | ||
914 | return status; | 915 | return status; |
915 | } | 916 | } |
@@ -931,7 +932,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
931 | if (!the_tps || the_tps->por) | 932 | if (!the_tps || the_tps->por) |
932 | return -ENODEV; | 933 | return -ENODEV; |
933 | 934 | ||
934 | down(&the_tps->lock); | 935 | mutex_lock(&the_tps->lock); |
935 | 936 | ||
936 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", | 937 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", |
937 | DRIVER_NAME, | 938 | DRIVER_NAME, |
@@ -959,7 +960,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
959 | if (status != 0) { | 960 | if (status != 0) { |
960 | printk(KERN_ERR "%s: Failed to write chconfig register\n", | 961 | printk(KERN_ERR "%s: Failed to write chconfig register\n", |
961 | DRIVER_NAME); | 962 | DRIVER_NAME); |
962 | up(&the_tps->lock); | 963 | mutex_unlock(&the_tps->lock); |
963 | return status; | 964 | return status; |
964 | } | 965 | } |
965 | 966 | ||
@@ -977,7 +978,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
977 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 978 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
978 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 979 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
979 | 980 | ||
980 | up(&the_tps->lock); | 981 | mutex_unlock(&the_tps->lock); |
981 | 982 | ||
982 | return status; | 983 | return status; |
983 | } | 984 | } |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 1a2c9ab5d9e3..45e2cdf54736 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -31,12 +31,13 @@ | |||
31 | #include <linux/idr.h> | 31 | #include <linux/idr.h> |
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/mutex.h> | ||
34 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
35 | 36 | ||
36 | 37 | ||
37 | static LIST_HEAD(adapters); | 38 | static LIST_HEAD(adapters); |
38 | static LIST_HEAD(drivers); | 39 | static LIST_HEAD(drivers); |
39 | static DECLARE_MUTEX(core_lists); | 40 | static DEFINE_MUTEX(core_lists); |
40 | static DEFINE_IDR(i2c_adapter_idr); | 41 | static DEFINE_IDR(i2c_adapter_idr); |
41 | 42 | ||
42 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ | 43 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ |
@@ -153,7 +154,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
153 | struct list_head *item; | 154 | struct list_head *item; |
154 | struct i2c_driver *driver; | 155 | struct i2c_driver *driver; |
155 | 156 | ||
156 | down(&core_lists); | 157 | mutex_lock(&core_lists); |
157 | 158 | ||
158 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { | 159 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { |
159 | res = -ENOMEM; | 160 | res = -ENOMEM; |
@@ -168,8 +169,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
168 | } | 169 | } |
169 | 170 | ||
170 | adap->nr = id & MAX_ID_MASK; | 171 | adap->nr = id & MAX_ID_MASK; |
171 | init_MUTEX(&adap->bus_lock); | 172 | mutex_init(&adap->bus_lock); |
172 | init_MUTEX(&adap->clist_lock); | 173 | mutex_init(&adap->clist_lock); |
173 | list_add_tail(&adap->list,&adapters); | 174 | list_add_tail(&adap->list,&adapters); |
174 | INIT_LIST_HEAD(&adap->clients); | 175 | INIT_LIST_HEAD(&adap->clients); |
175 | 176 | ||
@@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
203 | } | 204 | } |
204 | 205 | ||
205 | out_unlock: | 206 | out_unlock: |
206 | up(&core_lists); | 207 | mutex_unlock(&core_lists); |
207 | return res; | 208 | return res; |
208 | } | 209 | } |
209 | 210 | ||
@@ -216,7 +217,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
216 | struct i2c_client *client; | 217 | struct i2c_client *client; |
217 | int res = 0; | 218 | int res = 0; |
218 | 219 | ||
219 | down(&core_lists); | 220 | mutex_lock(&core_lists); |
220 | 221 | ||
221 | /* First make sure that this adapter was ever added */ | 222 | /* First make sure that this adapter was ever added */ |
222 | list_for_each_entry(adap_from_list, &adapters, list) { | 223 | list_for_each_entry(adap_from_list, &adapters, list) { |
@@ -272,7 +273,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
272 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); | 273 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); |
273 | 274 | ||
274 | out_unlock: | 275 | out_unlock: |
275 | up(&core_lists); | 276 | mutex_unlock(&core_lists); |
276 | return res; | 277 | return res; |
277 | } | 278 | } |
278 | 279 | ||
@@ -287,9 +288,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
287 | { | 288 | { |
288 | struct list_head *item; | 289 | struct list_head *item; |
289 | struct i2c_adapter *adapter; | 290 | struct i2c_adapter *adapter; |
290 | int res = 0; | 291 | int res; |
291 | |||
292 | down(&core_lists); | ||
293 | 292 | ||
294 | /* add the driver to the list of i2c drivers in the driver core */ | 293 | /* add the driver to the list of i2c drivers in the driver core */ |
295 | driver->driver.owner = owner; | 294 | driver->driver.owner = owner; |
@@ -297,8 +296,10 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
297 | 296 | ||
298 | res = driver_register(&driver->driver); | 297 | res = driver_register(&driver->driver); |
299 | if (res) | 298 | if (res) |
300 | goto out_unlock; | 299 | return res; |
301 | 300 | ||
301 | mutex_lock(&core_lists); | ||
302 | |||
302 | list_add_tail(&driver->list,&drivers); | 303 | list_add_tail(&driver->list,&drivers); |
303 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); | 304 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); |
304 | 305 | ||
@@ -310,9 +311,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 | ||
313 | out_unlock: | 314 | mutex_unlock(&core_lists); |
314 | up(&core_lists); | 315 | return 0; |
315 | return res; | ||
316 | } | 316 | } |
317 | EXPORT_SYMBOL(i2c_register_driver); | 317 | EXPORT_SYMBOL(i2c_register_driver); |
318 | 318 | ||
@@ -324,7 +324,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
324 | 324 | ||
325 | int res = 0; | 325 | int res = 0; |
326 | 326 | ||
327 | down(&core_lists); | 327 | mutex_lock(&core_lists); |
328 | 328 | ||
329 | /* Have a look at each adapter, if clients of this driver are still | 329 | /* Have a look at each adapter, if clients of this driver are still |
330 | * attached. If so, detach them to be able to kill the driver | 330 | * attached. If so, detach them to be able to kill the driver |
@@ -363,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
363 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); | 363 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); |
364 | 364 | ||
365 | out_unlock: | 365 | out_unlock: |
366 | up(&core_lists); | 366 | mutex_unlock(&core_lists); |
367 | return 0; | 367 | return 0; |
368 | } | 368 | } |
369 | 369 | ||
@@ -384,9 +384,9 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr) | |||
384 | { | 384 | { |
385 | int rval; | 385 | int rval; |
386 | 386 | ||
387 | down(&adapter->clist_lock); | 387 | mutex_lock(&adapter->clist_lock); |
388 | rval = __i2c_check_addr(adapter, addr); | 388 | rval = __i2c_check_addr(adapter, addr); |
389 | up(&adapter->clist_lock); | 389 | mutex_unlock(&adapter->clist_lock); |
390 | 390 | ||
391 | return rval; | 391 | return rval; |
392 | } | 392 | } |
@@ -395,13 +395,13 @@ int i2c_attach_client(struct i2c_client *client) | |||
395 | { | 395 | { |
396 | struct i2c_adapter *adapter = client->adapter; | 396 | struct i2c_adapter *adapter = client->adapter; |
397 | 397 | ||
398 | down(&adapter->clist_lock); | 398 | mutex_lock(&adapter->clist_lock); |
399 | if (__i2c_check_addr(client->adapter, client->addr)) { | 399 | if (__i2c_check_addr(client->adapter, client->addr)) { |
400 | up(&adapter->clist_lock); | 400 | mutex_unlock(&adapter->clist_lock); |
401 | return -EBUSY; | 401 | return -EBUSY; |
402 | } | 402 | } |
403 | list_add_tail(&client->list,&adapter->clients); | 403 | list_add_tail(&client->list,&adapter->clients); |
404 | up(&adapter->clist_lock); | 404 | mutex_unlock(&adapter->clist_lock); |
405 | 405 | ||
406 | if (adapter->client_register) { | 406 | if (adapter->client_register) { |
407 | if (adapter->client_register(client)) { | 407 | if (adapter->client_register(client)) { |
@@ -450,12 +450,12 @@ int i2c_detach_client(struct i2c_client *client) | |||
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | down(&adapter->clist_lock); | 453 | mutex_lock(&adapter->clist_lock); |
454 | list_del(&client->list); | 454 | list_del(&client->list); |
455 | init_completion(&client->released); | 455 | init_completion(&client->released); |
456 | device_remove_file(&client->dev, &dev_attr_client_name); | 456 | device_remove_file(&client->dev, &dev_attr_client_name); |
457 | device_unregister(&client->dev); | 457 | device_unregister(&client->dev); |
458 | up(&adapter->clist_lock); | 458 | mutex_unlock(&adapter->clist_lock); |
459 | wait_for_completion(&client->released); | 459 | wait_for_completion(&client->released); |
460 | 460 | ||
461 | out: | 461 | out: |
@@ -513,19 +513,19 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) | |||
513 | struct list_head *item; | 513 | struct list_head *item; |
514 | struct i2c_client *client; | 514 | struct i2c_client *client; |
515 | 515 | ||
516 | down(&adap->clist_lock); | 516 | mutex_lock(&adap->clist_lock); |
517 | list_for_each(item,&adap->clients) { | 517 | list_for_each(item,&adap->clients) { |
518 | client = list_entry(item, struct i2c_client, list); | 518 | client = list_entry(item, struct i2c_client, list); |
519 | if (!try_module_get(client->driver->driver.owner)) | 519 | if (!try_module_get(client->driver->driver.owner)) |
520 | continue; | 520 | continue; |
521 | if (NULL != client->driver->command) { | 521 | if (NULL != client->driver->command) { |
522 | up(&adap->clist_lock); | 522 | mutex_unlock(&adap->clist_lock); |
523 | client->driver->command(client,cmd,arg); | 523 | client->driver->command(client,cmd,arg); |
524 | down(&adap->clist_lock); | 524 | mutex_lock(&adap->clist_lock); |
525 | } | 525 | } |
526 | module_put(client->driver->driver.owner); | 526 | module_put(client->driver->driver.owner); |
527 | } | 527 | } |
528 | up(&adap->clist_lock); | 528 | mutex_unlock(&adap->clist_lock); |
529 | } | 529 | } |
530 | 530 | ||
531 | static int __init i2c_init(void) | 531 | static int __init i2c_init(void) |
@@ -569,9 +569,9 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) | |||
569 | } | 569 | } |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | down(&adap->bus_lock); | 572 | mutex_lock(&adap->bus_lock); |
573 | ret = adap->algo->master_xfer(adap,msgs,num); | 573 | ret = adap->algo->master_xfer(adap,msgs,num); |
574 | up(&adap->bus_lock); | 574 | mutex_unlock(&adap->bus_lock); |
575 | 575 | ||
576 | return ret; | 576 | return ret; |
577 | } else { | 577 | } else { |
@@ -779,12 +779,12 @@ struct i2c_adapter* i2c_get_adapter(int id) | |||
779 | { | 779 | { |
780 | struct i2c_adapter *adapter; | 780 | struct i2c_adapter *adapter; |
781 | 781 | ||
782 | down(&core_lists); | 782 | mutex_lock(&core_lists); |
783 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); | 783 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); |
784 | if (adapter && !try_module_get(adapter->owner)) | 784 | if (adapter && !try_module_get(adapter->owner)) |
785 | adapter = NULL; | 785 | adapter = NULL; |
786 | 786 | ||
787 | up(&core_lists); | 787 | mutex_unlock(&core_lists); |
788 | return adapter; | 788 | return adapter; |
789 | } | 789 | } |
790 | 790 | ||
@@ -919,12 +919,11 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
919 | u8 length, u8 *values) | 919 | u8 length, u8 *values) |
920 | { | 920 | { |
921 | union i2c_smbus_data data; | 921 | union i2c_smbus_data data; |
922 | int i; | 922 | |
923 | if (length > I2C_SMBUS_BLOCK_MAX) | 923 | if (length > I2C_SMBUS_BLOCK_MAX) |
924 | length = I2C_SMBUS_BLOCK_MAX; | 924 | length = I2C_SMBUS_BLOCK_MAX; |
925 | for (i = 1; i <= length; i++) | ||
926 | data.block[i] = values[i-1]; | ||
927 | data.block[0] = length; | 925 | data.block[0] = length; |
926 | memcpy(&data.block[1], values, length); | ||
928 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 927 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
929 | I2C_SMBUS_WRITE,command, | 928 | I2C_SMBUS_WRITE,command, |
930 | I2C_SMBUS_BLOCK_DATA,&data); | 929 | I2C_SMBUS_BLOCK_DATA,&data); |
@@ -934,16 +933,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
934 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) | 933 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) |
935 | { | 934 | { |
936 | union i2c_smbus_data data; | 935 | union i2c_smbus_data data; |
937 | int i; | 936 | |
938 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 937 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
939 | I2C_SMBUS_READ,command, | 938 | I2C_SMBUS_READ,command, |
940 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) | 939 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) |
941 | return -1; | 940 | return -1; |
942 | else { | 941 | |
943 | for (i = 1; i <= data.block[0]; i++) | 942 | memcpy(values, &data.block[1], data.block[0]); |
944 | values[i-1] = data.block[i]; | 943 | return data.block[0]; |
945 | return data.block[0]; | ||
946 | } | ||
947 | } | 944 | } |
948 | 945 | ||
949 | s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, | 946 | s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, |
@@ -1118,10 +1115,10 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1118 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 1115 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; |
1119 | 1116 | ||
1120 | if (adapter->algo->smbus_xfer) { | 1117 | if (adapter->algo->smbus_xfer) { |
1121 | down(&adapter->bus_lock); | 1118 | mutex_lock(&adapter->bus_lock); |
1122 | res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, | 1119 | res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, |
1123 | command,size,data); | 1120 | command,size,data); |
1124 | up(&adapter->bus_lock); | 1121 | mutex_unlock(&adapter->bus_lock); |
1125 | } else | 1122 | } else |
1126 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1123 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, |
1127 | command,size,data); | 1124 | command,size,data); |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 4ce07ae62dac..671e36db224d 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(x) (x)->name | 57 | #define I2C_NAME(x) (x)->name |
59 | 58 | ||
@@ -125,24 +124,21 @@ adv7170_write_block (struct i2c_client *client, | |||
125 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 124 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
126 | /* do raw I2C, not smbus compatible */ | 125 | /* do raw I2C, not smbus compatible */ |
127 | struct adv7170 *encoder = i2c_get_clientdata(client); | 126 | struct adv7170 *encoder = i2c_get_clientdata(client); |
128 | struct i2c_msg msg; | ||
129 | u8 block_data[32]; | 127 | u8 block_data[32]; |
128 | int block_len; | ||
130 | 129 | ||
131 | msg.addr = client->addr; | ||
132 | msg.flags = 0; | ||
133 | while (len >= 2) { | 130 | while (len >= 2) { |
134 | msg.buf = (char *) block_data; | 131 | block_len = 0; |
135 | msg.len = 0; | 132 | block_data[block_len++] = reg = data[0]; |
136 | block_data[msg.len++] = reg = data[0]; | ||
137 | do { | 133 | do { |
138 | block_data[msg.len++] = | 134 | block_data[block_len++] = |
139 | encoder->reg[reg++] = data[1]; | 135 | encoder->reg[reg++] = data[1]; |
140 | len -= 2; | 136 | len -= 2; |
141 | data += 2; | 137 | data += 2; |
142 | } while (len >= 2 && data[0] == reg && | 138 | } while (len >= 2 && data[0] == reg && |
143 | msg.len < 32); | 139 | block_len < 32); |
144 | if ((ret = i2c_transfer(client->adapter, | 140 | if ((ret = i2c_master_send(client, block_data, |
145 | &msg, 1)) < 0) | 141 | block_len)) < 0) |
146 | break; | 142 | break; |
147 | } | 143 | } |
148 | } else { | 144 | } else { |
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 4e218f22b214..085e8863cacb 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
49 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
50 | 50 | ||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/i2c-dev.h> | ||
53 | 52 | ||
54 | #define I2C_NAME(s) (s)->name | 53 | #define I2C_NAME(s) (s)->name |
55 | 54 | ||
@@ -68,8 +67,6 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
68 | /* ----------------------------------------------------------------------- */ | 67 | /* ----------------------------------------------------------------------- */ |
69 | 68 | ||
70 | struct adv7175 { | 69 | struct adv7175 { |
71 | unsigned char reg[128]; | ||
72 | |||
73 | int norm; | 70 | int norm; |
74 | int input; | 71 | int input; |
75 | int enable; | 72 | int enable; |
@@ -95,9 +92,6 @@ adv7175_write (struct i2c_client *client, | |||
95 | u8 reg, | 92 | u8 reg, |
96 | u8 value) | 93 | u8 value) |
97 | { | 94 | { |
98 | struct adv7175 *encoder = i2c_get_clientdata(client); | ||
99 | |||
100 | encoder->reg[reg] = value; | ||
101 | return i2c_smbus_write_byte_data(client, reg, value); | 95 | return i2c_smbus_write_byte_data(client, reg, value); |
102 | } | 96 | } |
103 | 97 | ||
@@ -120,25 +114,21 @@ adv7175_write_block (struct i2c_client *client, | |||
120 | * the adapter understands raw I2C */ | 114 | * the adapter understands raw I2C */ |
121 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 115 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
122 | /* do raw I2C, not smbus compatible */ | 116 | /* do raw I2C, not smbus compatible */ |
123 | struct adv7175 *encoder = i2c_get_clientdata(client); | ||
124 | struct i2c_msg msg; | ||
125 | u8 block_data[32]; | 117 | u8 block_data[32]; |
118 | int block_len; | ||
126 | 119 | ||
127 | msg.addr = client->addr; | ||
128 | msg.flags = 0; | ||
129 | while (len >= 2) { | 120 | while (len >= 2) { |
130 | msg.buf = (char *) block_data; | 121 | block_len = 0; |
131 | msg.len = 0; | 122 | block_data[block_len++] = reg = data[0]; |
132 | block_data[msg.len++] = reg = data[0]; | ||
133 | do { | 123 | do { |
134 | block_data[msg.len++] = | 124 | block_data[block_len++] = data[1]; |
135 | encoder->reg[reg++] = data[1]; | 125 | reg++; |
136 | len -= 2; | 126 | len -= 2; |
137 | data += 2; | 127 | data += 2; |
138 | } while (len >= 2 && data[0] == reg && | 128 | } while (len >= 2 && data[0] == reg && |
139 | msg.len < 32); | 129 | block_len < 32); |
140 | if ((ret = i2c_transfer(client->adapter, | 130 | if ((ret = i2c_master_send(client, block_data, |
141 | &msg, 1)) < 0) | 131 | block_len)) < 0) |
142 | break; | 132 | break; |
143 | } | 133 | } |
144 | } else { | 134 | } else { |
@@ -171,24 +161,6 @@ set_subcarrier_freq (struct i2c_client *client, | |||
171 | adv7175_write(client, 0x05, 0x25); | 161 | adv7175_write(client, 0x05, 0x25); |
172 | } | 162 | } |
173 | 163 | ||
174 | #ifdef ENCODER_DUMP | ||
175 | static void | ||
176 | dump (struct i2c_client *client) | ||
177 | { | ||
178 | struct adv7175 *encoder = i2c_get_clientdata(client); | ||
179 | int i, j; | ||
180 | |||
181 | printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client)); | ||
182 | for (i = 0; i < 182 / 8; i++) { | ||
183 | printk("%s: 0x%02x -", I2C_NAME(client), i * 8); | ||
184 | for (j = 0; j < 8; j++) { | ||
185 | printk(" 0x%02x", encoder->reg[i * 8 + j]); | ||
186 | } | ||
187 | printk("\n"); | ||
188 | } | ||
189 | } | ||
190 | #endif | ||
191 | |||
192 | /* ----------------------------------------------------------------------- */ | 164 | /* ----------------------------------------------------------------------- */ |
193 | // Output filter: S-Video Composite | 165 | // Output filter: S-Video Composite |
194 | 166 | ||
@@ -407,14 +379,6 @@ adv7175_command (struct i2c_client *client, | |||
407 | } | 379 | } |
408 | break; | 380 | break; |
409 | 381 | ||
410 | #ifdef ENCODER_DUMP | ||
411 | case ENCODER_DUMP: | ||
412 | { | ||
413 | dump(client); | ||
414 | } | ||
415 | break; | ||
416 | #endif | ||
417 | |||
418 | default: | 382 | default: |
419 | return -EINVAL; | 383 | return -EINVAL; |
420 | } | 384 | } |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index d6447791d0e5..d8a18a6a5bee 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
59 | 58 | ||
@@ -141,24 +140,21 @@ bt819_write_block (struct i2c_client *client, | |||
141 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 140 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
142 | /* do raw I2C, not smbus compatible */ | 141 | /* do raw I2C, not smbus compatible */ |
143 | struct bt819 *decoder = i2c_get_clientdata(client); | 142 | struct bt819 *decoder = i2c_get_clientdata(client); |
144 | struct i2c_msg msg; | ||
145 | u8 block_data[32]; | 143 | u8 block_data[32]; |
144 | int block_len; | ||
146 | 145 | ||
147 | msg.addr = client->addr; | ||
148 | msg.flags = 0; | ||
149 | while (len >= 2) { | 146 | while (len >= 2) { |
150 | msg.buf = (char *) block_data; | 147 | block_len = 0; |
151 | msg.len = 0; | 148 | block_data[block_len++] = reg = data[0]; |
152 | block_data[msg.len++] = reg = data[0]; | ||
153 | do { | 149 | do { |
154 | block_data[msg.len++] = | 150 | block_data[block_len++] = |
155 | decoder->reg[reg++] = data[1]; | 151 | decoder->reg[reg++] = data[1]; |
156 | len -= 2; | 152 | len -= 2; |
157 | data += 2; | 153 | data += 2; |
158 | } while (len >= 2 && data[0] == reg && | 154 | } while (len >= 2 && data[0] == reg && |
159 | msg.len < 32); | 155 | block_len < 32); |
160 | if ((ret = i2c_transfer(client->adapter, | 156 | if ((ret = i2c_master_send(client, block_data, |
161 | &msg, 1)) < 0) | 157 | block_len)) < 0) |
162 | break; | 158 | break; |
163 | } | 159 | } |
164 | } else { | 160 | } else { |
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 909b593530ed..4d47a0a0e974 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
59 | 58 | ||
@@ -71,17 +70,14 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
71 | 70 | ||
72 | /* ----------------------------------------------------------------------- */ | 71 | /* ----------------------------------------------------------------------- */ |
73 | 72 | ||
74 | #define REG_OFFSET 0xCE | 73 | #define REG_OFFSET 0xDA |
74 | #define BT856_NR_REG 6 | ||
75 | 75 | ||
76 | struct bt856 { | 76 | struct bt856 { |
77 | unsigned char reg[32]; | 77 | unsigned char reg[BT856_NR_REG]; |
78 | 78 | ||
79 | int norm; | 79 | int norm; |
80 | int enable; | 80 | int enable; |
81 | int bright; | ||
82 | int contrast; | ||
83 | int hue; | ||
84 | int sat; | ||
85 | }; | 81 | }; |
86 | 82 | ||
87 | #define I2C_BT856 0x88 | 83 | #define I2C_BT856 0x88 |
@@ -120,8 +116,8 @@ bt856_dump (struct i2c_client *client) | |||
120 | struct bt856 *encoder = i2c_get_clientdata(client); | 116 | struct bt856 *encoder = i2c_get_clientdata(client); |
121 | 117 | ||
122 | printk(KERN_INFO "%s: register dump:", I2C_NAME(client)); | 118 | printk(KERN_INFO "%s: register dump:", I2C_NAME(client)); |
123 | for (i = 0xd6; i <= 0xde; i += 2) | 119 | for (i = 0; i < BT856_NR_REG; i += 2) |
124 | printk(" %02x", encoder->reg[i - REG_OFFSET]); | 120 | printk(" %02x", encoder->reg[i]); |
125 | printk("\n"); | 121 | printk("\n"); |
126 | } | 122 | } |
127 | 123 | ||
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index d93a561e6b80..3cebfa91ca14 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
@@ -58,7 +58,7 @@ static int video_nr = -1; | |||
58 | 58 | ||
59 | #ifdef MODULE | 59 | #ifdef MODULE |
60 | module_param(video_nr, int, 0); | 60 | module_param(video_nr, int, 0); |
61 | MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfeld.com>"); | 61 | MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfelt.com>"); |
62 | MODULE_DESCRIPTION("V4L-driver for Vision CPiA based cameras"); | 62 | MODULE_DESCRIPTION("V4L-driver for Vision CPiA based cameras"); |
63 | MODULE_LICENSE("GPL"); | 63 | MODULE_LICENSE("GPL"); |
64 | MODULE_SUPPORTED_DEVICE("video"); | 64 | MODULE_SUPPORTED_DEVICE("video"); |
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 7bb85a7b326e..e18ea268384b 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -39,7 +39,6 @@ MODULE_AUTHOR("Pauline Middelink"); | |||
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
42 | #include <linux/i2c-dev.h> | ||
43 | 42 | ||
44 | #define I2C_NAME(s) (s)->name | 43 | #define I2C_NAME(s) (s)->name |
45 | 44 | ||
@@ -108,13 +107,8 @@ saa7110_write_block (struct i2c_client *client, | |||
108 | * the adapter understands raw I2C */ | 107 | * the adapter understands raw I2C */ |
109 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 108 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
110 | struct saa7110 *decoder = i2c_get_clientdata(client); | 109 | struct saa7110 *decoder = i2c_get_clientdata(client); |
111 | struct i2c_msg msg; | ||
112 | 110 | ||
113 | msg.len = len; | 111 | ret = i2c_master_send(client, data, len); |
114 | msg.buf = (char *) data; | ||
115 | msg.addr = client->addr; | ||
116 | msg.flags = 0; | ||
117 | ret = i2c_transfer(client->adapter, &msg, 1); | ||
118 | 112 | ||
119 | /* Cache the written data */ | 113 | /* Cache the written data */ |
120 | memcpy(decoder->reg + reg, data + 1, len - 1); | 114 | memcpy(decoder->reg + reg, data + 1, len - 1); |
@@ -432,15 +426,13 @@ saa7110_command (struct i2c_client *client, | |||
432 | break; | 426 | break; |
433 | 427 | ||
434 | case DECODER_DUMP: | 428 | case DECODER_DUMP: |
435 | for (v = 0; v < 0x34; v += 16) { | 429 | for (v = 0; v < SAA7110_NR_REG; v += 16) { |
436 | int j; | 430 | int j; |
437 | dprintk(1, KERN_INFO "%s: %03x\n", I2C_NAME(client), | 431 | dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client), |
438 | v); | 432 | v); |
439 | for (j = 0; j < 16; j++) { | 433 | for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) |
440 | dprintk(1, KERN_INFO " %02x", | 434 | dprintk(1, " %02x", decoder->reg[v + j]); |
441 | decoder->reg[v + j]); | 435 | dprintk(1, "\n"); |
442 | } | ||
443 | dprintk(1, KERN_INFO "\n"); | ||
444 | } | 436 | } |
445 | break; | 437 | break; |
446 | 438 | ||
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 8c06592b37ff..f9ba0c943adf 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -52,7 +52,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
53 | 53 | ||
54 | #include <linux/i2c.h> | 54 | #include <linux/i2c.h> |
55 | #include <linux/i2c-dev.h> | ||
56 | 55 | ||
57 | #define I2C_NAME(s) (s)->name | 56 | #define I2C_NAME(s) (s)->name |
58 | 57 | ||
@@ -70,8 +69,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
70 | 69 | ||
71 | /* ----------------------------------------------------------------------- */ | 70 | /* ----------------------------------------------------------------------- */ |
72 | 71 | ||
72 | #define SAA7111_NR_REG 0x18 | ||
73 | |||
73 | struct saa7111 { | 74 | struct saa7111 { |
74 | unsigned char reg[32]; | 75 | unsigned char reg[SAA7111_NR_REG]; |
75 | 76 | ||
76 | int norm; | 77 | int norm; |
77 | int input; | 78 | int input; |
@@ -110,24 +111,21 @@ saa7111_write_block (struct i2c_client *client, | |||
110 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 111 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
111 | /* do raw I2C, not smbus compatible */ | 112 | /* do raw I2C, not smbus compatible */ |
112 | struct saa7111 *decoder = i2c_get_clientdata(client); | 113 | struct saa7111 *decoder = i2c_get_clientdata(client); |
113 | struct i2c_msg msg; | ||
114 | u8 block_data[32]; | 114 | u8 block_data[32]; |
115 | int block_len; | ||
115 | 116 | ||
116 | msg.addr = client->addr; | ||
117 | msg.flags = 0; | ||
118 | while (len >= 2) { | 117 | while (len >= 2) { |
119 | msg.buf = (char *) block_data; | 118 | block_len = 0; |
120 | msg.len = 0; | 119 | block_data[block_len++] = reg = data[0]; |
121 | block_data[msg.len++] = reg = data[0]; | ||
122 | do { | 120 | do { |
123 | block_data[msg.len++] = | 121 | block_data[block_len++] = |
124 | decoder->reg[reg++] = data[1]; | 122 | decoder->reg[reg++] = data[1]; |
125 | len -= 2; | 123 | len -= 2; |
126 | data += 2; | 124 | data += 2; |
127 | } while (len >= 2 && data[0] == reg && | 125 | } while (len >= 2 && data[0] == reg && |
128 | msg.len < 32); | 126 | block_len < 32); |
129 | if ((ret = i2c_transfer(client->adapter, | 127 | if ((ret = i2c_master_send(client, block_data, |
130 | &msg, 1)) < 0) | 128 | block_len)) < 0) |
131 | break; | 129 | break; |
132 | } | 130 | } |
133 | } else { | 131 | } else { |
@@ -210,6 +208,7 @@ saa7111_command (struct i2c_client *client, | |||
210 | switch (cmd) { | 208 | switch (cmd) { |
211 | 209 | ||
212 | case 0: | 210 | case 0: |
211 | break; | ||
213 | case DECODER_INIT: | 212 | case DECODER_INIT: |
214 | { | 213 | { |
215 | struct video_decoder_init *init = arg; | 214 | struct video_decoder_init *init = arg; |
@@ -227,11 +226,11 @@ saa7111_command (struct i2c_client *client, | |||
227 | { | 226 | { |
228 | int i; | 227 | int i; |
229 | 228 | ||
230 | for (i = 0; i < 32; i += 16) { | 229 | for (i = 0; i < SAA7111_NR_REG; i += 16) { |
231 | int j; | 230 | int j; |
232 | 231 | ||
233 | printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); | 232 | printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); |
234 | for (j = 0; j < 16; ++j) { | 233 | for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { |
235 | printk(" %02x", | 234 | printk(" %02x", |
236 | saa7111_read(client, i + j)); | 235 | saa7111_read(client, i + j)); |
237 | } | 236 | } |
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index fd0a4b4ef014..4a1f841d0c77 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -55,7 +55,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin"); | |||
55 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
56 | 56 | ||
57 | #include <linux/i2c.h> | 57 | #include <linux/i2c.h> |
58 | #include <linux/i2c-dev.h> | ||
59 | 58 | ||
60 | #define I2C_NAME(x) (x)->name | 59 | #define I2C_NAME(x) (x)->name |
61 | 60 | ||
@@ -139,9 +138,6 @@ saa7114_write (struct i2c_client *client, | |||
139 | u8 reg, | 138 | u8 reg, |
140 | u8 value) | 139 | u8 value) |
141 | { | 140 | { |
142 | /*struct saa7114 *decoder = i2c_get_clientdata(client);*/ | ||
143 | |||
144 | /*decoder->reg[reg] = value;*/ | ||
145 | return i2c_smbus_write_byte_data(client, reg, value); | 141 | return i2c_smbus_write_byte_data(client, reg, value); |
146 | } | 142 | } |
147 | 143 | ||
@@ -157,25 +153,21 @@ saa7114_write_block (struct i2c_client *client, | |||
157 | * the adapter understands raw I2C */ | 153 | * the adapter understands raw I2C */ |
158 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 154 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
159 | /* do raw I2C, not smbus compatible */ | 155 | /* do raw I2C, not smbus compatible */ |
160 | /*struct saa7114 *decoder = i2c_get_clientdata(client);*/ | ||
161 | struct i2c_msg msg; | ||
162 | u8 block_data[32]; | 156 | u8 block_data[32]; |
157 | int block_len; | ||
163 | 158 | ||
164 | msg.addr = client->addr; | ||
165 | msg.flags = 0; | ||
166 | while (len >= 2) { | 159 | while (len >= 2) { |
167 | msg.buf = (char *) block_data; | 160 | block_len = 0; |
168 | msg.len = 0; | 161 | block_data[block_len++] = reg = data[0]; |
169 | block_data[msg.len++] = reg = data[0]; | ||
170 | do { | 162 | do { |
171 | block_data[msg.len++] = | 163 | block_data[block_len++] = data[1]; |
172 | /*decoder->reg[reg++] =*/ data[1]; | 164 | reg++; |
173 | len -= 2; | 165 | len -= 2; |
174 | data += 2; | 166 | data += 2; |
175 | } while (len >= 2 && data[0] == reg && | 167 | } while (len >= 2 && data[0] == reg && |
176 | msg.len < 32); | 168 | block_len < 32); |
177 | if ((ret = i2c_transfer(client->adapter, | 169 | if ((ret = i2c_master_send(client, block_data, |
178 | &msg, 1)) < 0) | 170 | block_len)) < 0) |
179 | break; | 171 | break; |
180 | } | 172 | } |
181 | } else { | 173 | } else { |
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 6c161f2f5e2c..708fae51e8ee 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c | |||
@@ -45,7 +45,6 @@ MODULE_AUTHOR("Dave Perks, Jose Ignacio Gijon, Joerg Heckenbach, Mark McClelland | |||
45 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
46 | 46 | ||
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/i2c-dev.h> | ||
49 | 48 | ||
50 | #define I2C_NAME(s) (s)->name | 49 | #define I2C_NAME(s) (s)->name |
51 | 50 | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 3ed0edb870a4..9f99ee1303e0 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
49 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
50 | 50 | ||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/i2c-dev.h> | ||
53 | 52 | ||
54 | #define I2C_NAME(s) (s)->name | 53 | #define I2C_NAME(s) (s)->name |
55 | 54 | ||
@@ -113,24 +112,21 @@ saa7185_write_block (struct i2c_client *client, | |||
113 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 112 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
114 | /* do raw I2C, not smbus compatible */ | 113 | /* do raw I2C, not smbus compatible */ |
115 | struct saa7185 *encoder = i2c_get_clientdata(client); | 114 | struct saa7185 *encoder = i2c_get_clientdata(client); |
116 | struct i2c_msg msg; | ||
117 | u8 block_data[32]; | 115 | u8 block_data[32]; |
116 | int block_len; | ||
118 | 117 | ||
119 | msg.addr = client->addr; | ||
120 | msg.flags = 0; | ||
121 | while (len >= 2) { | 118 | while (len >= 2) { |
122 | msg.buf = (char *) block_data; | 119 | block_len = 0; |
123 | msg.len = 0; | 120 | block_data[block_len++] = reg = data[0]; |
124 | block_data[msg.len++] = reg = data[0]; | ||
125 | do { | 121 | do { |
126 | block_data[msg.len++] = | 122 | block_data[block_len++] = |
127 | encoder->reg[reg++] = data[1]; | 123 | encoder->reg[reg++] = data[1]; |
128 | len -= 2; | 124 | len -= 2; |
129 | data += 2; | 125 | data += 2; |
130 | } while (len >= 2 && data[0] == reg && | 126 | } while (len >= 2 && data[0] == reg && |
131 | msg.len < 32); | 127 | block_len < 32); |
132 | if ((ret = i2c_transfer(client->adapter, | 128 | if ((ret = i2c_master_send(client, block_data, |
133 | &msg, 1)) < 0) | 129 | block_len)) < 0) |
134 | break; | 130 | break; |
135 | } | 131 | } |
136 | } else { | 132 | } else { |
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index d0a1e72ea8c4..4cd579967487 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
31 | 31 | ||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/i2c-dev.h> | ||
34 | 33 | ||
35 | #define I2C_NAME(x) (x)->name | 34 | #define I2C_NAME(x) (x)->name |
36 | 35 | ||
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h index 9fe6ad3b6352..ad04a129499d 100644 --- a/drivers/media/video/zoran.h +++ b/drivers/media/video/zoran.h | |||
@@ -395,7 +395,7 @@ struct zoran { | |||
395 | struct videocodec *codec; /* video codec */ | 395 | struct videocodec *codec; /* video codec */ |
396 | struct videocodec *vfe; /* video front end */ | 396 | struct videocodec *vfe; /* video front end */ |
397 | 397 | ||
398 | struct semaphore resource_lock; /* prevent evil stuff */ | 398 | struct mutex resource_lock; /* prevent evil stuff */ |
399 | 399 | ||
400 | u8 initialized; /* flag if zoran has been correctly initalized */ | 400 | u8 initialized; /* flag if zoran has been correctly initalized */ |
401 | int user; /* number of current users */ | 401 | int user; /* number of current users */ |
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 246e67cd8b51..b22dbb6d18f6 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/interrupt.h> | 47 | #include <linux/interrupt.h> |
48 | #include <linux/video_decoder.h> | 48 | #include <linux/video_decoder.h> |
49 | #include <linux/video_encoder.h> | 49 | #include <linux/video_encoder.h> |
50 | #include <linux/mutex.h> | ||
50 | 51 | ||
51 | #include <asm/io.h> | 52 | #include <asm/io.h> |
52 | 53 | ||
@@ -673,7 +674,7 @@ zoran_i2c_client_register (struct i2c_client *client) | |||
673 | KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n", | 674 | KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n", |
674 | ZR_DEVNAME(zr), client->driver->id); | 675 | ZR_DEVNAME(zr), client->driver->id); |
675 | 676 | ||
676 | down(&zr->resource_lock); | 677 | mutex_lock(&zr->resource_lock); |
677 | 678 | ||
678 | if (zr->user > 0) { | 679 | if (zr->user > 0) { |
679 | /* we're already busy, so we keep a reference to | 680 | /* we're already busy, so we keep a reference to |
@@ -694,7 +695,7 @@ zoran_i2c_client_register (struct i2c_client *client) | |||
694 | } | 695 | } |
695 | 696 | ||
696 | clientreg_unlock_and_return: | 697 | clientreg_unlock_and_return: |
697 | up(&zr->resource_lock); | 698 | mutex_unlock(&zr->resource_lock); |
698 | 699 | ||
699 | return res; | 700 | return res; |
700 | } | 701 | } |
@@ -707,7 +708,7 @@ zoran_i2c_client_unregister (struct i2c_client *client) | |||
707 | 708 | ||
708 | dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr)); | 709 | dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr)); |
709 | 710 | ||
710 | down(&zr->resource_lock); | 711 | mutex_lock(&zr->resource_lock); |
711 | 712 | ||
712 | if (zr->user > 0) { | 713 | if (zr->user > 0) { |
713 | res = -EBUSY; | 714 | res = -EBUSY; |
@@ -722,7 +723,7 @@ zoran_i2c_client_unregister (struct i2c_client *client) | |||
722 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id); | 723 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id); |
723 | } | 724 | } |
724 | clientunreg_unlock_and_return: | 725 | clientunreg_unlock_and_return: |
725 | up(&zr->resource_lock); | 726 | mutex_unlock(&zr->resource_lock); |
726 | return res; | 727 | return res; |
727 | } | 728 | } |
728 | 729 | ||
@@ -995,10 +996,7 @@ test_interrupts (struct zoran *zr) | |||
995 | static int __devinit | 996 | static int __devinit |
996 | zr36057_init (struct zoran *zr) | 997 | zr36057_init (struct zoran *zr) |
997 | { | 998 | { |
998 | u32 *mem; | 999 | int j, err; |
999 | void *vdev; | ||
1000 | unsigned mem_needed; | ||
1001 | int j; | ||
1002 | int two = 2; | 1000 | int two = 2; |
1003 | int zero = 0; | 1001 | int zero = 0; |
1004 | 1002 | ||
@@ -1049,19 +1047,16 @@ zr36057_init (struct zoran *zr) | |||
1049 | 1047 | ||
1050 | /* allocate memory *before* doing anything to the hardware | 1048 | /* allocate memory *before* doing anything to the hardware |
1051 | * in case allocation fails */ | 1049 | * in case allocation fails */ |
1052 | mem_needed = BUZ_NUM_STAT_COM * 4; | 1050 | zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL); |
1053 | mem = kzalloc(mem_needed, GFP_KERNEL); | 1051 | zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL); |
1054 | vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL); | 1052 | if (!zr->stat_com || !zr->video_dev) { |
1055 | if (!mem || !vdev) { | ||
1056 | dprintk(1, | 1053 | dprintk(1, |
1057 | KERN_ERR | 1054 | KERN_ERR |
1058 | "%s: zr36057_init() - kmalloc (STAT_COM) failed\n", | 1055 | "%s: zr36057_init() - kmalloc (STAT_COM) failed\n", |
1059 | ZR_DEVNAME(zr)); | 1056 | ZR_DEVNAME(zr)); |
1060 | kfree(vdev); | 1057 | err = -ENOMEM; |
1061 | kfree(mem); | 1058 | goto exit_free; |
1062 | return -ENOMEM; | ||
1063 | } | 1059 | } |
1064 | zr->stat_com = mem; | ||
1065 | for (j = 0; j < BUZ_NUM_STAT_COM; j++) { | 1060 | for (j = 0; j < BUZ_NUM_STAT_COM; j++) { |
1066 | zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ | 1061 | zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ |
1067 | } | 1062 | } |
@@ -1069,16 +1064,11 @@ zr36057_init (struct zoran *zr) | |||
1069 | /* | 1064 | /* |
1070 | * Now add the template and register the device unit. | 1065 | * Now add the template and register the device unit. |
1071 | */ | 1066 | */ |
1072 | zr->video_dev = vdev; | ||
1073 | memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); | 1067 | memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); |
1074 | strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); | 1068 | strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); |
1075 | if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER, | 1069 | err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr); |
1076 | video_nr) < 0) { | 1070 | if (err < 0) |
1077 | zoran_unregister_i2c(zr); | 1071 | goto exit_unregister; |
1078 | kfree((void *) zr->stat_com); | ||
1079 | kfree(vdev); | ||
1080 | return -1; | ||
1081 | } | ||
1082 | 1072 | ||
1083 | zoran_init_hardware(zr); | 1073 | zoran_init_hardware(zr); |
1084 | if (*zr_debug > 2) | 1074 | if (*zr_debug > 2) |
@@ -1092,6 +1082,13 @@ zr36057_init (struct zoran *zr) | |||
1092 | zr->zoran_proc = NULL; | 1082 | zr->zoran_proc = NULL; |
1093 | zr->initialized = 1; | 1083 | zr->initialized = 1; |
1094 | return 0; | 1084 | return 0; |
1085 | |||
1086 | exit_unregister: | ||
1087 | zoran_unregister_i2c(zr); | ||
1088 | exit_free: | ||
1089 | kfree(zr->stat_com); | ||
1090 | kfree(zr->video_dev); | ||
1091 | return err; | ||
1095 | } | 1092 | } |
1096 | 1093 | ||
1097 | static void | 1094 | static void |
@@ -1121,7 +1118,7 @@ zoran_release (struct zoran *zr) | |||
1121 | btwrite(0, ZR36057_SPGPPCR); | 1118 | btwrite(0, ZR36057_SPGPPCR); |
1122 | free_irq(zr->pci_dev->irq, zr); | 1119 | free_irq(zr->pci_dev->irq, zr); |
1123 | /* unmap and free memory */ | 1120 | /* unmap and free memory */ |
1124 | kfree((void *) zr->stat_com); | 1121 | kfree(zr->stat_com); |
1125 | zoran_proc_cleanup(zr); | 1122 | zoran_proc_cleanup(zr); |
1126 | iounmap(zr->zr36057_mem); | 1123 | iounmap(zr->zr36057_mem); |
1127 | pci_disable_device(zr->pci_dev); | 1124 | pci_disable_device(zr->pci_dev); |
@@ -1206,7 +1203,7 @@ find_zr36057 (void) | |||
1206 | zr->id = zoran_num; | 1203 | zr->id = zoran_num; |
1207 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); | 1204 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); |
1208 | spin_lock_init(&zr->spinlock); | 1205 | spin_lock_init(&zr->spinlock); |
1209 | init_MUTEX(&zr->resource_lock); | 1206 | mutex_init(&zr->resource_lock); |
1210 | if (pci_enable_device(dev)) | 1207 | if (pci_enable_device(dev)) |
1211 | continue; | 1208 | continue; |
1212 | zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); | 1209 | zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); |
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index 485553be190b..b2c6e01e3923 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c | |||
@@ -81,6 +81,7 @@ | |||
81 | 81 | ||
82 | #include <linux/video_decoder.h> | 82 | #include <linux/video_decoder.h> |
83 | #include <linux/video_encoder.h> | 83 | #include <linux/video_encoder.h> |
84 | #include <linux/mutex.h> | ||
84 | #include "zoran.h" | 85 | #include "zoran.h" |
85 | #include "zoran_device.h" | 86 | #include "zoran_device.h" |
86 | #include "zoran_card.h" | 87 | #include "zoran_card.h" |
@@ -1292,7 +1293,7 @@ zoran_open (struct inode *inode, | |||
1292 | 1293 | ||
1293 | /* see fs/device.c - the kernel already locks during open(), | 1294 | /* see fs/device.c - the kernel already locks during open(), |
1294 | * so locking ourselves only causes deadlocks */ | 1295 | * so locking ourselves only causes deadlocks */ |
1295 | /*down(&zr->resource_lock);*/ | 1296 | /*mutex_lock(&zr->resource_lock);*/ |
1296 | 1297 | ||
1297 | if (!zr->decoder) { | 1298 | if (!zr->decoder) { |
1298 | dprintk(1, | 1299 | dprintk(1, |
@@ -1371,7 +1372,7 @@ zoran_open (struct inode *inode, | |||
1371 | if (zr->user++ == 0) | 1372 | if (zr->user++ == 0) |
1372 | first_open = 1; | 1373 | first_open = 1; |
1373 | 1374 | ||
1374 | /*up(&zr->resource_lock);*/ | 1375 | /*mutex_unlock(&zr->resource_lock);*/ |
1375 | 1376 | ||
1376 | /* default setup - TODO: look at flags */ | 1377 | /* default setup - TODO: look at flags */ |
1377 | if (first_open) { /* First device open */ | 1378 | if (first_open) { /* First device open */ |
@@ -1401,7 +1402,7 @@ open_unlock_and_return: | |||
1401 | 1402 | ||
1402 | /* if there's no device found, we didn't obtain the lock either */ | 1403 | /* if there's no device found, we didn't obtain the lock either */ |
1403 | if (zr) { | 1404 | if (zr) { |
1404 | /*up(&zr->resource_lock);*/ | 1405 | /*mutex_unlock(&zr->resource_lock);*/ |
1405 | } | 1406 | } |
1406 | 1407 | ||
1407 | return res; | 1408 | return res; |
@@ -1419,7 +1420,7 @@ zoran_close (struct inode *inode, | |||
1419 | 1420 | ||
1420 | /* kernel locks (fs/device.c), so don't do that ourselves | 1421 | /* kernel locks (fs/device.c), so don't do that ourselves |
1421 | * (prevents deadlocks) */ | 1422 | * (prevents deadlocks) */ |
1422 | /*down(&zr->resource_lock);*/ | 1423 | /*mutex_lock(&zr->resource_lock);*/ |
1423 | 1424 | ||
1424 | zoran_close_end_session(file); | 1425 | zoran_close_end_session(file); |
1425 | 1426 | ||
@@ -1466,7 +1467,7 @@ zoran_close (struct inode *inode, | |||
1466 | } | 1467 | } |
1467 | module_put(THIS_MODULE); | 1468 | module_put(THIS_MODULE); |
1468 | 1469 | ||
1469 | /*up(&zr->resource_lock);*/ | 1470 | /*mutex_unlock(&zr->resource_lock);*/ |
1470 | 1471 | ||
1471 | dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); | 1472 | dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); |
1472 | 1473 | ||
@@ -2027,14 +2028,14 @@ zoran_do_ioctl (struct inode *inode, | |||
2027 | * but moving the free code outside the munmap() handler fixes | 2028 | * but moving the free code outside the munmap() handler fixes |
2028 | * all this... If someone knows why, please explain me (Ronald) | 2029 | * all this... If someone knows why, please explain me (Ronald) |
2029 | */ | 2030 | */ |
2030 | if (!down_trylock(&zr->resource_lock)) { | 2031 | if (!!mutex_trylock(&zr->resource_lock)) { |
2031 | /* we obtained it! Let's try to free some things */ | 2032 | /* we obtained it! Let's try to free some things */ |
2032 | if (fh->jpg_buffers.ready_to_be_freed) | 2033 | if (fh->jpg_buffers.ready_to_be_freed) |
2033 | jpg_fbuffer_free(file); | 2034 | jpg_fbuffer_free(file); |
2034 | if (fh->v4l_buffers.ready_to_be_freed) | 2035 | if (fh->v4l_buffers.ready_to_be_freed) |
2035 | v4l_fbuffer_free(file); | 2036 | v4l_fbuffer_free(file); |
2036 | 2037 | ||
2037 | up(&zr->resource_lock); | 2038 | mutex_unlock(&zr->resource_lock); |
2038 | } | 2039 | } |
2039 | 2040 | ||
2040 | switch (cmd) { | 2041 | switch (cmd) { |
@@ -2051,12 +2052,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2051 | 2052 | ||
2052 | vcap->channels = zr->card.inputs; | 2053 | vcap->channels = zr->card.inputs; |
2053 | vcap->audios = 0; | 2054 | vcap->audios = 0; |
2054 | down(&zr->resource_lock); | 2055 | mutex_lock(&zr->resource_lock); |
2055 | vcap->maxwidth = BUZ_MAX_WIDTH; | 2056 | vcap->maxwidth = BUZ_MAX_WIDTH; |
2056 | vcap->maxheight = BUZ_MAX_HEIGHT; | 2057 | vcap->maxheight = BUZ_MAX_HEIGHT; |
2057 | vcap->minwidth = BUZ_MIN_WIDTH; | 2058 | vcap->minwidth = BUZ_MIN_WIDTH; |
2058 | vcap->minheight = BUZ_MIN_HEIGHT; | 2059 | vcap->minheight = BUZ_MIN_HEIGHT; |
2059 | up(&zr->resource_lock); | 2060 | mutex_unlock(&zr->resource_lock); |
2060 | 2061 | ||
2061 | return 0; | 2062 | return 0; |
2062 | } | 2063 | } |
@@ -2084,9 +2085,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2084 | vchan->tuners = 0; | 2085 | vchan->tuners = 0; |
2085 | vchan->flags = 0; | 2086 | vchan->flags = 0; |
2086 | vchan->type = VIDEO_TYPE_CAMERA; | 2087 | vchan->type = VIDEO_TYPE_CAMERA; |
2087 | down(&zr->resource_lock); | 2088 | mutex_lock(&zr->resource_lock); |
2088 | vchan->norm = zr->norm; | 2089 | vchan->norm = zr->norm; |
2089 | up(&zr->resource_lock); | 2090 | mutex_unlock(&zr->resource_lock); |
2090 | vchan->channel = channel; | 2091 | vchan->channel = channel; |
2091 | 2092 | ||
2092 | return 0; | 2093 | return 0; |
@@ -2113,7 +2114,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2113 | "%s: VIDIOCSCHAN - channel=%d, norm=%d\n", | 2114 | "%s: VIDIOCSCHAN - channel=%d, norm=%d\n", |
2114 | ZR_DEVNAME(zr), vchan->channel, vchan->norm); | 2115 | ZR_DEVNAME(zr), vchan->channel, vchan->norm); |
2115 | 2116 | ||
2116 | down(&zr->resource_lock); | 2117 | mutex_lock(&zr->resource_lock); |
2117 | if ((res = zoran_set_input(zr, vchan->channel))) | 2118 | if ((res = zoran_set_input(zr, vchan->channel))) |
2118 | goto schan_unlock_and_return; | 2119 | goto schan_unlock_and_return; |
2119 | if ((res = zoran_set_norm(zr, vchan->norm))) | 2120 | if ((res = zoran_set_norm(zr, vchan->norm))) |
@@ -2122,7 +2123,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2122 | /* Make sure the changes come into effect */ | 2123 | /* Make sure the changes come into effect */ |
2123 | res = wait_grab_pending(zr); | 2124 | res = wait_grab_pending(zr); |
2124 | schan_unlock_and_return: | 2125 | schan_unlock_and_return: |
2125 | up(&zr->resource_lock); | 2126 | mutex_unlock(&zr->resource_lock); |
2126 | return res; | 2127 | return res; |
2127 | } | 2128 | } |
2128 | break; | 2129 | break; |
@@ -2134,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2134 | dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr)); | 2135 | dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr)); |
2135 | 2136 | ||
2136 | memset(vpict, 0, sizeof(struct video_picture)); | 2137 | memset(vpict, 0, sizeof(struct video_picture)); |
2137 | down(&zr->resource_lock); | 2138 | mutex_lock(&zr->resource_lock); |
2138 | vpict->hue = zr->hue; | 2139 | vpict->hue = zr->hue; |
2139 | vpict->brightness = zr->brightness; | 2140 | vpict->brightness = zr->brightness; |
2140 | vpict->contrast = zr->contrast; | 2141 | vpict->contrast = zr->contrast; |
@@ -2145,7 +2146,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2145 | } else { | 2146 | } else { |
2146 | vpict->depth = 0; | 2147 | vpict->depth = 0; |
2147 | } | 2148 | } |
2148 | up(&zr->resource_lock); | 2149 | mutex_unlock(&zr->resource_lock); |
2149 | 2150 | ||
2150 | return 0; | 2151 | return 0; |
2151 | } | 2152 | } |
@@ -2180,7 +2181,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2180 | return -EINVAL; | 2181 | return -EINVAL; |
2181 | } | 2182 | } |
2182 | 2183 | ||
2183 | down(&zr->resource_lock); | 2184 | mutex_lock(&zr->resource_lock); |
2184 | 2185 | ||
2185 | decoder_command(zr, DECODER_SET_PICTURE, vpict); | 2186 | decoder_command(zr, DECODER_SET_PICTURE, vpict); |
2186 | 2187 | ||
@@ -2191,7 +2192,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2191 | 2192 | ||
2192 | fh->overlay_settings.format = &zoran_formats[i]; | 2193 | fh->overlay_settings.format = &zoran_formats[i]; |
2193 | 2194 | ||
2194 | up(&zr->resource_lock); | 2195 | mutex_unlock(&zr->resource_lock); |
2195 | 2196 | ||
2196 | return 0; | 2197 | return 0; |
2197 | } | 2198 | } |
@@ -2204,9 +2205,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2204 | dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n", | 2205 | dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n", |
2205 | ZR_DEVNAME(zr), *on); | 2206 | ZR_DEVNAME(zr), *on); |
2206 | 2207 | ||
2207 | down(&zr->resource_lock); | 2208 | mutex_lock(&zr->resource_lock); |
2208 | res = setup_overlay(file, *on); | 2209 | res = setup_overlay(file, *on); |
2209 | up(&zr->resource_lock); | 2210 | mutex_unlock(&zr->resource_lock); |
2210 | 2211 | ||
2211 | return res; | 2212 | return res; |
2212 | } | 2213 | } |
@@ -2219,12 +2220,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2219 | dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr)); | 2220 | dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr)); |
2220 | 2221 | ||
2221 | memset(vwin, 0, sizeof(struct video_window)); | 2222 | memset(vwin, 0, sizeof(struct video_window)); |
2222 | down(&zr->resource_lock); | 2223 | mutex_lock(&zr->resource_lock); |
2223 | vwin->x = fh->overlay_settings.x; | 2224 | vwin->x = fh->overlay_settings.x; |
2224 | vwin->y = fh->overlay_settings.y; | 2225 | vwin->y = fh->overlay_settings.y; |
2225 | vwin->width = fh->overlay_settings.width; | 2226 | vwin->width = fh->overlay_settings.width; |
2226 | vwin->height = fh->overlay_settings.height; | 2227 | vwin->height = fh->overlay_settings.height; |
2227 | up(&zr->resource_lock); | 2228 | mutex_unlock(&zr->resource_lock); |
2228 | vwin->clipcount = 0; | 2229 | vwin->clipcount = 0; |
2229 | return 0; | 2230 | return 0; |
2230 | } | 2231 | } |
@@ -2241,12 +2242,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2241 | ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width, | 2242 | ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width, |
2242 | vwin->height, vwin->clipcount); | 2243 | vwin->height, vwin->clipcount); |
2243 | 2244 | ||
2244 | down(&zr->resource_lock); | 2245 | mutex_lock(&zr->resource_lock); |
2245 | res = | 2246 | res = |
2246 | setup_window(file, vwin->x, vwin->y, vwin->width, | 2247 | setup_window(file, vwin->x, vwin->y, vwin->width, |
2247 | vwin->height, vwin->clips, | 2248 | vwin->height, vwin->clips, |
2248 | vwin->clipcount, NULL); | 2249 | vwin->clipcount, NULL); |
2249 | up(&zr->resource_lock); | 2250 | mutex_unlock(&zr->resource_lock); |
2250 | 2251 | ||
2251 | return res; | 2252 | return res; |
2252 | } | 2253 | } |
@@ -2258,9 +2259,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2258 | 2259 | ||
2259 | dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr)); | 2260 | dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr)); |
2260 | 2261 | ||
2261 | down(&zr->resource_lock); | 2262 | mutex_lock(&zr->resource_lock); |
2262 | *vbuf = zr->buffer; | 2263 | *vbuf = zr->buffer; |
2263 | up(&zr->resource_lock); | 2264 | mutex_unlock(&zr->resource_lock); |
2264 | return 0; | 2265 | return 0; |
2265 | } | 2266 | } |
2266 | break; | 2267 | break; |
@@ -2287,12 +2288,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2287 | return -EINVAL; | 2288 | return -EINVAL; |
2288 | } | 2289 | } |
2289 | 2290 | ||
2290 | down(&zr->resource_lock); | 2291 | mutex_lock(&zr->resource_lock); |
2291 | res = | 2292 | res = |
2292 | setup_fbuffer(file, vbuf->base, &zoran_formats[i], | 2293 | setup_fbuffer(file, vbuf->base, &zoran_formats[i], |
2293 | vbuf->width, vbuf->height, | 2294 | vbuf->width, vbuf->height, |
2294 | vbuf->bytesperline); | 2295 | vbuf->bytesperline); |
2295 | up(&zr->resource_lock); | 2296 | mutex_unlock(&zr->resource_lock); |
2296 | 2297 | ||
2297 | return res; | 2298 | return res; |
2298 | } | 2299 | } |
@@ -2305,9 +2306,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2305 | dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n", | 2306 | dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n", |
2306 | ZR_DEVNAME(zr), *frame); | 2307 | ZR_DEVNAME(zr), *frame); |
2307 | 2308 | ||
2308 | down(&zr->resource_lock); | 2309 | mutex_lock(&zr->resource_lock); |
2309 | res = v4l_sync(file, *frame); | 2310 | res = v4l_sync(file, *frame); |
2310 | up(&zr->resource_lock); | 2311 | mutex_unlock(&zr->resource_lock); |
2311 | if (!res) | 2312 | if (!res) |
2312 | zr->v4l_sync_tail++; | 2313 | zr->v4l_sync_tail++; |
2313 | return res; | 2314 | return res; |
@@ -2325,9 +2326,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2325 | ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height, | 2326 | ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height, |
2326 | vmap->format); | 2327 | vmap->format); |
2327 | 2328 | ||
2328 | down(&zr->resource_lock); | 2329 | mutex_lock(&zr->resource_lock); |
2329 | res = v4l_grab(file, vmap); | 2330 | res = v4l_grab(file, vmap); |
2330 | up(&zr->resource_lock); | 2331 | mutex_unlock(&zr->resource_lock); |
2331 | return res; | 2332 | return res; |
2332 | } | 2333 | } |
2333 | break; | 2334 | break; |
@@ -2348,7 +2349,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2348 | i * fh->v4l_buffers.buffer_size; | 2349 | i * fh->v4l_buffers.buffer_size; |
2349 | } | 2350 | } |
2350 | 2351 | ||
2351 | down(&zr->resource_lock); | 2352 | mutex_lock(&zr->resource_lock); |
2352 | 2353 | ||
2353 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { | 2354 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { |
2354 | dprintk(1, | 2355 | dprintk(1, |
@@ -2367,7 +2368,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2367 | /* The next mmap will map the V4L buffers */ | 2368 | /* The next mmap will map the V4L buffers */ |
2368 | fh->map_mode = ZORAN_MAP_MODE_RAW; | 2369 | fh->map_mode = ZORAN_MAP_MODE_RAW; |
2369 | v4l1reqbuf_unlock_and_return: | 2370 | v4l1reqbuf_unlock_and_return: |
2370 | up(&zr->resource_lock); | 2371 | mutex_unlock(&zr->resource_lock); |
2371 | 2372 | ||
2372 | return res; | 2373 | return res; |
2373 | } | 2374 | } |
@@ -2421,7 +2422,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2421 | bparams->major_version = MAJOR_VERSION; | 2422 | bparams->major_version = MAJOR_VERSION; |
2422 | bparams->minor_version = MINOR_VERSION; | 2423 | bparams->minor_version = MINOR_VERSION; |
2423 | 2424 | ||
2424 | down(&zr->resource_lock); | 2425 | mutex_lock(&zr->resource_lock); |
2425 | 2426 | ||
2426 | bparams->norm = zr->norm; | 2427 | bparams->norm = zr->norm; |
2427 | bparams->input = zr->input; | 2428 | bparams->input = zr->input; |
@@ -2450,7 +2451,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2450 | bparams->jpeg_markers = | 2451 | bparams->jpeg_markers = |
2451 | fh->jpg_settings.jpg_comp.jpeg_markers; | 2452 | fh->jpg_settings.jpg_comp.jpeg_markers; |
2452 | 2453 | ||
2453 | up(&zr->resource_lock); | 2454 | mutex_unlock(&zr->resource_lock); |
2454 | 2455 | ||
2455 | bparams->VFIFO_FB = 0; | 2456 | bparams->VFIFO_FB = 0; |
2456 | 2457 | ||
@@ -2486,7 +2487,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2486 | sizeof(bparams->COM_data)); | 2487 | sizeof(bparams->COM_data)); |
2487 | settings.jpg_comp.jpeg_markers = bparams->jpeg_markers; | 2488 | settings.jpg_comp.jpeg_markers = bparams->jpeg_markers; |
2488 | 2489 | ||
2489 | down(&zr->resource_lock); | 2490 | mutex_lock(&zr->resource_lock); |
2490 | 2491 | ||
2491 | if (zr->codec_mode != BUZ_MODE_IDLE) { | 2492 | if (zr->codec_mode != BUZ_MODE_IDLE) { |
2492 | dprintk(1, | 2493 | dprintk(1, |
@@ -2506,7 +2507,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2506 | 2507 | ||
2507 | fh->jpg_settings = settings; | 2508 | fh->jpg_settings = settings; |
2508 | sparams_unlock_and_return: | 2509 | sparams_unlock_and_return: |
2509 | up(&zr->resource_lock); | 2510 | mutex_unlock(&zr->resource_lock); |
2510 | 2511 | ||
2511 | return res; | 2512 | return res; |
2512 | } | 2513 | } |
@@ -2538,7 +2539,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2538 | breq->size > MAX_KMALLOC_MEM) | 2539 | breq->size > MAX_KMALLOC_MEM) |
2539 | breq->size = MAX_KMALLOC_MEM; | 2540 | breq->size = MAX_KMALLOC_MEM; |
2540 | 2541 | ||
2541 | down(&zr->resource_lock); | 2542 | mutex_lock(&zr->resource_lock); |
2542 | 2543 | ||
2543 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { | 2544 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { |
2544 | dprintk(1, | 2545 | dprintk(1, |
@@ -2561,7 +2562,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2561 | * also be *_PLAY, but it doesn't matter here */ | 2562 | * also be *_PLAY, but it doesn't matter here */ |
2562 | fh->map_mode = ZORAN_MAP_MODE_JPG_REC; | 2563 | fh->map_mode = ZORAN_MAP_MODE_JPG_REC; |
2563 | jpgreqbuf_unlock_and_return: | 2564 | jpgreqbuf_unlock_and_return: |
2564 | up(&zr->resource_lock); | 2565 | mutex_unlock(&zr->resource_lock); |
2565 | 2566 | ||
2566 | return res; | 2567 | return res; |
2567 | } | 2568 | } |
@@ -2574,9 +2575,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2574 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n", | 2575 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n", |
2575 | ZR_DEVNAME(zr), *frame); | 2576 | ZR_DEVNAME(zr), *frame); |
2576 | 2577 | ||
2577 | down(&zr->resource_lock); | 2578 | mutex_lock(&zr->resource_lock); |
2578 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS); | 2579 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS); |
2579 | up(&zr->resource_lock); | 2580 | mutex_unlock(&zr->resource_lock); |
2580 | 2581 | ||
2581 | return res; | 2582 | return res; |
2582 | } | 2583 | } |
@@ -2589,9 +2590,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2589 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n", | 2590 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n", |
2590 | ZR_DEVNAME(zr), *frame); | 2591 | ZR_DEVNAME(zr), *frame); |
2591 | 2592 | ||
2592 | down(&zr->resource_lock); | 2593 | mutex_lock(&zr->resource_lock); |
2593 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS); | 2594 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS); |
2594 | up(&zr->resource_lock); | 2595 | mutex_unlock(&zr->resource_lock); |
2595 | 2596 | ||
2596 | return res; | 2597 | return res; |
2597 | } | 2598 | } |
@@ -2604,9 +2605,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2604 | 2605 | ||
2605 | dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr)); | 2606 | dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr)); |
2606 | 2607 | ||
2607 | down(&zr->resource_lock); | 2608 | mutex_lock(&zr->resource_lock); |
2608 | res = jpg_sync(file, bsync); | 2609 | res = jpg_sync(file, bsync); |
2609 | up(&zr->resource_lock); | 2610 | mutex_unlock(&zr->resource_lock); |
2610 | 2611 | ||
2611 | return res; | 2612 | return res; |
2612 | } | 2613 | } |
@@ -2630,7 +2631,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2630 | input = zr->card.input[bstat->input].muxsel; | 2631 | input = zr->card.input[bstat->input].muxsel; |
2631 | norm = VIDEO_MODE_AUTO; | 2632 | norm = VIDEO_MODE_AUTO; |
2632 | 2633 | ||
2633 | down(&zr->resource_lock); | 2634 | mutex_lock(&zr->resource_lock); |
2634 | 2635 | ||
2635 | if (zr->codec_mode != BUZ_MODE_IDLE) { | 2636 | if (zr->codec_mode != BUZ_MODE_IDLE) { |
2636 | dprintk(1, | 2637 | dprintk(1, |
@@ -2655,7 +2656,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2655 | decoder_command(zr, DECODER_SET_INPUT, &input); | 2656 | decoder_command(zr, DECODER_SET_INPUT, &input); |
2656 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); | 2657 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); |
2657 | gstat_unlock_and_return: | 2658 | gstat_unlock_and_return: |
2658 | up(&zr->resource_lock); | 2659 | mutex_unlock(&zr->resource_lock); |
2659 | 2660 | ||
2660 | if (!res) { | 2661 | if (!res) { |
2661 | bstat->signal = | 2662 | bstat->signal = |
@@ -2763,7 +2764,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2763 | switch (fmt->type) { | 2764 | switch (fmt->type) { |
2764 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 2765 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
2765 | 2766 | ||
2766 | down(&zr->resource_lock); | 2767 | mutex_lock(&zr->resource_lock); |
2767 | 2768 | ||
2768 | fmt->fmt.win.w.left = fh->overlay_settings.x; | 2769 | fmt->fmt.win.w.left = fh->overlay_settings.x; |
2769 | fmt->fmt.win.w.top = fh->overlay_settings.y; | 2770 | fmt->fmt.win.w.top = fh->overlay_settings.y; |
@@ -2776,14 +2777,14 @@ zoran_do_ioctl (struct inode *inode, | |||
2776 | else | 2777 | else |
2777 | fmt->fmt.win.field = V4L2_FIELD_TOP; | 2778 | fmt->fmt.win.field = V4L2_FIELD_TOP; |
2778 | 2779 | ||
2779 | up(&zr->resource_lock); | 2780 | mutex_unlock(&zr->resource_lock); |
2780 | 2781 | ||
2781 | break; | 2782 | break; |
2782 | 2783 | ||
2783 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 2784 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
2784 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 2785 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
2785 | 2786 | ||
2786 | down(&zr->resource_lock); | 2787 | mutex_lock(&zr->resource_lock); |
2787 | 2788 | ||
2788 | if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && | 2789 | if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && |
2789 | fh->map_mode == ZORAN_MAP_MODE_RAW) { | 2790 | fh->map_mode == ZORAN_MAP_MODE_RAW) { |
@@ -2837,7 +2838,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2837 | V4L2_COLORSPACE_SMPTE170M; | 2838 | V4L2_COLORSPACE_SMPTE170M; |
2838 | } | 2839 | } |
2839 | 2840 | ||
2840 | up(&zr->resource_lock); | 2841 | mutex_unlock(&zr->resource_lock); |
2841 | 2842 | ||
2842 | break; | 2843 | break; |
2843 | 2844 | ||
@@ -2870,7 +2871,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2870 | fmt->fmt.win.w.height, | 2871 | fmt->fmt.win.w.height, |
2871 | fmt->fmt.win.clipcount, | 2872 | fmt->fmt.win.clipcount, |
2872 | fmt->fmt.win.bitmap); | 2873 | fmt->fmt.win.bitmap); |
2873 | down(&zr->resource_lock); | 2874 | mutex_lock(&zr->resource_lock); |
2874 | res = | 2875 | res = |
2875 | setup_window(file, fmt->fmt.win.w.left, | 2876 | setup_window(file, fmt->fmt.win.w.left, |
2876 | fmt->fmt.win.w.top, | 2877 | fmt->fmt.win.w.top, |
@@ -2880,7 +2881,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2880 | fmt->fmt.win.clips, | 2881 | fmt->fmt.win.clips, |
2881 | fmt->fmt.win.clipcount, | 2882 | fmt->fmt.win.clipcount, |
2882 | fmt->fmt.win.bitmap); | 2883 | fmt->fmt.win.bitmap); |
2883 | up(&zr->resource_lock); | 2884 | mutex_unlock(&zr->resource_lock); |
2884 | return res; | 2885 | return res; |
2885 | break; | 2886 | break; |
2886 | 2887 | ||
@@ -2917,7 +2918,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2917 | } | 2918 | } |
2918 | 2919 | ||
2919 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { | 2920 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { |
2920 | down(&zr->resource_lock); | 2921 | mutex_lock(&zr->resource_lock); |
2921 | 2922 | ||
2922 | settings = fh->jpg_settings; | 2923 | settings = fh->jpg_settings; |
2923 | 2924 | ||
@@ -2995,7 +2996,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2995 | ZORAN_MAP_MODE_JPG_REC : | 2996 | ZORAN_MAP_MODE_JPG_REC : |
2996 | ZORAN_MAP_MODE_JPG_PLAY; | 2997 | ZORAN_MAP_MODE_JPG_PLAY; |
2997 | sfmtjpg_unlock_and_return: | 2998 | sfmtjpg_unlock_and_return: |
2998 | up(&zr->resource_lock); | 2999 | mutex_unlock(&zr->resource_lock); |
2999 | } else { | 3000 | } else { |
3000 | for (i = 0; i < zoran_num_formats; i++) | 3001 | for (i = 0; i < zoran_num_formats; i++) |
3001 | if (fmt->fmt.pix.pixelformat == | 3002 | if (fmt->fmt.pix.pixelformat == |
@@ -3010,7 +3011,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3010 | (char *) &printformat); | 3011 | (char *) &printformat); |
3011 | return -EINVAL; | 3012 | return -EINVAL; |
3012 | } | 3013 | } |
3013 | down(&zr->resource_lock); | 3014 | mutex_lock(&zr->resource_lock); |
3014 | if (fh->jpg_buffers.allocated || | 3015 | if (fh->jpg_buffers.allocated || |
3015 | (fh->v4l_buffers.allocated && | 3016 | (fh->v4l_buffers.allocated && |
3016 | fh->v4l_buffers.active != | 3017 | fh->v4l_buffers.active != |
@@ -3052,7 +3053,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3052 | 3053 | ||
3053 | fh->map_mode = ZORAN_MAP_MODE_RAW; | 3054 | fh->map_mode = ZORAN_MAP_MODE_RAW; |
3054 | sfmtv4l_unlock_and_return: | 3055 | sfmtv4l_unlock_and_return: |
3055 | up(&zr->resource_lock); | 3056 | mutex_unlock(&zr->resource_lock); |
3056 | } | 3057 | } |
3057 | 3058 | ||
3058 | break; | 3059 | break; |
@@ -3077,7 +3078,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3077 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr)); | 3078 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr)); |
3078 | 3079 | ||
3079 | memset(fb, 0, sizeof(*fb)); | 3080 | memset(fb, 0, sizeof(*fb)); |
3080 | down(&zr->resource_lock); | 3081 | mutex_lock(&zr->resource_lock); |
3081 | fb->base = zr->buffer.base; | 3082 | fb->base = zr->buffer.base; |
3082 | fb->fmt.width = zr->buffer.width; | 3083 | fb->fmt.width = zr->buffer.width; |
3083 | fb->fmt.height = zr->buffer.height; | 3084 | fb->fmt.height = zr->buffer.height; |
@@ -3086,7 +3087,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3086 | fh->overlay_settings.format->fourcc; | 3087 | fh->overlay_settings.format->fourcc; |
3087 | } | 3088 | } |
3088 | fb->fmt.bytesperline = zr->buffer.bytesperline; | 3089 | fb->fmt.bytesperline = zr->buffer.bytesperline; |
3089 | up(&zr->resource_lock); | 3090 | mutex_unlock(&zr->resource_lock); |
3090 | fb->fmt.colorspace = V4L2_COLORSPACE_SRGB; | 3091 | fb->fmt.colorspace = V4L2_COLORSPACE_SRGB; |
3091 | fb->fmt.field = V4L2_FIELD_INTERLACED; | 3092 | fb->fmt.field = V4L2_FIELD_INTERLACED; |
3092 | fb->flags = V4L2_FBUF_FLAG_OVERLAY; | 3093 | fb->flags = V4L2_FBUF_FLAG_OVERLAY; |
@@ -3121,12 +3122,12 @@ zoran_do_ioctl (struct inode *inode, | |||
3121 | return -EINVAL; | 3122 | return -EINVAL; |
3122 | } | 3123 | } |
3123 | 3124 | ||
3124 | down(&zr->resource_lock); | 3125 | mutex_lock(&zr->resource_lock); |
3125 | res = | 3126 | res = |
3126 | setup_fbuffer(file, fb->base, &zoran_formats[i], | 3127 | setup_fbuffer(file, fb->base, &zoran_formats[i], |
3127 | fb->fmt.width, fb->fmt.height, | 3128 | fb->fmt.width, fb->fmt.height, |
3128 | fb->fmt.bytesperline); | 3129 | fb->fmt.bytesperline); |
3129 | up(&zr->resource_lock); | 3130 | mutex_unlock(&zr->resource_lock); |
3130 | 3131 | ||
3131 | return res; | 3132 | return res; |
3132 | } | 3133 | } |
@@ -3139,9 +3140,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3139 | dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n", | 3140 | dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n", |
3140 | ZR_DEVNAME(zr), *on); | 3141 | ZR_DEVNAME(zr), *on); |
3141 | 3142 | ||
3142 | down(&zr->resource_lock); | 3143 | mutex_lock(&zr->resource_lock); |
3143 | res = setup_overlay(file, *on); | 3144 | res = setup_overlay(file, *on); |
3144 | up(&zr->resource_lock); | 3145 | mutex_unlock(&zr->resource_lock); |
3145 | 3146 | ||
3146 | return res; | 3147 | return res; |
3147 | } | 3148 | } |
@@ -3163,7 +3164,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3163 | return -EINVAL; | 3164 | return -EINVAL; |
3164 | } | 3165 | } |
3165 | 3166 | ||
3166 | down(&zr->resource_lock); | 3167 | mutex_lock(&zr->resource_lock); |
3167 | 3168 | ||
3168 | if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) { | 3169 | if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) { |
3169 | dprintk(1, | 3170 | dprintk(1, |
@@ -3224,7 +3225,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3224 | goto v4l2reqbuf_unlock_and_return; | 3225 | goto v4l2reqbuf_unlock_and_return; |
3225 | } | 3226 | } |
3226 | v4l2reqbuf_unlock_and_return: | 3227 | v4l2reqbuf_unlock_and_return: |
3227 | up(&zr->resource_lock); | 3228 | mutex_unlock(&zr->resource_lock); |
3228 | 3229 | ||
3229 | return 0; | 3230 | return 0; |
3230 | } | 3231 | } |
@@ -3245,9 +3246,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3245 | buf->type = type; | 3246 | buf->type = type; |
3246 | buf->index = index; | 3247 | buf->index = index; |
3247 | 3248 | ||
3248 | down(&zr->resource_lock); | 3249 | mutex_lock(&zr->resource_lock); |
3249 | res = zoran_v4l2_buffer_status(file, buf, buf->index); | 3250 | res = zoran_v4l2_buffer_status(file, buf, buf->index); |
3250 | up(&zr->resource_lock); | 3251 | mutex_unlock(&zr->resource_lock); |
3251 | 3252 | ||
3252 | return res; | 3253 | return res; |
3253 | } | 3254 | } |
@@ -3262,7 +3263,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3262 | KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n", | 3263 | KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n", |
3263 | ZR_DEVNAME(zr), buf->type, buf->index); | 3264 | ZR_DEVNAME(zr), buf->type, buf->index); |
3264 | 3265 | ||
3265 | down(&zr->resource_lock); | 3266 | mutex_lock(&zr->resource_lock); |
3266 | 3267 | ||
3267 | switch (fh->map_mode) { | 3268 | switch (fh->map_mode) { |
3268 | case ZORAN_MAP_MODE_RAW: | 3269 | case ZORAN_MAP_MODE_RAW: |
@@ -3322,7 +3323,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3322 | goto qbuf_unlock_and_return; | 3323 | goto qbuf_unlock_and_return; |
3323 | } | 3324 | } |
3324 | qbuf_unlock_and_return: | 3325 | qbuf_unlock_and_return: |
3325 | up(&zr->resource_lock); | 3326 | mutex_unlock(&zr->resource_lock); |
3326 | 3327 | ||
3327 | return res; | 3328 | return res; |
3328 | } | 3329 | } |
@@ -3336,7 +3337,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3336 | dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n", | 3337 | dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n", |
3337 | ZR_DEVNAME(zr), buf->type); | 3338 | ZR_DEVNAME(zr), buf->type); |
3338 | 3339 | ||
3339 | down(&zr->resource_lock); | 3340 | mutex_lock(&zr->resource_lock); |
3340 | 3341 | ||
3341 | switch (fh->map_mode) { | 3342 | switch (fh->map_mode) { |
3342 | case ZORAN_MAP_MODE_RAW: | 3343 | case ZORAN_MAP_MODE_RAW: |
@@ -3410,7 +3411,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3410 | goto dqbuf_unlock_and_return; | 3411 | goto dqbuf_unlock_and_return; |
3411 | } | 3412 | } |
3412 | dqbuf_unlock_and_return: | 3413 | dqbuf_unlock_and_return: |
3413 | up(&zr->resource_lock); | 3414 | mutex_unlock(&zr->resource_lock); |
3414 | 3415 | ||
3415 | return res; | 3416 | return res; |
3416 | } | 3417 | } |
@@ -3422,7 +3423,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3422 | 3423 | ||
3423 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr)); | 3424 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr)); |
3424 | 3425 | ||
3425 | down(&zr->resource_lock); | 3426 | mutex_lock(&zr->resource_lock); |
3426 | 3427 | ||
3427 | switch (fh->map_mode) { | 3428 | switch (fh->map_mode) { |
3428 | case ZORAN_MAP_MODE_RAW: /* raw capture */ | 3429 | case ZORAN_MAP_MODE_RAW: /* raw capture */ |
@@ -3470,7 +3471,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3470 | goto strmon_unlock_and_return; | 3471 | goto strmon_unlock_and_return; |
3471 | } | 3472 | } |
3472 | strmon_unlock_and_return: | 3473 | strmon_unlock_and_return: |
3473 | up(&zr->resource_lock); | 3474 | mutex_unlock(&zr->resource_lock); |
3474 | 3475 | ||
3475 | return res; | 3476 | return res; |
3476 | } | 3477 | } |
@@ -3482,7 +3483,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3482 | 3483 | ||
3483 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr)); | 3484 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr)); |
3484 | 3485 | ||
3485 | down(&zr->resource_lock); | 3486 | mutex_lock(&zr->resource_lock); |
3486 | 3487 | ||
3487 | switch (fh->map_mode) { | 3488 | switch (fh->map_mode) { |
3488 | case ZORAN_MAP_MODE_RAW: /* raw capture */ | 3489 | case ZORAN_MAP_MODE_RAW: /* raw capture */ |
@@ -3540,7 +3541,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3540 | goto strmoff_unlock_and_return; | 3541 | goto strmoff_unlock_and_return; |
3541 | } | 3542 | } |
3542 | strmoff_unlock_and_return: | 3543 | strmoff_unlock_and_return: |
3543 | up(&zr->resource_lock); | 3544 | mutex_unlock(&zr->resource_lock); |
3544 | 3545 | ||
3545 | return res; | 3546 | return res; |
3546 | } | 3547 | } |
@@ -3600,7 +3601,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3600 | ctrl->id > V4L2_CID_HUE) | 3601 | ctrl->id > V4L2_CID_HUE) |
3601 | return -EINVAL; | 3602 | return -EINVAL; |
3602 | 3603 | ||
3603 | down(&zr->resource_lock); | 3604 | mutex_lock(&zr->resource_lock); |
3604 | switch (ctrl->id) { | 3605 | switch (ctrl->id) { |
3605 | case V4L2_CID_BRIGHTNESS: | 3606 | case V4L2_CID_BRIGHTNESS: |
3606 | ctrl->value = zr->brightness; | 3607 | ctrl->value = zr->brightness; |
@@ -3615,7 +3616,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3615 | ctrl->value = zr->hue; | 3616 | ctrl->value = zr->hue; |
3616 | break; | 3617 | break; |
3617 | } | 3618 | } |
3618 | up(&zr->resource_lock); | 3619 | mutex_unlock(&zr->resource_lock); |
3619 | 3620 | ||
3620 | return 0; | 3621 | return 0; |
3621 | } | 3622 | } |
@@ -3642,7 +3643,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3642 | return -EINVAL; | 3643 | return -EINVAL; |
3643 | } | 3644 | } |
3644 | 3645 | ||
3645 | down(&zr->resource_lock); | 3646 | mutex_lock(&zr->resource_lock); |
3646 | switch (ctrl->id) { | 3647 | switch (ctrl->id) { |
3647 | case V4L2_CID_BRIGHTNESS: | 3648 | case V4L2_CID_BRIGHTNESS: |
3648 | zr->brightness = ctrl->value; | 3649 | zr->brightness = ctrl->value; |
@@ -3664,7 +3665,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3664 | 3665 | ||
3665 | decoder_command(zr, DECODER_SET_PICTURE, &pict); | 3666 | decoder_command(zr, DECODER_SET_PICTURE, &pict); |
3666 | 3667 | ||
3667 | up(&zr->resource_lock); | 3668 | mutex_unlock(&zr->resource_lock); |
3668 | 3669 | ||
3669 | return 0; | 3670 | return 0; |
3670 | } | 3671 | } |
@@ -3732,9 +3733,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3732 | 3733 | ||
3733 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr)); | 3734 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr)); |
3734 | 3735 | ||
3735 | down(&zr->resource_lock); | 3736 | mutex_lock(&zr->resource_lock); |
3736 | norm = zr->norm; | 3737 | norm = zr->norm; |
3737 | up(&zr->resource_lock); | 3738 | mutex_unlock(&zr->resource_lock); |
3738 | 3739 | ||
3739 | switch (norm) { | 3740 | switch (norm) { |
3740 | case VIDEO_MODE_PAL: | 3741 | case VIDEO_MODE_PAL: |
@@ -3776,13 +3777,13 @@ zoran_do_ioctl (struct inode *inode, | |||
3776 | return -EINVAL; | 3777 | return -EINVAL; |
3777 | } | 3778 | } |
3778 | 3779 | ||
3779 | down(&zr->resource_lock); | 3780 | mutex_lock(&zr->resource_lock); |
3780 | if ((res = zoran_set_norm(zr, norm))) | 3781 | if ((res = zoran_set_norm(zr, norm))) |
3781 | goto sstd_unlock_and_return; | 3782 | goto sstd_unlock_and_return; |
3782 | 3783 | ||
3783 | res = wait_grab_pending(zr); | 3784 | res = wait_grab_pending(zr); |
3784 | sstd_unlock_and_return: | 3785 | sstd_unlock_and_return: |
3785 | up(&zr->resource_lock); | 3786 | mutex_unlock(&zr->resource_lock); |
3786 | return res; | 3787 | return res; |
3787 | } | 3788 | } |
3788 | break; | 3789 | break; |
@@ -3809,9 +3810,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3809 | inp->std = V4L2_STD_ALL; | 3810 | inp->std = V4L2_STD_ALL; |
3810 | 3811 | ||
3811 | /* Get status of video decoder */ | 3812 | /* Get status of video decoder */ |
3812 | down(&zr->resource_lock); | 3813 | mutex_lock(&zr->resource_lock); |
3813 | decoder_command(zr, DECODER_GET_STATUS, &status); | 3814 | decoder_command(zr, DECODER_GET_STATUS, &status); |
3814 | up(&zr->resource_lock); | 3815 | mutex_unlock(&zr->resource_lock); |
3815 | 3816 | ||
3816 | if (!(status & DECODER_STATUS_GOOD)) { | 3817 | if (!(status & DECODER_STATUS_GOOD)) { |
3817 | inp->status |= V4L2_IN_ST_NO_POWER; | 3818 | inp->status |= V4L2_IN_ST_NO_POWER; |
@@ -3830,9 +3831,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3830 | 3831 | ||
3831 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr)); | 3832 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr)); |
3832 | 3833 | ||
3833 | down(&zr->resource_lock); | 3834 | mutex_lock(&zr->resource_lock); |
3834 | *input = zr->input; | 3835 | *input = zr->input; |
3835 | up(&zr->resource_lock); | 3836 | mutex_unlock(&zr->resource_lock); |
3836 | 3837 | ||
3837 | return 0; | 3838 | return 0; |
3838 | } | 3839 | } |
@@ -3845,14 +3846,14 @@ zoran_do_ioctl (struct inode *inode, | |||
3845 | dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n", | 3846 | dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n", |
3846 | ZR_DEVNAME(zr), *input); | 3847 | ZR_DEVNAME(zr), *input); |
3847 | 3848 | ||
3848 | down(&zr->resource_lock); | 3849 | mutex_lock(&zr->resource_lock); |
3849 | if ((res = zoran_set_input(zr, *input))) | 3850 | if ((res = zoran_set_input(zr, *input))) |
3850 | goto sinput_unlock_and_return; | 3851 | goto sinput_unlock_and_return; |
3851 | 3852 | ||
3852 | /* Make sure the changes come into effect */ | 3853 | /* Make sure the changes come into effect */ |
3853 | res = wait_grab_pending(zr); | 3854 | res = wait_grab_pending(zr); |
3854 | sinput_unlock_and_return: | 3855 | sinput_unlock_and_return: |
3855 | up(&zr->resource_lock); | 3856 | mutex_unlock(&zr->resource_lock); |
3856 | return res; | 3857 | return res; |
3857 | } | 3858 | } |
3858 | break; | 3859 | break; |
@@ -3914,7 +3915,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3914 | memset(cropcap, 0, sizeof(*cropcap)); | 3915 | memset(cropcap, 0, sizeof(*cropcap)); |
3915 | cropcap->type = type; | 3916 | cropcap->type = type; |
3916 | 3917 | ||
3917 | down(&zr->resource_lock); | 3918 | mutex_lock(&zr->resource_lock); |
3918 | 3919 | ||
3919 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 3920 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && |
3920 | (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 3921 | (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
@@ -3934,7 +3935,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3934 | cropcap->defrect.width = BUZ_MIN_WIDTH; | 3935 | cropcap->defrect.width = BUZ_MIN_WIDTH; |
3935 | cropcap->defrect.height = BUZ_MIN_HEIGHT; | 3936 | cropcap->defrect.height = BUZ_MIN_HEIGHT; |
3936 | cropcap_unlock_and_return: | 3937 | cropcap_unlock_and_return: |
3937 | up(&zr->resource_lock); | 3938 | mutex_unlock(&zr->resource_lock); |
3938 | return res; | 3939 | return res; |
3939 | } | 3940 | } |
3940 | break; | 3941 | break; |
@@ -3950,7 +3951,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3950 | memset(crop, 0, sizeof(*crop)); | 3951 | memset(crop, 0, sizeof(*crop)); |
3951 | crop->type = type; | 3952 | crop->type = type; |
3952 | 3953 | ||
3953 | down(&zr->resource_lock); | 3954 | mutex_lock(&zr->resource_lock); |
3954 | 3955 | ||
3955 | if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 3956 | if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && |
3956 | (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 3957 | (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
@@ -3969,7 +3970,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3969 | crop->c.height = fh->jpg_settings.img_height; | 3970 | crop->c.height = fh->jpg_settings.img_height; |
3970 | 3971 | ||
3971 | gcrop_unlock_and_return: | 3972 | gcrop_unlock_and_return: |
3972 | up(&zr->resource_lock); | 3973 | mutex_unlock(&zr->resource_lock); |
3973 | 3974 | ||
3974 | return res; | 3975 | return res; |
3975 | } | 3976 | } |
@@ -3988,7 +3989,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3988 | ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top, | 3989 | ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top, |
3989 | crop->c.width, crop->c.height); | 3990 | crop->c.width, crop->c.height); |
3990 | 3991 | ||
3991 | down(&zr->resource_lock); | 3992 | mutex_lock(&zr->resource_lock); |
3992 | 3993 | ||
3993 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { | 3994 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { |
3994 | dprintk(1, | 3995 | dprintk(1, |
@@ -4024,7 +4025,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4024 | fh->jpg_settings = settings; | 4025 | fh->jpg_settings = settings; |
4025 | 4026 | ||
4026 | scrop_unlock_and_return: | 4027 | scrop_unlock_and_return: |
4027 | up(&zr->resource_lock); | 4028 | mutex_unlock(&zr->resource_lock); |
4028 | return res; | 4029 | return res; |
4029 | } | 4030 | } |
4030 | break; | 4031 | break; |
@@ -4038,7 +4039,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4038 | 4039 | ||
4039 | memset(params, 0, sizeof(*params)); | 4040 | memset(params, 0, sizeof(*params)); |
4040 | 4041 | ||
4041 | down(&zr->resource_lock); | 4042 | mutex_lock(&zr->resource_lock); |
4042 | 4043 | ||
4043 | params->quality = fh->jpg_settings.jpg_comp.quality; | 4044 | params->quality = fh->jpg_settings.jpg_comp.quality; |
4044 | params->APPn = fh->jpg_settings.jpg_comp.APPn; | 4045 | params->APPn = fh->jpg_settings.jpg_comp.APPn; |
@@ -4053,7 +4054,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4053 | params->jpeg_markers = | 4054 | params->jpeg_markers = |
4054 | fh->jpg_settings.jpg_comp.jpeg_markers; | 4055 | fh->jpg_settings.jpg_comp.jpeg_markers; |
4055 | 4056 | ||
4056 | up(&zr->resource_lock); | 4057 | mutex_unlock(&zr->resource_lock); |
4057 | 4058 | ||
4058 | return 0; | 4059 | return 0; |
4059 | } | 4060 | } |
@@ -4074,7 +4075,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4074 | 4075 | ||
4075 | settings.jpg_comp = *params; | 4076 | settings.jpg_comp = *params; |
4076 | 4077 | ||
4077 | down(&zr->resource_lock); | 4078 | mutex_lock(&zr->resource_lock); |
4078 | 4079 | ||
4079 | if (fh->v4l_buffers.active != ZORAN_FREE || | 4080 | if (fh->v4l_buffers.active != ZORAN_FREE || |
4080 | fh->jpg_buffers.active != ZORAN_FREE) { | 4081 | fh->jpg_buffers.active != ZORAN_FREE) { |
@@ -4093,7 +4094,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4093 | zoran_v4l2_calc_bufsize(&fh->jpg_settings); | 4094 | zoran_v4l2_calc_bufsize(&fh->jpg_settings); |
4094 | fh->jpg_settings.jpg_comp = *params = settings.jpg_comp; | 4095 | fh->jpg_settings.jpg_comp = *params = settings.jpg_comp; |
4095 | sjpegc_unlock_and_return: | 4096 | sjpegc_unlock_and_return: |
4096 | up(&zr->resource_lock); | 4097 | mutex_unlock(&zr->resource_lock); |
4097 | 4098 | ||
4098 | return 0; | 4099 | return 0; |
4099 | } | 4100 | } |
@@ -4127,7 +4128,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4127 | 4128 | ||
4128 | switch (fmt->type) { | 4129 | switch (fmt->type) { |
4129 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 4130 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
4130 | down(&zr->resource_lock); | 4131 | mutex_lock(&zr->resource_lock); |
4131 | 4132 | ||
4132 | if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH) | 4133 | if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH) |
4133 | fmt->fmt.win.w.width = BUZ_MAX_WIDTH; | 4134 | fmt->fmt.win.w.width = BUZ_MAX_WIDTH; |
@@ -4138,7 +4139,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4138 | if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT) | 4139 | if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT) |
4139 | fmt->fmt.win.w.height = BUZ_MIN_HEIGHT; | 4140 | fmt->fmt.win.w.height = BUZ_MIN_HEIGHT; |
4140 | 4141 | ||
4141 | up(&zr->resource_lock); | 4142 | mutex_unlock(&zr->resource_lock); |
4142 | break; | 4143 | break; |
4143 | 4144 | ||
4144 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 4145 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
@@ -4146,7 +4147,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4146 | if (fmt->fmt.pix.bytesperline > 0) | 4147 | if (fmt->fmt.pix.bytesperline > 0) |
4147 | return -EINVAL; | 4148 | return -EINVAL; |
4148 | 4149 | ||
4149 | down(&zr->resource_lock); | 4150 | mutex_lock(&zr->resource_lock); |
4150 | 4151 | ||
4151 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { | 4152 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { |
4152 | settings = fh->jpg_settings; | 4153 | settings = fh->jpg_settings; |
@@ -4229,7 +4230,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4229 | goto tryfmt_unlock_and_return; | 4230 | goto tryfmt_unlock_and_return; |
4230 | } | 4231 | } |
4231 | tryfmt_unlock_and_return: | 4232 | tryfmt_unlock_and_return: |
4232 | up(&zr->resource_lock); | 4233 | mutex_unlock(&zr->resource_lock); |
4233 | 4234 | ||
4234 | return res; | 4235 | return res; |
4235 | break; | 4236 | break; |
@@ -4280,7 +4281,7 @@ zoran_poll (struct file *file, | |||
4280 | * if no buffers queued or so, return POLLNVAL | 4281 | * if no buffers queued or so, return POLLNVAL |
4281 | */ | 4282 | */ |
4282 | 4283 | ||
4283 | down(&zr->resource_lock); | 4284 | mutex_lock(&zr->resource_lock); |
4284 | 4285 | ||
4285 | switch (fh->map_mode) { | 4286 | switch (fh->map_mode) { |
4286 | case ZORAN_MAP_MODE_RAW: | 4287 | case ZORAN_MAP_MODE_RAW: |
@@ -4329,7 +4330,7 @@ zoran_poll (struct file *file, | |||
4329 | } | 4330 | } |
4330 | 4331 | ||
4331 | poll_unlock_and_return: | 4332 | poll_unlock_and_return: |
4332 | up(&zr->resource_lock); | 4333 | mutex_unlock(&zr->resource_lock); |
4333 | 4334 | ||
4334 | return res; | 4335 | return res; |
4335 | } | 4336 | } |
@@ -4385,7 +4386,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4385 | if (fh->jpg_buffers.buffer[i].map) | 4386 | if (fh->jpg_buffers.buffer[i].map) |
4386 | break; | 4387 | break; |
4387 | if (i == fh->jpg_buffers.num_buffers) { | 4388 | if (i == fh->jpg_buffers.num_buffers) { |
4388 | down(&zr->resource_lock); | 4389 | mutex_lock(&zr->resource_lock); |
4389 | 4390 | ||
4390 | if (fh->jpg_buffers.active != ZORAN_FREE) { | 4391 | if (fh->jpg_buffers.active != ZORAN_FREE) { |
4391 | jpg_qbuf(file, -1, zr->codec_mode); | 4392 | jpg_qbuf(file, -1, zr->codec_mode); |
@@ -4398,7 +4399,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4398 | fh->jpg_buffers.allocated = 0; | 4399 | fh->jpg_buffers.allocated = 0; |
4399 | fh->jpg_buffers.ready_to_be_freed = 1; | 4400 | fh->jpg_buffers.ready_to_be_freed = 1; |
4400 | 4401 | ||
4401 | up(&zr->resource_lock); | 4402 | mutex_unlock(&zr->resource_lock); |
4402 | } | 4403 | } |
4403 | 4404 | ||
4404 | break; | 4405 | break; |
@@ -4421,7 +4422,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4421 | if (fh->v4l_buffers.buffer[i].map) | 4422 | if (fh->v4l_buffers.buffer[i].map) |
4422 | break; | 4423 | break; |
4423 | if (i == fh->v4l_buffers.num_buffers) { | 4424 | if (i == fh->v4l_buffers.num_buffers) { |
4424 | down(&zr->resource_lock); | 4425 | mutex_lock(&zr->resource_lock); |
4425 | 4426 | ||
4426 | if (fh->v4l_buffers.active != ZORAN_FREE) { | 4427 | if (fh->v4l_buffers.active != ZORAN_FREE) { |
4427 | zr36057_set_memgrab(zr, 0); | 4428 | zr36057_set_memgrab(zr, 0); |
@@ -4434,7 +4435,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4434 | fh->v4l_buffers.allocated = 0; | 4435 | fh->v4l_buffers.allocated = 0; |
4435 | fh->v4l_buffers.ready_to_be_freed = 1; | 4436 | fh->v4l_buffers.ready_to_be_freed = 1; |
4436 | 4437 | ||
4437 | up(&zr->resource_lock); | 4438 | mutex_unlock(&zr->resource_lock); |
4438 | } | 4439 | } |
4439 | 4440 | ||
4440 | break; | 4441 | break; |
@@ -4489,7 +4490,7 @@ zoran_mmap (struct file *file, | |||
4489 | case ZORAN_MAP_MODE_JPG_PLAY: | 4490 | case ZORAN_MAP_MODE_JPG_PLAY: |
4490 | 4491 | ||
4491 | /* lock */ | 4492 | /* lock */ |
4492 | down(&zr->resource_lock); | 4493 | mutex_lock(&zr->resource_lock); |
4493 | 4494 | ||
4494 | /* Map the MJPEG buffers */ | 4495 | /* Map the MJPEG buffers */ |
4495 | if (!fh->jpg_buffers.allocated) { | 4496 | if (!fh->jpg_buffers.allocated) { |
@@ -4579,13 +4580,13 @@ zoran_mmap (struct file *file, | |||
4579 | 4580 | ||
4580 | } | 4581 | } |
4581 | jpg_mmap_unlock_and_return: | 4582 | jpg_mmap_unlock_and_return: |
4582 | up(&zr->resource_lock); | 4583 | mutex_unlock(&zr->resource_lock); |
4583 | 4584 | ||
4584 | break; | 4585 | break; |
4585 | 4586 | ||
4586 | case ZORAN_MAP_MODE_RAW: | 4587 | case ZORAN_MAP_MODE_RAW: |
4587 | 4588 | ||
4588 | down(&zr->resource_lock); | 4589 | mutex_lock(&zr->resource_lock); |
4589 | 4590 | ||
4590 | /* Map the V4L buffers */ | 4591 | /* Map the V4L buffers */ |
4591 | if (!fh->v4l_buffers.allocated) { | 4592 | if (!fh->v4l_buffers.allocated) { |
@@ -4657,7 +4658,7 @@ zoran_mmap (struct file *file, | |||
4657 | break; | 4658 | break; |
4658 | } | 4659 | } |
4659 | v4l_mmap_unlock_and_return: | 4660 | v4l_mmap_unlock_and_return: |
4660 | up(&zr->resource_lock); | 4661 | mutex_unlock(&zr->resource_lock); |
4661 | 4662 | ||
4662 | break; | 4663 | break; |
4663 | 4664 | ||
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 7d213707008a..2671da20a496 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -9,13 +9,54 @@ | |||
9 | * Written by: Michael Chan (mchan@broadcom.com) | 9 | * Written by: Michael Chan (mchan@broadcom.com) |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/config.h> | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/timer.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/ioport.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/vmalloc.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/netdevice.h> | ||
27 | #include <linux/etherdevice.h> | ||
28 | #include <linux/skbuff.h> | ||
29 | #include <linux/dma-mapping.h> | ||
30 | #include <asm/bitops.h> | ||
31 | #include <asm/io.h> | ||
32 | #include <asm/irq.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <asm/byteorder.h> | ||
35 | #include <linux/time.h> | ||
36 | #include <linux/ethtool.h> | ||
37 | #include <linux/mii.h> | ||
38 | #ifdef NETIF_F_HW_VLAN_TX | ||
39 | #include <linux/if_vlan.h> | ||
40 | #define BCM_VLAN 1 | ||
41 | #endif | ||
42 | #ifdef NETIF_F_TSO | ||
43 | #include <net/ip.h> | ||
44 | #include <net/tcp.h> | ||
45 | #include <net/checksum.h> | ||
46 | #define BCM_TSO 1 | ||
47 | #endif | ||
48 | #include <linux/workqueue.h> | ||
49 | #include <linux/crc32.h> | ||
50 | #include <linux/prefetch.h> | ||
51 | #include <linux/cache.h> | ||
52 | |||
12 | #include "bnx2.h" | 53 | #include "bnx2.h" |
13 | #include "bnx2_fw.h" | 54 | #include "bnx2_fw.h" |
14 | 55 | ||
15 | #define DRV_MODULE_NAME "bnx2" | 56 | #define DRV_MODULE_NAME "bnx2" |
16 | #define PFX DRV_MODULE_NAME ": " | 57 | #define PFX DRV_MODULE_NAME ": " |
17 | #define DRV_MODULE_VERSION "1.4.38" | 58 | #define DRV_MODULE_VERSION "1.4.39" |
18 | #define DRV_MODULE_RELDATE "February 10, 2006" | 59 | #define DRV_MODULE_RELDATE "March 22, 2006" |
19 | 60 | ||
20 | #define RUN_AT(x) (jiffies + (x)) | 61 | #define RUN_AT(x) (jiffies + (x)) |
21 | 62 | ||
@@ -313,8 +354,6 @@ bnx2_disable_int(struct bnx2 *bp) | |||
313 | static void | 354 | static void |
314 | bnx2_enable_int(struct bnx2 *bp) | 355 | bnx2_enable_int(struct bnx2 *bp) |
315 | { | 356 | { |
316 | u32 val; | ||
317 | |||
318 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, | 357 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, |
319 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | | 358 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | |
320 | BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx); | 359 | BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx); |
@@ -322,8 +361,7 @@ bnx2_enable_int(struct bnx2 *bp) | |||
322 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, | 361 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, |
323 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx); | 362 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx); |
324 | 363 | ||
325 | val = REG_RD(bp, BNX2_HC_COMMAND); | 364 | REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW); |
326 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW); | ||
327 | } | 365 | } |
328 | 366 | ||
329 | static void | 367 | static void |
@@ -362,15 +400,11 @@ bnx2_free_mem(struct bnx2 *bp) | |||
362 | { | 400 | { |
363 | int i; | 401 | int i; |
364 | 402 | ||
365 | if (bp->stats_blk) { | ||
366 | pci_free_consistent(bp->pdev, sizeof(struct statistics_block), | ||
367 | bp->stats_blk, bp->stats_blk_mapping); | ||
368 | bp->stats_blk = NULL; | ||
369 | } | ||
370 | if (bp->status_blk) { | 403 | if (bp->status_blk) { |
371 | pci_free_consistent(bp->pdev, sizeof(struct status_block), | 404 | pci_free_consistent(bp->pdev, bp->status_stats_size, |
372 | bp->status_blk, bp->status_blk_mapping); | 405 | bp->status_blk, bp->status_blk_mapping); |
373 | bp->status_blk = NULL; | 406 | bp->status_blk = NULL; |
407 | bp->stats_blk = NULL; | ||
374 | } | 408 | } |
375 | if (bp->tx_desc_ring) { | 409 | if (bp->tx_desc_ring) { |
376 | pci_free_consistent(bp->pdev, | 410 | pci_free_consistent(bp->pdev, |
@@ -395,14 +429,13 @@ bnx2_free_mem(struct bnx2 *bp) | |||
395 | static int | 429 | static int |
396 | bnx2_alloc_mem(struct bnx2 *bp) | 430 | bnx2_alloc_mem(struct bnx2 *bp) |
397 | { | 431 | { |
398 | int i; | 432 | int i, status_blk_size; |
399 | 433 | ||
400 | bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT, | 434 | bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT, |
401 | GFP_KERNEL); | 435 | GFP_KERNEL); |
402 | if (bp->tx_buf_ring == NULL) | 436 | if (bp->tx_buf_ring == NULL) |
403 | return -ENOMEM; | 437 | return -ENOMEM; |
404 | 438 | ||
405 | memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT); | ||
406 | bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, | 439 | bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, |
407 | sizeof(struct tx_bd) * | 440 | sizeof(struct tx_bd) * |
408 | TX_DESC_CNT, | 441 | TX_DESC_CNT, |
@@ -428,21 +461,22 @@ bnx2_alloc_mem(struct bnx2 *bp) | |||
428 | 461 | ||
429 | } | 462 | } |
430 | 463 | ||
431 | bp->status_blk = pci_alloc_consistent(bp->pdev, | 464 | /* Combine status and statistics blocks into one allocation. */ |
432 | sizeof(struct status_block), | 465 | status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block)); |
466 | bp->status_stats_size = status_blk_size + | ||
467 | sizeof(struct statistics_block); | ||
468 | |||
469 | bp->status_blk = pci_alloc_consistent(bp->pdev, bp->status_stats_size, | ||
433 | &bp->status_blk_mapping); | 470 | &bp->status_blk_mapping); |
434 | if (bp->status_blk == NULL) | 471 | if (bp->status_blk == NULL) |
435 | goto alloc_mem_err; | 472 | goto alloc_mem_err; |
436 | 473 | ||
437 | memset(bp->status_blk, 0, sizeof(struct status_block)); | 474 | memset(bp->status_blk, 0, bp->status_stats_size); |
438 | 475 | ||
439 | bp->stats_blk = pci_alloc_consistent(bp->pdev, | 476 | bp->stats_blk = (void *) ((unsigned long) bp->status_blk + |
440 | sizeof(struct statistics_block), | 477 | status_blk_size); |
441 | &bp->stats_blk_mapping); | ||
442 | if (bp->stats_blk == NULL) | ||
443 | goto alloc_mem_err; | ||
444 | 478 | ||
445 | memset(bp->stats_blk, 0, sizeof(struct statistics_block)); | 479 | bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size; |
446 | 480 | ||
447 | return 0; | 481 | return 0; |
448 | 482 | ||
@@ -1926,6 +1960,13 @@ bnx2_poll(struct net_device *dev, int *budget) | |||
1926 | spin_lock(&bp->phy_lock); | 1960 | spin_lock(&bp->phy_lock); |
1927 | bnx2_phy_int(bp); | 1961 | bnx2_phy_int(bp); |
1928 | spin_unlock(&bp->phy_lock); | 1962 | spin_unlock(&bp->phy_lock); |
1963 | |||
1964 | /* This is needed to take care of transient status | ||
1965 | * during link changes. | ||
1966 | */ | ||
1967 | REG_WR(bp, BNX2_HC_COMMAND, | ||
1968 | bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); | ||
1969 | REG_RD(bp, BNX2_HC_COMMAND); | ||
1929 | } | 1970 | } |
1930 | 1971 | ||
1931 | if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons) | 1972 | if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons) |
@@ -3307,6 +3348,8 @@ bnx2_init_chip(struct bnx2 *bp) | |||
3307 | 3348 | ||
3308 | udelay(20); | 3349 | udelay(20); |
3309 | 3350 | ||
3351 | bp->hc_cmd = REG_RD(bp, BNX2_HC_COMMAND); | ||
3352 | |||
3310 | return rc; | 3353 | return rc; |
3311 | } | 3354 | } |
3312 | 3355 | ||
@@ -3746,7 +3789,6 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
3746 | struct sk_buff *skb, *rx_skb; | 3789 | struct sk_buff *skb, *rx_skb; |
3747 | unsigned char *packet; | 3790 | unsigned char *packet; |
3748 | u16 rx_start_idx, rx_idx; | 3791 | u16 rx_start_idx, rx_idx; |
3749 | u32 val; | ||
3750 | dma_addr_t map; | 3792 | dma_addr_t map; |
3751 | struct tx_bd *txbd; | 3793 | struct tx_bd *txbd; |
3752 | struct sw_bd *rx_buf; | 3794 | struct sw_bd *rx_buf; |
@@ -3777,8 +3819,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
3777 | map = pci_map_single(bp->pdev, skb->data, pkt_size, | 3819 | map = pci_map_single(bp->pdev, skb->data, pkt_size, |
3778 | PCI_DMA_TODEVICE); | 3820 | PCI_DMA_TODEVICE); |
3779 | 3821 | ||
3780 | val = REG_RD(bp, BNX2_HC_COMMAND); | 3822 | REG_WR(bp, BNX2_HC_COMMAND, |
3781 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT); | 3823 | bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); |
3824 | |||
3782 | REG_RD(bp, BNX2_HC_COMMAND); | 3825 | REG_RD(bp, BNX2_HC_COMMAND); |
3783 | 3826 | ||
3784 | udelay(5); | 3827 | udelay(5); |
@@ -3802,8 +3845,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
3802 | 3845 | ||
3803 | udelay(100); | 3846 | udelay(100); |
3804 | 3847 | ||
3805 | val = REG_RD(bp, BNX2_HC_COMMAND); | 3848 | REG_WR(bp, BNX2_HC_COMMAND, |
3806 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT); | 3849 | bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); |
3850 | |||
3807 | REG_RD(bp, BNX2_HC_COMMAND); | 3851 | REG_RD(bp, BNX2_HC_COMMAND); |
3808 | 3852 | ||
3809 | udelay(5); | 3853 | udelay(5); |
@@ -3939,7 +3983,6 @@ static int | |||
3939 | bnx2_test_intr(struct bnx2 *bp) | 3983 | bnx2_test_intr(struct bnx2 *bp) |
3940 | { | 3984 | { |
3941 | int i; | 3985 | int i; |
3942 | u32 val; | ||
3943 | u16 status_idx; | 3986 | u16 status_idx; |
3944 | 3987 | ||
3945 | if (!netif_running(bp->dev)) | 3988 | if (!netif_running(bp->dev)) |
@@ -3948,8 +3991,7 @@ bnx2_test_intr(struct bnx2 *bp) | |||
3948 | status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff; | 3991 | status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff; |
3949 | 3992 | ||
3950 | /* This register is not touched during run-time. */ | 3993 | /* This register is not touched during run-time. */ |
3951 | val = REG_RD(bp, BNX2_HC_COMMAND); | 3994 | REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW); |
3952 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW); | ||
3953 | REG_RD(bp, BNX2_HC_COMMAND); | 3995 | REG_RD(bp, BNX2_HC_COMMAND); |
3954 | 3996 | ||
3955 | for (i = 0; i < 10; i++) { | 3997 | for (i = 0; i < 10; i++) { |
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index fd4b7f2eb477..b87925f6a228 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h | |||
@@ -13,46 +13,6 @@ | |||
13 | #ifndef BNX2_H | 13 | #ifndef BNX2_H |
14 | #define BNX2_H | 14 | #define BNX2_H |
15 | 15 | ||
16 | #include <linux/config.h> | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/moduleparam.h> | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/timer.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/vmalloc.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/pci.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/netdevice.h> | ||
31 | #include <linux/etherdevice.h> | ||
32 | #include <linux/skbuff.h> | ||
33 | #include <linux/dma-mapping.h> | ||
34 | #include <asm/bitops.h> | ||
35 | #include <asm/io.h> | ||
36 | #include <asm/irq.h> | ||
37 | #include <linux/delay.h> | ||
38 | #include <asm/byteorder.h> | ||
39 | #include <linux/time.h> | ||
40 | #include <linux/ethtool.h> | ||
41 | #include <linux/mii.h> | ||
42 | #ifdef NETIF_F_HW_VLAN_TX | ||
43 | #include <linux/if_vlan.h> | ||
44 | #define BCM_VLAN 1 | ||
45 | #endif | ||
46 | #ifdef NETIF_F_TSO | ||
47 | #include <net/ip.h> | ||
48 | #include <net/tcp.h> | ||
49 | #include <net/checksum.h> | ||
50 | #define BCM_TSO 1 | ||
51 | #endif | ||
52 | #include <linux/workqueue.h> | ||
53 | #include <linux/crc32.h> | ||
54 | #include <linux/prefetch.h> | ||
55 | |||
56 | /* Hardware data structures and register definitions automatically | 16 | /* Hardware data structures and register definitions automatically |
57 | * generated from RTL code. Do not modify. | 17 | * generated from RTL code. Do not modify. |
58 | */ | 18 | */ |
@@ -3917,15 +3877,17 @@ struct bnx2 { | |||
3917 | #define USING_MSI_FLAG 0x20 | 3877 | #define USING_MSI_FLAG 0x20 |
3918 | #define ASF_ENABLE_FLAG 0x40 | 3878 | #define ASF_ENABLE_FLAG 0x40 |
3919 | 3879 | ||
3920 | struct tx_bd *tx_desc_ring; | 3880 | /* Put tx producer and consumer fields in separate cache lines. */ |
3921 | struct sw_bd *tx_buf_ring; | ||
3922 | u32 tx_prod_bseq; | ||
3923 | u16 tx_prod; | ||
3924 | u16 tx_cons; | ||
3925 | int tx_ring_size; | ||
3926 | 3881 | ||
3927 | u16 hw_tx_cons; | 3882 | u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES))); |
3928 | u16 hw_rx_cons; | 3883 | u16 tx_prod; |
3884 | |||
3885 | struct tx_bd *tx_desc_ring; | ||
3886 | struct sw_bd *tx_buf_ring; | ||
3887 | int tx_ring_size; | ||
3888 | |||
3889 | u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES))); | ||
3890 | u16 hw_tx_cons; | ||
3929 | 3891 | ||
3930 | #ifdef BCM_VLAN | 3892 | #ifdef BCM_VLAN |
3931 | struct vlan_group *vlgrp; | 3893 | struct vlan_group *vlgrp; |
@@ -3939,6 +3901,7 @@ struct bnx2 { | |||
3939 | u32 rx_prod_bseq; | 3901 | u32 rx_prod_bseq; |
3940 | u16 rx_prod; | 3902 | u16 rx_prod; |
3941 | u16 rx_cons; | 3903 | u16 rx_cons; |
3904 | u16 hw_rx_cons; | ||
3942 | 3905 | ||
3943 | u32 rx_csum; | 3906 | u32 rx_csum; |
3944 | 3907 | ||
@@ -4038,6 +4001,7 @@ struct bnx2 { | |||
4038 | struct statistics_block *stats_blk; | 4001 | struct statistics_block *stats_blk; |
4039 | dma_addr_t stats_blk_mapping; | 4002 | dma_addr_t stats_blk_mapping; |
4040 | 4003 | ||
4004 | u32 hc_cmd; | ||
4041 | u32 rx_mode; | 4005 | u32 rx_mode; |
4042 | 4006 | ||
4043 | u16 req_line_speed; | 4007 | u16 req_line_speed; |
@@ -4082,6 +4046,8 @@ struct bnx2 { | |||
4082 | 4046 | ||
4083 | struct flash_spec *flash_info; | 4047 | struct flash_spec *flash_info; |
4084 | u32 flash_size; | 4048 | u32 flash_size; |
4049 | |||
4050 | int status_stats_size; | ||
4085 | }; | 4051 | }; |
4086 | 4052 | ||
4087 | static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset); | 4053 | static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset); |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 88829eb9568e..b5473325bff4 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -69,8 +69,8 @@ | |||
69 | 69 | ||
70 | #define DRV_MODULE_NAME "tg3" | 70 | #define DRV_MODULE_NAME "tg3" |
71 | #define PFX DRV_MODULE_NAME ": " | 71 | #define PFX DRV_MODULE_NAME ": " |
72 | #define DRV_MODULE_VERSION "3.53" | 72 | #define DRV_MODULE_VERSION "3.54" |
73 | #define DRV_MODULE_RELDATE "Mar 22, 2006" | 73 | #define DRV_MODULE_RELDATE "Mar 23, 2006" |
74 | 74 | ||
75 | #define TG3_DEF_MAC_MODE 0 | 75 | #define TG3_DEF_MAC_MODE 0 |
76 | #define TG3_DEF_RX_MODE 0 | 76 | #define TG3_DEF_RX_MODE 0 |
@@ -225,6 +225,10 @@ static struct pci_device_id tg3_pci_tbl[] = { | |||
225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M, | 226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M, |
227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755, | ||
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M, | ||
231 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, | 232 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, |
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 233 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, | 234 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, |
@@ -4557,6 +4561,7 @@ static int tg3_chip_reset(struct tg3 *tp) | |||
4557 | } | 4561 | } |
4558 | 4562 | ||
4559 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | 4563 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || |
4564 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | ||
4560 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 4565 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
4561 | tw32(GRC_FASTBOOT_PC, 0); | 4566 | tw32(GRC_FASTBOOT_PC, 0); |
4562 | 4567 | ||
@@ -6152,6 +6157,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6152 | gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | | 6157 | gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | |
6153 | GRC_LCLCTRL_GPIO_OUTPUT3; | 6158 | GRC_LCLCTRL_GPIO_OUTPUT3; |
6154 | 6159 | ||
6160 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6161 | gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL; | ||
6162 | |||
6155 | tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; | 6163 | tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; |
6156 | 6164 | ||
6157 | /* GPIO1 must be driven high for eeprom write protect */ | 6165 | /* GPIO1 must be driven high for eeprom write protect */ |
@@ -6191,7 +6199,8 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6191 | } | 6199 | } |
6192 | 6200 | ||
6193 | /* Enable host coalescing bug fix */ | 6201 | /* Enable host coalescing bug fix */ |
6194 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 6202 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) || |
6203 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)) | ||
6195 | val |= (1 << 29); | 6204 | val |= (1 << 29); |
6196 | 6205 | ||
6197 | tw32_f(WDMAC_MODE, val); | 6206 | tw32_f(WDMAC_MODE, val); |
@@ -6249,6 +6258,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6249 | udelay(100); | 6258 | udelay(100); |
6250 | 6259 | ||
6251 | tp->rx_mode = RX_MODE_ENABLE; | 6260 | tp->rx_mode = RX_MODE_ENABLE; |
6261 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6262 | tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE; | ||
6263 | |||
6252 | tw32_f(MAC_RX_MODE, tp->rx_mode); | 6264 | tw32_f(MAC_RX_MODE, tp->rx_mode); |
6253 | udelay(10); | 6265 | udelay(10); |
6254 | 6266 | ||
@@ -7907,7 +7919,8 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data) | |||
7907 | return 0; | 7919 | return 0; |
7908 | } | 7920 | } |
7909 | 7921 | ||
7910 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 7922 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
7923 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
7911 | ethtool_op_set_tx_hw_csum(dev, data); | 7924 | ethtool_op_set_tx_hw_csum(dev, data); |
7912 | else | 7925 | else |
7913 | ethtool_op_set_tx_csum(dev, data); | 7926 | ethtool_op_set_tx_csum(dev, data); |
@@ -8332,7 +8345,8 @@ static int tg3_test_memory(struct tg3 *tp) | |||
8332 | int i; | 8345 | int i; |
8333 | 8346 | ||
8334 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { | 8347 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { |
8335 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 8348 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
8349 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
8336 | mem_tbl = mem_tbl_5755; | 8350 | mem_tbl = mem_tbl_5755; |
8337 | else | 8351 | else |
8338 | mem_tbl = mem_tbl_5705; | 8352 | mem_tbl = mem_tbl_5705; |
@@ -8924,6 +8938,47 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp) | |||
8924 | } | 8938 | } |
8925 | } | 8939 | } |
8926 | 8940 | ||
8941 | static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp) | ||
8942 | { | ||
8943 | u32 nvcfg1; | ||
8944 | |||
8945 | nvcfg1 = tr32(NVRAM_CFG1); | ||
8946 | |||
8947 | /* NVRAM protection for TPM */ | ||
8948 | if (nvcfg1 & (1 << 27)) | ||
8949 | tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM; | ||
8950 | |||
8951 | switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { | ||
8952 | case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ: | ||
8953 | case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ: | ||
8954 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8955 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8956 | tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; | ||
8957 | |||
8958 | nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS; | ||
8959 | tw32(NVRAM_CFG1, nvcfg1); | ||
8960 | break; | ||
8961 | case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED: | ||
8962 | case FLASH_5755VENDOR_ATMEL_FLASH_1: | ||
8963 | case FLASH_5755VENDOR_ATMEL_FLASH_2: | ||
8964 | case FLASH_5755VENDOR_ATMEL_FLASH_3: | ||
8965 | case FLASH_5755VENDOR_ATMEL_FLASH_4: | ||
8966 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8967 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8968 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8969 | tp->nvram_pagesize = 264; | ||
8970 | break; | ||
8971 | case FLASH_5752VENDOR_ST_M45PE10: | ||
8972 | case FLASH_5752VENDOR_ST_M45PE20: | ||
8973 | case FLASH_5752VENDOR_ST_M45PE40: | ||
8974 | tp->nvram_jedecnum = JEDEC_ST; | ||
8975 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8976 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8977 | tp->nvram_pagesize = 256; | ||
8978 | break; | ||
8979 | } | ||
8980 | } | ||
8981 | |||
8927 | static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp) | 8982 | static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp) |
8928 | { | 8983 | { |
8929 | u32 nvcfg1; | 8984 | u32 nvcfg1; |
@@ -8997,6 +9052,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) | |||
8997 | 9052 | ||
8998 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 9053 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
8999 | tg3_get_5752_nvram_info(tp); | 9054 | tg3_get_5752_nvram_info(tp); |
9055 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
9056 | tg3_get_5755_nvram_info(tp); | ||
9000 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 9057 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
9001 | tg3_get_5787_nvram_info(tp); | 9058 | tg3_get_5787_nvram_info(tp); |
9002 | else | 9059 | else |
@@ -9310,6 +9367,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
9310 | nvram_cmd |= NVRAM_CMD_LAST; | 9367 | nvram_cmd |= NVRAM_CMD_LAST; |
9311 | 9368 | ||
9312 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && | 9369 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && |
9370 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | ||
9313 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) && | 9371 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) && |
9314 | (tp->nvram_jedecnum == JEDEC_ST) && | 9372 | (tp->nvram_jedecnum == JEDEC_ST) && |
9315 | (nvram_cmd & NVRAM_CMD_FIRST)) { | 9373 | (nvram_cmd & NVRAM_CMD_FIRST)) { |
@@ -10044,6 +10102,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10044 | 10102 | ||
10045 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || | 10103 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || |
10046 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | 10104 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || |
10105 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | ||
10047 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || | 10106 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || |
10048 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) | 10107 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) |
10049 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; | 10108 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; |
@@ -10053,7 +10112,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10053 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; | 10112 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; |
10054 | 10113 | ||
10055 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { | 10114 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { |
10056 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { | 10115 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10116 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { | ||
10057 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; | 10117 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; |
10058 | tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; | 10118 | tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; |
10059 | } else | 10119 | } else |
@@ -10063,6 +10123,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10063 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && | 10123 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && |
10064 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && | 10124 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && |
10065 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && | 10125 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && |
10126 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755 && | ||
10066 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) | 10127 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) |
10067 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; | 10128 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; |
10068 | 10129 | ||
@@ -10219,6 +10280,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10219 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 10280 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
10220 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; | 10281 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; |
10221 | 10282 | ||
10283 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
10284 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL; | ||
10285 | |||
10222 | /* Force the chip into D0. */ | 10286 | /* Force the chip into D0. */ |
10223 | err = tg3_set_power_state(tp, PCI_D0); | 10287 | err = tg3_set_power_state(tp, PCI_D0); |
10224 | if (err) { | 10288 | if (err) { |
@@ -10274,6 +10338,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10274 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; | 10338 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; |
10275 | 10339 | ||
10276 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && | 10340 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && |
10341 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | ||
10277 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) | 10342 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) |
10278 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | 10343 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; |
10279 | 10344 | ||
@@ -10413,7 +10478,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10413 | /* All chips before 5787 can get confused if TX buffers | 10478 | /* All chips before 5787 can get confused if TX buffers |
10414 | * straddle the 4GB address boundary in some cases. | 10479 | * straddle the 4GB address boundary in some cases. |
10415 | */ | 10480 | */ |
10416 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 10481 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10482 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
10417 | tp->dev->hard_start_xmit = tg3_start_xmit; | 10483 | tp->dev->hard_start_xmit = tg3_start_xmit; |
10418 | else | 10484 | else |
10419 | tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug; | 10485 | tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug; |
@@ -11002,6 +11068,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp) | |||
11002 | case PHY_ID_BCM5752: return "5752"; | 11068 | case PHY_ID_BCM5752: return "5752"; |
11003 | case PHY_ID_BCM5714: return "5714"; | 11069 | case PHY_ID_BCM5714: return "5714"; |
11004 | case PHY_ID_BCM5780: return "5780"; | 11070 | case PHY_ID_BCM5780: return "5780"; |
11071 | case PHY_ID_BCM5755: return "5755"; | ||
11005 | case PHY_ID_BCM5787: return "5787"; | 11072 | case PHY_ID_BCM5787: return "5787"; |
11006 | case PHY_ID_BCM8002: return "8002/serdes"; | 11073 | case PHY_ID_BCM8002: return "8002/serdes"; |
11007 | case 0: return "serdes"; | 11074 | case 0: return "serdes"; |
@@ -11350,7 +11417,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
11350 | * checksumming. | 11417 | * checksumming. |
11351 | */ | 11418 | */ |
11352 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { | 11419 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { |
11353 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 11420 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
11421 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
11354 | dev->features |= NETIF_F_HW_CSUM; | 11422 | dev->features |= NETIF_F_HW_CSUM; |
11355 | else | 11423 | else |
11356 | dev->features |= NETIF_F_IP_CSUM; | 11424 | dev->features |= NETIF_F_IP_CSUM; |
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index baa34c4721db..c43cc3264202 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -138,6 +138,7 @@ | |||
138 | #define ASIC_REV_5752 0x06 | 138 | #define ASIC_REV_5752 0x06 |
139 | #define ASIC_REV_5780 0x08 | 139 | #define ASIC_REV_5780 0x08 |
140 | #define ASIC_REV_5714 0x09 | 140 | #define ASIC_REV_5714 0x09 |
141 | #define ASIC_REV_5755 0x0a | ||
141 | #define ASIC_REV_5787 0x0b | 142 | #define ASIC_REV_5787 0x0b |
142 | #define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) | 143 | #define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) |
143 | #define CHIPREV_5700_AX 0x70 | 144 | #define CHIPREV_5700_AX 0x70 |
@@ -456,6 +457,7 @@ | |||
456 | #define RX_MODE_PROMISC 0x00000100 | 457 | #define RX_MODE_PROMISC 0x00000100 |
457 | #define RX_MODE_NO_CRC_CHECK 0x00000200 | 458 | #define RX_MODE_NO_CRC_CHECK 0x00000200 |
458 | #define RX_MODE_KEEP_VLAN_TAG 0x00000400 | 459 | #define RX_MODE_KEEP_VLAN_TAG 0x00000400 |
460 | #define RX_MODE_IPV6_CSUM_ENABLE 0x01000000 | ||
459 | #define MAC_RX_STATUS 0x0000046c | 461 | #define MAC_RX_STATUS 0x0000046c |
460 | #define RX_STATUS_REMOTE_TX_XOFFED 0x00000001 | 462 | #define RX_STATUS_REMOTE_TX_XOFFED 0x00000001 |
461 | #define RX_STATUS_XOFF_RCVD 0x00000002 | 463 | #define RX_STATUS_XOFF_RCVD 0x00000002 |
@@ -1340,6 +1342,7 @@ | |||
1340 | #define GRC_LCLCTRL_CLEARINT 0x00000002 | 1342 | #define GRC_LCLCTRL_CLEARINT 0x00000002 |
1341 | #define GRC_LCLCTRL_SETINT 0x00000004 | 1343 | #define GRC_LCLCTRL_SETINT 0x00000004 |
1342 | #define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 | 1344 | #define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 |
1345 | #define GRC_LCLCTRL_GPIO_UART_SEL 0x00000010 /* 5755 only */ | ||
1343 | #define GRC_LCLCTRL_USE_SIG_DETECT 0x00000010 /* 5714/5780 only */ | 1346 | #define GRC_LCLCTRL_USE_SIG_DETECT 0x00000010 /* 5714/5780 only */ |
1344 | #define GRC_LCLCTRL_USE_EXT_SIG_DETECT 0x00000020 /* 5714/5780 only */ | 1347 | #define GRC_LCLCTRL_USE_EXT_SIG_DETECT 0x00000020 /* 5714/5780 only */ |
1345 | #define GRC_LCLCTRL_GPIO_INPUT3 0x00000020 | 1348 | #define GRC_LCLCTRL_GPIO_INPUT3 0x00000020 |
@@ -1441,6 +1444,9 @@ | |||
1441 | #define FLASH_5755VENDOR_ATMEL_FLASH_1 0x03400001 | 1444 | #define FLASH_5755VENDOR_ATMEL_FLASH_1 0x03400001 |
1442 | #define FLASH_5755VENDOR_ATMEL_FLASH_2 0x03400002 | 1445 | #define FLASH_5755VENDOR_ATMEL_FLASH_2 0x03400002 |
1443 | #define FLASH_5755VENDOR_ATMEL_FLASH_3 0x03400000 | 1446 | #define FLASH_5755VENDOR_ATMEL_FLASH_3 0x03400000 |
1447 | #define FLASH_5755VENDOR_ATMEL_FLASH_4 0x00000003 | ||
1448 | #define FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ 0x03c00003 | ||
1449 | #define FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ 0x03c00002 | ||
1444 | #define FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ 0x03000003 | 1450 | #define FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ 0x03000003 |
1445 | #define FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ 0x03000002 | 1451 | #define FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ 0x03000002 |
1446 | #define FLASH_5787VENDOR_MICRO_EEPROM_64KHZ 0x03000000 | 1452 | #define FLASH_5787VENDOR_MICRO_EEPROM_64KHZ 0x03000000 |
@@ -2259,6 +2265,7 @@ struct tg3 { | |||
2259 | #define PHY_ID_BCM5752 0x60008100 | 2265 | #define PHY_ID_BCM5752 0x60008100 |
2260 | #define PHY_ID_BCM5714 0x60008340 | 2266 | #define PHY_ID_BCM5714 0x60008340 |
2261 | #define PHY_ID_BCM5780 0x60008350 | 2267 | #define PHY_ID_BCM5780 0x60008350 |
2268 | #define PHY_ID_BCM5755 0xbc050cc0 | ||
2262 | #define PHY_ID_BCM5787 0xbc050ce0 | 2269 | #define PHY_ID_BCM5787 0xbc050ce0 |
2263 | #define PHY_ID_BCM8002 0x60010140 | 2270 | #define PHY_ID_BCM8002 0x60010140 |
2264 | #define PHY_ID_INVALID 0xffffffff | 2271 | #define PHY_ID_INVALID 0xffffffff |
@@ -2286,7 +2293,7 @@ struct tg3 { | |||
2286 | (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \ | 2293 | (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \ |
2287 | (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \ | 2294 | (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \ |
2288 | (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \ | 2295 | (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \ |
2289 | (X) == PHY_ID_BCM8002) | 2296 | (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM8002) |
2290 | 2297 | ||
2291 | struct tg3_hw_stats *hw_stats; | 2298 | struct tg3_hw_stats *hw_stats; |
2292 | dma_addr_t stats_mapping; | 2299 | dma_addr_t stats_mapping; |
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index f187fd8aeed6..4d762fc4878c 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig | |||
@@ -11,24 +11,11 @@ config PCI_MSI | |||
11 | generate an interrupt using an inbound Memory Write on its | 11 | generate an interrupt using an inbound Memory Write on its |
12 | PCI bus instead of asserting a device IRQ pin. | 12 | PCI bus instead of asserting a device IRQ pin. |
13 | 13 | ||
14 | If you don't know what to do here, say N. | 14 | Use of PCI MSI interrupts can be disabled at kernel boot time |
15 | 15 | by using the 'pci=nomsi' option. This disables MSI for the | |
16 | config PCI_LEGACY_PROC | 16 | entire system. |
17 | bool "Legacy /proc/pci interface" | ||
18 | depends on PCI | ||
19 | ---help--- | ||
20 | This feature enables a procfs file -- /proc/pci -- that provides a | ||
21 | summary of PCI devices in the system. | ||
22 | |||
23 | This feature has been deprecated as of v2.5.53, in favor of using the | ||
24 | tool lspci(8). This feature may be removed at a future date. | ||
25 | 17 | ||
26 | lspci can provide the same data, as well as much more. lspci is a part of | 18 | If you don't know what to do here, say N. |
27 | the pci-utils package, which should be installed by your distribution. | ||
28 | See <file:Documentation/Changes> for information on where to get the latest | ||
29 | version. | ||
30 | |||
31 | When in doubt, say N. | ||
32 | 19 | ||
33 | config PCI_DEBUG | 20 | config PCI_DEBUG |
34 | bool "PCI Debugging" | 21 | bool "PCI Debugging" |
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 3c71e3077ff1..421cfffb1756 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile | |||
@@ -22,6 +22,9 @@ ifdef CONFIG_HOTPLUG_PCI_CPCI | |||
22 | pci_hotplug-objs += cpci_hotplug_core.o \ | 22 | pci_hotplug-objs += cpci_hotplug_core.o \ |
23 | cpci_hotplug_pci.o | 23 | cpci_hotplug_pci.o |
24 | endif | 24 | endif |
25 | ifdef CONFIG_ACPI | ||
26 | pci_hotplug-objs += acpi_pcihp.o | ||
27 | endif | ||
25 | 28 | ||
26 | cpqphp-objs := cpqphp_core.o \ | 29 | cpqphp-objs := cpqphp_core.o \ |
27 | cpqphp_ctrl.o \ | 30 | cpqphp_ctrl.o \ |
@@ -37,7 +40,8 @@ ibmphp-objs := ibmphp_core.o \ | |||
37 | ibmphp_hpc.o | 40 | ibmphp_hpc.o |
38 | 41 | ||
39 | acpiphp-objs := acpiphp_core.o \ | 42 | acpiphp-objs := acpiphp_core.o \ |
40 | acpiphp_glue.o | 43 | acpiphp_glue.o \ |
44 | acpiphp_dock.o | ||
41 | 45 | ||
42 | rpaphp-objs := rpaphp_core.o \ | 46 | rpaphp-objs := rpaphp_core.o \ |
43 | rpaphp_pci.o \ | 47 | rpaphp_pci.o \ |
@@ -50,23 +54,9 @@ pciehp-objs := pciehp_core.o \ | |||
50 | pciehp_ctrl.o \ | 54 | pciehp_ctrl.o \ |
51 | pciehp_pci.o \ | 55 | pciehp_pci.o \ |
52 | pciehp_hpc.o | 56 | pciehp_hpc.o |
53 | ifdef CONFIG_ACPI | ||
54 | pciehp-objs += pciehprm_acpi.o | ||
55 | else | ||
56 | pciehp-objs += pciehprm_nonacpi.o | ||
57 | endif | ||
58 | 57 | ||
59 | shpchp-objs := shpchp_core.o \ | 58 | shpchp-objs := shpchp_core.o \ |
60 | shpchp_ctrl.o \ | 59 | shpchp_ctrl.o \ |
61 | shpchp_pci.o \ | 60 | shpchp_pci.o \ |
62 | shpchp_sysfs.o \ | 61 | shpchp_sysfs.o \ |
63 | shpchp_hpc.o | 62 | shpchp_hpc.o |
64 | ifdef CONFIG_ACPI | ||
65 | shpchp-objs += shpchprm_acpi.o | ||
66 | else | ||
67 | ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY | ||
68 | shpchp-objs += shpchprm_legacy.o | ||
69 | else | ||
70 | shpchp-objs += shpchprm_nonacpi.o | ||
71 | endif | ||
72 | endif | ||
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/acpi_pcihp.c index 17145e52223a..39af9c325f35 100644 --- a/drivers/pci/hotplug/shpchprm_acpi.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * SHPCHPRM ACPI: PHP Resource Manager for ACPI platform | 2 | * Common ACPI functions for hot plug platforms |
3 | * | 3 | * |
4 | * Copyright (C) 2003-2004 Intel Corporation | 4 | * Copyright (C) 2006 Intel Corporation |
5 | * | 5 | * |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
@@ -31,26 +31,12 @@ | |||
31 | #include <acpi/acpi.h> | 31 | #include <acpi/acpi.h> |
32 | #include <acpi/acpi_bus.h> | 32 | #include <acpi/acpi_bus.h> |
33 | #include <acpi/actypes.h> | 33 | #include <acpi/actypes.h> |
34 | #include "shpchp.h" | 34 | #include "pci_hotplug.h" |
35 | 35 | ||
36 | #define METHOD_NAME__SUN "_SUN" | 36 | #define METHOD_NAME__SUN "_SUN" |
37 | #define METHOD_NAME__HPP "_HPP" | 37 | #define METHOD_NAME__HPP "_HPP" |
38 | #define METHOD_NAME_OSHP "OSHP" | 38 | #define METHOD_NAME_OSHP "OSHP" |
39 | 39 | ||
40 | static u8 * acpi_path_name( acpi_handle handle) | ||
41 | { | ||
42 | acpi_status status; | ||
43 | static u8 path_name[ACPI_PATHNAME_MAX]; | ||
44 | struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name }; | ||
45 | |||
46 | memset(path_name, 0, sizeof (path_name)); | ||
47 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf); | ||
48 | |||
49 | if (ACPI_FAILURE(status)) | ||
50 | return NULL; | ||
51 | else | ||
52 | return path_name; | ||
53 | } | ||
54 | 40 | ||
55 | static acpi_status | 41 | static acpi_status |
56 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | 42 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) |
@@ -58,18 +44,21 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
58 | acpi_status status; | 44 | acpi_status status; |
59 | u8 nui[4]; | 45 | u8 nui[4]; |
60 | struct acpi_buffer ret_buf = { 0, NULL}; | 46 | struct acpi_buffer ret_buf = { 0, NULL}; |
47 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
61 | union acpi_object *ext_obj, *package; | 48 | union acpi_object *ext_obj, *package; |
62 | u8 *path_name = acpi_path_name(handle); | ||
63 | int i, len = 0; | 49 | int i, len = 0; |
64 | 50 | ||
51 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
52 | |||
65 | /* get _hpp */ | 53 | /* get _hpp */ |
66 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); | 54 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); |
67 | switch (status) { | 55 | switch (status) { |
68 | case AE_BUFFER_OVERFLOW: | 56 | case AE_BUFFER_OVERFLOW: |
69 | ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); | 57 | ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); |
70 | if (!ret_buf.pointer) { | 58 | if (!ret_buf.pointer) { |
71 | err ("%s:%s alloc for _HPP fail\n", __FUNCTION__, | 59 | printk(KERN_ERR "%s:%s alloc for _HPP fail\n", |
72 | path_name); | 60 | __FUNCTION__, (char *)string.pointer); |
61 | acpi_os_free(string.pointer); | ||
73 | return AE_NO_MEMORY; | 62 | return AE_NO_MEMORY; |
74 | } | 63 | } |
75 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, | 64 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, |
@@ -78,16 +67,17 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
78 | break; | 67 | break; |
79 | default: | 68 | default: |
80 | if (ACPI_FAILURE(status)) { | 69 | if (ACPI_FAILURE(status)) { |
81 | dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__, | 70 | pr_debug("%s:%s _HPP fail=0x%x\n", __FUNCTION__, |
82 | path_name, status); | 71 | (char *)string.pointer, status); |
72 | acpi_os_free(string.pointer); | ||
83 | return status; | 73 | return status; |
84 | } | 74 | } |
85 | } | 75 | } |
86 | 76 | ||
87 | ext_obj = (union acpi_object *) ret_buf.pointer; | 77 | ext_obj = (union acpi_object *) ret_buf.pointer; |
88 | if (ext_obj->type != ACPI_TYPE_PACKAGE) { | 78 | if (ext_obj->type != ACPI_TYPE_PACKAGE) { |
89 | err ("%s:%s _HPP obj not a package\n", __FUNCTION__, | 79 | printk(KERN_ERR "%s:%s _HPP obj not a package\n", __FUNCTION__, |
90 | path_name); | 80 | (char *)string.pointer); |
91 | status = AE_ERROR; | 81 | status = AE_ERROR; |
92 | goto free_and_return; | 82 | goto free_and_return; |
93 | } | 83 | } |
@@ -101,8 +91,8 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
101 | nui[i] = (u8)ext_obj->integer.value; | 91 | nui[i] = (u8)ext_obj->integer.value; |
102 | break; | 92 | break; |
103 | default: | 93 | default: |
104 | err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__, | 94 | printk(KERN_ERR "%s:%s _HPP obj type incorrect\n", |
105 | path_name); | 95 | __FUNCTION__, (char *)string.pointer); |
106 | status = AE_ERROR; | 96 | status = AE_ERROR; |
107 | goto free_and_return; | 97 | goto free_and_return; |
108 | } | 98 | } |
@@ -113,54 +103,52 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
113 | hpp->enable_serr = nui[2]; | 103 | hpp->enable_serr = nui[2]; |
114 | hpp->enable_perr = nui[3]; | 104 | hpp->enable_perr = nui[3]; |
115 | 105 | ||
116 | dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size); | 106 | pr_debug(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size); |
117 | dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer); | 107 | pr_debug(" _HPP: latency timer =0x%x\n", hpp->latency_timer); |
118 | dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr); | 108 | pr_debug(" _HPP: enable SERR =0x%x\n", hpp->enable_serr); |
119 | dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); | 109 | pr_debug(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); |
120 | 110 | ||
121 | free_and_return: | 111 | free_and_return: |
122 | kfree(ret_buf.pointer); | 112 | acpi_os_free(string.pointer); |
113 | acpi_os_free(ret_buf.pointer); | ||
123 | return status; | 114 | return status; |
124 | } | 115 | } |
125 | 116 | ||
126 | static void acpi_run_oshp(acpi_handle handle) | 117 | |
118 | |||
119 | /* acpi_run_oshp - get control of hotplug from the firmware | ||
120 | * | ||
121 | * @handle - the handle of the hotplug controller. | ||
122 | */ | ||
123 | acpi_status acpi_run_oshp(acpi_handle handle) | ||
127 | { | 124 | { |
128 | acpi_status status; | 125 | acpi_status status; |
129 | u8 *path_name = acpi_path_name(handle); | 126 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; |
127 | |||
128 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
130 | 129 | ||
131 | /* run OSHP */ | 130 | /* run OSHP */ |
132 | status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); | 131 | status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); |
133 | if (ACPI_FAILURE(status)) { | 132 | if (ACPI_FAILURE(status)) |
134 | err("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name, | 133 | printk(KERN_ERR "%s:%s OSHP fails=0x%x\n", __FUNCTION__, |
135 | status); | 134 | (char *)string.pointer, status); |
136 | } else { | 135 | else |
137 | dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name); | 136 | pr_debug("%s:%s OSHP passes\n", __FUNCTION__, |
138 | } | 137 | (char *)string.pointer); |
139 | } | ||
140 | |||
141 | int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) | ||
142 | { | ||
143 | int offset = devnum - ctrl->slot_device_offset; | ||
144 | 138 | ||
145 | dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset); | 139 | acpi_os_free(string.pointer); |
146 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset); | 140 | return status; |
147 | return 0; | ||
148 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(acpi_run_oshp); | ||
143 | |||
149 | 144 | ||
150 | void get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
151 | { | ||
152 | /* | ||
153 | * OSHP is an optional ACPI firmware control method. If present, | ||
154 | * we need to run it to inform BIOS that we will control SHPC | ||
155 | * hardware from now on. | ||
156 | */ | ||
157 | acpi_handle handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
158 | if (!handle) | ||
159 | return; | ||
160 | acpi_run_oshp(handle); | ||
161 | } | ||
162 | 145 | ||
163 | void get_hp_params_from_firmware(struct pci_dev *dev, | 146 | /* acpi_get_hp_params_from_firmware |
147 | * | ||
148 | * @dev - the pci_dev of the newly added device | ||
149 | * @hpp - allocated by the caller | ||
150 | */ | ||
151 | acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev, | ||
164 | struct hotplug_params *hpp) | 152 | struct hotplug_params *hpp) |
165 | { | 153 | { |
166 | acpi_status status = AE_NOT_FOUND; | 154 | acpi_status status = AE_NOT_FOUND; |
@@ -182,5 +170,42 @@ void get_hp_params_from_firmware(struct pci_dev *dev, | |||
182 | /* Check if a parent object supports _HPP */ | 170 | /* Check if a parent object supports _HPP */ |
183 | pdev = pdev->bus->parent->self; | 171 | pdev = pdev->bus->parent->self; |
184 | } | 172 | } |
173 | return status; | ||
185 | } | 174 | } |
175 | EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware); | ||
186 | 176 | ||
177 | |||
178 | /* acpi_root_bridge - check to see if this acpi object is a root bridge | ||
179 | * | ||
180 | * @handle - the acpi object in question. | ||
181 | */ | ||
182 | int acpi_root_bridge(acpi_handle handle) | ||
183 | { | ||
184 | acpi_status status; | ||
185 | struct acpi_device_info *info; | ||
186 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
187 | int i; | ||
188 | |||
189 | status = acpi_get_object_info(handle, &buffer); | ||
190 | if (ACPI_SUCCESS(status)) { | ||
191 | info = buffer.pointer; | ||
192 | if ((info->valid & ACPI_VALID_HID) && | ||
193 | !strcmp(PCI_ROOT_HID_STRING, | ||
194 | info->hardware_id.value)) { | ||
195 | acpi_os_free(buffer.pointer); | ||
196 | return 1; | ||
197 | } | ||
198 | if (info->valid & ACPI_VALID_CID) { | ||
199 | for (i=0; i < info->compatibility_id.count; i++) { | ||
200 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
201 | info->compatibility_id.id[i].value)) { | ||
202 | acpi_os_free(buffer.pointer); | ||
203 | return 1; | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | acpi_os_free(buffer.pointer); | ||
208 | } | ||
209 | return 0; | ||
210 | } | ||
211 | EXPORT_SYMBOL_GPL(acpi_root_bridge); | ||
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index 293603e1b7c3..467ac70a46ff 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <linux/kobject.h> /* for KOBJ_NAME_LEN */ | 39 | #include <linux/kobject.h> /* for KOBJ_NAME_LEN */ |
40 | #include <linux/mutex.h> | ||
40 | #include "pci_hotplug.h" | 41 | #include "pci_hotplug.h" |
41 | 42 | ||
42 | #define dbg(format, arg...) \ | 43 | #define dbg(format, arg...) \ |
@@ -59,26 +60,10 @@ struct acpiphp_slot; | |||
59 | * struct slot - slot information for each *physical* slot | 60 | * struct slot - slot information for each *physical* slot |
60 | */ | 61 | */ |
61 | struct slot { | 62 | struct slot { |
62 | u8 number; | ||
63 | struct hotplug_slot *hotplug_slot; | 63 | struct hotplug_slot *hotplug_slot; |
64 | struct list_head slot_list; | ||
65 | |||
66 | struct acpiphp_slot *acpi_slot; | 64 | struct acpiphp_slot *acpi_slot; |
67 | }; | 65 | }; |
68 | 66 | ||
69 | /** | ||
70 | * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters | ||
71 | * @cache_line_size in DWORD | ||
72 | * @latency_timer in PCI clock | ||
73 | * @enable_SERR 0 or 1 | ||
74 | * @enable_PERR 0 or 1 | ||
75 | */ | ||
76 | struct hpp_param { | ||
77 | u8 cache_line_size; | ||
78 | u8 latency_timer; | ||
79 | u8 enable_SERR; | ||
80 | u8 enable_PERR; | ||
81 | }; | ||
82 | 67 | ||
83 | 68 | ||
84 | /** | 69 | /** |
@@ -102,7 +87,7 @@ struct acpiphp_bridge { | |||
102 | struct pci_dev *pci_dev; | 87 | struct pci_dev *pci_dev; |
103 | 88 | ||
104 | /* ACPI 2.0 _HPP parameters */ | 89 | /* ACPI 2.0 _HPP parameters */ |
105 | struct hpp_param hpp; | 90 | struct hotplug_params hpp; |
106 | 91 | ||
107 | spinlock_t res_lock; | 92 | spinlock_t res_lock; |
108 | }; | 93 | }; |
@@ -118,9 +103,9 @@ struct acpiphp_slot { | |||
118 | struct acpiphp_bridge *bridge; /* parent */ | 103 | struct acpiphp_bridge *bridge; /* parent */ |
119 | struct list_head funcs; /* one slot may have different | 104 | struct list_head funcs; /* one slot may have different |
120 | objects (i.e. for each function) */ | 105 | objects (i.e. for each function) */ |
121 | struct semaphore crit_sect; | 106 | struct slot *slot; |
107 | struct mutex crit_sect; | ||
122 | 108 | ||
123 | u32 id; /* slot id (serial #) for hotplug core */ | ||
124 | u8 device; /* pci device# */ | 109 | u8 device; /* pci device# */ |
125 | 110 | ||
126 | u32 sun; /* ACPI _SUN (slot unique number) */ | 111 | u32 sun; /* ACPI _SUN (slot unique number) */ |
@@ -160,6 +145,25 @@ struct acpiphp_attention_info | |||
160 | struct module *owner; | 145 | struct module *owner; |
161 | }; | 146 | }; |
162 | 147 | ||
148 | |||
149 | struct dependent_device { | ||
150 | struct list_head device_list; | ||
151 | struct list_head pci_list; | ||
152 | acpi_handle handle; | ||
153 | struct acpiphp_func *func; | ||
154 | }; | ||
155 | |||
156 | |||
157 | struct acpiphp_dock_station { | ||
158 | acpi_handle handle; | ||
159 | u32 last_dock_time; | ||
160 | u32 flags; | ||
161 | struct acpiphp_func *dock_bridge; | ||
162 | struct list_head dependent_devices; | ||
163 | struct list_head pci_dependent_devices; | ||
164 | }; | ||
165 | |||
166 | |||
163 | /* PCI bus bridge HID */ | 167 | /* PCI bus bridge HID */ |
164 | #define ACPI_PCI_HOST_HID "PNP0A03" | 168 | #define ACPI_PCI_HOST_HID "PNP0A03" |
165 | 169 | ||
@@ -197,19 +201,27 @@ struct acpiphp_attention_info | |||
197 | #define FUNC_HAS_PS1 (0x00000020) | 201 | #define FUNC_HAS_PS1 (0x00000020) |
198 | #define FUNC_HAS_PS2 (0x00000040) | 202 | #define FUNC_HAS_PS2 (0x00000040) |
199 | #define FUNC_HAS_PS3 (0x00000080) | 203 | #define FUNC_HAS_PS3 (0x00000080) |
204 | #define FUNC_HAS_DCK (0x00000100) | ||
205 | #define FUNC_IS_DD (0x00000200) | ||
206 | |||
207 | /* dock station flags */ | ||
208 | #define DOCK_DOCKING (0x00000001) | ||
209 | #define DOCK_HAS_BRIDGE (0x00000002) | ||
200 | 210 | ||
201 | /* function prototypes */ | 211 | /* function prototypes */ |
202 | 212 | ||
203 | /* acpiphp_core.c */ | 213 | /* acpiphp_core.c */ |
204 | extern int acpiphp_register_attention(struct acpiphp_attention_info*info); | 214 | extern int acpiphp_register_attention(struct acpiphp_attention_info*info); |
205 | extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info); | 215 | extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info); |
216 | extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot); | ||
217 | extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); | ||
206 | 218 | ||
207 | /* acpiphp_glue.c */ | 219 | /* acpiphp_glue.c */ |
208 | extern int acpiphp_glue_init (void); | 220 | extern int acpiphp_glue_init (void); |
209 | extern void acpiphp_glue_exit (void); | 221 | extern void acpiphp_glue_exit (void); |
210 | extern int acpiphp_get_num_slots (void); | 222 | extern int acpiphp_get_num_slots (void); |
211 | extern struct acpiphp_slot *get_slot_from_id (int id); | ||
212 | typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); | 223 | typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); |
224 | void handle_hotplug_event_func(acpi_handle, u32, void*); | ||
213 | 225 | ||
214 | extern int acpiphp_enable_slot (struct acpiphp_slot *slot); | 226 | extern int acpiphp_enable_slot (struct acpiphp_slot *slot); |
215 | extern int acpiphp_disable_slot (struct acpiphp_slot *slot); | 227 | extern int acpiphp_disable_slot (struct acpiphp_slot *slot); |
@@ -219,6 +231,16 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot); | |||
219 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); | 231 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); |
220 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); | 232 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); |
221 | 233 | ||
234 | /* acpiphp_dock.c */ | ||
235 | extern int find_dock_station(void); | ||
236 | extern void remove_dock_station(void); | ||
237 | extern void add_dependent_device(struct dependent_device *new_dd); | ||
238 | extern void add_pci_dependent_device(struct dependent_device *new_dd); | ||
239 | extern struct dependent_device *get_dependent_device(acpi_handle handle); | ||
240 | extern int is_dependent_device(acpi_handle handle); | ||
241 | extern int detect_dependent_devices(acpi_handle *bridge_handle); | ||
242 | extern struct dependent_device *alloc_dependent_device(acpi_handle handle); | ||
243 | |||
222 | /* variables */ | 244 | /* variables */ |
223 | extern int acpiphp_debug; | 245 | extern int acpiphp_debug; |
224 | 246 | ||
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 60c4c38047a3..4f1b0da8e47e 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -44,8 +44,6 @@ | |||
44 | #include "pci_hotplug.h" | 44 | #include "pci_hotplug.h" |
45 | #include "acpiphp.h" | 45 | #include "acpiphp.h" |
46 | 46 | ||
47 | static LIST_HEAD(slot_list); | ||
48 | |||
49 | #define MY_NAME "acpiphp" | 47 | #define MY_NAME "acpiphp" |
50 | 48 | ||
51 | static int debug; | 49 | static int debug; |
@@ -341,62 +339,53 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
341 | kfree(slot); | 339 | kfree(slot); |
342 | } | 340 | } |
343 | 341 | ||
344 | /** | 342 | /* callback routine to initialize 'struct slot' for each slot */ |
345 | * init_slots - initialize 'struct slot' structures for each slot | 343 | int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) |
346 | * | ||
347 | */ | ||
348 | static int __init init_slots(void) | ||
349 | { | 344 | { |
350 | struct slot *slot; | 345 | struct slot *slot; |
346 | struct hotplug_slot *hotplug_slot; | ||
347 | struct hotplug_slot_info *hotplug_slot_info; | ||
351 | int retval = -ENOMEM; | 348 | int retval = -ENOMEM; |
352 | int i; | 349 | |
353 | 350 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | |
354 | for (i = 0; i < num_slots; ++i) { | 351 | if (!slot) |
355 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 352 | goto error; |
356 | if (!slot) | 353 | |
357 | goto error; | 354 | slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
358 | memset(slot, 0, sizeof(struct slot)); | 355 | if (!slot->hotplug_slot) |
359 | 356 | goto error_slot; | |
360 | slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 357 | |
361 | if (!slot->hotplug_slot) | 358 | slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info), |
362 | goto error_slot; | 359 | GFP_KERNEL); |
363 | memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); | 360 | if (!slot->hotplug_slot->info) |
364 | 361 | goto error_hpslot; | |
365 | slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 362 | |
366 | if (!slot->hotplug_slot->info) | 363 | slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
367 | goto error_hpslot; | 364 | if (!slot->hotplug_slot->name) |
368 | memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info)); | 365 | goto error_info; |
369 | 366 | ||
370 | slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 367 | slot->hotplug_slot->private = slot; |
371 | if (!slot->hotplug_slot->name) | 368 | slot->hotplug_slot->release = &release_slot; |
372 | goto error_info; | 369 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; |
373 | 370 | ||
374 | slot->number = i; | 371 | slot->acpi_slot = acpiphp_slot; |
375 | 372 | slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot); | |
376 | slot->hotplug_slot->private = slot; | 373 | slot->hotplug_slot->info->attention_status = 0; |
377 | slot->hotplug_slot->release = &release_slot; | 374 | slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot); |
378 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; | 375 | slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); |
379 | 376 | slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | |
380 | slot->acpi_slot = get_slot_from_id(i); | 377 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; |
381 | slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot); | 378 | |
382 | slot->hotplug_slot->info->attention_status = 0; | 379 | acpiphp_slot->slot = slot; |
383 | slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot); | 380 | make_slot_name(slot); |
384 | slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); | 381 | |
385 | slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | 382 | retval = pci_hp_register(slot->hotplug_slot); |
386 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; | 383 | if (retval) { |
387 | 384 | err("pci_hp_register failed with error %d\n", retval); | |
388 | make_slot_name(slot); | 385 | goto error_name; |
389 | 386 | } | |
390 | retval = pci_hp_register(slot->hotplug_slot); | 387 | |
391 | if (retval) { | 388 | info("Slot [%s] registered\n", slot->hotplug_slot->name); |
392 | err("pci_hp_register failed with error %d\n", retval); | ||
393 | goto error_name; | ||
394 | } | ||
395 | |||
396 | /* add slot to our internal list */ | ||
397 | list_add(&slot->slot_list, &slot_list); | ||
398 | info("Slot [%s] registered\n", slot->hotplug_slot->name); | ||
399 | } | ||
400 | 389 | ||
401 | return 0; | 390 | return 0; |
402 | error_name: | 391 | error_name: |
@@ -412,42 +401,51 @@ error: | |||
412 | } | 401 | } |
413 | 402 | ||
414 | 403 | ||
415 | static void __exit cleanup_slots (void) | 404 | void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot) |
416 | { | 405 | { |
417 | struct list_head *tmp, *n; | 406 | struct slot *slot = acpiphp_slot->slot; |
418 | struct slot *slot; | 407 | int retval = 0; |
419 | 408 | ||
420 | list_for_each_safe (tmp, n, &slot_list) { | 409 | info ("Slot [%s] unregistered\n", slot->hotplug_slot->name); |
421 | /* memory will be freed in release_slot callback */ | 410 | |
422 | slot = list_entry(tmp, struct slot, slot_list); | 411 | retval = pci_hp_deregister(slot->hotplug_slot); |
423 | list_del(&slot->slot_list); | 412 | if (retval) |
424 | pci_hp_deregister(slot->hotplug_slot); | 413 | err("pci_hp_deregister failed with error %d\n", retval); |
425 | } | ||
426 | } | 414 | } |
427 | 415 | ||
428 | 416 | ||
429 | static int __init acpiphp_init(void) | 417 | static int __init acpiphp_init(void) |
430 | { | 418 | { |
431 | int retval; | 419 | int retval; |
420 | int docking_station; | ||
432 | 421 | ||
433 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 422 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
434 | 423 | ||
435 | acpiphp_debug = debug; | 424 | acpiphp_debug = debug; |
436 | 425 | ||
426 | docking_station = find_dock_station(); | ||
427 | |||
437 | /* read all the ACPI info from the system */ | 428 | /* read all the ACPI info from the system */ |
438 | retval = init_acpi(); | 429 | retval = init_acpi(); |
439 | if (retval) | ||
440 | return retval; | ||
441 | 430 | ||
442 | return init_slots(); | 431 | /* if we have found a docking station, we should |
432 | * go ahead and load even if init_acpi has found | ||
433 | * no slots. This handles the case when the _DCK | ||
434 | * method not defined under the actual dock bridge | ||
435 | */ | ||
436 | if (docking_station) | ||
437 | return 0; | ||
438 | else | ||
439 | return retval; | ||
443 | } | 440 | } |
444 | 441 | ||
445 | 442 | ||
446 | static void __exit acpiphp_exit(void) | 443 | static void __exit acpiphp_exit(void) |
447 | { | 444 | { |
448 | cleanup_slots(); | ||
449 | /* deallocate internal data structures etc. */ | 445 | /* deallocate internal data structures etc. */ |
450 | acpiphp_glue_exit(); | 446 | acpiphp_glue_exit(); |
447 | |||
448 | remove_dock_station(); | ||
451 | } | 449 | } |
452 | 450 | ||
453 | module_init(acpiphp_init); | 451 | module_init(acpiphp_init); |
diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c new file mode 100644 index 000000000000..4f1aaf128312 --- /dev/null +++ b/drivers/pci/hotplug/acpiphp_dock.c | |||
@@ -0,0 +1,438 @@ | |||
1 | /* | ||
2 | * ACPI PCI HotPlug dock functions to ACPI CA subsystem | ||
3 | * | ||
4 | * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com) | ||
5 | * Copyright (C) 2006 Intel Corporation | ||
6 | * | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Send feedback to <kristen.c.accardi@intel.com> | ||
25 | * | ||
26 | */ | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/module.h> | ||
29 | |||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/pci.h> | ||
32 | #include <linux/smp_lock.h> | ||
33 | #include <linux/mutex.h> | ||
34 | |||
35 | #include "../pci.h" | ||
36 | #include "pci_hotplug.h" | ||
37 | #include "acpiphp.h" | ||
38 | |||
39 | static struct acpiphp_dock_station *ds; | ||
40 | #define MY_NAME "acpiphp_dock" | ||
41 | |||
42 | |||
43 | int is_dependent_device(acpi_handle handle) | ||
44 | { | ||
45 | return (get_dependent_device(handle) ? 1 : 0); | ||
46 | } | ||
47 | |||
48 | |||
49 | static acpi_status | ||
50 | find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
51 | { | ||
52 | int *count = (int *)context; | ||
53 | |||
54 | if (is_dependent_device(handle)) { | ||
55 | (*count)++; | ||
56 | return AE_CTRL_TERMINATE; | ||
57 | } else { | ||
58 | return AE_OK; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | |||
63 | |||
64 | |||
65 | void add_dependent_device(struct dependent_device *new_dd) | ||
66 | { | ||
67 | list_add_tail(&new_dd->device_list, &ds->dependent_devices); | ||
68 | } | ||
69 | |||
70 | |||
71 | void add_pci_dependent_device(struct dependent_device *new_dd) | ||
72 | { | ||
73 | list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices); | ||
74 | } | ||
75 | |||
76 | |||
77 | |||
78 | struct dependent_device * get_dependent_device(acpi_handle handle) | ||
79 | { | ||
80 | struct dependent_device *dd; | ||
81 | |||
82 | if (!ds) | ||
83 | return NULL; | ||
84 | |||
85 | list_for_each_entry(dd, &ds->dependent_devices, device_list) { | ||
86 | if (handle == dd->handle) | ||
87 | return dd; | ||
88 | } | ||
89 | return NULL; | ||
90 | } | ||
91 | |||
92 | |||
93 | |||
94 | struct dependent_device *alloc_dependent_device(acpi_handle handle) | ||
95 | { | ||
96 | struct dependent_device *dd; | ||
97 | |||
98 | dd = kzalloc(sizeof(*dd), GFP_KERNEL); | ||
99 | if (dd) { | ||
100 | INIT_LIST_HEAD(&dd->pci_list); | ||
101 | INIT_LIST_HEAD(&dd->device_list); | ||
102 | dd->handle = handle; | ||
103 | } | ||
104 | return dd; | ||
105 | } | ||
106 | |||
107 | |||
108 | |||
109 | static int is_dock(acpi_handle handle) | ||
110 | { | ||
111 | acpi_status status; | ||
112 | acpi_handle tmp; | ||
113 | |||
114 | status = acpi_get_handle(handle, "_DCK", &tmp); | ||
115 | if (ACPI_FAILURE(status)) { | ||
116 | return 0; | ||
117 | } | ||
118 | return 1; | ||
119 | } | ||
120 | |||
121 | |||
122 | |||
123 | static int dock_present(void) | ||
124 | { | ||
125 | unsigned long sta; | ||
126 | acpi_status status; | ||
127 | |||
128 | if (ds) { | ||
129 | status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); | ||
130 | if (ACPI_SUCCESS(status) && sta) | ||
131 | return 1; | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | |||
137 | |||
138 | static void eject_dock(void) | ||
139 | { | ||
140 | struct acpi_object_list arg_list; | ||
141 | union acpi_object arg; | ||
142 | |||
143 | arg_list.count = 1; | ||
144 | arg_list.pointer = &arg; | ||
145 | arg.type = ACPI_TYPE_INTEGER; | ||
146 | arg.integer.value = 1; | ||
147 | |||
148 | if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", | ||
149 | &arg_list, NULL)) || dock_present()) | ||
150 | warn("%s: failed to eject dock!\n", __FUNCTION__); | ||
151 | |||
152 | return; | ||
153 | } | ||
154 | |||
155 | |||
156 | |||
157 | |||
158 | static acpi_status handle_dock(int dock) | ||
159 | { | ||
160 | acpi_status status; | ||
161 | struct acpi_object_list arg_list; | ||
162 | union acpi_object arg; | ||
163 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
164 | |||
165 | dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking"); | ||
166 | |||
167 | /* _DCK method has one argument */ | ||
168 | arg_list.count = 1; | ||
169 | arg_list.pointer = &arg; | ||
170 | arg.type = ACPI_TYPE_INTEGER; | ||
171 | arg.integer.value = dock; | ||
172 | status = acpi_evaluate_object(ds->handle, "_DCK", | ||
173 | &arg_list, &buffer); | ||
174 | if (ACPI_FAILURE(status)) | ||
175 | err("%s: failed to execute _DCK\n", __FUNCTION__); | ||
176 | acpi_os_free(buffer.pointer); | ||
177 | |||
178 | return status; | ||
179 | } | ||
180 | |||
181 | |||
182 | |||
183 | static inline void dock(void) | ||
184 | { | ||
185 | handle_dock(1); | ||
186 | } | ||
187 | |||
188 | |||
189 | |||
190 | static inline void undock(void) | ||
191 | { | ||
192 | handle_dock(0); | ||
193 | } | ||
194 | |||
195 | |||
196 | |||
197 | /* | ||
198 | * the _DCK method can do funny things... and sometimes not | ||
199 | * hah-hah funny. | ||
200 | * | ||
201 | * TBD - figure out a way to only call fixups for | ||
202 | * systems that require them. | ||
203 | */ | ||
204 | static void post_dock_fixups(void) | ||
205 | { | ||
206 | struct pci_bus *bus; | ||
207 | u32 buses; | ||
208 | struct dependent_device *dd; | ||
209 | |||
210 | list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) { | ||
211 | bus = dd->func->slot->bridge->pci_bus; | ||
212 | |||
213 | /* fixup bad _DCK function that rewrites | ||
214 | * secondary bridge on slot | ||
215 | */ | ||
216 | pci_read_config_dword(bus->self, | ||
217 | PCI_PRIMARY_BUS, | ||
218 | &buses); | ||
219 | |||
220 | if (((buses >> 8) & 0xff) != bus->secondary) { | ||
221 | buses = (buses & 0xff000000) | ||
222 | | ((unsigned int)(bus->primary) << 0) | ||
223 | | ((unsigned int)(bus->secondary) << 8) | ||
224 | | ((unsigned int)(bus->subordinate) << 16); | ||
225 | pci_write_config_dword(bus->self, | ||
226 | PCI_PRIMARY_BUS, | ||
227 | buses); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | |||
233 | |||
234 | static void hotplug_pci(u32 type) | ||
235 | { | ||
236 | struct dependent_device *dd; | ||
237 | |||
238 | list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) | ||
239 | handle_hotplug_event_func(dd->handle, type, dd->func); | ||
240 | } | ||
241 | |||
242 | |||
243 | |||
244 | static inline void begin_dock(void) | ||
245 | { | ||
246 | ds->flags |= DOCK_DOCKING; | ||
247 | } | ||
248 | |||
249 | |||
250 | static inline void complete_dock(void) | ||
251 | { | ||
252 | ds->flags &= ~(DOCK_DOCKING); | ||
253 | ds->last_dock_time = jiffies; | ||
254 | } | ||
255 | |||
256 | |||
257 | static int dock_in_progress(void) | ||
258 | { | ||
259 | if (ds->flags & DOCK_DOCKING || | ||
260 | ds->last_dock_time == jiffies) { | ||
261 | dbg("dock in progress\n"); | ||
262 | return 1; | ||
263 | } | ||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | |||
268 | |||
269 | static void | ||
270 | handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context) | ||
271 | { | ||
272 | dbg("%s: enter\n", __FUNCTION__); | ||
273 | |||
274 | switch (type) { | ||
275 | case ACPI_NOTIFY_BUS_CHECK: | ||
276 | dbg("BUS Check\n"); | ||
277 | if (!dock_in_progress() && dock_present()) { | ||
278 | begin_dock(); | ||
279 | dock(); | ||
280 | if (!dock_present()) { | ||
281 | err("Unable to dock!\n"); | ||
282 | break; | ||
283 | } | ||
284 | post_dock_fixups(); | ||
285 | hotplug_pci(type); | ||
286 | complete_dock(); | ||
287 | } | ||
288 | break; | ||
289 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
290 | dbg("EJECT request\n"); | ||
291 | if (!dock_in_progress() && dock_present()) { | ||
292 | hotplug_pci(type); | ||
293 | undock(); | ||
294 | eject_dock(); | ||
295 | if (dock_present()) | ||
296 | err("Unable to undock!\n"); | ||
297 | } | ||
298 | break; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | |||
303 | |||
304 | |||
305 | static acpi_status | ||
306 | find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
307 | { | ||
308 | acpi_status status; | ||
309 | acpi_handle tmp; | ||
310 | acpi_handle dck_handle = (acpi_handle) context; | ||
311 | char objname[64]; | ||
312 | struct acpi_buffer buffer = { .length = sizeof(objname), | ||
313 | .pointer = objname }; | ||
314 | struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
315 | union acpi_object *ejd_obj; | ||
316 | |||
317 | status = acpi_get_handle(handle, "_EJD", &tmp); | ||
318 | if (ACPI_FAILURE(status)) | ||
319 | return AE_OK; | ||
320 | |||
321 | /* make sure we are dependent on the dock device, | ||
322 | * by executing the _EJD method, then getting a handle | ||
323 | * to the device referenced by that name. If that | ||
324 | * device handle is the same handle as the dock station | ||
325 | * handle, then we are a device dependent on the dock station | ||
326 | */ | ||
327 | acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer); | ||
328 | status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer); | ||
329 | if (ACPI_FAILURE(status)) { | ||
330 | err("Unable to execute _EJD!\n"); | ||
331 | goto find_ejd_out; | ||
332 | } | ||
333 | ejd_obj = ejd_buffer.pointer; | ||
334 | status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp); | ||
335 | if (ACPI_FAILURE(status)) | ||
336 | goto find_ejd_out; | ||
337 | |||
338 | if (tmp == dck_handle) { | ||
339 | struct dependent_device *dd; | ||
340 | dbg("%s: found device dependent on dock\n", __FUNCTION__); | ||
341 | dd = alloc_dependent_device(handle); | ||
342 | if (!dd) { | ||
343 | err("Can't allocate memory for dependent device!\n"); | ||
344 | goto find_ejd_out; | ||
345 | } | ||
346 | add_dependent_device(dd); | ||
347 | } | ||
348 | |||
349 | find_ejd_out: | ||
350 | acpi_os_free(ejd_buffer.pointer); | ||
351 | return AE_OK; | ||
352 | } | ||
353 | |||
354 | |||
355 | |||
356 | int detect_dependent_devices(acpi_handle *bridge_handle) | ||
357 | { | ||
358 | acpi_status status; | ||
359 | int count; | ||
360 | |||
361 | count = 0; | ||
362 | |||
363 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, | ||
364 | (u32)1, find_dependent_device, | ||
365 | (void *)&count, NULL); | ||
366 | |||
367 | return count; | ||
368 | } | ||
369 | |||
370 | |||
371 | |||
372 | |||
373 | |||
374 | static acpi_status | ||
375 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
376 | { | ||
377 | int *count = (int *)context; | ||
378 | |||
379 | if (is_dock(handle)) { | ||
380 | dbg("%s: found dock\n", __FUNCTION__); | ||
381 | ds = kzalloc(sizeof(*ds), GFP_KERNEL); | ||
382 | ds->handle = handle; | ||
383 | INIT_LIST_HEAD(&ds->dependent_devices); | ||
384 | INIT_LIST_HEAD(&ds->pci_dependent_devices); | ||
385 | |||
386 | /* look for devices dependent on dock station */ | ||
387 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
388 | ACPI_UINT32_MAX, find_dock_ejd, handle, NULL); | ||
389 | |||
390 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
391 | handle_hotplug_event_dock, ds); | ||
392 | (*count)++; | ||
393 | } | ||
394 | |||
395 | return AE_OK; | ||
396 | } | ||
397 | |||
398 | |||
399 | |||
400 | |||
401 | int find_dock_station(void) | ||
402 | { | ||
403 | int num = 0; | ||
404 | |||
405 | ds = NULL; | ||
406 | |||
407 | /* start from the root object, because some laptops define | ||
408 | * _DCK methods outside the scope of PCI (IBM x-series laptop) | ||
409 | */ | ||
410 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
411 | ACPI_UINT32_MAX, find_dock, &num, NULL); | ||
412 | |||
413 | return num; | ||
414 | } | ||
415 | |||
416 | |||
417 | |||
418 | void remove_dock_station(void) | ||
419 | { | ||
420 | struct dependent_device *dd, *tmp; | ||
421 | if (ds) { | ||
422 | if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle, | ||
423 | ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock))) | ||
424 | err("failed to remove dock notify handler\n"); | ||
425 | |||
426 | /* free all dependent devices */ | ||
427 | list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, | ||
428 | device_list) | ||
429 | kfree(dd); | ||
430 | |||
431 | /* no need to touch the pci_dependent_device list, | ||
432 | * cause all memory was freed above | ||
433 | */ | ||
434 | kfree(ds); | ||
435 | } | ||
436 | } | ||
437 | |||
438 | |||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 509a5b3ae998..053ee843863c 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
47 | #include <linux/pci.h> | 47 | #include <linux/pci.h> |
48 | #include <linux/smp_lock.h> | 48 | #include <linux/smp_lock.h> |
49 | #include <asm/semaphore.h> | 49 | #include <linux/mutex.h> |
50 | 50 | ||
51 | #include "../pci.h" | 51 | #include "../pci.h" |
52 | #include "pci_hotplug.h" | 52 | #include "pci_hotplug.h" |
@@ -57,7 +57,6 @@ static LIST_HEAD(bridge_list); | |||
57 | #define MY_NAME "acpiphp_glue" | 57 | #define MY_NAME "acpiphp_glue" |
58 | 58 | ||
59 | static void handle_hotplug_event_bridge (acpi_handle, u32, void *); | 59 | static void handle_hotplug_event_bridge (acpi_handle, u32, void *); |
60 | static void handle_hotplug_event_func (acpi_handle, u32, void *); | ||
61 | static void acpiphp_sanitize_bus(struct pci_bus *bus); | 60 | static void acpiphp_sanitize_bus(struct pci_bus *bus); |
62 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); | 61 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); |
63 | 62 | ||
@@ -125,11 +124,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
125 | struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; | 124 | struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; |
126 | struct acpiphp_slot *slot; | 125 | struct acpiphp_slot *slot; |
127 | struct acpiphp_func *newfunc; | 126 | struct acpiphp_func *newfunc; |
127 | struct dependent_device *dd; | ||
128 | acpi_handle tmp; | 128 | acpi_handle tmp; |
129 | acpi_status status = AE_OK; | 129 | acpi_status status = AE_OK; |
130 | unsigned long adr, sun; | 130 | unsigned long adr, sun; |
131 | int device, function; | 131 | int device, function, retval; |
132 | static int num_slots = 0; /* XXX if we support I/O node hotplug... */ | ||
133 | 132 | ||
134 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); | 133 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); |
135 | 134 | ||
@@ -138,21 +137,21 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
138 | 137 | ||
139 | status = acpi_get_handle(handle, "_EJ0", &tmp); | 138 | status = acpi_get_handle(handle, "_EJ0", &tmp); |
140 | 139 | ||
141 | if (ACPI_FAILURE(status)) | 140 | if (ACPI_FAILURE(status) && !(is_dependent_device(handle))) |
142 | return AE_OK; | 141 | return AE_OK; |
143 | 142 | ||
144 | device = (adr >> 16) & 0xffff; | 143 | device = (adr >> 16) & 0xffff; |
145 | function = adr & 0xffff; | 144 | function = adr & 0xffff; |
146 | 145 | ||
147 | newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL); | 146 | newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL); |
148 | if (!newfunc) | 147 | if (!newfunc) |
149 | return AE_NO_MEMORY; | 148 | return AE_NO_MEMORY; |
150 | memset(newfunc, 0, sizeof(struct acpiphp_func)); | ||
151 | 149 | ||
152 | INIT_LIST_HEAD(&newfunc->sibling); | 150 | INIT_LIST_HEAD(&newfunc->sibling); |
153 | newfunc->handle = handle; | 151 | newfunc->handle = handle; |
154 | newfunc->function = function; | 152 | newfunc->function = function; |
155 | newfunc->flags = FUNC_HAS_EJ0; | 153 | if (ACPI_SUCCESS(status)) |
154 | newfunc->flags = FUNC_HAS_EJ0; | ||
156 | 155 | ||
157 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) | 156 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) |
158 | newfunc->flags |= FUNC_HAS_STA; | 157 | newfunc->flags |= FUNC_HAS_STA; |
@@ -163,6 +162,19 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
163 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) | 162 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) |
164 | newfunc->flags |= FUNC_HAS_PS3; | 163 | newfunc->flags |= FUNC_HAS_PS3; |
165 | 164 | ||
165 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) { | ||
166 | newfunc->flags |= FUNC_HAS_DCK; | ||
167 | /* add to devices dependent on dock station, | ||
168 | * because this may actually be the dock bridge | ||
169 | */ | ||
170 | dd = alloc_dependent_device(handle); | ||
171 | if (!dd) | ||
172 | err("Can't allocate memory for " | ||
173 | "new dependent device!\n"); | ||
174 | else | ||
175 | add_dependent_device(dd); | ||
176 | } | ||
177 | |||
166 | status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); | 178 | status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); |
167 | if (ACPI_FAILURE(status)) | 179 | if (ACPI_FAILURE(status)) |
168 | sun = -1; | 180 | sun = -1; |
@@ -176,19 +188,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
176 | } | 188 | } |
177 | 189 | ||
178 | if (!slot) { | 190 | if (!slot) { |
179 | slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); | 191 | slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); |
180 | if (!slot) { | 192 | if (!slot) { |
181 | kfree(newfunc); | 193 | kfree(newfunc); |
182 | return AE_NO_MEMORY; | 194 | return AE_NO_MEMORY; |
183 | } | 195 | } |
184 | 196 | ||
185 | memset(slot, 0, sizeof(struct acpiphp_slot)); | ||
186 | slot->bridge = bridge; | 197 | slot->bridge = bridge; |
187 | slot->id = num_slots++; | ||
188 | slot->device = device; | 198 | slot->device = device; |
189 | slot->sun = sun; | 199 | slot->sun = sun; |
190 | INIT_LIST_HEAD(&slot->funcs); | 200 | INIT_LIST_HEAD(&slot->funcs); |
191 | init_MUTEX(&slot->crit_sect); | 201 | mutex_init(&slot->crit_sect); |
192 | 202 | ||
193 | slot->next = bridge->slots; | 203 | slot->next = bridge->slots; |
194 | bridge->slots = slot; | 204 | bridge->slots = slot; |
@@ -198,6 +208,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
198 | dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n", | 208 | dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n", |
199 | slot->sun, pci_domain_nr(bridge->pci_bus), | 209 | slot->sun, pci_domain_nr(bridge->pci_bus), |
200 | bridge->pci_bus->number, slot->device); | 210 | bridge->pci_bus->number, slot->device); |
211 | retval = acpiphp_register_hotplug_slot(slot); | ||
212 | if (retval) { | ||
213 | warn("acpiphp_register_hotplug_slot failed(err code = 0x%x)\n", retval); | ||
214 | goto err_exit; | ||
215 | } | ||
201 | } | 216 | } |
202 | 217 | ||
203 | newfunc->slot = slot; | 218 | newfunc->slot = slot; |
@@ -210,16 +225,41 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
210 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); | 225 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); |
211 | } | 226 | } |
212 | 227 | ||
228 | /* if this is a device dependent on a dock station, | ||
229 | * associate the acpiphp_func to the dependent_device | ||
230 | * struct. | ||
231 | */ | ||
232 | if ((dd = get_dependent_device(handle))) { | ||
233 | newfunc->flags |= FUNC_IS_DD; | ||
234 | /* | ||
235 | * we don't want any devices which is dependent | ||
236 | * on the dock to have it's _EJ0 method executed. | ||
237 | * because we need to run _DCK first. | ||
238 | */ | ||
239 | newfunc->flags &= ~FUNC_HAS_EJ0; | ||
240 | dd->func = newfunc; | ||
241 | add_pci_dependent_device(dd); | ||
242 | } | ||
243 | |||
213 | /* install notify handler */ | 244 | /* install notify handler */ |
214 | status = acpi_install_notify_handler(handle, | 245 | if (!(newfunc->flags & FUNC_HAS_DCK)) { |
246 | status = acpi_install_notify_handler(handle, | ||
215 | ACPI_SYSTEM_NOTIFY, | 247 | ACPI_SYSTEM_NOTIFY, |
216 | handle_hotplug_event_func, | 248 | handle_hotplug_event_func, |
217 | newfunc); | 249 | newfunc); |
218 | 250 | ||
219 | if (ACPI_FAILURE(status)) { | 251 | if (ACPI_FAILURE(status)) |
220 | err("failed to register interrupt notify handler\n"); | 252 | err("failed to register interrupt notify handler\n"); |
221 | return status; | 253 | } else |
222 | } | 254 | status = AE_OK; |
255 | |||
256 | return status; | ||
257 | |||
258 | err_exit: | ||
259 | bridge->nr_slots--; | ||
260 | bridge->slots = slot->next; | ||
261 | kfree(slot); | ||
262 | kfree(newfunc); | ||
223 | 263 | ||
224 | return AE_OK; | 264 | return AE_OK; |
225 | } | 265 | } |
@@ -245,57 +285,19 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle) | |||
245 | static void decode_hpp(struct acpiphp_bridge *bridge) | 285 | static void decode_hpp(struct acpiphp_bridge *bridge) |
246 | { | 286 | { |
247 | acpi_status status; | 287 | acpi_status status; |
248 | struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER, | ||
249 | .pointer = NULL}; | ||
250 | union acpi_object *package; | ||
251 | int i; | ||
252 | |||
253 | /* default numbers */ | ||
254 | bridge->hpp.cache_line_size = 0x10; | ||
255 | bridge->hpp.latency_timer = 0x40; | ||
256 | bridge->hpp.enable_SERR = 0; | ||
257 | bridge->hpp.enable_PERR = 0; | ||
258 | |||
259 | status = acpi_evaluate_object(bridge->handle, "_HPP", NULL, &buffer); | ||
260 | 288 | ||
289 | status = acpi_get_hp_params_from_firmware(bridge->pci_dev, &bridge->hpp); | ||
261 | if (ACPI_FAILURE(status)) { | 290 | if (ACPI_FAILURE(status)) { |
262 | dbg("_HPP evaluation failed\n"); | 291 | /* use default numbers */ |
263 | return; | 292 | bridge->hpp.cache_line_size = 0x10; |
293 | bridge->hpp.latency_timer = 0x40; | ||
294 | bridge->hpp.enable_serr = 0; | ||
295 | bridge->hpp.enable_perr = 0; | ||
264 | } | 296 | } |
265 | |||
266 | package = (union acpi_object *) buffer.pointer; | ||
267 | |||
268 | if (!package || package->type != ACPI_TYPE_PACKAGE || | ||
269 | package->package.count != 4 || !package->package.elements) { | ||
270 | err("invalid _HPP object; ignoring\n"); | ||
271 | goto err_exit; | ||
272 | } | ||
273 | |||
274 | for (i = 0; i < 4; i++) { | ||
275 | if (package->package.elements[i].type != ACPI_TYPE_INTEGER) { | ||
276 | err("invalid _HPP parameter type; ignoring\n"); | ||
277 | goto err_exit; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | bridge->hpp.cache_line_size = package->package.elements[0].integer.value; | ||
282 | bridge->hpp.latency_timer = package->package.elements[1].integer.value; | ||
283 | bridge->hpp.enable_SERR = package->package.elements[2].integer.value; | ||
284 | bridge->hpp.enable_PERR = package->package.elements[3].integer.value; | ||
285 | |||
286 | dbg("_HPP parameter = (%02x, %02x, %02x, %02x)\n", | ||
287 | bridge->hpp.cache_line_size, | ||
288 | bridge->hpp.latency_timer, | ||
289 | bridge->hpp.enable_SERR, | ||
290 | bridge->hpp.enable_PERR); | ||
291 | |||
292 | bridge->flags |= BRIDGE_HAS_HPP; | ||
293 | |||
294 | err_exit: | ||
295 | kfree(buffer.pointer); | ||
296 | } | 297 | } |
297 | 298 | ||
298 | 299 | ||
300 | |||
299 | /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ | 301 | /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ |
300 | static void init_bridge_misc(struct acpiphp_bridge *bridge) | 302 | static void init_bridge_misc(struct acpiphp_bridge *bridge) |
301 | { | 303 | { |
@@ -304,9 +306,16 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge) | |||
304 | /* decode ACPI 2.0 _HPP (hot plug parameters) */ | 306 | /* decode ACPI 2.0 _HPP (hot plug parameters) */ |
305 | decode_hpp(bridge); | 307 | decode_hpp(bridge); |
306 | 308 | ||
309 | /* must be added to the list prior to calling register_slot */ | ||
310 | list_add(&bridge->list, &bridge_list); | ||
311 | |||
307 | /* register all slot objects under this bridge */ | 312 | /* register all slot objects under this bridge */ |
308 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1, | 313 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1, |
309 | register_slot, bridge, NULL); | 314 | register_slot, bridge, NULL); |
315 | if (ACPI_FAILURE(status)) { | ||
316 | list_del(&bridge->list); | ||
317 | return; | ||
318 | } | ||
310 | 319 | ||
311 | /* install notify handler */ | 320 | /* install notify handler */ |
312 | if (bridge->type != BRIDGE_TYPE_HOST) { | 321 | if (bridge->type != BRIDGE_TYPE_HOST) { |
@@ -319,8 +328,6 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge) | |||
319 | err("failed to register interrupt notify handler\n"); | 328 | err("failed to register interrupt notify handler\n"); |
320 | } | 329 | } |
321 | } | 330 | } |
322 | |||
323 | list_add(&bridge->list, &bridge_list); | ||
324 | } | 331 | } |
325 | 332 | ||
326 | 333 | ||
@@ -329,12 +336,10 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) | |||
329 | { | 336 | { |
330 | struct acpiphp_bridge *bridge; | 337 | struct acpiphp_bridge *bridge; |
331 | 338 | ||
332 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 339 | bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
333 | if (bridge == NULL) | 340 | if (bridge == NULL) |
334 | return; | 341 | return; |
335 | 342 | ||
336 | memset(bridge, 0, sizeof(struct acpiphp_bridge)); | ||
337 | |||
338 | bridge->type = BRIDGE_TYPE_HOST; | 343 | bridge->type = BRIDGE_TYPE_HOST; |
339 | bridge->handle = handle; | 344 | bridge->handle = handle; |
340 | 345 | ||
@@ -351,14 +356,12 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) | |||
351 | { | 356 | { |
352 | struct acpiphp_bridge *bridge; | 357 | struct acpiphp_bridge *bridge; |
353 | 358 | ||
354 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 359 | bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
355 | if (bridge == NULL) { | 360 | if (bridge == NULL) { |
356 | err("out of memory\n"); | 361 | err("out of memory\n"); |
357 | return; | 362 | return; |
358 | } | 363 | } |
359 | 364 | ||
360 | memset(bridge, 0, sizeof(struct acpiphp_bridge)); | ||
361 | |||
362 | bridge->type = BRIDGE_TYPE_P2P; | 365 | bridge->type = BRIDGE_TYPE_P2P; |
363 | bridge->handle = handle; | 366 | bridge->handle = handle; |
364 | 367 | ||
@@ -410,11 +413,18 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
410 | goto out; | 413 | goto out; |
411 | 414 | ||
412 | /* check if this bridge has ejectable slots */ | 415 | /* check if this bridge has ejectable slots */ |
413 | if (detect_ejectable_slots(handle) > 0) { | 416 | if ((detect_ejectable_slots(handle) > 0) || |
417 | (detect_dependent_devices(handle) > 0)) { | ||
414 | dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); | 418 | dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); |
415 | add_p2p_bridge(handle, dev); | 419 | add_p2p_bridge(handle, dev); |
416 | } | 420 | } |
417 | 421 | ||
422 | /* search P2P bridges under this p2p bridge */ | ||
423 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | ||
424 | find_p2p_bridge, dev->subordinate, NULL); | ||
425 | if (ACPI_FAILURE(status)) | ||
426 | warn("find_p2p_bridge faied (error code = 0x%x)\n", status); | ||
427 | |||
418 | out: | 428 | out: |
419 | pci_dev_put(dev); | 429 | pci_dev_put(dev); |
420 | return AE_OK; | 430 | return AE_OK; |
@@ -512,15 +522,19 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
512 | list_for_each_safe (list, tmp, &slot->funcs) { | 522 | list_for_each_safe (list, tmp, &slot->funcs) { |
513 | struct acpiphp_func *func; | 523 | struct acpiphp_func *func; |
514 | func = list_entry(list, struct acpiphp_func, sibling); | 524 | func = list_entry(list, struct acpiphp_func, sibling); |
515 | status = acpi_remove_notify_handler(func->handle, | 525 | if (!(func->flags & FUNC_HAS_DCK)) { |
526 | status = acpi_remove_notify_handler(func->handle, | ||
516 | ACPI_SYSTEM_NOTIFY, | 527 | ACPI_SYSTEM_NOTIFY, |
517 | handle_hotplug_event_func); | 528 | handle_hotplug_event_func); |
518 | if (ACPI_FAILURE(status)) | 529 | if (ACPI_FAILURE(status)) |
519 | err("failed to remove notify handler\n"); | 530 | err("failed to remove notify handler\n"); |
531 | } | ||
520 | pci_dev_put(func->pci_dev); | 532 | pci_dev_put(func->pci_dev); |
521 | list_del(list); | 533 | list_del(list); |
522 | kfree(func); | 534 | kfree(func); |
523 | } | 535 | } |
536 | acpiphp_unregister_hotplug_slot(slot); | ||
537 | list_del(&slot->funcs); | ||
524 | kfree(slot); | 538 | kfree(slot); |
525 | slot = next; | 539 | slot = next; |
526 | } | 540 | } |
@@ -551,7 +565,8 @@ static void remove_bridge(acpi_handle handle) | |||
551 | } else { | 565 | } else { |
552 | /* clean-up p2p bridges under this host bridge */ | 566 | /* clean-up p2p bridges under this host bridge */ |
553 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | 567 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
554 | (u32)1, cleanup_p2p_bridge, NULL, NULL); | 568 | ACPI_UINT32_MAX, cleanup_p2p_bridge, |
569 | NULL, NULL); | ||
555 | } | 570 | } |
556 | } | 571 | } |
557 | 572 | ||
@@ -751,6 +766,113 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
751 | } | 766 | } |
752 | 767 | ||
753 | 768 | ||
769 | |||
770 | /** | ||
771 | * acpiphp_max_busnr - return the highest reserved bus number under | ||
772 | * the given bus. | ||
773 | * @bus: bus to start search with | ||
774 | * | ||
775 | */ | ||
776 | static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | ||
777 | { | ||
778 | struct list_head *tmp; | ||
779 | unsigned char max, n; | ||
780 | |||
781 | /* | ||
782 | * pci_bus_max_busnr will return the highest | ||
783 | * reserved busnr for all these children. | ||
784 | * that is equivalent to the bus->subordinate | ||
785 | * value. We don't want to use the parent's | ||
786 | * bus->subordinate value because it could have | ||
787 | * padding in it. | ||
788 | */ | ||
789 | max = bus->secondary; | ||
790 | |||
791 | list_for_each(tmp, &bus->children) { | ||
792 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | ||
793 | if (n > max) | ||
794 | max = n; | ||
795 | } | ||
796 | return max; | ||
797 | } | ||
798 | |||
799 | |||
800 | |||
801 | /** | ||
802 | * get_func - get a pointer to acpiphp_func given a slot, device | ||
803 | * @slot: slot to search | ||
804 | * @dev: pci_dev struct to match. | ||
805 | * | ||
806 | * This function will increase the reference count of pci_dev, | ||
807 | * so callers should call pci_dev_put when complete. | ||
808 | * | ||
809 | */ | ||
810 | static struct acpiphp_func * | ||
811 | get_func(struct acpiphp_slot *slot, struct pci_dev *dev) | ||
812 | { | ||
813 | struct acpiphp_func *func = NULL; | ||
814 | struct pci_bus *bus = slot->bridge->pci_bus; | ||
815 | struct pci_dev *pdev; | ||
816 | |||
817 | list_for_each_entry(func, &slot->funcs, sibling) { | ||
818 | pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, | ||
819 | func->function)); | ||
820 | if (pdev) { | ||
821 | if (pdev == dev) | ||
822 | break; | ||
823 | pci_dev_put(pdev); | ||
824 | } | ||
825 | } | ||
826 | return func; | ||
827 | } | ||
828 | |||
829 | |||
830 | /** | ||
831 | * acpiphp_bus_add - add a new bus to acpi subsystem | ||
832 | * @func: acpiphp_func of the bridge | ||
833 | * | ||
834 | */ | ||
835 | static int acpiphp_bus_add(struct acpiphp_func *func) | ||
836 | { | ||
837 | acpi_handle phandle; | ||
838 | struct acpi_device *device, *pdevice; | ||
839 | int ret_val; | ||
840 | |||
841 | acpi_get_parent(func->handle, &phandle); | ||
842 | if (acpi_bus_get_device(phandle, &pdevice)) { | ||
843 | dbg("no parent device, assuming NULL\n"); | ||
844 | pdevice = NULL; | ||
845 | } | ||
846 | if (!acpi_bus_get_device(func->handle, &device)) { | ||
847 | dbg("bus exists... trim\n"); | ||
848 | /* this shouldn't be in here, so remove | ||
849 | * the bus then re-add it... | ||
850 | */ | ||
851 | ret_val = acpi_bus_trim(device, 1); | ||
852 | dbg("acpi_bus_trim return %x\n", ret_val); | ||
853 | } | ||
854 | |||
855 | ret_val = acpi_bus_add(&device, pdevice, func->handle, | ||
856 | ACPI_BUS_TYPE_DEVICE); | ||
857 | if (ret_val) { | ||
858 | dbg("error adding bus, %x\n", | ||
859 | -ret_val); | ||
860 | goto acpiphp_bus_add_out; | ||
861 | } | ||
862 | /* | ||
863 | * try to start anyway. We could have failed to add | ||
864 | * simply because this bus had previously been added | ||
865 | * on another add. Don't bother with the return value | ||
866 | * we just keep going. | ||
867 | */ | ||
868 | ret_val = acpi_bus_start(device); | ||
869 | |||
870 | acpiphp_bus_add_out: | ||
871 | return ret_val; | ||
872 | } | ||
873 | |||
874 | |||
875 | |||
754 | /** | 876 | /** |
755 | * enable_device - enable, configure a slot | 877 | * enable_device - enable, configure a slot |
756 | * @slot: slot to be enabled | 878 | * @slot: slot to be enabled |
@@ -788,7 +910,7 @@ static int enable_device(struct acpiphp_slot *slot) | |||
788 | goto err_exit; | 910 | goto err_exit; |
789 | } | 911 | } |
790 | 912 | ||
791 | max = bus->secondary; | 913 | max = acpiphp_max_busnr(bus); |
792 | for (pass = 0; pass < 2; pass++) { | 914 | for (pass = 0; pass < 2; pass++) { |
793 | list_for_each_entry(dev, &bus->devices, bus_list) { | 915 | list_for_each_entry(dev, &bus->devices, bus_list) { |
794 | if (PCI_SLOT(dev->devfn) != slot->device) | 916 | if (PCI_SLOT(dev->devfn) != slot->device) |
@@ -796,8 +918,15 @@ static int enable_device(struct acpiphp_slot *slot) | |||
796 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 918 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
797 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { | 919 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { |
798 | max = pci_scan_bridge(bus, dev, max, pass); | 920 | max = pci_scan_bridge(bus, dev, max, pass); |
799 | if (pass && dev->subordinate) | 921 | if (pass && dev->subordinate) { |
800 | pci_bus_size_bridges(dev->subordinate); | 922 | pci_bus_size_bridges(dev->subordinate); |
923 | func = get_func(slot, dev); | ||
924 | if (func) { | ||
925 | acpiphp_bus_add(func); | ||
926 | /* side effect of get_func */ | ||
927 | pci_dev_put(dev); | ||
928 | } | ||
929 | } | ||
801 | } | 930 | } |
802 | } | 931 | } |
803 | } | 932 | } |
@@ -806,8 +935,8 @@ static int enable_device(struct acpiphp_slot *slot) | |||
806 | acpiphp_sanitize_bus(bus); | 935 | acpiphp_sanitize_bus(bus); |
807 | pci_enable_bridges(bus); | 936 | pci_enable_bridges(bus); |
808 | pci_bus_add_devices(bus); | 937 | pci_bus_add_devices(bus); |
809 | acpiphp_set_hpp_values(DEVICE_ACPI_HANDLE(&bus->self->dev), bus); | 938 | acpiphp_set_hpp_values(slot->bridge->handle, bus); |
810 | acpiphp_configure_ioapics(DEVICE_ACPI_HANDLE(&bus->self->dev)); | 939 | acpiphp_configure_ioapics(slot->bridge->handle); |
811 | 940 | ||
812 | /* associate pci_dev to our representation */ | 941 | /* associate pci_dev to our representation */ |
813 | list_for_each (l, &slot->funcs) { | 942 | list_for_each (l, &slot->funcs) { |
@@ -987,11 +1116,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | |||
987 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, | 1116 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, |
988 | bridge->hpp.latency_timer); | 1117 | bridge->hpp.latency_timer); |
989 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | 1118 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); |
990 | if (bridge->hpp.enable_SERR) | 1119 | if (bridge->hpp.enable_serr) |
991 | pci_cmd |= PCI_COMMAND_SERR; | 1120 | pci_cmd |= PCI_COMMAND_SERR; |
992 | else | 1121 | else |
993 | pci_cmd &= ~PCI_COMMAND_SERR; | 1122 | pci_cmd &= ~PCI_COMMAND_SERR; |
994 | if (bridge->hpp.enable_PERR) | 1123 | if (bridge->hpp.enable_perr) |
995 | pci_cmd |= PCI_COMMAND_PARITY; | 1124 | pci_cmd |= PCI_COMMAND_PARITY; |
996 | else | 1125 | else |
997 | pci_cmd &= ~PCI_COMMAND_PARITY; | 1126 | pci_cmd &= ~PCI_COMMAND_PARITY; |
@@ -1002,11 +1131,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | |||
1002 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, | 1131 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, |
1003 | bridge->hpp.latency_timer); | 1132 | bridge->hpp.latency_timer); |
1004 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); | 1133 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); |
1005 | if (bridge->hpp.enable_SERR) | 1134 | if (bridge->hpp.enable_serr) |
1006 | pci_bctl |= PCI_BRIDGE_CTL_SERR; | 1135 | pci_bctl |= PCI_BRIDGE_CTL_SERR; |
1007 | else | 1136 | else |
1008 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; | 1137 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; |
1009 | if (bridge->hpp.enable_PERR) | 1138 | if (bridge->hpp.enable_perr) |
1010 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; | 1139 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; |
1011 | else | 1140 | else |
1012 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; | 1141 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; |
@@ -1026,6 +1155,7 @@ static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus) | |||
1026 | 1155 | ||
1027 | memset(&bridge, 0, sizeof(bridge)); | 1156 | memset(&bridge, 0, sizeof(bridge)); |
1028 | bridge.handle = handle; | 1157 | bridge.handle = handle; |
1158 | bridge.pci_dev = bus->self; | ||
1029 | decode_hpp(&bridge); | 1159 | decode_hpp(&bridge); |
1030 | list_for_each_entry(dev, &bus->devices, bus_list) | 1160 | list_for_each_entry(dev, &bus->devices, bus_list) |
1031 | program_hpp(dev, &bridge); | 1161 | program_hpp(dev, &bridge); |
@@ -1200,7 +1330,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont | |||
1200 | * handles ACPI event notification on slots | 1330 | * handles ACPI event notification on slots |
1201 | * | 1331 | * |
1202 | */ | 1332 | */ |
1203 | static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) | 1333 | void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) |
1204 | { | 1334 | { |
1205 | struct acpiphp_func *func; | 1335 | struct acpiphp_func *func; |
1206 | char objname[64]; | 1336 | char objname[64]; |
@@ -1242,41 +1372,13 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex | |||
1242 | } | 1372 | } |
1243 | } | 1373 | } |
1244 | 1374 | ||
1245 | static int is_root_bridge(acpi_handle handle) | ||
1246 | { | ||
1247 | acpi_status status; | ||
1248 | struct acpi_device_info *info; | ||
1249 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
1250 | int i; | ||
1251 | |||
1252 | status = acpi_get_object_info(handle, &buffer); | ||
1253 | if (ACPI_SUCCESS(status)) { | ||
1254 | info = buffer.pointer; | ||
1255 | if ((info->valid & ACPI_VALID_HID) && | ||
1256 | !strcmp(PCI_ROOT_HID_STRING, | ||
1257 | info->hardware_id.value)) { | ||
1258 | acpi_os_free(buffer.pointer); | ||
1259 | return 1; | ||
1260 | } | ||
1261 | if (info->valid & ACPI_VALID_CID) { | ||
1262 | for (i=0; i < info->compatibility_id.count; i++) { | ||
1263 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
1264 | info->compatibility_id.id[i].value)) { | ||
1265 | acpi_os_free(buffer.pointer); | ||
1266 | return 1; | ||
1267 | } | ||
1268 | } | ||
1269 | } | ||
1270 | } | ||
1271 | return 0; | ||
1272 | } | ||
1273 | 1375 | ||
1274 | static acpi_status | 1376 | static acpi_status |
1275 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | 1377 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) |
1276 | { | 1378 | { |
1277 | int *count = (int *)context; | 1379 | int *count = (int *)context; |
1278 | 1380 | ||
1279 | if (is_root_bridge(handle)) { | 1381 | if (acpi_root_bridge(handle)) { |
1280 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1382 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1281 | handle_hotplug_event_bridge, NULL); | 1383 | handle_hotplug_event_bridge, NULL); |
1282 | (*count)++; | 1384 | (*count)++; |
@@ -1373,26 +1475,6 @@ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data) | |||
1373 | } | 1475 | } |
1374 | #endif | 1476 | #endif |
1375 | 1477 | ||
1376 | /* search matching slot from id */ | ||
1377 | struct acpiphp_slot *get_slot_from_id(int id) | ||
1378 | { | ||
1379 | struct list_head *node; | ||
1380 | struct acpiphp_bridge *bridge; | ||
1381 | struct acpiphp_slot *slot; | ||
1382 | |||
1383 | list_for_each (node, &bridge_list) { | ||
1384 | bridge = (struct acpiphp_bridge *)node; | ||
1385 | for (slot = bridge->slots; slot; slot = slot->next) | ||
1386 | if (slot->id == id) | ||
1387 | return slot; | ||
1388 | } | ||
1389 | |||
1390 | /* should never happen! */ | ||
1391 | err("%s: no object for id %d\n", __FUNCTION__, id); | ||
1392 | WARN_ON(1); | ||
1393 | return NULL; | ||
1394 | } | ||
1395 | |||
1396 | 1478 | ||
1397 | /** | 1479 | /** |
1398 | * acpiphp_enable_slot - power on slot | 1480 | * acpiphp_enable_slot - power on slot |
@@ -1401,7 +1483,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) | |||
1401 | { | 1483 | { |
1402 | int retval; | 1484 | int retval; |
1403 | 1485 | ||
1404 | down(&slot->crit_sect); | 1486 | mutex_lock(&slot->crit_sect); |
1405 | 1487 | ||
1406 | /* wake up all functions */ | 1488 | /* wake up all functions */ |
1407 | retval = power_on_slot(slot); | 1489 | retval = power_on_slot(slot); |
@@ -1413,7 +1495,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) | |||
1413 | retval = enable_device(slot); | 1495 | retval = enable_device(slot); |
1414 | 1496 | ||
1415 | err_exit: | 1497 | err_exit: |
1416 | up(&slot->crit_sect); | 1498 | mutex_unlock(&slot->crit_sect); |
1417 | return retval; | 1499 | return retval; |
1418 | } | 1500 | } |
1419 | 1501 | ||
@@ -1424,7 +1506,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot) | |||
1424 | { | 1506 | { |
1425 | int retval = 0; | 1507 | int retval = 0; |
1426 | 1508 | ||
1427 | down(&slot->crit_sect); | 1509 | mutex_lock(&slot->crit_sect); |
1428 | 1510 | ||
1429 | /* unconfigure all functions */ | 1511 | /* unconfigure all functions */ |
1430 | retval = disable_device(slot); | 1512 | retval = disable_device(slot); |
@@ -1437,7 +1519,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot) | |||
1437 | goto err_exit; | 1519 | goto err_exit; |
1438 | 1520 | ||
1439 | err_exit: | 1521 | err_exit: |
1440 | up(&slot->crit_sect); | 1522 | mutex_unlock(&slot->crit_sect); |
1441 | return retval; | 1523 | return retval; |
1442 | } | 1524 | } |
1443 | 1525 | ||
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 30af105271a2..037ce4c91687 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
248 | * with the pci_hotplug subsystem. | 248 | * with the pci_hotplug subsystem. |
249 | */ | 249 | */ |
250 | for (i = first; i <= last; ++i) { | 250 | for (i = first; i <= last; ++i) { |
251 | slot = kmalloc(sizeof (struct slot), GFP_KERNEL); | 251 | slot = kzalloc(sizeof (struct slot), GFP_KERNEL); |
252 | if (!slot) | 252 | if (!slot) |
253 | goto error; | 253 | goto error; |
254 | memset(slot, 0, sizeof (struct slot)); | ||
255 | 254 | ||
256 | hotplug_slot = | 255 | hotplug_slot = |
257 | kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); | 256 | kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL); |
258 | if (!hotplug_slot) | 257 | if (!hotplug_slot) |
259 | goto error_slot; | 258 | goto error_slot; |
260 | memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); | ||
261 | slot->hotplug_slot = hotplug_slot; | 259 | slot->hotplug_slot = hotplug_slot; |
262 | 260 | ||
263 | info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); | 261 | info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); |
264 | if (!info) | 262 | if (!info) |
265 | goto error_hpslot; | 263 | goto error_hpslot; |
266 | memset(info, 0, sizeof (struct hotplug_slot_info)); | ||
267 | hotplug_slot->info = info; | 264 | hotplug_slot->info = info; |
268 | 265 | ||
269 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 266 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index cb88404c89fe..c74e9e37e76b 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <asm/io.h> /* for read? and write? functions */ | 33 | #include <asm/io.h> /* for read? and write? functions */ |
34 | #include <linux/delay.h> /* for delays */ | 34 | #include <linux/delay.h> /* for delays */ |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | #define MY_NAME "cpqphp" | 37 | #define MY_NAME "cpqphp" |
37 | 38 | ||
@@ -286,7 +287,7 @@ struct event_info { | |||
286 | struct controller { | 287 | struct controller { |
287 | struct controller *next; | 288 | struct controller *next; |
288 | u32 ctrl_int_comp; | 289 | u32 ctrl_int_comp; |
289 | struct semaphore crit_sect; /* critical section semaphore */ | 290 | struct mutex crit_sect; /* critical section mutex */ |
290 | void __iomem *hpc_reg; /* cookie for our pci controller location */ | 291 | void __iomem *hpc_reg; /* cookie for our pci controller location */ |
291 | struct pci_resource *mem_head; | 292 | struct pci_resource *mem_head; |
292 | struct pci_resource *p_mem_head; | 293 | struct pci_resource *p_mem_head; |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index b3659ffccac9..9bc1deb8df52 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
347 | slot_number = ctrl->first_slot; | 347 | slot_number = ctrl->first_slot; |
348 | 348 | ||
349 | while (number_of_slots) { | 349 | while (number_of_slots) { |
350 | slot = kmalloc(sizeof(*slot), GFP_KERNEL); | 350 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
351 | if (!slot) | 351 | if (!slot) |
352 | goto error; | 352 | goto error; |
353 | 353 | ||
354 | memset(slot, 0, sizeof(struct slot)); | 354 | slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), |
355 | slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)), | ||
356 | GFP_KERNEL); | 355 | GFP_KERNEL); |
357 | if (!slot->hotplug_slot) | 356 | if (!slot->hotplug_slot) |
358 | goto error_slot; | 357 | goto error_slot; |
359 | hotplug_slot = slot->hotplug_slot; | 358 | hotplug_slot = slot->hotplug_slot; |
360 | memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); | ||
361 | 359 | ||
362 | hotplug_slot->info = | 360 | hotplug_slot->info = |
363 | kmalloc(sizeof(*(hotplug_slot->info)), | 361 | kzalloc(sizeof(*(hotplug_slot->info)), |
364 | GFP_KERNEL); | 362 | GFP_KERNEL); |
365 | if (!hotplug_slot->info) | 363 | if (!hotplug_slot->info) |
366 | goto error_hpslot; | 364 | goto error_hpslot; |
367 | hotplug_slot_info = hotplug_slot->info; | 365 | hotplug_slot_info = hotplug_slot->info; |
368 | memset(hotplug_slot_info, 0, | ||
369 | sizeof(struct hotplug_slot_info)); | ||
370 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 366 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
371 | 367 | ||
372 | if (!hotplug_slot->name) | 368 | if (!hotplug_slot->name) |
@@ -599,7 +595,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
599 | hp_slot = func->device - ctrl->slot_device_offset; | 595 | hp_slot = func->device - ctrl->slot_device_offset; |
600 | 596 | ||
601 | // Wait for exclusive access to hardware | 597 | // Wait for exclusive access to hardware |
602 | down(&ctrl->crit_sect); | 598 | mutex_lock(&ctrl->crit_sect); |
603 | 599 | ||
604 | if (status == 1) { | 600 | if (status == 1) { |
605 | amber_LED_on (ctrl, hp_slot); | 601 | amber_LED_on (ctrl, hp_slot); |
@@ -607,7 +603,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
607 | amber_LED_off (ctrl, hp_slot); | 603 | amber_LED_off (ctrl, hp_slot); |
608 | } else { | 604 | } else { |
609 | // Done with exclusive hardware access | 605 | // Done with exclusive hardware access |
610 | up(&ctrl->crit_sect); | 606 | mutex_unlock(&ctrl->crit_sect); |
611 | return(1); | 607 | return(1); |
612 | } | 608 | } |
613 | 609 | ||
@@ -617,7 +613,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
617 | wait_for_ctrl_irq (ctrl); | 613 | wait_for_ctrl_irq (ctrl); |
618 | 614 | ||
619 | // Done with exclusive hardware access | 615 | // Done with exclusive hardware access |
620 | up(&ctrl->crit_sect); | 616 | mutex_unlock(&ctrl->crit_sect); |
621 | 617 | ||
622 | return(0); | 618 | return(0); |
623 | } | 619 | } |
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
854 | goto err_disable_device; | 850 | goto err_disable_device; |
855 | } | 851 | } |
856 | 852 | ||
857 | ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); | 853 | ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); |
858 | if (!ctrl) { | 854 | if (!ctrl) { |
859 | err("%s : out of memory\n", __FUNCTION__); | 855 | err("%s : out of memory\n", __FUNCTION__); |
860 | rc = -ENOMEM; | 856 | rc = -ENOMEM; |
861 | goto err_disable_device; | 857 | goto err_disable_device; |
862 | } | 858 | } |
863 | memset(ctrl, 0, sizeof(struct controller)); | ||
864 | 859 | ||
865 | rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); | 860 | rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); |
866 | if (rc) { | 861 | if (rc) { |
@@ -1084,7 +1079,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1084 | dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, | 1079 | dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, |
1085 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); | 1080 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); |
1086 | 1081 | ||
1087 | init_MUTEX(&ctrl->crit_sect); | 1082 | mutex_init(&ctrl->crit_sect); |
1088 | init_waitqueue_head(&ctrl->queue); | 1083 | init_waitqueue_head(&ctrl->queue); |
1089 | 1084 | ||
1090 | /* initialize our threads if they haven't already been started up */ | 1085 | /* initialize our threads if they haven't already been started up */ |
@@ -1223,7 +1218,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1223 | 1218 | ||
1224 | // turn off empty slots here unless command line option "ON" set | 1219 | // turn off empty slots here unless command line option "ON" set |
1225 | // Wait for exclusive access to hardware | 1220 | // Wait for exclusive access to hardware |
1226 | down(&ctrl->crit_sect); | 1221 | mutex_lock(&ctrl->crit_sect); |
1227 | 1222 | ||
1228 | num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; | 1223 | num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; |
1229 | 1224 | ||
@@ -1270,12 +1265,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1270 | rc = init_SERR(ctrl); | 1265 | rc = init_SERR(ctrl); |
1271 | if (rc) { | 1266 | if (rc) { |
1272 | err("init_SERR failed\n"); | 1267 | err("init_SERR failed\n"); |
1273 | up(&ctrl->crit_sect); | 1268 | mutex_unlock(&ctrl->crit_sect); |
1274 | goto err_free_irq; | 1269 | goto err_free_irq; |
1275 | } | 1270 | } |
1276 | 1271 | ||
1277 | // Done with exclusive hardware access | 1272 | // Done with exclusive hardware access |
1278 | up(&ctrl->crit_sect); | 1273 | mutex_unlock(&ctrl->crit_sect); |
1279 | 1274 | ||
1280 | cpqhp_create_debugfs_files(ctrl); | 1275 | cpqhp_create_debugfs_files(ctrl); |
1281 | 1276 | ||
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 771ed34b1819..55d2dc7e39ca 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -1282,9 +1282,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1282 | u8 hp_slot; | 1282 | u8 hp_slot; |
1283 | u8 temp_byte; | 1283 | u8 temp_byte; |
1284 | u8 adapter_speed; | 1284 | u8 adapter_speed; |
1285 | u32 index; | ||
1286 | u32 rc = 0; | 1285 | u32 rc = 0; |
1287 | u32 src = 8; | ||
1288 | 1286 | ||
1289 | hp_slot = func->device - ctrl->slot_device_offset; | 1287 | hp_slot = func->device - ctrl->slot_device_offset; |
1290 | 1288 | ||
@@ -1299,7 +1297,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1299 | **********************************/ | 1297 | **********************************/ |
1300 | rc = CARD_FUNCTIONING; | 1298 | rc = CARD_FUNCTIONING; |
1301 | } else { | 1299 | } else { |
1302 | down(&ctrl->crit_sect); | 1300 | mutex_lock(&ctrl->crit_sect); |
1303 | 1301 | ||
1304 | /* turn on board without attaching to the bus */ | 1302 | /* turn on board without attaching to the bus */ |
1305 | enable_slot_power (ctrl, hp_slot); | 1303 | enable_slot_power (ctrl, hp_slot); |
@@ -1333,12 +1331,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1333 | /* Wait for SOBS to be unset */ | 1331 | /* Wait for SOBS to be unset */ |
1334 | wait_for_ctrl_irq (ctrl); | 1332 | wait_for_ctrl_irq (ctrl); |
1335 | 1333 | ||
1336 | up(&ctrl->crit_sect); | 1334 | mutex_unlock(&ctrl->crit_sect); |
1337 | 1335 | ||
1338 | if (rc) | 1336 | if (rc) |
1339 | return rc; | 1337 | return rc; |
1340 | 1338 | ||
1341 | down(&ctrl->crit_sect); | 1339 | mutex_lock(&ctrl->crit_sect); |
1342 | 1340 | ||
1343 | slot_enable (ctrl, hp_slot); | 1341 | slot_enable (ctrl, hp_slot); |
1344 | green_LED_blink (ctrl, hp_slot); | 1342 | green_LED_blink (ctrl, hp_slot); |
@@ -1350,7 +1348,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1350 | /* Wait for SOBS to be unset */ | 1348 | /* Wait for SOBS to be unset */ |
1351 | wait_for_ctrl_irq (ctrl); | 1349 | wait_for_ctrl_irq (ctrl); |
1352 | 1350 | ||
1353 | up(&ctrl->crit_sect); | 1351 | mutex_unlock(&ctrl->crit_sect); |
1354 | 1352 | ||
1355 | /* Wait for ~1 second because of hot plug spec */ | 1353 | /* Wait for ~1 second because of hot plug spec */ |
1356 | long_delay(1*HZ); | 1354 | long_delay(1*HZ); |
@@ -1368,76 +1366,30 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1368 | 1366 | ||
1369 | rc = cpqhp_configure_board(ctrl, func); | 1367 | rc = cpqhp_configure_board(ctrl, func); |
1370 | 1368 | ||
1371 | if (rc || src) { | 1369 | /* If configuration fails, turn it off |
1372 | /* If configuration fails, turn it off | 1370 | * Get slot won't work for devices behind |
1373 | * Get slot won't work for devices behind | 1371 | * bridges, but in this case it will always be |
1374 | * bridges, but in this case it will always be | 1372 | * called for the "base" bus/dev/func of an |
1375 | * called for the "base" bus/dev/func of an | 1373 | * adapter. */ |
1376 | * adapter. */ | ||
1377 | 1374 | ||
1378 | down(&ctrl->crit_sect); | 1375 | mutex_lock(&ctrl->crit_sect); |
1379 | 1376 | ||
1380 | amber_LED_on (ctrl, hp_slot); | 1377 | amber_LED_on (ctrl, hp_slot); |
1381 | green_LED_off (ctrl, hp_slot); | 1378 | green_LED_off (ctrl, hp_slot); |
1382 | slot_disable (ctrl, hp_slot); | 1379 | slot_disable (ctrl, hp_slot); |
1383 | |||
1384 | set_SOGO(ctrl); | ||
1385 | |||
1386 | /* Wait for SOBS to be unset */ | ||
1387 | wait_for_ctrl_irq (ctrl); | ||
1388 | |||
1389 | up(&ctrl->crit_sect); | ||
1390 | |||
1391 | if (rc) | ||
1392 | return rc; | ||
1393 | else | ||
1394 | return 1; | ||
1395 | } | ||
1396 | |||
1397 | func->status = 0; | ||
1398 | func->switch_save = 0x10; | ||
1399 | |||
1400 | index = 1; | ||
1401 | while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) { | ||
1402 | rc |= cpqhp_configure_board(ctrl, func); | ||
1403 | index++; | ||
1404 | } | ||
1405 | |||
1406 | if (rc) { | ||
1407 | /* If configuration fails, turn it off | ||
1408 | * Get slot won't work for devices behind | ||
1409 | * bridges, but in this case it will always be | ||
1410 | * called for the "base" bus/dev/func of an | ||
1411 | * adapter. */ | ||
1412 | |||
1413 | down(&ctrl->crit_sect); | ||
1414 | |||
1415 | amber_LED_on (ctrl, hp_slot); | ||
1416 | green_LED_off (ctrl, hp_slot); | ||
1417 | slot_disable (ctrl, hp_slot); | ||
1418 | |||
1419 | set_SOGO(ctrl); | ||
1420 | |||
1421 | /* Wait for SOBS to be unset */ | ||
1422 | wait_for_ctrl_irq (ctrl); | ||
1423 | |||
1424 | up(&ctrl->crit_sect); | ||
1425 | |||
1426 | return rc; | ||
1427 | } | ||
1428 | /* Done configuring so turn LED on full time */ | ||
1429 | |||
1430 | down(&ctrl->crit_sect); | ||
1431 | |||
1432 | green_LED_on (ctrl, hp_slot); | ||
1433 | 1380 | ||
1434 | set_SOGO(ctrl); | 1381 | set_SOGO(ctrl); |
1435 | 1382 | ||
1436 | /* Wait for SOBS to be unset */ | 1383 | /* Wait for SOBS to be unset */ |
1437 | wait_for_ctrl_irq (ctrl); | 1384 | wait_for_ctrl_irq (ctrl); |
1438 | 1385 | ||
1439 | up(&ctrl->crit_sect); | 1386 | mutex_unlock(&ctrl->crit_sect); |
1440 | rc = 0; | 1387 | |
1388 | if (rc) | ||
1389 | return rc; | ||
1390 | else | ||
1391 | return 1; | ||
1392 | |||
1441 | } else { | 1393 | } else { |
1442 | /* Something is wrong | 1394 | /* Something is wrong |
1443 | 1395 | ||
@@ -1445,7 +1397,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1445 | * in this case it will always be called for the "base" | 1397 | * in this case it will always be called for the "base" |
1446 | * bus/dev/func of an adapter. */ | 1398 | * bus/dev/func of an adapter. */ |
1447 | 1399 | ||
1448 | down(&ctrl->crit_sect); | 1400 | mutex_lock(&ctrl->crit_sect); |
1449 | 1401 | ||
1450 | amber_LED_on (ctrl, hp_slot); | 1402 | amber_LED_on (ctrl, hp_slot); |
1451 | green_LED_off (ctrl, hp_slot); | 1403 | green_LED_off (ctrl, hp_slot); |
@@ -1456,7 +1408,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1456 | /* Wait for SOBS to be unset */ | 1408 | /* Wait for SOBS to be unset */ |
1457 | wait_for_ctrl_irq (ctrl); | 1409 | wait_for_ctrl_irq (ctrl); |
1458 | 1410 | ||
1459 | up(&ctrl->crit_sect); | 1411 | mutex_unlock(&ctrl->crit_sect); |
1460 | } | 1412 | } |
1461 | 1413 | ||
1462 | } | 1414 | } |
@@ -1488,7 +1440,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1488 | dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", | 1440 | dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", |
1489 | __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); | 1441 | __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); |
1490 | 1442 | ||
1491 | down(&ctrl->crit_sect); | 1443 | mutex_lock(&ctrl->crit_sect); |
1492 | 1444 | ||
1493 | /* turn on board without attaching to the bus */ | 1445 | /* turn on board without attaching to the bus */ |
1494 | enable_slot_power(ctrl, hp_slot); | 1446 | enable_slot_power(ctrl, hp_slot); |
@@ -1522,7 +1474,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1522 | /* Wait for SOBS to be unset */ | 1474 | /* Wait for SOBS to be unset */ |
1523 | wait_for_ctrl_irq(ctrl); | 1475 | wait_for_ctrl_irq(ctrl); |
1524 | 1476 | ||
1525 | up(&ctrl->crit_sect); | 1477 | mutex_unlock(&ctrl->crit_sect); |
1526 | 1478 | ||
1527 | if (rc) | 1479 | if (rc) |
1528 | return rc; | 1480 | return rc; |
@@ -1532,7 +1484,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1532 | /* turn on board and blink green LED */ | 1484 | /* turn on board and blink green LED */ |
1533 | 1485 | ||
1534 | dbg("%s: before down\n", __FUNCTION__); | 1486 | dbg("%s: before down\n", __FUNCTION__); |
1535 | down(&ctrl->crit_sect); | 1487 | mutex_lock(&ctrl->crit_sect); |
1536 | dbg("%s: after down\n", __FUNCTION__); | 1488 | dbg("%s: after down\n", __FUNCTION__); |
1537 | 1489 | ||
1538 | dbg("%s: before slot_enable\n", __FUNCTION__); | 1490 | dbg("%s: before slot_enable\n", __FUNCTION__); |
@@ -1553,7 +1505,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1553 | dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); | 1505 | dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); |
1554 | 1506 | ||
1555 | dbg("%s: before up\n", __FUNCTION__); | 1507 | dbg("%s: before up\n", __FUNCTION__); |
1556 | up(&ctrl->crit_sect); | 1508 | mutex_unlock(&ctrl->crit_sect); |
1557 | dbg("%s: after up\n", __FUNCTION__); | 1509 | dbg("%s: after up\n", __FUNCTION__); |
1558 | 1510 | ||
1559 | /* Wait for ~1 second because of hot plug spec */ | 1511 | /* Wait for ~1 second because of hot plug spec */ |
@@ -1607,7 +1559,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1607 | cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); | 1559 | cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); |
1608 | 1560 | ||
1609 | if (rc) { | 1561 | if (rc) { |
1610 | down(&ctrl->crit_sect); | 1562 | mutex_lock(&ctrl->crit_sect); |
1611 | 1563 | ||
1612 | amber_LED_on (ctrl, hp_slot); | 1564 | amber_LED_on (ctrl, hp_slot); |
1613 | green_LED_off (ctrl, hp_slot); | 1565 | green_LED_off (ctrl, hp_slot); |
@@ -1618,7 +1570,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1618 | /* Wait for SOBS to be unset */ | 1570 | /* Wait for SOBS to be unset */ |
1619 | wait_for_ctrl_irq (ctrl); | 1571 | wait_for_ctrl_irq (ctrl); |
1620 | 1572 | ||
1621 | up(&ctrl->crit_sect); | 1573 | mutex_unlock(&ctrl->crit_sect); |
1622 | return rc; | 1574 | return rc; |
1623 | } else { | 1575 | } else { |
1624 | cpqhp_save_slot_config(ctrl, func); | 1576 | cpqhp_save_slot_config(ctrl, func); |
@@ -1640,7 +1592,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1640 | } | 1592 | } |
1641 | } while (new_slot); | 1593 | } while (new_slot); |
1642 | 1594 | ||
1643 | down(&ctrl->crit_sect); | 1595 | mutex_lock(&ctrl->crit_sect); |
1644 | 1596 | ||
1645 | green_LED_on (ctrl, hp_slot); | 1597 | green_LED_on (ctrl, hp_slot); |
1646 | 1598 | ||
@@ -1649,9 +1601,9 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1649 | /* Wait for SOBS to be unset */ | 1601 | /* Wait for SOBS to be unset */ |
1650 | wait_for_ctrl_irq (ctrl); | 1602 | wait_for_ctrl_irq (ctrl); |
1651 | 1603 | ||
1652 | up(&ctrl->crit_sect); | 1604 | mutex_unlock(&ctrl->crit_sect); |
1653 | } else { | 1605 | } else { |
1654 | down(&ctrl->crit_sect); | 1606 | mutex_lock(&ctrl->crit_sect); |
1655 | 1607 | ||
1656 | amber_LED_on (ctrl, hp_slot); | 1608 | amber_LED_on (ctrl, hp_slot); |
1657 | green_LED_off (ctrl, hp_slot); | 1609 | green_LED_off (ctrl, hp_slot); |
@@ -1662,7 +1614,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1662 | /* Wait for SOBS to be unset */ | 1614 | /* Wait for SOBS to be unset */ |
1663 | wait_for_ctrl_irq (ctrl); | 1615 | wait_for_ctrl_irq (ctrl); |
1664 | 1616 | ||
1665 | up(&ctrl->crit_sect); | 1617 | mutex_unlock(&ctrl->crit_sect); |
1666 | 1618 | ||
1667 | return rc; | 1619 | return rc; |
1668 | } | 1620 | } |
@@ -1721,7 +1673,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control | |||
1721 | func->status = 0x01; | 1673 | func->status = 0x01; |
1722 | func->configured = 0; | 1674 | func->configured = 0; |
1723 | 1675 | ||
1724 | down(&ctrl->crit_sect); | 1676 | mutex_lock(&ctrl->crit_sect); |
1725 | 1677 | ||
1726 | green_LED_off (ctrl, hp_slot); | 1678 | green_LED_off (ctrl, hp_slot); |
1727 | slot_disable (ctrl, hp_slot); | 1679 | slot_disable (ctrl, hp_slot); |
@@ -1736,7 +1688,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control | |||
1736 | /* Wait for SOBS to be unset */ | 1688 | /* Wait for SOBS to be unset */ |
1737 | wait_for_ctrl_irq (ctrl); | 1689 | wait_for_ctrl_irq (ctrl); |
1738 | 1690 | ||
1739 | up(&ctrl->crit_sect); | 1691 | mutex_unlock(&ctrl->crit_sect); |
1740 | 1692 | ||
1741 | if (!replace_flag && ctrl->add_support) { | 1693 | if (!replace_flag && ctrl->add_support) { |
1742 | while (func) { | 1694 | while (func) { |
@@ -1899,7 +1851,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1899 | dbg("button cancel\n"); | 1851 | dbg("button cancel\n"); |
1900 | del_timer(&p_slot->task_event); | 1852 | del_timer(&p_slot->task_event); |
1901 | 1853 | ||
1902 | down(&ctrl->crit_sect); | 1854 | mutex_lock(&ctrl->crit_sect); |
1903 | 1855 | ||
1904 | if (p_slot->state == BLINKINGOFF_STATE) { | 1856 | if (p_slot->state == BLINKINGOFF_STATE) { |
1905 | /* slot is on */ | 1857 | /* slot is on */ |
@@ -1922,7 +1874,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1922 | /* Wait for SOBS to be unset */ | 1874 | /* Wait for SOBS to be unset */ |
1923 | wait_for_ctrl_irq (ctrl); | 1875 | wait_for_ctrl_irq (ctrl); |
1924 | 1876 | ||
1925 | up(&ctrl->crit_sect); | 1877 | mutex_unlock(&ctrl->crit_sect); |
1926 | } | 1878 | } |
1927 | /*** button Released (No action on press...) */ | 1879 | /*** button Released (No action on press...) */ |
1928 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { | 1880 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { |
@@ -1937,7 +1889,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1937 | p_slot->state = BLINKINGON_STATE; | 1889 | p_slot->state = BLINKINGON_STATE; |
1938 | info(msg_button_on, p_slot->number); | 1890 | info(msg_button_on, p_slot->number); |
1939 | } | 1891 | } |
1940 | down(&ctrl->crit_sect); | 1892 | mutex_lock(&ctrl->crit_sect); |
1941 | 1893 | ||
1942 | dbg("blink green LED and turn off amber\n"); | 1894 | dbg("blink green LED and turn off amber\n"); |
1943 | 1895 | ||
@@ -1949,7 +1901,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1949 | /* Wait for SOBS to be unset */ | 1901 | /* Wait for SOBS to be unset */ |
1950 | wait_for_ctrl_irq (ctrl); | 1902 | wait_for_ctrl_irq (ctrl); |
1951 | 1903 | ||
1952 | up(&ctrl->crit_sect); | 1904 | mutex_unlock(&ctrl->crit_sect); |
1953 | init_timer(&p_slot->task_event); | 1905 | init_timer(&p_slot->task_event); |
1954 | p_slot->hp_slot = hp_slot; | 1906 | p_slot->hp_slot = hp_slot; |
1955 | p_slot->ctrl = ctrl; | 1907 | p_slot->ctrl = ctrl; |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 060d74775d7b..71b80c23e8ce 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c | |||
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev) | |||
95 | struct hotplug_slot *slot; | 95 | struct hotplug_slot *slot; |
96 | int retval = -ENOMEM; | 96 | int retval = -ENOMEM; |
97 | 97 | ||
98 | slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 98 | slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
99 | if (!slot) | 99 | if (!slot) |
100 | goto error; | 100 | goto error; |
101 | memset(slot, 0, sizeof(*slot)); | ||
102 | 101 | ||
103 | slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 102 | slot->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
104 | if (!slot->info) | 103 | if (!slot->info) |
105 | goto error_slot; | 104 | goto error_slot; |
106 | memset(slot->info, 0, sizeof(struct hotplug_slot_info)); | ||
107 | 105 | ||
108 | slot->info->power_status = 1; | 106 | slot->info->power_status = 1; |
109 | slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | 107 | slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; |
@@ -227,11 +225,10 @@ static void pci_rescan_bus(const struct pci_bus *bus) | |||
227 | { | 225 | { |
228 | unsigned int devfn; | 226 | unsigned int devfn; |
229 | struct pci_dev *dev; | 227 | struct pci_dev *dev; |
230 | dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); | 228 | dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); |
231 | if (!dev) | 229 | if (!dev) |
232 | return; | 230 | return; |
233 | 231 | ||
234 | memset(dev, 0, sizeof(dev)); | ||
235 | dev->bus = (struct pci_bus*)bus; | 232 | dev->bus = (struct pci_bus*)bus; |
236 | dev->sysdata = bus->sysdata; | 233 | dev->sysdata = bus->sysdata; |
237 | for (devfn = 0; devfn < 0x100; devfn += 8) { | 234 | for (devfn = 0; devfn < 0x100; devfn += 8) { |
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h index c22e0284d7b1..dba6d8ca9bda 100644 --- a/drivers/pci/hotplug/ibmphp.h +++ b/drivers/pci/hotplug/ibmphp.h | |||
@@ -406,8 +406,6 @@ extern void ibmphp_hpc_stop_poll_thread (void); | |||
406 | //---------------------------------------------------------------------------- | 406 | //---------------------------------------------------------------------------- |
407 | // HPC return codes | 407 | // HPC return codes |
408 | //---------------------------------------------------------------------------- | 408 | //---------------------------------------------------------------------------- |
409 | #define FALSE 0x00 | ||
410 | #define TRUE 0x01 | ||
411 | #define HPC_ERROR 0xFF | 409 | #define HPC_ERROR 0xFF |
412 | 410 | ||
413 | //----------------------------------------------------------------------------- | 411 | //----------------------------------------------------------------------------- |
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index dc59da675c08..e13d5b87241a 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_slot *hs) | |||
1141 | goto error_power; | 1141 | goto error_power; |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL); | 1144 | slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); |
1145 | if (!slot_cur->func) { | 1145 | if (!slot_cur->func) { |
1146 | /* We cannot do update_slot_info here, since no memory for | 1146 | /* We cannot do update_slot_info here, since no memory for |
1147 | * kmalloc n.e.ways, and update_slot_info allocates some */ | 1147 | * kmalloc n.e.ways, and update_slot_info allocates some */ |
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_slot *hs) | |||
1149 | rc = -ENOMEM; | 1149 | rc = -ENOMEM; |
1150 | goto error_power; | 1150 | goto error_power; |
1151 | } | 1151 | } |
1152 | memset(slot_cur->func, 0, sizeof(struct pci_func)); | ||
1153 | slot_cur->func->busno = slot_cur->bus; | 1152 | slot_cur->func->busno = slot_cur->bus; |
1154 | slot_cur->func->device = slot_cur->device; | 1153 | slot_cur->func->device = slot_cur->device; |
1155 | for (i = 0; i < 4; i++) | 1154 | for (i = 0; i < 4; i++) |
@@ -1240,9 +1239,9 @@ int ibmphp_do_disable_slot(struct slot *slot_cur) | |||
1240 | } | 1239 | } |
1241 | 1240 | ||
1242 | flag = slot_cur->flag; | 1241 | flag = slot_cur->flag; |
1243 | slot_cur->flag = TRUE; | 1242 | slot_cur->flag = 1; |
1244 | 1243 | ||
1245 | if (flag == TRUE) { | 1244 | if (flag == 1) { |
1246 | rc = validate(slot_cur, DISABLE); | 1245 | rc = validate(slot_cur, DISABLE); |
1247 | /* checking if powered off already & valid slot # */ | 1246 | /* checking if powered off already & valid slot # */ |
1248 | if (rc) | 1247 | if (rc) |
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *slot_cur) | |||
1252 | 1251 | ||
1253 | if (slot_cur->func == NULL) { | 1252 | if (slot_cur->func == NULL) { |
1254 | /* We need this for fncs's that were there on bootup */ | 1253 | /* We need this for fncs's that were there on bootup */ |
1255 | slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL); | 1254 | slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); |
1256 | if (!slot_cur->func) { | 1255 | if (!slot_cur->func) { |
1257 | err("out of system memory\n"); | 1256 | err("out of system memory\n"); |
1258 | rc = -ENOMEM; | 1257 | rc = -ENOMEM; |
1259 | goto error; | 1258 | goto error; |
1260 | } | 1259 | } |
1261 | memset(slot_cur->func, 0, sizeof(struct pci_func)); | ||
1262 | slot_cur->func->busno = slot_cur->bus; | 1260 | slot_cur->func->busno = slot_cur->bus; |
1263 | slot_cur->func->device = slot_cur->device; | 1261 | slot_cur->func->device = slot_cur->device; |
1264 | } | 1262 | } |
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index aea1187c73ad..05e4f5a1927a 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -72,13 +72,7 @@ static int ebda_rio_table (void); | |||
72 | 72 | ||
73 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) | 73 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) |
74 | { | 74 | { |
75 | struct ebda_hpc_list *list; | 75 | return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); |
76 | |||
77 | list = kmalloc (sizeof (struct ebda_hpc_list), GFP_KERNEL); | ||
78 | if (!list) | ||
79 | return NULL; | ||
80 | memset (list, 0, sizeof (*list)); | ||
81 | return list; | ||
82 | } | 76 | } |
83 | 77 | ||
84 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | 78 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) |
@@ -87,21 +81,18 @@ static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | |||
87 | struct ebda_hpc_slot *slots; | 81 | struct ebda_hpc_slot *slots; |
88 | struct ebda_hpc_bus *buses; | 82 | struct ebda_hpc_bus *buses; |
89 | 83 | ||
90 | controller = kmalloc (sizeof (struct controller), GFP_KERNEL); | 84 | controller = kzalloc(sizeof(struct controller), GFP_KERNEL); |
91 | if (!controller) | 85 | if (!controller) |
92 | goto error; | 86 | goto error; |
93 | memset (controller, 0, sizeof (*controller)); | ||
94 | 87 | ||
95 | slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL); | 88 | slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL); |
96 | if (!slots) | 89 | if (!slots) |
97 | goto error_contr; | 90 | goto error_contr; |
98 | memset (slots, 0, sizeof (*slots) * slot_count); | ||
99 | controller->slots = slots; | 91 | controller->slots = slots; |
100 | 92 | ||
101 | buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL); | 93 | buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL); |
102 | if (!buses) | 94 | if (!buses) |
103 | goto error_slots; | 95 | goto error_slots; |
104 | memset (buses, 0, sizeof (*buses) * bus_count); | ||
105 | controller->buses = buses; | 96 | controller->buses = buses; |
106 | 97 | ||
107 | return controller; | 98 | return controller; |
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct controller *controller) | |||
122 | 113 | ||
123 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) | 114 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) |
124 | { | 115 | { |
125 | struct ebda_rsrc_list *list; | 116 | return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); |
126 | |||
127 | list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL); | ||
128 | if (!list) | ||
129 | return NULL; | ||
130 | memset (list, 0, sizeof (*list)); | ||
131 | return list; | ||
132 | } | 117 | } |
133 | 118 | ||
134 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) | 119 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) |
135 | { | 120 | { |
136 | struct ebda_pci_rsrc *resource; | 121 | return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); |
137 | |||
138 | resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL); | ||
139 | if (!resource) | ||
140 | return NULL; | ||
141 | memset (resource, 0, sizeof (*resource)); | ||
142 | return resource; | ||
143 | } | 122 | } |
144 | 123 | ||
145 | static void __init print_bus_info (void) | 124 | static void __init print_bus_info (void) |
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void) | |||
390 | debug ("now enter io table ---\n"); | 369 | debug ("now enter io table ---\n"); |
391 | debug ("rio blk id: %x\n", blk_id); | 370 | debug ("rio blk id: %x\n", blk_id); |
392 | 371 | ||
393 | rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL); | 372 | rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); |
394 | if (!rio_table_ptr) | 373 | if (!rio_table_ptr) |
395 | return -ENOMEM; | 374 | return -ENOMEM; |
396 | memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) ); | ||
397 | rio_table_ptr->ver_num = readb (io_mem + offset); | 375 | rio_table_ptr->ver_num = readb (io_mem + offset); |
398 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); | 376 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); |
399 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); | 377 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); |
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void) | |||
445 | 423 | ||
446 | // we do concern about rio details | 424 | // we do concern about rio details |
447 | for (i = 0; i < rio_table_ptr->riodev_count; i++) { | 425 | for (i = 0; i < rio_table_ptr->riodev_count; i++) { |
448 | rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL); | 426 | rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); |
449 | if (!rio_detail_ptr) | 427 | if (!rio_detail_ptr) |
450 | return -ENOMEM; | 428 | return -ENOMEM; |
451 | memset (rio_detail_ptr, 0, sizeof (struct rio_detail)); | ||
452 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); | 429 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); |
453 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); | 430 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); |
454 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); | 431 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); |
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassis (void) | |||
503 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | 480 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); |
504 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); | 481 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); |
505 | if (!opt_rio_ptr) { | 482 | if (!opt_rio_ptr) { |
506 | opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL); | 483 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); |
507 | if (!opt_rio_ptr) | 484 | if (!opt_rio_ptr) |
508 | return -ENOMEM; | 485 | return -ENOMEM; |
509 | memset (opt_rio_ptr, 0, sizeof (struct opt_rio)); | ||
510 | opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; | 486 | opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; |
511 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; | 487 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; |
512 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 488 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (void) | |||
546 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | 522 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); |
547 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); | 523 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); |
548 | if (!opt_rio_lo_ptr) { | 524 | if (!opt_rio_lo_ptr) { |
549 | opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL); | 525 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); |
550 | if (!opt_rio_lo_ptr) | 526 | if (!opt_rio_lo_ptr) |
551 | return -ENOMEM; | 527 | return -ENOMEM; |
552 | memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo)); | ||
553 | opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; | 528 | opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; |
554 | opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; | 529 | opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; |
555 | opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 530 | opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (void) | |||
842 | 817 | ||
843 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); | 818 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); |
844 | if (!bus_info_ptr2) { | 819 | if (!bus_info_ptr2) { |
845 | bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL); | 820 | bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); |
846 | if (!bus_info_ptr1) { | 821 | if (!bus_info_ptr1) { |
847 | rc = -ENOMEM; | 822 | rc = -ENOMEM; |
848 | goto error_no_hp_slot; | 823 | goto error_no_hp_slot; |
849 | } | 824 | } |
850 | memset (bus_info_ptr1, 0, sizeof (struct bus_info)); | ||
851 | bus_info_ptr1->slot_min = slot_ptr->slot_num; | 825 | bus_info_ptr1->slot_min = slot_ptr->slot_num; |
852 | bus_info_ptr1->slot_max = slot_ptr->slot_num; | 826 | bus_info_ptr1->slot_max = slot_ptr->slot_num; |
853 | bus_info_ptr1->slot_count += 1; | 827 | bus_info_ptr1->slot_count += 1; |
@@ -946,19 +920,17 @@ static int __init ebda_rsrc_controller (void) | |||
946 | // register slots with hpc core as well as create linked list of ibm slot | 920 | // register slots with hpc core as well as create linked list of ibm slot |
947 | for (index = 0; index < hpc_ptr->slot_count; index++) { | 921 | for (index = 0; index < hpc_ptr->slot_count; index++) { |
948 | 922 | ||
949 | hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); | 923 | hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); |
950 | if (!hp_slot_ptr) { | 924 | if (!hp_slot_ptr) { |
951 | rc = -ENOMEM; | 925 | rc = -ENOMEM; |
952 | goto error_no_hp_slot; | 926 | goto error_no_hp_slot; |
953 | } | 927 | } |
954 | memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr)); | ||
955 | 928 | ||
956 | hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL); | 929 | hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
957 | if (!hp_slot_ptr->info) { | 930 | if (!hp_slot_ptr->info) { |
958 | rc = -ENOMEM; | 931 | rc = -ENOMEM; |
959 | goto error_no_hp_info; | 932 | goto error_no_hp_info; |
960 | } | 933 | } |
961 | memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info)); | ||
962 | 934 | ||
963 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); | 935 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); |
964 | if (!hp_slot_ptr->name) { | 936 | if (!hp_slot_ptr->name) { |
@@ -966,14 +938,13 @@ static int __init ebda_rsrc_controller (void) | |||
966 | goto error_no_hp_name; | 938 | goto error_no_hp_name; |
967 | } | 939 | } |
968 | 940 | ||
969 | tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL); | 941 | tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); |
970 | if (!tmp_slot) { | 942 | if (!tmp_slot) { |
971 | rc = -ENOMEM; | 943 | rc = -ENOMEM; |
972 | goto error_no_slot; | 944 | goto error_no_slot; |
973 | } | 945 | } |
974 | memset(tmp_slot, 0, sizeof(*tmp_slot)); | ||
975 | 946 | ||
976 | tmp_slot->flag = TRUE; | 947 | tmp_slot->flag = 1; |
977 | 948 | ||
978 | tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap; | 949 | tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap; |
979 | if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX) | 950 | if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX) |
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c index 1a3eb8d3d4cb..c3ac98a0a6a6 100644 --- a/drivers/pci/hotplug/ibmphp_hpc.c +++ b/drivers/pci/hotplug/ibmphp_hpc.c | |||
@@ -34,9 +34,11 @@ | |||
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/smp_lock.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/mutex.h> | ||
38 | |||
37 | #include "ibmphp.h" | 39 | #include "ibmphp.h" |
38 | 40 | ||
39 | static int to_debug = FALSE; | 41 | static int to_debug = 0; |
40 | #define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) | 42 | #define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) |
41 | 43 | ||
42 | //---------------------------------------------------------------------------- | 44 | //---------------------------------------------------------------------------- |
@@ -93,15 +95,15 @@ static int to_debug = FALSE; | |||
93 | //---------------------------------------------------------------------------- | 95 | //---------------------------------------------------------------------------- |
94 | // macro utilities | 96 | // macro utilities |
95 | //---------------------------------------------------------------------------- | 97 | //---------------------------------------------------------------------------- |
96 | // if bits 20,22,25,26,27,29,30 are OFF return TRUE | 98 | // if bits 20,22,25,26,27,29,30 are OFF return 1 |
97 | #define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? FALSE : TRUE)) | 99 | #define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? 0 : 1)) |
98 | 100 | ||
99 | //---------------------------------------------------------------------------- | 101 | //---------------------------------------------------------------------------- |
100 | // global variables | 102 | // global variables |
101 | //---------------------------------------------------------------------------- | 103 | //---------------------------------------------------------------------------- |
102 | static int ibmphp_shutdown; | 104 | static int ibmphp_shutdown; |
103 | static int tid_poll; | 105 | static int tid_poll; |
104 | static struct semaphore sem_hpcaccess; // lock access to HPC | 106 | static struct mutex sem_hpcaccess; // lock access to HPC |
105 | static struct semaphore semOperations; // lock all operations and | 107 | static struct semaphore semOperations; // lock all operations and |
106 | // access to data structures | 108 | // access to data structures |
107 | static struct semaphore sem_exit; // make sure polling thread goes away | 109 | static struct semaphore sem_exit; // make sure polling thread goes away |
@@ -131,11 +133,11 @@ void __init ibmphp_hpc_initvars (void) | |||
131 | { | 133 | { |
132 | debug ("%s - Entry\n", __FUNCTION__); | 134 | debug ("%s - Entry\n", __FUNCTION__); |
133 | 135 | ||
134 | init_MUTEX (&sem_hpcaccess); | 136 | mutex_init(&sem_hpcaccess); |
135 | init_MUTEX (&semOperations); | 137 | init_MUTEX (&semOperations); |
136 | init_MUTEX_LOCKED (&sem_exit); | 138 | init_MUTEX_LOCKED (&sem_exit); |
137 | to_debug = FALSE; | 139 | to_debug = 0; |
138 | ibmphp_shutdown = FALSE; | 140 | ibmphp_shutdown = 0; |
139 | tid_poll = 0; | 141 | tid_poll = 0; |
140 | 142 | ||
141 | debug ("%s - Exit\n", __FUNCTION__); | 143 | debug ("%s - Exit\n", __FUNCTION__); |
@@ -737,21 +739,21 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) | |||
737 | // check controller is still not working on the command | 739 | // check controller is still not working on the command |
738 | //-------------------------------------------------------------------- | 740 | //-------------------------------------------------------------------- |
739 | timeout = CMD_COMPLETE_TOUT_SEC; | 741 | timeout = CMD_COMPLETE_TOUT_SEC; |
740 | done = FALSE; | 742 | done = 0; |
741 | while (!done) { | 743 | while (!done) { |
742 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, | 744 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, |
743 | &status); | 745 | &status); |
744 | if (!rc) { | 746 | if (!rc) { |
745 | if (NEEDTOCHECK_CMDSTATUS (cmd)) { | 747 | if (NEEDTOCHECK_CMDSTATUS (cmd)) { |
746 | if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) | 748 | if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) |
747 | done = TRUE; | 749 | done = 1; |
748 | } else | 750 | } else |
749 | done = TRUE; | 751 | done = 1; |
750 | } | 752 | } |
751 | if (!done) { | 753 | if (!done) { |
752 | msleep(1000); | 754 | msleep(1000); |
753 | if (timeout < 1) { | 755 | if (timeout < 1) { |
754 | done = TRUE; | 756 | done = 1; |
755 | err ("%s - Error command complete timeout\n", __FUNCTION__); | 757 | err ("%s - Error command complete timeout\n", __FUNCTION__); |
756 | rc = -EFAULT; | 758 | rc = -EFAULT; |
757 | } else | 759 | } else |
@@ -778,7 +780,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) | |||
778 | *---------------------------------------------------------------------*/ | 780 | *---------------------------------------------------------------------*/ |
779 | static void get_hpc_access (void) | 781 | static void get_hpc_access (void) |
780 | { | 782 | { |
781 | down (&sem_hpcaccess); | 783 | mutex_lock(&sem_hpcaccess); |
782 | } | 784 | } |
783 | 785 | ||
784 | /*---------------------------------------------------------------------- | 786 | /*---------------------------------------------------------------------- |
@@ -786,7 +788,7 @@ static void get_hpc_access (void) | |||
786 | *---------------------------------------------------------------------*/ | 788 | *---------------------------------------------------------------------*/ |
787 | void free_hpc_access (void) | 789 | void free_hpc_access (void) |
788 | { | 790 | { |
789 | up (&sem_hpcaccess); | 791 | mutex_unlock(&sem_hpcaccess); |
790 | } | 792 | } |
791 | 793 | ||
792 | /*---------------------------------------------------------------------- | 794 | /*---------------------------------------------------------------------- |
@@ -797,7 +799,7 @@ void free_hpc_access (void) | |||
797 | void ibmphp_lock_operations (void) | 799 | void ibmphp_lock_operations (void) |
798 | { | 800 | { |
799 | down (&semOperations); | 801 | down (&semOperations); |
800 | to_debug = TRUE; | 802 | to_debug = 1; |
801 | } | 803 | } |
802 | 804 | ||
803 | /*---------------------------------------------------------------------- | 805 | /*---------------------------------------------------------------------- |
@@ -807,7 +809,7 @@ void ibmphp_unlock_operations (void) | |||
807 | { | 809 | { |
808 | debug ("%s - Entry\n", __FUNCTION__); | 810 | debug ("%s - Entry\n", __FUNCTION__); |
809 | up (&semOperations); | 811 | up (&semOperations); |
810 | to_debug = FALSE; | 812 | to_debug = 0; |
811 | debug ("%s - Exit\n", __FUNCTION__); | 813 | debug ("%s - Exit\n", __FUNCTION__); |
812 | } | 814 | } |
813 | 815 | ||
@@ -935,40 +937,40 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
935 | { | 937 | { |
936 | u8 status; | 938 | u8 status; |
937 | int rc = 0; | 939 | int rc = 0; |
938 | u8 disable = FALSE; | 940 | u8 disable = 0; |
939 | u8 update = FALSE; | 941 | u8 update = 0; |
940 | 942 | ||
941 | debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); | 943 | debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); |
942 | 944 | ||
943 | // bit 0 - HPC_SLOT_POWER | 945 | // bit 0 - HPC_SLOT_POWER |
944 | if ((pslot->status & 0x01) != (poldslot->status & 0x01)) | 946 | if ((pslot->status & 0x01) != (poldslot->status & 0x01)) |
945 | update = TRUE; | 947 | update = 1; |
946 | 948 | ||
947 | // bit 1 - HPC_SLOT_CONNECT | 949 | // bit 1 - HPC_SLOT_CONNECT |
948 | // ignore | 950 | // ignore |
949 | 951 | ||
950 | // bit 2 - HPC_SLOT_ATTN | 952 | // bit 2 - HPC_SLOT_ATTN |
951 | if ((pslot->status & 0x04) != (poldslot->status & 0x04)) | 953 | if ((pslot->status & 0x04) != (poldslot->status & 0x04)) |
952 | update = TRUE; | 954 | update = 1; |
953 | 955 | ||
954 | // bit 3 - HPC_SLOT_PRSNT2 | 956 | // bit 3 - HPC_SLOT_PRSNT2 |
955 | // bit 4 - HPC_SLOT_PRSNT1 | 957 | // bit 4 - HPC_SLOT_PRSNT1 |
956 | if (((pslot->status & 0x08) != (poldslot->status & 0x08)) | 958 | if (((pslot->status & 0x08) != (poldslot->status & 0x08)) |
957 | || ((pslot->status & 0x10) != (poldslot->status & 0x10))) | 959 | || ((pslot->status & 0x10) != (poldslot->status & 0x10))) |
958 | update = TRUE; | 960 | update = 1; |
959 | 961 | ||
960 | // bit 5 - HPC_SLOT_PWRGD | 962 | // bit 5 - HPC_SLOT_PWRGD |
961 | if ((pslot->status & 0x20) != (poldslot->status & 0x20)) | 963 | if ((pslot->status & 0x20) != (poldslot->status & 0x20)) |
962 | // OFF -> ON: ignore, ON -> OFF: disable slot | 964 | // OFF -> ON: ignore, ON -> OFF: disable slot |
963 | if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) | 965 | if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) |
964 | disable = TRUE; | 966 | disable = 1; |
965 | 967 | ||
966 | // bit 6 - HPC_SLOT_BUS_SPEED | 968 | // bit 6 - HPC_SLOT_BUS_SPEED |
967 | // ignore | 969 | // ignore |
968 | 970 | ||
969 | // bit 7 - HPC_SLOT_LATCH | 971 | // bit 7 - HPC_SLOT_LATCH |
970 | if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { | 972 | if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { |
971 | update = TRUE; | 973 | update = 1; |
972 | // OPEN -> CLOSE | 974 | // OPEN -> CLOSE |
973 | if (pslot->status & 0x80) { | 975 | if (pslot->status & 0x80) { |
974 | if (SLOT_PWRGD (pslot->status)) { | 976 | if (SLOT_PWRGD (pslot->status)) { |
@@ -977,7 +979,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
977 | msleep(1000); | 979 | msleep(1000); |
978 | rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); | 980 | rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); |
979 | if (SLOT_PWRGD (status)) | 981 | if (SLOT_PWRGD (status)) |
980 | update = TRUE; | 982 | update = 1; |
981 | else // overwrite power in pslot to OFF | 983 | else // overwrite power in pslot to OFF |
982 | pslot->status &= ~HPC_SLOT_POWER; | 984 | pslot->status &= ~HPC_SLOT_POWER; |
983 | } | 985 | } |
@@ -985,17 +987,17 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
985 | // CLOSE -> OPEN | 987 | // CLOSE -> OPEN |
986 | else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) | 988 | else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) |
987 | && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { | 989 | && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { |
988 | disable = TRUE; | 990 | disable = 1; |
989 | } | 991 | } |
990 | // else - ignore | 992 | // else - ignore |
991 | } | 993 | } |
992 | // bit 4 - HPC_SLOT_BLINK_ATTN | 994 | // bit 4 - HPC_SLOT_BLINK_ATTN |
993 | if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) | 995 | if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) |
994 | update = TRUE; | 996 | update = 1; |
995 | 997 | ||
996 | if (disable) { | 998 | if (disable) { |
997 | debug ("process_changeinstatus - disable slot\n"); | 999 | debug ("process_changeinstatus - disable slot\n"); |
998 | pslot->flag = FALSE; | 1000 | pslot->flag = 0; |
999 | rc = ibmphp_do_disable_slot (pslot); | 1001 | rc = ibmphp_do_disable_slot (pslot); |
1000 | } | 1002 | } |
1001 | 1003 | ||
@@ -1100,7 +1102,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void) | |||
1100 | { | 1102 | { |
1101 | debug ("%s - Entry\n", __FUNCTION__); | 1103 | debug ("%s - Entry\n", __FUNCTION__); |
1102 | 1104 | ||
1103 | ibmphp_shutdown = TRUE; | 1105 | ibmphp_shutdown = 1; |
1104 | debug ("before locking operations \n"); | 1106 | debug ("before locking operations \n"); |
1105 | ibmphp_lock_operations (); | 1107 | ibmphp_lock_operations (); |
1106 | debug ("after locking operations \n"); | 1108 | debug ("after locking operations \n"); |
@@ -1134,7 +1136,7 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v | |||
1134 | u8 * pstatus) | 1136 | u8 * pstatus) |
1135 | { | 1137 | { |
1136 | int rc = 0; | 1138 | int rc = 0; |
1137 | u8 done = FALSE; | 1139 | u8 done = 0; |
1138 | 1140 | ||
1139 | debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); | 1141 | debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); |
1140 | 1142 | ||
@@ -1142,14 +1144,14 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v | |||
1142 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); | 1144 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); |
1143 | if (*pstatus == HPC_ERROR) { | 1145 | if (*pstatus == HPC_ERROR) { |
1144 | rc = HPC_ERROR; | 1146 | rc = HPC_ERROR; |
1145 | done = TRUE; | 1147 | done = 1; |
1146 | } | 1148 | } |
1147 | if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) | 1149 | if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) |
1148 | done = TRUE; | 1150 | done = 1; |
1149 | if (!done) { | 1151 | if (!done) { |
1150 | msleep(1000); | 1152 | msleep(1000); |
1151 | if (timeout < 1) { | 1153 | if (timeout < 1) { |
1152 | done = TRUE; | 1154 | done = 1; |
1153 | err ("HPCreadslot - Error ctlr timeout\n"); | 1155 | err ("HPCreadslot - Error ctlr timeout\n"); |
1154 | rc = HPC_ERROR; | 1156 | rc = HPC_ERROR; |
1155 | } else | 1157 | } else |
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index 155133fe5c12..d87a9e3eaeeb 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c | |||
@@ -164,12 +164,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
164 | cleanup_count = 6; | 164 | cleanup_count = 6; |
165 | goto error; | 165 | goto error; |
166 | } | 166 | } |
167 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 167 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
168 | if (!newfunc) { | 168 | if (!newfunc) { |
169 | err ("out of system memory\n"); | 169 | err ("out of system memory\n"); |
170 | return -ENOMEM; | 170 | return -ENOMEM; |
171 | } | 171 | } |
172 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
173 | newfunc->busno = cur_func->busno; | 172 | newfunc->busno = cur_func->busno; |
174 | newfunc->device = device; | 173 | newfunc->device = device; |
175 | cur_func->next = newfunc; | 174 | cur_func->next = newfunc; |
@@ -200,15 +199,14 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
200 | } | 199 | } |
201 | 200 | ||
202 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 201 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
203 | flag = FALSE; | 202 | flag = 0; |
204 | for (i = 0; i < 32; i++) { | 203 | for (i = 0; i < 32; i++) { |
205 | if (func->devices[i]) { | 204 | if (func->devices[i]) { |
206 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 205 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
207 | if (!newfunc) { | 206 | if (!newfunc) { |
208 | err ("out of system memory\n"); | 207 | err ("out of system memory\n"); |
209 | return -ENOMEM; | 208 | return -ENOMEM; |
210 | } | 209 | } |
211 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
212 | newfunc->busno = sec_number; | 210 | newfunc->busno = sec_number; |
213 | newfunc->device = (u8) i; | 211 | newfunc->device = (u8) i; |
214 | for (j = 0; j < 4; j++) | 212 | for (j = 0; j < 4; j++) |
@@ -228,16 +226,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
228 | cleanup_count = 2; | 226 | cleanup_count = 2; |
229 | goto error; | 227 | goto error; |
230 | } | 228 | } |
231 | flag = TRUE; | 229 | flag = 1; |
232 | } | 230 | } |
233 | } | 231 | } |
234 | 232 | ||
235 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 233 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
236 | if (!newfunc) { | 234 | if (!newfunc) { |
237 | err ("out of system memory\n"); | 235 | err ("out of system memory\n"); |
238 | return -ENOMEM; | 236 | return -ENOMEM; |
239 | } | 237 | } |
240 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
241 | newfunc->busno = cur_func->busno; | 238 | newfunc->busno = cur_func->busno; |
242 | newfunc->device = device; | 239 | newfunc->device = device; |
243 | for (j = 0; j < 4; j++) | 240 | for (j = 0; j < 4; j++) |
@@ -275,16 +272,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
275 | cur_func->busno, device, function); | 272 | cur_func->busno, device, function); |
276 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 273 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
277 | debug ("after configuring bridge..., sec_number = %x\n", sec_number); | 274 | debug ("after configuring bridge..., sec_number = %x\n", sec_number); |
278 | flag = FALSE; | 275 | flag = 0; |
279 | for (i = 0; i < 32; i++) { | 276 | for (i = 0; i < 32; i++) { |
280 | if (func->devices[i]) { | 277 | if (func->devices[i]) { |
281 | debug ("inside for loop, device is %x\n", i); | 278 | debug ("inside for loop, device is %x\n", i); |
282 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 279 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
283 | if (!newfunc) { | 280 | if (!newfunc) { |
284 | err (" out of system memory\n"); | 281 | err (" out of system memory\n"); |
285 | return -ENOMEM; | 282 | return -ENOMEM; |
286 | } | 283 | } |
287 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
288 | newfunc->busno = sec_number; | 284 | newfunc->busno = sec_number; |
289 | newfunc->device = (u8) i; | 285 | newfunc->device = (u8) i; |
290 | for (j = 0; j < 4; j++) | 286 | for (j = 0; j < 4; j++) |
@@ -305,7 +301,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
305 | cleanup_count = 2; | 301 | cleanup_count = 2; |
306 | goto error; | 302 | goto error; |
307 | } | 303 | } |
308 | flag = TRUE; | 304 | flag = 1; |
309 | } | 305 | } |
310 | } | 306 | } |
311 | 307 | ||
@@ -405,13 +401,12 @@ static int configure_device (struct pci_func *func) | |||
405 | 401 | ||
406 | debug ("len[count] in IO %x, count %d\n", len[count], count); | 402 | debug ("len[count] in IO %x, count %d\n", len[count], count); |
407 | 403 | ||
408 | io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 404 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
409 | 405 | ||
410 | if (!io[count]) { | 406 | if (!io[count]) { |
411 | err ("out of system memory\n"); | 407 | err ("out of system memory\n"); |
412 | return -ENOMEM; | 408 | return -ENOMEM; |
413 | } | 409 | } |
414 | memset (io[count], 0, sizeof (struct resource_node)); | ||
415 | io[count]->type = IO; | 410 | io[count]->type = IO; |
416 | io[count]->busno = func->busno; | 411 | io[count]->busno = func->busno; |
417 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); | 412 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); |
@@ -444,29 +439,27 @@ static int configure_device (struct pci_func *func) | |||
444 | 439 | ||
445 | debug ("len[count] in PFMEM %x, count %d\n", len[count], count); | 440 | debug ("len[count] in PFMEM %x, count %d\n", len[count], count); |
446 | 441 | ||
447 | pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 442 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
448 | if (!pfmem[count]) { | 443 | if (!pfmem[count]) { |
449 | err ("out of system memory\n"); | 444 | err ("out of system memory\n"); |
450 | return -ENOMEM; | 445 | return -ENOMEM; |
451 | } | 446 | } |
452 | memset (pfmem[count], 0, sizeof (struct resource_node)); | ||
453 | pfmem[count]->type = PFMEM; | 447 | pfmem[count]->type = PFMEM; |
454 | pfmem[count]->busno = func->busno; | 448 | pfmem[count]->busno = func->busno; |
455 | pfmem[count]->devfunc = PCI_DEVFN(func->device, | 449 | pfmem[count]->devfunc = PCI_DEVFN(func->device, |
456 | func->function); | 450 | func->function); |
457 | pfmem[count]->len = len[count]; | 451 | pfmem[count]->len = len[count]; |
458 | pfmem[count]->fromMem = FALSE; | 452 | pfmem[count]->fromMem = 0; |
459 | if (ibmphp_check_resource (pfmem[count], 0) == 0) { | 453 | if (ibmphp_check_resource (pfmem[count], 0) == 0) { |
460 | ibmphp_add_resource (pfmem[count]); | 454 | ibmphp_add_resource (pfmem[count]); |
461 | func->pfmem[count] = pfmem[count]; | 455 | func->pfmem[count] = pfmem[count]; |
462 | } else { | 456 | } else { |
463 | mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); | 457 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
464 | if (!mem_tmp) { | 458 | if (!mem_tmp) { |
465 | err ("out of system memory\n"); | 459 | err ("out of system memory\n"); |
466 | kfree (pfmem[count]); | 460 | kfree (pfmem[count]); |
467 | return -ENOMEM; | 461 | return -ENOMEM; |
468 | } | 462 | } |
469 | memset (mem_tmp, 0, sizeof (struct resource_node)); | ||
470 | mem_tmp->type = MEM; | 463 | mem_tmp->type = MEM; |
471 | mem_tmp->busno = pfmem[count]->busno; | 464 | mem_tmp->busno = pfmem[count]->busno; |
472 | mem_tmp->devfunc = pfmem[count]->devfunc; | 465 | mem_tmp->devfunc = pfmem[count]->devfunc; |
@@ -474,7 +467,7 @@ static int configure_device (struct pci_func *func) | |||
474 | debug ("there's no pfmem... going into mem.\n"); | 467 | debug ("there's no pfmem... going into mem.\n"); |
475 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 468 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { |
476 | ibmphp_add_resource (mem_tmp); | 469 | ibmphp_add_resource (mem_tmp); |
477 | pfmem[count]->fromMem = TRUE; | 470 | pfmem[count]->fromMem = 1; |
478 | pfmem[count]->rangeno = mem_tmp->rangeno; | 471 | pfmem[count]->rangeno = mem_tmp->rangeno; |
479 | pfmem[count]->start = mem_tmp->start; | 472 | pfmem[count]->start = mem_tmp->start; |
480 | pfmem[count]->end = mem_tmp->end; | 473 | pfmem[count]->end = mem_tmp->end; |
@@ -512,12 +505,11 @@ static int configure_device (struct pci_func *func) | |||
512 | 505 | ||
513 | debug ("len[count] in Mem %x, count %d\n", len[count], count); | 506 | debug ("len[count] in Mem %x, count %d\n", len[count], count); |
514 | 507 | ||
515 | mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 508 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
516 | if (!mem[count]) { | 509 | if (!mem[count]) { |
517 | err ("out of system memory\n"); | 510 | err ("out of system memory\n"); |
518 | return -ENOMEM; | 511 | return -ENOMEM; |
519 | } | 512 | } |
520 | memset (mem[count], 0, sizeof (struct resource_node)); | ||
521 | mem[count]->type = MEM; | 513 | mem[count]->type = MEM; |
522 | mem[count]->busno = func->busno; | 514 | mem[count]->busno = func->busno; |
523 | mem[count]->devfunc = PCI_DEVFN(func->device, | 515 | mem[count]->devfunc = PCI_DEVFN(func->device, |
@@ -579,11 +571,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
579 | u16 pfmem_base; | 571 | u16 pfmem_base; |
580 | u32 bar[2]; | 572 | u32 bar[2]; |
581 | u32 len[2]; | 573 | u32 len[2]; |
582 | u8 flag_io = FALSE; | 574 | u8 flag_io = 0; |
583 | u8 flag_mem = FALSE; | 575 | u8 flag_mem = 0; |
584 | u8 flag_pfmem = FALSE; | 576 | u8 flag_pfmem = 0; |
585 | u8 need_io_upper = FALSE; | 577 | u8 need_io_upper = 0; |
586 | u8 need_pfmem_upper = FALSE; | 578 | u8 need_pfmem_upper = 0; |
587 | struct res_needed *amount_needed = NULL; | 579 | struct res_needed *amount_needed = NULL; |
588 | struct resource_node *io = NULL; | 580 | struct resource_node *io = NULL; |
589 | struct resource_node *bus_io[2] = {NULL, NULL}; | 581 | struct resource_node *bus_io[2] = {NULL, NULL}; |
@@ -677,14 +669,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
677 | 669 | ||
678 | debug ("len[count] in IO = %x\n", len[count]); | 670 | debug ("len[count] in IO = %x\n", len[count]); |
679 | 671 | ||
680 | bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 672 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
681 | 673 | ||
682 | if (!bus_io[count]) { | 674 | if (!bus_io[count]) { |
683 | err ("out of system memory\n"); | 675 | err ("out of system memory\n"); |
684 | retval = -ENOMEM; | 676 | retval = -ENOMEM; |
685 | goto error; | 677 | goto error; |
686 | } | 678 | } |
687 | memset (bus_io[count], 0, sizeof (struct resource_node)); | ||
688 | bus_io[count]->type = IO; | 679 | bus_io[count]->type = IO; |
689 | bus_io[count]->busno = func->busno; | 680 | bus_io[count]->busno = func->busno; |
690 | bus_io[count]->devfunc = PCI_DEVFN(func->device, | 681 | bus_io[count]->devfunc = PCI_DEVFN(func->device, |
@@ -711,37 +702,35 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
711 | 702 | ||
712 | debug ("len[count] in PFMEM = %x\n", len[count]); | 703 | debug ("len[count] in PFMEM = %x\n", len[count]); |
713 | 704 | ||
714 | bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 705 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
715 | if (!bus_pfmem[count]) { | 706 | if (!bus_pfmem[count]) { |
716 | err ("out of system memory\n"); | 707 | err ("out of system memory\n"); |
717 | retval = -ENOMEM; | 708 | retval = -ENOMEM; |
718 | goto error; | 709 | goto error; |
719 | } | 710 | } |
720 | memset (bus_pfmem[count], 0, sizeof (struct resource_node)); | ||
721 | bus_pfmem[count]->type = PFMEM; | 711 | bus_pfmem[count]->type = PFMEM; |
722 | bus_pfmem[count]->busno = func->busno; | 712 | bus_pfmem[count]->busno = func->busno; |
723 | bus_pfmem[count]->devfunc = PCI_DEVFN(func->device, | 713 | bus_pfmem[count]->devfunc = PCI_DEVFN(func->device, |
724 | func->function); | 714 | func->function); |
725 | bus_pfmem[count]->len = len[count]; | 715 | bus_pfmem[count]->len = len[count]; |
726 | bus_pfmem[count]->fromMem = FALSE; | 716 | bus_pfmem[count]->fromMem = 0; |
727 | if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { | 717 | if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { |
728 | ibmphp_add_resource (bus_pfmem[count]); | 718 | ibmphp_add_resource (bus_pfmem[count]); |
729 | func->pfmem[count] = bus_pfmem[count]; | 719 | func->pfmem[count] = bus_pfmem[count]; |
730 | } else { | 720 | } else { |
731 | mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); | 721 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
732 | if (!mem_tmp) { | 722 | if (!mem_tmp) { |
733 | err ("out of system memory\n"); | 723 | err ("out of system memory\n"); |
734 | retval = -ENOMEM; | 724 | retval = -ENOMEM; |
735 | goto error; | 725 | goto error; |
736 | } | 726 | } |
737 | memset (mem_tmp, 0, sizeof (struct resource_node)); | ||
738 | mem_tmp->type = MEM; | 727 | mem_tmp->type = MEM; |
739 | mem_tmp->busno = bus_pfmem[count]->busno; | 728 | mem_tmp->busno = bus_pfmem[count]->busno; |
740 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; | 729 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; |
741 | mem_tmp->len = bus_pfmem[count]->len; | 730 | mem_tmp->len = bus_pfmem[count]->len; |
742 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 731 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { |
743 | ibmphp_add_resource (mem_tmp); | 732 | ibmphp_add_resource (mem_tmp); |
744 | bus_pfmem[count]->fromMem = TRUE; | 733 | bus_pfmem[count]->fromMem = 1; |
745 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; | 734 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; |
746 | ibmphp_add_pfmem_from_mem (bus_pfmem[count]); | 735 | ibmphp_add_pfmem_from_mem (bus_pfmem[count]); |
747 | func->pfmem[count] = bus_pfmem[count]; | 736 | func->pfmem[count] = bus_pfmem[count]; |
@@ -770,13 +759,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
770 | 759 | ||
771 | debug ("len[count] in Memory is %x\n", len[count]); | 760 | debug ("len[count] in Memory is %x\n", len[count]); |
772 | 761 | ||
773 | bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 762 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
774 | if (!bus_mem[count]) { | 763 | if (!bus_mem[count]) { |
775 | err ("out of system memory\n"); | 764 | err ("out of system memory\n"); |
776 | retval = -ENOMEM; | 765 | retval = -ENOMEM; |
777 | goto error; | 766 | goto error; |
778 | } | 767 | } |
779 | memset (bus_mem[count], 0, sizeof (struct resource_node)); | ||
780 | bus_mem[count]->type = MEM; | 768 | bus_mem[count]->type = MEM; |
781 | bus_mem[count]->busno = func->busno; | 769 | bus_mem[count]->busno = func->busno; |
782 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, | 770 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, |
@@ -838,17 +826,16 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
838 | 826 | ||
839 | if (!amount_needed->io) { | 827 | if (!amount_needed->io) { |
840 | debug ("it doesn't want IO?\n"); | 828 | debug ("it doesn't want IO?\n"); |
841 | flag_io = TRUE; | 829 | flag_io = 1; |
842 | } else { | 830 | } else { |
843 | debug ("it wants %x IO behind the bridge\n", amount_needed->io); | 831 | debug ("it wants %x IO behind the bridge\n", amount_needed->io); |
844 | io = kmalloc(sizeof(*io), GFP_KERNEL); | 832 | io = kzalloc(sizeof(*io), GFP_KERNEL); |
845 | 833 | ||
846 | if (!io) { | 834 | if (!io) { |
847 | err ("out of system memory\n"); | 835 | err ("out of system memory\n"); |
848 | retval = -ENOMEM; | 836 | retval = -ENOMEM; |
849 | goto error; | 837 | goto error; |
850 | } | 838 | } |
851 | memset (io, 0, sizeof (struct resource_node)); | ||
852 | io->type = IO; | 839 | io->type = IO; |
853 | io->busno = func->busno; | 840 | io->busno = func->busno; |
854 | io->devfunc = PCI_DEVFN(func->device, func->function); | 841 | io->devfunc = PCI_DEVFN(func->device, func->function); |
@@ -856,71 +843,68 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
856 | if (ibmphp_check_resource (io, 1) == 0) { | 843 | if (ibmphp_check_resource (io, 1) == 0) { |
857 | debug ("were we able to add io\n"); | 844 | debug ("were we able to add io\n"); |
858 | ibmphp_add_resource (io); | 845 | ibmphp_add_resource (io); |
859 | flag_io = TRUE; | 846 | flag_io = 1; |
860 | } | 847 | } |
861 | } | 848 | } |
862 | 849 | ||
863 | if (!amount_needed->mem) { | 850 | if (!amount_needed->mem) { |
864 | debug ("it doesn't want n.e.memory?\n"); | 851 | debug ("it doesn't want n.e.memory?\n"); |
865 | flag_mem = TRUE; | 852 | flag_mem = 1; |
866 | } else { | 853 | } else { |
867 | debug ("it wants %x memory behind the bridge\n", amount_needed->mem); | 854 | debug ("it wants %x memory behind the bridge\n", amount_needed->mem); |
868 | mem = kmalloc(sizeof(*mem), GFP_KERNEL); | 855 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
869 | if (!mem) { | 856 | if (!mem) { |
870 | err ("out of system memory\n"); | 857 | err ("out of system memory\n"); |
871 | retval = -ENOMEM; | 858 | retval = -ENOMEM; |
872 | goto error; | 859 | goto error; |
873 | } | 860 | } |
874 | memset (mem, 0, sizeof (struct resource_node)); | ||
875 | mem->type = MEM; | 861 | mem->type = MEM; |
876 | mem->busno = func->busno; | 862 | mem->busno = func->busno; |
877 | mem->devfunc = PCI_DEVFN(func->device, func->function); | 863 | mem->devfunc = PCI_DEVFN(func->device, func->function); |
878 | mem->len = amount_needed->mem; | 864 | mem->len = amount_needed->mem; |
879 | if (ibmphp_check_resource (mem, 1) == 0) { | 865 | if (ibmphp_check_resource (mem, 1) == 0) { |
880 | ibmphp_add_resource (mem); | 866 | ibmphp_add_resource (mem); |
881 | flag_mem = TRUE; | 867 | flag_mem = 1; |
882 | debug ("were we able to add mem\n"); | 868 | debug ("were we able to add mem\n"); |
883 | } | 869 | } |
884 | } | 870 | } |
885 | 871 | ||
886 | if (!amount_needed->pfmem) { | 872 | if (!amount_needed->pfmem) { |
887 | debug ("it doesn't want n.e.pfmem mem?\n"); | 873 | debug ("it doesn't want n.e.pfmem mem?\n"); |
888 | flag_pfmem = TRUE; | 874 | flag_pfmem = 1; |
889 | } else { | 875 | } else { |
890 | debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); | 876 | debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); |
891 | pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL); | 877 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); |
892 | if (!pfmem) { | 878 | if (!pfmem) { |
893 | err ("out of system memory\n"); | 879 | err ("out of system memory\n"); |
894 | retval = -ENOMEM; | 880 | retval = -ENOMEM; |
895 | goto error; | 881 | goto error; |
896 | } | 882 | } |
897 | memset (pfmem, 0, sizeof (struct resource_node)); | ||
898 | pfmem->type = PFMEM; | 883 | pfmem->type = PFMEM; |
899 | pfmem->busno = func->busno; | 884 | pfmem->busno = func->busno; |
900 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); | 885 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); |
901 | pfmem->len = amount_needed->pfmem; | 886 | pfmem->len = amount_needed->pfmem; |
902 | pfmem->fromMem = FALSE; | 887 | pfmem->fromMem = 0; |
903 | if (ibmphp_check_resource (pfmem, 1) == 0) { | 888 | if (ibmphp_check_resource (pfmem, 1) == 0) { |
904 | ibmphp_add_resource (pfmem); | 889 | ibmphp_add_resource (pfmem); |
905 | flag_pfmem = TRUE; | 890 | flag_pfmem = 1; |
906 | } else { | 891 | } else { |
907 | mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); | 892 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
908 | if (!mem_tmp) { | 893 | if (!mem_tmp) { |
909 | err ("out of system memory\n"); | 894 | err ("out of system memory\n"); |
910 | retval = -ENOMEM; | 895 | retval = -ENOMEM; |
911 | goto error; | 896 | goto error; |
912 | } | 897 | } |
913 | memset (mem_tmp, 0, sizeof (struct resource_node)); | ||
914 | mem_tmp->type = MEM; | 898 | mem_tmp->type = MEM; |
915 | mem_tmp->busno = pfmem->busno; | 899 | mem_tmp->busno = pfmem->busno; |
916 | mem_tmp->devfunc = pfmem->devfunc; | 900 | mem_tmp->devfunc = pfmem->devfunc; |
917 | mem_tmp->len = pfmem->len; | 901 | mem_tmp->len = pfmem->len; |
918 | if (ibmphp_check_resource (mem_tmp, 1) == 0) { | 902 | if (ibmphp_check_resource (mem_tmp, 1) == 0) { |
919 | ibmphp_add_resource (mem_tmp); | 903 | ibmphp_add_resource (mem_tmp); |
920 | pfmem->fromMem = TRUE; | 904 | pfmem->fromMem = 1; |
921 | pfmem->rangeno = mem_tmp->rangeno; | 905 | pfmem->rangeno = mem_tmp->rangeno; |
922 | ibmphp_add_pfmem_from_mem (pfmem); | 906 | ibmphp_add_pfmem_from_mem (pfmem); |
923 | flag_pfmem = TRUE; | 907 | flag_pfmem = 1; |
924 | } | 908 | } |
925 | } | 909 | } |
926 | } | 910 | } |
@@ -936,13 +920,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
936 | */ | 920 | */ |
937 | bus = ibmphp_find_res_bus (sec_number); | 921 | bus = ibmphp_find_res_bus (sec_number); |
938 | if (!bus) { | 922 | if (!bus) { |
939 | bus = kmalloc(sizeof(*bus), GFP_KERNEL); | 923 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); |
940 | if (!bus) { | 924 | if (!bus) { |
941 | err ("out of system memory\n"); | 925 | err ("out of system memory\n"); |
942 | retval = -ENOMEM; | 926 | retval = -ENOMEM; |
943 | goto error; | 927 | goto error; |
944 | } | 928 | } |
945 | memset (bus, 0, sizeof (struct bus_node)); | ||
946 | bus->busno = sec_number; | 929 | bus->busno = sec_number; |
947 | debug ("b4 adding new bus\n"); | 930 | debug ("b4 adding new bus\n"); |
948 | rc = add_new_bus (bus, io, mem, pfmem, func->busno); | 931 | rc = add_new_bus (bus, io, mem, pfmem, func->busno); |
@@ -967,11 +950,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
967 | 950 | ||
968 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { | 951 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { |
969 | debug ("io 32\n"); | 952 | debug ("io 32\n"); |
970 | need_io_upper = TRUE; | 953 | need_io_upper = 1; |
971 | } | 954 | } |
972 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { | 955 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { |
973 | debug ("pfmem 64\n"); | 956 | debug ("pfmem 64\n"); |
974 | need_pfmem_upper = TRUE; | 957 | need_pfmem_upper = 1; |
975 | } | 958 | } |
976 | 959 | ||
977 | if (bus->noIORanges) { | 960 | if (bus->noIORanges) { |
@@ -1111,10 +1094,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1111 | }; | 1094 | }; |
1112 | struct res_needed *amount; | 1095 | struct res_needed *amount; |
1113 | 1096 | ||
1114 | amount = kmalloc(sizeof(*amount), GFP_KERNEL); | 1097 | amount = kzalloc(sizeof(*amount), GFP_KERNEL); |
1115 | if (amount == NULL) | 1098 | if (amount == NULL) |
1116 | return NULL; | 1099 | return NULL; |
1117 | memset (amount, 0, sizeof (struct res_needed)); | ||
1118 | 1100 | ||
1119 | ibmphp_pci_bus->number = busno; | 1101 | ibmphp_pci_bus->number = busno; |
1120 | 1102 | ||
@@ -1137,7 +1119,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1137 | debug ("hdr_type behind the bridge is %x\n", hdr_type); | 1119 | debug ("hdr_type behind the bridge is %x\n", hdr_type); |
1138 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 1120 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { |
1139 | err ("embedded bridges not supported for hot-plugging.\n"); | 1121 | err ("embedded bridges not supported for hot-plugging.\n"); |
1140 | amount->not_correct = TRUE; | 1122 | amount->not_correct = 1; |
1141 | return amount; | 1123 | return amount; |
1142 | } | 1124 | } |
1143 | 1125 | ||
@@ -1145,12 +1127,12 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1145 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 1127 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
1146 | err ("The device %x is VGA compatible and as is not supported for hot plugging. " | 1128 | err ("The device %x is VGA compatible and as is not supported for hot plugging. " |
1147 | "Please choose another device.\n", device); | 1129 | "Please choose another device.\n", device); |
1148 | amount->not_correct = TRUE; | 1130 | amount->not_correct = 1; |
1149 | return amount; | 1131 | return amount; |
1150 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 1132 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
1151 | err ("The device %x is not supported for hot plugging. " | 1133 | err ("The device %x is not supported for hot plugging. " |
1152 | "Please choose another device.\n", device); | 1134 | "Please choose another device.\n", device); |
1153 | amount->not_correct = TRUE; | 1135 | amount->not_correct = 1; |
1154 | return amount; | 1136 | return amount; |
1155 | } | 1137 | } |
1156 | 1138 | ||
@@ -1210,9 +1192,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1210 | } /* end for */ | 1192 | } /* end for */ |
1211 | 1193 | ||
1212 | if (!howmany) | 1194 | if (!howmany) |
1213 | amount->not_correct = TRUE; | 1195 | amount->not_correct = 1; |
1214 | else | 1196 | else |
1215 | amount->not_correct = FALSE; | 1197 | amount->not_correct = 0; |
1216 | if ((amount->io) && (amount->io < IOBRIDGE)) | 1198 | if ((amount->io) && (amount->io < IOBRIDGE)) |
1217 | amount->io = IOBRIDGE; | 1199 | amount->io = IOBRIDGE; |
1218 | if ((amount->mem) && (amount->mem < MEMBRIDGE)) | 1200 | if ((amount->mem) && (amount->mem < MEMBRIDGE)) |
@@ -1672,12 +1654,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1672 | list_add (&bus->bus_list, &cur_bus->bus_list); | 1654 | list_add (&bus->bus_list, &cur_bus->bus_list); |
1673 | } | 1655 | } |
1674 | if (io) { | 1656 | if (io) { |
1675 | io_range = kmalloc(sizeof(*io_range), GFP_KERNEL); | 1657 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); |
1676 | if (!io_range) { | 1658 | if (!io_range) { |
1677 | err ("out of system memory\n"); | 1659 | err ("out of system memory\n"); |
1678 | return -ENOMEM; | 1660 | return -ENOMEM; |
1679 | } | 1661 | } |
1680 | memset (io_range, 0, sizeof (struct range_node)); | ||
1681 | io_range->start = io->start; | 1662 | io_range->start = io->start; |
1682 | io_range->end = io->end; | 1663 | io_range->end = io->end; |
1683 | io_range->rangeno = 1; | 1664 | io_range->rangeno = 1; |
@@ -1685,12 +1666,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1685 | bus->rangeIO = io_range; | 1666 | bus->rangeIO = io_range; |
1686 | } | 1667 | } |
1687 | if (mem) { | 1668 | if (mem) { |
1688 | mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL); | 1669 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); |
1689 | if (!mem_range) { | 1670 | if (!mem_range) { |
1690 | err ("out of system memory\n"); | 1671 | err ("out of system memory\n"); |
1691 | return -ENOMEM; | 1672 | return -ENOMEM; |
1692 | } | 1673 | } |
1693 | memset (mem_range, 0, sizeof (struct range_node)); | ||
1694 | mem_range->start = mem->start; | 1674 | mem_range->start = mem->start; |
1695 | mem_range->end = mem->end; | 1675 | mem_range->end = mem->end; |
1696 | mem_range->rangeno = 1; | 1676 | mem_range->rangeno = 1; |
@@ -1698,12 +1678,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1698 | bus->rangeMem = mem_range; | 1678 | bus->rangeMem = mem_range; |
1699 | } | 1679 | } |
1700 | if (pfmem) { | 1680 | if (pfmem) { |
1701 | pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL); | 1681 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); |
1702 | if (!pfmem_range) { | 1682 | if (!pfmem_range) { |
1703 | err ("out of system memory\n"); | 1683 | err ("out of system memory\n"); |
1704 | return -ENOMEM; | 1684 | return -ENOMEM; |
1705 | } | 1685 | } |
1706 | memset (pfmem_range, 0, sizeof (struct range_node)); | ||
1707 | pfmem_range->start = pfmem->start; | 1686 | pfmem_range->start = pfmem->start; |
1708 | pfmem_range->end = pfmem->end; | 1687 | pfmem_range->end = pfmem->end; |
1709 | pfmem_range->rangeno = 1; | 1688 | pfmem_range->rangeno = 1; |
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c index 9c224c94d698..5636b1ac2a2e 100644 --- a/drivers/pci/hotplug/ibmphp_res.c +++ b/drivers/pci/hotplug/ibmphp_res.c | |||
@@ -55,13 +55,12 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8 | |||
55 | return NULL; | 55 | return NULL; |
56 | } | 56 | } |
57 | 57 | ||
58 | newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); | 58 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
59 | if (!newbus) { | 59 | if (!newbus) { |
60 | err ("out of system memory\n"); | 60 | err ("out of system memory\n"); |
61 | return NULL; | 61 | return NULL; |
62 | } | 62 | } |
63 | 63 | ||
64 | memset (newbus, 0, sizeof (struct bus_node)); | ||
65 | if (flag) | 64 | if (flag) |
66 | newbus->busno = busno; | 65 | newbus->busno = busno; |
67 | else | 66 | else |
@@ -79,12 +78,11 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * cur | |||
79 | return NULL; | 78 | return NULL; |
80 | } | 79 | } |
81 | 80 | ||
82 | rs = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 81 | rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
83 | if (!rs) { | 82 | if (!rs) { |
84 | err ("out of system memory\n"); | 83 | err ("out of system memory\n"); |
85 | return NULL; | 84 | return NULL; |
86 | } | 85 | } |
87 | memset (rs, 0, sizeof (struct resource_node)); | ||
88 | rs->busno = curr->bus_num; | 86 | rs->busno = curr->bus_num; |
89 | rs->devfunc = curr->dev_fun; | 87 | rs->devfunc = curr->dev_fun; |
90 | rs->start = curr->start_addr; | 88 | rs->start = curr->start_addr; |
@@ -100,12 +98,11 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
100 | u8 num_ranges = 0; | 98 | u8 num_ranges = 0; |
101 | 99 | ||
102 | if (first_bus) { | 100 | if (first_bus) { |
103 | newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); | 101 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
104 | if (!newbus) { | 102 | if (!newbus) { |
105 | err ("out of system memory.\n"); | 103 | err ("out of system memory.\n"); |
106 | return -ENOMEM; | 104 | return -ENOMEM; |
107 | } | 105 | } |
108 | memset (newbus, 0, sizeof (struct bus_node)); | ||
109 | newbus->busno = curr->bus_num; | 106 | newbus->busno = curr->bus_num; |
110 | } else { | 107 | } else { |
111 | newbus = *new_bus; | 108 | newbus = *new_bus; |
@@ -122,14 +119,13 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
122 | } | 119 | } |
123 | } | 120 | } |
124 | 121 | ||
125 | newrange = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 122 | newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
126 | if (!newrange) { | 123 | if (!newrange) { |
127 | if (first_bus) | 124 | if (first_bus) |
128 | kfree (newbus); | 125 | kfree (newbus); |
129 | err ("out of system memory\n"); | 126 | err ("out of system memory\n"); |
130 | return -ENOMEM; | 127 | return -ENOMEM; |
131 | } | 128 | } |
132 | memset (newrange, 0, sizeof (struct range_node)); | ||
133 | newrange->start = curr->start_addr; | 129 | newrange->start = curr->start_addr; |
134 | newrange->end = curr->end_addr; | 130 | newrange->end = curr->end_addr; |
135 | 131 | ||
@@ -329,7 +325,7 @@ int __init ibmphp_rsrc_init (void) | |||
329 | if (!new_pfmem) | 325 | if (!new_pfmem) |
330 | return -ENOMEM; | 326 | return -ENOMEM; |
331 | new_pfmem->type = PFMEM; | 327 | new_pfmem->type = PFMEM; |
332 | new_pfmem->fromMem = FALSE; | 328 | new_pfmem->fromMem = 0; |
333 | if (ibmphp_add_resource (new_pfmem) < 0) { | 329 | if (ibmphp_add_resource (new_pfmem) < 0) { |
334 | newbus = alloc_error_bus (curr, 0, 0); | 330 | newbus = alloc_error_bus (curr, 0, 0); |
335 | if (!newbus) | 331 | if (!newbus) |
@@ -466,7 +462,7 @@ static int add_range (int type, struct range_node *range, struct bus_node *bus_c | |||
466 | static void update_resources (struct bus_node *bus_cur, int type, int rangeno) | 462 | static void update_resources (struct bus_node *bus_cur, int type, int rangeno) |
467 | { | 463 | { |
468 | struct resource_node *res = NULL; | 464 | struct resource_node *res = NULL; |
469 | u8 eol = FALSE; /* end of list indicator */ | 465 | u8 eol = 0; /* end of list indicator */ |
470 | 466 | ||
471 | switch (type) { | 467 | switch (type) { |
472 | case MEM: | 468 | case MEM: |
@@ -492,7 +488,7 @@ static void update_resources (struct bus_node *bus_cur, int type, int rangeno) | |||
492 | else if (res->nextRange) | 488 | else if (res->nextRange) |
493 | res = res->nextRange; | 489 | res = res->nextRange; |
494 | else { | 490 | else { |
495 | eol = TRUE; | 491 | eol = 1; |
496 | break; | 492 | break; |
497 | } | 493 | } |
498 | } | 494 | } |
@@ -983,7 +979,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
983 | int noranges = 0; | 979 | int noranges = 0; |
984 | u32 tmp_start; /* this is to make sure start address is divisible by the length needed */ | 980 | u32 tmp_start; /* this is to make sure start address is divisible by the length needed */ |
985 | u32 tmp_divide; | 981 | u32 tmp_divide; |
986 | u8 flag = FALSE; | 982 | u8 flag = 0; |
987 | 983 | ||
988 | if (!res) | 984 | if (!res) |
989 | return -EINVAL; | 985 | return -EINVAL; |
@@ -1050,17 +1046,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1050 | 1046 | ||
1051 | if ((range->start % tmp_divide) == 0) { | 1047 | if ((range->start % tmp_divide) == 0) { |
1052 | /* just perfect, starting address is divisible by length */ | 1048 | /* just perfect, starting address is divisible by length */ |
1053 | flag = TRUE; | 1049 | flag = 1; |
1054 | len_cur = len_tmp; | 1050 | len_cur = len_tmp; |
1055 | start_cur = range->start; | 1051 | start_cur = range->start; |
1056 | } else { | 1052 | } else { |
1057 | /* Needs adjusting */ | 1053 | /* Needs adjusting */ |
1058 | tmp_start = range->start; | 1054 | tmp_start = range->start; |
1059 | flag = FALSE; | 1055 | flag = 0; |
1060 | 1056 | ||
1061 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { | 1057 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { |
1062 | if ((tmp_start % tmp_divide) == 0) { | 1058 | if ((tmp_start % tmp_divide) == 0) { |
1063 | flag = TRUE; | 1059 | flag = 1; |
1064 | len_cur = len_tmp; | 1060 | len_cur = len_tmp; |
1065 | start_cur = tmp_start; | 1061 | start_cur = tmp_start; |
1066 | break; | 1062 | break; |
@@ -1089,17 +1085,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1089 | 1085 | ||
1090 | if (((res_cur->end + 1) % tmp_divide) == 0) { | 1086 | if (((res_cur->end + 1) % tmp_divide) == 0) { |
1091 | /* just perfect, starting address is divisible by length */ | 1087 | /* just perfect, starting address is divisible by length */ |
1092 | flag = TRUE; | 1088 | flag = 1; |
1093 | len_cur = len_tmp; | 1089 | len_cur = len_tmp; |
1094 | start_cur = res_cur->end + 1; | 1090 | start_cur = res_cur->end + 1; |
1095 | } else { | 1091 | } else { |
1096 | /* Needs adjusting */ | 1092 | /* Needs adjusting */ |
1097 | tmp_start = res_cur->end + 1; | 1093 | tmp_start = res_cur->end + 1; |
1098 | flag = FALSE; | 1094 | flag = 0; |
1099 | 1095 | ||
1100 | while ((len_tmp = range->end - tmp_start) >= res->len) { | 1096 | while ((len_tmp = range->end - tmp_start) >= res->len) { |
1101 | if ((tmp_start % tmp_divide) == 0) { | 1097 | if ((tmp_start % tmp_divide) == 0) { |
1102 | flag = TRUE; | 1098 | flag = 1; |
1103 | len_cur = len_tmp; | 1099 | len_cur = len_tmp; |
1104 | start_cur = tmp_start; | 1100 | start_cur = tmp_start; |
1105 | break; | 1101 | break; |
@@ -1127,17 +1123,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1127 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1123 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1128 | if ((range->start % tmp_divide) == 0) { | 1124 | if ((range->start % tmp_divide) == 0) { |
1129 | /* just perfect, starting address is divisible by length */ | 1125 | /* just perfect, starting address is divisible by length */ |
1130 | flag = TRUE; | 1126 | flag = 1; |
1131 | len_cur = len_tmp; | 1127 | len_cur = len_tmp; |
1132 | start_cur = range->start; | 1128 | start_cur = range->start; |
1133 | } else { | 1129 | } else { |
1134 | /* Needs adjusting */ | 1130 | /* Needs adjusting */ |
1135 | tmp_start = range->start; | 1131 | tmp_start = range->start; |
1136 | flag = FALSE; | 1132 | flag = 0; |
1137 | 1133 | ||
1138 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { | 1134 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { |
1139 | if ((tmp_start % tmp_divide) == 0) { | 1135 | if ((tmp_start % tmp_divide) == 0) { |
1140 | flag = TRUE; | 1136 | flag = 1; |
1141 | len_cur = len_tmp; | 1137 | len_cur = len_tmp; |
1142 | start_cur = tmp_start; | 1138 | start_cur = tmp_start; |
1143 | break; | 1139 | break; |
@@ -1162,17 +1158,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1162 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1158 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1163 | if (((res_prev->end + 1) % tmp_divide) == 0) { | 1159 | if (((res_prev->end + 1) % tmp_divide) == 0) { |
1164 | /* just perfect, starting address's divisible by length */ | 1160 | /* just perfect, starting address's divisible by length */ |
1165 | flag = TRUE; | 1161 | flag = 1; |
1166 | len_cur = len_tmp; | 1162 | len_cur = len_tmp; |
1167 | start_cur = res_prev->end + 1; | 1163 | start_cur = res_prev->end + 1; |
1168 | } else { | 1164 | } else { |
1169 | /* Needs adjusting */ | 1165 | /* Needs adjusting */ |
1170 | tmp_start = res_prev->end + 1; | 1166 | tmp_start = res_prev->end + 1; |
1171 | flag = FALSE; | 1167 | flag = 0; |
1172 | 1168 | ||
1173 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { | 1169 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { |
1174 | if ((tmp_start % tmp_divide) == 0) { | 1170 | if ((tmp_start % tmp_divide) == 0) { |
1175 | flag = TRUE; | 1171 | flag = 1; |
1176 | len_cur = len_tmp; | 1172 | len_cur = len_tmp; |
1177 | start_cur = tmp_start; | 1173 | start_cur = tmp_start; |
1178 | break; | 1174 | break; |
@@ -1221,17 +1217,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1221 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1217 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1222 | if ((range->start % tmp_divide) == 0) { | 1218 | if ((range->start % tmp_divide) == 0) { |
1223 | /* just perfect, starting address's divisible by length */ | 1219 | /* just perfect, starting address's divisible by length */ |
1224 | flag = TRUE; | 1220 | flag = 1; |
1225 | len_cur = len_tmp; | 1221 | len_cur = len_tmp; |
1226 | start_cur = range->start; | 1222 | start_cur = range->start; |
1227 | } else { | 1223 | } else { |
1228 | /* Needs adjusting */ | 1224 | /* Needs adjusting */ |
1229 | tmp_start = range->start; | 1225 | tmp_start = range->start; |
1230 | flag = FALSE; | 1226 | flag = 0; |
1231 | 1227 | ||
1232 | while ((len_tmp = range->end - tmp_start) >= res->len) { | 1228 | while ((len_tmp = range->end - tmp_start) >= res->len) { |
1233 | if ((tmp_start % tmp_divide) == 0) { | 1229 | if ((tmp_start % tmp_divide) == 0) { |
1234 | flag = TRUE; | 1230 | flag = 1; |
1235 | len_cur = len_tmp; | 1231 | len_cur = len_tmp; |
1236 | start_cur = tmp_start; | 1232 | start_cur = tmp_start; |
1237 | break; | 1233 | break; |
@@ -1285,17 +1281,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1285 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1281 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1286 | if ((range->start % tmp_divide) == 0) { | 1282 | if ((range->start % tmp_divide) == 0) { |
1287 | /* just perfect, starting address's divisible by length */ | 1283 | /* just perfect, starting address's divisible by length */ |
1288 | flag = TRUE; | 1284 | flag = 1; |
1289 | len_cur = len_tmp; | 1285 | len_cur = len_tmp; |
1290 | start_cur = range->start; | 1286 | start_cur = range->start; |
1291 | } else { | 1287 | } else { |
1292 | /* Needs adjusting */ | 1288 | /* Needs adjusting */ |
1293 | tmp_start = range->start; | 1289 | tmp_start = range->start; |
1294 | flag = FALSE; | 1290 | flag = 0; |
1295 | 1291 | ||
1296 | while ((len_tmp = range->end - tmp_start) >= res->len) { | 1292 | while ((len_tmp = range->end - tmp_start) >= res->len) { |
1297 | if ((tmp_start % tmp_divide) == 0) { | 1293 | if ((tmp_start % tmp_divide) == 0) { |
1298 | flag = TRUE; | 1294 | flag = 1; |
1299 | len_cur = len_tmp; | 1295 | len_cur = len_tmp; |
1300 | start_cur = tmp_start; | 1296 | start_cur = tmp_start; |
1301 | break; | 1297 | break; |
@@ -1688,7 +1684,7 @@ static int __init once_over (void) | |||
1688 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | 1684 | bus_cur = list_entry (tmp, struct bus_node, bus_list); |
1689 | if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { | 1685 | if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { |
1690 | for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) { | 1686 | for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) { |
1691 | pfmem_cur->fromMem = TRUE; | 1687 | pfmem_cur->fromMem = 1; |
1692 | if (pfmem_prev) | 1688 | if (pfmem_prev) |
1693 | pfmem_prev->next = pfmem_cur->next; | 1689 | pfmem_prev->next = pfmem_cur->next; |
1694 | else | 1690 | else |
@@ -1705,12 +1701,11 @@ static int __init once_over (void) | |||
1705 | 1701 | ||
1706 | bus_cur->firstPFMemFromMem = pfmem_cur; | 1702 | bus_cur->firstPFMemFromMem = pfmem_cur; |
1707 | 1703 | ||
1708 | mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 1704 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
1709 | if (!mem) { | 1705 | if (!mem) { |
1710 | err ("out of system memory\n"); | 1706 | err ("out of system memory\n"); |
1711 | return -ENOMEM; | 1707 | return -ENOMEM; |
1712 | } | 1708 | } |
1713 | memset (mem, 0, sizeof (struct resource_node)); | ||
1714 | mem->type = MEM; | 1709 | mem->type = MEM; |
1715 | mem->busno = pfmem_cur->busno; | 1710 | mem->busno = pfmem_cur->busno; |
1716 | mem->devfunc = pfmem_cur->devfunc; | 1711 | mem->devfunc = pfmem_cur->devfunc; |
@@ -1994,12 +1989,11 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
1994 | end_address |= (upper_io_end << 16); | 1989 | end_address |= (upper_io_end << 16); |
1995 | 1990 | ||
1996 | if ((start_address) && (start_address <= end_address)) { | 1991 | if ((start_address) && (start_address <= end_address)) { |
1997 | range = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 1992 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
1998 | if (!range) { | 1993 | if (!range) { |
1999 | err ("out of system memory\n"); | 1994 | err ("out of system memory\n"); |
2000 | return -ENOMEM; | 1995 | return -ENOMEM; |
2001 | } | 1996 | } |
2002 | memset (range, 0, sizeof (struct range_node)); | ||
2003 | range->start = start_address; | 1997 | range->start = start_address; |
2004 | range->end = end_address + 0xfff; | 1998 | range->end = end_address + 0xfff; |
2005 | 1999 | ||
@@ -2020,13 +2014,12 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2020 | fix_resources (bus_sec); | 2014 | fix_resources (bus_sec); |
2021 | 2015 | ||
2022 | if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { | 2016 | if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { |
2023 | io = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 2017 | io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2024 | if (!io) { | 2018 | if (!io) { |
2025 | kfree (range); | 2019 | kfree (range); |
2026 | err ("out of system memory\n"); | 2020 | err ("out of system memory\n"); |
2027 | return -ENOMEM; | 2021 | return -ENOMEM; |
2028 | } | 2022 | } |
2029 | memset (io, 0, sizeof (struct resource_node)); | ||
2030 | io->type = IO; | 2023 | io->type = IO; |
2031 | io->busno = bus_cur->busno; | 2024 | io->busno = bus_cur->busno; |
2032 | io->devfunc = ((device << 3) | (function & 0x7)); | 2025 | io->devfunc = ((device << 3) | (function & 0x7)); |
@@ -2045,12 +2038,11 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2045 | 2038 | ||
2046 | if ((start_address) && (start_address <= end_address)) { | 2039 | if ((start_address) && (start_address <= end_address)) { |
2047 | 2040 | ||
2048 | range = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 2041 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2049 | if (!range) { | 2042 | if (!range) { |
2050 | err ("out of system memory\n"); | 2043 | err ("out of system memory\n"); |
2051 | return -ENOMEM; | 2044 | return -ENOMEM; |
2052 | } | 2045 | } |
2053 | memset (range, 0, sizeof (struct range_node)); | ||
2054 | range->start = start_address; | 2046 | range->start = start_address; |
2055 | range->end = end_address + 0xfffff; | 2047 | range->end = end_address + 0xfffff; |
2056 | 2048 | ||
@@ -2072,13 +2064,12 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2072 | fix_resources (bus_sec); | 2064 | fix_resources (bus_sec); |
2073 | 2065 | ||
2074 | if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { | 2066 | if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { |
2075 | mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 2067 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2076 | if (!mem) { | 2068 | if (!mem) { |
2077 | kfree (range); | 2069 | kfree (range); |
2078 | err ("out of system memory\n"); | 2070 | err ("out of system memory\n"); |
2079 | return -ENOMEM; | 2071 | return -ENOMEM; |
2080 | } | 2072 | } |
2081 | memset (mem, 0, sizeof (struct resource_node)); | ||
2082 | mem->type = MEM; | 2073 | mem->type = MEM; |
2083 | mem->busno = bus_cur->busno; | 2074 | mem->busno = bus_cur->busno; |
2084 | mem->devfunc = ((device << 3) | (function & 0x7)); | 2075 | mem->devfunc = ((device << 3) | (function & 0x7)); |
@@ -2101,12 +2092,11 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2101 | 2092 | ||
2102 | if ((start_address) && (start_address <= end_address)) { | 2093 | if ((start_address) && (start_address <= end_address)) { |
2103 | 2094 | ||
2104 | range = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 2095 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2105 | if (!range) { | 2096 | if (!range) { |
2106 | err ("out of system memory\n"); | 2097 | err ("out of system memory\n"); |
2107 | return -ENOMEM; | 2098 | return -ENOMEM; |
2108 | } | 2099 | } |
2109 | memset (range, 0, sizeof (struct range_node)); | ||
2110 | range->start = start_address; | 2100 | range->start = start_address; |
2111 | range->end = end_address + 0xfffff; | 2101 | range->end = end_address + 0xfffff; |
2112 | 2102 | ||
@@ -2127,20 +2117,19 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2127 | 2117 | ||
2128 | fix_resources (bus_sec); | 2118 | fix_resources (bus_sec); |
2129 | if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { | 2119 | if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { |
2130 | pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 2120 | pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2131 | if (!pfmem) { | 2121 | if (!pfmem) { |
2132 | kfree (range); | 2122 | kfree (range); |
2133 | err ("out of system memory\n"); | 2123 | err ("out of system memory\n"); |
2134 | return -ENOMEM; | 2124 | return -ENOMEM; |
2135 | } | 2125 | } |
2136 | memset (pfmem, 0, sizeof (struct resource_node)); | ||
2137 | pfmem->type = PFMEM; | 2126 | pfmem->type = PFMEM; |
2138 | pfmem->busno = bus_cur->busno; | 2127 | pfmem->busno = bus_cur->busno; |
2139 | pfmem->devfunc = ((device << 3) | (function & 0x7)); | 2128 | pfmem->devfunc = ((device << 3) | (function & 0x7)); |
2140 | pfmem->start = start_address; | 2129 | pfmem->start = start_address; |
2141 | pfmem->end = end_address + 0xfffff; | 2130 | pfmem->end = end_address + 0xfffff; |
2142 | pfmem->len = pfmem->end - pfmem->start + 1; | 2131 | pfmem->len = pfmem->end - pfmem->start + 1; |
2143 | pfmem->fromMem = FALSE; | 2132 | pfmem->fromMem = 0; |
2144 | 2133 | ||
2145 | ibmphp_add_resource (pfmem); | 2134 | ibmphp_add_resource (pfmem); |
2146 | } | 2135 | } |
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h index 88d44f7fef29..eb0d01d47236 100644 --- a/drivers/pci/hotplug/pci_hotplug.h +++ b/drivers/pci/hotplug/pci_hotplug.h | |||
@@ -176,5 +176,21 @@ extern int pci_hp_change_slot_info (struct hotplug_slot *slot, | |||
176 | struct hotplug_slot_info *info); | 176 | struct hotplug_slot_info *info); |
177 | extern struct subsystem pci_hotplug_slots_subsys; | 177 | extern struct subsystem pci_hotplug_slots_subsys; |
178 | 178 | ||
179 | struct hotplug_params { | ||
180 | u8 cache_line_size; | ||
181 | u8 latency_timer; | ||
182 | u8 enable_serr; | ||
183 | u8 enable_perr; | ||
184 | }; | ||
185 | |||
186 | #ifdef CONFIG_ACPI | ||
187 | #include <acpi/acpi.h> | ||
188 | #include <acpi/acpi_bus.h> | ||
189 | #include <acpi/actypes.h> | ||
190 | extern acpi_status acpi_run_oshp(acpi_handle handle); | ||
191 | extern acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev, | ||
192 | struct hotplug_params *hpp); | ||
193 | int acpi_root_bridge(acpi_handle handle); | ||
194 | #endif | ||
179 | #endif | 195 | #endif |
180 | 196 | ||
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 0aac6a61337d..92c1f0f1e1ad 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/sched.h> /* signal_pending() */ | 35 | #include <linux/sched.h> /* signal_pending() */ |
36 | #include <linux/pcieport_if.h> | 36 | #include <linux/pcieport_if.h> |
37 | #include <linux/mutex.h> | ||
37 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
38 | 39 | ||
39 | #define MY_NAME "pciehp" | 40 | #define MY_NAME "pciehp" |
@@ -49,12 +50,6 @@ extern int pciehp_force; | |||
49 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 50 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) |
50 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
51 | 52 | ||
52 | struct hotplug_params { | ||
53 | u8 cache_line_size; | ||
54 | u8 latency_timer; | ||
55 | u8 enable_serr; | ||
56 | u8 enable_perr; | ||
57 | }; | ||
58 | 53 | ||
59 | struct slot { | 54 | struct slot { |
60 | struct slot *next; | 55 | struct slot *next; |
@@ -96,7 +91,7 @@ struct php_ctlr_state_s { | |||
96 | #define MAX_EVENTS 10 | 91 | #define MAX_EVENTS 10 |
97 | struct controller { | 92 | struct controller { |
98 | struct controller *next; | 93 | struct controller *next; |
99 | struct semaphore crit_sect; /* critical section semaphore */ | 94 | struct mutex crit_sect; /* critical section mutex */ |
100 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ | 95 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ |
101 | int num_slots; /* Number of slots on ctlr */ | 96 | int num_slots; /* Number of slots on ctlr */ |
102 | int slot_num_inc; /* 1 or -1 */ | 97 | int slot_num_inc; /* 1 or -1 */ |
@@ -191,9 +186,6 @@ extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id); | |||
191 | /* pci functions */ | 186 | /* pci functions */ |
192 | extern int pciehp_configure_device (struct slot *p_slot); | 187 | extern int pciehp_configure_device (struct slot *p_slot); |
193 | extern int pciehp_unconfigure_device (struct slot *p_slot); | 188 | extern int pciehp_unconfigure_device (struct slot *p_slot); |
194 | extern int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev); | ||
195 | extern void pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
196 | struct hotplug_params *hpp); | ||
197 | 189 | ||
198 | 190 | ||
199 | 191 | ||
@@ -285,4 +277,19 @@ struct hpc_ops { | |||
285 | int (*check_lnk_status) (struct controller *ctrl); | 277 | int (*check_lnk_status) (struct controller *ctrl); |
286 | }; | 278 | }; |
287 | 279 | ||
280 | |||
281 | #ifdef CONFIG_ACPI | ||
282 | #define pciehp_get_hp_hw_control_from_firmware(dev) \ | ||
283 | pciehp_acpi_get_hp_hw_control_from_firmware(dev) | ||
284 | static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
285 | struct hotplug_params *hpp) | ||
286 | { | ||
287 | if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev, hpp))) | ||
288 | return -ENODEV; | ||
289 | return 0; | ||
290 | } | ||
291 | #else | ||
292 | #define pciehp_get_hp_hw_control_from_firmware(dev) 0 | ||
293 | #define pciehp_get_hp_params_from_firmware(dev, hpp) (-ENODEV) | ||
294 | #endif /* CONFIG_ACPI */ | ||
288 | #endif /* _PCIEHP_H */ | 295 | #endif /* _PCIEHP_H */ |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 4fb569018a24..601cf9045b20 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -117,27 +117,23 @@ static int init_slots(struct controller *ctrl) | |||
117 | slot_number = ctrl->first_slot; | 117 | slot_number = ctrl->first_slot; |
118 | 118 | ||
119 | while (number_of_slots) { | 119 | while (number_of_slots) { |
120 | slot = kmalloc(sizeof(*slot), GFP_KERNEL); | 120 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
121 | if (!slot) | 121 | if (!slot) |
122 | goto error; | 122 | goto error; |
123 | 123 | ||
124 | memset(slot, 0, sizeof(struct slot)); | ||
125 | slot->hotplug_slot = | 124 | slot->hotplug_slot = |
126 | kmalloc(sizeof(*(slot->hotplug_slot)), | 125 | kzalloc(sizeof(*(slot->hotplug_slot)), |
127 | GFP_KERNEL); | 126 | GFP_KERNEL); |
128 | if (!slot->hotplug_slot) | 127 | if (!slot->hotplug_slot) |
129 | goto error_slot; | 128 | goto error_slot; |
130 | hotplug_slot = slot->hotplug_slot; | 129 | hotplug_slot = slot->hotplug_slot; |
131 | memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); | ||
132 | 130 | ||
133 | hotplug_slot->info = | 131 | hotplug_slot->info = |
134 | kmalloc(sizeof(*(hotplug_slot->info)), | 132 | kzalloc(sizeof(*(hotplug_slot->info)), |
135 | GFP_KERNEL); | 133 | GFP_KERNEL); |
136 | if (!hotplug_slot->info) | 134 | if (!hotplug_slot->info) |
137 | goto error_hpslot; | 135 | goto error_hpslot; |
138 | hotplug_slot_info = hotplug_slot->info; | 136 | hotplug_slot_info = hotplug_slot->info; |
139 | memset(hotplug_slot_info, 0, | ||
140 | sizeof(struct hotplug_slot_info)); | ||
141 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 137 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
142 | if (!hotplug_slot->name) | 138 | if (!hotplug_slot->name) |
143 | goto error_info; | 139 | goto error_info; |
@@ -373,12 +369,11 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
373 | u8 value; | 369 | u8 value; |
374 | struct pci_dev *pdev; | 370 | struct pci_dev *pdev; |
375 | 371 | ||
376 | ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL); | 372 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
377 | if (!ctrl) { | 373 | if (!ctrl) { |
378 | err("%s : out of memory\n", __FUNCTION__); | 374 | err("%s : out of memory\n", __FUNCTION__); |
379 | goto err_out_none; | 375 | goto err_out_none; |
380 | } | 376 | } |
381 | memset(ctrl, 0, sizeof(struct controller)); | ||
382 | 377 | ||
383 | pdev = dev->port; | 378 | pdev = dev->port; |
384 | ctrl->pci_dev = pdev; | 379 | ctrl->pci_dev = pdev; |
@@ -439,7 +434,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
439 | } | 434 | } |
440 | 435 | ||
441 | /* Wait for exclusive access to hardware */ | 436 | /* Wait for exclusive access to hardware */ |
442 | down(&ctrl->crit_sect); | 437 | mutex_lock(&ctrl->crit_sect); |
443 | 438 | ||
444 | t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ | 439 | t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ |
445 | 440 | ||
@@ -447,7 +442,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
447 | rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ | 442 | rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ |
448 | if (rc) { | 443 | if (rc) { |
449 | /* Done with exclusive hardware access */ | 444 | /* Done with exclusive hardware access */ |
450 | up(&ctrl->crit_sect); | 445 | mutex_unlock(&ctrl->crit_sect); |
451 | goto err_out_free_ctrl_slot; | 446 | goto err_out_free_ctrl_slot; |
452 | } else | 447 | } else |
453 | /* Wait for the command to complete */ | 448 | /* Wait for the command to complete */ |
@@ -455,7 +450,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
455 | } | 450 | } |
456 | 451 | ||
457 | /* Done with exclusive hardware access */ | 452 | /* Done with exclusive hardware access */ |
458 | up(&ctrl->crit_sect); | 453 | mutex_unlock(&ctrl->crit_sect); |
459 | 454 | ||
460 | return 0; | 455 | return 0; |
461 | 456 | ||
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 83c4b865718a..33d198768356 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -229,13 +229,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id) | |||
229 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) | 229 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) |
230 | { | 230 | { |
231 | /* Wait for exclusive access to hardware */ | 231 | /* Wait for exclusive access to hardware */ |
232 | down(&ctrl->crit_sect); | 232 | mutex_lock(&ctrl->crit_sect); |
233 | 233 | ||
234 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ | 234 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ |
235 | if (POWER_CTRL(ctrl->ctrlcap)) { | 235 | if (POWER_CTRL(ctrl->ctrlcap)) { |
236 | if (pslot->hpc_ops->power_off_slot(pslot)) { | 236 | if (pslot->hpc_ops->power_off_slot(pslot)) { |
237 | err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); | 237 | err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); |
238 | up(&ctrl->crit_sect); | 238 | mutex_unlock(&ctrl->crit_sect); |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | wait_for_ctrl_irq (ctrl); | 241 | wait_for_ctrl_irq (ctrl); |
@@ -249,14 +249,14 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) | |||
249 | if (ATTN_LED(ctrl->ctrlcap)) { | 249 | if (ATTN_LED(ctrl->ctrlcap)) { |
250 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { | 250 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { |
251 | err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); | 251 | err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); |
252 | up(&ctrl->crit_sect); | 252 | mutex_unlock(&ctrl->crit_sect); |
253 | return; | 253 | return; |
254 | } | 254 | } |
255 | wait_for_ctrl_irq (ctrl); | 255 | wait_for_ctrl_irq (ctrl); |
256 | } | 256 | } |
257 | 257 | ||
258 | /* Done with exclusive hardware access */ | 258 | /* Done with exclusive hardware access */ |
259 | up(&ctrl->crit_sect); | 259 | mutex_unlock(&ctrl->crit_sect); |
260 | } | 260 | } |
261 | 261 | ||
262 | /** | 262 | /** |
@@ -279,13 +279,13 @@ static int board_added(struct slot *p_slot) | |||
279 | ctrl->slot_device_offset, hp_slot); | 279 | ctrl->slot_device_offset, hp_slot); |
280 | 280 | ||
281 | /* Wait for exclusive access to hardware */ | 281 | /* Wait for exclusive access to hardware */ |
282 | down(&ctrl->crit_sect); | 282 | mutex_lock(&ctrl->crit_sect); |
283 | 283 | ||
284 | if (POWER_CTRL(ctrl->ctrlcap)) { | 284 | if (POWER_CTRL(ctrl->ctrlcap)) { |
285 | /* Power on slot */ | 285 | /* Power on slot */ |
286 | rc = p_slot->hpc_ops->power_on_slot(p_slot); | 286 | rc = p_slot->hpc_ops->power_on_slot(p_slot); |
287 | if (rc) { | 287 | if (rc) { |
288 | up(&ctrl->crit_sect); | 288 | mutex_unlock(&ctrl->crit_sect); |
289 | return -1; | 289 | return -1; |
290 | } | 290 | } |
291 | 291 | ||
@@ -301,7 +301,7 @@ static int board_added(struct slot *p_slot) | |||
301 | } | 301 | } |
302 | 302 | ||
303 | /* Done with exclusive hardware access */ | 303 | /* Done with exclusive hardware access */ |
304 | up(&ctrl->crit_sect); | 304 | mutex_unlock(&ctrl->crit_sect); |
305 | 305 | ||
306 | /* Wait for ~1 second */ | 306 | /* Wait for ~1 second */ |
307 | wait_for_ctrl_irq (ctrl); | 307 | wait_for_ctrl_irq (ctrl); |
@@ -335,7 +335,7 @@ static int board_added(struct slot *p_slot) | |||
335 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); | 335 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); |
336 | if (PWR_LED(ctrl->ctrlcap)) { | 336 | if (PWR_LED(ctrl->ctrlcap)) { |
337 | /* Wait for exclusive access to hardware */ | 337 | /* Wait for exclusive access to hardware */ |
338 | down(&ctrl->crit_sect); | 338 | mutex_lock(&ctrl->crit_sect); |
339 | 339 | ||
340 | p_slot->hpc_ops->green_led_on(p_slot); | 340 | p_slot->hpc_ops->green_led_on(p_slot); |
341 | 341 | ||
@@ -343,7 +343,7 @@ static int board_added(struct slot *p_slot) | |||
343 | wait_for_ctrl_irq (ctrl); | 343 | wait_for_ctrl_irq (ctrl); |
344 | 344 | ||
345 | /* Done with exclusive hardware access */ | 345 | /* Done with exclusive hardware access */ |
346 | up(&ctrl->crit_sect); | 346 | mutex_unlock(&ctrl->crit_sect); |
347 | } | 347 | } |
348 | return 0; | 348 | return 0; |
349 | 349 | ||
@@ -375,14 +375,14 @@ static int remove_board(struct slot *p_slot) | |||
375 | dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); | 375 | dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); |
376 | 376 | ||
377 | /* Wait for exclusive access to hardware */ | 377 | /* Wait for exclusive access to hardware */ |
378 | down(&ctrl->crit_sect); | 378 | mutex_lock(&ctrl->crit_sect); |
379 | 379 | ||
380 | if (POWER_CTRL(ctrl->ctrlcap)) { | 380 | if (POWER_CTRL(ctrl->ctrlcap)) { |
381 | /* power off slot */ | 381 | /* power off slot */ |
382 | rc = p_slot->hpc_ops->power_off_slot(p_slot); | 382 | rc = p_slot->hpc_ops->power_off_slot(p_slot); |
383 | if (rc) { | 383 | if (rc) { |
384 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); | 384 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
385 | up(&ctrl->crit_sect); | 385 | mutex_unlock(&ctrl->crit_sect); |
386 | return rc; | 386 | return rc; |
387 | } | 387 | } |
388 | /* Wait for the command to complete */ | 388 | /* Wait for the command to complete */ |
@@ -398,7 +398,7 @@ static int remove_board(struct slot *p_slot) | |||
398 | } | 398 | } |
399 | 399 | ||
400 | /* Done with exclusive hardware access */ | 400 | /* Done with exclusive hardware access */ |
401 | up(&ctrl->crit_sect); | 401 | mutex_unlock(&ctrl->crit_sect); |
402 | 402 | ||
403 | return 0; | 403 | return 0; |
404 | } | 404 | } |
@@ -445,7 +445,7 @@ static void pciehp_pushbutton_thread(unsigned long slot) | |||
445 | 445 | ||
446 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { | 446 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { |
447 | /* Wait for exclusive access to hardware */ | 447 | /* Wait for exclusive access to hardware */ |
448 | down(&p_slot->ctrl->crit_sect); | 448 | mutex_lock(&p_slot->ctrl->crit_sect); |
449 | 449 | ||
450 | p_slot->hpc_ops->green_led_off(p_slot); | 450 | p_slot->hpc_ops->green_led_off(p_slot); |
451 | 451 | ||
@@ -453,7 +453,7 @@ static void pciehp_pushbutton_thread(unsigned long slot) | |||
453 | wait_for_ctrl_irq (p_slot->ctrl); | 453 | wait_for_ctrl_irq (p_slot->ctrl); |
454 | 454 | ||
455 | /* Done with exclusive hardware access */ | 455 | /* Done with exclusive hardware access */ |
456 | up(&p_slot->ctrl->crit_sect); | 456 | mutex_unlock(&p_slot->ctrl->crit_sect); |
457 | } | 457 | } |
458 | p_slot->state = STATIC_STATE; | 458 | p_slot->state = STATIC_STATE; |
459 | } | 459 | } |
@@ -495,7 +495,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot) | |||
495 | 495 | ||
496 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { | 496 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { |
497 | /* Wait for exclusive access to hardware */ | 497 | /* Wait for exclusive access to hardware */ |
498 | down(&p_slot->ctrl->crit_sect); | 498 | mutex_lock(&p_slot->ctrl->crit_sect); |
499 | 499 | ||
500 | p_slot->hpc_ops->green_led_off(p_slot); | 500 | p_slot->hpc_ops->green_led_off(p_slot); |
501 | 501 | ||
@@ -503,7 +503,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot) | |||
503 | wait_for_ctrl_irq (p_slot->ctrl); | 503 | wait_for_ctrl_irq (p_slot->ctrl); |
504 | 504 | ||
505 | /* Done with exclusive hardware access */ | 505 | /* Done with exclusive hardware access */ |
506 | up(&p_slot->ctrl->crit_sect); | 506 | mutex_unlock(&p_slot->ctrl->crit_sect); |
507 | } | 507 | } |
508 | p_slot->state = STATIC_STATE; | 508 | p_slot->state = STATIC_STATE; |
509 | } | 509 | } |
@@ -616,7 +616,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
616 | switch (p_slot->state) { | 616 | switch (p_slot->state) { |
617 | case BLINKINGOFF_STATE: | 617 | case BLINKINGOFF_STATE: |
618 | /* Wait for exclusive access to hardware */ | 618 | /* Wait for exclusive access to hardware */ |
619 | down(&ctrl->crit_sect); | 619 | mutex_lock(&ctrl->crit_sect); |
620 | 620 | ||
621 | if (PWR_LED(ctrl->ctrlcap)) { | 621 | if (PWR_LED(ctrl->ctrlcap)) { |
622 | p_slot->hpc_ops->green_led_on(p_slot); | 622 | p_slot->hpc_ops->green_led_on(p_slot); |
@@ -630,11 +630,11 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
630 | wait_for_ctrl_irq (ctrl); | 630 | wait_for_ctrl_irq (ctrl); |
631 | } | 631 | } |
632 | /* Done with exclusive hardware access */ | 632 | /* Done with exclusive hardware access */ |
633 | up(&ctrl->crit_sect); | 633 | mutex_unlock(&ctrl->crit_sect); |
634 | break; | 634 | break; |
635 | case BLINKINGON_STATE: | 635 | case BLINKINGON_STATE: |
636 | /* Wait for exclusive access to hardware */ | 636 | /* Wait for exclusive access to hardware */ |
637 | down(&ctrl->crit_sect); | 637 | mutex_lock(&ctrl->crit_sect); |
638 | 638 | ||
639 | if (PWR_LED(ctrl->ctrlcap)) { | 639 | if (PWR_LED(ctrl->ctrlcap)) { |
640 | p_slot->hpc_ops->green_led_off(p_slot); | 640 | p_slot->hpc_ops->green_led_off(p_slot); |
@@ -647,7 +647,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
647 | wait_for_ctrl_irq (ctrl); | 647 | wait_for_ctrl_irq (ctrl); |
648 | } | 648 | } |
649 | /* Done with exclusive hardware access */ | 649 | /* Done with exclusive hardware access */ |
650 | up(&ctrl->crit_sect); | 650 | mutex_unlock(&ctrl->crit_sect); |
651 | 651 | ||
652 | break; | 652 | break; |
653 | default: | 653 | default: |
@@ -676,7 +676,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
676 | } | 676 | } |
677 | 677 | ||
678 | /* Wait for exclusive access to hardware */ | 678 | /* Wait for exclusive access to hardware */ |
679 | down(&ctrl->crit_sect); | 679 | mutex_lock(&ctrl->crit_sect); |
680 | 680 | ||
681 | /* blink green LED and turn off amber */ | 681 | /* blink green LED and turn off amber */ |
682 | if (PWR_LED(ctrl->ctrlcap)) { | 682 | if (PWR_LED(ctrl->ctrlcap)) { |
@@ -693,7 +693,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
693 | } | 693 | } |
694 | 694 | ||
695 | /* Done with exclusive hardware access */ | 695 | /* Done with exclusive hardware access */ |
696 | up(&ctrl->crit_sect); | 696 | mutex_unlock(&ctrl->crit_sect); |
697 | 697 | ||
698 | init_timer(&p_slot->task_event); | 698 | init_timer(&p_slot->task_event); |
699 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ | 699 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ |
@@ -708,7 +708,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
708 | if (POWER_CTRL(ctrl->ctrlcap)) { | 708 | if (POWER_CTRL(ctrl->ctrlcap)) { |
709 | dbg("power fault\n"); | 709 | dbg("power fault\n"); |
710 | /* Wait for exclusive access to hardware */ | 710 | /* Wait for exclusive access to hardware */ |
711 | down(&ctrl->crit_sect); | 711 | mutex_lock(&ctrl->crit_sect); |
712 | 712 | ||
713 | if (ATTN_LED(ctrl->ctrlcap)) { | 713 | if (ATTN_LED(ctrl->ctrlcap)) { |
714 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | 714 | p_slot->hpc_ops->set_attention_status(p_slot, 1); |
@@ -721,7 +721,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
721 | } | 721 | } |
722 | 722 | ||
723 | /* Done with exclusive hardware access */ | 723 | /* Done with exclusive hardware access */ |
724 | up(&ctrl->crit_sect); | 724 | mutex_unlock(&ctrl->crit_sect); |
725 | } | 725 | } |
726 | } | 726 | } |
727 | /***********SURPRISE REMOVAL********************/ | 727 | /***********SURPRISE REMOVAL********************/ |
@@ -756,19 +756,19 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
756 | int rc; | 756 | int rc; |
757 | 757 | ||
758 | /* Check to see if (latch closed, card present, power off) */ | 758 | /* Check to see if (latch closed, card present, power off) */ |
759 | down(&p_slot->ctrl->crit_sect); | 759 | mutex_lock(&p_slot->ctrl->crit_sect); |
760 | 760 | ||
761 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 761 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
762 | if (rc || !getstatus) { | 762 | if (rc || !getstatus) { |
763 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 763 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
764 | up(&p_slot->ctrl->crit_sect); | 764 | mutex_unlock(&p_slot->ctrl->crit_sect); |
765 | return 1; | 765 | return 1; |
766 | } | 766 | } |
767 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { | 767 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { |
768 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 768 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
769 | if (rc || getstatus) { | 769 | if (rc || getstatus) { |
770 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 770 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
771 | up(&p_slot->ctrl->crit_sect); | 771 | mutex_unlock(&p_slot->ctrl->crit_sect); |
772 | return 1; | 772 | return 1; |
773 | } | 773 | } |
774 | } | 774 | } |
@@ -777,11 +777,11 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
777 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 777 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
778 | if (rc || getstatus) { | 778 | if (rc || getstatus) { |
779 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); | 779 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); |
780 | up(&p_slot->ctrl->crit_sect); | 780 | mutex_unlock(&p_slot->ctrl->crit_sect); |
781 | return 1; | 781 | return 1; |
782 | } | 782 | } |
783 | } | 783 | } |
784 | up(&p_slot->ctrl->crit_sect); | 784 | mutex_unlock(&p_slot->ctrl->crit_sect); |
785 | 785 | ||
786 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 786 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
787 | 787 | ||
@@ -806,13 +806,13 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
806 | return 1; | 806 | return 1; |
807 | 807 | ||
808 | /* Check to see if (latch closed, card present, power on) */ | 808 | /* Check to see if (latch closed, card present, power on) */ |
809 | down(&p_slot->ctrl->crit_sect); | 809 | mutex_lock(&p_slot->ctrl->crit_sect); |
810 | 810 | ||
811 | if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { | 811 | if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { |
812 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 812 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
813 | if (ret || !getstatus) { | 813 | if (ret || !getstatus) { |
814 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 814 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
815 | up(&p_slot->ctrl->crit_sect); | 815 | mutex_unlock(&p_slot->ctrl->crit_sect); |
816 | return 1; | 816 | return 1; |
817 | } | 817 | } |
818 | } | 818 | } |
@@ -821,7 +821,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
821 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 821 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
822 | if (ret || getstatus) { | 822 | if (ret || getstatus) { |
823 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 823 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
824 | up(&p_slot->ctrl->crit_sect); | 824 | mutex_unlock(&p_slot->ctrl->crit_sect); |
825 | return 1; | 825 | return 1; |
826 | } | 826 | } |
827 | } | 827 | } |
@@ -830,12 +830,12 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
830 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 830 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
831 | if (ret || !getstatus) { | 831 | if (ret || !getstatus) { |
832 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); | 832 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); |
833 | up(&p_slot->ctrl->crit_sect); | 833 | mutex_unlock(&p_slot->ctrl->crit_sect); |
834 | return 1; | 834 | return 1; |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | up(&p_slot->ctrl->crit_sect); | 838 | mutex_unlock(&p_slot->ctrl->crit_sect); |
839 | 839 | ||
840 | ret = remove_board(p_slot); | 840 | ret = remove_board(p_slot); |
841 | update_slot_info(p_slot); | 841 | update_slot_info(p_slot); |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 77e530321de2..6c14d9e46b2e 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -38,7 +38,10 @@ | |||
38 | 38 | ||
39 | #include "../pci.h" | 39 | #include "../pci.h" |
40 | #include "pciehp.h" | 40 | #include "pciehp.h" |
41 | 41 | #include <acpi/acpi.h> | |
42 | #include <acpi/acpi_bus.h> | ||
43 | #include <acpi/actypes.h> | ||
44 | #include <linux/pci-acpi.h> | ||
42 | #ifdef DEBUG | 45 | #ifdef DEBUG |
43 | #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */ | 46 | #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */ |
44 | #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */ | 47 | #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */ |
@@ -1236,6 +1239,76 @@ static struct hpc_ops pciehp_hpc_ops = { | |||
1236 | .check_lnk_status = hpc_check_lnk_status, | 1239 | .check_lnk_status = hpc_check_lnk_status, |
1237 | }; | 1240 | }; |
1238 | 1241 | ||
1242 | #ifdef CONFIG_ACPI | ||
1243 | int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
1244 | { | ||
1245 | acpi_status status; | ||
1246 | acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
1247 | struct pci_dev *pdev = dev; | ||
1248 | struct pci_bus *parent; | ||
1249 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
1250 | |||
1251 | /* | ||
1252 | * Per PCI firmware specification, we should run the ACPI _OSC | ||
1253 | * method to get control of hotplug hardware before using it. | ||
1254 | * If an _OSC is missing, we look for an OSHP to do the same thing. | ||
1255 | * To handle different BIOS behavior, we look for _OSC and OSHP | ||
1256 | * within the scope of the hotplug controller and its parents, upto | ||
1257 | * the host bridge under which this controller exists. | ||
1258 | */ | ||
1259 | while (!handle) { | ||
1260 | /* | ||
1261 | * This hotplug controller was not listed in the ACPI name | ||
1262 | * space at all. Try to get acpi handle of parent pci bus. | ||
1263 | */ | ||
1264 | if (!pdev || !pdev->bus->parent) | ||
1265 | break; | ||
1266 | parent = pdev->bus->parent; | ||
1267 | dbg("Could not find %s in acpi namespace, trying parent\n", | ||
1268 | pci_name(pdev)); | ||
1269 | if (!parent->self) | ||
1270 | /* Parent must be a host bridge */ | ||
1271 | handle = acpi_get_pci_rootbridge_handle( | ||
1272 | pci_domain_nr(parent), | ||
1273 | parent->number); | ||
1274 | else | ||
1275 | handle = DEVICE_ACPI_HANDLE( | ||
1276 | &(parent->self->dev)); | ||
1277 | pdev = parent->self; | ||
1278 | } | ||
1279 | |||
1280 | while (handle) { | ||
1281 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
1282 | dbg("Trying to get hotplug control for %s \n", | ||
1283 | (char *)string.pointer); | ||
1284 | status = pci_osc_control_set(handle, | ||
1285 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); | ||
1286 | if (status == AE_NOT_FOUND) | ||
1287 | status = acpi_run_oshp(handle); | ||
1288 | if (ACPI_SUCCESS(status)) { | ||
1289 | dbg("Gained control for hotplug HW for pci %s (%s)\n", | ||
1290 | pci_name(dev), (char *)string.pointer); | ||
1291 | acpi_os_free(string.pointer); | ||
1292 | return 0; | ||
1293 | } | ||
1294 | if (acpi_root_bridge(handle)) | ||
1295 | break; | ||
1296 | chandle = handle; | ||
1297 | status = acpi_get_parent(chandle, &handle); | ||
1298 | if (ACPI_FAILURE(status)) | ||
1299 | break; | ||
1300 | } | ||
1301 | |||
1302 | err("Cannot get control of hotplug hardware for pci %s\n", | ||
1303 | pci_name(dev)); | ||
1304 | |||
1305 | acpi_os_free(string.pointer); | ||
1306 | return -1; | ||
1307 | } | ||
1308 | #endif | ||
1309 | |||
1310 | |||
1311 | |||
1239 | int pcie_init(struct controller * ctrl, struct pcie_device *dev) | 1312 | int pcie_init(struct controller * ctrl, struct pcie_device *dev) |
1240 | { | 1313 | { |
1241 | struct php_ctlr_state_s *php_ctlr, *p; | 1314 | struct php_ctlr_state_s *php_ctlr, *p; |
@@ -1334,7 +1407,7 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev) | |||
1334 | if (pci_enable_device(pdev)) | 1407 | if (pci_enable_device(pdev)) |
1335 | goto abort_free_ctlr; | 1408 | goto abort_free_ctlr; |
1336 | 1409 | ||
1337 | init_MUTEX(&ctrl->crit_sect); | 1410 | mutex_init(&ctrl->crit_sect); |
1338 | /* setup wait queue */ | 1411 | /* setup wait queue */ |
1339 | init_waitqueue_head(&ctrl->queue); | 1412 | init_waitqueue_head(&ctrl->queue); |
1340 | 1413 | ||
diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c deleted file mode 100644 index 2bdb30f68bf8..000000000000 --- a/drivers/pci/hotplug/pciehprm_acpi.c +++ /dev/null | |||
@@ -1,257 +0,0 @@ | |||
1 | /* | ||
2 | * PCIEHPRM ACPI: PHP Resource Manager for ACPI platform | ||
3 | * | ||
4 | * Copyright (C) 2003-2004 Intel Corporation | ||
5 | * | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
16 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | * | ||
23 | * Send feedback to <kristen.c.accardi@intel.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/acpi.h> | ||
32 | #include <linux/pci-acpi.h> | ||
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <acpi/actypes.h> | ||
35 | #include "pciehp.h" | ||
36 | |||
37 | #define METHOD_NAME__SUN "_SUN" | ||
38 | #define METHOD_NAME__HPP "_HPP" | ||
39 | #define METHOD_NAME_OSHP "OSHP" | ||
40 | |||
41 | static u8 * acpi_path_name( acpi_handle handle) | ||
42 | { | ||
43 | acpi_status status; | ||
44 | static u8 path_name[ACPI_PATHNAME_MAX]; | ||
45 | struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name }; | ||
46 | |||
47 | memset(path_name, 0, sizeof (path_name)); | ||
48 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf); | ||
49 | |||
50 | if (ACPI_FAILURE(status)) | ||
51 | return NULL; | ||
52 | else | ||
53 | return path_name; | ||
54 | } | ||
55 | |||
56 | static acpi_status | ||
57 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | ||
58 | { | ||
59 | acpi_status status; | ||
60 | u8 nui[4]; | ||
61 | struct acpi_buffer ret_buf = { 0, NULL}; | ||
62 | union acpi_object *ext_obj, *package; | ||
63 | u8 *path_name = acpi_path_name(handle); | ||
64 | int i, len = 0; | ||
65 | |||
66 | /* get _hpp */ | ||
67 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); | ||
68 | switch (status) { | ||
69 | case AE_BUFFER_OVERFLOW: | ||
70 | ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); | ||
71 | if (!ret_buf.pointer) { | ||
72 | err ("%s:%s alloc for _HPP fail\n", __FUNCTION__, | ||
73 | path_name); | ||
74 | return AE_NO_MEMORY; | ||
75 | } | ||
76 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, | ||
77 | NULL, &ret_buf); | ||
78 | if (ACPI_SUCCESS(status)) | ||
79 | break; | ||
80 | default: | ||
81 | if (ACPI_FAILURE(status)) { | ||
82 | dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__, | ||
83 | path_name, status); | ||
84 | return status; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | ext_obj = (union acpi_object *) ret_buf.pointer; | ||
89 | if (ext_obj->type != ACPI_TYPE_PACKAGE) { | ||
90 | err ("%s:%s _HPP obj not a package\n", __FUNCTION__, | ||
91 | path_name); | ||
92 | status = AE_ERROR; | ||
93 | goto free_and_return; | ||
94 | } | ||
95 | |||
96 | len = ext_obj->package.count; | ||
97 | package = (union acpi_object *) ret_buf.pointer; | ||
98 | for ( i = 0; (i < len) || (i < 4); i++) { | ||
99 | ext_obj = (union acpi_object *) &package->package.elements[i]; | ||
100 | switch (ext_obj->type) { | ||
101 | case ACPI_TYPE_INTEGER: | ||
102 | nui[i] = (u8)ext_obj->integer.value; | ||
103 | break; | ||
104 | default: | ||
105 | err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__, | ||
106 | path_name); | ||
107 | status = AE_ERROR; | ||
108 | goto free_and_return; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | hpp->cache_line_size = nui[0]; | ||
113 | hpp->latency_timer = nui[1]; | ||
114 | hpp->enable_serr = nui[2]; | ||
115 | hpp->enable_perr = nui[3]; | ||
116 | |||
117 | dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size); | ||
118 | dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer); | ||
119 | dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr); | ||
120 | dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); | ||
121 | |||
122 | free_and_return: | ||
123 | kfree(ret_buf.pointer); | ||
124 | return status; | ||
125 | } | ||
126 | |||
127 | static acpi_status acpi_run_oshp(acpi_handle handle) | ||
128 | { | ||
129 | acpi_status status; | ||
130 | u8 *path_name = acpi_path_name(handle); | ||
131 | |||
132 | /* run OSHP */ | ||
133 | status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); | ||
134 | if (ACPI_FAILURE(status)) { | ||
135 | dbg("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name, | ||
136 | status); | ||
137 | } else { | ||
138 | dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name); | ||
139 | } | ||
140 | return status; | ||
141 | } | ||
142 | |||
143 | static int is_root_bridge(acpi_handle handle) | ||
144 | { | ||
145 | acpi_status status; | ||
146 | struct acpi_device_info *info; | ||
147 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
148 | int i; | ||
149 | |||
150 | status = acpi_get_object_info(handle, &buffer); | ||
151 | if (ACPI_SUCCESS(status)) { | ||
152 | info = buffer.pointer; | ||
153 | if ((info->valid & ACPI_VALID_HID) && | ||
154 | !strcmp(PCI_ROOT_HID_STRING, | ||
155 | info->hardware_id.value)) { | ||
156 | acpi_os_free(buffer.pointer); | ||
157 | return 1; | ||
158 | } | ||
159 | if (info->valid & ACPI_VALID_CID) { | ||
160 | for (i=0; i < info->compatibility_id.count; i++) { | ||
161 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
162 | info->compatibility_id.id[i].value)) { | ||
163 | acpi_os_free(buffer.pointer); | ||
164 | return 1; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
173 | { | ||
174 | acpi_status status; | ||
175 | acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
176 | struct pci_dev *pdev = dev; | ||
177 | struct pci_bus *parent; | ||
178 | u8 *path_name; | ||
179 | |||
180 | /* | ||
181 | * Per PCI firmware specification, we should run the ACPI _OSC | ||
182 | * method to get control of hotplug hardware before using it. | ||
183 | * If an _OSC is missing, we look for an OSHP to do the same thing. | ||
184 | * To handle different BIOS behavior, we look for _OSC and OSHP | ||
185 | * within the scope of the hotplug controller and its parents, upto | ||
186 | * the host bridge under which this controller exists. | ||
187 | */ | ||
188 | while (!handle) { | ||
189 | /* | ||
190 | * This hotplug controller was not listed in the ACPI name | ||
191 | * space at all. Try to get acpi handle of parent pci bus. | ||
192 | */ | ||
193 | if (!pdev || !pdev->bus->parent) | ||
194 | break; | ||
195 | parent = pdev->bus->parent; | ||
196 | dbg("Could not find %s in acpi namespace, trying parent\n", | ||
197 | pci_name(pdev)); | ||
198 | if (!parent->self) | ||
199 | /* Parent must be a host bridge */ | ||
200 | handle = acpi_get_pci_rootbridge_handle( | ||
201 | pci_domain_nr(parent), | ||
202 | parent->number); | ||
203 | else | ||
204 | handle = DEVICE_ACPI_HANDLE( | ||
205 | &(parent->self->dev)); | ||
206 | pdev = parent->self; | ||
207 | } | ||
208 | |||
209 | while (handle) { | ||
210 | path_name = acpi_path_name(handle); | ||
211 | dbg("Trying to get hotplug control for %s \n", path_name); | ||
212 | status = pci_osc_control_set(handle, | ||
213 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); | ||
214 | if (status == AE_NOT_FOUND) | ||
215 | status = acpi_run_oshp(handle); | ||
216 | if (ACPI_SUCCESS(status)) { | ||
217 | dbg("Gained control for hotplug HW for pci %s (%s)\n", | ||
218 | pci_name(dev), path_name); | ||
219 | return 0; | ||
220 | } | ||
221 | if (is_root_bridge(handle)) | ||
222 | break; | ||
223 | chandle = handle; | ||
224 | status = acpi_get_parent(chandle, &handle); | ||
225 | if (ACPI_FAILURE(status)) | ||
226 | break; | ||
227 | } | ||
228 | |||
229 | err("Cannot get control of hotplug hardware for pci %s\n", | ||
230 | pci_name(dev)); | ||
231 | return -1; | ||
232 | } | ||
233 | |||
234 | void pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
235 | struct hotplug_params *hpp) | ||
236 | { | ||
237 | acpi_status status = AE_NOT_FOUND; | ||
238 | struct pci_dev *pdev = dev; | ||
239 | |||
240 | /* | ||
241 | * _HPP settings apply to all child buses, until another _HPP is | ||
242 | * encountered. If we don't find an _HPP for the input pci dev, | ||
243 | * look for it in the parent device scope since that would apply to | ||
244 | * this pci dev. If we don't find any _HPP, use hardcoded defaults | ||
245 | */ | ||
246 | while (pdev && (ACPI_FAILURE(status))) { | ||
247 | acpi_handle handle = DEVICE_ACPI_HANDLE(&(pdev->dev)); | ||
248 | if (!handle) | ||
249 | break; | ||
250 | status = acpi_run_hpp(handle, hpp); | ||
251 | if (!(pdev->bus->parent)) | ||
252 | break; | ||
253 | /* Check if a parent object supports _HPP */ | ||
254 | pdev = pdev->bus->parent->self; | ||
255 | } | ||
256 | } | ||
257 | |||
diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.c b/drivers/pci/hotplug/pciehprm_nonacpi.c deleted file mode 100644 index 29180dfe8493..000000000000 --- a/drivers/pci/hotplug/pciehprm_nonacpi.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * PCIEHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2003-2004 Intel Corporation | ||
8 | * | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/sched.h> | ||
34 | #include <linux/pci.h> | ||
35 | #include <linux/slab.h> | ||
36 | #include "pciehp.h" | ||
37 | |||
38 | void pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
39 | struct hotplug_params *hpp) | ||
40 | { | ||
41 | return; | ||
42 | } | ||
43 | |||
44 | int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
45 | { | ||
46 | return 0; | ||
47 | } | ||
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c index 3194d51c6ec9..0a46f549676a 100644 --- a/drivers/pci/hotplug/pcihp_skeleton.c +++ b/drivers/pci/hotplug/pcihp_skeleton.c | |||
@@ -37,10 +37,12 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
39 | 39 | ||
40 | #define SLOT_NAME_SIZE 10 | ||
40 | struct slot { | 41 | struct slot { |
41 | u8 number; | 42 | u8 number; |
42 | struct hotplug_slot *hotplug_slot; | 43 | struct hotplug_slot *hotplug_slot; |
43 | struct list_head slot_list; | 44 | struct list_head slot_list; |
45 | char name[SLOT_NAME_SIZE]; | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | static LIST_HEAD(slot_list); | 48 | static LIST_HEAD(slot_list); |
@@ -233,12 +235,10 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
233 | 235 | ||
234 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 236 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
235 | kfree(slot->hotplug_slot->info); | 237 | kfree(slot->hotplug_slot->info); |
236 | kfree(slot->hotplug_slot->name); | ||
237 | kfree(slot->hotplug_slot); | 238 | kfree(slot->hotplug_slot); |
238 | kfree(slot); | 239 | kfree(slot); |
239 | } | 240 | } |
240 | 241 | ||
241 | #define SLOT_NAME_SIZE 10 | ||
242 | static void make_slot_name(struct slot *slot) | 242 | static void make_slot_name(struct slot *slot) |
243 | { | 243 | { |
244 | /* | 244 | /* |
@@ -257,7 +257,6 @@ static int __init init_slots(void) | |||
257 | struct slot *slot; | 257 | struct slot *slot; |
258 | struct hotplug_slot *hotplug_slot; | 258 | struct hotplug_slot *hotplug_slot; |
259 | struct hotplug_slot_info *info; | 259 | struct hotplug_slot_info *info; |
260 | char *name; | ||
261 | int retval = -ENOMEM; | 260 | int retval = -ENOMEM; |
262 | int i; | 261 | int i; |
263 | 262 | ||
@@ -266,31 +265,23 @@ static int __init init_slots(void) | |||
266 | * with the pci_hotplug subsystem. | 265 | * with the pci_hotplug subsystem. |
267 | */ | 266 | */ |
268 | for (i = 0; i < num_slots; ++i) { | 267 | for (i = 0; i < num_slots; ++i) { |
269 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 268 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
270 | if (!slot) | 269 | if (!slot) |
271 | goto error; | 270 | goto error; |
272 | memset(slot, 0, sizeof(struct slot)); | ||
273 | 271 | ||
274 | hotplug_slot = kmalloc(sizeof(struct hotplug_slot), | 272 | hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
275 | GFP_KERNEL); | ||
276 | if (!hotplug_slot) | 273 | if (!hotplug_slot) |
277 | goto error_slot; | 274 | goto error_slot; |
278 | memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); | ||
279 | slot->hotplug_slot = hotplug_slot; | 275 | slot->hotplug_slot = hotplug_slot; |
280 | 276 | ||
281 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 277 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
282 | if (!info) | 278 | if (!info) |
283 | goto error_hpslot; | 279 | goto error_hpslot; |
284 | memset(info, 0, sizeof (struct hotplug_slot_info)); | ||
285 | hotplug_slot->info = info; | 280 | hotplug_slot->info = info; |
286 | 281 | ||
287 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | ||
288 | if (!name) | ||
289 | goto error_info; | ||
290 | hotplug_slot->name = name; | ||
291 | |||
292 | slot->number = i; | 282 | slot->number = i; |
293 | 283 | ||
284 | hotplug_slot->name = slot->name; | ||
294 | hotplug_slot->private = slot; | 285 | hotplug_slot->private = slot; |
295 | hotplug_slot->release = &release_slot; | 286 | hotplug_slot->release = &release_slot; |
296 | make_slot_name(slot); | 287 | make_slot_name(slot); |
@@ -300,16 +291,16 @@ static int __init init_slots(void) | |||
300 | * Initialize the slot info structure with some known | 291 | * Initialize the slot info structure with some known |
301 | * good values. | 292 | * good values. |
302 | */ | 293 | */ |
303 | info->power_status = get_power_status(slot); | 294 | get_power_status(hotplug_slot, &info->power_status); |
304 | info->attention_status = get_attention_status(slot); | 295 | get_attention_status(hotplug_slot, &info->attention_status); |
305 | info->latch_status = get_latch_status(slot); | 296 | get_latch_status(hotplug_slot, &info->latch_status); |
306 | info->adapter_status = get_adapter_status(slot); | 297 | get_adapter_status(hotplug_slot, &info->adapter_status); |
307 | 298 | ||
308 | dbg("registering slot %d\n", i); | 299 | dbg("registering slot %d\n", i); |
309 | retval = pci_hp_register(slot->hotplug_slot); | 300 | retval = pci_hp_register(slot->hotplug_slot); |
310 | if (retval) { | 301 | if (retval) { |
311 | err("pci_hp_register failed with error %d\n", retval); | 302 | err("pci_hp_register failed with error %d\n", retval); |
312 | goto error_name; | 303 | goto error_info; |
313 | } | 304 | } |
314 | 305 | ||
315 | /* add slot to our internal list */ | 306 | /* add slot to our internal list */ |
@@ -317,8 +308,6 @@ static int __init init_slots(void) | |||
317 | } | 308 | } |
318 | 309 | ||
319 | return 0; | 310 | return 0; |
320 | error_name: | ||
321 | kfree(name); | ||
322 | error_info: | 311 | error_info: |
323 | kfree(info); | 312 | kfree(info); |
324 | error_hpslot: | 313 | error_hpslot: |
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 78943e064b59..b771196a654e 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -84,19 +84,16 @@ struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_ | |||
84 | { | 84 | { |
85 | struct slot *slot; | 85 | struct slot *slot; |
86 | 86 | ||
87 | slot = kmalloc(sizeof (struct slot), GFP_KERNEL); | 87 | slot = kzalloc(sizeof(struct slot), GFP_KERNEL); |
88 | if (!slot) | 88 | if (!slot) |
89 | goto error_nomem; | 89 | goto error_nomem; |
90 | memset(slot, 0, sizeof (struct slot)); | 90 | slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
91 | slot->hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); | ||
92 | if (!slot->hotplug_slot) | 91 | if (!slot->hotplug_slot) |
93 | goto error_slot; | 92 | goto error_slot; |
94 | memset(slot->hotplug_slot, 0, sizeof (struct hotplug_slot)); | 93 | slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), |
95 | slot->hotplug_slot->info = kmalloc(sizeof (struct hotplug_slot_info), | ||
96 | GFP_KERNEL); | 94 | GFP_KERNEL); |
97 | if (!slot->hotplug_slot->info) | 95 | if (!slot->hotplug_slot->info) |
98 | goto error_hpslot; | 96 | goto error_hpslot; |
99 | memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info)); | ||
100 | slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL); | 97 | slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL); |
101 | if (!slot->hotplug_slot->name) | 98 | if (!slot->hotplug_slot->name) |
102 | goto error_info; | 99 | goto error_info; |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index a32ae82e5922..c402da8e78ae 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * License. See the file "COPYING" in the main directory of this archive | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (C) 2005 Silicon Graphics, Inc. All rights reserved. | 6 | * Copyright (C) 2005-2006 Silicon Graphics, Inc. All rights reserved. |
7 | * | 7 | * |
8 | * This work was based on the 2.4/2.6 kernel development by Dick Reigner. | 8 | * This work was based on the 2.4/2.6 kernel development by Dick Reigner. |
9 | * Work to add BIOS PROM support was completed by Mike Habeck. | 9 | * Work to add BIOS PROM support was completed by Mike Habeck. |
@@ -230,6 +230,13 @@ static void sn_bus_free_data(struct pci_dev *dev) | |||
230 | list_for_each_entry(child, &subordinate_bus->devices, bus_list) | 230 | list_for_each_entry(child, &subordinate_bus->devices, bus_list) |
231 | sn_bus_free_data(child); | 231 | sn_bus_free_data(child); |
232 | } | 232 | } |
233 | /* | ||
234 | * Some drivers may use dma accesses during the | ||
235 | * driver remove function. We release the sysdata | ||
236 | * areas after the driver remove functions have | ||
237 | * been called. | ||
238 | */ | ||
239 | sn_bus_store_sysdata(dev); | ||
233 | sn_pci_unfixup_slot(dev); | 240 | sn_pci_unfixup_slot(dev); |
234 | } | 241 | } |
235 | 242 | ||
@@ -429,13 +436,6 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
429 | PCI_DEVFN(slot->device_num + 1, | 436 | PCI_DEVFN(slot->device_num + 1, |
430 | PCI_FUNC(func))); | 437 | PCI_FUNC(func))); |
431 | if (dev) { | 438 | if (dev) { |
432 | /* | ||
433 | * Some drivers may use dma accesses during the | ||
434 | * driver remove function. We release the sysdata | ||
435 | * areas after the driver remove functions have | ||
436 | * been called. | ||
437 | */ | ||
438 | sn_bus_store_sysdata(dev); | ||
439 | sn_bus_free_data(dev); | 439 | sn_bus_free_data(dev); |
440 | pci_remove_bus_device(dev); | 440 | pci_remove_bus_device(dev); |
441 | pci_dev_put(dev); | 441 | pci_dev_put(dev); |
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 7d6f521d02ea..5c70f43908c4 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/sched.h> /* signal_pending(), struct timer_list */ | 35 | #include <linux/sched.h> /* signal_pending(), struct timer_list */ |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
38 | 39 | ||
@@ -45,6 +46,7 @@ | |||
45 | extern int shpchp_poll_mode; | 46 | extern int shpchp_poll_mode; |
46 | extern int shpchp_poll_time; | 47 | extern int shpchp_poll_time; |
47 | extern int shpchp_debug; | 48 | extern int shpchp_debug; |
49 | extern struct workqueue_struct *shpchp_wq; | ||
48 | 50 | ||
49 | /*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ | 51 | /*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ |
50 | #define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) | 52 | #define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) |
@@ -52,10 +54,8 @@ extern int shpchp_debug; | |||
52 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 54 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) |
53 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 55 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
54 | 56 | ||
55 | #define SLOT_MAGIC 0x67267321 | 57 | #define SLOT_NAME_SIZE 10 |
56 | struct slot { | 58 | struct slot { |
57 | u32 magic; | ||
58 | struct slot *next; | ||
59 | u8 bus; | 59 | u8 bus; |
60 | u8 device; | 60 | u8 device; |
61 | u16 status; | 61 | u16 status; |
@@ -70,26 +70,27 @@ struct slot { | |||
70 | struct hpc_ops *hpc_ops; | 70 | struct hpc_ops *hpc_ops; |
71 | struct hotplug_slot *hotplug_slot; | 71 | struct hotplug_slot *hotplug_slot; |
72 | struct list_head slot_list; | 72 | struct list_head slot_list; |
73 | char name[SLOT_NAME_SIZE]; | ||
74 | struct work_struct work; /* work for button event */ | ||
75 | struct mutex lock; | ||
73 | }; | 76 | }; |
74 | 77 | ||
75 | struct event_info { | 78 | struct event_info { |
76 | u32 event_type; | 79 | u32 event_type; |
77 | u8 hp_slot; | 80 | struct slot *p_slot; |
81 | struct work_struct work; | ||
78 | }; | 82 | }; |
79 | 83 | ||
80 | struct controller { | 84 | struct controller { |
81 | struct controller *next; | 85 | struct mutex crit_sect; /* critical section mutex */ |
82 | struct semaphore crit_sect; /* critical section semaphore */ | 86 | struct mutex cmd_lock; /* command lock */ |
83 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ | 87 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ |
84 | int num_slots; /* Number of slots on ctlr */ | 88 | int num_slots; /* Number of slots on ctlr */ |
85 | int slot_num_inc; /* 1 or -1 */ | 89 | int slot_num_inc; /* 1 or -1 */ |
86 | struct pci_dev *pci_dev; | 90 | struct pci_dev *pci_dev; |
87 | struct pci_bus *pci_bus; | 91 | struct list_head slot_list; |
88 | struct event_info event_queue[10]; | ||
89 | struct slot *slot; | ||
90 | struct hpc_ops *hpc_ops; | 92 | struct hpc_ops *hpc_ops; |
91 | wait_queue_head_t queue; /* sleep & wake process */ | 93 | wait_queue_head_t queue; /* sleep & wake process */ |
92 | u8 next_event; | ||
93 | u8 bus; | 94 | u8 bus; |
94 | u8 device; | 95 | u8 device; |
95 | u8 function; | 96 | u8 function; |
@@ -105,12 +106,6 @@ struct controller { | |||
105 | volatile int cmd_busy; | 106 | volatile int cmd_busy; |
106 | }; | 107 | }; |
107 | 108 | ||
108 | struct hotplug_params { | ||
109 | u8 cache_line_size; | ||
110 | u8 latency_timer; | ||
111 | u8 enable_serr; | ||
112 | u8 enable_perr; | ||
113 | }; | ||
114 | 109 | ||
115 | /* Define AMD SHPC ID */ | 110 | /* Define AMD SHPC ID */ |
116 | #define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450 | 111 | #define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450 |
@@ -180,11 +175,8 @@ struct hotplug_params { | |||
180 | /* sysfs functions for the hotplug controller info */ | 175 | /* sysfs functions for the hotplug controller info */ |
181 | extern void shpchp_create_ctrl_files (struct controller *ctrl); | 176 | extern void shpchp_create_ctrl_files (struct controller *ctrl); |
182 | 177 | ||
183 | /* controller functions */ | 178 | extern int shpchp_sysfs_enable_slot(struct slot *slot); |
184 | extern int shpchp_event_start_thread(void); | 179 | extern int shpchp_sysfs_disable_slot(struct slot *slot); |
185 | extern void shpchp_event_stop_thread(void); | ||
186 | extern int shpchp_enable_slot(struct slot *slot); | ||
187 | extern int shpchp_disable_slot(struct slot *slot); | ||
188 | 180 | ||
189 | extern u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id); | 181 | extern u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id); |
190 | extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id); | 182 | extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id); |
@@ -195,16 +187,28 @@ extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id); | |||
195 | extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); | 187 | extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); |
196 | extern int shpchp_configure_device(struct slot *p_slot); | 188 | extern int shpchp_configure_device(struct slot *p_slot); |
197 | extern int shpchp_unconfigure_device(struct slot *p_slot); | 189 | extern int shpchp_unconfigure_device(struct slot *p_slot); |
198 | extern void get_hp_hw_control_from_firmware(struct pci_dev *dev); | ||
199 | extern void get_hp_params_from_firmware(struct pci_dev *dev, | ||
200 | struct hotplug_params *hpp); | ||
201 | extern int shpchprm_get_physical_slot_number(struct controller *ctrl, | ||
202 | u32 *sun, u8 busnum, u8 devnum); | ||
203 | extern void shpchp_remove_ctrl_files(struct controller *ctrl); | 190 | extern void shpchp_remove_ctrl_files(struct controller *ctrl); |
191 | extern void cleanup_slots(struct controller *ctrl); | ||
192 | extern void queue_pushbutton_work(void *data); | ||
204 | 193 | ||
205 | 194 | ||
206 | /* Global variables */ | 195 | #ifdef CONFIG_ACPI |
207 | extern struct controller *shpchp_ctrl_list; | 196 | static inline int get_hp_params_from_firmware(struct pci_dev *dev, |
197 | struct hotplug_params *hpp) | ||
198 | { | ||
199 | if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev, hpp))) | ||
200 | return -ENODEV; | ||
201 | return 0; | ||
202 | } | ||
203 | #define get_hp_hw_control_from_firmware(pdev) \ | ||
204 | do { \ | ||
205 | if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \ | ||
206 | acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev))); \ | ||
207 | } while (0) | ||
208 | #else | ||
209 | #define get_hp_params_from_firmware(dev, hpp) (-ENODEV) | ||
210 | #define get_hp_hw_control_from_firmware(dev) do { } while (0) | ||
211 | #endif | ||
208 | 212 | ||
209 | struct ctrl_reg { | 213 | struct ctrl_reg { |
210 | volatile u32 base_offset; | 214 | volatile u32 base_offset; |
@@ -286,10 +290,6 @@ static inline int slot_paranoia_check (struct slot *slot, const char *function) | |||
286 | dbg("%s - slot == NULL", function); | 290 | dbg("%s - slot == NULL", function); |
287 | return -1; | 291 | return -1; |
288 | } | 292 | } |
289 | if (slot->magic != SLOT_MAGIC) { | ||
290 | dbg("%s - bad magic number for slot", function); | ||
291 | return -1; | ||
292 | } | ||
293 | if (!slot->hotplug_slot) { | 293 | if (!slot->hotplug_slot) { |
294 | dbg("%s - slot->hotplug_slot == NULL!", function); | 294 | dbg("%s - slot->hotplug_slot == NULL!", function); |
295 | return -1; | 295 | return -1; |
@@ -314,44 +314,19 @@ static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const ch | |||
314 | 314 | ||
315 | static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) | 315 | static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) |
316 | { | 316 | { |
317 | struct slot *p_slot, *tmp_slot = NULL; | 317 | struct slot *slot; |
318 | 318 | ||
319 | if (!ctrl) | 319 | if (!ctrl) |
320 | return NULL; | 320 | return NULL; |
321 | 321 | ||
322 | p_slot = ctrl->slot; | 322 | list_for_each_entry(slot, &ctrl->slot_list, slot_list) { |
323 | 323 | if (slot->device == device) | |
324 | while (p_slot && (p_slot->device != device)) { | 324 | return slot; |
325 | tmp_slot = p_slot; | ||
326 | p_slot = p_slot->next; | ||
327 | } | 325 | } |
328 | if (p_slot == NULL) { | ||
329 | err("ERROR: shpchp_find_slot device=0x%x\n", device); | ||
330 | p_slot = tmp_slot; | ||
331 | } | ||
332 | |||
333 | return (p_slot); | ||
334 | } | ||
335 | |||
336 | static inline int wait_for_ctrl_irq (struct controller *ctrl) | ||
337 | { | ||
338 | DECLARE_WAITQUEUE(wait, current); | ||
339 | int retval = 0; | ||
340 | |||
341 | add_wait_queue(&ctrl->queue, &wait); | ||
342 | 326 | ||
343 | if (!shpchp_poll_mode) { | 327 | err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device); |
344 | /* Sleep for up to 1 second */ | ||
345 | msleep_interruptible(1000); | ||
346 | } else { | ||
347 | /* Sleep for up to 2 seconds */ | ||
348 | msleep_interruptible(2000); | ||
349 | } | ||
350 | remove_wait_queue(&ctrl->queue, &wait); | ||
351 | if (signal_pending(current)) | ||
352 | retval = -EINTR; | ||
353 | 328 | ||
354 | return retval; | 329 | return NULL; |
355 | } | 330 | } |
356 | 331 | ||
357 | static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot) | 332 | static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot) |
@@ -427,13 +402,6 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) | |||
427 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp); | 402 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp); |
428 | } | 403 | } |
429 | 404 | ||
430 | #define SLOT_NAME_SIZE 10 | ||
431 | |||
432 | static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) | ||
433 | { | ||
434 | snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number); | ||
435 | } | ||
436 | |||
437 | enum php_ctlr_type { | 405 | enum php_ctlr_type { |
438 | PCI, | 406 | PCI, |
439 | ISA, | 407 | ISA, |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index a2b3f0010cec..3be4d492ccc2 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -32,13 +32,14 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/workqueue.h> | ||
35 | #include "shpchp.h" | 36 | #include "shpchp.h" |
36 | 37 | ||
37 | /* Global variables */ | 38 | /* Global variables */ |
38 | int shpchp_debug; | 39 | int shpchp_debug; |
39 | int shpchp_poll_mode; | 40 | int shpchp_poll_mode; |
40 | int shpchp_poll_time; | 41 | int shpchp_poll_time; |
41 | struct controller *shpchp_ctrl_list; /* = NULL */ | 42 | struct workqueue_struct *shpchp_wq; |
42 | 43 | ||
43 | #define DRIVER_VERSION "0.4" | 44 | #define DRIVER_VERSION "0.4" |
44 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" | 45 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" |
@@ -57,7 +58,6 @@ MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds"); | |||
57 | 58 | ||
58 | #define SHPC_MODULE_NAME "shpchp" | 59 | #define SHPC_MODULE_NAME "shpchp" |
59 | 60 | ||
60 | static int shpc_start_thread (void); | ||
61 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 61 | static int set_attention_status (struct hotplug_slot *slot, u8 value); |
62 | static int enable_slot (struct hotplug_slot *slot); | 62 | static int enable_slot (struct hotplug_slot *slot); |
63 | static int disable_slot (struct hotplug_slot *slot); | 63 | static int disable_slot (struct hotplug_slot *slot); |
@@ -94,107 +94,120 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
94 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 94 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
95 | 95 | ||
96 | kfree(slot->hotplug_slot->info); | 96 | kfree(slot->hotplug_slot->info); |
97 | kfree(slot->hotplug_slot->name); | ||
98 | kfree(slot->hotplug_slot); | 97 | kfree(slot->hotplug_slot); |
99 | kfree(slot); | 98 | kfree(slot); |
100 | } | 99 | } |
101 | 100 | ||
101 | static void make_slot_name(struct slot *slot) | ||
102 | { | ||
103 | snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", | ||
104 | slot->bus, slot->number); | ||
105 | } | ||
106 | |||
107 | |||
108 | |||
109 | |||
110 | static int | ||
111 | shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, | ||
112 | u8 busnum, u8 devnum) | ||
113 | { | ||
114 | int offset = devnum - ctrl->slot_device_offset; | ||
115 | |||
116 | dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, | ||
117 | ctrl->slot_num_inc, offset); | ||
118 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset); | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | |||
123 | |||
102 | static int init_slots(struct controller *ctrl) | 124 | static int init_slots(struct controller *ctrl) |
103 | { | 125 | { |
104 | struct slot *new_slot; | 126 | struct slot *slot; |
105 | u8 number_of_slots; | 127 | struct hotplug_slot *hotplug_slot; |
106 | u8 slot_device; | 128 | struct hotplug_slot_info *info; |
107 | u32 slot_number, sun; | 129 | int retval = -ENOMEM; |
108 | int result = -ENOMEM; | 130 | int i; |
109 | 131 | u32 sun; | |
110 | number_of_slots = ctrl->num_slots; | 132 | |
111 | slot_device = ctrl->slot_device_offset; | 133 | for (i = 0; i < ctrl->num_slots; i++) { |
112 | slot_number = ctrl->first_slot; | 134 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
113 | 135 | if (!slot) | |
114 | while (number_of_slots) { | ||
115 | new_slot = (struct slot *) kmalloc(sizeof(struct slot), GFP_KERNEL); | ||
116 | if (!new_slot) | ||
117 | goto error; | 136 | goto error; |
118 | 137 | ||
119 | memset(new_slot, 0, sizeof(struct slot)); | 138 | hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
120 | new_slot->hotplug_slot = kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL); | 139 | if (!hotplug_slot) |
121 | if (!new_slot->hotplug_slot) | ||
122 | goto error_slot; | 140 | goto error_slot; |
123 | memset(new_slot->hotplug_slot, 0, sizeof (struct hotplug_slot)); | 141 | slot->hotplug_slot = hotplug_slot; |
124 | 142 | ||
125 | new_slot->hotplug_slot->info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL); | 143 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
126 | if (!new_slot->hotplug_slot->info) | 144 | if (!info) |
127 | goto error_hpslot; | 145 | goto error_hpslot; |
128 | memset(new_slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info)); | 146 | hotplug_slot->info = info; |
129 | new_slot->hotplug_slot->name = kmalloc (SLOT_NAME_SIZE, GFP_KERNEL); | 147 | |
130 | if (!new_slot->hotplug_slot->name) | 148 | hotplug_slot->name = slot->name; |
131 | goto error_info; | ||
132 | 149 | ||
133 | new_slot->magic = SLOT_MAGIC; | 150 | slot->hp_slot = i; |
134 | new_slot->ctrl = ctrl; | 151 | slot->ctrl = ctrl; |
135 | new_slot->bus = ctrl->slot_bus; | 152 | slot->bus = ctrl->slot_bus; |
136 | new_slot->device = slot_device; | 153 | slot->device = ctrl->slot_device_offset + i; |
137 | new_slot->hpc_ops = ctrl->hpc_ops; | 154 | slot->hpc_ops = ctrl->hpc_ops; |
155 | mutex_init(&slot->lock); | ||
138 | 156 | ||
139 | if (shpchprm_get_physical_slot_number(ctrl, &sun, | 157 | if (shpchprm_get_physical_slot_number(ctrl, &sun, |
140 | new_slot->bus, new_slot->device)) | 158 | slot->bus, slot->device)) |
141 | goto error_name; | 159 | goto error_info; |
142 | 160 | ||
143 | new_slot->number = sun; | 161 | slot->number = sun; |
144 | new_slot->hp_slot = slot_device - ctrl->slot_device_offset; | 162 | INIT_WORK(&slot->work, queue_pushbutton_work, slot); |
145 | 163 | ||
146 | /* register this slot with the hotplug pci core */ | 164 | /* register this slot with the hotplug pci core */ |
147 | new_slot->hotplug_slot->private = new_slot; | 165 | hotplug_slot->private = slot; |
148 | new_slot->hotplug_slot->release = &release_slot; | 166 | hotplug_slot->release = &release_slot; |
149 | make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); | 167 | make_slot_name(slot); |
150 | new_slot->hotplug_slot->ops = &shpchp_hotplug_slot_ops; | 168 | hotplug_slot->ops = &shpchp_hotplug_slot_ops; |
151 | 169 | ||
152 | new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); | 170 | get_power_status(hotplug_slot, &info->power_status); |
153 | new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status)); | 171 | get_attention_status(hotplug_slot, &info->attention_status); |
154 | new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status)); | 172 | get_latch_status(hotplug_slot, &info->latch_status); |
155 | new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status)); | 173 | get_adapter_status(hotplug_slot, &info->adapter_status); |
156 | 174 | ||
157 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", new_slot->bus, | 175 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " |
158 | new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset); | 176 | "slot_device_offset=%x\n", slot->bus, slot->device, |
159 | result = pci_hp_register (new_slot->hotplug_slot); | 177 | slot->hp_slot, slot->number, ctrl->slot_device_offset); |
160 | if (result) { | 178 | retval = pci_hp_register(slot->hotplug_slot); |
161 | err ("pci_hp_register failed with error %d\n", result); | 179 | if (retval) { |
162 | goto error_name; | 180 | err("pci_hp_register failed with error %d\n", retval); |
181 | goto error_info; | ||
163 | } | 182 | } |
164 | 183 | ||
165 | new_slot->next = ctrl->slot; | 184 | list_add(&slot->slot_list, &ctrl->slot_list); |
166 | ctrl->slot = new_slot; | ||
167 | |||
168 | number_of_slots--; | ||
169 | slot_device++; | ||
170 | slot_number += ctrl->slot_num_inc; | ||
171 | } | 185 | } |
172 | 186 | ||
173 | return 0; | 187 | return 0; |
174 | |||
175 | error_name: | ||
176 | kfree(new_slot->hotplug_slot->name); | ||
177 | error_info: | 188 | error_info: |
178 | kfree(new_slot->hotplug_slot->info); | 189 | kfree(info); |
179 | error_hpslot: | 190 | error_hpslot: |
180 | kfree(new_slot->hotplug_slot); | 191 | kfree(hotplug_slot); |
181 | error_slot: | 192 | error_slot: |
182 | kfree(new_slot); | 193 | kfree(slot); |
183 | error: | 194 | error: |
184 | return result; | 195 | return retval; |
185 | } | 196 | } |
186 | 197 | ||
187 | static void cleanup_slots(struct controller *ctrl) | 198 | void cleanup_slots(struct controller *ctrl) |
188 | { | 199 | { |
189 | struct slot *old_slot, *next_slot; | 200 | struct list_head *tmp; |
190 | 201 | struct list_head *next; | |
191 | old_slot = ctrl->slot; | 202 | struct slot *slot; |
192 | ctrl->slot = NULL; | 203 | |
193 | 204 | list_for_each_safe(tmp, next, &ctrl->slot_list) { | |
194 | while (old_slot) { | 205 | slot = list_entry(tmp, struct slot, slot_list); |
195 | next_slot = old_slot->next; | 206 | list_del(&slot->slot_list); |
196 | pci_hp_deregister(old_slot->hotplug_slot); | 207 | cancel_delayed_work(&slot->work); |
197 | old_slot = next_slot; | 208 | flush_scheduled_work(); |
209 | flush_workqueue(shpchp_wq); | ||
210 | pci_hp_deregister(slot->hotplug_slot); | ||
198 | } | 211 | } |
199 | } | 212 | } |
200 | 213 | ||
@@ -207,9 +220,12 @@ static int get_ctlr_slot_config(struct controller *ctrl) | |||
207 | int rc; | 220 | int rc; |
208 | int flags; | 221 | int flags; |
209 | 222 | ||
210 | rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags); | 223 | rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, |
224 | &first_device_num, &physical_slot_num, | ||
225 | &updown, &flags); | ||
211 | if (rc) { | 226 | if (rc) { |
212 | err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device); | 227 | err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", |
228 | __FUNCTION__, ctrl->bus, ctrl->device); | ||
213 | return -1; | 229 | return -1; |
214 | } | 230 | } |
215 | 231 | ||
@@ -218,19 +234,19 @@ static int get_ctlr_slot_config(struct controller *ctrl) | |||
218 | ctrl->first_slot = physical_slot_num; | 234 | ctrl->first_slot = physical_slot_num; |
219 | ctrl->slot_num_inc = updown; /* either -1 or 1 */ | 235 | ctrl->slot_num_inc = updown; /* either -1 or 1 */ |
220 | 236 | ||
221 | dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n", | 237 | dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d " |
222 | __FUNCTION__, num_ctlr_slots, first_device_num, physical_slot_num, updown, ctrl->bus, ctrl->device); | 238 | "(%x:%x)\n", __FUNCTION__, num_ctlr_slots, first_device_num, |
239 | physical_slot_num, updown, ctrl->bus, ctrl->device); | ||
223 | 240 | ||
224 | return 0; | 241 | return 0; |
225 | } | 242 | } |
226 | 243 | ||
227 | |||
228 | /* | 244 | /* |
229 | * set_attention_status - Turns the Amber LED for a slot on, off or blink | 245 | * set_attention_status - Turns the Amber LED for a slot on, off or blink |
230 | */ | 246 | */ |
231 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | 247 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) |
232 | { | 248 | { |
233 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 249 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
234 | 250 | ||
235 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 251 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
236 | 252 | ||
@@ -240,29 +256,27 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | |||
240 | return 0; | 256 | return 0; |
241 | } | 257 | } |
242 | 258 | ||
243 | |||
244 | static int enable_slot (struct hotplug_slot *hotplug_slot) | 259 | static int enable_slot (struct hotplug_slot *hotplug_slot) |
245 | { | 260 | { |
246 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 261 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
247 | 262 | ||
248 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 263 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
249 | 264 | ||
250 | return shpchp_enable_slot(slot); | 265 | return shpchp_sysfs_enable_slot(slot); |
251 | } | 266 | } |
252 | 267 | ||
253 | |||
254 | static int disable_slot (struct hotplug_slot *hotplug_slot) | 268 | static int disable_slot (struct hotplug_slot *hotplug_slot) |
255 | { | 269 | { |
256 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 270 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
257 | 271 | ||
258 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 272 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
259 | 273 | ||
260 | return shpchp_disable_slot(slot); | 274 | return shpchp_sysfs_disable_slot(slot); |
261 | } | 275 | } |
262 | 276 | ||
263 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | 277 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) |
264 | { | 278 | { |
265 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 279 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
266 | int retval; | 280 | int retval; |
267 | 281 | ||
268 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 282 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -276,7 +290,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
276 | 290 | ||
277 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | 291 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) |
278 | { | 292 | { |
279 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 293 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
280 | int retval; | 294 | int retval; |
281 | 295 | ||
282 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 296 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -290,7 +304,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
290 | 304 | ||
291 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | 305 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) |
292 | { | 306 | { |
293 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 307 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
294 | int retval; | 308 | int retval; |
295 | 309 | ||
296 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 310 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -304,7 +318,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
304 | 318 | ||
305 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | 319 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) |
306 | { | 320 | { |
307 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 321 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
308 | int retval; | 322 | int retval; |
309 | 323 | ||
310 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 324 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -318,7 +332,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
318 | 332 | ||
319 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | 333 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) |
320 | { | 334 | { |
321 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 335 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
322 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; | 336 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; |
323 | 337 | ||
324 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 338 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -330,11 +344,11 @@ static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | |||
330 | 344 | ||
331 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 345 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
332 | { | 346 | { |
333 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 347 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
334 | int retval; | 348 | int retval; |
335 | 349 | ||
336 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 350 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
337 | 351 | ||
338 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); | 352 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); |
339 | if (retval < 0) | 353 | if (retval < 0) |
340 | *value = PCI_SPEED_UNKNOWN; | 354 | *value = PCI_SPEED_UNKNOWN; |
@@ -344,11 +358,11 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
344 | 358 | ||
345 | static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 359 | static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
346 | { | 360 | { |
347 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 361 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
348 | int retval; | 362 | int retval; |
349 | 363 | ||
350 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 364 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
351 | 365 | ||
352 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); | 366 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); |
353 | if (retval < 0) | 367 | if (retval < 0) |
354 | *value = PCI_SPEED_UNKNOWN; | 368 | *value = PCI_SPEED_UNKNOWN; |
@@ -372,61 +386,54 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
372 | int rc; | 386 | int rc; |
373 | struct controller *ctrl; | 387 | struct controller *ctrl; |
374 | struct slot *t_slot; | 388 | struct slot *t_slot; |
375 | int first_device_num; /* first PCI device number supported by this SHPC */ | 389 | int first_device_num; /* first PCI device number */ |
376 | int num_ctlr_slots; /* number of slots supported by this SHPC */ | 390 | int num_ctlr_slots; /* number of slots implemented */ |
377 | 391 | ||
378 | if (!is_shpc_capable(pdev)) | 392 | if (!is_shpc_capable(pdev)) |
379 | return -ENODEV; | 393 | return -ENODEV; |
380 | 394 | ||
381 | ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); | 395 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
382 | if (!ctrl) { | 396 | if (!ctrl) { |
383 | err("%s : out of memory\n", __FUNCTION__); | 397 | err("%s : out of memory\n", __FUNCTION__); |
384 | goto err_out_none; | 398 | goto err_out_none; |
385 | } | 399 | } |
386 | memset(ctrl, 0, sizeof(struct controller)); | 400 | INIT_LIST_HEAD(&ctrl->slot_list); |
387 | 401 | ||
388 | rc = shpc_init(ctrl, pdev); | 402 | rc = shpc_init(ctrl, pdev); |
389 | if (rc) { | 403 | if (rc) { |
390 | dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME); | 404 | dbg("%s: controller initialization failed\n", |
405 | SHPC_MODULE_NAME); | ||
391 | goto err_out_free_ctrl; | 406 | goto err_out_free_ctrl; |
392 | } | 407 | } |
393 | 408 | ||
394 | pci_set_drvdata(pdev, ctrl); | 409 | pci_set_drvdata(pdev, ctrl); |
395 | 410 | ||
396 | ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); | ||
397 | if (!ctrl->pci_bus) { | ||
398 | err("out of memory\n"); | ||
399 | rc = -ENOMEM; | ||
400 | goto err_out_unmap_mmio_region; | ||
401 | } | ||
402 | |||
403 | memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus)); | ||
404 | ctrl->bus = pdev->bus->number; | 411 | ctrl->bus = pdev->bus->number; |
405 | ctrl->slot_bus = pdev->subordinate->number; | 412 | ctrl->slot_bus = pdev->subordinate->number; |
406 | |||
407 | ctrl->device = PCI_SLOT(pdev->devfn); | 413 | ctrl->device = PCI_SLOT(pdev->devfn); |
408 | ctrl->function = PCI_FUNC(pdev->devfn); | 414 | ctrl->function = PCI_FUNC(pdev->devfn); |
409 | dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", ctrl->bus, ctrl->device, ctrl->function, pdev->irq); | 415 | |
416 | dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", | ||
417 | ctrl->bus, ctrl->device, ctrl->function, pdev->irq); | ||
410 | 418 | ||
411 | /* | 419 | /* |
412 | * Save configuration headers for this and subordinate PCI buses | 420 | * Save configuration headers for this and subordinate PCI buses |
413 | */ | 421 | */ |
414 | |||
415 | rc = get_ctlr_slot_config(ctrl); | 422 | rc = get_ctlr_slot_config(ctrl); |
416 | if (rc) { | 423 | if (rc) { |
417 | err(msg_initialization_err, rc); | 424 | err(msg_initialization_err, rc); |
418 | goto err_out_free_ctrl_bus; | 425 | goto err_out_release_ctlr; |
419 | } | 426 | } |
420 | first_device_num = ctrl->slot_device_offset; | 427 | first_device_num = ctrl->slot_device_offset; |
421 | num_ctlr_slots = ctrl->num_slots; | 428 | num_ctlr_slots = ctrl->num_slots; |
422 | 429 | ||
423 | ctrl->add_support = 1; | 430 | ctrl->add_support = 1; |
424 | 431 | ||
425 | /* Setup the slot information structures */ | 432 | /* Setup the slot information structures */ |
426 | rc = init_slots(ctrl); | 433 | rc = init_slots(ctrl); |
427 | if (rc) { | 434 | if (rc) { |
428 | err(msg_initialization_err, 6); | 435 | err(msg_initialization_err, 6); |
429 | goto err_out_free_ctrl_slot; | 436 | goto err_out_release_ctlr; |
430 | } | 437 | } |
431 | 438 | ||
432 | /* Now hpc_functions (slot->hpc_ops->functions) are ready */ | 439 | /* Now hpc_functions (slot->hpc_ops->functions) are ready */ |
@@ -437,30 +444,16 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
437 | dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot); | 444 | dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot); |
438 | 445 | ||
439 | if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) { | 446 | if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) { |
440 | err(SHPC_MODULE_NAME ": Can't get current bus speed. Set to 33MHz PCI.\n"); | 447 | err(SHPC_MODULE_NAME ": Can't get current bus speed. " |
448 | "Set to 33MHz PCI.\n"); | ||
441 | ctrl->speed = PCI_SPEED_33MHz; | 449 | ctrl->speed = PCI_SPEED_33MHz; |
442 | } | 450 | } |
443 | 451 | ||
444 | /* Finish setting up the hot plug ctrl device */ | ||
445 | ctrl->next_event = 0; | ||
446 | |||
447 | if (!shpchp_ctrl_list) { | ||
448 | shpchp_ctrl_list = ctrl; | ||
449 | ctrl->next = NULL; | ||
450 | } else { | ||
451 | ctrl->next = shpchp_ctrl_list; | ||
452 | shpchp_ctrl_list = ctrl; | ||
453 | } | ||
454 | |||
455 | shpchp_create_ctrl_files(ctrl); | 452 | shpchp_create_ctrl_files(ctrl); |
456 | 453 | ||
457 | return 0; | 454 | return 0; |
458 | 455 | ||
459 | err_out_free_ctrl_slot: | 456 | err_out_release_ctlr: |
460 | cleanup_slots(ctrl); | ||
461 | err_out_free_ctrl_bus: | ||
462 | kfree(ctrl->pci_bus); | ||
463 | err_out_unmap_mmio_region: | ||
464 | ctrl->hpc_ops->release_ctlr(ctrl); | 457 | ctrl->hpc_ops->release_ctlr(ctrl); |
465 | err_out_free_ctrl: | 458 | err_out_free_ctrl: |
466 | kfree(ctrl); | 459 | kfree(ctrl); |
@@ -468,74 +461,28 @@ err_out_none: | |||
468 | return -ENODEV; | 461 | return -ENODEV; |
469 | } | 462 | } |
470 | 463 | ||
471 | 464 | static void shpc_remove(struct pci_dev *dev) | |
472 | static int shpc_start_thread(void) | ||
473 | { | ||
474 | int retval = 0; | ||
475 | |||
476 | dbg("Initialize + Start the notification/polling mechanism \n"); | ||
477 | |||
478 | retval = shpchp_event_start_thread(); | ||
479 | if (retval) { | ||
480 | dbg("shpchp_event_start_thread() failed\n"); | ||
481 | return retval; | ||
482 | } | ||
483 | |||
484 | return retval; | ||
485 | } | ||
486 | |||
487 | static void __exit unload_shpchpd(void) | ||
488 | { | 465 | { |
489 | struct controller *ctrl; | 466 | struct controller *ctrl = pci_get_drvdata(dev); |
490 | struct controller *tctrl; | ||
491 | |||
492 | ctrl = shpchp_ctrl_list; | ||
493 | |||
494 | while (ctrl) { | ||
495 | shpchp_remove_ctrl_files(ctrl); | ||
496 | cleanup_slots(ctrl); | ||
497 | |||
498 | kfree (ctrl->pci_bus); | ||
499 | ctrl->hpc_ops->release_ctlr(ctrl); | ||
500 | |||
501 | tctrl = ctrl; | ||
502 | ctrl = ctrl->next; | ||
503 | |||
504 | kfree(tctrl); | ||
505 | } | ||
506 | |||
507 | /* Stop the notification mechanism */ | ||
508 | shpchp_event_stop_thread(); | ||
509 | 467 | ||
468 | shpchp_remove_ctrl_files(ctrl); | ||
469 | ctrl->hpc_ops->release_ctlr(ctrl); | ||
470 | kfree(ctrl); | ||
510 | } | 471 | } |
511 | 472 | ||
512 | |||
513 | static struct pci_device_id shpcd_pci_tbl[] = { | 473 | static struct pci_device_id shpcd_pci_tbl[] = { |
514 | { | 474 | {PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0)}, |
515 | .class = ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), | ||
516 | .class_mask = ~0, | ||
517 | .vendor = PCI_ANY_ID, | ||
518 | .device = PCI_ANY_ID, | ||
519 | .subvendor = PCI_ANY_ID, | ||
520 | .subdevice = PCI_ANY_ID, | ||
521 | }, | ||
522 | |||
523 | { /* end: all zeroes */ } | 475 | { /* end: all zeroes */ } |
524 | }; | 476 | }; |
525 | |||
526 | MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl); | 477 | MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl); |
527 | 478 | ||
528 | |||
529 | |||
530 | static struct pci_driver shpc_driver = { | 479 | static struct pci_driver shpc_driver = { |
531 | .name = SHPC_MODULE_NAME, | 480 | .name = SHPC_MODULE_NAME, |
532 | .id_table = shpcd_pci_tbl, | 481 | .id_table = shpcd_pci_tbl, |
533 | .probe = shpc_probe, | 482 | .probe = shpc_probe, |
534 | /* remove: shpc_remove_one, */ | 483 | .remove = shpc_remove, |
535 | }; | 484 | }; |
536 | 485 | ||
537 | |||
538 | |||
539 | static int __init shpcd_init(void) | 486 | static int __init shpcd_init(void) |
540 | { | 487 | { |
541 | int retval = 0; | 488 | int retval = 0; |
@@ -544,17 +491,15 @@ static int __init shpcd_init(void) | |||
544 | shpchp_poll_mode = 1; | 491 | shpchp_poll_mode = 1; |
545 | #endif | 492 | #endif |
546 | 493 | ||
547 | retval = shpc_start_thread(); | 494 | shpchp_wq = create_singlethread_workqueue("shpchpd"); |
548 | if (retval) | 495 | if (!shpchp_wq) |
549 | goto error_hpc_init; | 496 | return -ENOMEM; |
550 | 497 | ||
551 | retval = pci_register_driver(&shpc_driver); | 498 | retval = pci_register_driver(&shpc_driver); |
552 | dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval); | 499 | dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval); |
553 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 500 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
554 | |||
555 | error_hpc_init: | ||
556 | if (retval) { | 501 | if (retval) { |
557 | shpchp_event_stop_thread(); | 502 | destroy_workqueue(shpchp_wq); |
558 | } | 503 | } |
559 | return retval; | 504 | return retval; |
560 | } | 505 | } |
@@ -562,10 +507,8 @@ error_hpc_init: | |||
562 | static void __exit shpcd_cleanup(void) | 507 | static void __exit shpcd_cleanup(void) |
563 | { | 508 | { |
564 | dbg("unload_shpchpd()\n"); | 509 | dbg("unload_shpchpd()\n"); |
565 | unload_shpchpd(); | ||
566 | |||
567 | pci_unregister_driver(&shpc_driver); | 510 | pci_unregister_driver(&shpc_driver); |
568 | 511 | destroy_workqueue(shpchp_wq); | |
569 | info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); | 512 | info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); |
570 | } | 513 | } |
571 | 514 | ||
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index 643252d9bf3b..4e6381481c55 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c | |||
@@ -32,65 +32,50 @@ | |||
32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/workqueue.h> | ||
35 | #include "../pci.h" | 36 | #include "../pci.h" |
36 | #include "shpchp.h" | 37 | #include "shpchp.h" |
37 | 38 | ||
38 | static void interrupt_event_handler(struct controller *ctrl); | 39 | static void interrupt_event_handler(void *data); |
40 | static int shpchp_enable_slot(struct slot *p_slot); | ||
41 | static int shpchp_disable_slot(struct slot *p_slot); | ||
39 | 42 | ||
40 | static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ | 43 | static int queue_interrupt_event(struct slot *p_slot, u32 event_type) |
41 | static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */ | 44 | { |
42 | static int event_finished; | 45 | struct event_info *info; |
43 | static unsigned long pushbutton_pending; /* = 0 */ | 46 | |
47 | info = kmalloc(sizeof(*info), GFP_ATOMIC); | ||
48 | if (!info) | ||
49 | return -ENOMEM; | ||
50 | |||
51 | info->event_type = event_type; | ||
52 | info->p_slot = p_slot; | ||
53 | INIT_WORK(&info->work, interrupt_event_handler, info); | ||
54 | |||
55 | schedule_work(&info->work); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
44 | 59 | ||
45 | u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id) | 60 | u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id) |
46 | { | 61 | { |
47 | struct controller *ctrl = (struct controller *) inst_id; | 62 | struct controller *ctrl = (struct controller *) inst_id; |
48 | struct slot *p_slot; | 63 | struct slot *p_slot; |
49 | u8 rc = 0; | 64 | u32 event_type; |
50 | u8 getstatus; | ||
51 | struct event_info *taskInfo; | ||
52 | 65 | ||
53 | /* Attention Button Change */ | 66 | /* Attention Button Change */ |
54 | dbg("shpchp: Attention button interrupt received.\n"); | 67 | dbg("shpchp: Attention button interrupt received.\n"); |
55 | 68 | ||
56 | /* This is the structure that tells the worker thread what to do */ | ||
57 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
58 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 69 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
59 | |||
60 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 70 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
61 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | ||
62 | |||
63 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
64 | taskInfo->hp_slot = hp_slot; | ||
65 | |||
66 | rc++; | ||
67 | 71 | ||
68 | /* | 72 | /* |
69 | * Button pressed - See if need to TAKE ACTION!!! | 73 | * Button pressed - See if need to TAKE ACTION!!! |
70 | */ | 74 | */ |
71 | info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); | 75 | info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); |
72 | taskInfo->event_type = INT_BUTTON_PRESS; | 76 | event_type = INT_BUTTON_PRESS; |
73 | |||
74 | if ((p_slot->state == BLINKINGON_STATE) | ||
75 | || (p_slot->state == BLINKINGOFF_STATE)) { | ||
76 | /* Cancel if we are still blinking; this means that we press the | ||
77 | * attention again before the 5 sec. limit expires to cancel hot-add | ||
78 | * or hot-remove | ||
79 | */ | ||
80 | taskInfo->event_type = INT_BUTTON_CANCEL; | ||
81 | info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot); | ||
82 | } else if ((p_slot->state == POWERON_STATE) | ||
83 | || (p_slot->state == POWEROFF_STATE)) { | ||
84 | /* Ignore if the slot is on power-on or power-off state; this | ||
85 | * means that the previous attention button action to hot-add or | ||
86 | * hot-remove is undergoing | ||
87 | */ | ||
88 | taskInfo->event_type = INT_BUTTON_IGNORE; | ||
89 | info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot); | ||
90 | } | ||
91 | 77 | ||
92 | if (rc) | 78 | queue_interrupt_event(p_slot, event_type); |
93 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
94 | 79 | ||
95 | return 0; | 80 | return 0; |
96 | 81 | ||
@@ -100,21 +85,12 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id) | |||
100 | { | 85 | { |
101 | struct controller *ctrl = (struct controller *) inst_id; | 86 | struct controller *ctrl = (struct controller *) inst_id; |
102 | struct slot *p_slot; | 87 | struct slot *p_slot; |
103 | u8 rc = 0; | ||
104 | u8 getstatus; | 88 | u8 getstatus; |
105 | struct event_info *taskInfo; | 89 | u32 event_type; |
106 | 90 | ||
107 | /* Switch Change */ | 91 | /* Switch Change */ |
108 | dbg("shpchp: Switch interrupt received.\n"); | 92 | dbg("shpchp: Switch interrupt received.\n"); |
109 | 93 | ||
110 | /* This is the structure that tells the worker thread | ||
111 | * what to do | ||
112 | */ | ||
113 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
114 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
115 | taskInfo->hp_slot = hp_slot; | ||
116 | |||
117 | rc++; | ||
118 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 94 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
119 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 95 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
120 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 96 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
@@ -126,9 +102,9 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id) | |||
126 | * Switch opened | 102 | * Switch opened |
127 | */ | 103 | */ |
128 | info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); | 104 | info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); |
129 | taskInfo->event_type = INT_SWITCH_OPEN; | 105 | event_type = INT_SWITCH_OPEN; |
130 | if (p_slot->pwr_save && p_slot->presence_save) { | 106 | if (p_slot->pwr_save && p_slot->presence_save) { |
131 | taskInfo->event_type = INT_POWER_FAULT; | 107 | event_type = INT_POWER_FAULT; |
132 | err("Surprise Removal of card\n"); | 108 | err("Surprise Removal of card\n"); |
133 | } | 109 | } |
134 | } else { | 110 | } else { |
@@ -136,34 +112,23 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id) | |||
136 | * Switch closed | 112 | * Switch closed |
137 | */ | 113 | */ |
138 | info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); | 114 | info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); |
139 | taskInfo->event_type = INT_SWITCH_CLOSE; | 115 | event_type = INT_SWITCH_CLOSE; |
140 | } | 116 | } |
141 | 117 | ||
142 | if (rc) | 118 | queue_interrupt_event(p_slot, event_type); |
143 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
144 | 119 | ||
145 | return rc; | 120 | return 1; |
146 | } | 121 | } |
147 | 122 | ||
148 | u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id) | 123 | u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id) |
149 | { | 124 | { |
150 | struct controller *ctrl = (struct controller *) inst_id; | 125 | struct controller *ctrl = (struct controller *) inst_id; |
151 | struct slot *p_slot; | 126 | struct slot *p_slot; |
152 | u8 rc = 0; | 127 | u32 event_type; |
153 | /*u8 temp_byte;*/ | ||
154 | struct event_info *taskInfo; | ||
155 | 128 | ||
156 | /* Presence Change */ | 129 | /* Presence Change */ |
157 | dbg("shpchp: Presence/Notify input change.\n"); | 130 | dbg("shpchp: Presence/Notify input change.\n"); |
158 | 131 | ||
159 | /* This is the structure that tells the worker thread | ||
160 | * what to do | ||
161 | */ | ||
162 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
163 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
164 | taskInfo->hp_slot = hp_slot; | ||
165 | |||
166 | rc++; | ||
167 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 132 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
168 | 133 | ||
169 | /* | 134 | /* |
@@ -175,39 +140,29 @@ u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id) | |||
175 | * Card Present | 140 | * Card Present |
176 | */ | 141 | */ |
177 | info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); | 142 | info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); |
178 | taskInfo->event_type = INT_PRESENCE_ON; | 143 | event_type = INT_PRESENCE_ON; |
179 | } else { | 144 | } else { |
180 | /* | 145 | /* |
181 | * Not Present | 146 | * Not Present |
182 | */ | 147 | */ |
183 | info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); | 148 | info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); |
184 | taskInfo->event_type = INT_PRESENCE_OFF; | 149 | event_type = INT_PRESENCE_OFF; |
185 | } | 150 | } |
186 | 151 | ||
187 | if (rc) | 152 | queue_interrupt_event(p_slot, event_type); |
188 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
189 | 153 | ||
190 | return rc; | 154 | return 1; |
191 | } | 155 | } |
192 | 156 | ||
193 | u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id) | 157 | u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id) |
194 | { | 158 | { |
195 | struct controller *ctrl = (struct controller *) inst_id; | 159 | struct controller *ctrl = (struct controller *) inst_id; |
196 | struct slot *p_slot; | 160 | struct slot *p_slot; |
197 | u8 rc = 0; | 161 | u32 event_type; |
198 | struct event_info *taskInfo; | ||
199 | 162 | ||
200 | /* Power fault */ | 163 | /* Power fault */ |
201 | dbg("shpchp: Power fault interrupt received.\n"); | 164 | dbg("shpchp: Power fault interrupt received.\n"); |
202 | 165 | ||
203 | /* This is the structure that tells the worker thread | ||
204 | * what to do | ||
205 | */ | ||
206 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
207 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
208 | taskInfo->hp_slot = hp_slot; | ||
209 | |||
210 | rc++; | ||
211 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 166 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
212 | 167 | ||
213 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { | 168 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { |
@@ -216,21 +171,21 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id) | |||
216 | */ | 171 | */ |
217 | info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); | 172 | info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); |
218 | p_slot->status = 0x00; | 173 | p_slot->status = 0x00; |
219 | taskInfo->event_type = INT_POWER_FAULT_CLEAR; | 174 | event_type = INT_POWER_FAULT_CLEAR; |
220 | } else { | 175 | } else { |
221 | /* | 176 | /* |
222 | * Power fault | 177 | * Power fault |
223 | */ | 178 | */ |
224 | info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); | 179 | info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); |
225 | taskInfo->event_type = INT_POWER_FAULT; | 180 | event_type = INT_POWER_FAULT; |
226 | /* set power fault status for this board */ | 181 | /* set power fault status for this board */ |
227 | p_slot->status = 0xFF; | 182 | p_slot->status = 0xFF; |
228 | info("power fault bit %x set\n", hp_slot); | 183 | info("power fault bit %x set\n", hp_slot); |
229 | } | 184 | } |
230 | if (rc) | ||
231 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
232 | 185 | ||
233 | return rc; | 186 | queue_interrupt_event(p_slot, event_type); |
187 | |||
188 | return 1; | ||
234 | } | 189 | } |
235 | 190 | ||
236 | /* The following routines constitute the bulk of the | 191 | /* The following routines constitute the bulk of the |
@@ -242,21 +197,11 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot, | |||
242 | int rc = 0; | 197 | int rc = 0; |
243 | 198 | ||
244 | dbg("%s: change to speed %d\n", __FUNCTION__, speed); | 199 | dbg("%s: change to speed %d\n", __FUNCTION__, speed); |
245 | down(&ctrl->crit_sect); | ||
246 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { | 200 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { |
247 | err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); | 201 | err("%s: Issue of set bus speed mode command failed\n", |
248 | up(&ctrl->crit_sect); | 202 | __FUNCTION__); |
249 | return WRONG_BUS_FREQUENCY; | 203 | return WRONG_BUS_FREQUENCY; |
250 | } | 204 | } |
251 | |||
252 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
253 | err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", | ||
254 | __FUNCTION__); | ||
255 | err("%s: Error code (%d)\n", __FUNCTION__, rc); | ||
256 | up(&ctrl->crit_sect); | ||
257 | return WRONG_BUS_FREQUENCY; | ||
258 | } | ||
259 | up(&ctrl->crit_sect); | ||
260 | return rc; | 205 | return rc; |
261 | } | 206 | } |
262 | 207 | ||
@@ -265,33 +210,26 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot, | |||
265 | enum pci_bus_speed msp) | 210 | enum pci_bus_speed msp) |
266 | { | 211 | { |
267 | int rc = 0; | 212 | int rc = 0; |
268 | 213 | ||
269 | if (flag != 0) { /* Other slots on the same bus are occupied */ | 214 | /* |
270 | if ( asp < bsp ) { | 215 | * If other slots on the same bus are occupied, we cannot |
271 | err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bsp, asp); | 216 | * change the bus speed. |
272 | return WRONG_BUS_FREQUENCY; | 217 | */ |
218 | if (flag) { | ||
219 | if (asp < bsp) { | ||
220 | err("%s: speed of bus %x and adapter %x mismatch\n", | ||
221 | __FUNCTION__, bsp, asp); | ||
222 | rc = WRONG_BUS_FREQUENCY; | ||
273 | } | 223 | } |
224 | return rc; | ||
225 | } | ||
226 | |||
227 | if (asp < msp) { | ||
228 | if (bsp != asp) | ||
229 | rc = change_bus_speed(ctrl, pslot, asp); | ||
274 | } else { | 230 | } else { |
275 | /* Other slots on the same bus are empty */ | 231 | if (bsp != msp) |
276 | if (msp == bsp) { | 232 | rc = change_bus_speed(ctrl, pslot, msp); |
277 | /* if adapter_speed >= bus_speed, do nothing */ | ||
278 | if (asp < bsp) { | ||
279 | /* | ||
280 | * Try to lower bus speed to accommodate the adapter if other slots | ||
281 | * on the same controller are empty | ||
282 | */ | ||
283 | if ((rc = change_bus_speed(ctrl, pslot, asp))) | ||
284 | return rc; | ||
285 | } | ||
286 | } else { | ||
287 | if (asp < msp) { | ||
288 | if ((rc = change_bus_speed(ctrl, pslot, asp))) | ||
289 | return rc; | ||
290 | } else { | ||
291 | if ((rc = change_bus_speed(ctrl, pslot, msp))) | ||
292 | return rc; | ||
293 | } | ||
294 | } | ||
295 | } | 233 | } |
296 | return rc; | 234 | return rc; |
297 | } | 235 | } |
@@ -308,8 +246,7 @@ static int board_added(struct slot *p_slot) | |||
308 | u8 hp_slot; | 246 | u8 hp_slot; |
309 | u8 slots_not_empty = 0; | 247 | u8 slots_not_empty = 0; |
310 | int rc = 0; | 248 | int rc = 0; |
311 | enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed; | 249 | enum pci_bus_speed asp, bsp, msp; |
312 | u8 pi, mode; | ||
313 | struct controller *ctrl = p_slot->ctrl; | 250 | struct controller *ctrl = p_slot->ctrl; |
314 | 251 | ||
315 | hp_slot = p_slot->device - ctrl->slot_device_offset; | 252 | hp_slot = p_slot->device - ctrl->slot_device_offset; |
@@ -318,187 +255,68 @@ static int board_added(struct slot *p_slot) | |||
318 | __FUNCTION__, p_slot->device, | 255 | __FUNCTION__, p_slot->device, |
319 | ctrl->slot_device_offset, hp_slot); | 256 | ctrl->slot_device_offset, hp_slot); |
320 | 257 | ||
321 | /* Wait for exclusive access to hardware */ | ||
322 | down(&ctrl->crit_sect); | ||
323 | |||
324 | /* Power on slot without connecting to bus */ | 258 | /* Power on slot without connecting to bus */ |
325 | rc = p_slot->hpc_ops->power_on_slot(p_slot); | 259 | rc = p_slot->hpc_ops->power_on_slot(p_slot); |
326 | if (rc) { | 260 | if (rc) { |
327 | err("%s: Failed to power on slot\n", __FUNCTION__); | 261 | err("%s: Failed to power on slot\n", __FUNCTION__); |
328 | /* Done with exclusive hardware access */ | ||
329 | up(&ctrl->crit_sect); | ||
330 | return -1; | 262 | return -1; |
331 | } | 263 | } |
332 | 264 | ||
333 | rc = p_slot->hpc_ops->check_cmd_status(ctrl); | ||
334 | if (rc) { | ||
335 | err("%s: Failed to power on slot, error code(%d)\n", __FUNCTION__, rc); | ||
336 | /* Done with exclusive hardware access */ | ||
337 | up(&ctrl->crit_sect); | ||
338 | return -1; | ||
339 | } | ||
340 | |||
341 | |||
342 | if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { | 265 | if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { |
343 | if (slots_not_empty) | 266 | if (slots_not_empty) |
344 | return WRONG_BUS_FREQUENCY; | 267 | return WRONG_BUS_FREQUENCY; |
345 | 268 | ||
346 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { | 269 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { |
347 | err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); | 270 | err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); |
348 | up(&ctrl->crit_sect); | ||
349 | return WRONG_BUS_FREQUENCY; | 271 | return WRONG_BUS_FREQUENCY; |
350 | } | 272 | } |
351 | 273 | ||
352 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
353 | err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", | ||
354 | __FUNCTION__); | ||
355 | err("%s: Error code (%d)\n", __FUNCTION__, rc); | ||
356 | up(&ctrl->crit_sect); | ||
357 | return WRONG_BUS_FREQUENCY; | ||
358 | } | ||
359 | /* turn on board, blink green LED, turn off Amber LED */ | 274 | /* turn on board, blink green LED, turn off Amber LED */ |
360 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { | 275 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { |
361 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); | 276 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); |
362 | up(&ctrl->crit_sect); | ||
363 | return rc; | 277 | return rc; |
364 | } | 278 | } |
365 | |||
366 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
367 | err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); | ||
368 | up(&ctrl->crit_sect); | ||
369 | return rc; | ||
370 | } | ||
371 | } | 279 | } |
372 | 280 | ||
373 | rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &adapter_speed); | 281 | rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); |
374 | /* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */ | 282 | if (rc) { |
375 | /* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC, 0xa = PCI-X 133 Mhz 266, */ | 283 | err("%s: Can't get adapter speed or bus mode mismatch\n", |
376 | /* 0xd = PCI-X 133 Mhz 533 */ | 284 | __FUNCTION__); |
377 | /* This encoding is different from the one used in cur_bus_speed & */ | ||
378 | /* max_bus_speed */ | ||
379 | |||
380 | if (rc || adapter_speed == PCI_SPEED_UNKNOWN) { | ||
381 | err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__); | ||
382 | /* Done with exclusive hardware access */ | ||
383 | up(&ctrl->crit_sect); | ||
384 | return WRONG_BUS_FREQUENCY; | 285 | return WRONG_BUS_FREQUENCY; |
385 | } | 286 | } |
386 | 287 | ||
387 | rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bus_speed); | 288 | rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp); |
388 | if (rc || bus_speed == PCI_SPEED_UNKNOWN) { | 289 | if (rc) { |
389 | err("%s: Can't get bus operation speed\n", __FUNCTION__); | 290 | err("%s: Can't get bus operation speed\n", __FUNCTION__); |
390 | /* Done with exclusive hardware access */ | ||
391 | up(&ctrl->crit_sect); | ||
392 | return WRONG_BUS_FREQUENCY; | 291 | return WRONG_BUS_FREQUENCY; |
393 | } | 292 | } |
394 | 293 | ||
395 | rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &max_bus_speed); | 294 | rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp); |
396 | if (rc || max_bus_speed == PCI_SPEED_UNKNOWN) { | 295 | if (rc) { |
397 | err("%s: Can't get max bus operation speed\n", __FUNCTION__); | 296 | err("%s: Can't get max bus operation speed\n", __FUNCTION__); |
398 | max_bus_speed = bus_speed; | 297 | msp = bsp; |
399 | } | ||
400 | |||
401 | /* Done with exclusive hardware access */ | ||
402 | up(&ctrl->crit_sect); | ||
403 | |||
404 | if ((rc = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) { | ||
405 | err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__); | ||
406 | pi = 1; | ||
407 | } | 298 | } |
408 | 299 | ||
409 | /* Check if there are other slots or devices on the same bus */ | 300 | /* Check if there are other slots or devices on the same bus */ |
410 | if (!list_empty(&ctrl->pci_dev->subordinate->devices)) | 301 | if (!list_empty(&ctrl->pci_dev->subordinate->devices)) |
411 | slots_not_empty = 1; | 302 | slots_not_empty = 1; |
412 | 303 | ||
413 | dbg("%s: slots_not_empty %d, pi %d\n", __FUNCTION__, | 304 | dbg("%s: slots_not_empty %d, adapter_speed %d, bus_speed %d, " |
414 | slots_not_empty, pi); | 305 | "max_bus_speed %d\n", __FUNCTION__, slots_not_empty, asp, |
415 | dbg("adapter_speed %d, bus_speed %d, max_bus_speed %d\n", | 306 | bsp, msp); |
416 | adapter_speed, bus_speed, max_bus_speed); | ||
417 | |||
418 | if (pi == 2) { | ||
419 | dbg("%s: In PI = %d\n", __FUNCTION__, pi); | ||
420 | if ((rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode))) { | ||
421 | err("%s: Can't get Mode1_ECC, set mode to 0\n", __FUNCTION__); | ||
422 | mode = 0; | ||
423 | } | ||
424 | 307 | ||
425 | switch (adapter_speed) { | 308 | rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp); |
426 | case PCI_SPEED_133MHz_PCIX_533: | 309 | if (rc) |
427 | case PCI_SPEED_133MHz_PCIX_266: | 310 | return rc; |
428 | if ((bus_speed != adapter_speed) && | ||
429 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
430 | return rc; | ||
431 | break; | ||
432 | case PCI_SPEED_133MHz_PCIX_ECC: | ||
433 | case PCI_SPEED_133MHz_PCIX: | ||
434 | if (mode) { /* Bus - Mode 1 ECC */ | ||
435 | if ((bus_speed != 0x7) && | ||
436 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
437 | return rc; | ||
438 | } else { | ||
439 | if ((bus_speed != 0x4) && | ||
440 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
441 | return rc; | ||
442 | } | ||
443 | break; | ||
444 | case PCI_SPEED_66MHz_PCIX_ECC: | ||
445 | case PCI_SPEED_66MHz_PCIX: | ||
446 | if (mode) { /* Bus - Mode 1 ECC */ | ||
447 | if ((bus_speed != 0x5) && | ||
448 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
449 | return rc; | ||
450 | } else { | ||
451 | if ((bus_speed != 0x2) && | ||
452 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
453 | return rc; | ||
454 | } | ||
455 | break; | ||
456 | case PCI_SPEED_66MHz: | ||
457 | if ((bus_speed != 0x1) && | ||
458 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
459 | return rc; | ||
460 | break; | ||
461 | case PCI_SPEED_33MHz: | ||
462 | if (bus_speed > 0x0) { | ||
463 | if (slots_not_empty == 0) { | ||
464 | if ((rc = change_bus_speed(ctrl, p_slot, adapter_speed))) | ||
465 | return rc; | ||
466 | } else { | ||
467 | err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed); | ||
468 | return WRONG_BUS_FREQUENCY; | ||
469 | } | ||
470 | } | ||
471 | break; | ||
472 | default: | ||
473 | err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed); | ||
474 | return WRONG_BUS_FREQUENCY; | ||
475 | } | ||
476 | } else { | ||
477 | /* If adpater_speed == bus_speed, nothing to do here */ | ||
478 | dbg("%s: In PI = %d\n", __FUNCTION__, pi); | ||
479 | if ((adapter_speed != bus_speed) && | ||
480 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
481 | return rc; | ||
482 | } | ||
483 | 311 | ||
484 | down(&ctrl->crit_sect); | ||
485 | /* turn on board, blink green LED, turn off Amber LED */ | 312 | /* turn on board, blink green LED, turn off Amber LED */ |
486 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { | 313 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { |
487 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); | 314 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); |
488 | up(&ctrl->crit_sect); | ||
489 | return rc; | 315 | return rc; |
490 | } | 316 | } |
491 | 317 | ||
492 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
493 | err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); | ||
494 | up(&ctrl->crit_sect); | ||
495 | return rc; | ||
496 | } | ||
497 | |||
498 | up(&ctrl->crit_sect); | ||
499 | |||
500 | /* Wait for ~1 second */ | 318 | /* Wait for ~1 second */ |
501 | wait_for_ctrl_irq (ctrl); | 319 | msleep(1000); |
502 | 320 | ||
503 | dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status); | 321 | dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status); |
504 | /* Check for a power fault */ | 322 | /* Check for a power fault */ |
@@ -520,40 +338,18 @@ static int board_added(struct slot *p_slot) | |||
520 | p_slot->is_a_board = 0x01; | 338 | p_slot->is_a_board = 0x01; |
521 | p_slot->pwr_save = 1; | 339 | p_slot->pwr_save = 1; |
522 | 340 | ||
523 | /* Wait for exclusive access to hardware */ | ||
524 | down(&ctrl->crit_sect); | ||
525 | |||
526 | p_slot->hpc_ops->green_led_on(p_slot); | 341 | p_slot->hpc_ops->green_led_on(p_slot); |
527 | 342 | ||
528 | /* Done with exclusive hardware access */ | ||
529 | up(&ctrl->crit_sect); | ||
530 | |||
531 | return 0; | 343 | return 0; |
532 | 344 | ||
533 | err_exit: | 345 | err_exit: |
534 | /* Wait for exclusive access to hardware */ | ||
535 | down(&ctrl->crit_sect); | ||
536 | |||
537 | /* turn off slot, turn on Amber LED, turn off Green LED */ | 346 | /* turn off slot, turn on Amber LED, turn off Green LED */ |
538 | rc = p_slot->hpc_ops->slot_disable(p_slot); | 347 | rc = p_slot->hpc_ops->slot_disable(p_slot); |
539 | if (rc) { | 348 | if (rc) { |
540 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); | 349 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
541 | /* Done with exclusive hardware access */ | ||
542 | up(&ctrl->crit_sect); | ||
543 | return rc; | ||
544 | } | ||
545 | |||
546 | rc = p_slot->hpc_ops->check_cmd_status(ctrl); | ||
547 | if (rc) { | ||
548 | err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc); | ||
549 | /* Done with exclusive hardware access */ | ||
550 | up(&ctrl->crit_sect); | ||
551 | return rc; | 350 | return rc; |
552 | } | 351 | } |
553 | 352 | ||
554 | /* Done with exclusive hardware access */ | ||
555 | up(&ctrl->crit_sect); | ||
556 | |||
557 | return(rc); | 353 | return(rc); |
558 | } | 354 | } |
559 | 355 | ||
@@ -580,37 +376,19 @@ static int remove_board(struct slot *p_slot) | |||
580 | if (p_slot->is_a_board) | 376 | if (p_slot->is_a_board) |
581 | p_slot->status = 0x01; | 377 | p_slot->status = 0x01; |
582 | 378 | ||
583 | /* Wait for exclusive access to hardware */ | ||
584 | down(&ctrl->crit_sect); | ||
585 | |||
586 | /* turn off slot, turn on Amber LED, turn off Green LED */ | 379 | /* turn off slot, turn on Amber LED, turn off Green LED */ |
587 | rc = p_slot->hpc_ops->slot_disable(p_slot); | 380 | rc = p_slot->hpc_ops->slot_disable(p_slot); |
588 | if (rc) { | 381 | if (rc) { |
589 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); | 382 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
590 | /* Done with exclusive hardware access */ | ||
591 | up(&ctrl->crit_sect); | ||
592 | return rc; | 383 | return rc; |
593 | } | 384 | } |
594 | |||
595 | rc = p_slot->hpc_ops->check_cmd_status(ctrl); | ||
596 | if (rc) { | ||
597 | err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc); | ||
598 | /* Done with exclusive hardware access */ | ||
599 | up(&ctrl->crit_sect); | ||
600 | return rc; | ||
601 | } | ||
602 | 385 | ||
603 | rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); | 386 | rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); |
604 | if (rc) { | 387 | if (rc) { |
605 | err("%s: Issue of Set Attention command failed\n", __FUNCTION__); | 388 | err("%s: Issue of Set Attention command failed\n", __FUNCTION__); |
606 | /* Done with exclusive hardware access */ | ||
607 | up(&ctrl->crit_sect); | ||
608 | return rc; | 389 | return rc; |
609 | } | 390 | } |
610 | 391 | ||
611 | /* Done with exclusive hardware access */ | ||
612 | up(&ctrl->crit_sect); | ||
613 | |||
614 | p_slot->pwr_save = 0; | 392 | p_slot->pwr_save = 0; |
615 | p_slot->is_a_board = 0; | 393 | p_slot->is_a_board = 0; |
616 | 394 | ||
@@ -618,13 +396,10 @@ static int remove_board(struct slot *p_slot) | |||
618 | } | 396 | } |
619 | 397 | ||
620 | 398 | ||
621 | static void pushbutton_helper_thread (unsigned long data) | 399 | struct pushbutton_work_info { |
622 | { | 400 | struct slot *p_slot; |
623 | pushbutton_pending = data; | 401 | struct work_struct work; |
624 | 402 | }; | |
625 | up(&event_semaphore); | ||
626 | } | ||
627 | |||
628 | 403 | ||
629 | /** | 404 | /** |
630 | * shpchp_pushbutton_thread | 405 | * shpchp_pushbutton_thread |
@@ -633,96 +408,63 @@ static void pushbutton_helper_thread (unsigned long data) | |||
633 | * Handles all pending events and exits. | 408 | * Handles all pending events and exits. |
634 | * | 409 | * |
635 | */ | 410 | */ |
636 | static void shpchp_pushbutton_thread (unsigned long slot) | 411 | static void shpchp_pushbutton_thread(void *data) |
637 | { | 412 | { |
638 | struct slot *p_slot = (struct slot *) slot; | 413 | struct pushbutton_work_info *info = data; |
639 | u8 getstatus; | 414 | struct slot *p_slot = info->p_slot; |
640 | |||
641 | pushbutton_pending = 0; | ||
642 | |||
643 | if (!p_slot) { | ||
644 | dbg("%s: Error! slot NULL\n", __FUNCTION__); | ||
645 | return; | ||
646 | } | ||
647 | |||
648 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | ||
649 | if (getstatus) { | ||
650 | p_slot->state = POWEROFF_STATE; | ||
651 | 415 | ||
416 | mutex_lock(&p_slot->lock); | ||
417 | switch (p_slot->state) { | ||
418 | case POWEROFF_STATE: | ||
419 | mutex_unlock(&p_slot->lock); | ||
652 | shpchp_disable_slot(p_slot); | 420 | shpchp_disable_slot(p_slot); |
421 | mutex_lock(&p_slot->lock); | ||
653 | p_slot->state = STATIC_STATE; | 422 | p_slot->state = STATIC_STATE; |
654 | } else { | 423 | break; |
655 | p_slot->state = POWERON_STATE; | 424 | case POWERON_STATE: |
656 | 425 | mutex_unlock(&p_slot->lock); | |
657 | if (shpchp_enable_slot(p_slot)) { | 426 | if (shpchp_enable_slot(p_slot)) |
658 | /* Wait for exclusive access to hardware */ | ||
659 | down(&p_slot->ctrl->crit_sect); | ||
660 | |||
661 | p_slot->hpc_ops->green_led_off(p_slot); | 427 | p_slot->hpc_ops->green_led_off(p_slot); |
662 | 428 | mutex_lock(&p_slot->lock); | |
663 | /* Done with exclusive hardware access */ | ||
664 | up(&p_slot->ctrl->crit_sect); | ||
665 | } | ||
666 | p_slot->state = STATIC_STATE; | 429 | p_slot->state = STATIC_STATE; |
430 | break; | ||
431 | default: | ||
432 | break; | ||
667 | } | 433 | } |
434 | mutex_unlock(&p_slot->lock); | ||
668 | 435 | ||
669 | return; | 436 | kfree(info); |
670 | } | ||
671 | |||
672 | |||
673 | /* this is the main worker thread */ | ||
674 | static int event_thread(void* data) | ||
675 | { | ||
676 | struct controller *ctrl; | ||
677 | lock_kernel(); | ||
678 | daemonize("shpchpd_event"); | ||
679 | unlock_kernel(); | ||
680 | |||
681 | while (1) { | ||
682 | dbg("!!!!event_thread sleeping\n"); | ||
683 | down_interruptible (&event_semaphore); | ||
684 | dbg("event_thread woken finished = %d\n", event_finished); | ||
685 | if (event_finished || signal_pending(current)) | ||
686 | break; | ||
687 | /* Do stuff here */ | ||
688 | if (pushbutton_pending) | ||
689 | shpchp_pushbutton_thread(pushbutton_pending); | ||
690 | else | ||
691 | for (ctrl = shpchp_ctrl_list; ctrl; ctrl=ctrl->next) | ||
692 | interrupt_event_handler(ctrl); | ||
693 | } | ||
694 | dbg("event_thread signals exit\n"); | ||
695 | up(&event_exit); | ||
696 | return 0; | ||
697 | } | 437 | } |
698 | 438 | ||
699 | int shpchp_event_start_thread (void) | 439 | void queue_pushbutton_work(void *data) |
700 | { | 440 | { |
701 | int pid; | 441 | struct slot *p_slot = data; |
442 | struct pushbutton_work_info *info; | ||
702 | 443 | ||
703 | /* initialize our semaphores */ | 444 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
704 | init_MUTEX_LOCKED(&event_exit); | 445 | if (!info) { |
705 | event_finished=0; | 446 | err("%s: Cannot allocate memory\n", __FUNCTION__); |
706 | 447 | return; | |
707 | init_MUTEX_LOCKED(&event_semaphore); | ||
708 | pid = kernel_thread(event_thread, NULL, 0); | ||
709 | |||
710 | if (pid < 0) { | ||
711 | err ("Can't start up our event thread\n"); | ||
712 | return -1; | ||
713 | } | 448 | } |
714 | return 0; | 449 | info->p_slot = p_slot; |
715 | } | 450 | INIT_WORK(&info->work, shpchp_pushbutton_thread, info); |
716 | |||
717 | 451 | ||
718 | void shpchp_event_stop_thread (void) | 452 | mutex_lock(&p_slot->lock); |
719 | { | 453 | switch (p_slot->state) { |
720 | event_finished = 1; | 454 | case BLINKINGOFF_STATE: |
721 | up(&event_semaphore); | 455 | p_slot->state = POWEROFF_STATE; |
722 | down(&event_exit); | 456 | break; |
457 | case BLINKINGON_STATE: | ||
458 | p_slot->state = POWERON_STATE; | ||
459 | break; | ||
460 | default: | ||
461 | goto out; | ||
462 | } | ||
463 | queue_work(shpchp_wq, &info->work); | ||
464 | out: | ||
465 | mutex_unlock(&p_slot->lock); | ||
723 | } | 466 | } |
724 | 467 | ||
725 | |||
726 | static int update_slot_info (struct slot *slot) | 468 | static int update_slot_info (struct slot *slot) |
727 | { | 469 | { |
728 | struct hotplug_slot_info *info; | 470 | struct hotplug_slot_info *info; |
@@ -742,149 +484,110 @@ static int update_slot_info (struct slot *slot) | |||
742 | return result; | 484 | return result; |
743 | } | 485 | } |
744 | 486 | ||
745 | static void interrupt_event_handler(struct controller *ctrl) | 487 | /* |
488 | * Note: This function must be called with slot->lock held | ||
489 | */ | ||
490 | static void handle_button_press_event(struct slot *p_slot) | ||
746 | { | 491 | { |
747 | int loop = 0; | ||
748 | int change = 1; | ||
749 | u8 hp_slot; | ||
750 | u8 getstatus; | 492 | u8 getstatus; |
751 | struct slot *p_slot; | ||
752 | 493 | ||
753 | while (change) { | 494 | switch (p_slot->state) { |
754 | change = 0; | 495 | case STATIC_STATE: |
755 | 496 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | |
756 | for (loop = 0; loop < 10; loop++) { | 497 | if (getstatus) { |
757 | if (ctrl->event_queue[loop].event_type != 0) { | 498 | p_slot->state = BLINKINGOFF_STATE; |
758 | dbg("%s:loop %x event_type %x\n", __FUNCTION__, loop, | 499 | info(msg_button_off, p_slot->number); |
759 | ctrl->event_queue[loop].event_type); | 500 | } else { |
760 | hp_slot = ctrl->event_queue[loop].hp_slot; | 501 | p_slot->state = BLINKINGON_STATE; |
761 | 502 | info(msg_button_on, p_slot->number); | |
762 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 503 | } |
763 | 504 | /* blink green LED and turn off amber */ | |
764 | if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { | 505 | p_slot->hpc_ops->green_led_blink(p_slot); |
765 | dbg("%s: button cancel\n", __FUNCTION__); | 506 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
766 | del_timer(&p_slot->task_event); | 507 | |
767 | 508 | schedule_delayed_work(&p_slot->work, 5*HZ); | |
768 | switch (p_slot->state) { | 509 | break; |
769 | case BLINKINGOFF_STATE: | 510 | case BLINKINGOFF_STATE: |
770 | /* Wait for exclusive access to hardware */ | 511 | case BLINKINGON_STATE: |
771 | down(&ctrl->crit_sect); | 512 | /* |
772 | 513 | * Cancel if we are still blinking; this means that we | |
773 | p_slot->hpc_ops->green_led_on(p_slot); | 514 | * press the attention again before the 5 sec. limit |
774 | 515 | * expires to cancel hot-add or hot-remove | |
775 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 516 | */ |
776 | 517 | info("Button cancel on Slot(%s)\n", p_slot->name); | |
777 | /* Done with exclusive hardware access */ | 518 | dbg("%s: button cancel\n", __FUNCTION__); |
778 | up(&ctrl->crit_sect); | 519 | cancel_delayed_work(&p_slot->work); |
779 | break; | 520 | if (p_slot->state == BLINKINGOFF_STATE) |
780 | case BLINKINGON_STATE: | 521 | p_slot->hpc_ops->green_led_on(p_slot); |
781 | /* Wait for exclusive access to hardware */ | 522 | else |
782 | down(&ctrl->crit_sect); | 523 | p_slot->hpc_ops->green_led_off(p_slot); |
783 | 524 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | |
784 | p_slot->hpc_ops->green_led_off(p_slot); | 525 | info(msg_button_cancel, p_slot->number); |
785 | 526 | p_slot->state = STATIC_STATE; | |
786 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 527 | break; |
787 | 528 | case POWEROFF_STATE: | |
788 | /* Done with exclusive hardware access */ | 529 | case POWERON_STATE: |
789 | up(&ctrl->crit_sect); | 530 | /* |
790 | 531 | * Ignore if the slot is on power-on or power-off state; | |
791 | break; | 532 | * this means that the previous attention button action |
792 | default: | 533 | * to hot-add or hot-remove is undergoing |
793 | warn("Not a valid state\n"); | 534 | */ |
794 | return; | 535 | info("Button ignore on Slot(%s)\n", p_slot->name); |
795 | } | 536 | update_slot_info(p_slot); |
796 | info(msg_button_cancel, p_slot->number); | 537 | break; |
797 | p_slot->state = STATIC_STATE; | 538 | default: |
798 | } else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) { | 539 | warn("Not a valid state\n"); |
799 | /* Button Pressed (No action on 1st press...) */ | 540 | break; |
800 | dbg("%s: Button pressed\n", __FUNCTION__); | ||
801 | |||
802 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | ||
803 | if (getstatus) { | ||
804 | /* slot is on */ | ||
805 | dbg("%s: slot is on\n", __FUNCTION__); | ||
806 | p_slot->state = BLINKINGOFF_STATE; | ||
807 | info(msg_button_off, p_slot->number); | ||
808 | } else { | ||
809 | /* slot is off */ | ||
810 | dbg("%s: slot is off\n", __FUNCTION__); | ||
811 | p_slot->state = BLINKINGON_STATE; | ||
812 | info(msg_button_on, p_slot->number); | ||
813 | } | ||
814 | |||
815 | /* Wait for exclusive access to hardware */ | ||
816 | down(&ctrl->crit_sect); | ||
817 | |||
818 | /* blink green LED and turn off amber */ | ||
819 | p_slot->hpc_ops->green_led_blink(p_slot); | ||
820 | |||
821 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | ||
822 | |||
823 | /* Done with exclusive hardware access */ | ||
824 | up(&ctrl->crit_sect); | ||
825 | |||
826 | init_timer(&p_slot->task_event); | ||
827 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ | ||
828 | p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread; | ||
829 | p_slot->task_event.data = (unsigned long) p_slot; | ||
830 | |||
831 | dbg("%s: add_timer p_slot = %p\n", __FUNCTION__,(void *) p_slot); | ||
832 | add_timer(&p_slot->task_event); | ||
833 | } else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) { | ||
834 | /***********POWER FAULT********************/ | ||
835 | dbg("%s: power fault\n", __FUNCTION__); | ||
836 | /* Wait for exclusive access to hardware */ | ||
837 | down(&ctrl->crit_sect); | ||
838 | |||
839 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | ||
840 | |||
841 | p_slot->hpc_ops->green_led_off(p_slot); | ||
842 | |||
843 | /* Done with exclusive hardware access */ | ||
844 | up(&ctrl->crit_sect); | ||
845 | } else { | ||
846 | /* refresh notification */ | ||
847 | if (p_slot) | ||
848 | update_slot_info(p_slot); | ||
849 | } | ||
850 | |||
851 | ctrl->event_queue[loop].event_type = 0; | ||
852 | |||
853 | change = 1; | ||
854 | } | ||
855 | } /* End of FOR loop */ | ||
856 | } | 541 | } |
542 | } | ||
543 | |||
544 | static void interrupt_event_handler(void *data) | ||
545 | { | ||
546 | struct event_info *info = data; | ||
547 | struct slot *p_slot = info->p_slot; | ||
548 | |||
549 | mutex_lock(&p_slot->lock); | ||
550 | switch (info->event_type) { | ||
551 | case INT_BUTTON_PRESS: | ||
552 | handle_button_press_event(p_slot); | ||
553 | break; | ||
554 | case INT_POWER_FAULT: | ||
555 | dbg("%s: power fault\n", __FUNCTION__); | ||
556 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | ||
557 | p_slot->hpc_ops->green_led_off(p_slot); | ||
558 | break; | ||
559 | default: | ||
560 | update_slot_info(p_slot); | ||
561 | break; | ||
562 | } | ||
563 | mutex_unlock(&p_slot->lock); | ||
857 | 564 | ||
858 | return; | 565 | kfree(info); |
859 | } | 566 | } |
860 | 567 | ||
861 | 568 | ||
862 | int shpchp_enable_slot (struct slot *p_slot) | 569 | static int shpchp_enable_slot (struct slot *p_slot) |
863 | { | 570 | { |
864 | u8 getstatus = 0; | 571 | u8 getstatus = 0; |
865 | int rc; | 572 | int rc, retval = -ENODEV; |
866 | 573 | ||
867 | /* Check to see if (latch closed, card present, power off) */ | 574 | /* Check to see if (latch closed, card present, power off) */ |
868 | down(&p_slot->ctrl->crit_sect); | 575 | mutex_lock(&p_slot->ctrl->crit_sect); |
869 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 576 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
870 | if (rc || !getstatus) { | 577 | if (rc || !getstatus) { |
871 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 578 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
872 | up(&p_slot->ctrl->crit_sect); | 579 | goto out; |
873 | return -ENODEV; | ||
874 | } | 580 | } |
875 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 581 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
876 | if (rc || getstatus) { | 582 | if (rc || getstatus) { |
877 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 583 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
878 | up(&p_slot->ctrl->crit_sect); | 584 | goto out; |
879 | return -ENODEV; | ||
880 | } | 585 | } |
881 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 586 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
882 | if (rc || getstatus) { | 587 | if (rc || getstatus) { |
883 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); | 588 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); |
884 | up(&p_slot->ctrl->crit_sect); | 589 | goto out; |
885 | return -ENODEV; | ||
886 | } | 590 | } |
887 | up(&p_slot->ctrl->crit_sect); | ||
888 | 591 | ||
889 | p_slot->is_a_board = 1; | 592 | p_slot->is_a_board = 1; |
890 | 593 | ||
@@ -899,56 +602,119 @@ int shpchp_enable_slot (struct slot *p_slot) | |||
899 | && p_slot->ctrl->num_slots == 1) { | 602 | && p_slot->ctrl->num_slots == 1) { |
900 | /* handle amd pogo errata; this must be done before enable */ | 603 | /* handle amd pogo errata; this must be done before enable */ |
901 | amd_pogo_errata_save_misc_reg(p_slot); | 604 | amd_pogo_errata_save_misc_reg(p_slot); |
902 | rc = board_added(p_slot); | 605 | retval = board_added(p_slot); |
903 | /* handle amd pogo errata; this must be done after enable */ | 606 | /* handle amd pogo errata; this must be done after enable */ |
904 | amd_pogo_errata_restore_misc_reg(p_slot); | 607 | amd_pogo_errata_restore_misc_reg(p_slot); |
905 | } else | 608 | } else |
906 | rc = board_added(p_slot); | 609 | retval = board_added(p_slot); |
907 | 610 | ||
908 | if (rc) { | 611 | if (retval) { |
909 | p_slot->hpc_ops->get_adapter_status(p_slot, | 612 | p_slot->hpc_ops->get_adapter_status(p_slot, |
910 | &(p_slot->presence_save)); | 613 | &(p_slot->presence_save)); |
911 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 614 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
912 | } | 615 | } |
913 | 616 | ||
914 | update_slot_info(p_slot); | 617 | update_slot_info(p_slot); |
915 | return rc; | 618 | out: |
619 | mutex_unlock(&p_slot->ctrl->crit_sect); | ||
620 | return retval; | ||
916 | } | 621 | } |
917 | 622 | ||
918 | 623 | ||
919 | int shpchp_disable_slot (struct slot *p_slot) | 624 | static int shpchp_disable_slot (struct slot *p_slot) |
920 | { | 625 | { |
921 | u8 getstatus = 0; | 626 | u8 getstatus = 0; |
922 | int ret = 0; | 627 | int rc, retval = -ENODEV; |
923 | 628 | ||
924 | if (!p_slot->ctrl) | 629 | if (!p_slot->ctrl) |
925 | return -ENODEV; | 630 | return -ENODEV; |
926 | 631 | ||
927 | /* Check to see if (latch closed, card present, power on) */ | 632 | /* Check to see if (latch closed, card present, power on) */ |
928 | down(&p_slot->ctrl->crit_sect); | 633 | mutex_lock(&p_slot->ctrl->crit_sect); |
929 | 634 | ||
930 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 635 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
931 | if (ret || !getstatus) { | 636 | if (rc || !getstatus) { |
932 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 637 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
933 | up(&p_slot->ctrl->crit_sect); | 638 | goto out; |
934 | return -ENODEV; | ||
935 | } | 639 | } |
936 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 640 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
937 | if (ret || getstatus) { | 641 | if (rc || getstatus) { |
938 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 642 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
939 | up(&p_slot->ctrl->crit_sect); | 643 | goto out; |
940 | return -ENODEV; | ||
941 | } | 644 | } |
942 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 645 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
943 | if (ret || !getstatus) { | 646 | if (rc || !getstatus) { |
944 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); | 647 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); |
945 | up(&p_slot->ctrl->crit_sect); | 648 | goto out; |
946 | return -ENODEV; | ||
947 | } | 649 | } |
948 | up(&p_slot->ctrl->crit_sect); | ||
949 | 650 | ||
950 | ret = remove_board(p_slot); | 651 | retval = remove_board(p_slot); |
951 | update_slot_info(p_slot); | 652 | update_slot_info(p_slot); |
952 | return ret; | 653 | out: |
654 | mutex_unlock(&p_slot->ctrl->crit_sect); | ||
655 | return retval; | ||
953 | } | 656 | } |
954 | 657 | ||
658 | int shpchp_sysfs_enable_slot(struct slot *p_slot) | ||
659 | { | ||
660 | int retval = -ENODEV; | ||
661 | |||
662 | mutex_lock(&p_slot->lock); | ||
663 | switch (p_slot->state) { | ||
664 | case BLINKINGON_STATE: | ||
665 | cancel_delayed_work(&p_slot->work); | ||
666 | case STATIC_STATE: | ||
667 | p_slot->state = POWERON_STATE; | ||
668 | mutex_unlock(&p_slot->lock); | ||
669 | retval = shpchp_enable_slot(p_slot); | ||
670 | mutex_lock(&p_slot->lock); | ||
671 | p_slot->state = STATIC_STATE; | ||
672 | break; | ||
673 | case POWERON_STATE: | ||
674 | info("Slot %s is already in powering on state\n", | ||
675 | p_slot->name); | ||
676 | break; | ||
677 | case BLINKINGOFF_STATE: | ||
678 | case POWEROFF_STATE: | ||
679 | info("Already enabled on slot %s\n", p_slot->name); | ||
680 | break; | ||
681 | default: | ||
682 | err("Not a valid state on slot %s\n", p_slot->name); | ||
683 | break; | ||
684 | } | ||
685 | mutex_unlock(&p_slot->lock); | ||
686 | |||
687 | return retval; | ||
688 | } | ||
689 | |||
690 | int shpchp_sysfs_disable_slot(struct slot *p_slot) | ||
691 | { | ||
692 | int retval = -ENODEV; | ||
693 | |||
694 | mutex_lock(&p_slot->lock); | ||
695 | switch (p_slot->state) { | ||
696 | case BLINKINGOFF_STATE: | ||
697 | cancel_delayed_work(&p_slot->work); | ||
698 | case STATIC_STATE: | ||
699 | p_slot->state = POWEROFF_STATE; | ||
700 | mutex_unlock(&p_slot->lock); | ||
701 | retval = shpchp_disable_slot(p_slot); | ||
702 | mutex_lock(&p_slot->lock); | ||
703 | p_slot->state = STATIC_STATE; | ||
704 | break; | ||
705 | case POWEROFF_STATE: | ||
706 | info("Slot %s is already in powering off state\n", | ||
707 | p_slot->name); | ||
708 | break; | ||
709 | case BLINKINGON_STATE: | ||
710 | case POWERON_STATE: | ||
711 | info("Already disabled on slot %s\n", p_slot->name); | ||
712 | break; | ||
713 | default: | ||
714 | err("Not a valid state on slot %s\n", p_slot->name); | ||
715 | break; | ||
716 | } | ||
717 | mutex_unlock(&p_slot->lock); | ||
718 | |||
719 | return retval; | ||
720 | } | ||
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index b4226ff3a854..66123cf4deaa 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -82,31 +82,6 @@ | |||
82 | #define SLOT_100MHZ_PCIX_533 0x0f000000 | 82 | #define SLOT_100MHZ_PCIX_533 0x0f000000 |
83 | #define SLOT_133MHZ_PCIX_533 0xf0000000 | 83 | #define SLOT_133MHZ_PCIX_533 0xf0000000 |
84 | 84 | ||
85 | |||
86 | /* Secondary Bus Configuration Register */ | ||
87 | /* For PI = 1, Bits 0 to 2 have been encoded as follows to show current bus speed/mode */ | ||
88 | #define PCI_33MHZ 0x0 | ||
89 | #define PCI_66MHZ 0x1 | ||
90 | #define PCIX_66MHZ 0x2 | ||
91 | #define PCIX_100MHZ 0x3 | ||
92 | #define PCIX_133MHZ 0x4 | ||
93 | |||
94 | /* For PI = 2, Bits 0 to 3 have been encoded as follows to show current bus speed/mode */ | ||
95 | #define PCI_33MHZ 0x0 | ||
96 | #define PCI_66MHZ 0x1 | ||
97 | #define PCIX_66MHZ 0x2 | ||
98 | #define PCIX_100MHZ 0x3 | ||
99 | #define PCIX_133MHZ 0x4 | ||
100 | #define PCIX_66MHZ_ECC 0x5 | ||
101 | #define PCIX_100MHZ_ECC 0x6 | ||
102 | #define PCIX_133MHZ_ECC 0x7 | ||
103 | #define PCIX_66MHZ_266 0x9 | ||
104 | #define PCIX_100MHZ_266 0xa | ||
105 | #define PCIX_133MHZ_266 0xb | ||
106 | #define PCIX_66MHZ_533 0x11 | ||
107 | #define PCIX_100MHZ_533 0x12 | ||
108 | #define PCIX_133MHZ_533 0x13 | ||
109 | |||
110 | /* Slot Configuration */ | 85 | /* Slot Configuration */ |
111 | #define SLOT_NUM 0x0000001F | 86 | #define SLOT_NUM 0x0000001F |
112 | #define FIRST_DEV_NUM 0x00001F00 | 87 | #define FIRST_DEV_NUM 0x00001F00 |
@@ -231,6 +206,7 @@ static spinlock_t list_lock; | |||
231 | static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs); | 206 | static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs); |
232 | 207 | ||
233 | static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds); | 208 | static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds); |
209 | static int hpc_check_cmd_status(struct controller *ctrl); | ||
234 | 210 | ||
235 | /* This is the interrupt polling timeout function. */ | 211 | /* This is the interrupt polling timeout function. */ |
236 | static void int_poll_timeout(unsigned long lphp_ctlr) | 212 | static void int_poll_timeout(unsigned long lphp_ctlr) |
@@ -303,10 +279,13 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
303 | int i; | 279 | int i; |
304 | 280 | ||
305 | DBG_ENTER_ROUTINE | 281 | DBG_ENTER_ROUTINE |
306 | 282 | ||
283 | mutex_lock(&slot->ctrl->cmd_lock); | ||
284 | |||
307 | if (!php_ctlr) { | 285 | if (!php_ctlr) { |
308 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | 286 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
309 | return -1; | 287 | retval = -EINVAL; |
288 | goto out; | ||
310 | } | 289 | } |
311 | 290 | ||
312 | for (i = 0; i < 10; i++) { | 291 | for (i = 0; i < 10; i++) { |
@@ -323,7 +302,8 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
323 | if (cmd_status & 0x1) { | 302 | if (cmd_status & 0x1) { |
324 | /* After 1 sec and and the controller is still busy */ | 303 | /* After 1 sec and and the controller is still busy */ |
325 | err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); | 304 | err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); |
326 | return -1; | 305 | retval = -EBUSY; |
306 | goto out; | ||
327 | } | 307 | } |
328 | 308 | ||
329 | ++t_slot; | 309 | ++t_slot; |
@@ -340,6 +320,17 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
340 | * Wait for command completion. | 320 | * Wait for command completion. |
341 | */ | 321 | */ |
342 | retval = shpc_wait_cmd(slot->ctrl); | 322 | retval = shpc_wait_cmd(slot->ctrl); |
323 | if (retval) | ||
324 | goto out; | ||
325 | |||
326 | cmd_status = hpc_check_cmd_status(slot->ctrl); | ||
327 | if (cmd_status) { | ||
328 | err("%s: Failed to issued command 0x%x (error code = %d)\n", | ||
329 | __FUNCTION__, cmd, cmd_status); | ||
330 | retval = -EIO; | ||
331 | } | ||
332 | out: | ||
333 | mutex_unlock(&slot->ctrl->cmd_lock); | ||
343 | 334 | ||
344 | DBG_LEAVE_ROUTINE | 335 | DBG_LEAVE_ROUTINE |
345 | return retval; | 336 | return retval; |
@@ -532,81 +523,41 @@ static int hpc_get_prog_int(struct slot *slot, u8 *prog_int) | |||
532 | 523 | ||
533 | static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) | 524 | static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) |
534 | { | 525 | { |
535 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | ||
536 | u32 slot_reg; | ||
537 | u16 slot_status, sec_bus_status; | ||
538 | u8 m66_cap, pcix_cap, pi; | ||
539 | int retval = 0; | 526 | int retval = 0; |
527 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | ||
528 | u32 slot_reg = readl(php_ctlr->creg + SLOT1 + 4 * slot->hp_slot); | ||
529 | u8 pcix_cap = (slot_reg >> 12) & 7; | ||
530 | u8 m66_cap = (slot_reg >> 9) & 1; | ||
540 | 531 | ||
541 | DBG_ENTER_ROUTINE | 532 | DBG_ENTER_ROUTINE |
542 | 533 | ||
543 | if (!slot->ctrl->hpc_ctlr_handle) { | 534 | dbg("%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", |
544 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | 535 | __FUNCTION__, slot_reg, pcix_cap, m66_cap); |
545 | return -1; | ||
546 | } | ||
547 | |||
548 | if (slot->hp_slot >= php_ctlr->num_slots) { | ||
549 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); | ||
550 | return -1; | ||
551 | } | ||
552 | |||
553 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | ||
554 | slot_reg = readl(php_ctlr->creg + SLOT1 + 4*(slot->hp_slot)); | ||
555 | dbg("%s: pi = %d, slot_reg = %x\n", __FUNCTION__, pi, slot_reg); | ||
556 | slot_status = (u16) slot_reg; | ||
557 | dbg("%s: slot_status = %x\n", __FUNCTION__, slot_status); | ||
558 | sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG); | ||
559 | |||
560 | pcix_cap = (u8) ((slot_status & 0x3000) >> 12); | ||
561 | dbg("%s: pcix_cap = %x\n", __FUNCTION__, pcix_cap); | ||
562 | m66_cap = (u8) ((slot_status & 0x0200) >> 9); | ||
563 | dbg("%s: m66_cap = %x\n", __FUNCTION__, m66_cap); | ||
564 | |||
565 | 536 | ||
566 | if (pi == 2) { | 537 | switch (pcix_cap) { |
567 | switch (pcix_cap) { | 538 | case 0x0: |
568 | case 0: | 539 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; |
569 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; | 540 | break; |
570 | break; | 541 | case 0x1: |
571 | case 1: | 542 | *value = PCI_SPEED_66MHz_PCIX; |
572 | *value = PCI_SPEED_66MHz_PCIX; | 543 | break; |
573 | break; | 544 | case 0x3: |
574 | case 3: | 545 | *value = PCI_SPEED_133MHz_PCIX; |
575 | *value = PCI_SPEED_133MHz_PCIX; | 546 | break; |
576 | break; | 547 | case 0x4: |
577 | case 4: | 548 | *value = PCI_SPEED_133MHz_PCIX_266; |
578 | *value = PCI_SPEED_133MHz_PCIX_266; | 549 | break; |
579 | break; | 550 | case 0x5: |
580 | case 5: | 551 | *value = PCI_SPEED_133MHz_PCIX_533; |
581 | *value = PCI_SPEED_133MHz_PCIX_533; | 552 | break; |
582 | break; | 553 | case 0x2: |
583 | case 2: /* Reserved */ | 554 | default: |
584 | default: | 555 | *value = PCI_SPEED_UNKNOWN; |
585 | *value = PCI_SPEED_UNKNOWN; | 556 | retval = -ENODEV; |
586 | retval = -ENODEV; | 557 | break; |
587 | break; | ||
588 | } | ||
589 | } else { | ||
590 | switch (pcix_cap) { | ||
591 | case 0: | ||
592 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; | ||
593 | break; | ||
594 | case 1: | ||
595 | *value = PCI_SPEED_66MHz_PCIX; | ||
596 | break; | ||
597 | case 3: | ||
598 | *value = PCI_SPEED_133MHz_PCIX; | ||
599 | break; | ||
600 | case 2: /* Reserved */ | ||
601 | default: | ||
602 | *value = PCI_SPEED_UNKNOWN; | ||
603 | retval = -ENODEV; | ||
604 | break; | ||
605 | } | ||
606 | } | 558 | } |
607 | 559 | ||
608 | dbg("Adapter speed = %d\n", *value); | 560 | dbg("Adapter speed = %d\n", *value); |
609 | |||
610 | DBG_LEAVE_ROUTINE | 561 | DBG_LEAVE_ROUTINE |
611 | return retval; | 562 | return retval; |
612 | } | 563 | } |
@@ -797,6 +748,7 @@ static void hpc_release_ctlr(struct controller *ctrl) | |||
797 | { | 748 | { |
798 | struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle; | 749 | struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle; |
799 | struct php_ctlr_state_s *p, *p_prev; | 750 | struct php_ctlr_state_s *p, *p_prev; |
751 | int i; | ||
800 | 752 | ||
801 | DBG_ENTER_ROUTINE | 753 | DBG_ENTER_ROUTINE |
802 | 754 | ||
@@ -805,6 +757,14 @@ static void hpc_release_ctlr(struct controller *ctrl) | |||
805 | return ; | 757 | return ; |
806 | } | 758 | } |
807 | 759 | ||
760 | /* | ||
761 | * Mask all slot event interrupts | ||
762 | */ | ||
763 | for (i = 0; i < ctrl->num_slots; i++) | ||
764 | writel(0xffff3fff, php_ctlr->creg + SLOT1 + (4 * i)); | ||
765 | |||
766 | cleanup_slots(ctrl); | ||
767 | |||
808 | if (shpchp_poll_mode) { | 768 | if (shpchp_poll_mode) { |
809 | del_timer(&php_ctlr->int_poll_timer); | 769 | del_timer(&php_ctlr->int_poll_timer); |
810 | } else { | 770 | } else { |
@@ -814,6 +774,7 @@ static void hpc_release_ctlr(struct controller *ctrl) | |||
814 | pci_disable_msi(php_ctlr->pci_dev); | 774 | pci_disable_msi(php_ctlr->pci_dev); |
815 | } | 775 | } |
816 | } | 776 | } |
777 | |||
817 | if (php_ctlr->pci_dev) { | 778 | if (php_ctlr->pci_dev) { |
818 | iounmap(php_ctlr->creg); | 779 | iounmap(php_ctlr->creg); |
819 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); | 780 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); |
@@ -939,98 +900,66 @@ static int hpc_slot_disable(struct slot * slot) | |||
939 | 900 | ||
940 | static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) | 901 | static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) |
941 | { | 902 | { |
942 | u8 slot_cmd; | 903 | int retval; |
943 | u8 pi; | ||
944 | int retval = 0; | ||
945 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | 904 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
905 | u8 pi, cmd; | ||
946 | 906 | ||
947 | DBG_ENTER_ROUTINE | 907 | DBG_ENTER_ROUTINE |
948 | |||
949 | if (!slot->ctrl->hpc_ctlr_handle) { | ||
950 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | ||
951 | return -1; | ||
952 | } | ||
953 | 908 | ||
954 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | 909 | pi = readb(php_ctlr->creg + PROG_INTERFACE); |
955 | 910 | if ((pi == 1) && (value > PCI_SPEED_133MHz_PCIX)) | |
956 | if (pi == 1) { | 911 | return -EINVAL; |
957 | switch (value) { | ||
958 | case 0: | ||
959 | slot_cmd = SETA_PCI_33MHZ; | ||
960 | break; | ||
961 | case 1: | ||
962 | slot_cmd = SETA_PCI_66MHZ; | ||
963 | break; | ||
964 | case 2: | ||
965 | slot_cmd = SETA_PCIX_66MHZ; | ||
966 | break; | ||
967 | case 3: | ||
968 | slot_cmd = SETA_PCIX_100MHZ; | ||
969 | break; | ||
970 | case 4: | ||
971 | slot_cmd = SETA_PCIX_133MHZ; | ||
972 | break; | ||
973 | default: | ||
974 | slot_cmd = PCI_SPEED_UNKNOWN; | ||
975 | retval = -ENODEV; | ||
976 | return retval; | ||
977 | } | ||
978 | } else { | ||
979 | switch (value) { | ||
980 | case 0: | ||
981 | slot_cmd = SETB_PCI_33MHZ; | ||
982 | break; | ||
983 | case 1: | ||
984 | slot_cmd = SETB_PCI_66MHZ; | ||
985 | break; | ||
986 | case 2: | ||
987 | slot_cmd = SETB_PCIX_66MHZ_PM; | ||
988 | break; | ||
989 | case 3: | ||
990 | slot_cmd = SETB_PCIX_100MHZ_PM; | ||
991 | break; | ||
992 | case 4: | ||
993 | slot_cmd = SETB_PCIX_133MHZ_PM; | ||
994 | break; | ||
995 | case 5: | ||
996 | slot_cmd = SETB_PCIX_66MHZ_EM; | ||
997 | break; | ||
998 | case 6: | ||
999 | slot_cmd = SETB_PCIX_100MHZ_EM; | ||
1000 | break; | ||
1001 | case 7: | ||
1002 | slot_cmd = SETB_PCIX_133MHZ_EM; | ||
1003 | break; | ||
1004 | case 8: | ||
1005 | slot_cmd = SETB_PCIX_66MHZ_266; | ||
1006 | break; | ||
1007 | case 0x9: | ||
1008 | slot_cmd = SETB_PCIX_100MHZ_266; | ||
1009 | break; | ||
1010 | case 0xa: | ||
1011 | slot_cmd = SETB_PCIX_133MHZ_266; | ||
1012 | break; | ||
1013 | case 0xb: | ||
1014 | slot_cmd = SETB_PCIX_66MHZ_533; | ||
1015 | break; | ||
1016 | case 0xc: | ||
1017 | slot_cmd = SETB_PCIX_100MHZ_533; | ||
1018 | break; | ||
1019 | case 0xd: | ||
1020 | slot_cmd = SETB_PCIX_133MHZ_533; | ||
1021 | break; | ||
1022 | default: | ||
1023 | slot_cmd = PCI_SPEED_UNKNOWN; | ||
1024 | retval = -ENODEV; | ||
1025 | return retval; | ||
1026 | } | ||
1027 | 912 | ||
913 | switch (value) { | ||
914 | case PCI_SPEED_33MHz: | ||
915 | cmd = SETA_PCI_33MHZ; | ||
916 | break; | ||
917 | case PCI_SPEED_66MHz: | ||
918 | cmd = SETA_PCI_66MHZ; | ||
919 | break; | ||
920 | case PCI_SPEED_66MHz_PCIX: | ||
921 | cmd = SETA_PCIX_66MHZ; | ||
922 | break; | ||
923 | case PCI_SPEED_100MHz_PCIX: | ||
924 | cmd = SETA_PCIX_100MHZ; | ||
925 | break; | ||
926 | case PCI_SPEED_133MHz_PCIX: | ||
927 | cmd = SETA_PCIX_133MHZ; | ||
928 | break; | ||
929 | case PCI_SPEED_66MHz_PCIX_ECC: | ||
930 | cmd = SETB_PCIX_66MHZ_EM; | ||
931 | break; | ||
932 | case PCI_SPEED_100MHz_PCIX_ECC: | ||
933 | cmd = SETB_PCIX_100MHZ_EM; | ||
934 | break; | ||
935 | case PCI_SPEED_133MHz_PCIX_ECC: | ||
936 | cmd = SETB_PCIX_133MHZ_EM; | ||
937 | break; | ||
938 | case PCI_SPEED_66MHz_PCIX_266: | ||
939 | cmd = SETB_PCIX_66MHZ_266; | ||
940 | break; | ||
941 | case PCI_SPEED_100MHz_PCIX_266: | ||
942 | cmd = SETB_PCIX_100MHZ_266; | ||
943 | break; | ||
944 | case PCI_SPEED_133MHz_PCIX_266: | ||
945 | cmd = SETB_PCIX_133MHZ_266; | ||
946 | break; | ||
947 | case PCI_SPEED_66MHz_PCIX_533: | ||
948 | cmd = SETB_PCIX_66MHZ_533; | ||
949 | break; | ||
950 | case PCI_SPEED_100MHz_PCIX_533: | ||
951 | cmd = SETB_PCIX_100MHZ_533; | ||
952 | break; | ||
953 | case PCI_SPEED_133MHz_PCIX_533: | ||
954 | cmd = SETB_PCIX_133MHZ_533; | ||
955 | break; | ||
956 | default: | ||
957 | return -EINVAL; | ||
1028 | } | 958 | } |
1029 | retval = shpc_write_cmd(slot, 0, slot_cmd); | 959 | |
1030 | if (retval) { | 960 | retval = shpc_write_cmd(slot, 0, cmd); |
961 | if (retval) | ||
1031 | err("%s: Write command failed!\n", __FUNCTION__); | 962 | err("%s: Write command failed!\n", __FUNCTION__); |
1032 | return -1; | ||
1033 | } | ||
1034 | 963 | ||
1035 | DBG_LEAVE_ROUTINE | 964 | DBG_LEAVE_ROUTINE |
1036 | return retval; | 965 | return retval; |
@@ -1093,14 +1022,8 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) | |||
1093 | wake_up_interruptible(&ctrl->queue); | 1022 | wake_up_interruptible(&ctrl->queue); |
1094 | } | 1023 | } |
1095 | 1024 | ||
1096 | if ((intr_loc = (intr_loc >> 1)) == 0) { | 1025 | if ((intr_loc = (intr_loc >> 1)) == 0) |
1097 | /* Unmask Global Interrupt Mask */ | 1026 | goto out; |
1098 | temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); | ||
1099 | temp_dword &= 0xfffffffe; | ||
1100 | writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); | ||
1101 | |||
1102 | return IRQ_NONE; | ||
1103 | } | ||
1104 | 1027 | ||
1105 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { | 1028 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { |
1106 | /* To find out which slot has interrupt pending */ | 1029 | /* To find out which slot has interrupt pending */ |
@@ -1130,6 +1053,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) | |||
1130 | dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2); | 1053 | dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2); |
1131 | } | 1054 | } |
1132 | } | 1055 | } |
1056 | out: | ||
1133 | if (!shpchp_poll_mode) { | 1057 | if (!shpchp_poll_mode) { |
1134 | /* Unmask Global Interrupt Mask */ | 1058 | /* Unmask Global Interrupt Mask */ |
1135 | temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); | 1059 | temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); |
@@ -1142,64 +1066,43 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) | |||
1142 | 1066 | ||
1143 | static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) | 1067 | static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) |
1144 | { | 1068 | { |
1069 | int retval = 0; | ||
1145 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | 1070 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
1146 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; | 1071 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; |
1147 | int retval = 0; | 1072 | u8 pi = readb(php_ctlr->creg + PROG_INTERFACE); |
1148 | u8 pi; | 1073 | u32 slot_avail1 = readl(php_ctlr->creg + SLOT_AVAIL1); |
1149 | u32 slot_avail1, slot_avail2; | 1074 | u32 slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2); |
1150 | 1075 | ||
1151 | DBG_ENTER_ROUTINE | 1076 | DBG_ENTER_ROUTINE |
1152 | 1077 | ||
1153 | if (!slot->ctrl->hpc_ctlr_handle) { | ||
1154 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | ||
1155 | return -1; | ||
1156 | } | ||
1157 | |||
1158 | if (slot->hp_slot >= php_ctlr->num_slots) { | ||
1159 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); | ||
1160 | return -1; | ||
1161 | } | ||
1162 | |||
1163 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | ||
1164 | slot_avail1 = readl(php_ctlr->creg + SLOT_AVAIL1); | ||
1165 | slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2); | ||
1166 | |||
1167 | if (pi == 2) { | 1078 | if (pi == 2) { |
1168 | if (slot_avail2 & SLOT_133MHZ_PCIX_533) | 1079 | if (slot_avail2 & SLOT_133MHZ_PCIX_533) |
1169 | bus_speed = PCIX_133MHZ_533; | 1080 | bus_speed = PCI_SPEED_133MHz_PCIX_533; |
1170 | else if (slot_avail2 & SLOT_100MHZ_PCIX_533) | 1081 | else if (slot_avail2 & SLOT_100MHZ_PCIX_533) |
1171 | bus_speed = PCIX_100MHZ_533; | 1082 | bus_speed = PCI_SPEED_100MHz_PCIX_533; |
1172 | else if (slot_avail2 & SLOT_66MHZ_PCIX_533) | 1083 | else if (slot_avail2 & SLOT_66MHZ_PCIX_533) |
1173 | bus_speed = PCIX_66MHZ_533; | 1084 | bus_speed = PCI_SPEED_66MHz_PCIX_533; |
1174 | else if (slot_avail2 & SLOT_133MHZ_PCIX_266) | 1085 | else if (slot_avail2 & SLOT_133MHZ_PCIX_266) |
1175 | bus_speed = PCIX_133MHZ_266; | 1086 | bus_speed = PCI_SPEED_133MHz_PCIX_266; |
1176 | else if (slot_avail2 & SLOT_100MHZ_PCIX_266) | 1087 | else if (slot_avail2 & SLOT_100MHZ_PCIX_266) |
1177 | bus_speed = PCIX_100MHZ_266; | 1088 | bus_speed = PCI_SPEED_100MHz_PCIX_266; |
1178 | else if (slot_avail2 & SLOT_66MHZ_PCIX_266) | 1089 | else if (slot_avail2 & SLOT_66MHZ_PCIX_266) |
1179 | bus_speed = PCIX_66MHZ_266; | 1090 | bus_speed = PCI_SPEED_66MHz_PCIX_266; |
1180 | else if (slot_avail1 & SLOT_133MHZ_PCIX) | 1091 | } |
1181 | bus_speed = PCIX_133MHZ; | 1092 | |
1182 | else if (slot_avail1 & SLOT_100MHZ_PCIX) | 1093 | if (bus_speed == PCI_SPEED_UNKNOWN) { |
1183 | bus_speed = PCIX_100MHZ; | ||
1184 | else if (slot_avail1 & SLOT_66MHZ_PCIX) | ||
1185 | bus_speed = PCIX_66MHZ; | ||
1186 | else if (slot_avail2 & SLOT_66MHZ) | ||
1187 | bus_speed = PCI_66MHZ; | ||
1188 | else if (slot_avail1 & SLOT_33MHZ) | ||
1189 | bus_speed = PCI_33MHZ; | ||
1190 | else bus_speed = PCI_SPEED_UNKNOWN; | ||
1191 | } else { | ||
1192 | if (slot_avail1 & SLOT_133MHZ_PCIX) | 1094 | if (slot_avail1 & SLOT_133MHZ_PCIX) |
1193 | bus_speed = PCIX_133MHZ; | 1095 | bus_speed = PCI_SPEED_133MHz_PCIX; |
1194 | else if (slot_avail1 & SLOT_100MHZ_PCIX) | 1096 | else if (slot_avail1 & SLOT_100MHZ_PCIX) |
1195 | bus_speed = PCIX_100MHZ; | 1097 | bus_speed = PCI_SPEED_100MHz_PCIX; |
1196 | else if (slot_avail1 & SLOT_66MHZ_PCIX) | 1098 | else if (slot_avail1 & SLOT_66MHZ_PCIX) |
1197 | bus_speed = PCIX_66MHZ; | 1099 | bus_speed = PCI_SPEED_66MHz_PCIX; |
1198 | else if (slot_avail2 & SLOT_66MHZ) | 1100 | else if (slot_avail2 & SLOT_66MHZ) |
1199 | bus_speed = PCI_66MHZ; | 1101 | bus_speed = PCI_SPEED_66MHz; |
1200 | else if (slot_avail1 & SLOT_33MHZ) | 1102 | else if (slot_avail1 & SLOT_33MHZ) |
1201 | bus_speed = PCI_33MHZ; | 1103 | bus_speed = PCI_SPEED_33MHz; |
1202 | else bus_speed = PCI_SPEED_UNKNOWN; | 1104 | else |
1105 | retval = -ENODEV; | ||
1203 | } | 1106 | } |
1204 | 1107 | ||
1205 | *value = bus_speed; | 1108 | *value = bus_speed; |
@@ -1210,111 +1113,69 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) | |||
1210 | 1113 | ||
1211 | static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) | 1114 | static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) |
1212 | { | 1115 | { |
1116 | int retval = 0; | ||
1213 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | 1117 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
1214 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; | 1118 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; |
1215 | u16 sec_bus_status; | 1119 | u16 sec_bus_reg = readw(php_ctlr->creg + SEC_BUS_CONFIG); |
1216 | int retval = 0; | 1120 | u8 pi = readb(php_ctlr->creg + PROG_INTERFACE); |
1217 | u8 pi; | 1121 | u8 speed_mode = (pi == 2) ? (sec_bus_reg & 0xF) : (sec_bus_reg & 0x7); |
1218 | 1122 | ||
1219 | DBG_ENTER_ROUTINE | 1123 | DBG_ENTER_ROUTINE |
1220 | 1124 | ||
1221 | if (!slot->ctrl->hpc_ctlr_handle) { | 1125 | if ((pi == 1) && (speed_mode > 4)) { |
1222 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | 1126 | *value = PCI_SPEED_UNKNOWN; |
1223 | return -1; | 1127 | return -ENODEV; |
1224 | } | ||
1225 | |||
1226 | if (slot->hp_slot >= php_ctlr->num_slots) { | ||
1227 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); | ||
1228 | return -1; | ||
1229 | } | 1128 | } |
1230 | 1129 | ||
1231 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | 1130 | switch (speed_mode) { |
1232 | sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG); | 1131 | case 0x0: |
1233 | 1132 | *value = PCI_SPEED_33MHz; | |
1234 | if (pi == 2) { | 1133 | break; |
1235 | switch (sec_bus_status & 0x000f) { | 1134 | case 0x1: |
1236 | case 0: | 1135 | *value = PCI_SPEED_66MHz; |
1237 | bus_speed = PCI_SPEED_33MHz; | 1136 | break; |
1238 | break; | 1137 | case 0x2: |
1239 | case 1: | 1138 | *value = PCI_SPEED_66MHz_PCIX; |
1240 | bus_speed = PCI_SPEED_66MHz; | 1139 | break; |
1241 | break; | 1140 | case 0x3: |
1242 | case 2: | 1141 | *value = PCI_SPEED_100MHz_PCIX; |
1243 | bus_speed = PCI_SPEED_66MHz_PCIX; | 1142 | break; |
1244 | break; | 1143 | case 0x4: |
1245 | case 3: | 1144 | *value = PCI_SPEED_133MHz_PCIX; |
1246 | bus_speed = PCI_SPEED_100MHz_PCIX; | 1145 | break; |
1247 | break; | 1146 | case 0x5: |
1248 | case 4: | 1147 | *value = PCI_SPEED_66MHz_PCIX_ECC; |
1249 | bus_speed = PCI_SPEED_133MHz_PCIX; | 1148 | break; |
1250 | break; | 1149 | case 0x6: |
1251 | case 5: | 1150 | *value = PCI_SPEED_100MHz_PCIX_ECC; |
1252 | bus_speed = PCI_SPEED_66MHz_PCIX_ECC; | 1151 | break; |
1253 | break; | 1152 | case 0x7: |
1254 | case 6: | 1153 | *value = PCI_SPEED_133MHz_PCIX_ECC; |
1255 | bus_speed = PCI_SPEED_100MHz_PCIX_ECC; | 1154 | break; |
1256 | break; | 1155 | case 0x8: |
1257 | case 7: | 1156 | *value = PCI_SPEED_66MHz_PCIX_266; |
1258 | bus_speed = PCI_SPEED_133MHz_PCIX_ECC; | 1157 | break; |
1259 | break; | 1158 | case 0x9: |
1260 | case 8: | 1159 | *value = PCI_SPEED_100MHz_PCIX_266; |
1261 | bus_speed = PCI_SPEED_66MHz_PCIX_266; | 1160 | break; |
1262 | break; | 1161 | case 0xa: |
1263 | case 9: | 1162 | *value = PCI_SPEED_133MHz_PCIX_266; |
1264 | bus_speed = PCI_SPEED_100MHz_PCIX_266; | 1163 | break; |
1265 | break; | 1164 | case 0xb: |
1266 | case 0xa: | 1165 | *value = PCI_SPEED_66MHz_PCIX_533; |
1267 | bus_speed = PCI_SPEED_133MHz_PCIX_266; | 1166 | break; |
1268 | break; | 1167 | case 0xc: |
1269 | case 0xb: | 1168 | *value = PCI_SPEED_100MHz_PCIX_533; |
1270 | bus_speed = PCI_SPEED_66MHz_PCIX_533; | 1169 | break; |
1271 | break; | 1170 | case 0xd: |
1272 | case 0xc: | 1171 | *value = PCI_SPEED_133MHz_PCIX_533; |
1273 | bus_speed = PCI_SPEED_100MHz_PCIX_533; | 1172 | break; |
1274 | break; | 1173 | default: |
1275 | case 0xd: | 1174 | *value = PCI_SPEED_UNKNOWN; |
1276 | bus_speed = PCI_SPEED_133MHz_PCIX_533; | 1175 | retval = -ENODEV; |
1277 | break; | 1176 | break; |
1278 | case 0xe: | ||
1279 | case 0xf: | ||
1280 | default: | ||
1281 | bus_speed = PCI_SPEED_UNKNOWN; | ||
1282 | break; | ||
1283 | } | ||
1284 | } else { | ||
1285 | /* In the case where pi is undefined, default it to 1 */ | ||
1286 | switch (sec_bus_status & 0x0007) { | ||
1287 | case 0: | ||
1288 | bus_speed = PCI_SPEED_33MHz; | ||
1289 | break; | ||
1290 | case 1: | ||
1291 | bus_speed = PCI_SPEED_66MHz; | ||
1292 | break; | ||
1293 | case 2: | ||
1294 | bus_speed = PCI_SPEED_66MHz_PCIX; | ||
1295 | break; | ||
1296 | case 3: | ||
1297 | bus_speed = PCI_SPEED_100MHz_PCIX; | ||
1298 | break; | ||
1299 | case 4: | ||
1300 | bus_speed = PCI_SPEED_133MHz_PCIX; | ||
1301 | break; | ||
1302 | case 5: | ||
1303 | bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */ | ||
1304 | break; | ||
1305 | case 6: | ||
1306 | bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */ | ||
1307 | break; | ||
1308 | case 7: | ||
1309 | bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */ | ||
1310 | break; | ||
1311 | default: | ||
1312 | bus_speed = PCI_SPEED_UNKNOWN; | ||
1313 | break; | ||
1314 | } | ||
1315 | } | 1177 | } |
1316 | 1178 | ||
1317 | *value = bus_speed; | ||
1318 | dbg("Current bus speed = %d\n", bus_speed); | 1179 | dbg("Current bus speed = %d\n", bus_speed); |
1319 | DBG_LEAVE_ROUTINE | 1180 | DBG_LEAVE_ROUTINE |
1320 | return retval; | 1181 | return retval; |
@@ -1343,7 +1204,6 @@ static struct hpc_ops shpchp_hpc_ops = { | |||
1343 | .green_led_blink = hpc_set_green_led_blink, | 1204 | .green_led_blink = hpc_set_green_led_blink, |
1344 | 1205 | ||
1345 | .release_ctlr = hpc_release_ctlr, | 1206 | .release_ctlr = hpc_release_ctlr, |
1346 | .check_cmd_status = hpc_check_cmd_status, | ||
1347 | }; | 1207 | }; |
1348 | 1208 | ||
1349 | inline static int shpc_indirect_creg_read(struct controller *ctrl, int index, | 1209 | inline static int shpc_indirect_creg_read(struct controller *ctrl, int index, |
@@ -1375,15 +1235,13 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) | |||
1375 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ | 1235 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ |
1376 | 1236 | ||
1377 | spin_lock_init(&list_lock); | 1237 | spin_lock_init(&list_lock); |
1378 | php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); | 1238 | php_ctlr = kzalloc(sizeof(*php_ctlr), GFP_KERNEL); |
1379 | 1239 | ||
1380 | if (!php_ctlr) { /* allocate controller state data */ | 1240 | if (!php_ctlr) { /* allocate controller state data */ |
1381 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); | 1241 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); |
1382 | goto abort; | 1242 | goto abort; |
1383 | } | 1243 | } |
1384 | 1244 | ||
1385 | memset(php_ctlr, 0, sizeof(struct php_ctlr_state_s)); | ||
1386 | |||
1387 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ | 1245 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ |
1388 | 1246 | ||
1389 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == | 1247 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == |
@@ -1454,7 +1312,9 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) | |||
1454 | } | 1312 | } |
1455 | dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); | 1313 | dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); |
1456 | 1314 | ||
1457 | init_MUTEX(&ctrl->crit_sect); | 1315 | mutex_init(&ctrl->crit_sect); |
1316 | mutex_init(&ctrl->cmd_lock); | ||
1317 | |||
1458 | /* Setup wait queue */ | 1318 | /* Setup wait queue */ |
1459 | init_waitqueue_head(&ctrl->queue); | 1319 | init_waitqueue_head(&ctrl->queue); |
1460 | 1320 | ||
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 19e1a5e1e30b..257adc233996 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
@@ -38,7 +38,7 @@ static void program_fw_provided_values(struct pci_dev *dev) | |||
38 | { | 38 | { |
39 | u16 pci_cmd, pci_bctl; | 39 | u16 pci_cmd, pci_bctl; |
40 | struct pci_dev *cdev; | 40 | struct pci_dev *cdev; |
41 | struct hotplug_params hpp = {0x8, 0x40, 0, 0}; /* defaults */ | 41 | struct hotplug_params hpp; |
42 | 42 | ||
43 | /* Program hpp values for this device */ | 43 | /* Program hpp values for this device */ |
44 | if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL || | 44 | if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL || |
@@ -46,7 +46,13 @@ static void program_fw_provided_values(struct pci_dev *dev) | |||
46 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) | 46 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) |
47 | return; | 47 | return; |
48 | 48 | ||
49 | get_hp_params_from_firmware(dev, &hpp); | 49 | /* use default values if we can't get them from firmware */ |
50 | if (get_hp_params_from_firmware(dev, &hpp)) { | ||
51 | hpp.cache_line_size = 8; | ||
52 | hpp.latency_timer = 0x40; | ||
53 | hpp.enable_serr = 0; | ||
54 | hpp.enable_perr = 0; | ||
55 | } | ||
50 | 56 | ||
51 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp.cache_line_size); | 57 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp.cache_line_size); |
52 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.latency_timer); | 58 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.latency_timer); |
diff --git a/drivers/pci/hotplug/shpchprm_legacy.c b/drivers/pci/hotplug/shpchprm_legacy.c deleted file mode 100644 index ed6c1254bf6f..000000000000 --- a/drivers/pci/hotplug/shpchprm_legacy.c +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* | ||
2 | * SHPCHPRM Legacy: PHP Resource Manager for Non-ACPI/Legacy platform | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2003-2004 Intel Corporation | ||
8 | * | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/pci.h> | ||
34 | #include "shpchp.h" | ||
35 | |||
36 | int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) | ||
37 | { | ||
38 | int offset = devnum - ctrl->slot_device_offset; | ||
39 | |||
40 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc * offset); | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | void get_hp_params_from_firmware(struct pci_dev *dev, | ||
45 | struct hotplug_params *hpp) | ||
46 | { | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | void get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
51 | { | ||
52 | return; | ||
53 | } | ||
54 | |||
diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.c b/drivers/pci/hotplug/shpchprm_nonacpi.c deleted file mode 100644 index c6b40998eeb3..000000000000 --- a/drivers/pci/hotplug/shpchprm_nonacpi.c +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * SHPCHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2003-2004 Intel Corporation | ||
8 | * | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #include <linux/config.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/pci.h> | ||
35 | #include <linux/slab.h> | ||
36 | |||
37 | #include "shpchp.h" | ||
38 | |||
39 | int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) | ||
40 | { | ||
41 | int offset = devnum - ctrl->slot_device_offset; | ||
42 | |||
43 | dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset); | ||
44 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc * offset); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | void get_hp_params_from_firmware(struct pci_dev *dev, | ||
49 | struct hotplug_params *hpp) | ||
50 | { | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | void get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
55 | { | ||
56 | return; | ||
57 | } | ||
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 48723d6fa60f..a77e79c8c82e 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -103,9 +103,9 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask) | |||
103 | switch (entry->msi_attrib.type) { | 103 | switch (entry->msi_attrib.type) { |
104 | case PCI_CAP_ID_MSI: | 104 | case PCI_CAP_ID_MSI: |
105 | { | 105 | { |
106 | int pos; | 106 | int pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI); |
107 | 107 | ||
108 | if (!(pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI))) | 108 | if (!pos) |
109 | return; | 109 | return; |
110 | 110 | ||
111 | pci_read_config_dword(entry->dev, msi_lower_address_reg(pos), | 111 | pci_read_config_dword(entry->dev, msi_lower_address_reg(pos), |
@@ -347,9 +347,9 @@ static int assign_msi_vector(void) | |||
347 | 347 | ||
348 | static int get_new_vector(void) | 348 | static int get_new_vector(void) |
349 | { | 349 | { |
350 | int vector; | 350 | int vector = assign_msi_vector(); |
351 | 351 | ||
352 | if ((vector = assign_msi_vector()) > 0) | 352 | if (vector > 0) |
353 | set_intr_gate(vector, interrupt[vector]); | 353 | set_intr_gate(vector, interrupt[vector]); |
354 | 354 | ||
355 | return vector; | 355 | return vector; |
@@ -369,7 +369,8 @@ static int msi_init(void) | |||
369 | return status; | 369 | return status; |
370 | } | 370 | } |
371 | 371 | ||
372 | if ((status = msi_cache_init()) < 0) { | 372 | status = msi_cache_init(); |
373 | if (status < 0) { | ||
373 | pci_msi_enable = 0; | 374 | pci_msi_enable = 0; |
374 | printk(KERN_WARNING "PCI: MSI cache init failed\n"); | 375 | printk(KERN_WARNING "PCI: MSI cache init failed\n"); |
375 | return status; | 376 | return status; |
@@ -523,10 +524,12 @@ static int msi_capability_init(struct pci_dev *dev) | |||
523 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | 524 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
524 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 525 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
525 | /* MSI Entry Initialization */ | 526 | /* MSI Entry Initialization */ |
526 | if (!(entry = alloc_msi_entry())) | 527 | entry = alloc_msi_entry(); |
528 | if (!entry) | ||
527 | return -ENOMEM; | 529 | return -ENOMEM; |
528 | 530 | ||
529 | if ((vector = get_msi_vector(dev)) < 0) { | 531 | vector = get_msi_vector(dev); |
532 | if (vector < 0) { | ||
530 | kmem_cache_free(msi_cachep, entry); | 533 | kmem_cache_free(msi_cachep, entry); |
531 | return -EBUSY; | 534 | return -EBUSY; |
532 | } | 535 | } |
@@ -597,7 +600,8 @@ static int msix_capability_init(struct pci_dev *dev, | |||
597 | struct msg_address address; | 600 | struct msg_address address; |
598 | struct msg_data data; | 601 | struct msg_data data; |
599 | int vector, pos, i, j, nr_entries, temp = 0; | 602 | int vector, pos, i, j, nr_entries, temp = 0; |
600 | u32 phys_addr, table_offset; | 603 | unsigned long phys_addr; |
604 | u32 table_offset; | ||
601 | u16 control; | 605 | u16 control; |
602 | u8 bir; | 606 | u8 bir; |
603 | void __iomem *base; | 607 | void __iomem *base; |
@@ -606,11 +610,11 @@ static int msix_capability_init(struct pci_dev *dev, | |||
606 | /* Request & Map MSI-X table region */ | 610 | /* Request & Map MSI-X table region */ |
607 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 611 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
608 | nr_entries = multi_msix_capable(control); | 612 | nr_entries = multi_msix_capable(control); |
609 | pci_read_config_dword(dev, msix_table_offset_reg(pos), | 613 | |
610 | &table_offset); | 614 | pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset); |
611 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); | 615 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); |
612 | phys_addr = pci_resource_start (dev, bir); | 616 | table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; |
613 | phys_addr += (u32)(table_offset & ~PCI_MSIX_FLAGS_BIRMASK); | 617 | phys_addr = pci_resource_start (dev, bir) + table_offset; |
614 | base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE); | 618 | base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE); |
615 | if (base == NULL) | 619 | if (base == NULL) |
616 | return -ENOMEM; | 620 | return -ENOMEM; |
@@ -620,7 +624,8 @@ static int msix_capability_init(struct pci_dev *dev, | |||
620 | entry = alloc_msi_entry(); | 624 | entry = alloc_msi_entry(); |
621 | if (!entry) | 625 | if (!entry) |
622 | break; | 626 | break; |
623 | if ((vector = get_msi_vector(dev)) < 0) | 627 | vector = get_msi_vector(dev); |
628 | if (vector < 0) | ||
624 | break; | 629 | break; |
625 | 630 | ||
626 | j = entries[i].entry; | 631 | j = entries[i].entry; |
@@ -699,12 +704,17 @@ int pci_enable_msi(struct pci_dev* dev) | |||
699 | if (dev->no_msi) | 704 | if (dev->no_msi) |
700 | return status; | 705 | return status; |
701 | 706 | ||
707 | if (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) | ||
708 | return -EINVAL; | ||
709 | |||
702 | temp = dev->irq; | 710 | temp = dev->irq; |
703 | 711 | ||
704 | if ((status = msi_init()) < 0) | 712 | status = msi_init(); |
713 | if (status < 0) | ||
705 | return status; | 714 | return status; |
706 | 715 | ||
707 | if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSI))) | 716 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
717 | if (!pos) | ||
708 | return -EINVAL; | 718 | return -EINVAL; |
709 | 719 | ||
710 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 720 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -728,8 +738,8 @@ int pci_enable_msi(struct pci_dev* dev) | |||
728 | dev->irq = temp; | 738 | dev->irq = temp; |
729 | } | 739 | } |
730 | /* Check whether driver already requested for MSI-X vectors */ | 740 | /* Check whether driver already requested for MSI-X vectors */ |
731 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 && | 741 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
732 | !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { | 742 | if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { |
733 | printk(KERN_INFO "PCI: %s: Can't enable MSI. " | 743 | printk(KERN_INFO "PCI: %s: Can't enable MSI. " |
734 | "Device already has MSI-X vectors assigned\n", | 744 | "Device already has MSI-X vectors assigned\n", |
735 | pci_name(dev)); | 745 | pci_name(dev)); |
@@ -755,7 +765,13 @@ void pci_disable_msi(struct pci_dev* dev) | |||
755 | u16 control; | 765 | u16 control; |
756 | unsigned long flags; | 766 | unsigned long flags; |
757 | 767 | ||
758 | if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSI))) | 768 | if (!pci_msi_enable) |
769 | return; | ||
770 | if (!dev) | ||
771 | return; | ||
772 | |||
773 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | ||
774 | if (!pos) | ||
759 | return; | 775 | return; |
760 | 776 | ||
761 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 777 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -826,8 +842,10 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) | |||
826 | * Detect last MSI-X vector to be released. | 842 | * Detect last MSI-X vector to be released. |
827 | * Release the MSI-X memory-mapped table. | 843 | * Release the MSI-X memory-mapped table. |
828 | */ | 844 | */ |
845 | #if 0 | ||
829 | int pos, nr_entries; | 846 | int pos, nr_entries; |
830 | u32 phys_addr, table_offset; | 847 | unsigned long phys_addr; |
848 | u32 table_offset; | ||
831 | u16 control; | 849 | u16 control; |
832 | u8 bir; | 850 | u8 bir; |
833 | 851 | ||
@@ -838,9 +856,12 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) | |||
838 | pci_read_config_dword(dev, msix_table_offset_reg(pos), | 856 | pci_read_config_dword(dev, msix_table_offset_reg(pos), |
839 | &table_offset); | 857 | &table_offset); |
840 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); | 858 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); |
841 | phys_addr = pci_resource_start (dev, bir); | 859 | table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; |
842 | phys_addr += (u32)(table_offset & | 860 | phys_addr = pci_resource_start(dev, bir) + table_offset; |
843 | ~PCI_MSIX_FLAGS_BIRMASK); | 861 | /* |
862 | * FIXME! and what did you want to do with phys_addr? | ||
863 | */ | ||
864 | #endif | ||
844 | iounmap(base); | 865 | iounmap(base); |
845 | } | 866 | } |
846 | } | 867 | } |
@@ -924,10 +945,12 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) | |||
924 | if (!pci_msi_enable || !dev || !entries) | 945 | if (!pci_msi_enable || !dev || !entries) |
925 | return -EINVAL; | 946 | return -EINVAL; |
926 | 947 | ||
927 | if ((status = msi_init()) < 0) | 948 | status = msi_init(); |
949 | if (status < 0) | ||
928 | return status; | 950 | return status; |
929 | 951 | ||
930 | if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX))) | 952 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
953 | if (!pos) | ||
931 | return -EINVAL; | 954 | return -EINVAL; |
932 | 955 | ||
933 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 956 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -1006,7 +1029,13 @@ void pci_disable_msix(struct pci_dev* dev) | |||
1006 | int pos, temp; | 1029 | int pos, temp; |
1007 | u16 control; | 1030 | u16 control; |
1008 | 1031 | ||
1009 | if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX))) | 1032 | if (!pci_msi_enable) |
1033 | return; | ||
1034 | if (!dev) | ||
1035 | return; | ||
1036 | |||
1037 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); | ||
1038 | if (!pos) | ||
1010 | return; | 1039 | return; |
1011 | 1040 | ||
1012 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 1041 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -1066,8 +1095,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1066 | return; | 1095 | return; |
1067 | 1096 | ||
1068 | temp = dev->irq; /* Save IOAPIC IRQ */ | 1097 | temp = dev->irq; /* Save IOAPIC IRQ */ |
1069 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) > 0 && | 1098 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
1070 | !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) { | 1099 | if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) { |
1071 | spin_lock_irqsave(&msi_lock, flags); | 1100 | spin_lock_irqsave(&msi_lock, flags); |
1072 | state = msi_desc[dev->irq]->msi_attrib.state; | 1101 | state = msi_desc[dev->irq]->msi_attrib.state; |
1073 | spin_unlock_irqrestore(&msi_lock, flags); | 1102 | spin_unlock_irqrestore(&msi_lock, flags); |
@@ -1080,8 +1109,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1080 | msi_free_vector(dev, dev->irq, 0); | 1109 | msi_free_vector(dev, dev->irq, 0); |
1081 | dev->irq = temp; /* Restore IOAPIC IRQ */ | 1110 | dev->irq = temp; /* Restore IOAPIC IRQ */ |
1082 | } | 1111 | } |
1083 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 && | 1112 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
1084 | !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { | 1113 | if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { |
1085 | int vector, head, tail = 0, warning = 0; | 1114 | int vector, head, tail = 0, warning = 0; |
1086 | void __iomem *base = NULL; | 1115 | void __iomem *base = NULL; |
1087 | 1116 | ||
@@ -1101,7 +1130,9 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1101 | msi_free_vector(dev, vector, 0); | 1130 | msi_free_vector(dev, vector, 0); |
1102 | if (warning) { | 1131 | if (warning) { |
1103 | /* Force to release the MSI-X memory-mapped table */ | 1132 | /* Force to release the MSI-X memory-mapped table */ |
1104 | u32 phys_addr, table_offset; | 1133 | #if 0 |
1134 | unsigned long phys_addr; | ||
1135 | u32 table_offset; | ||
1105 | u16 control; | 1136 | u16 control; |
1106 | u8 bir; | 1137 | u8 bir; |
1107 | 1138 | ||
@@ -1110,9 +1141,12 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1110 | pci_read_config_dword(dev, msix_table_offset_reg(pos), | 1141 | pci_read_config_dword(dev, msix_table_offset_reg(pos), |
1111 | &table_offset); | 1142 | &table_offset); |
1112 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); | 1143 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); |
1113 | phys_addr = pci_resource_start (dev, bir); | 1144 | table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; |
1114 | phys_addr += (u32)(table_offset & | 1145 | phys_addr = pci_resource_start(dev, bir) + table_offset; |
1115 | ~PCI_MSIX_FLAGS_BIRMASK); | 1146 | /* |
1147 | * FIXME! and what did you want to do with phys_addr? | ||
1148 | */ | ||
1149 | #endif | ||
1116 | iounmap(base); | 1150 | iounmap(base); |
1117 | printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() " | 1151 | printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() " |
1118 | "called without free_irq() on all MSI-X vectors\n", | 1152 | "called without free_irq() on all MSI-X vectors\n", |
@@ -1123,6 +1157,11 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1123 | } | 1157 | } |
1124 | } | 1158 | } |
1125 | 1159 | ||
1160 | void pci_no_msi(void) | ||
1161 | { | ||
1162 | pci_msi_enable = 0; | ||
1163 | } | ||
1164 | |||
1126 | EXPORT_SYMBOL(pci_enable_msi); | 1165 | EXPORT_SYMBOL(pci_enable_msi); |
1127 | EXPORT_SYMBOL(pci_disable_msi); | 1166 | EXPORT_SYMBOL(pci_disable_msi); |
1128 | EXPORT_SYMBOL(pci_enable_msix); | 1167 | EXPORT_SYMBOL(pci_enable_msix); |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 0aa14c92b570..f22f69ac6445 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -53,11 +53,10 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) | |||
53 | if (fields < 0) | 53 | if (fields < 0) |
54 | return -EINVAL; | 54 | return -EINVAL; |
55 | 55 | ||
56 | dynid = kmalloc(sizeof(*dynid), GFP_KERNEL); | 56 | dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); |
57 | if (!dynid) | 57 | if (!dynid) |
58 | return -ENOMEM; | 58 | return -ENOMEM; |
59 | 59 | ||
60 | memset(dynid, 0, sizeof(*dynid)); | ||
61 | INIT_LIST_HEAD(&dynid->node); | 60 | INIT_LIST_HEAD(&dynid->node); |
62 | dynid->id.vendor = vendor; | 61 | dynid->id.vendor = vendor; |
63 | dynid->id.device = device; | 62 | dynid->id.device = device; |
@@ -380,14 +379,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner) | |||
380 | /* initialize common driver fields */ | 379 | /* initialize common driver fields */ |
381 | drv->driver.name = drv->name; | 380 | drv->driver.name = drv->name; |
382 | drv->driver.bus = &pci_bus_type; | 381 | drv->driver.bus = &pci_bus_type; |
383 | /* FIXME, once all of the existing PCI drivers have been fixed to set | ||
384 | * the pci shutdown function, this test can go away. */ | ||
385 | if (!drv->driver.shutdown) | ||
386 | drv->driver.shutdown = pci_device_shutdown; | ||
387 | else | ||
388 | printk(KERN_WARNING "Warning: PCI driver %s has a struct " | ||
389 | "device_driver shutdown method, please update!\n", | ||
390 | drv->name); | ||
391 | drv->driver.owner = owner; | 382 | drv->driver.owner = owner; |
392 | drv->driver.kobj.ktype = &pci_driver_kobj_type; | 383 | drv->driver.kobj.ktype = &pci_driver_kobj_type; |
393 | 384 | ||
@@ -514,6 +505,7 @@ struct bus_type pci_bus_type = { | |||
514 | .probe = pci_device_probe, | 505 | .probe = pci_device_probe, |
515 | .remove = pci_device_remove, | 506 | .remove = pci_device_remove, |
516 | .suspend = pci_device_suspend, | 507 | .suspend = pci_device_suspend, |
508 | .shutdown = pci_device_shutdown, | ||
517 | .resume = pci_device_resume, | 509 | .resume = pci_device_resume, |
518 | .dev_attrs = pci_dev_attrs, | 510 | .dev_attrs = pci_dev_attrs, |
519 | }; | 511 | }; |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 965a5934623a..56ac2bc003c7 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -501,9 +501,8 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
501 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { | 501 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { |
502 | struct bin_attribute *rom_attr; | 502 | struct bin_attribute *rom_attr; |
503 | 503 | ||
504 | rom_attr = kmalloc(sizeof(*rom_attr), GFP_ATOMIC); | 504 | rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); |
505 | if (rom_attr) { | 505 | if (rom_attr) { |
506 | memset(rom_attr, 0x00, sizeof(*rom_attr)); | ||
507 | pdev->rom_attr = rom_attr; | 506 | pdev->rom_attr = rom_attr; |
508 | rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); | 507 | rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); |
509 | rom_attr->attr.name = "rom"; | 508 | rom_attr->attr.name = "rom"; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d2d187916643..bea1ad1ad5ba 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ | 19 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ |
20 | #include "pci.h" | 20 | #include "pci.h" |
21 | 21 | ||
22 | #if 0 | ||
23 | 22 | ||
24 | /** | 23 | /** |
25 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children | 24 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children |
@@ -34,7 +33,7 @@ pci_bus_max_busnr(struct pci_bus* bus) | |||
34 | struct list_head *tmp; | 33 | struct list_head *tmp; |
35 | unsigned char max, n; | 34 | unsigned char max, n; |
36 | 35 | ||
37 | max = bus->number; | 36 | max = bus->subordinate; |
38 | list_for_each(tmp, &bus->children) { | 37 | list_for_each(tmp, &bus->children) { |
39 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | 38 | n = pci_bus_max_busnr(pci_bus_b(tmp)); |
40 | if(n > max) | 39 | if(n > max) |
@@ -42,7 +41,9 @@ pci_bus_max_busnr(struct pci_bus* bus) | |||
42 | } | 41 | } |
43 | return max; | 42 | return max; |
44 | } | 43 | } |
44 | EXPORT_SYMBOL_GPL(pci_bus_max_busnr); | ||
45 | 45 | ||
46 | #if 0 | ||
46 | /** | 47 | /** |
47 | * pci_max_busnr - returns maximum PCI bus number | 48 | * pci_max_busnr - returns maximum PCI bus number |
48 | * | 49 | * |
@@ -495,9 +496,8 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) | |||
495 | int | 496 | int |
496 | pci_enable_device(struct pci_dev *dev) | 497 | pci_enable_device(struct pci_dev *dev) |
497 | { | 498 | { |
498 | int err; | 499 | int err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1); |
499 | 500 | if (err) | |
500 | if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1))) | ||
501 | return err; | 501 | return err; |
502 | pci_fixup_device(pci_fixup_enable, dev); | 502 | pci_fixup_device(pci_fixup_enable, dev); |
503 | dev->is_enabled = 1; | 503 | dev->is_enabled = 1; |
@@ -639,7 +639,7 @@ void pci_release_region(struct pci_dev *pdev, int bar) | |||
639 | * Returns 0 on success, or %EBUSY on error. A warning | 639 | * Returns 0 on success, or %EBUSY on error. A warning |
640 | * message is also printed on failure. | 640 | * message is also printed on failure. |
641 | */ | 641 | */ |
642 | int pci_request_region(struct pci_dev *pdev, int bar, char *res_name) | 642 | int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) |
643 | { | 643 | { |
644 | if (pci_resource_len(pdev, bar) == 0) | 644 | if (pci_resource_len(pdev, bar) == 0) |
645 | return 0; | 645 | return 0; |
@@ -697,7 +697,7 @@ void pci_release_regions(struct pci_dev *pdev) | |||
697 | * Returns 0 on success, or %EBUSY on error. A warning | 697 | * Returns 0 on success, or %EBUSY on error. A warning |
698 | * message is also printed on failure. | 698 | * message is also printed on failure. |
699 | */ | 699 | */ |
700 | int pci_request_regions(struct pci_dev *pdev, char *res_name) | 700 | int pci_request_regions(struct pci_dev *pdev, const char *res_name) |
701 | { | 701 | { |
702 | int i; | 702 | int i; |
703 | 703 | ||
@@ -900,8 +900,12 @@ static int __devinit pci_setup(char *str) | |||
900 | if (k) | 900 | if (k) |
901 | *k++ = 0; | 901 | *k++ = 0; |
902 | if (*str && (str = pcibios_setup(str)) && *str) { | 902 | if (*str && (str = pcibios_setup(str)) && *str) { |
903 | /* PCI layer options should be handled here */ | 903 | if (!strcmp(str, "nomsi")) { |
904 | printk(KERN_ERR "PCI: Unknown option `%s'\n", str); | 904 | pci_no_msi(); |
905 | } else { | ||
906 | printk(KERN_ERR "PCI: Unknown option `%s'\n", | ||
907 | str); | ||
908 | } | ||
905 | } | 909 | } |
906 | str = k; | 910 | str = k; |
907 | } | 911 | } |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index a6dfee2f6d2b..8f3fb47ea671 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -50,8 +50,10 @@ extern int pci_msi_quirk; | |||
50 | 50 | ||
51 | #ifdef CONFIG_PCI_MSI | 51 | #ifdef CONFIG_PCI_MSI |
52 | void disable_msi_mode(struct pci_dev *dev, int pos, int type); | 52 | void disable_msi_mode(struct pci_dev *dev, int pos, int type); |
53 | void pci_no_msi(void); | ||
53 | #else | 54 | #else |
54 | static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { } | 55 | static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { } |
56 | static inline void pci_no_msi(void) { } | ||
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | extern int pcie_mch_quirk; | 59 | extern int pcie_mch_quirk; |
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index a63bd8f72601..1d317d22ee89 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | struct pcie_port_device_ext { | 30 | struct pcie_port_device_ext { |
31 | int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */ | 31 | int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */ |
32 | unsigned int saved_msi_config_space[5]; | ||
33 | }; | 32 | }; |
34 | 33 | ||
35 | extern struct bus_type pcie_port_bus_type; | 34 | extern struct bus_type pcie_port_bus_type; |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index e4e5f1e8d816..55c662267868 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -248,11 +248,10 @@ static struct pcie_device* alloc_pcie_device(struct pci_dev *parent, | |||
248 | { | 248 | { |
249 | struct pcie_device *device; | 249 | struct pcie_device *device; |
250 | 250 | ||
251 | device = kmalloc(sizeof(struct pcie_device), GFP_KERNEL); | 251 | device = kzalloc(sizeof(struct pcie_device), GFP_KERNEL); |
252 | if (!device) | 252 | if (!device) |
253 | return NULL; | 253 | return NULL; |
254 | 254 | ||
255 | memset(device, 0, sizeof(struct pcie_device)); | ||
256 | pcie_device_init(parent, device, port_type, service_type, irq,irq_mode); | 255 | pcie_device_init(parent, device, port_type, service_type, irq,irq_mode); |
257 | printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id); | 256 | printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id); |
258 | return device; | 257 | return device; |
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 02260141dc81..50bfc1b2f3bf 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c | |||
@@ -30,75 +30,16 @@ MODULE_LICENSE("GPL"); | |||
30 | /* global data */ | 30 | /* global data */ |
31 | static const char device_name[] = "pcieport-driver"; | 31 | static const char device_name[] = "pcieport-driver"; |
32 | 32 | ||
33 | static void pci_save_msi_state(struct pci_dev *dev) | 33 | static int pcie_portdrv_save_config(struct pci_dev *dev) |
34 | { | 34 | { |
35 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | 35 | return pci_save_state(dev); |
36 | int i = 0, pos; | ||
37 | u16 control; | ||
38 | |||
39 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0) | ||
40 | return; | ||
41 | |||
42 | pci_read_config_dword(dev, pos, &p_ext->saved_msi_config_space[i++]); | ||
43 | control = p_ext->saved_msi_config_space[0] >> 16; | ||
44 | pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_LO, | ||
45 | &p_ext->saved_msi_config_space[i++]); | ||
46 | if (control & PCI_MSI_FLAGS_64BIT) { | ||
47 | pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_HI, | ||
48 | &p_ext->saved_msi_config_space[i++]); | ||
49 | pci_read_config_dword(dev, pos + PCI_MSI_DATA_64, | ||
50 | &p_ext->saved_msi_config_space[i++]); | ||
51 | } else | ||
52 | pci_read_config_dword(dev, pos + PCI_MSI_DATA_32, | ||
53 | &p_ext->saved_msi_config_space[i++]); | ||
54 | if (control & PCI_MSI_FLAGS_MASKBIT) | ||
55 | pci_read_config_dword(dev, pos + PCI_MSI_MASK_BIT, | ||
56 | &p_ext->saved_msi_config_space[i++]); | ||
57 | } | ||
58 | |||
59 | static void pci_restore_msi_state(struct pci_dev *dev) | ||
60 | { | ||
61 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | ||
62 | int i = 0, pos; | ||
63 | u16 control; | ||
64 | |||
65 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0) | ||
66 | return; | ||
67 | |||
68 | control = p_ext->saved_msi_config_space[i++] >> 16; | ||
69 | pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); | ||
70 | pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_LO, | ||
71 | p_ext->saved_msi_config_space[i++]); | ||
72 | if (control & PCI_MSI_FLAGS_64BIT) { | ||
73 | pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_HI, | ||
74 | p_ext->saved_msi_config_space[i++]); | ||
75 | pci_write_config_dword(dev, pos + PCI_MSI_DATA_64, | ||
76 | p_ext->saved_msi_config_space[i++]); | ||
77 | } else | ||
78 | pci_write_config_dword(dev, pos + PCI_MSI_DATA_32, | ||
79 | p_ext->saved_msi_config_space[i++]); | ||
80 | if (control & PCI_MSI_FLAGS_MASKBIT) | ||
81 | pci_write_config_dword(dev, pos + PCI_MSI_MASK_BIT, | ||
82 | p_ext->saved_msi_config_space[i++]); | ||
83 | } | ||
84 | |||
85 | static void pcie_portdrv_save_config(struct pci_dev *dev) | ||
86 | { | ||
87 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | ||
88 | |||
89 | pci_save_state(dev); | ||
90 | if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE) | ||
91 | pci_save_msi_state(dev); | ||
92 | } | 36 | } |
93 | 37 | ||
94 | static int pcie_portdrv_restore_config(struct pci_dev *dev) | 38 | static int pcie_portdrv_restore_config(struct pci_dev *dev) |
95 | { | 39 | { |
96 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | ||
97 | int retval; | 40 | int retval; |
98 | 41 | ||
99 | pci_restore_state(dev); | 42 | pci_restore_state(dev); |
100 | if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE) | ||
101 | pci_restore_msi_state(dev); | ||
102 | retval = pci_enable_device(dev); | 43 | retval = pci_enable_device(dev); |
103 | if (retval) | 44 | if (retval) |
104 | return retval; | 45 | return retval; |
@@ -149,7 +90,8 @@ static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state) | |||
149 | { | 90 | { |
150 | int ret = pcie_port_device_suspend(dev, state); | 91 | int ret = pcie_port_device_suspend(dev, state); |
151 | 92 | ||
152 | pcie_portdrv_save_config(dev); | 93 | if (!ret) |
94 | ret = pcie_portdrv_save_config(dev); | ||
153 | return ret; | 95 | return ret; |
154 | } | 96 | } |
155 | 97 | ||
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index adfad4fd6a13..a10ed9dab2c2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -33,10 +33,9 @@ LIST_HEAD(pci_devices); | |||
33 | */ | 33 | */ |
34 | static void pci_create_legacy_files(struct pci_bus *b) | 34 | static void pci_create_legacy_files(struct pci_bus *b) |
35 | { | 35 | { |
36 | b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2, | 36 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, |
37 | GFP_ATOMIC); | 37 | GFP_ATOMIC); |
38 | if (b->legacy_io) { | 38 | if (b->legacy_io) { |
39 | memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2); | ||
40 | b->legacy_io->attr.name = "legacy_io"; | 39 | b->legacy_io->attr.name = "legacy_io"; |
41 | b->legacy_io->size = 0xffff; | 40 | b->legacy_io->size = 0xffff; |
42 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | 41 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; |
@@ -320,9 +319,8 @@ static struct pci_bus * __devinit pci_alloc_bus(void) | |||
320 | { | 319 | { |
321 | struct pci_bus *b; | 320 | struct pci_bus *b; |
322 | 321 | ||
323 | b = kmalloc(sizeof(*b), GFP_KERNEL); | 322 | b = kzalloc(sizeof(*b), GFP_KERNEL); |
324 | if (b) { | 323 | if (b) { |
325 | memset(b, 0, sizeof(*b)); | ||
326 | INIT_LIST_HEAD(&b->node); | 324 | INIT_LIST_HEAD(&b->node); |
327 | INIT_LIST_HEAD(&b->children); | 325 | INIT_LIST_HEAD(&b->children); |
328 | INIT_LIST_HEAD(&b->devices); | 326 | INIT_LIST_HEAD(&b->devices); |
@@ -347,6 +345,7 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr) | |||
347 | child->parent = parent; | 345 | child->parent = parent; |
348 | child->ops = parent->ops; | 346 | child->ops = parent->ops; |
349 | child->sysdata = parent->sysdata; | 347 | child->sysdata = parent->sysdata; |
348 | child->bus_flags = parent->bus_flags; | ||
350 | child->bridge = get_device(&bridge->dev); | 349 | child->bridge = get_device(&bridge->dev); |
351 | 350 | ||
352 | child->class_dev.class = &pcibus_class; | 351 | child->class_dev.class = &pcibus_class; |
@@ -456,7 +455,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
456 | * pass and just note the configuration. | 455 | * pass and just note the configuration. |
457 | */ | 456 | */ |
458 | if (pass) | 457 | if (pass) |
459 | return max; | 458 | goto out; |
460 | busnr = (buses >> 8) & 0xFF; | 459 | busnr = (buses >> 8) & 0xFF; |
461 | 460 | ||
462 | /* | 461 | /* |
@@ -466,12 +465,12 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
466 | if (pci_find_bus(pci_domain_nr(bus), busnr)) { | 465 | if (pci_find_bus(pci_domain_nr(bus), busnr)) { |
467 | printk(KERN_INFO "PCI: Bus %04x:%02x already known\n", | 466 | printk(KERN_INFO "PCI: Bus %04x:%02x already known\n", |
468 | pci_domain_nr(bus), busnr); | 467 | pci_domain_nr(bus), busnr); |
469 | return max; | 468 | goto out; |
470 | } | 469 | } |
471 | 470 | ||
472 | child = pci_add_new_bus(bus, dev, busnr); | 471 | child = pci_add_new_bus(bus, dev, busnr); |
473 | if (!child) | 472 | if (!child) |
474 | return max; | 473 | goto out; |
475 | child->primary = buses & 0xFF; | 474 | child->primary = buses & 0xFF; |
476 | child->subordinate = (buses >> 16) & 0xFF; | 475 | child->subordinate = (buses >> 16) & 0xFF; |
477 | child->bridge_ctl = bctl; | 476 | child->bridge_ctl = bctl; |
@@ -496,7 +495,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
496 | bus ranges. */ | 495 | bus ranges. */ |
497 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, | 496 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, |
498 | buses & ~0xffffff); | 497 | buses & ~0xffffff); |
499 | return max; | 498 | goto out; |
500 | } | 499 | } |
501 | 500 | ||
502 | /* Clear errors */ | 501 | /* Clear errors */ |
@@ -505,7 +504,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
505 | /* Prevent assigning a bus number that already exists. | 504 | /* Prevent assigning a bus number that already exists. |
506 | * This can happen when a bridge is hot-plugged */ | 505 | * This can happen when a bridge is hot-plugged */ |
507 | if (pci_find_bus(pci_domain_nr(bus), max+1)) | 506 | if (pci_find_bus(pci_domain_nr(bus), max+1)) |
508 | return max; | 507 | goto out; |
509 | child = pci_add_new_bus(bus, dev, ++max); | 508 | child = pci_add_new_bus(bus, dev, ++max); |
510 | buses = (buses & 0xff000000) | 509 | buses = (buses & 0xff000000) |
511 | | ((unsigned int)(child->primary) << 0) | 510 | | ((unsigned int)(child->primary) << 0) |
@@ -537,6 +536,11 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
537 | pci_fixup_parent_subordinate_busnr(child, max); | 536 | pci_fixup_parent_subordinate_busnr(child, max); |
538 | /* Now we can scan all subordinate buses... */ | 537 | /* Now we can scan all subordinate buses... */ |
539 | max = pci_scan_child_bus(child); | 538 | max = pci_scan_child_bus(child); |
539 | /* | ||
540 | * now fix it up again since we have found | ||
541 | * the real value of max. | ||
542 | */ | ||
543 | pci_fixup_parent_subordinate_busnr(child, max); | ||
540 | } else { | 544 | } else { |
541 | /* | 545 | /* |
542 | * For CardBus bridges, we leave 4 bus numbers | 546 | * For CardBus bridges, we leave 4 bus numbers |
@@ -576,8 +580,6 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
576 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); | 580 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); |
577 | } | 581 | } |
578 | 582 | ||
579 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); | ||
580 | |||
581 | sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); | 583 | sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); |
582 | 584 | ||
583 | while (bus->parent) { | 585 | while (bus->parent) { |
@@ -585,17 +587,22 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
585 | (child->number > bus->subordinate) || | 587 | (child->number > bus->subordinate) || |
586 | (child->number < bus->number) || | 588 | (child->number < bus->number) || |
587 | (child->subordinate < bus->number)) { | 589 | (child->subordinate < bus->number)) { |
588 | printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) may be " | 590 | printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) is " |
589 | "hidden behind%s bridge #%02x (-#%02x)%s\n", | 591 | "hidden behind%s bridge #%02x (-#%02x)%s\n", |
590 | child->number, child->subordinate, | 592 | child->number, child->subordinate, |
591 | bus->self->transparent ? " transparent" : " ", | 593 | bus->self->transparent ? " transparent" : " ", |
592 | bus->number, bus->subordinate, | 594 | bus->number, bus->subordinate, |
593 | pcibios_assign_all_busses() ? " " : | 595 | pcibios_assign_all_busses() ? " " : |
594 | " (try 'pci=assign-busses')"); | 596 | " (try 'pci=assign-busses')"); |
597 | printk(KERN_WARNING "Please report the result to " | ||
598 | "linux-kernel to fix this permanently\n"); | ||
595 | } | 599 | } |
596 | bus = bus->parent; | 600 | bus = bus->parent; |
597 | } | 601 | } |
598 | 602 | ||
603 | out: | ||
604 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); | ||
605 | |||
599 | return max; | 606 | return max; |
600 | } | 607 | } |
601 | 608 | ||
@@ -788,11 +795,10 @@ pci_scan_device(struct pci_bus *bus, int devfn) | |||
788 | if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) | 795 | if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) |
789 | return NULL; | 796 | return NULL; |
790 | 797 | ||
791 | dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); | 798 | dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); |
792 | if (!dev) | 799 | if (!dev) |
793 | return NULL; | 800 | return NULL; |
794 | 801 | ||
795 | memset(dev, 0, sizeof(struct pci_dev)); | ||
796 | dev->bus = bus; | 802 | dev->bus = bus; |
797 | dev->sysdata = bus->sysdata; | 803 | dev->sysdata = bus->sysdata; |
798 | dev->dev.parent = bus->bridge; | 804 | dev->dev.parent = bus->bridge; |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 92a885760832..54b2ebc9c91a 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -458,131 +458,6 @@ int pci_proc_detach_bus(struct pci_bus* bus) | |||
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
460 | 460 | ||
461 | #ifdef CONFIG_PCI_LEGACY_PROC | ||
462 | |||
463 | /* | ||
464 | * Backward compatible /proc/pci interface. | ||
465 | */ | ||
466 | |||
467 | /* | ||
468 | * Convert some of the configuration space registers of the device at | ||
469 | * address (bus,devfn) into a string (possibly several lines each). | ||
470 | * The configuration string is stored starting at buf[len]. If the | ||
471 | * string would exceed the size of the buffer (SIZE), 0 is returned. | ||
472 | */ | ||
473 | static int show_dev_config(struct seq_file *m, void *v) | ||
474 | { | ||
475 | struct pci_dev *dev = v; | ||
476 | struct pci_dev *first_dev; | ||
477 | struct pci_driver *drv; | ||
478 | u32 class_rev; | ||
479 | unsigned char latency, min_gnt, max_lat; | ||
480 | int reg; | ||
481 | |||
482 | first_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
483 | if (dev == first_dev) | ||
484 | seq_puts(m, "PCI devices found:\n"); | ||
485 | pci_dev_put(first_dev); | ||
486 | |||
487 | drv = pci_dev_driver(dev); | ||
488 | |||
489 | pci_user_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); | ||
490 | pci_user_read_config_byte (dev, PCI_LATENCY_TIMER, &latency); | ||
491 | pci_user_read_config_byte (dev, PCI_MIN_GNT, &min_gnt); | ||
492 | pci_user_read_config_byte (dev, PCI_MAX_LAT, &max_lat); | ||
493 | seq_printf(m, " Bus %2d, device %3d, function %2d:\n", | ||
494 | dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); | ||
495 | seq_printf(m, " Class %04x", class_rev >> 16); | ||
496 | seq_printf(m, ": PCI device %04x:%04x", dev->vendor, dev->device); | ||
497 | seq_printf(m, " (rev %d).\n", class_rev & 0xff); | ||
498 | |||
499 | if (dev->irq) | ||
500 | seq_printf(m, " IRQ %d.\n", dev->irq); | ||
501 | |||
502 | if (latency || min_gnt || max_lat) { | ||
503 | seq_printf(m, " Master Capable. "); | ||
504 | if (latency) | ||
505 | seq_printf(m, "Latency=%d. ", latency); | ||
506 | else | ||
507 | seq_puts(m, "No bursts. "); | ||
508 | if (min_gnt) | ||
509 | seq_printf(m, "Min Gnt=%d.", min_gnt); | ||
510 | if (max_lat) | ||
511 | seq_printf(m, "Max Lat=%d.", max_lat); | ||
512 | seq_putc(m, '\n'); | ||
513 | } | ||
514 | |||
515 | for (reg = 0; reg < 6; reg++) { | ||
516 | struct resource *res = dev->resource + reg; | ||
517 | unsigned long base, end, flags; | ||
518 | |||
519 | base = res->start; | ||
520 | end = res->end; | ||
521 | flags = res->flags; | ||
522 | if (!end) | ||
523 | continue; | ||
524 | |||
525 | if (flags & PCI_BASE_ADDRESS_SPACE_IO) { | ||
526 | seq_printf(m, " I/O at 0x%lx [0x%lx].\n", | ||
527 | base, end); | ||
528 | } else { | ||
529 | const char *pref, *type = "unknown"; | ||
530 | |||
531 | if (flags & PCI_BASE_ADDRESS_MEM_PREFETCH) | ||
532 | pref = "P"; | ||
533 | else | ||
534 | pref = "Non-p"; | ||
535 | switch (flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK) { | ||
536 | case PCI_BASE_ADDRESS_MEM_TYPE_32: | ||
537 | type = "32 bit"; break; | ||
538 | case PCI_BASE_ADDRESS_MEM_TYPE_1M: | ||
539 | type = "20 bit"; break; | ||
540 | case PCI_BASE_ADDRESS_MEM_TYPE_64: | ||
541 | type = "64 bit"; break; | ||
542 | } | ||
543 | seq_printf(m, " %srefetchable %s memory at " | ||
544 | "0x%lx [0x%lx].\n", pref, type, | ||
545 | base, | ||
546 | end); | ||
547 | } | ||
548 | } | ||
549 | return 0; | ||
550 | } | ||
551 | |||
552 | static struct seq_operations proc_pci_op = { | ||
553 | .start = pci_seq_start, | ||
554 | .next = pci_seq_next, | ||
555 | .stop = pci_seq_stop, | ||
556 | .show = show_dev_config | ||
557 | }; | ||
558 | |||
559 | static int proc_pci_open(struct inode *inode, struct file *file) | ||
560 | { | ||
561 | return seq_open(file, &proc_pci_op); | ||
562 | } | ||
563 | static struct file_operations proc_pci_operations = { | ||
564 | .open = proc_pci_open, | ||
565 | .read = seq_read, | ||
566 | .llseek = seq_lseek, | ||
567 | .release = seq_release, | ||
568 | }; | ||
569 | |||
570 | static void legacy_proc_init(void) | ||
571 | { | ||
572 | struct proc_dir_entry * entry = create_proc_entry("pci", 0, NULL); | ||
573 | if (entry) | ||
574 | entry->proc_fops = &proc_pci_operations; | ||
575 | } | ||
576 | |||
577 | #else | ||
578 | |||
579 | static void legacy_proc_init(void) | ||
580 | { | ||
581 | |||
582 | } | ||
583 | |||
584 | #endif /* CONFIG_PCI_LEGACY_PROC */ | ||
585 | |||
586 | static int proc_bus_pci_dev_open(struct inode *inode, struct file *file) | 461 | static int proc_bus_pci_dev_open(struct inode *inode, struct file *file) |
587 | { | 462 | { |
588 | return seq_open(file, &proc_bus_pci_devices_op); | 463 | return seq_open(file, &proc_bus_pci_devices_op); |
@@ -606,7 +481,6 @@ static int __init pci_proc_init(void) | |||
606 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 481 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
607 | pci_proc_attach_device(dev); | 482 | pci_proc_attach_device(dev); |
608 | } | 483 | } |
609 | legacy_proc_init(); | ||
610 | return 0; | 484 | return 0; |
611 | } | 485 | } |
612 | 486 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dda6099903c1..4970f47be72c 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -575,8 +575,11 @@ static void __init quirk_amd_8131_ioapic(struct pci_dev *dev) | |||
575 | { | 575 | { |
576 | unsigned char revid, tmp; | 576 | unsigned char revid, tmp; |
577 | 577 | ||
578 | pci_msi_quirk = 1; | 578 | if (dev->subordinate) { |
579 | printk(KERN_WARNING "PCI: MSI quirk detected. pci_msi_quirk set.\n"); | 579 | printk(KERN_WARNING "PCI: MSI quirk detected. " |
580 | "PCI_BUS_FLAGS_NO_MSI set for subordinate bus.\n"); | ||
581 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | ||
582 | } | ||
580 | 583 | ||
581 | if (nr_ioapics == 0) | 584 | if (nr_ioapics == 0) |
582 | return; | 585 | return; |
@@ -934,6 +937,12 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) | |||
934 | case 0x12bd: /* HP D530 */ | 937 | case 0x12bd: /* HP D530 */ |
935 | asus_hides_smbus = 1; | 938 | asus_hides_smbus = 1; |
936 | } | 939 | } |
940 | if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) { | ||
941 | switch (dev->subsystem_device) { | ||
942 | case 0x099c: /* HP Compaq nx6110 */ | ||
943 | asus_hides_smbus = 1; | ||
944 | } | ||
945 | } | ||
937 | } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) { | 946 | } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) { |
938 | if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB) | 947 | if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB) |
939 | switch(dev->subsystem_device) { | 948 | switch(dev->subsystem_device) { |
@@ -1068,6 +1077,37 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_651, quirk_sis_96x_ | |||
1068 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_735, quirk_sis_96x_compatible ); | 1077 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_735, quirk_sis_96x_compatible ); |
1069 | 1078 | ||
1070 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503 ); | 1079 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503 ); |
1080 | /* | ||
1081 | * On ASUS A8V and A8V Deluxe boards, the onboard AC97 audio controller | ||
1082 | * and MC97 modem controller are disabled when a second PCI soundcard is | ||
1083 | * present. This patch, tweaking the VT8237 ISA bridge, enables them. | ||
1084 | * -- bjd | ||
1085 | */ | ||
1086 | static void __init asus_hides_ac97_lpc(struct pci_dev *dev) | ||
1087 | { | ||
1088 | u8 val; | ||
1089 | int asus_hides_ac97 = 0; | ||
1090 | |||
1091 | if (likely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) { | ||
1092 | if (dev->device == PCI_DEVICE_ID_VIA_8237) | ||
1093 | asus_hides_ac97 = 1; | ||
1094 | } | ||
1095 | |||
1096 | if (!asus_hides_ac97) | ||
1097 | return; | ||
1098 | |||
1099 | pci_read_config_byte(dev, 0x50, &val); | ||
1100 | if (val & 0xc0) { | ||
1101 | pci_write_config_byte(dev, 0x50, val & (~0xc0)); | ||
1102 | pci_read_config_byte(dev, 0x50, &val); | ||
1103 | if (val & 0xc0) | ||
1104 | printk(KERN_INFO "PCI: onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", val); | ||
1105 | else | ||
1106 | printk(KERN_INFO "PCI: enabled onboard AC97/MC97 devices\n"); | ||
1107 | } | ||
1108 | } | ||
1109 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc ); | ||
1110 | |||
1071 | 1111 | ||
1072 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus ); | 1112 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus ); |
1073 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus ); | 1113 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus ); |
@@ -1242,6 +1282,33 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1, quirk_pc | |||
1242 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_pcie_pxh); | 1282 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_pcie_pxh); |
1243 | 1283 | ||
1244 | 1284 | ||
1285 | /* | ||
1286 | * Fixup the cardbus bridges on the IBM Dock II docking station | ||
1287 | */ | ||
1288 | static void __devinit quirk_ibm_dock2_cardbus(struct pci_dev *dev) | ||
1289 | { | ||
1290 | u32 val; | ||
1291 | |||
1292 | /* | ||
1293 | * tie the 2 interrupt pins to INTA, and configure the | ||
1294 | * multifunction routing register to handle this. | ||
1295 | */ | ||
1296 | if ((dev->subsystem_vendor == PCI_VENDOR_ID_IBM) && | ||
1297 | (dev->subsystem_device == 0x0148)) { | ||
1298 | printk(KERN_INFO "PCI: Found IBM Dock II Cardbus Bridge " | ||
1299 | "applying quirk\n"); | ||
1300 | pci_read_config_dword(dev, 0x8c, &val); | ||
1301 | val = ((val & 0xffffff00) | 0x1002); | ||
1302 | pci_write_config_dword(dev, 0x8c, val); | ||
1303 | pci_read_config_dword(dev, 0x80, &val); | ||
1304 | val = ((val & 0x00ffff00) | 0x2864c077); | ||
1305 | pci_write_config_dword(dev, 0x80, val); | ||
1306 | } | ||
1307 | } | ||
1308 | |||
1309 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, | ||
1310 | quirk_ibm_dock2_cardbus); | ||
1311 | |||
1245 | static void __devinit quirk_netmos(struct pci_dev *dev) | 1312 | static void __devinit quirk_netmos(struct pci_dev *dev) |
1246 | { | 1313 | { |
1247 | unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; | 1314 | unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; |
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 05fa91a31c62..ce7dd6e7be60 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -246,9 +246,9 @@ pci_get_subsys(unsigned int vendor, unsigned int device, | |||
246 | } | 246 | } |
247 | dev = NULL; | 247 | dev = NULL; |
248 | exit: | 248 | exit: |
249 | pci_dev_put(from); | ||
250 | dev = pci_dev_get(dev); | 249 | dev = pci_dev_get(dev); |
251 | spin_unlock(&pci_bus_lock); | 250 | spin_unlock(&pci_bus_lock); |
251 | pci_dev_put(from); | ||
252 | return dev; | 252 | return dev; |
253 | } | 253 | } |
254 | 254 | ||
@@ -339,9 +339,9 @@ struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) | |||
339 | } | 339 | } |
340 | dev = NULL; | 340 | dev = NULL; |
341 | exit: | 341 | exit: |
342 | pci_dev_put(from); | ||
343 | dev = pci_dev_get(dev); | 342 | dev = pci_dev_get(dev); |
344 | spin_unlock(&pci_bus_lock); | 343 | spin_unlock(&pci_bus_lock); |
344 | pci_dev_put(from); | ||
345 | return dev; | 345 | return dev; |
346 | } | 346 | } |
347 | 347 | ||
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6 index 97bd4743b461..5d73eaa1971f 100644 --- a/fs/xfs/Makefile-linux-2.6 +++ b/fs/xfs/Makefile-linux-2.6 | |||
@@ -1,33 +1,19 @@ | |||
1 | # | 1 | # |
2 | # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | # Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | # All Rights Reserved. | ||
3 | # | 4 | # |
4 | # This program is free software; you can redistribute it and/or modify it | 5 | # This program is free software; you can redistribute it and/or |
5 | # under the terms of version 2 of the GNU General Public License as | 6 | # modify it under the terms of the GNU General Public License as |
6 | # published by the Free Software Foundation. | 7 | # published by the Free Software Foundation. |
7 | # | 8 | # |
8 | # This program is distributed in the hope that it would be useful, but | 9 | # This program is distributed in the hope that it would be useful, |
9 | # WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | ||
11 | # | 13 | # |
12 | # Further, this software is distributed without any warranty that it is | 14 | # You should have received a copy of the GNU General Public License |
13 | # free of the rightful claim of any third person regarding infringement | 15 | # along with this program; if not, write the Free Software Foundation, |
14 | # or the like. Any license provided herein, whether implied or | 16 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | # otherwise, applies only to this software file. Patent licenses, if | ||
16 | # any, provided herein do not apply to combinations of this program with | ||
17 | # other software, or any other product whatsoever. | ||
18 | # | ||
19 | # You should have received a copy of the GNU General Public License along | ||
20 | # with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | # Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | # | ||
23 | # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | # Mountain View, CA 94043, or: | ||
25 | # | ||
26 | # http://www.sgi.com | ||
27 | # | ||
28 | # For further information regarding this notice, see: | ||
29 | # | ||
30 | # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | # | 17 | # |
32 | 18 | ||
33 | EXTRA_CFLAGS += -Ifs/xfs -Ifs/xfs/linux-2.6 -funsigned-char | 19 | EXTRA_CFLAGS += -Ifs/xfs -Ifs/xfs/linux-2.6 -funsigned-char |
@@ -36,7 +22,7 @@ XFS_LINUX := linux-2.6 | |||
36 | 22 | ||
37 | ifeq ($(CONFIG_XFS_DEBUG),y) | 23 | ifeq ($(CONFIG_XFS_DEBUG),y) |
38 | EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG | 24 | EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG |
39 | EXTRA_CFLAGS += -DPAGEBUF_LOCK_TRACKING | 25 | EXTRA_CFLAGS += -DXFS_BUF_LOCK_TRACKING |
40 | endif | 26 | endif |
41 | ifeq ($(CONFIG_XFS_TRACE),y) | 27 | ifeq ($(CONFIG_XFS_TRACE),y) |
42 | EXTRA_CFLAGS += -DXFS_ALLOC_TRACE | 28 | EXTRA_CFLAGS += -DXFS_ALLOC_TRACE |
@@ -50,7 +36,7 @@ ifeq ($(CONFIG_XFS_TRACE),y) | |||
50 | EXTRA_CFLAGS += -DXFS_ILOCK_TRACE | 36 | EXTRA_CFLAGS += -DXFS_ILOCK_TRACE |
51 | EXTRA_CFLAGS += -DXFS_LOG_TRACE | 37 | EXTRA_CFLAGS += -DXFS_LOG_TRACE |
52 | EXTRA_CFLAGS += -DXFS_RW_TRACE | 38 | EXTRA_CFLAGS += -DXFS_RW_TRACE |
53 | EXTRA_CFLAGS += -DPAGEBUF_TRACE | 39 | EXTRA_CFLAGS += -DXFS_BUF_TRACE |
54 | EXTRA_CFLAGS += -DXFS_VNODE_TRACE | 40 | EXTRA_CFLAGS += -DXFS_VNODE_TRACE |
55 | endif | 41 | endif |
56 | 42 | ||
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h index c64a29cdfff3..f0268a84e6fd 100644 --- a/fs/xfs/linux-2.6/kmem.h +++ b/fs/xfs/linux-2.6/kmem.h | |||
@@ -23,17 +23,8 @@ | |||
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * memory management routines | 26 | * Process flags handling |
27 | */ | 27 | */ |
28 | #define KM_SLEEP 0x0001u | ||
29 | #define KM_NOSLEEP 0x0002u | ||
30 | #define KM_NOFS 0x0004u | ||
31 | #define KM_MAYFAIL 0x0008u | ||
32 | |||
33 | #define kmem_zone kmem_cache | ||
34 | #define kmem_zone_t struct kmem_cache | ||
35 | |||
36 | typedef unsigned long xfs_pflags_t; | ||
37 | 28 | ||
38 | #define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO) | 29 | #define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO) |
39 | #define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS) | 30 | #define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS) |
@@ -67,74 +58,102 @@ typedef unsigned long xfs_pflags_t; | |||
67 | *(NSTATEP) = *(OSTATEP); \ | 58 | *(NSTATEP) = *(OSTATEP); \ |
68 | } while (0) | 59 | } while (0) |
69 | 60 | ||
70 | static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) | 61 | /* |
62 | * General memory allocation interfaces | ||
63 | */ | ||
64 | |||
65 | #define KM_SLEEP 0x0001u | ||
66 | #define KM_NOSLEEP 0x0002u | ||
67 | #define KM_NOFS 0x0004u | ||
68 | #define KM_MAYFAIL 0x0008u | ||
69 | |||
70 | /* | ||
71 | * We use a special process flag to avoid recursive callbacks into | ||
72 | * the filesystem during transactions. We will also issue our own | ||
73 | * warnings, so we explicitly skip any generic ones (silly of us). | ||
74 | */ | ||
75 | static inline gfp_t | ||
76 | kmem_flags_convert(unsigned int __nocast flags) | ||
71 | { | 77 | { |
72 | gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */ | 78 | gfp_t lflags; |
73 | 79 | ||
74 | #ifdef DEBUG | 80 | BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL)); |
75 | if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { | ||
76 | printk(KERN_WARNING | ||
77 | "XFS: memory allocation with wrong flags (%x)\n", flags); | ||
78 | BUG(); | ||
79 | } | ||
80 | #endif | ||
81 | 81 | ||
82 | if (flags & KM_NOSLEEP) { | 82 | if (flags & KM_NOSLEEP) { |
83 | lflags |= GFP_ATOMIC; | 83 | lflags = GFP_ATOMIC | __GFP_NOWARN; |
84 | } else { | 84 | } else { |
85 | lflags |= GFP_KERNEL; | 85 | lflags = GFP_KERNEL | __GFP_NOWARN; |
86 | |||
87 | /* avoid recusive callbacks to filesystem during transactions */ | ||
88 | if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) | 86 | if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) |
89 | lflags &= ~__GFP_FS; | 87 | lflags &= ~__GFP_FS; |
90 | } | 88 | } |
91 | 89 | return lflags; | |
92 | return lflags; | ||
93 | } | 90 | } |
94 | 91 | ||
95 | static __inline kmem_zone_t * | 92 | extern void *kmem_alloc(size_t, unsigned int __nocast); |
93 | extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); | ||
94 | extern void *kmem_zalloc(size_t, unsigned int __nocast); | ||
95 | extern void kmem_free(void *, size_t); | ||
96 | |||
97 | /* | ||
98 | * Zone interfaces | ||
99 | */ | ||
100 | |||
101 | #define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN | ||
102 | #define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT | ||
103 | #define KM_ZONE_SPREAD 0 | ||
104 | |||
105 | #define kmem_zone kmem_cache | ||
106 | #define kmem_zone_t struct kmem_cache | ||
107 | |||
108 | static inline kmem_zone_t * | ||
96 | kmem_zone_init(int size, char *zone_name) | 109 | kmem_zone_init(int size, char *zone_name) |
97 | { | 110 | { |
98 | return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL); | 111 | return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL); |
99 | } | 112 | } |
100 | 113 | ||
101 | static __inline void | 114 | static inline kmem_zone_t * |
115 | kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, | ||
116 | void (*construct)(void *, kmem_zone_t *, unsigned long)) | ||
117 | { | ||
118 | return kmem_cache_create(zone_name, size, 0, flags, construct, NULL); | ||
119 | } | ||
120 | |||
121 | static inline void | ||
102 | kmem_zone_free(kmem_zone_t *zone, void *ptr) | 122 | kmem_zone_free(kmem_zone_t *zone, void *ptr) |
103 | { | 123 | { |
104 | kmem_cache_free(zone, ptr); | 124 | kmem_cache_free(zone, ptr); |
105 | } | 125 | } |
106 | 126 | ||
107 | static __inline void | 127 | static inline void |
108 | kmem_zone_destroy(kmem_zone_t *zone) | 128 | kmem_zone_destroy(kmem_zone_t *zone) |
109 | { | 129 | { |
110 | if (zone && kmem_cache_destroy(zone)) | 130 | if (zone && kmem_cache_destroy(zone)) |
111 | BUG(); | 131 | BUG(); |
112 | } | 132 | } |
113 | 133 | ||
114 | extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); | ||
115 | extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); | 134 | extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); |
135 | extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); | ||
116 | 136 | ||
117 | extern void *kmem_alloc(size_t, unsigned int __nocast); | 137 | /* |
118 | extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); | 138 | * Low memory cache shrinkers |
119 | extern void *kmem_zalloc(size_t, unsigned int __nocast); | 139 | */ |
120 | extern void kmem_free(void *, size_t); | ||
121 | 140 | ||
122 | typedef struct shrinker *kmem_shaker_t; | 141 | typedef struct shrinker *kmem_shaker_t; |
123 | typedef int (*kmem_shake_func_t)(int, gfp_t); | 142 | typedef int (*kmem_shake_func_t)(int, gfp_t); |
124 | 143 | ||
125 | static __inline kmem_shaker_t | 144 | static inline kmem_shaker_t |
126 | kmem_shake_register(kmem_shake_func_t sfunc) | 145 | kmem_shake_register(kmem_shake_func_t sfunc) |
127 | { | 146 | { |
128 | return set_shrinker(DEFAULT_SEEKS, sfunc); | 147 | return set_shrinker(DEFAULT_SEEKS, sfunc); |
129 | } | 148 | } |
130 | 149 | ||
131 | static __inline void | 150 | static inline void |
132 | kmem_shake_deregister(kmem_shaker_t shrinker) | 151 | kmem_shake_deregister(kmem_shaker_t shrinker) |
133 | { | 152 | { |
134 | remove_shrinker(shrinker); | 153 | remove_shrinker(shrinker); |
135 | } | 154 | } |
136 | 155 | ||
137 | static __inline int | 156 | static inline int |
138 | kmem_shake_allow(gfp_t gfp_mask) | 157 | kmem_shake_allow(gfp_t gfp_mask) |
139 | { | 158 | { |
140 | return (gfp_mask & __GFP_WAIT); | 159 | return (gfp_mask & __GFP_WAIT); |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 74d8be87f983..97fc056130eb 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -43,7 +43,29 @@ | |||
43 | #include <linux/pagevec.h> | 43 | #include <linux/pagevec.h> |
44 | #include <linux/writeback.h> | 44 | #include <linux/writeback.h> |
45 | 45 | ||
46 | STATIC void xfs_count_page_state(struct page *, int *, int *, int *); | 46 | STATIC void |
47 | xfs_count_page_state( | ||
48 | struct page *page, | ||
49 | int *delalloc, | ||
50 | int *unmapped, | ||
51 | int *unwritten) | ||
52 | { | ||
53 | struct buffer_head *bh, *head; | ||
54 | |||
55 | *delalloc = *unmapped = *unwritten = 0; | ||
56 | |||
57 | bh = head = page_buffers(page); | ||
58 | do { | ||
59 | if (buffer_uptodate(bh) && !buffer_mapped(bh)) | ||
60 | (*unmapped) = 1; | ||
61 | else if (buffer_unwritten(bh) && !buffer_delay(bh)) | ||
62 | clear_buffer_unwritten(bh); | ||
63 | else if (buffer_unwritten(bh)) | ||
64 | (*unwritten) = 1; | ||
65 | else if (buffer_delay(bh)) | ||
66 | (*delalloc) = 1; | ||
67 | } while ((bh = bh->b_this_page) != head); | ||
68 | } | ||
47 | 69 | ||
48 | #if defined(XFS_RW_TRACE) | 70 | #if defined(XFS_RW_TRACE) |
49 | void | 71 | void |
@@ -54,7 +76,7 @@ xfs_page_trace( | |||
54 | int mask) | 76 | int mask) |
55 | { | 77 | { |
56 | xfs_inode_t *ip; | 78 | xfs_inode_t *ip; |
57 | vnode_t *vp = LINVFS_GET_VP(inode); | 79 | vnode_t *vp = vn_from_inode(inode); |
58 | loff_t isize = i_size_read(inode); | 80 | loff_t isize = i_size_read(inode); |
59 | loff_t offset = page_offset(page); | 81 | loff_t offset = page_offset(page); |
60 | int delalloc = -1, unmapped = -1, unwritten = -1; | 82 | int delalloc = -1, unmapped = -1, unwritten = -1; |
@@ -81,7 +103,7 @@ xfs_page_trace( | |||
81 | (void *)((unsigned long)delalloc), | 103 | (void *)((unsigned long)delalloc), |
82 | (void *)((unsigned long)unmapped), | 104 | (void *)((unsigned long)unmapped), |
83 | (void *)((unsigned long)unwritten), | 105 | (void *)((unsigned long)unwritten), |
84 | (void *)NULL, | 106 | (void *)((unsigned long)current_pid()), |
85 | (void *)NULL); | 107 | (void *)NULL); |
86 | } | 108 | } |
87 | #else | 109 | #else |
@@ -192,7 +214,7 @@ xfs_alloc_ioend( | |||
192 | ioend->io_uptodate = 1; /* cleared if any I/O fails */ | 214 | ioend->io_uptodate = 1; /* cleared if any I/O fails */ |
193 | ioend->io_list = NULL; | 215 | ioend->io_list = NULL; |
194 | ioend->io_type = type; | 216 | ioend->io_type = type; |
195 | ioend->io_vnode = LINVFS_GET_VP(inode); | 217 | ioend->io_vnode = vn_from_inode(inode); |
196 | ioend->io_buffer_head = NULL; | 218 | ioend->io_buffer_head = NULL; |
197 | ioend->io_buffer_tail = NULL; | 219 | ioend->io_buffer_tail = NULL; |
198 | atomic_inc(&ioend->io_vnode->v_iocount); | 220 | atomic_inc(&ioend->io_vnode->v_iocount); |
@@ -217,7 +239,7 @@ xfs_map_blocks( | |||
217 | xfs_iomap_t *mapp, | 239 | xfs_iomap_t *mapp, |
218 | int flags) | 240 | int flags) |
219 | { | 241 | { |
220 | vnode_t *vp = LINVFS_GET_VP(inode); | 242 | vnode_t *vp = vn_from_inode(inode); |
221 | int error, nmaps = 1; | 243 | int error, nmaps = 1; |
222 | 244 | ||
223 | VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error); | 245 | VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error); |
@@ -462,28 +484,37 @@ xfs_add_to_ioend( | |||
462 | } | 484 | } |
463 | 485 | ||
464 | STATIC void | 486 | STATIC void |
487 | xfs_map_buffer( | ||
488 | struct buffer_head *bh, | ||
489 | xfs_iomap_t *mp, | ||
490 | xfs_off_t offset, | ||
491 | uint block_bits) | ||
492 | { | ||
493 | sector_t bn; | ||
494 | |||
495 | ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL); | ||
496 | |||
497 | bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) + | ||
498 | ((offset - mp->iomap_offset) >> block_bits); | ||
499 | |||
500 | ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME)); | ||
501 | |||
502 | bh->b_blocknr = bn; | ||
503 | set_buffer_mapped(bh); | ||
504 | } | ||
505 | |||
506 | STATIC void | ||
465 | xfs_map_at_offset( | 507 | xfs_map_at_offset( |
466 | struct buffer_head *bh, | 508 | struct buffer_head *bh, |
467 | loff_t offset, | 509 | loff_t offset, |
468 | int block_bits, | 510 | int block_bits, |
469 | xfs_iomap_t *iomapp) | 511 | xfs_iomap_t *iomapp) |
470 | { | 512 | { |
471 | xfs_daddr_t bn; | ||
472 | int sector_shift; | ||
473 | |||
474 | ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE)); | 513 | ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE)); |
475 | ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY)); | 514 | ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY)); |
476 | ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL); | ||
477 | |||
478 | sector_shift = block_bits - BBSHIFT; | ||
479 | bn = (iomapp->iomap_bn >> sector_shift) + | ||
480 | ((offset - iomapp->iomap_offset) >> block_bits); | ||
481 | |||
482 | ASSERT(bn || (iomapp->iomap_flags & IOMAP_REALTIME)); | ||
483 | ASSERT((bn << sector_shift) >= iomapp->iomap_bn); | ||
484 | 515 | ||
485 | lock_buffer(bh); | 516 | lock_buffer(bh); |
486 | bh->b_blocknr = bn; | 517 | xfs_map_buffer(bh, iomapp, offset, block_bits); |
487 | bh->b_bdev = iomapp->iomap_target->bt_bdev; | 518 | bh->b_bdev = iomapp->iomap_target->bt_bdev; |
488 | set_buffer_mapped(bh); | 519 | set_buffer_mapped(bh); |
489 | clear_buffer_delay(bh); | 520 | clear_buffer_delay(bh); |
@@ -616,7 +647,7 @@ xfs_is_delayed_page( | |||
616 | acceptable = (type == IOMAP_UNWRITTEN); | 647 | acceptable = (type == IOMAP_UNWRITTEN); |
617 | else if (buffer_delay(bh)) | 648 | else if (buffer_delay(bh)) |
618 | acceptable = (type == IOMAP_DELAY); | 649 | acceptable = (type == IOMAP_DELAY); |
619 | else if (buffer_mapped(bh)) | 650 | else if (buffer_dirty(bh) && buffer_mapped(bh)) |
620 | acceptable = (type == 0); | 651 | acceptable = (type == 0); |
621 | else | 652 | else |
622 | break; | 653 | break; |
@@ -1040,8 +1071,159 @@ error: | |||
1040 | return err; | 1071 | return err; |
1041 | } | 1072 | } |
1042 | 1073 | ||
1074 | /* | ||
1075 | * writepage: Called from one of two places: | ||
1076 | * | ||
1077 | * 1. we are flushing a delalloc buffer head. | ||
1078 | * | ||
1079 | * 2. we are writing out a dirty page. Typically the page dirty | ||
1080 | * state is cleared before we get here. In this case is it | ||
1081 | * conceivable we have no buffer heads. | ||
1082 | * | ||
1083 | * For delalloc space on the page we need to allocate space and | ||
1084 | * flush it. For unmapped buffer heads on the page we should | ||
1085 | * allocate space if the page is uptodate. For any other dirty | ||
1086 | * buffer heads on the page we should flush them. | ||
1087 | * | ||
1088 | * If we detect that a transaction would be required to flush | ||
1089 | * the page, we have to check the process flags first, if we | ||
1090 | * are already in a transaction or disk I/O during allocations | ||
1091 | * is off, we need to fail the writepage and redirty the page. | ||
1092 | */ | ||
1093 | |||
1094 | STATIC int | ||
1095 | xfs_vm_writepage( | ||
1096 | struct page *page, | ||
1097 | struct writeback_control *wbc) | ||
1098 | { | ||
1099 | int error; | ||
1100 | int need_trans; | ||
1101 | int delalloc, unmapped, unwritten; | ||
1102 | struct inode *inode = page->mapping->host; | ||
1103 | |||
1104 | xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0); | ||
1105 | |||
1106 | /* | ||
1107 | * We need a transaction if: | ||
1108 | * 1. There are delalloc buffers on the page | ||
1109 | * 2. The page is uptodate and we have unmapped buffers | ||
1110 | * 3. The page is uptodate and we have no buffers | ||
1111 | * 4. There are unwritten buffers on the page | ||
1112 | */ | ||
1113 | |||
1114 | if (!page_has_buffers(page)) { | ||
1115 | unmapped = 1; | ||
1116 | need_trans = 1; | ||
1117 | } else { | ||
1118 | xfs_count_page_state(page, &delalloc, &unmapped, &unwritten); | ||
1119 | if (!PageUptodate(page)) | ||
1120 | unmapped = 0; | ||
1121 | need_trans = delalloc + unmapped + unwritten; | ||
1122 | } | ||
1123 | |||
1124 | /* | ||
1125 | * If we need a transaction and the process flags say | ||
1126 | * we are already in a transaction, or no IO is allowed | ||
1127 | * then mark the page dirty again and leave the page | ||
1128 | * as is. | ||
1129 | */ | ||
1130 | if (PFLAGS_TEST_FSTRANS() && need_trans) | ||
1131 | goto out_fail; | ||
1132 | |||
1133 | /* | ||
1134 | * Delay hooking up buffer heads until we have | ||
1135 | * made our go/no-go decision. | ||
1136 | */ | ||
1137 | if (!page_has_buffers(page)) | ||
1138 | create_empty_buffers(page, 1 << inode->i_blkbits, 0); | ||
1139 | |||
1140 | /* | ||
1141 | * Convert delayed allocate, unwritten or unmapped space | ||
1142 | * to real space and flush out to disk. | ||
1143 | */ | ||
1144 | error = xfs_page_state_convert(inode, page, wbc, 1, unmapped); | ||
1145 | if (error == -EAGAIN) | ||
1146 | goto out_fail; | ||
1147 | if (unlikely(error < 0)) | ||
1148 | goto out_unlock; | ||
1149 | |||
1150 | return 0; | ||
1151 | |||
1152 | out_fail: | ||
1153 | redirty_page_for_writepage(wbc, page); | ||
1154 | unlock_page(page); | ||
1155 | return 0; | ||
1156 | out_unlock: | ||
1157 | unlock_page(page); | ||
1158 | return error; | ||
1159 | } | ||
1160 | |||
1161 | /* | ||
1162 | * Called to move a page into cleanable state - and from there | ||
1163 | * to be released. Possibly the page is already clean. We always | ||
1164 | * have buffer heads in this call. | ||
1165 | * | ||
1166 | * Returns 0 if the page is ok to release, 1 otherwise. | ||
1167 | * | ||
1168 | * Possible scenarios are: | ||
1169 | * | ||
1170 | * 1. We are being called to release a page which has been written | ||
1171 | * to via regular I/O. buffer heads will be dirty and possibly | ||
1172 | * delalloc. If no delalloc buffer heads in this case then we | ||
1173 | * can just return zero. | ||
1174 | * | ||
1175 | * 2. We are called to release a page which has been written via | ||
1176 | * mmap, all we need to do is ensure there is no delalloc | ||
1177 | * state in the buffer heads, if not we can let the caller | ||
1178 | * free them and we should come back later via writepage. | ||
1179 | */ | ||
1043 | STATIC int | 1180 | STATIC int |
1044 | __linvfs_get_block( | 1181 | xfs_vm_releasepage( |
1182 | struct page *page, | ||
1183 | gfp_t gfp_mask) | ||
1184 | { | ||
1185 | struct inode *inode = page->mapping->host; | ||
1186 | int dirty, delalloc, unmapped, unwritten; | ||
1187 | struct writeback_control wbc = { | ||
1188 | .sync_mode = WB_SYNC_ALL, | ||
1189 | .nr_to_write = 1, | ||
1190 | }; | ||
1191 | |||
1192 | xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask); | ||
1193 | |||
1194 | if (!page_has_buffers(page)) | ||
1195 | return 0; | ||
1196 | |||
1197 | xfs_count_page_state(page, &delalloc, &unmapped, &unwritten); | ||
1198 | if (!delalloc && !unwritten) | ||
1199 | goto free_buffers; | ||
1200 | |||
1201 | if (!(gfp_mask & __GFP_FS)) | ||
1202 | return 0; | ||
1203 | |||
1204 | /* If we are already inside a transaction or the thread cannot | ||
1205 | * do I/O, we cannot release this page. | ||
1206 | */ | ||
1207 | if (PFLAGS_TEST_FSTRANS()) | ||
1208 | return 0; | ||
1209 | |||
1210 | /* | ||
1211 | * Convert delalloc space to real space, do not flush the | ||
1212 | * data out to disk, that will be done by the caller. | ||
1213 | * Never need to allocate space here - we will always | ||
1214 | * come back to writepage in that case. | ||
1215 | */ | ||
1216 | dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0); | ||
1217 | if (dirty == 0 && !unwritten) | ||
1218 | goto free_buffers; | ||
1219 | return 0; | ||
1220 | |||
1221 | free_buffers: | ||
1222 | return try_to_free_buffers(page); | ||
1223 | } | ||
1224 | |||
1225 | STATIC int | ||
1226 | __xfs_get_block( | ||
1045 | struct inode *inode, | 1227 | struct inode *inode, |
1046 | sector_t iblock, | 1228 | sector_t iblock, |
1047 | unsigned long blocks, | 1229 | unsigned long blocks, |
@@ -1050,7 +1232,7 @@ __linvfs_get_block( | |||
1050 | int direct, | 1232 | int direct, |
1051 | bmapi_flags_t flags) | 1233 | bmapi_flags_t flags) |
1052 | { | 1234 | { |
1053 | vnode_t *vp = LINVFS_GET_VP(inode); | 1235 | vnode_t *vp = vn_from_inode(inode); |
1054 | xfs_iomap_t iomap; | 1236 | xfs_iomap_t iomap; |
1055 | xfs_off_t offset; | 1237 | xfs_off_t offset; |
1056 | ssize_t size; | 1238 | ssize_t size; |
@@ -1073,21 +1255,13 @@ __linvfs_get_block( | |||
1073 | return 0; | 1255 | return 0; |
1074 | 1256 | ||
1075 | if (iomap.iomap_bn != IOMAP_DADDR_NULL) { | 1257 | if (iomap.iomap_bn != IOMAP_DADDR_NULL) { |
1076 | xfs_daddr_t bn; | 1258 | /* |
1077 | xfs_off_t delta; | 1259 | * For unwritten extents do not report a disk address on |
1078 | |||
1079 | /* For unwritten extents do not report a disk address on | ||
1080 | * the read case (treat as if we're reading into a hole). | 1260 | * the read case (treat as if we're reading into a hole). |
1081 | */ | 1261 | */ |
1082 | if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { | 1262 | if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { |
1083 | delta = offset - iomap.iomap_offset; | 1263 | xfs_map_buffer(bh_result, &iomap, offset, |
1084 | delta >>= inode->i_blkbits; | 1264 | inode->i_blkbits); |
1085 | |||
1086 | bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT); | ||
1087 | bn += delta; | ||
1088 | BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME)); | ||
1089 | bh_result->b_blocknr = bn; | ||
1090 | set_buffer_mapped(bh_result); | ||
1091 | } | 1265 | } |
1092 | if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { | 1266 | if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { |
1093 | if (direct) | 1267 | if (direct) |
@@ -1130,30 +1304,30 @@ __linvfs_get_block( | |||
1130 | } | 1304 | } |
1131 | 1305 | ||
1132 | int | 1306 | int |
1133 | linvfs_get_block( | 1307 | xfs_get_block( |
1134 | struct inode *inode, | 1308 | struct inode *inode, |
1135 | sector_t iblock, | 1309 | sector_t iblock, |
1136 | struct buffer_head *bh_result, | 1310 | struct buffer_head *bh_result, |
1137 | int create) | 1311 | int create) |
1138 | { | 1312 | { |
1139 | return __linvfs_get_block(inode, iblock, 0, bh_result, | 1313 | return __xfs_get_block(inode, iblock, 0, bh_result, |
1140 | create, 0, BMAPI_WRITE); | 1314 | create, 0, BMAPI_WRITE); |
1141 | } | 1315 | } |
1142 | 1316 | ||
1143 | STATIC int | 1317 | STATIC int |
1144 | linvfs_get_blocks_direct( | 1318 | xfs_get_blocks_direct( |
1145 | struct inode *inode, | 1319 | struct inode *inode, |
1146 | sector_t iblock, | 1320 | sector_t iblock, |
1147 | unsigned long max_blocks, | 1321 | unsigned long max_blocks, |
1148 | struct buffer_head *bh_result, | 1322 | struct buffer_head *bh_result, |
1149 | int create) | 1323 | int create) |
1150 | { | 1324 | { |
1151 | return __linvfs_get_block(inode, iblock, max_blocks, bh_result, | 1325 | return __xfs_get_block(inode, iblock, max_blocks, bh_result, |
1152 | create, 1, BMAPI_WRITE|BMAPI_DIRECT); | 1326 | create, 1, BMAPI_WRITE|BMAPI_DIRECT); |
1153 | } | 1327 | } |
1154 | 1328 | ||
1155 | STATIC void | 1329 | STATIC void |
1156 | linvfs_end_io_direct( | 1330 | xfs_end_io_direct( |
1157 | struct kiocb *iocb, | 1331 | struct kiocb *iocb, |
1158 | loff_t offset, | 1332 | loff_t offset, |
1159 | ssize_t size, | 1333 | ssize_t size, |
@@ -1191,7 +1365,7 @@ linvfs_end_io_direct( | |||
1191 | } | 1365 | } |
1192 | 1366 | ||
1193 | STATIC ssize_t | 1367 | STATIC ssize_t |
1194 | linvfs_direct_IO( | 1368 | xfs_vm_direct_IO( |
1195 | int rw, | 1369 | int rw, |
1196 | struct kiocb *iocb, | 1370 | struct kiocb *iocb, |
1197 | const struct iovec *iov, | 1371 | const struct iovec *iov, |
@@ -1200,7 +1374,7 @@ linvfs_direct_IO( | |||
1200 | { | 1374 | { |
1201 | struct file *file = iocb->ki_filp; | 1375 | struct file *file = iocb->ki_filp; |
1202 | struct inode *inode = file->f_mapping->host; | 1376 | struct inode *inode = file->f_mapping->host; |
1203 | vnode_t *vp = LINVFS_GET_VP(inode); | 1377 | vnode_t *vp = vn_from_inode(inode); |
1204 | xfs_iomap_t iomap; | 1378 | xfs_iomap_t iomap; |
1205 | int maps = 1; | 1379 | int maps = 1; |
1206 | int error; | 1380 | int error; |
@@ -1215,164 +1389,61 @@ linvfs_direct_IO( | |||
1215 | ret = blockdev_direct_IO_own_locking(rw, iocb, inode, | 1389 | ret = blockdev_direct_IO_own_locking(rw, iocb, inode, |
1216 | iomap.iomap_target->bt_bdev, | 1390 | iomap.iomap_target->bt_bdev, |
1217 | iov, offset, nr_segs, | 1391 | iov, offset, nr_segs, |
1218 | linvfs_get_blocks_direct, | 1392 | xfs_get_blocks_direct, |
1219 | linvfs_end_io_direct); | 1393 | xfs_end_io_direct); |
1220 | 1394 | ||
1221 | if (unlikely(ret <= 0 && iocb->private)) | 1395 | if (unlikely(ret <= 0 && iocb->private)) |
1222 | xfs_destroy_ioend(iocb->private); | 1396 | xfs_destroy_ioend(iocb->private); |
1223 | return ret; | 1397 | return ret; |
1224 | } | 1398 | } |
1225 | 1399 | ||
1400 | STATIC int | ||
1401 | xfs_vm_prepare_write( | ||
1402 | struct file *file, | ||
1403 | struct page *page, | ||
1404 | unsigned int from, | ||
1405 | unsigned int to) | ||
1406 | { | ||
1407 | return block_prepare_write(page, from, to, xfs_get_block); | ||
1408 | } | ||
1226 | 1409 | ||
1227 | STATIC sector_t | 1410 | STATIC sector_t |
1228 | linvfs_bmap( | 1411 | xfs_vm_bmap( |
1229 | struct address_space *mapping, | 1412 | struct address_space *mapping, |
1230 | sector_t block) | 1413 | sector_t block) |
1231 | { | 1414 | { |
1232 | struct inode *inode = (struct inode *)mapping->host; | 1415 | struct inode *inode = (struct inode *)mapping->host; |
1233 | vnode_t *vp = LINVFS_GET_VP(inode); | 1416 | vnode_t *vp = vn_from_inode(inode); |
1234 | int error; | 1417 | int error; |
1235 | 1418 | ||
1236 | vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address); | 1419 | vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); |
1237 | 1420 | ||
1238 | VOP_RWLOCK(vp, VRWLOCK_READ); | 1421 | VOP_RWLOCK(vp, VRWLOCK_READ); |
1239 | VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error); | 1422 | VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error); |
1240 | VOP_RWUNLOCK(vp, VRWLOCK_READ); | 1423 | VOP_RWUNLOCK(vp, VRWLOCK_READ); |
1241 | return generic_block_bmap(mapping, block, linvfs_get_block); | 1424 | return generic_block_bmap(mapping, block, xfs_get_block); |
1242 | } | 1425 | } |
1243 | 1426 | ||
1244 | STATIC int | 1427 | STATIC int |
1245 | linvfs_readpage( | 1428 | xfs_vm_readpage( |
1246 | struct file *unused, | 1429 | struct file *unused, |
1247 | struct page *page) | 1430 | struct page *page) |
1248 | { | 1431 | { |
1249 | return mpage_readpage(page, linvfs_get_block); | 1432 | return mpage_readpage(page, xfs_get_block); |
1250 | } | 1433 | } |
1251 | 1434 | ||
1252 | STATIC int | 1435 | STATIC int |
1253 | linvfs_readpages( | 1436 | xfs_vm_readpages( |
1254 | struct file *unused, | 1437 | struct file *unused, |
1255 | struct address_space *mapping, | 1438 | struct address_space *mapping, |
1256 | struct list_head *pages, | 1439 | struct list_head *pages, |
1257 | unsigned nr_pages) | 1440 | unsigned nr_pages) |
1258 | { | 1441 | { |
1259 | return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block); | 1442 | return mpage_readpages(mapping, pages, nr_pages, xfs_get_block); |
1260 | } | ||
1261 | |||
1262 | STATIC void | ||
1263 | xfs_count_page_state( | ||
1264 | struct page *page, | ||
1265 | int *delalloc, | ||
1266 | int *unmapped, | ||
1267 | int *unwritten) | ||
1268 | { | ||
1269 | struct buffer_head *bh, *head; | ||
1270 | |||
1271 | *delalloc = *unmapped = *unwritten = 0; | ||
1272 | |||
1273 | bh = head = page_buffers(page); | ||
1274 | do { | ||
1275 | if (buffer_uptodate(bh) && !buffer_mapped(bh)) | ||
1276 | (*unmapped) = 1; | ||
1277 | else if (buffer_unwritten(bh) && !buffer_delay(bh)) | ||
1278 | clear_buffer_unwritten(bh); | ||
1279 | else if (buffer_unwritten(bh)) | ||
1280 | (*unwritten) = 1; | ||
1281 | else if (buffer_delay(bh)) | ||
1282 | (*delalloc) = 1; | ||
1283 | } while ((bh = bh->b_this_page) != head); | ||
1284 | } | 1443 | } |
1285 | 1444 | ||
1286 | |||
1287 | /* | ||
1288 | * writepage: Called from one of two places: | ||
1289 | * | ||
1290 | * 1. we are flushing a delalloc buffer head. | ||
1291 | * | ||
1292 | * 2. we are writing out a dirty page. Typically the page dirty | ||
1293 | * state is cleared before we get here. In this case is it | ||
1294 | * conceivable we have no buffer heads. | ||
1295 | * | ||
1296 | * For delalloc space on the page we need to allocate space and | ||
1297 | * flush it. For unmapped buffer heads on the page we should | ||
1298 | * allocate space if the page is uptodate. For any other dirty | ||
1299 | * buffer heads on the page we should flush them. | ||
1300 | * | ||
1301 | * If we detect that a transaction would be required to flush | ||
1302 | * the page, we have to check the process flags first, if we | ||
1303 | * are already in a transaction or disk I/O during allocations | ||
1304 | * is off, we need to fail the writepage and redirty the page. | ||
1305 | */ | ||
1306 | |||
1307 | STATIC int | 1445 | STATIC int |
1308 | linvfs_writepage( | 1446 | xfs_vm_invalidatepage( |
1309 | struct page *page, | ||
1310 | struct writeback_control *wbc) | ||
1311 | { | ||
1312 | int error; | ||
1313 | int need_trans; | ||
1314 | int delalloc, unmapped, unwritten; | ||
1315 | struct inode *inode = page->mapping->host; | ||
1316 | |||
1317 | xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0); | ||
1318 | |||
1319 | /* | ||
1320 | * We need a transaction if: | ||
1321 | * 1. There are delalloc buffers on the page | ||
1322 | * 2. The page is uptodate and we have unmapped buffers | ||
1323 | * 3. The page is uptodate and we have no buffers | ||
1324 | * 4. There are unwritten buffers on the page | ||
1325 | */ | ||
1326 | |||
1327 | if (!page_has_buffers(page)) { | ||
1328 | unmapped = 1; | ||
1329 | need_trans = 1; | ||
1330 | } else { | ||
1331 | xfs_count_page_state(page, &delalloc, &unmapped, &unwritten); | ||
1332 | if (!PageUptodate(page)) | ||
1333 | unmapped = 0; | ||
1334 | need_trans = delalloc + unmapped + unwritten; | ||
1335 | } | ||
1336 | |||
1337 | /* | ||
1338 | * If we need a transaction and the process flags say | ||
1339 | * we are already in a transaction, or no IO is allowed | ||
1340 | * then mark the page dirty again and leave the page | ||
1341 | * as is. | ||
1342 | */ | ||
1343 | if (PFLAGS_TEST_FSTRANS() && need_trans) | ||
1344 | goto out_fail; | ||
1345 | |||
1346 | /* | ||
1347 | * Delay hooking up buffer heads until we have | ||
1348 | * made our go/no-go decision. | ||
1349 | */ | ||
1350 | if (!page_has_buffers(page)) | ||
1351 | create_empty_buffers(page, 1 << inode->i_blkbits, 0); | ||
1352 | |||
1353 | /* | ||
1354 | * Convert delayed allocate, unwritten or unmapped space | ||
1355 | * to real space and flush out to disk. | ||
1356 | */ | ||
1357 | error = xfs_page_state_convert(inode, page, wbc, 1, unmapped); | ||
1358 | if (error == -EAGAIN) | ||
1359 | goto out_fail; | ||
1360 | if (unlikely(error < 0)) | ||
1361 | goto out_unlock; | ||
1362 | |||
1363 | return 0; | ||
1364 | |||
1365 | out_fail: | ||
1366 | redirty_page_for_writepage(wbc, page); | ||
1367 | unlock_page(page); | ||
1368 | return 0; | ||
1369 | out_unlock: | ||
1370 | unlock_page(page); | ||
1371 | return error; | ||
1372 | } | ||
1373 | |||
1374 | STATIC int | ||
1375 | linvfs_invalidate_page( | ||
1376 | struct page *page, | 1447 | struct page *page, |
1377 | unsigned long offset) | 1448 | unsigned long offset) |
1378 | { | 1449 | { |
@@ -1381,87 +1452,16 @@ linvfs_invalidate_page( | |||
1381 | return block_invalidatepage(page, offset); | 1452 | return block_invalidatepage(page, offset); |
1382 | } | 1453 | } |
1383 | 1454 | ||
1384 | /* | 1455 | struct address_space_operations xfs_address_space_operations = { |
1385 | * Called to move a page into cleanable state - and from there | 1456 | .readpage = xfs_vm_readpage, |
1386 | * to be released. Possibly the page is already clean. We always | 1457 | .readpages = xfs_vm_readpages, |
1387 | * have buffer heads in this call. | 1458 | .writepage = xfs_vm_writepage, |
1388 | * | ||
1389 | * Returns 0 if the page is ok to release, 1 otherwise. | ||
1390 | * | ||
1391 | * Possible scenarios are: | ||
1392 | * | ||
1393 | * 1. We are being called to release a page which has been written | ||
1394 | * to via regular I/O. buffer heads will be dirty and possibly | ||
1395 | * delalloc. If no delalloc buffer heads in this case then we | ||
1396 | * can just return zero. | ||
1397 | * | ||
1398 | * 2. We are called to release a page which has been written via | ||
1399 | * mmap, all we need to do is ensure there is no delalloc | ||
1400 | * state in the buffer heads, if not we can let the caller | ||
1401 | * free them and we should come back later via writepage. | ||
1402 | */ | ||
1403 | STATIC int | ||
1404 | linvfs_release_page( | ||
1405 | struct page *page, | ||
1406 | gfp_t gfp_mask) | ||
1407 | { | ||
1408 | struct inode *inode = page->mapping->host; | ||
1409 | int dirty, delalloc, unmapped, unwritten; | ||
1410 | struct writeback_control wbc = { | ||
1411 | .sync_mode = WB_SYNC_ALL, | ||
1412 | .nr_to_write = 1, | ||
1413 | }; | ||
1414 | |||
1415 | xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask); | ||
1416 | |||
1417 | xfs_count_page_state(page, &delalloc, &unmapped, &unwritten); | ||
1418 | if (!delalloc && !unwritten) | ||
1419 | goto free_buffers; | ||
1420 | |||
1421 | if (!(gfp_mask & __GFP_FS)) | ||
1422 | return 0; | ||
1423 | |||
1424 | /* If we are already inside a transaction or the thread cannot | ||
1425 | * do I/O, we cannot release this page. | ||
1426 | */ | ||
1427 | if (PFLAGS_TEST_FSTRANS()) | ||
1428 | return 0; | ||
1429 | |||
1430 | /* | ||
1431 | * Convert delalloc space to real space, do not flush the | ||
1432 | * data out to disk, that will be done by the caller. | ||
1433 | * Never need to allocate space here - we will always | ||
1434 | * come back to writepage in that case. | ||
1435 | */ | ||
1436 | dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0); | ||
1437 | if (dirty == 0 && !unwritten) | ||
1438 | goto free_buffers; | ||
1439 | return 0; | ||
1440 | |||
1441 | free_buffers: | ||
1442 | return try_to_free_buffers(page); | ||
1443 | } | ||
1444 | |||
1445 | STATIC int | ||
1446 | linvfs_prepare_write( | ||
1447 | struct file *file, | ||
1448 | struct page *page, | ||
1449 | unsigned int from, | ||
1450 | unsigned int to) | ||
1451 | { | ||
1452 | return block_prepare_write(page, from, to, linvfs_get_block); | ||
1453 | } | ||
1454 | |||
1455 | struct address_space_operations linvfs_aops = { | ||
1456 | .readpage = linvfs_readpage, | ||
1457 | .readpages = linvfs_readpages, | ||
1458 | .writepage = linvfs_writepage, | ||
1459 | .sync_page = block_sync_page, | 1459 | .sync_page = block_sync_page, |
1460 | .releasepage = linvfs_release_page, | 1460 | .releasepage = xfs_vm_releasepage, |
1461 | .invalidatepage = linvfs_invalidate_page, | 1461 | .invalidatepage = xfs_vm_invalidatepage, |
1462 | .prepare_write = linvfs_prepare_write, | 1462 | .prepare_write = xfs_vm_prepare_write, |
1463 | .commit_write = generic_commit_write, | 1463 | .commit_write = generic_commit_write, |
1464 | .bmap = linvfs_bmap, | 1464 | .bmap = xfs_vm_bmap, |
1465 | .direct_IO = linvfs_direct_IO, | 1465 | .direct_IO = xfs_vm_direct_IO, |
1466 | .migratepage = buffer_migrate_page, | 1466 | .migratepage = buffer_migrate_page, |
1467 | }; | 1467 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h index 55339dd5a30d..795699f121d2 100644 --- a/fs/xfs/linux-2.6/xfs_aops.h +++ b/fs/xfs/linux-2.6/xfs_aops.h | |||
@@ -40,7 +40,7 @@ typedef struct xfs_ioend { | |||
40 | struct work_struct io_work; /* xfsdatad work queue */ | 40 | struct work_struct io_work; /* xfsdatad work queue */ |
41 | } xfs_ioend_t; | 41 | } xfs_ioend_t; |
42 | 42 | ||
43 | extern struct address_space_operations linvfs_aops; | 43 | extern struct address_space_operations xfs_address_space_operations; |
44 | extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int); | 44 | extern int xfs_get_block(struct inode *, sector_t, struct buffer_head *, int); |
45 | 45 | ||
46 | #endif /* __XFS_IOPS_H__ */ | 46 | #endif /* __XFS_IOPS_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 8cdfa4151659..9fb0312665ca 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -1806,13 +1806,12 @@ xfs_flush_buftarg( | |||
1806 | int __init | 1806 | int __init |
1807 | xfs_buf_init(void) | 1807 | xfs_buf_init(void) |
1808 | { | 1808 | { |
1809 | int error = -ENOMEM; | ||
1810 | |||
1811 | #ifdef XFS_BUF_TRACE | 1809 | #ifdef XFS_BUF_TRACE |
1812 | xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_SLEEP); | 1810 | xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_SLEEP); |
1813 | #endif | 1811 | #endif |
1814 | 1812 | ||
1815 | xfs_buf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf"); | 1813 | xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf", |
1814 | KM_ZONE_HWALIGN, NULL); | ||
1816 | if (!xfs_buf_zone) | 1815 | if (!xfs_buf_zone) |
1817 | goto out_free_trace_buf; | 1816 | goto out_free_trace_buf; |
1818 | 1817 | ||
@@ -1840,7 +1839,7 @@ xfs_buf_init(void) | |||
1840 | #ifdef XFS_BUF_TRACE | 1839 | #ifdef XFS_BUF_TRACE |
1841 | ktrace_free(xfs_buf_trace_buf); | 1840 | ktrace_free(xfs_buf_trace_buf); |
1842 | #endif | 1841 | #endif |
1843 | return error; | 1842 | return -ENOMEM; |
1844 | } | 1843 | } |
1845 | 1844 | ||
1846 | void | 1845 | void |
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c index 80eb249f2fa0..b768ea910bbe 100644 --- a/fs/xfs/linux-2.6/xfs_export.c +++ b/fs/xfs/linux-2.6/xfs_export.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
26 | #include "xfs_export.h" | 26 | #include "xfs_export.h" |
27 | 27 | ||
28 | STATIC struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, }; | ||
29 | |||
28 | /* | 30 | /* |
29 | * XFS encodes and decodes the fileid portion of NFS filehandles | 31 | * XFS encodes and decodes the fileid portion of NFS filehandles |
30 | * itself instead of letting the generic NFS code do it. This | 32 | * itself instead of letting the generic NFS code do it. This |
@@ -37,7 +39,7 @@ | |||
37 | */ | 39 | */ |
38 | 40 | ||
39 | STATIC struct dentry * | 41 | STATIC struct dentry * |
40 | linvfs_decode_fh( | 42 | xfs_fs_decode_fh( |
41 | struct super_block *sb, | 43 | struct super_block *sb, |
42 | __u32 *fh, | 44 | __u32 *fh, |
43 | int fh_len, | 45 | int fh_len, |
@@ -78,12 +80,12 @@ linvfs_decode_fh( | |||
78 | } | 80 | } |
79 | 81 | ||
80 | fh = (__u32 *)&ifid; | 82 | fh = (__u32 *)&ifid; |
81 | return find_exported_dentry(sb, fh, parent, acceptable, context); | 83 | return sb->s_export_op->find_exported_dentry(sb, fh, parent, acceptable, context); |
82 | } | 84 | } |
83 | 85 | ||
84 | 86 | ||
85 | STATIC int | 87 | STATIC int |
86 | linvfs_encode_fh( | 88 | xfs_fs_encode_fh( |
87 | struct dentry *dentry, | 89 | struct dentry *dentry, |
88 | __u32 *fh, | 90 | __u32 *fh, |
89 | int *max_len, | 91 | int *max_len, |
@@ -95,7 +97,7 @@ linvfs_encode_fh( | |||
95 | int len; | 97 | int len; |
96 | int is64 = 0; | 98 | int is64 = 0; |
97 | #if XFS_BIG_INUMS | 99 | #if XFS_BIG_INUMS |
98 | vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); | 100 | vfs_t *vfs = vfs_from_sb(inode->i_sb); |
99 | 101 | ||
100 | if (!(vfs->vfs_flag & VFS_32BITINODES)) { | 102 | if (!(vfs->vfs_flag & VFS_32BITINODES)) { |
101 | /* filesystem may contain 64bit inode numbers */ | 103 | /* filesystem may contain 64bit inode numbers */ |
@@ -130,21 +132,21 @@ linvfs_encode_fh( | |||
130 | } | 132 | } |
131 | 133 | ||
132 | STATIC struct dentry * | 134 | STATIC struct dentry * |
133 | linvfs_get_dentry( | 135 | xfs_fs_get_dentry( |
134 | struct super_block *sb, | 136 | struct super_block *sb, |
135 | void *data) | 137 | void *data) |
136 | { | 138 | { |
137 | vnode_t *vp; | 139 | vnode_t *vp; |
138 | struct inode *inode; | 140 | struct inode *inode; |
139 | struct dentry *result; | 141 | struct dentry *result; |
140 | vfs_t *vfsp = LINVFS_GET_VFS(sb); | 142 | vfs_t *vfsp = vfs_from_sb(sb); |
141 | int error; | 143 | int error; |
142 | 144 | ||
143 | VFS_VGET(vfsp, &vp, (fid_t *)data, error); | 145 | VFS_VGET(vfsp, &vp, (fid_t *)data, error); |
144 | if (error || vp == NULL) | 146 | if (error || vp == NULL) |
145 | return ERR_PTR(-ESTALE) ; | 147 | return ERR_PTR(-ESTALE) ; |
146 | 148 | ||
147 | inode = LINVFS_GET_IP(vp); | 149 | inode = vn_to_inode(vp); |
148 | result = d_alloc_anon(inode); | 150 | result = d_alloc_anon(inode); |
149 | if (!result) { | 151 | if (!result) { |
150 | iput(inode); | 152 | iput(inode); |
@@ -154,25 +156,20 @@ linvfs_get_dentry( | |||
154 | } | 156 | } |
155 | 157 | ||
156 | STATIC struct dentry * | 158 | STATIC struct dentry * |
157 | linvfs_get_parent( | 159 | xfs_fs_get_parent( |
158 | struct dentry *child) | 160 | struct dentry *child) |
159 | { | 161 | { |
160 | int error; | 162 | int error; |
161 | vnode_t *vp, *cvp; | 163 | vnode_t *vp, *cvp; |
162 | struct dentry *parent; | 164 | struct dentry *parent; |
163 | struct dentry dotdot; | ||
164 | |||
165 | dotdot.d_name.name = ".."; | ||
166 | dotdot.d_name.len = 2; | ||
167 | dotdot.d_inode = NULL; | ||
168 | 165 | ||
169 | cvp = NULL; | 166 | cvp = NULL; |
170 | vp = LINVFS_GET_VP(child->d_inode); | 167 | vp = vn_from_inode(child->d_inode); |
171 | VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error); | 168 | VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error); |
172 | if (unlikely(error)) | 169 | if (unlikely(error)) |
173 | return ERR_PTR(-error); | 170 | return ERR_PTR(-error); |
174 | 171 | ||
175 | parent = d_alloc_anon(LINVFS_GET_IP(cvp)); | 172 | parent = d_alloc_anon(vn_to_inode(cvp)); |
176 | if (unlikely(!parent)) { | 173 | if (unlikely(!parent)) { |
177 | VN_RELE(cvp); | 174 | VN_RELE(cvp); |
178 | return ERR_PTR(-ENOMEM); | 175 | return ERR_PTR(-ENOMEM); |
@@ -180,9 +177,9 @@ linvfs_get_parent( | |||
180 | return parent; | 177 | return parent; |
181 | } | 178 | } |
182 | 179 | ||
183 | struct export_operations linvfs_export_ops = { | 180 | struct export_operations xfs_export_operations = { |
184 | .decode_fh = linvfs_decode_fh, | 181 | .decode_fh = xfs_fs_decode_fh, |
185 | .encode_fh = linvfs_encode_fh, | 182 | .encode_fh = xfs_fs_encode_fh, |
186 | .get_parent = linvfs_get_parent, | 183 | .get_parent = xfs_fs_get_parent, |
187 | .get_dentry = linvfs_get_dentry, | 184 | .get_dentry = xfs_fs_get_dentry, |
188 | }; | 185 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index ced4404339c7..185567a6a561 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
@@ -43,13 +43,13 @@ | |||
43 | #include <linux/dcache.h> | 43 | #include <linux/dcache.h> |
44 | #include <linux/smp_lock.h> | 44 | #include <linux/smp_lock.h> |
45 | 45 | ||
46 | static struct vm_operations_struct linvfs_file_vm_ops; | 46 | static struct vm_operations_struct xfs_file_vm_ops; |
47 | #ifdef CONFIG_XFS_DMAPI | 47 | #ifdef CONFIG_XFS_DMAPI |
48 | static struct vm_operations_struct linvfs_dmapi_file_vm_ops; | 48 | static struct vm_operations_struct xfs_dmapi_file_vm_ops; |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | STATIC inline ssize_t | 51 | STATIC inline ssize_t |
52 | __linvfs_read( | 52 | __xfs_file_read( |
53 | struct kiocb *iocb, | 53 | struct kiocb *iocb, |
54 | char __user *buf, | 54 | char __user *buf, |
55 | int ioflags, | 55 | int ioflags, |
@@ -58,7 +58,7 @@ __linvfs_read( | |||
58 | { | 58 | { |
59 | struct iovec iov = {buf, count}; | 59 | struct iovec iov = {buf, count}; |
60 | struct file *file = iocb->ki_filp; | 60 | struct file *file = iocb->ki_filp; |
61 | vnode_t *vp = LINVFS_GET_VP(file->f_dentry->d_inode); | 61 | vnode_t *vp = vn_from_inode(file->f_dentry->d_inode); |
62 | ssize_t rval; | 62 | ssize_t rval; |
63 | 63 | ||
64 | BUG_ON(iocb->ki_pos != pos); | 64 | BUG_ON(iocb->ki_pos != pos); |
@@ -71,28 +71,28 @@ __linvfs_read( | |||
71 | 71 | ||
72 | 72 | ||
73 | STATIC ssize_t | 73 | STATIC ssize_t |
74 | linvfs_aio_read( | 74 | xfs_file_aio_read( |
75 | struct kiocb *iocb, | 75 | struct kiocb *iocb, |
76 | char __user *buf, | 76 | char __user *buf, |
77 | size_t count, | 77 | size_t count, |
78 | loff_t pos) | 78 | loff_t pos) |
79 | { | 79 | { |
80 | return __linvfs_read(iocb, buf, IO_ISAIO, count, pos); | 80 | return __xfs_file_read(iocb, buf, IO_ISAIO, count, pos); |
81 | } | 81 | } |
82 | 82 | ||
83 | STATIC ssize_t | 83 | STATIC ssize_t |
84 | linvfs_aio_read_invis( | 84 | xfs_file_aio_read_invis( |
85 | struct kiocb *iocb, | 85 | struct kiocb *iocb, |
86 | char __user *buf, | 86 | char __user *buf, |
87 | size_t count, | 87 | size_t count, |
88 | loff_t pos) | 88 | loff_t pos) |
89 | { | 89 | { |
90 | return __linvfs_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); | 90 | return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | STATIC inline ssize_t | 94 | STATIC inline ssize_t |
95 | __linvfs_write( | 95 | __xfs_file_write( |
96 | struct kiocb *iocb, | 96 | struct kiocb *iocb, |
97 | const char __user *buf, | 97 | const char __user *buf, |
98 | int ioflags, | 98 | int ioflags, |
@@ -102,7 +102,7 @@ __linvfs_write( | |||
102 | struct iovec iov = {(void __user *)buf, count}; | 102 | struct iovec iov = {(void __user *)buf, count}; |
103 | struct file *file = iocb->ki_filp; | 103 | struct file *file = iocb->ki_filp; |
104 | struct inode *inode = file->f_mapping->host; | 104 | struct inode *inode = file->f_mapping->host; |
105 | vnode_t *vp = LINVFS_GET_VP(inode); | 105 | vnode_t *vp = vn_from_inode(inode); |
106 | ssize_t rval; | 106 | ssize_t rval; |
107 | 107 | ||
108 | BUG_ON(iocb->ki_pos != pos); | 108 | BUG_ON(iocb->ki_pos != pos); |
@@ -115,28 +115,28 @@ __linvfs_write( | |||
115 | 115 | ||
116 | 116 | ||
117 | STATIC ssize_t | 117 | STATIC ssize_t |
118 | linvfs_aio_write( | 118 | xfs_file_aio_write( |
119 | struct kiocb *iocb, | 119 | struct kiocb *iocb, |
120 | const char __user *buf, | 120 | const char __user *buf, |
121 | size_t count, | 121 | size_t count, |
122 | loff_t pos) | 122 | loff_t pos) |
123 | { | 123 | { |
124 | return __linvfs_write(iocb, buf, IO_ISAIO, count, pos); | 124 | return __xfs_file_write(iocb, buf, IO_ISAIO, count, pos); |
125 | } | 125 | } |
126 | 126 | ||
127 | STATIC ssize_t | 127 | STATIC ssize_t |
128 | linvfs_aio_write_invis( | 128 | xfs_file_aio_write_invis( |
129 | struct kiocb *iocb, | 129 | struct kiocb *iocb, |
130 | const char __user *buf, | 130 | const char __user *buf, |
131 | size_t count, | 131 | size_t count, |
132 | loff_t pos) | 132 | loff_t pos) |
133 | { | 133 | { |
134 | return __linvfs_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); | 134 | return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | STATIC inline ssize_t | 138 | STATIC inline ssize_t |
139 | __linvfs_readv( | 139 | __xfs_file_readv( |
140 | struct file *file, | 140 | struct file *file, |
141 | const struct iovec *iov, | 141 | const struct iovec *iov, |
142 | int ioflags, | 142 | int ioflags, |
@@ -144,8 +144,8 @@ __linvfs_readv( | |||
144 | loff_t *ppos) | 144 | loff_t *ppos) |
145 | { | 145 | { |
146 | struct inode *inode = file->f_mapping->host; | 146 | struct inode *inode = file->f_mapping->host; |
147 | vnode_t *vp = LINVFS_GET_VP(inode); | 147 | vnode_t *vp = vn_from_inode(inode); |
148 | struct kiocb kiocb; | 148 | struct kiocb kiocb; |
149 | ssize_t rval; | 149 | ssize_t rval; |
150 | 150 | ||
151 | init_sync_kiocb(&kiocb, file); | 151 | init_sync_kiocb(&kiocb, file); |
@@ -160,28 +160,28 @@ __linvfs_readv( | |||
160 | } | 160 | } |
161 | 161 | ||
162 | STATIC ssize_t | 162 | STATIC ssize_t |
163 | linvfs_readv( | 163 | xfs_file_readv( |
164 | struct file *file, | 164 | struct file *file, |
165 | const struct iovec *iov, | 165 | const struct iovec *iov, |
166 | unsigned long nr_segs, | 166 | unsigned long nr_segs, |
167 | loff_t *ppos) | 167 | loff_t *ppos) |
168 | { | 168 | { |
169 | return __linvfs_readv(file, iov, 0, nr_segs, ppos); | 169 | return __xfs_file_readv(file, iov, 0, nr_segs, ppos); |
170 | } | 170 | } |
171 | 171 | ||
172 | STATIC ssize_t | 172 | STATIC ssize_t |
173 | linvfs_readv_invis( | 173 | xfs_file_readv_invis( |
174 | struct file *file, | 174 | struct file *file, |
175 | const struct iovec *iov, | 175 | const struct iovec *iov, |
176 | unsigned long nr_segs, | 176 | unsigned long nr_segs, |
177 | loff_t *ppos) | 177 | loff_t *ppos) |
178 | { | 178 | { |
179 | return __linvfs_readv(file, iov, IO_INVIS, nr_segs, ppos); | 179 | return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos); |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | STATIC inline ssize_t | 183 | STATIC inline ssize_t |
184 | __linvfs_writev( | 184 | __xfs_file_writev( |
185 | struct file *file, | 185 | struct file *file, |
186 | const struct iovec *iov, | 186 | const struct iovec *iov, |
187 | int ioflags, | 187 | int ioflags, |
@@ -189,8 +189,8 @@ __linvfs_writev( | |||
189 | loff_t *ppos) | 189 | loff_t *ppos) |
190 | { | 190 | { |
191 | struct inode *inode = file->f_mapping->host; | 191 | struct inode *inode = file->f_mapping->host; |
192 | vnode_t *vp = LINVFS_GET_VP(inode); | 192 | vnode_t *vp = vn_from_inode(inode); |
193 | struct kiocb kiocb; | 193 | struct kiocb kiocb; |
194 | ssize_t rval; | 194 | ssize_t rval; |
195 | 195 | ||
196 | init_sync_kiocb(&kiocb, file); | 196 | init_sync_kiocb(&kiocb, file); |
@@ -206,34 +206,34 @@ __linvfs_writev( | |||
206 | 206 | ||
207 | 207 | ||
208 | STATIC ssize_t | 208 | STATIC ssize_t |
209 | linvfs_writev( | 209 | xfs_file_writev( |
210 | struct file *file, | 210 | struct file *file, |
211 | const struct iovec *iov, | 211 | const struct iovec *iov, |
212 | unsigned long nr_segs, | 212 | unsigned long nr_segs, |
213 | loff_t *ppos) | 213 | loff_t *ppos) |
214 | { | 214 | { |
215 | return __linvfs_writev(file, iov, 0, nr_segs, ppos); | 215 | return __xfs_file_writev(file, iov, 0, nr_segs, ppos); |
216 | } | 216 | } |
217 | 217 | ||
218 | STATIC ssize_t | 218 | STATIC ssize_t |
219 | linvfs_writev_invis( | 219 | xfs_file_writev_invis( |
220 | struct file *file, | 220 | struct file *file, |
221 | const struct iovec *iov, | 221 | const struct iovec *iov, |
222 | unsigned long nr_segs, | 222 | unsigned long nr_segs, |
223 | loff_t *ppos) | 223 | loff_t *ppos) |
224 | { | 224 | { |
225 | return __linvfs_writev(file, iov, IO_INVIS, nr_segs, ppos); | 225 | return __xfs_file_writev(file, iov, IO_INVIS, nr_segs, ppos); |
226 | } | 226 | } |
227 | 227 | ||
228 | STATIC ssize_t | 228 | STATIC ssize_t |
229 | linvfs_sendfile( | 229 | xfs_file_sendfile( |
230 | struct file *filp, | 230 | struct file *filp, |
231 | loff_t *ppos, | 231 | loff_t *ppos, |
232 | size_t count, | 232 | size_t count, |
233 | read_actor_t actor, | 233 | read_actor_t actor, |
234 | void *target) | 234 | void *target) |
235 | { | 235 | { |
236 | vnode_t *vp = LINVFS_GET_VP(filp->f_dentry->d_inode); | 236 | vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode); |
237 | ssize_t rval; | 237 | ssize_t rval; |
238 | 238 | ||
239 | VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval); | 239 | VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval); |
@@ -242,11 +242,11 @@ linvfs_sendfile( | |||
242 | 242 | ||
243 | 243 | ||
244 | STATIC int | 244 | STATIC int |
245 | linvfs_open( | 245 | xfs_file_open( |
246 | struct inode *inode, | 246 | struct inode *inode, |
247 | struct file *filp) | 247 | struct file *filp) |
248 | { | 248 | { |
249 | vnode_t *vp = LINVFS_GET_VP(inode); | 249 | vnode_t *vp = vn_from_inode(inode); |
250 | int error; | 250 | int error; |
251 | 251 | ||
252 | if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) | 252 | if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) |
@@ -259,11 +259,11 @@ linvfs_open( | |||
259 | 259 | ||
260 | 260 | ||
261 | STATIC int | 261 | STATIC int |
262 | linvfs_release( | 262 | xfs_file_release( |
263 | struct inode *inode, | 263 | struct inode *inode, |
264 | struct file *filp) | 264 | struct file *filp) |
265 | { | 265 | { |
266 | vnode_t *vp = LINVFS_GET_VP(inode); | 266 | vnode_t *vp = vn_from_inode(inode); |
267 | int error = 0; | 267 | int error = 0; |
268 | 268 | ||
269 | if (vp) | 269 | if (vp) |
@@ -273,13 +273,13 @@ linvfs_release( | |||
273 | 273 | ||
274 | 274 | ||
275 | STATIC int | 275 | STATIC int |
276 | linvfs_fsync( | 276 | xfs_file_fsync( |
277 | struct file *filp, | 277 | struct file *filp, |
278 | struct dentry *dentry, | 278 | struct dentry *dentry, |
279 | int datasync) | 279 | int datasync) |
280 | { | 280 | { |
281 | struct inode *inode = dentry->d_inode; | 281 | struct inode *inode = dentry->d_inode; |
282 | vnode_t *vp = LINVFS_GET_VP(inode); | 282 | vnode_t *vp = vn_from_inode(inode); |
283 | int error; | 283 | int error; |
284 | int flags = FSYNC_WAIT; | 284 | int flags = FSYNC_WAIT; |
285 | 285 | ||
@@ -292,7 +292,7 @@ linvfs_fsync( | |||
292 | } | 292 | } |
293 | 293 | ||
294 | /* | 294 | /* |
295 | * linvfs_readdir maps to VOP_READDIR(). | 295 | * xfs_file_readdir maps to VOP_READDIR(). |
296 | * We need to build a uio, cred, ... | 296 | * We need to build a uio, cred, ... |
297 | */ | 297 | */ |
298 | 298 | ||
@@ -301,13 +301,13 @@ linvfs_fsync( | |||
301 | #ifdef CONFIG_XFS_DMAPI | 301 | #ifdef CONFIG_XFS_DMAPI |
302 | 302 | ||
303 | STATIC struct page * | 303 | STATIC struct page * |
304 | linvfs_filemap_nopage( | 304 | xfs_vm_nopage( |
305 | struct vm_area_struct *area, | 305 | struct vm_area_struct *area, |
306 | unsigned long address, | 306 | unsigned long address, |
307 | int *type) | 307 | int *type) |
308 | { | 308 | { |
309 | struct inode *inode = area->vm_file->f_dentry->d_inode; | 309 | struct inode *inode = area->vm_file->f_dentry->d_inode; |
310 | vnode_t *vp = LINVFS_GET_VP(inode); | 310 | vnode_t *vp = vn_from_inode(inode); |
311 | xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); | 311 | xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); |
312 | int error; | 312 | int error; |
313 | 313 | ||
@@ -324,7 +324,7 @@ linvfs_filemap_nopage( | |||
324 | 324 | ||
325 | 325 | ||
326 | STATIC int | 326 | STATIC int |
327 | linvfs_readdir( | 327 | xfs_file_readdir( |
328 | struct file *filp, | 328 | struct file *filp, |
329 | void *dirent, | 329 | void *dirent, |
330 | filldir_t filldir) | 330 | filldir_t filldir) |
@@ -340,7 +340,7 @@ linvfs_readdir( | |||
340 | xfs_off_t start_offset, curr_offset; | 340 | xfs_off_t start_offset, curr_offset; |
341 | xfs_dirent_t *dbp = NULL; | 341 | xfs_dirent_t *dbp = NULL; |
342 | 342 | ||
343 | vp = LINVFS_GET_VP(filp->f_dentry->d_inode); | 343 | vp = vn_from_inode(filp->f_dentry->d_inode); |
344 | ASSERT(vp); | 344 | ASSERT(vp); |
345 | 345 | ||
346 | /* Try fairly hard to get memory */ | 346 | /* Try fairly hard to get memory */ |
@@ -404,39 +404,40 @@ done: | |||
404 | 404 | ||
405 | 405 | ||
406 | STATIC int | 406 | STATIC int |
407 | linvfs_file_mmap( | 407 | xfs_file_mmap( |
408 | struct file *filp, | 408 | struct file *filp, |
409 | struct vm_area_struct *vma) | 409 | struct vm_area_struct *vma) |
410 | { | 410 | { |
411 | struct inode *ip = filp->f_dentry->d_inode; | 411 | struct inode *ip = filp->f_dentry->d_inode; |
412 | vnode_t *vp = LINVFS_GET_VP(ip); | 412 | vnode_t *vp = vn_from_inode(ip); |
413 | vattr_t va = { .va_mask = XFS_AT_UPDATIME }; | 413 | vattr_t vattr; |
414 | int error; | 414 | int error; |
415 | 415 | ||
416 | vma->vm_ops = &linvfs_file_vm_ops; | 416 | vma->vm_ops = &xfs_file_vm_ops; |
417 | 417 | ||
418 | #ifdef CONFIG_XFS_DMAPI | 418 | #ifdef CONFIG_XFS_DMAPI |
419 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { | 419 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { |
420 | vma->vm_ops = &linvfs_dmapi_file_vm_ops; | 420 | vma->vm_ops = &xfs_dmapi_file_vm_ops; |
421 | } | 421 | } |
422 | #endif /* CONFIG_XFS_DMAPI */ | 422 | #endif /* CONFIG_XFS_DMAPI */ |
423 | 423 | ||
424 | VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error); | 424 | vattr.va_mask = XFS_AT_UPDATIME; |
425 | if (!error) | 425 | VOP_SETATTR(vp, &vattr, XFS_AT_UPDATIME, NULL, error); |
426 | vn_revalidate(vp); /* update Linux inode flags */ | 426 | if (likely(!error)) |
427 | __vn_revalidate(vp, &vattr); /* update flags */ | ||
427 | return 0; | 428 | return 0; |
428 | } | 429 | } |
429 | 430 | ||
430 | 431 | ||
431 | STATIC long | 432 | STATIC long |
432 | linvfs_ioctl( | 433 | xfs_file_ioctl( |
433 | struct file *filp, | 434 | struct file *filp, |
434 | unsigned int cmd, | 435 | unsigned int cmd, |
435 | unsigned long arg) | 436 | unsigned long arg) |
436 | { | 437 | { |
437 | int error; | 438 | int error; |
438 | struct inode *inode = filp->f_dentry->d_inode; | 439 | struct inode *inode = filp->f_dentry->d_inode; |
439 | vnode_t *vp = LINVFS_GET_VP(inode); | 440 | vnode_t *vp = vn_from_inode(inode); |
440 | 441 | ||
441 | VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error); | 442 | VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error); |
442 | VMODIFY(vp); | 443 | VMODIFY(vp); |
@@ -451,14 +452,14 @@ linvfs_ioctl( | |||
451 | } | 452 | } |
452 | 453 | ||
453 | STATIC long | 454 | STATIC long |
454 | linvfs_ioctl_invis( | 455 | xfs_file_ioctl_invis( |
455 | struct file *filp, | 456 | struct file *filp, |
456 | unsigned int cmd, | 457 | unsigned int cmd, |
457 | unsigned long arg) | 458 | unsigned long arg) |
458 | { | 459 | { |
459 | int error; | 460 | int error; |
460 | struct inode *inode = filp->f_dentry->d_inode; | 461 | struct inode *inode = filp->f_dentry->d_inode; |
461 | vnode_t *vp = LINVFS_GET_VP(inode); | 462 | vnode_t *vp = vn_from_inode(inode); |
462 | 463 | ||
463 | ASSERT(vp); | 464 | ASSERT(vp); |
464 | VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error); | 465 | VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error); |
@@ -476,11 +477,11 @@ linvfs_ioctl_invis( | |||
476 | #ifdef CONFIG_XFS_DMAPI | 477 | #ifdef CONFIG_XFS_DMAPI |
477 | #ifdef HAVE_VMOP_MPROTECT | 478 | #ifdef HAVE_VMOP_MPROTECT |
478 | STATIC int | 479 | STATIC int |
479 | linvfs_mprotect( | 480 | xfs_vm_mprotect( |
480 | struct vm_area_struct *vma, | 481 | struct vm_area_struct *vma, |
481 | unsigned int newflags) | 482 | unsigned int newflags) |
482 | { | 483 | { |
483 | vnode_t *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode); | 484 | vnode_t *vp = vn_from_inode(vma->vm_file->f_dentry->d_inode); |
484 | int error = 0; | 485 | int error = 0; |
485 | 486 | ||
486 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { | 487 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { |
@@ -503,10 +504,10 @@ linvfs_mprotect( | |||
503 | * it back online. | 504 | * it back online. |
504 | */ | 505 | */ |
505 | STATIC int | 506 | STATIC int |
506 | linvfs_open_exec( | 507 | xfs_file_open_exec( |
507 | struct inode *inode) | 508 | struct inode *inode) |
508 | { | 509 | { |
509 | vnode_t *vp = LINVFS_GET_VP(inode); | 510 | vnode_t *vp = vn_from_inode(inode); |
510 | xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); | 511 | xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); |
511 | int error = 0; | 512 | int error = 0; |
512 | xfs_inode_t *ip; | 513 | xfs_inode_t *ip; |
@@ -527,69 +528,69 @@ open_exec_out: | |||
527 | } | 528 | } |
528 | #endif /* HAVE_FOP_OPEN_EXEC */ | 529 | #endif /* HAVE_FOP_OPEN_EXEC */ |
529 | 530 | ||
530 | struct file_operations linvfs_file_operations = { | 531 | struct file_operations xfs_file_operations = { |
531 | .llseek = generic_file_llseek, | 532 | .llseek = generic_file_llseek, |
532 | .read = do_sync_read, | 533 | .read = do_sync_read, |
533 | .write = do_sync_write, | 534 | .write = do_sync_write, |
534 | .readv = linvfs_readv, | 535 | .readv = xfs_file_readv, |
535 | .writev = linvfs_writev, | 536 | .writev = xfs_file_writev, |
536 | .aio_read = linvfs_aio_read, | 537 | .aio_read = xfs_file_aio_read, |
537 | .aio_write = linvfs_aio_write, | 538 | .aio_write = xfs_file_aio_write, |
538 | .sendfile = linvfs_sendfile, | 539 | .sendfile = xfs_file_sendfile, |
539 | .unlocked_ioctl = linvfs_ioctl, | 540 | .unlocked_ioctl = xfs_file_ioctl, |
540 | #ifdef CONFIG_COMPAT | 541 | #ifdef CONFIG_COMPAT |
541 | .compat_ioctl = linvfs_compat_ioctl, | 542 | .compat_ioctl = xfs_file_compat_ioctl, |
542 | #endif | 543 | #endif |
543 | .mmap = linvfs_file_mmap, | 544 | .mmap = xfs_file_mmap, |
544 | .open = linvfs_open, | 545 | .open = xfs_file_open, |
545 | .release = linvfs_release, | 546 | .release = xfs_file_release, |
546 | .fsync = linvfs_fsync, | 547 | .fsync = xfs_file_fsync, |
547 | #ifdef HAVE_FOP_OPEN_EXEC | 548 | #ifdef HAVE_FOP_OPEN_EXEC |
548 | .open_exec = linvfs_open_exec, | 549 | .open_exec = xfs_file_open_exec, |
549 | #endif | 550 | #endif |
550 | }; | 551 | }; |
551 | 552 | ||
552 | struct file_operations linvfs_invis_file_operations = { | 553 | struct file_operations xfs_invis_file_operations = { |
553 | .llseek = generic_file_llseek, | 554 | .llseek = generic_file_llseek, |
554 | .read = do_sync_read, | 555 | .read = do_sync_read, |
555 | .write = do_sync_write, | 556 | .write = do_sync_write, |
556 | .readv = linvfs_readv_invis, | 557 | .readv = xfs_file_readv_invis, |
557 | .writev = linvfs_writev_invis, | 558 | .writev = xfs_file_writev_invis, |
558 | .aio_read = linvfs_aio_read_invis, | 559 | .aio_read = xfs_file_aio_read_invis, |
559 | .aio_write = linvfs_aio_write_invis, | 560 | .aio_write = xfs_file_aio_write_invis, |
560 | .sendfile = linvfs_sendfile, | 561 | .sendfile = xfs_file_sendfile, |
561 | .unlocked_ioctl = linvfs_ioctl_invis, | 562 | .unlocked_ioctl = xfs_file_ioctl_invis, |
562 | #ifdef CONFIG_COMPAT | 563 | #ifdef CONFIG_COMPAT |
563 | .compat_ioctl = linvfs_compat_invis_ioctl, | 564 | .compat_ioctl = xfs_file_compat_invis_ioctl, |
564 | #endif | 565 | #endif |
565 | .mmap = linvfs_file_mmap, | 566 | .mmap = xfs_file_mmap, |
566 | .open = linvfs_open, | 567 | .open = xfs_file_open, |
567 | .release = linvfs_release, | 568 | .release = xfs_file_release, |
568 | .fsync = linvfs_fsync, | 569 | .fsync = xfs_file_fsync, |
569 | }; | 570 | }; |
570 | 571 | ||
571 | 572 | ||
572 | struct file_operations linvfs_dir_operations = { | 573 | struct file_operations xfs_dir_file_operations = { |
573 | .read = generic_read_dir, | 574 | .read = generic_read_dir, |
574 | .readdir = linvfs_readdir, | 575 | .readdir = xfs_file_readdir, |
575 | .unlocked_ioctl = linvfs_ioctl, | 576 | .unlocked_ioctl = xfs_file_ioctl, |
576 | #ifdef CONFIG_COMPAT | 577 | #ifdef CONFIG_COMPAT |
577 | .compat_ioctl = linvfs_compat_ioctl, | 578 | .compat_ioctl = xfs_file_compat_ioctl, |
578 | #endif | 579 | #endif |
579 | .fsync = linvfs_fsync, | 580 | .fsync = xfs_file_fsync, |
580 | }; | 581 | }; |
581 | 582 | ||
582 | static struct vm_operations_struct linvfs_file_vm_ops = { | 583 | static struct vm_operations_struct xfs_file_vm_ops = { |
583 | .nopage = filemap_nopage, | 584 | .nopage = filemap_nopage, |
584 | .populate = filemap_populate, | 585 | .populate = filemap_populate, |
585 | }; | 586 | }; |
586 | 587 | ||
587 | #ifdef CONFIG_XFS_DMAPI | 588 | #ifdef CONFIG_XFS_DMAPI |
588 | static struct vm_operations_struct linvfs_dmapi_file_vm_ops = { | 589 | static struct vm_operations_struct xfs_dmapi_file_vm_ops = { |
589 | .nopage = linvfs_filemap_nopage, | 590 | .nopage = xfs_vm_nopage, |
590 | .populate = filemap_populate, | 591 | .populate = filemap_populate, |
591 | #ifdef HAVE_VMOP_MPROTECT | 592 | #ifdef HAVE_VMOP_MPROTECT |
592 | .mprotect = linvfs_mprotect, | 593 | .mprotect = xfs_vm_mprotect, |
593 | #endif | 594 | #endif |
594 | }; | 595 | }; |
595 | #endif /* CONFIG_XFS_DMAPI */ | 596 | #endif /* CONFIG_XFS_DMAPI */ |
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c index 4fa4b1a5187e..575f2a790f31 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.c +++ b/fs/xfs/linux-2.6/xfs_fs_subr.c | |||
@@ -57,7 +57,7 @@ fs_tosspages( | |||
57 | int fiopt) | 57 | int fiopt) |
58 | { | 58 | { |
59 | vnode_t *vp = BHV_TO_VNODE(bdp); | 59 | vnode_t *vp = BHV_TO_VNODE(bdp); |
60 | struct inode *ip = LINVFS_GET_IP(vp); | 60 | struct inode *ip = vn_to_inode(vp); |
61 | 61 | ||
62 | if (VN_CACHED(vp)) | 62 | if (VN_CACHED(vp)) |
63 | truncate_inode_pages(ip->i_mapping, first); | 63 | truncate_inode_pages(ip->i_mapping, first); |
@@ -76,7 +76,7 @@ fs_flushinval_pages( | |||
76 | int fiopt) | 76 | int fiopt) |
77 | { | 77 | { |
78 | vnode_t *vp = BHV_TO_VNODE(bdp); | 78 | vnode_t *vp = BHV_TO_VNODE(bdp); |
79 | struct inode *ip = LINVFS_GET_IP(vp); | 79 | struct inode *ip = vn_to_inode(vp); |
80 | 80 | ||
81 | if (VN_CACHED(vp)) { | 81 | if (VN_CACHED(vp)) { |
82 | filemap_write_and_wait(ip->i_mapping); | 82 | filemap_write_and_wait(ip->i_mapping); |
@@ -98,7 +98,7 @@ fs_flush_pages( | |||
98 | int fiopt) | 98 | int fiopt) |
99 | { | 99 | { |
100 | vnode_t *vp = BHV_TO_VNODE(bdp); | 100 | vnode_t *vp = BHV_TO_VNODE(bdp); |
101 | struct inode *ip = LINVFS_GET_IP(vp); | 101 | struct inode *ip = vn_to_inode(vp); |
102 | 102 | ||
103 | if (VN_CACHED(vp)) { | 103 | if (VN_CACHED(vp)) { |
104 | filemap_fdatawrite(ip->i_mapping); | 104 | filemap_fdatawrite(ip->i_mapping); |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index 4db47790415c..84478491609b 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
@@ -138,7 +138,7 @@ xfs_find_handle( | |||
138 | } | 138 | } |
139 | 139 | ||
140 | /* we need the vnode */ | 140 | /* we need the vnode */ |
141 | vp = LINVFS_GET_VP(inode); | 141 | vp = vn_from_inode(inode); |
142 | 142 | ||
143 | /* now we can grab the fsid */ | 143 | /* now we can grab the fsid */ |
144 | memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t)); | 144 | memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t)); |
@@ -256,7 +256,7 @@ xfs_vget_fsop_handlereq( | |||
256 | } | 256 | } |
257 | 257 | ||
258 | vpp = XFS_ITOV(ip); | 258 | vpp = XFS_ITOV(ip); |
259 | inodep = LINVFS_GET_IP(vpp); | 259 | inodep = vn_to_inode(vpp); |
260 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 260 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
261 | 261 | ||
262 | *vp = vpp; | 262 | *vp = vpp; |
@@ -344,7 +344,7 @@ xfs_open_by_handle( | |||
344 | return -XFS_ERROR(-PTR_ERR(filp)); | 344 | return -XFS_ERROR(-PTR_ERR(filp)); |
345 | } | 345 | } |
346 | if (inode->i_mode & S_IFREG) | 346 | if (inode->i_mode & S_IFREG) |
347 | filp->f_op = &linvfs_invis_file_operations; | 347 | filp->f_op = &xfs_invis_file_operations; |
348 | 348 | ||
349 | fd_install(new_fd, filp); | 349 | fd_install(new_fd, filp); |
350 | return new_fd; | 350 | return new_fd; |
@@ -715,7 +715,7 @@ xfs_ioctl( | |||
715 | xfs_inode_t *ip; | 715 | xfs_inode_t *ip; |
716 | xfs_mount_t *mp; | 716 | xfs_mount_t *mp; |
717 | 717 | ||
718 | vp = LINVFS_GET_VP(inode); | 718 | vp = vn_from_inode(inode); |
719 | 719 | ||
720 | vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address); | 720 | vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address); |
721 | 721 | ||
@@ -1160,105 +1160,129 @@ xfs_ioc_xattr( | |||
1160 | void __user *arg) | 1160 | void __user *arg) |
1161 | { | 1161 | { |
1162 | struct fsxattr fa; | 1162 | struct fsxattr fa; |
1163 | vattr_t va; | 1163 | struct vattr *vattr; |
1164 | int error; | 1164 | int error = 0; |
1165 | int attr_flags; | 1165 | int attr_flags; |
1166 | unsigned int flags; | 1166 | unsigned int flags; |
1167 | 1167 | ||
1168 | vattr = kmalloc(sizeof(*vattr), GFP_KERNEL); | ||
1169 | if (unlikely(!vattr)) | ||
1170 | return -ENOMEM; | ||
1171 | |||
1168 | switch (cmd) { | 1172 | switch (cmd) { |
1169 | case XFS_IOC_FSGETXATTR: { | 1173 | case XFS_IOC_FSGETXATTR: { |
1170 | va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ | 1174 | vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ |
1171 | XFS_AT_NEXTENTS | XFS_AT_PROJID; | 1175 | XFS_AT_NEXTENTS | XFS_AT_PROJID; |
1172 | VOP_GETATTR(vp, &va, 0, NULL, error); | 1176 | VOP_GETATTR(vp, vattr, 0, NULL, error); |
1173 | if (error) | 1177 | if (unlikely(error)) { |
1174 | return -error; | 1178 | error = -error; |
1179 | break; | ||
1180 | } | ||
1175 | 1181 | ||
1176 | fa.fsx_xflags = va.va_xflags; | 1182 | fa.fsx_xflags = vattr->va_xflags; |
1177 | fa.fsx_extsize = va.va_extsize; | 1183 | fa.fsx_extsize = vattr->va_extsize; |
1178 | fa.fsx_nextents = va.va_nextents; | 1184 | fa.fsx_nextents = vattr->va_nextents; |
1179 | fa.fsx_projid = va.va_projid; | 1185 | fa.fsx_projid = vattr->va_projid; |
1180 | 1186 | ||
1181 | if (copy_to_user(arg, &fa, sizeof(fa))) | 1187 | if (copy_to_user(arg, &fa, sizeof(fa))) { |
1182 | return -XFS_ERROR(EFAULT); | 1188 | error = -EFAULT; |
1183 | return 0; | 1189 | break; |
1190 | } | ||
1191 | break; | ||
1184 | } | 1192 | } |
1185 | 1193 | ||
1186 | case XFS_IOC_FSSETXATTR: { | 1194 | case XFS_IOC_FSSETXATTR: { |
1187 | if (copy_from_user(&fa, arg, sizeof(fa))) | 1195 | if (copy_from_user(&fa, arg, sizeof(fa))) { |
1188 | return -XFS_ERROR(EFAULT); | 1196 | error = -EFAULT; |
1197 | break; | ||
1198 | } | ||
1189 | 1199 | ||
1190 | attr_flags = 0; | 1200 | attr_flags = 0; |
1191 | if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) | 1201 | if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) |
1192 | attr_flags |= ATTR_NONBLOCK; | 1202 | attr_flags |= ATTR_NONBLOCK; |
1193 | 1203 | ||
1194 | va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID; | 1204 | vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID; |
1195 | va.va_xflags = fa.fsx_xflags; | 1205 | vattr->va_xflags = fa.fsx_xflags; |
1196 | va.va_extsize = fa.fsx_extsize; | 1206 | vattr->va_extsize = fa.fsx_extsize; |
1197 | va.va_projid = fa.fsx_projid; | 1207 | vattr->va_projid = fa.fsx_projid; |
1198 | 1208 | ||
1199 | VOP_SETATTR(vp, &va, attr_flags, NULL, error); | 1209 | VOP_SETATTR(vp, vattr, attr_flags, NULL, error); |
1200 | if (!error) | 1210 | if (likely(!error)) |
1201 | vn_revalidate(vp); /* update Linux inode flags */ | 1211 | __vn_revalidate(vp, vattr); /* update flags */ |
1202 | return -error; | 1212 | error = -error; |
1213 | break; | ||
1203 | } | 1214 | } |
1204 | 1215 | ||
1205 | case XFS_IOC_FSGETXATTRA: { | 1216 | case XFS_IOC_FSGETXATTRA: { |
1206 | va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ | 1217 | vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ |
1207 | XFS_AT_ANEXTENTS | XFS_AT_PROJID; | 1218 | XFS_AT_ANEXTENTS | XFS_AT_PROJID; |
1208 | VOP_GETATTR(vp, &va, 0, NULL, error); | 1219 | VOP_GETATTR(vp, vattr, 0, NULL, error); |
1209 | if (error) | 1220 | if (unlikely(error)) { |
1210 | return -error; | 1221 | error = -error; |
1222 | break; | ||
1223 | } | ||
1211 | 1224 | ||
1212 | fa.fsx_xflags = va.va_xflags; | 1225 | fa.fsx_xflags = vattr->va_xflags; |
1213 | fa.fsx_extsize = va.va_extsize; | 1226 | fa.fsx_extsize = vattr->va_extsize; |
1214 | fa.fsx_nextents = va.va_anextents; | 1227 | fa.fsx_nextents = vattr->va_anextents; |
1215 | fa.fsx_projid = va.va_projid; | 1228 | fa.fsx_projid = vattr->va_projid; |
1216 | 1229 | ||
1217 | if (copy_to_user(arg, &fa, sizeof(fa))) | 1230 | if (copy_to_user(arg, &fa, sizeof(fa))) { |
1218 | return -XFS_ERROR(EFAULT); | 1231 | error = -EFAULT; |
1219 | return 0; | 1232 | break; |
1233 | } | ||
1234 | break; | ||
1220 | } | 1235 | } |
1221 | 1236 | ||
1222 | case XFS_IOC_GETXFLAGS: { | 1237 | case XFS_IOC_GETXFLAGS: { |
1223 | flags = xfs_di2lxflags(ip->i_d.di_flags); | 1238 | flags = xfs_di2lxflags(ip->i_d.di_flags); |
1224 | if (copy_to_user(arg, &flags, sizeof(flags))) | 1239 | if (copy_to_user(arg, &flags, sizeof(flags))) |
1225 | return -XFS_ERROR(EFAULT); | 1240 | error = -EFAULT; |
1226 | return 0; | 1241 | break; |
1227 | } | 1242 | } |
1228 | 1243 | ||
1229 | case XFS_IOC_SETXFLAGS: { | 1244 | case XFS_IOC_SETXFLAGS: { |
1230 | if (copy_from_user(&flags, arg, sizeof(flags))) | 1245 | if (copy_from_user(&flags, arg, sizeof(flags))) { |
1231 | return -XFS_ERROR(EFAULT); | 1246 | error = -EFAULT; |
1247 | break; | ||
1248 | } | ||
1232 | 1249 | ||
1233 | if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \ | 1250 | if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \ |
1234 | LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \ | 1251 | LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \ |
1235 | LINUX_XFLAG_SYNC)) | 1252 | LINUX_XFLAG_SYNC)) { |
1236 | return -XFS_ERROR(EOPNOTSUPP); | 1253 | error = -EOPNOTSUPP; |
1254 | break; | ||
1255 | } | ||
1237 | 1256 | ||
1238 | attr_flags = 0; | 1257 | attr_flags = 0; |
1239 | if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) | 1258 | if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) |
1240 | attr_flags |= ATTR_NONBLOCK; | 1259 | attr_flags |= ATTR_NONBLOCK; |
1241 | 1260 | ||
1242 | va.va_mask = XFS_AT_XFLAGS; | 1261 | vattr->va_mask = XFS_AT_XFLAGS; |
1243 | va.va_xflags = xfs_merge_ioc_xflags(flags, | 1262 | vattr->va_xflags = xfs_merge_ioc_xflags(flags, |
1244 | xfs_ip2xflags(ip)); | 1263 | xfs_ip2xflags(ip)); |
1245 | 1264 | ||
1246 | VOP_SETATTR(vp, &va, attr_flags, NULL, error); | 1265 | VOP_SETATTR(vp, vattr, attr_flags, NULL, error); |
1247 | if (!error) | 1266 | if (likely(!error)) |
1248 | vn_revalidate(vp); /* update Linux inode flags */ | 1267 | __vn_revalidate(vp, vattr); /* update flags */ |
1249 | return -error; | 1268 | error = -error; |
1269 | break; | ||
1250 | } | 1270 | } |
1251 | 1271 | ||
1252 | case XFS_IOC_GETVERSION: { | 1272 | case XFS_IOC_GETVERSION: { |
1253 | flags = LINVFS_GET_IP(vp)->i_generation; | 1273 | flags = vn_to_inode(vp)->i_generation; |
1254 | if (copy_to_user(arg, &flags, sizeof(flags))) | 1274 | if (copy_to_user(arg, &flags, sizeof(flags))) |
1255 | return -XFS_ERROR(EFAULT); | 1275 | error = -EFAULT; |
1256 | return 0; | 1276 | break; |
1257 | } | 1277 | } |
1258 | 1278 | ||
1259 | default: | 1279 | default: |
1260 | return -ENOTTY; | 1280 | error = -ENOTTY; |
1281 | break; | ||
1261 | } | 1282 | } |
1283 | |||
1284 | kfree(vattr); | ||
1285 | return error; | ||
1262 | } | 1286 | } |
1263 | 1287 | ||
1264 | STATIC int | 1288 | STATIC int |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c index a7c9ba1a9f7b..b6321abd9a81 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.c +++ b/fs/xfs/linux-2.6/xfs_ioctl32.c | |||
@@ -107,11 +107,11 @@ xfs_ioctl32_bulkstat( | |||
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | STATIC long | 109 | STATIC long |
110 | __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg) | 110 | xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg) |
111 | { | 111 | { |
112 | int error; | 112 | int error; |
113 | struct inode *inode = f->f_dentry->d_inode; | 113 | struct inode *inode = f->f_dentry->d_inode; |
114 | vnode_t *vp = LINVFS_GET_VP(inode); | 114 | vnode_t *vp = vn_to_inode(inode); |
115 | 115 | ||
116 | switch (cmd) { | 116 | switch (cmd) { |
117 | case XFS_IOC_DIOINFO: | 117 | case XFS_IOC_DIOINFO: |
@@ -196,19 +196,19 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg) | |||
196 | } | 196 | } |
197 | 197 | ||
198 | long | 198 | long |
199 | linvfs_compat_ioctl( | 199 | xfs_file_compat_ioctl( |
200 | struct file *f, | 200 | struct file *f, |
201 | unsigned cmd, | 201 | unsigned cmd, |
202 | unsigned long arg) | 202 | unsigned long arg) |
203 | { | 203 | { |
204 | return __linvfs_compat_ioctl(0, f, cmd, arg); | 204 | return xfs_compat_ioctl(0, f, cmd, arg); |
205 | } | 205 | } |
206 | 206 | ||
207 | long | 207 | long |
208 | linvfs_compat_invis_ioctl( | 208 | xfs_file_compat_invis_ioctl( |
209 | struct file *f, | 209 | struct file *f, |
210 | unsigned cmd, | 210 | unsigned cmd, |
211 | unsigned long arg) | 211 | unsigned long arg) |
212 | { | 212 | { |
213 | return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg); | 213 | return xfs_compat_ioctl(IO_INVIS, f, cmd, arg); |
214 | } | 214 | } |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h index 011c273bec50..02de6e62ee37 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.h +++ b/fs/xfs/linux-2.6/xfs_ioctl32.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #ifndef __XFS_IOCTL32_H__ | 18 | #ifndef __XFS_IOCTL32_H__ |
19 | #define __XFS_IOCTL32_H__ | 19 | #define __XFS_IOCTL32_H__ |
20 | 20 | ||
21 | extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long); | 21 | extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long); |
22 | extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long); | 22 | extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned long); |
23 | 23 | ||
24 | #endif /* __XFS_IOCTL32_H__ */ | 24 | #endif /* __XFS_IOCTL32_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index d7f6f2d8ac8e..af487437bd7e 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -106,7 +106,7 @@ xfs_ichgtime( | |||
106 | xfs_inode_t *ip, | 106 | xfs_inode_t *ip, |
107 | int flags) | 107 | int flags) |
108 | { | 108 | { |
109 | struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); | 109 | struct inode *inode = vn_to_inode(XFS_ITOV(ip)); |
110 | timespec_t tv; | 110 | timespec_t tv; |
111 | 111 | ||
112 | nanotime(&tv); | 112 | nanotime(&tv); |
@@ -198,22 +198,22 @@ xfs_ichgtime_fast( | |||
198 | * Pull the link count and size up from the xfs inode to the linux inode | 198 | * Pull the link count and size up from the xfs inode to the linux inode |
199 | */ | 199 | */ |
200 | STATIC void | 200 | STATIC void |
201 | validate_fields( | 201 | xfs_validate_fields( |
202 | struct inode *ip) | 202 | struct inode *ip, |
203 | struct vattr *vattr) | ||
203 | { | 204 | { |
204 | vnode_t *vp = LINVFS_GET_VP(ip); | 205 | vnode_t *vp = vn_from_inode(ip); |
205 | vattr_t va; | ||
206 | int error; | 206 | int error; |
207 | 207 | ||
208 | va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS; | 208 | vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS; |
209 | VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error); | 209 | VOP_GETATTR(vp, vattr, ATTR_LAZY, NULL, error); |
210 | if (likely(!error)) { | 210 | if (likely(!error)) { |
211 | ip->i_nlink = va.va_nlink; | 211 | ip->i_nlink = vattr->va_nlink; |
212 | ip->i_blocks = va.va_nblocks; | 212 | ip->i_blocks = vattr->va_nblocks; |
213 | 213 | ||
214 | /* we're under i_mutex so i_size can't change under us */ | 214 | /* we're under i_sem so i_size can't change under us */ |
215 | if (i_size_read(ip) != va.va_size) | 215 | if (i_size_read(ip) != vattr->va_size) |
216 | i_size_write(ip, va.va_size); | 216 | i_size_write(ip, vattr->va_size); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
@@ -224,11 +224,11 @@ validate_fields( | |||
224 | * inode, of course, such that log replay can't cause these to be lost). | 224 | * inode, of course, such that log replay can't cause these to be lost). |
225 | */ | 225 | */ |
226 | STATIC int | 226 | STATIC int |
227 | linvfs_init_security( | 227 | xfs_init_security( |
228 | struct vnode *vp, | 228 | struct vnode *vp, |
229 | struct inode *dir) | 229 | struct inode *dir) |
230 | { | 230 | { |
231 | struct inode *ip = LINVFS_GET_IP(vp); | 231 | struct inode *ip = vn_to_inode(vp); |
232 | size_t length; | 232 | size_t length; |
233 | void *value; | 233 | void *value; |
234 | char *name; | 234 | char *name; |
@@ -257,46 +257,46 @@ linvfs_init_security( | |||
257 | * XXX(hch): nfsd is broken, better fix it instead. | 257 | * XXX(hch): nfsd is broken, better fix it instead. |
258 | */ | 258 | */ |
259 | STATIC inline int | 259 | STATIC inline int |
260 | has_fs_struct(struct task_struct *task) | 260 | xfs_has_fs_struct(struct task_struct *task) |
261 | { | 261 | { |
262 | return (task->fs != init_task.fs); | 262 | return (task->fs != init_task.fs); |
263 | } | 263 | } |
264 | 264 | ||
265 | STATIC inline void | 265 | STATIC inline void |
266 | cleanup_inode( | 266 | xfs_cleanup_inode( |
267 | vnode_t *dvp, | 267 | vnode_t *dvp, |
268 | vnode_t *vp, | 268 | vnode_t *vp, |
269 | struct dentry *dentry, | 269 | struct dentry *dentry, |
270 | int mode) | 270 | int mode) |
271 | { | 271 | { |
272 | struct dentry teardown = {}; | 272 | struct dentry teardown = {}; |
273 | int err2; | 273 | int error; |
274 | 274 | ||
275 | /* Oh, the horror. | 275 | /* Oh, the horror. |
276 | * If we can't add the ACL or we fail in | 276 | * If we can't add the ACL or we fail in |
277 | * linvfs_init_security we must back out. | 277 | * xfs_init_security we must back out. |
278 | * ENOSPC can hit here, among other things. | 278 | * ENOSPC can hit here, among other things. |
279 | */ | 279 | */ |
280 | teardown.d_inode = LINVFS_GET_IP(vp); | 280 | teardown.d_inode = vn_to_inode(vp); |
281 | teardown.d_name = dentry->d_name; | 281 | teardown.d_name = dentry->d_name; |
282 | 282 | ||
283 | if (S_ISDIR(mode)) | 283 | if (S_ISDIR(mode)) |
284 | VOP_RMDIR(dvp, &teardown, NULL, err2); | 284 | VOP_RMDIR(dvp, &teardown, NULL, error); |
285 | else | 285 | else |
286 | VOP_REMOVE(dvp, &teardown, NULL, err2); | 286 | VOP_REMOVE(dvp, &teardown, NULL, error); |
287 | VN_RELE(vp); | 287 | VN_RELE(vp); |
288 | } | 288 | } |
289 | 289 | ||
290 | STATIC int | 290 | STATIC int |
291 | linvfs_mknod( | 291 | xfs_vn_mknod( |
292 | struct inode *dir, | 292 | struct inode *dir, |
293 | struct dentry *dentry, | 293 | struct dentry *dentry, |
294 | int mode, | 294 | int mode, |
295 | dev_t rdev) | 295 | dev_t rdev) |
296 | { | 296 | { |
297 | struct inode *ip; | 297 | struct inode *ip; |
298 | vattr_t va; | 298 | vattr_t vattr = { 0 }; |
299 | vnode_t *vp = NULL, *dvp = LINVFS_GET_VP(dir); | 299 | vnode_t *vp = NULL, *dvp = vn_from_inode(dir); |
300 | xfs_acl_t *default_acl = NULL; | 300 | xfs_acl_t *default_acl = NULL; |
301 | attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; | 301 | attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; |
302 | int error; | 302 | int error; |
@@ -305,99 +305,98 @@ linvfs_mknod( | |||
305 | * Irix uses Missed'em'V split, but doesn't want to see | 305 | * Irix uses Missed'em'V split, but doesn't want to see |
306 | * the upper 5 bits of (14bit) major. | 306 | * the upper 5 bits of (14bit) major. |
307 | */ | 307 | */ |
308 | if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff) | 308 | if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) |
309 | return -EINVAL; | 309 | return -EINVAL; |
310 | 310 | ||
311 | if (test_default_acl && test_default_acl(dvp)) { | 311 | if (unlikely(test_default_acl && test_default_acl(dvp))) { |
312 | if (!_ACL_ALLOC(default_acl)) | 312 | if (!_ACL_ALLOC(default_acl)) { |
313 | return -ENOMEM; | 313 | return -ENOMEM; |
314 | } | ||
314 | if (!_ACL_GET_DEFAULT(dvp, default_acl)) { | 315 | if (!_ACL_GET_DEFAULT(dvp, default_acl)) { |
315 | _ACL_FREE(default_acl); | 316 | _ACL_FREE(default_acl); |
316 | default_acl = NULL; | 317 | default_acl = NULL; |
317 | } | 318 | } |
318 | } | 319 | } |
319 | 320 | ||
320 | if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current)) | 321 | if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current)) |
321 | mode &= ~current->fs->umask; | 322 | mode &= ~current->fs->umask; |
322 | 323 | ||
323 | memset(&va, 0, sizeof(va)); | 324 | vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE; |
324 | va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; | 325 | vattr.va_mode = mode; |
325 | va.va_mode = mode; | ||
326 | 326 | ||
327 | switch (mode & S_IFMT) { | 327 | switch (mode & S_IFMT) { |
328 | case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: | 328 | case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: |
329 | va.va_rdev = sysv_encode_dev(rdev); | 329 | vattr.va_rdev = sysv_encode_dev(rdev); |
330 | va.va_mask |= XFS_AT_RDEV; | 330 | vattr.va_mask |= XFS_AT_RDEV; |
331 | /*FALLTHROUGH*/ | 331 | /*FALLTHROUGH*/ |
332 | case S_IFREG: | 332 | case S_IFREG: |
333 | VOP_CREATE(dvp, dentry, &va, &vp, NULL, error); | 333 | VOP_CREATE(dvp, dentry, &vattr, &vp, NULL, error); |
334 | break; | 334 | break; |
335 | case S_IFDIR: | 335 | case S_IFDIR: |
336 | VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error); | 336 | VOP_MKDIR(dvp, dentry, &vattr, &vp, NULL, error); |
337 | break; | 337 | break; |
338 | default: | 338 | default: |
339 | error = EINVAL; | 339 | error = EINVAL; |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | 342 | ||
343 | if (!error) | 343 | if (unlikely(!error)) { |
344 | { | 344 | error = xfs_init_security(vp, dir); |
345 | error = linvfs_init_security(vp, dir); | ||
346 | if (error) | 345 | if (error) |
347 | cleanup_inode(dvp, vp, dentry, mode); | 346 | xfs_cleanup_inode(dvp, vp, dentry, mode); |
348 | } | 347 | } |
349 | 348 | ||
350 | if (default_acl) { | 349 | if (unlikely(default_acl)) { |
351 | if (!error) { | 350 | if (!error) { |
352 | error = _ACL_INHERIT(vp, &va, default_acl); | 351 | error = _ACL_INHERIT(vp, &vattr, default_acl); |
353 | if (!error) | 352 | if (!error) |
354 | VMODIFY(vp); | 353 | VMODIFY(vp); |
355 | else | 354 | else |
356 | cleanup_inode(dvp, vp, dentry, mode); | 355 | xfs_cleanup_inode(dvp, vp, dentry, mode); |
357 | } | 356 | } |
358 | _ACL_FREE(default_acl); | 357 | _ACL_FREE(default_acl); |
359 | } | 358 | } |
360 | 359 | ||
361 | if (!error) { | 360 | if (likely(!error)) { |
362 | ASSERT(vp); | 361 | ASSERT(vp); |
363 | ip = LINVFS_GET_IP(vp); | 362 | ip = vn_to_inode(vp); |
364 | 363 | ||
365 | if (S_ISCHR(mode) || S_ISBLK(mode)) | 364 | if (S_ISCHR(mode) || S_ISBLK(mode)) |
366 | ip->i_rdev = rdev; | 365 | ip->i_rdev = rdev; |
367 | else if (S_ISDIR(mode)) | 366 | else if (S_ISDIR(mode)) |
368 | validate_fields(ip); | 367 | xfs_validate_fields(ip, &vattr); |
369 | d_instantiate(dentry, ip); | 368 | d_instantiate(dentry, ip); |
370 | validate_fields(dir); | 369 | xfs_validate_fields(dir, &vattr); |
371 | } | 370 | } |
372 | return -error; | 371 | return -error; |
373 | } | 372 | } |
374 | 373 | ||
375 | STATIC int | 374 | STATIC int |
376 | linvfs_create( | 375 | xfs_vn_create( |
377 | struct inode *dir, | 376 | struct inode *dir, |
378 | struct dentry *dentry, | 377 | struct dentry *dentry, |
379 | int mode, | 378 | int mode, |
380 | struct nameidata *nd) | 379 | struct nameidata *nd) |
381 | { | 380 | { |
382 | return linvfs_mknod(dir, dentry, mode, 0); | 381 | return xfs_vn_mknod(dir, dentry, mode, 0); |
383 | } | 382 | } |
384 | 383 | ||
385 | STATIC int | 384 | STATIC int |
386 | linvfs_mkdir( | 385 | xfs_vn_mkdir( |
387 | struct inode *dir, | 386 | struct inode *dir, |
388 | struct dentry *dentry, | 387 | struct dentry *dentry, |
389 | int mode) | 388 | int mode) |
390 | { | 389 | { |
391 | return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0); | 390 | return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0); |
392 | } | 391 | } |
393 | 392 | ||
394 | STATIC struct dentry * | 393 | STATIC struct dentry * |
395 | linvfs_lookup( | 394 | xfs_vn_lookup( |
396 | struct inode *dir, | 395 | struct inode *dir, |
397 | struct dentry *dentry, | 396 | struct dentry *dentry, |
398 | struct nameidata *nd) | 397 | struct nameidata *nd) |
399 | { | 398 | { |
400 | struct vnode *vp = LINVFS_GET_VP(dir), *cvp; | 399 | struct vnode *vp = vn_from_inode(dir), *cvp; |
401 | int error; | 400 | int error; |
402 | 401 | ||
403 | if (dentry->d_name.len >= MAXNAMELEN) | 402 | if (dentry->d_name.len >= MAXNAMELEN) |
@@ -411,11 +410,11 @@ linvfs_lookup( | |||
411 | return NULL; | 410 | return NULL; |
412 | } | 411 | } |
413 | 412 | ||
414 | return d_splice_alias(LINVFS_GET_IP(cvp), dentry); | 413 | return d_splice_alias(vn_to_inode(cvp), dentry); |
415 | } | 414 | } |
416 | 415 | ||
417 | STATIC int | 416 | STATIC int |
418 | linvfs_link( | 417 | xfs_vn_link( |
419 | struct dentry *old_dentry, | 418 | struct dentry *old_dentry, |
420 | struct inode *dir, | 419 | struct inode *dir, |
421 | struct dentry *dentry) | 420 | struct dentry *dentry) |
@@ -423,99 +422,102 @@ linvfs_link( | |||
423 | struct inode *ip; /* inode of guy being linked to */ | 422 | struct inode *ip; /* inode of guy being linked to */ |
424 | vnode_t *tdvp; /* target directory for new name/link */ | 423 | vnode_t *tdvp; /* target directory for new name/link */ |
425 | vnode_t *vp; /* vp of name being linked */ | 424 | vnode_t *vp; /* vp of name being linked */ |
425 | vattr_t vattr; | ||
426 | int error; | 426 | int error; |
427 | 427 | ||
428 | ip = old_dentry->d_inode; /* inode being linked to */ | 428 | ip = old_dentry->d_inode; /* inode being linked to */ |
429 | if (S_ISDIR(ip->i_mode)) | 429 | if (S_ISDIR(ip->i_mode)) |
430 | return -EPERM; | 430 | return -EPERM; |
431 | 431 | ||
432 | tdvp = LINVFS_GET_VP(dir); | 432 | tdvp = vn_from_inode(dir); |
433 | vp = LINVFS_GET_VP(ip); | 433 | vp = vn_from_inode(ip); |
434 | 434 | ||
435 | VOP_LINK(tdvp, vp, dentry, NULL, error); | 435 | VOP_LINK(tdvp, vp, dentry, NULL, error); |
436 | if (!error) { | 436 | if (likely(!error)) { |
437 | VMODIFY(tdvp); | 437 | VMODIFY(tdvp); |
438 | VN_HOLD(vp); | 438 | VN_HOLD(vp); |
439 | validate_fields(ip); | 439 | xfs_validate_fields(ip, &vattr); |
440 | d_instantiate(dentry, ip); | 440 | d_instantiate(dentry, ip); |
441 | } | 441 | } |
442 | return -error; | 442 | return -error; |
443 | } | 443 | } |
444 | 444 | ||
445 | STATIC int | 445 | STATIC int |
446 | linvfs_unlink( | 446 | xfs_vn_unlink( |
447 | struct inode *dir, | 447 | struct inode *dir, |
448 | struct dentry *dentry) | 448 | struct dentry *dentry) |
449 | { | 449 | { |
450 | struct inode *inode; | 450 | struct inode *inode; |
451 | vnode_t *dvp; /* directory containing name to remove */ | 451 | vnode_t *dvp; /* directory containing name to remove */ |
452 | vattr_t vattr; | ||
452 | int error; | 453 | int error; |
453 | 454 | ||
454 | inode = dentry->d_inode; | 455 | inode = dentry->d_inode; |
455 | dvp = LINVFS_GET_VP(dir); | 456 | dvp = vn_from_inode(dir); |
456 | 457 | ||
457 | VOP_REMOVE(dvp, dentry, NULL, error); | 458 | VOP_REMOVE(dvp, dentry, NULL, error); |
458 | if (!error) { | 459 | if (likely(!error)) { |
459 | validate_fields(dir); /* For size only */ | 460 | xfs_validate_fields(dir, &vattr); /* size needs update */ |
460 | validate_fields(inode); | 461 | xfs_validate_fields(inode, &vattr); |
461 | } | 462 | } |
462 | |||
463 | return -error; | 463 | return -error; |
464 | } | 464 | } |
465 | 465 | ||
466 | STATIC int | 466 | STATIC int |
467 | linvfs_symlink( | 467 | xfs_vn_symlink( |
468 | struct inode *dir, | 468 | struct inode *dir, |
469 | struct dentry *dentry, | 469 | struct dentry *dentry, |
470 | const char *symname) | 470 | const char *symname) |
471 | { | 471 | { |
472 | struct inode *ip; | 472 | struct inode *ip; |
473 | vattr_t va; | 473 | vattr_t vattr = { 0 }; |
474 | vnode_t *dvp; /* directory containing name of symlink */ | 474 | vnode_t *dvp; /* directory containing name of symlink */ |
475 | vnode_t *cvp; /* used to lookup symlink to put in dentry */ | 475 | vnode_t *cvp; /* used to lookup symlink to put in dentry */ |
476 | int error; | 476 | int error; |
477 | 477 | ||
478 | dvp = LINVFS_GET_VP(dir); | 478 | dvp = vn_from_inode(dir); |
479 | cvp = NULL; | 479 | cvp = NULL; |
480 | 480 | ||
481 | memset(&va, 0, sizeof(va)); | 481 | vattr.va_mode = S_IFLNK | |
482 | va.va_mode = S_IFLNK | | ||
483 | (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); | 482 | (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); |
484 | va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; | 483 | vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE; |
485 | 484 | ||
486 | error = 0; | 485 | error = 0; |
487 | VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); | 486 | VOP_SYMLINK(dvp, dentry, &vattr, (char *)symname, &cvp, NULL, error); |
488 | if (likely(!error && cvp)) { | 487 | if (likely(!error && cvp)) { |
489 | error = linvfs_init_security(cvp, dir); | 488 | error = xfs_init_security(cvp, dir); |
490 | if (likely(!error)) { | 489 | if (likely(!error)) { |
491 | ip = LINVFS_GET_IP(cvp); | 490 | ip = vn_to_inode(cvp); |
492 | d_instantiate(dentry, ip); | 491 | d_instantiate(dentry, ip); |
493 | validate_fields(dir); | 492 | xfs_validate_fields(dir, &vattr); |
494 | validate_fields(ip); | 493 | xfs_validate_fields(ip, &vattr); |
494 | } else { | ||
495 | xfs_cleanup_inode(dvp, cvp, dentry, 0); | ||
495 | } | 496 | } |
496 | } | 497 | } |
497 | return -error; | 498 | return -error; |
498 | } | 499 | } |
499 | 500 | ||
500 | STATIC int | 501 | STATIC int |
501 | linvfs_rmdir( | 502 | xfs_vn_rmdir( |
502 | struct inode *dir, | 503 | struct inode *dir, |
503 | struct dentry *dentry) | 504 | struct dentry *dentry) |
504 | { | 505 | { |
505 | struct inode *inode = dentry->d_inode; | 506 | struct inode *inode = dentry->d_inode; |
506 | vnode_t *dvp = LINVFS_GET_VP(dir); | 507 | vnode_t *dvp = vn_from_inode(dir); |
508 | vattr_t vattr; | ||
507 | int error; | 509 | int error; |
508 | 510 | ||
509 | VOP_RMDIR(dvp, dentry, NULL, error); | 511 | VOP_RMDIR(dvp, dentry, NULL, error); |
510 | if (!error) { | 512 | if (likely(!error)) { |
511 | validate_fields(inode); | 513 | xfs_validate_fields(inode, &vattr); |
512 | validate_fields(dir); | 514 | xfs_validate_fields(dir, &vattr); |
513 | } | 515 | } |
514 | return -error; | 516 | return -error; |
515 | } | 517 | } |
516 | 518 | ||
517 | STATIC int | 519 | STATIC int |
518 | linvfs_rename( | 520 | xfs_vn_rename( |
519 | struct inode *odir, | 521 | struct inode *odir, |
520 | struct dentry *odentry, | 522 | struct dentry *odentry, |
521 | struct inode *ndir, | 523 | struct inode *ndir, |
@@ -524,22 +526,21 @@ linvfs_rename( | |||
524 | struct inode *new_inode = ndentry->d_inode; | 526 | struct inode *new_inode = ndentry->d_inode; |
525 | vnode_t *fvp; /* from directory */ | 527 | vnode_t *fvp; /* from directory */ |
526 | vnode_t *tvp; /* target directory */ | 528 | vnode_t *tvp; /* target directory */ |
529 | vattr_t vattr; | ||
527 | int error; | 530 | int error; |
528 | 531 | ||
529 | fvp = LINVFS_GET_VP(odir); | 532 | fvp = vn_from_inode(odir); |
530 | tvp = LINVFS_GET_VP(ndir); | 533 | tvp = vn_from_inode(ndir); |
531 | 534 | ||
532 | VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error); | 535 | VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error); |
533 | if (error) | 536 | if (likely(!error)) { |
534 | return -error; | 537 | if (new_inode) |
535 | 538 | xfs_validate_fields(new_inode, &vattr); | |
536 | if (new_inode) | 539 | xfs_validate_fields(odir, &vattr); |
537 | validate_fields(new_inode); | 540 | if (ndir != odir) |
538 | 541 | xfs_validate_fields(ndir, &vattr); | |
539 | validate_fields(odir); | 542 | } |
540 | if (ndir != odir) | 543 | return -error; |
541 | validate_fields(ndir); | ||
542 | return 0; | ||
543 | } | 544 | } |
544 | 545 | ||
545 | /* | 546 | /* |
@@ -548,7 +549,7 @@ linvfs_rename( | |||
548 | * uio is kmalloced for this reason... | 549 | * uio is kmalloced for this reason... |
549 | */ | 550 | */ |
550 | STATIC void * | 551 | STATIC void * |
551 | linvfs_follow_link( | 552 | xfs_vn_follow_link( |
552 | struct dentry *dentry, | 553 | struct dentry *dentry, |
553 | struct nameidata *nd) | 554 | struct nameidata *nd) |
554 | { | 555 | { |
@@ -574,7 +575,7 @@ linvfs_follow_link( | |||
574 | return NULL; | 575 | return NULL; |
575 | } | 576 | } |
576 | 577 | ||
577 | vp = LINVFS_GET_VP(dentry->d_inode); | 578 | vp = vn_from_inode(dentry->d_inode); |
578 | 579 | ||
579 | iov.iov_base = link; | 580 | iov.iov_base = link; |
580 | iov.iov_len = MAXPATHLEN; | 581 | iov.iov_len = MAXPATHLEN; |
@@ -599,7 +600,7 @@ linvfs_follow_link( | |||
599 | } | 600 | } |
600 | 601 | ||
601 | STATIC void | 602 | STATIC void |
602 | linvfs_put_link( | 603 | xfs_vn_put_link( |
603 | struct dentry *dentry, | 604 | struct dentry *dentry, |
604 | struct nameidata *nd, | 605 | struct nameidata *nd, |
605 | void *p) | 606 | void *p) |
@@ -612,12 +613,12 @@ linvfs_put_link( | |||
612 | 613 | ||
613 | #ifdef CONFIG_XFS_POSIX_ACL | 614 | #ifdef CONFIG_XFS_POSIX_ACL |
614 | STATIC int | 615 | STATIC int |
615 | linvfs_permission( | 616 | xfs_vn_permission( |
616 | struct inode *inode, | 617 | struct inode *inode, |
617 | int mode, | 618 | int mode, |
618 | struct nameidata *nd) | 619 | struct nameidata *nd) |
619 | { | 620 | { |
620 | vnode_t *vp = LINVFS_GET_VP(inode); | 621 | vnode_t *vp = vn_from_inode(inode); |
621 | int error; | 622 | int error; |
622 | 623 | ||
623 | mode <<= 6; /* convert from linux to vnode access bits */ | 624 | mode <<= 6; /* convert from linux to vnode access bits */ |
@@ -625,17 +626,17 @@ linvfs_permission( | |||
625 | return -error; | 626 | return -error; |
626 | } | 627 | } |
627 | #else | 628 | #else |
628 | #define linvfs_permission NULL | 629 | #define xfs_vn_permission NULL |
629 | #endif | 630 | #endif |
630 | 631 | ||
631 | STATIC int | 632 | STATIC int |
632 | linvfs_getattr( | 633 | xfs_vn_getattr( |
633 | struct vfsmount *mnt, | 634 | struct vfsmount *mnt, |
634 | struct dentry *dentry, | 635 | struct dentry *dentry, |
635 | struct kstat *stat) | 636 | struct kstat *stat) |
636 | { | 637 | { |
637 | struct inode *inode = dentry->d_inode; | 638 | struct inode *inode = dentry->d_inode; |
638 | vnode_t *vp = LINVFS_GET_VP(inode); | 639 | vnode_t *vp = vn_from_inode(inode); |
639 | int error = 0; | 640 | int error = 0; |
640 | 641 | ||
641 | if (unlikely(vp->v_flag & VMODIFIED)) | 642 | if (unlikely(vp->v_flag & VMODIFIED)) |
@@ -646,18 +647,17 @@ linvfs_getattr( | |||
646 | } | 647 | } |
647 | 648 | ||
648 | STATIC int | 649 | STATIC int |
649 | linvfs_setattr( | 650 | xfs_vn_setattr( |
650 | struct dentry *dentry, | 651 | struct dentry *dentry, |
651 | struct iattr *attr) | 652 | struct iattr *attr) |
652 | { | 653 | { |
653 | struct inode *inode = dentry->d_inode; | 654 | struct inode *inode = dentry->d_inode; |
654 | unsigned int ia_valid = attr->ia_valid; | 655 | unsigned int ia_valid = attr->ia_valid; |
655 | vnode_t *vp = LINVFS_GET_VP(inode); | 656 | vnode_t *vp = vn_from_inode(inode); |
656 | vattr_t vattr; | 657 | vattr_t vattr = { 0 }; |
657 | int flags = 0; | 658 | int flags = 0; |
658 | int error; | 659 | int error; |
659 | 660 | ||
660 | memset(&vattr, 0, sizeof(vattr_t)); | ||
661 | if (ia_valid & ATTR_UID) { | 661 | if (ia_valid & ATTR_UID) { |
662 | vattr.va_mask |= XFS_AT_UID; | 662 | vattr.va_mask |= XFS_AT_UID; |
663 | vattr.va_uid = attr->ia_uid; | 663 | vattr.va_uid = attr->ia_uid; |
@@ -699,28 +699,27 @@ linvfs_setattr( | |||
699 | #endif | 699 | #endif |
700 | 700 | ||
701 | VOP_SETATTR(vp, &vattr, flags, NULL, error); | 701 | VOP_SETATTR(vp, &vattr, flags, NULL, error); |
702 | if (error) | 702 | if (likely(!error)) |
703 | return -error; | 703 | __vn_revalidate(vp, &vattr); |
704 | vn_revalidate(vp); | 704 | return -error; |
705 | return error; | ||
706 | } | 705 | } |
707 | 706 | ||
708 | STATIC void | 707 | STATIC void |
709 | linvfs_truncate( | 708 | xfs_vn_truncate( |
710 | struct inode *inode) | 709 | struct inode *inode) |
711 | { | 710 | { |
712 | block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block); | 711 | block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_block); |
713 | } | 712 | } |
714 | 713 | ||
715 | STATIC int | 714 | STATIC int |
716 | linvfs_setxattr( | 715 | xfs_vn_setxattr( |
717 | struct dentry *dentry, | 716 | struct dentry *dentry, |
718 | const char *name, | 717 | const char *name, |
719 | const void *data, | 718 | const void *data, |
720 | size_t size, | 719 | size_t size, |
721 | int flags) | 720 | int flags) |
722 | { | 721 | { |
723 | vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); | 722 | vnode_t *vp = vn_from_inode(dentry->d_inode); |
724 | char *attr = (char *)name; | 723 | char *attr = (char *)name; |
725 | attrnames_t *namesp; | 724 | attrnames_t *namesp; |
726 | int xflags = 0; | 725 | int xflags = 0; |
@@ -744,13 +743,13 @@ linvfs_setxattr( | |||
744 | } | 743 | } |
745 | 744 | ||
746 | STATIC ssize_t | 745 | STATIC ssize_t |
747 | linvfs_getxattr( | 746 | xfs_vn_getxattr( |
748 | struct dentry *dentry, | 747 | struct dentry *dentry, |
749 | const char *name, | 748 | const char *name, |
750 | void *data, | 749 | void *data, |
751 | size_t size) | 750 | size_t size) |
752 | { | 751 | { |
753 | vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); | 752 | vnode_t *vp = vn_from_inode(dentry->d_inode); |
754 | char *attr = (char *)name; | 753 | char *attr = (char *)name; |
755 | attrnames_t *namesp; | 754 | attrnames_t *namesp; |
756 | int xflags = 0; | 755 | int xflags = 0; |
@@ -774,12 +773,12 @@ linvfs_getxattr( | |||
774 | } | 773 | } |
775 | 774 | ||
776 | STATIC ssize_t | 775 | STATIC ssize_t |
777 | linvfs_listxattr( | 776 | xfs_vn_listxattr( |
778 | struct dentry *dentry, | 777 | struct dentry *dentry, |
779 | char *data, | 778 | char *data, |
780 | size_t size) | 779 | size_t size) |
781 | { | 780 | { |
782 | vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); | 781 | vnode_t *vp = vn_from_inode(dentry->d_inode); |
783 | int error, xflags = ATTR_KERNAMELS; | 782 | int error, xflags = ATTR_KERNAMELS; |
784 | ssize_t result; | 783 | ssize_t result; |
785 | 784 | ||
@@ -794,11 +793,11 @@ linvfs_listxattr( | |||
794 | } | 793 | } |
795 | 794 | ||
796 | STATIC int | 795 | STATIC int |
797 | linvfs_removexattr( | 796 | xfs_vn_removexattr( |
798 | struct dentry *dentry, | 797 | struct dentry *dentry, |
799 | const char *name) | 798 | const char *name) |
800 | { | 799 | { |
801 | vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); | 800 | vnode_t *vp = vn_from_inode(dentry->d_inode); |
802 | char *attr = (char *)name; | 801 | char *attr = (char *)name; |
803 | attrnames_t *namesp; | 802 | attrnames_t *namesp; |
804 | int xflags = 0; | 803 | int xflags = 0; |
@@ -816,45 +815,45 @@ linvfs_removexattr( | |||
816 | } | 815 | } |
817 | 816 | ||
818 | 817 | ||
819 | struct inode_operations linvfs_file_inode_operations = { | 818 | struct inode_operations xfs_inode_operations = { |
820 | .permission = linvfs_permission, | 819 | .permission = xfs_vn_permission, |
821 | .truncate = linvfs_truncate, | 820 | .truncate = xfs_vn_truncate, |
822 | .getattr = linvfs_getattr, | 821 | .getattr = xfs_vn_getattr, |
823 | .setattr = linvfs_setattr, | 822 | .setattr = xfs_vn_setattr, |
824 | .setxattr = linvfs_setxattr, | 823 | .setxattr = xfs_vn_setxattr, |
825 | .getxattr = linvfs_getxattr, | 824 | .getxattr = xfs_vn_getxattr, |
826 | .listxattr = linvfs_listxattr, | 825 | .listxattr = xfs_vn_listxattr, |
827 | .removexattr = linvfs_removexattr, | 826 | .removexattr = xfs_vn_removexattr, |
828 | }; | 827 | }; |
829 | 828 | ||
830 | struct inode_operations linvfs_dir_inode_operations = { | 829 | struct inode_operations xfs_dir_inode_operations = { |
831 | .create = linvfs_create, | 830 | .create = xfs_vn_create, |
832 | .lookup = linvfs_lookup, | 831 | .lookup = xfs_vn_lookup, |
833 | .link = linvfs_link, | 832 | .link = xfs_vn_link, |
834 | .unlink = linvfs_unlink, | 833 | .unlink = xfs_vn_unlink, |
835 | .symlink = linvfs_symlink, | 834 | .symlink = xfs_vn_symlink, |
836 | .mkdir = linvfs_mkdir, | 835 | .mkdir = xfs_vn_mkdir, |
837 | .rmdir = linvfs_rmdir, | 836 | .rmdir = xfs_vn_rmdir, |
838 | .mknod = linvfs_mknod, | 837 | .mknod = xfs_vn_mknod, |
839 | .rename = linvfs_rename, | 838 | .rename = xfs_vn_rename, |
840 | .permission = linvfs_permission, | 839 | .permission = xfs_vn_permission, |
841 | .getattr = linvfs_getattr, | 840 | .getattr = xfs_vn_getattr, |
842 | .setattr = linvfs_setattr, | 841 | .setattr = xfs_vn_setattr, |
843 | .setxattr = linvfs_setxattr, | 842 | .setxattr = xfs_vn_setxattr, |
844 | .getxattr = linvfs_getxattr, | 843 | .getxattr = xfs_vn_getxattr, |
845 | .listxattr = linvfs_listxattr, | 844 | .listxattr = xfs_vn_listxattr, |
846 | .removexattr = linvfs_removexattr, | 845 | .removexattr = xfs_vn_removexattr, |
847 | }; | 846 | }; |
848 | 847 | ||
849 | struct inode_operations linvfs_symlink_inode_operations = { | 848 | struct inode_operations xfs_symlink_inode_operations = { |
850 | .readlink = generic_readlink, | 849 | .readlink = generic_readlink, |
851 | .follow_link = linvfs_follow_link, | 850 | .follow_link = xfs_vn_follow_link, |
852 | .put_link = linvfs_put_link, | 851 | .put_link = xfs_vn_put_link, |
853 | .permission = linvfs_permission, | 852 | .permission = xfs_vn_permission, |
854 | .getattr = linvfs_getattr, | 853 | .getattr = xfs_vn_getattr, |
855 | .setattr = linvfs_setattr, | 854 | .setattr = xfs_vn_setattr, |
856 | .setxattr = linvfs_setxattr, | 855 | .setxattr = xfs_vn_setxattr, |
857 | .getxattr = linvfs_getxattr, | 856 | .getxattr = xfs_vn_getxattr, |
858 | .listxattr = linvfs_listxattr, | 857 | .listxattr = xfs_vn_listxattr, |
859 | .removexattr = linvfs_removexattr, | 858 | .removexattr = xfs_vn_removexattr, |
860 | }; | 859 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h index 6899a6b4a50a..a8417d7af5f9 100644 --- a/fs/xfs/linux-2.6/xfs_iops.h +++ b/fs/xfs/linux-2.6/xfs_iops.h | |||
@@ -18,13 +18,13 @@ | |||
18 | #ifndef __XFS_IOPS_H__ | 18 | #ifndef __XFS_IOPS_H__ |
19 | #define __XFS_IOPS_H__ | 19 | #define __XFS_IOPS_H__ |
20 | 20 | ||
21 | extern struct inode_operations linvfs_file_inode_operations; | 21 | extern struct inode_operations xfs_inode_operations; |
22 | extern struct inode_operations linvfs_dir_inode_operations; | 22 | extern struct inode_operations xfs_dir_inode_operations; |
23 | extern struct inode_operations linvfs_symlink_inode_operations; | 23 | extern struct inode_operations xfs_symlink_inode_operations; |
24 | 24 | ||
25 | extern struct file_operations linvfs_file_operations; | 25 | extern struct file_operations xfs_file_operations; |
26 | extern struct file_operations linvfs_invis_file_operations; | 26 | extern struct file_operations xfs_dir_file_operations; |
27 | extern struct file_operations linvfs_dir_operations; | 27 | extern struct file_operations xfs_invis_file_operations; |
28 | 28 | ||
29 | extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, | 29 | extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, |
30 | int, unsigned int, void __user *); | 30 | int, unsigned int, void __user *); |
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index 67389b745526..1fe09f2d6519 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
@@ -73,6 +73,9 @@ | |||
73 | #include <linux/list.h> | 73 | #include <linux/list.h> |
74 | #include <linux/proc_fs.h> | 74 | #include <linux/proc_fs.h> |
75 | #include <linux/sort.h> | 75 | #include <linux/sort.h> |
76 | #include <linux/cpu.h> | ||
77 | #include <linux/notifier.h> | ||
78 | #include <linux/delay.h> | ||
76 | 79 | ||
77 | #include <asm/page.h> | 80 | #include <asm/page.h> |
78 | #include <asm/div64.h> | 81 | #include <asm/div64.h> |
@@ -100,6 +103,11 @@ | |||
100 | */ | 103 | */ |
101 | #undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */ | 104 | #undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */ |
102 | #define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */ | 105 | #define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */ |
106 | #ifdef CONFIG_SMP | ||
107 | #define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */ | ||
108 | #else | ||
109 | #undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */ | ||
110 | #endif | ||
103 | 111 | ||
104 | /* | 112 | /* |
105 | * State flag for unwritten extent buffers. | 113 | * State flag for unwritten extent buffers. |
@@ -226,7 +234,7 @@ BUFFER_FNS(PrivateStart, unwritten); | |||
226 | #define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL) | 234 | #define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL) |
227 | #define xfs_stack_trace() dump_stack() | 235 | #define xfs_stack_trace() dump_stack() |
228 | #define xfs_itruncate_data(ip, off) \ | 236 | #define xfs_itruncate_data(ip, off) \ |
229 | (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) | 237 | (-vmtruncate(vn_to_inode(XFS_ITOV(ip)), (off))) |
230 | #define xfs_statvfs_fsid(statp, mp) \ | 238 | #define xfs_statvfs_fsid(statp, mp) \ |
231 | ({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \ | 239 | ({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \ |
232 | __kernel_fsid_t *fsid = &(statp)->f_fsid; \ | 240 | __kernel_fsid_t *fsid = &(statp)->f_fsid; \ |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index e0ab45fbfebd..0169360475c4 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -83,7 +83,7 @@ xfs_rw_enter_trace( | |||
83 | (void *)((unsigned long)ioflags), | 83 | (void *)((unsigned long)ioflags), |
84 | (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), | 84 | (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), |
85 | (void *)((unsigned long)(io->io_new_size & 0xffffffff)), | 85 | (void *)((unsigned long)(io->io_new_size & 0xffffffff)), |
86 | (void *)NULL, | 86 | (void *)((unsigned long)current_pid()), |
87 | (void *)NULL, | 87 | (void *)NULL, |
88 | (void *)NULL, | 88 | (void *)NULL, |
89 | (void *)NULL, | 89 | (void *)NULL, |
@@ -113,7 +113,7 @@ xfs_inval_cached_trace( | |||
113 | (void *)((unsigned long)(first & 0xffffffff)), | 113 | (void *)((unsigned long)(first & 0xffffffff)), |
114 | (void *)((unsigned long)((last >> 32) & 0xffffffff)), | 114 | (void *)((unsigned long)((last >> 32) & 0xffffffff)), |
115 | (void *)((unsigned long)(last & 0xffffffff)), | 115 | (void *)((unsigned long)(last & 0xffffffff)), |
116 | (void *)NULL, | 116 | (void *)((unsigned long)current_pid()), |
117 | (void *)NULL, | 117 | (void *)NULL, |
118 | (void *)NULL, | 118 | (void *)NULL, |
119 | (void *)NULL, | 119 | (void *)NULL, |
@@ -249,9 +249,8 @@ xfs_read( | |||
249 | if (n < size) | 249 | if (n < size) |
250 | size = n; | 250 | size = n; |
251 | 251 | ||
252 | if (XFS_FORCED_SHUTDOWN(mp)) { | 252 | if (XFS_FORCED_SHUTDOWN(mp)) |
253 | return -EIO; | 253 | return -EIO; |
254 | } | ||
255 | 254 | ||
256 | if (unlikely(ioflags & IO_ISDIRECT)) | 255 | if (unlikely(ioflags & IO_ISDIRECT)) |
257 | mutex_lock(&inode->i_mutex); | 256 | mutex_lock(&inode->i_mutex); |
@@ -267,10 +266,14 @@ xfs_read( | |||
267 | dmflags, &locktype); | 266 | dmflags, &locktype); |
268 | if (ret) { | 267 | if (ret) { |
269 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 268 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
270 | goto unlock_isem; | 269 | goto unlock_mutex; |
271 | } | 270 | } |
272 | } | 271 | } |
273 | 272 | ||
273 | if (unlikely((ioflags & IO_ISDIRECT) && VN_CACHED(vp))) | ||
274 | VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(*offset)), | ||
275 | -1, FI_REMAPF_LOCKED); | ||
276 | |||
274 | xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, | 277 | xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, |
275 | (void *)iovp, segs, *offset, ioflags); | 278 | (void *)iovp, segs, *offset, ioflags); |
276 | ret = __generic_file_aio_read(iocb, iovp, segs, offset); | 279 | ret = __generic_file_aio_read(iocb, iovp, segs, offset); |
@@ -281,7 +284,7 @@ xfs_read( | |||
281 | 284 | ||
282 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 285 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
283 | 286 | ||
284 | unlock_isem: | 287 | unlock_mutex: |
285 | if (unlikely(ioflags & IO_ISDIRECT)) | 288 | if (unlikely(ioflags & IO_ISDIRECT)) |
286 | mutex_unlock(&inode->i_mutex); | 289 | mutex_unlock(&inode->i_mutex); |
287 | return ret; | 290 | return ret; |
@@ -432,7 +435,7 @@ xfs_zero_eof( | |||
432 | xfs_fsize_t isize, /* current inode size */ | 435 | xfs_fsize_t isize, /* current inode size */ |
433 | xfs_fsize_t end_size) /* terminal inode size */ | 436 | xfs_fsize_t end_size) /* terminal inode size */ |
434 | { | 437 | { |
435 | struct inode *ip = LINVFS_GET_IP(vp); | 438 | struct inode *ip = vn_to_inode(vp); |
436 | xfs_fileoff_t start_zero_fsb; | 439 | xfs_fileoff_t start_zero_fsb; |
437 | xfs_fileoff_t end_zero_fsb; | 440 | xfs_fileoff_t end_zero_fsb; |
438 | xfs_fileoff_t zero_count_fsb; | 441 | xfs_fileoff_t zero_count_fsb; |
@@ -573,7 +576,7 @@ xfs_write( | |||
573 | vrwlock_t locktype; | 576 | vrwlock_t locktype; |
574 | size_t ocount = 0, count; | 577 | size_t ocount = 0, count; |
575 | loff_t pos; | 578 | loff_t pos; |
576 | int need_isem = 1, need_flush = 0; | 579 | int need_i_mutex = 1, need_flush = 0; |
577 | 580 | ||
578 | XFS_STATS_INC(xs_write_calls); | 581 | XFS_STATS_INC(xs_write_calls); |
579 | 582 | ||
@@ -622,14 +625,14 @@ xfs_write( | |||
622 | return XFS_ERROR(-EINVAL); | 625 | return XFS_ERROR(-EINVAL); |
623 | 626 | ||
624 | if (!VN_CACHED(vp) && pos < i_size_read(inode)) | 627 | if (!VN_CACHED(vp) && pos < i_size_read(inode)) |
625 | need_isem = 0; | 628 | need_i_mutex = 0; |
626 | 629 | ||
627 | if (VN_CACHED(vp)) | 630 | if (VN_CACHED(vp)) |
628 | need_flush = 1; | 631 | need_flush = 1; |
629 | } | 632 | } |
630 | 633 | ||
631 | relock: | 634 | relock: |
632 | if (need_isem) { | 635 | if (need_i_mutex) { |
633 | iolock = XFS_IOLOCK_EXCL; | 636 | iolock = XFS_IOLOCK_EXCL; |
634 | locktype = VRWLOCK_WRITE; | 637 | locktype = VRWLOCK_WRITE; |
635 | 638 | ||
@@ -651,7 +654,7 @@ start: | |||
651 | S_ISBLK(inode->i_mode)); | 654 | S_ISBLK(inode->i_mode)); |
652 | if (error) { | 655 | if (error) { |
653 | xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); | 656 | xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); |
654 | goto out_unlock_isem; | 657 | goto out_unlock_mutex; |
655 | } | 658 | } |
656 | 659 | ||
657 | new_size = pos + count; | 660 | new_size = pos + count; |
@@ -663,7 +666,7 @@ start: | |||
663 | loff_t savedsize = pos; | 666 | loff_t savedsize = pos; |
664 | int dmflags = FILP_DELAY_FLAG(file); | 667 | int dmflags = FILP_DELAY_FLAG(file); |
665 | 668 | ||
666 | if (need_isem) | 669 | if (need_i_mutex) |
667 | dmflags |= DM_FLAGS_IMUX; | 670 | dmflags |= DM_FLAGS_IMUX; |
668 | 671 | ||
669 | xfs_iunlock(xip, XFS_ILOCK_EXCL); | 672 | xfs_iunlock(xip, XFS_ILOCK_EXCL); |
@@ -672,7 +675,7 @@ start: | |||
672 | dmflags, &locktype); | 675 | dmflags, &locktype); |
673 | if (error) { | 676 | if (error) { |
674 | xfs_iunlock(xip, iolock); | 677 | xfs_iunlock(xip, iolock); |
675 | goto out_unlock_isem; | 678 | goto out_unlock_mutex; |
676 | } | 679 | } |
677 | xfs_ilock(xip, XFS_ILOCK_EXCL); | 680 | xfs_ilock(xip, XFS_ILOCK_EXCL); |
678 | eventsent = 1; | 681 | eventsent = 1; |
@@ -710,7 +713,7 @@ start: | |||
710 | isize, pos + count); | 713 | isize, pos + count); |
711 | if (error) { | 714 | if (error) { |
712 | xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); | 715 | xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); |
713 | goto out_unlock_isem; | 716 | goto out_unlock_mutex; |
714 | } | 717 | } |
715 | } | 718 | } |
716 | xfs_iunlock(xip, XFS_ILOCK_EXCL); | 719 | xfs_iunlock(xip, XFS_ILOCK_EXCL); |
@@ -731,7 +734,7 @@ start: | |||
731 | error = -remove_suid(file->f_dentry); | 734 | error = -remove_suid(file->f_dentry); |
732 | if (unlikely(error)) { | 735 | if (unlikely(error)) { |
733 | xfs_iunlock(xip, iolock); | 736 | xfs_iunlock(xip, iolock); |
734 | goto out_unlock_isem; | 737 | goto out_unlock_mutex; |
735 | } | 738 | } |
736 | } | 739 | } |
737 | 740 | ||
@@ -747,14 +750,14 @@ retry: | |||
747 | -1, FI_REMAPF_LOCKED); | 750 | -1, FI_REMAPF_LOCKED); |
748 | } | 751 | } |
749 | 752 | ||
750 | if (need_isem) { | 753 | if (need_i_mutex) { |
751 | /* demote the lock now the cached pages are gone */ | 754 | /* demote the lock now the cached pages are gone */ |
752 | XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL); | 755 | XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL); |
753 | mutex_unlock(&inode->i_mutex); | 756 | mutex_unlock(&inode->i_mutex); |
754 | 757 | ||
755 | iolock = XFS_IOLOCK_SHARED; | 758 | iolock = XFS_IOLOCK_SHARED; |
756 | locktype = VRWLOCK_WRITE_DIRECT; | 759 | locktype = VRWLOCK_WRITE_DIRECT; |
757 | need_isem = 0; | 760 | need_i_mutex = 0; |
758 | } | 761 | } |
759 | 762 | ||
760 | xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs, | 763 | xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs, |
@@ -772,7 +775,7 @@ retry: | |||
772 | pos += ret; | 775 | pos += ret; |
773 | count -= ret; | 776 | count -= ret; |
774 | 777 | ||
775 | need_isem = 1; | 778 | need_i_mutex = 1; |
776 | ioflags &= ~IO_ISDIRECT; | 779 | ioflags &= ~IO_ISDIRECT; |
777 | xfs_iunlock(xip, iolock); | 780 | xfs_iunlock(xip, iolock); |
778 | goto relock; | 781 | goto relock; |
@@ -794,14 +797,14 @@ retry: | |||
794 | !(ioflags & IO_INVIS)) { | 797 | !(ioflags & IO_INVIS)) { |
795 | 798 | ||
796 | xfs_rwunlock(bdp, locktype); | 799 | xfs_rwunlock(bdp, locktype); |
797 | if (need_isem) | 800 | if (need_i_mutex) |
798 | mutex_unlock(&inode->i_mutex); | 801 | mutex_unlock(&inode->i_mutex); |
799 | error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, | 802 | error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, |
800 | DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, | 803 | DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, |
801 | 0, 0, 0); /* Delay flag intentionally unused */ | 804 | 0, 0, 0); /* Delay flag intentionally unused */ |
802 | if (error) | 805 | if (error) |
803 | goto out_nounlocks; | 806 | goto out_nounlocks; |
804 | if (need_isem) | 807 | if (need_i_mutex) |
805 | mutex_lock(&inode->i_mutex); | 808 | mutex_lock(&inode->i_mutex); |
806 | xfs_rwlock(bdp, locktype); | 809 | xfs_rwlock(bdp, locktype); |
807 | pos = xip->i_d.di_size; | 810 | pos = xip->i_d.di_size; |
@@ -905,9 +908,9 @@ retry: | |||
905 | if (error) | 908 | if (error) |
906 | goto out_unlock_internal; | 909 | goto out_unlock_internal; |
907 | } | 910 | } |
908 | 911 | ||
909 | xfs_rwunlock(bdp, locktype); | 912 | xfs_rwunlock(bdp, locktype); |
910 | if (need_isem) | 913 | if (need_i_mutex) |
911 | mutex_unlock(&inode->i_mutex); | 914 | mutex_unlock(&inode->i_mutex); |
912 | 915 | ||
913 | error = sync_page_range(inode, mapping, pos, ret); | 916 | error = sync_page_range(inode, mapping, pos, ret); |
@@ -918,8 +921,8 @@ retry: | |||
918 | 921 | ||
919 | out_unlock_internal: | 922 | out_unlock_internal: |
920 | xfs_rwunlock(bdp, locktype); | 923 | xfs_rwunlock(bdp, locktype); |
921 | out_unlock_isem: | 924 | out_unlock_mutex: |
922 | if (need_isem) | 925 | if (need_i_mutex) |
923 | mutex_unlock(&inode->i_mutex); | 926 | mutex_unlock(&inode->i_mutex); |
924 | out_nounlocks: | 927 | out_nounlocks: |
925 | return -error; | 928 | return -error; |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index f22e426d9e42..8355faf8ffde 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -59,8 +59,8 @@ | |||
59 | #include <linux/writeback.h> | 59 | #include <linux/writeback.h> |
60 | #include <linux/kthread.h> | 60 | #include <linux/kthread.h> |
61 | 61 | ||
62 | STATIC struct quotactl_ops linvfs_qops; | 62 | STATIC struct quotactl_ops xfs_quotactl_operations; |
63 | STATIC struct super_operations linvfs_sops; | 63 | STATIC struct super_operations xfs_super_operations; |
64 | STATIC kmem_zone_t *xfs_vnode_zone; | 64 | STATIC kmem_zone_t *xfs_vnode_zone; |
65 | STATIC kmem_zone_t *xfs_ioend_zone; | 65 | STATIC kmem_zone_t *xfs_ioend_zone; |
66 | mempool_t *xfs_ioend_pool; | 66 | mempool_t *xfs_ioend_pool; |
@@ -76,8 +76,6 @@ xfs_args_allocate( | |||
76 | strncpy(args->fsname, sb->s_id, MAXNAMELEN); | 76 | strncpy(args->fsname, sb->s_id, MAXNAMELEN); |
77 | 77 | ||
78 | /* Copy the already-parsed mount(2) flags we're interested in */ | 78 | /* Copy the already-parsed mount(2) flags we're interested in */ |
79 | if (sb->s_flags & MS_NOATIME) | ||
80 | args->flags |= XFSMNT_NOATIME; | ||
81 | if (sb->s_flags & MS_DIRSYNC) | 79 | if (sb->s_flags & MS_DIRSYNC) |
82 | args->flags |= XFSMNT_DIRSYNC; | 80 | args->flags |= XFSMNT_DIRSYNC; |
83 | if (sb->s_flags & MS_SYNCHRONOUS) | 81 | if (sb->s_flags & MS_SYNCHRONOUS) |
@@ -129,21 +127,21 @@ xfs_set_inodeops( | |||
129 | { | 127 | { |
130 | switch (inode->i_mode & S_IFMT) { | 128 | switch (inode->i_mode & S_IFMT) { |
131 | case S_IFREG: | 129 | case S_IFREG: |
132 | inode->i_op = &linvfs_file_inode_operations; | 130 | inode->i_op = &xfs_inode_operations; |
133 | inode->i_fop = &linvfs_file_operations; | 131 | inode->i_fop = &xfs_file_operations; |
134 | inode->i_mapping->a_ops = &linvfs_aops; | 132 | inode->i_mapping->a_ops = &xfs_address_space_operations; |
135 | break; | 133 | break; |
136 | case S_IFDIR: | 134 | case S_IFDIR: |
137 | inode->i_op = &linvfs_dir_inode_operations; | 135 | inode->i_op = &xfs_dir_inode_operations; |
138 | inode->i_fop = &linvfs_dir_operations; | 136 | inode->i_fop = &xfs_dir_file_operations; |
139 | break; | 137 | break; |
140 | case S_IFLNK: | 138 | case S_IFLNK: |
141 | inode->i_op = &linvfs_symlink_inode_operations; | 139 | inode->i_op = &xfs_symlink_inode_operations; |
142 | if (inode->i_blocks) | 140 | if (inode->i_blocks) |
143 | inode->i_mapping->a_ops = &linvfs_aops; | 141 | inode->i_mapping->a_ops = &xfs_address_space_operations; |
144 | break; | 142 | break; |
145 | default: | 143 | default: |
146 | inode->i_op = &linvfs_file_inode_operations; | 144 | inode->i_op = &xfs_inode_operations; |
147 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 145 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
148 | break; | 146 | break; |
149 | } | 147 | } |
@@ -155,7 +153,7 @@ xfs_revalidate_inode( | |||
155 | vnode_t *vp, | 153 | vnode_t *vp, |
156 | xfs_inode_t *ip) | 154 | xfs_inode_t *ip) |
157 | { | 155 | { |
158 | struct inode *inode = LINVFS_GET_IP(vp); | 156 | struct inode *inode = vn_to_inode(vp); |
159 | 157 | ||
160 | inode->i_mode = ip->i_d.di_mode; | 158 | inode->i_mode = ip->i_d.di_mode; |
161 | inode->i_nlink = ip->i_d.di_nlink; | 159 | inode->i_nlink = ip->i_d.di_nlink; |
@@ -212,7 +210,7 @@ xfs_initialize_vnode( | |||
212 | int unlock) | 210 | int unlock) |
213 | { | 211 | { |
214 | xfs_inode_t *ip = XFS_BHVTOI(inode_bhv); | 212 | xfs_inode_t *ip = XFS_BHVTOI(inode_bhv); |
215 | struct inode *inode = LINVFS_GET_IP(vp); | 213 | struct inode *inode = vn_to_inode(vp); |
216 | 214 | ||
217 | if (!inode_bhv->bd_vobj) { | 215 | if (!inode_bhv->bd_vobj) { |
218 | vp->v_vfsp = bhvtovfs(bdp); | 216 | vp->v_vfsp = bhvtovfs(bdp); |
@@ -230,7 +228,7 @@ xfs_initialize_vnode( | |||
230 | if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) { | 228 | if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) { |
231 | xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); | 229 | xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); |
232 | xfs_set_inodeops(inode); | 230 | xfs_set_inodeops(inode); |
233 | 231 | ||
234 | ip->i_flags &= ~XFS_INEW; | 232 | ip->i_flags &= ~XFS_INEW; |
235 | barrier(); | 233 | barrier(); |
236 | 234 | ||
@@ -334,43 +332,42 @@ xfs_blkdev_issue_flush( | |||
334 | } | 332 | } |
335 | 333 | ||
336 | STATIC struct inode * | 334 | STATIC struct inode * |
337 | linvfs_alloc_inode( | 335 | xfs_fs_alloc_inode( |
338 | struct super_block *sb) | 336 | struct super_block *sb) |
339 | { | 337 | { |
340 | vnode_t *vp; | 338 | vnode_t *vp; |
341 | 339 | ||
342 | vp = kmem_cache_alloc(xfs_vnode_zone, kmem_flags_convert(KM_SLEEP)); | 340 | vp = kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP); |
343 | if (!vp) | 341 | if (unlikely(!vp)) |
344 | return NULL; | 342 | return NULL; |
345 | return LINVFS_GET_IP(vp); | 343 | return vn_to_inode(vp); |
346 | } | 344 | } |
347 | 345 | ||
348 | STATIC void | 346 | STATIC void |
349 | linvfs_destroy_inode( | 347 | xfs_fs_destroy_inode( |
350 | struct inode *inode) | 348 | struct inode *inode) |
351 | { | 349 | { |
352 | kmem_zone_free(xfs_vnode_zone, LINVFS_GET_VP(inode)); | 350 | kmem_zone_free(xfs_vnode_zone, vn_from_inode(inode)); |
353 | } | 351 | } |
354 | 352 | ||
355 | STATIC void | 353 | STATIC void |
356 | linvfs_inode_init_once( | 354 | xfs_fs_inode_init_once( |
357 | void *data, | 355 | void *vnode, |
358 | kmem_cache_t *cachep, | 356 | kmem_zone_t *zonep, |
359 | unsigned long flags) | 357 | unsigned long flags) |
360 | { | 358 | { |
361 | vnode_t *vp = (vnode_t *)data; | ||
362 | |||
363 | if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == | 359 | if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == |
364 | SLAB_CTOR_CONSTRUCTOR) | 360 | SLAB_CTOR_CONSTRUCTOR) |
365 | inode_init_once(LINVFS_GET_IP(vp)); | 361 | inode_init_once(vn_to_inode((vnode_t *)vnode)); |
366 | } | 362 | } |
367 | 363 | ||
368 | STATIC int | 364 | STATIC int |
369 | linvfs_init_zones(void) | 365 | xfs_init_zones(void) |
370 | { | 366 | { |
371 | xfs_vnode_zone = kmem_cache_create("xfs_vnode", | 367 | xfs_vnode_zone = kmem_zone_init_flags(sizeof(vnode_t), "xfs_vnode_t", |
372 | sizeof(vnode_t), 0, SLAB_RECLAIM_ACCOUNT, | 368 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | |
373 | linvfs_inode_init_once, NULL); | 369 | KM_ZONE_SPREAD, |
370 | xfs_fs_inode_init_once); | ||
374 | if (!xfs_vnode_zone) | 371 | if (!xfs_vnode_zone) |
375 | goto out; | 372 | goto out; |
376 | 373 | ||
@@ -379,14 +376,12 @@ linvfs_init_zones(void) | |||
379 | goto out_destroy_vnode_zone; | 376 | goto out_destroy_vnode_zone; |
380 | 377 | ||
381 | xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE, | 378 | xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE, |
382 | mempool_alloc_slab, mempool_free_slab, | 379 | mempool_alloc_slab, mempool_free_slab, |
383 | xfs_ioend_zone); | 380 | xfs_ioend_zone); |
384 | if (!xfs_ioend_pool) | 381 | if (!xfs_ioend_pool) |
385 | goto out_free_ioend_zone; | 382 | goto out_free_ioend_zone; |
386 | |||
387 | return 0; | 383 | return 0; |
388 | 384 | ||
389 | |||
390 | out_free_ioend_zone: | 385 | out_free_ioend_zone: |
391 | kmem_zone_destroy(xfs_ioend_zone); | 386 | kmem_zone_destroy(xfs_ioend_zone); |
392 | out_destroy_vnode_zone: | 387 | out_destroy_vnode_zone: |
@@ -396,7 +391,7 @@ linvfs_init_zones(void) | |||
396 | } | 391 | } |
397 | 392 | ||
398 | STATIC void | 393 | STATIC void |
399 | linvfs_destroy_zones(void) | 394 | xfs_destroy_zones(void) |
400 | { | 395 | { |
401 | mempool_destroy(xfs_ioend_pool); | 396 | mempool_destroy(xfs_ioend_pool); |
402 | kmem_zone_destroy(xfs_vnode_zone); | 397 | kmem_zone_destroy(xfs_vnode_zone); |
@@ -407,14 +402,14 @@ linvfs_destroy_zones(void) | |||
407 | * Attempt to flush the inode, this will actually fail | 402 | * Attempt to flush the inode, this will actually fail |
408 | * if the inode is pinned, but we dirty the inode again | 403 | * if the inode is pinned, but we dirty the inode again |
409 | * at the point when it is unpinned after a log write, | 404 | * at the point when it is unpinned after a log write, |
410 | * since this is when the inode itself becomes flushable. | 405 | * since this is when the inode itself becomes flushable. |
411 | */ | 406 | */ |
412 | STATIC int | 407 | STATIC int |
413 | linvfs_write_inode( | 408 | xfs_fs_write_inode( |
414 | struct inode *inode, | 409 | struct inode *inode, |
415 | int sync) | 410 | int sync) |
416 | { | 411 | { |
417 | vnode_t *vp = LINVFS_GET_VP(inode); | 412 | vnode_t *vp = vn_from_inode(inode); |
418 | int error = 0, flags = FLUSH_INODE; | 413 | int error = 0, flags = FLUSH_INODE; |
419 | 414 | ||
420 | if (vp) { | 415 | if (vp) { |
@@ -434,13 +429,13 @@ linvfs_write_inode( | |||
434 | } | 429 | } |
435 | 430 | ||
436 | STATIC void | 431 | STATIC void |
437 | linvfs_clear_inode( | 432 | xfs_fs_clear_inode( |
438 | struct inode *inode) | 433 | struct inode *inode) |
439 | { | 434 | { |
440 | vnode_t *vp = LINVFS_GET_VP(inode); | 435 | vnode_t *vp = vn_from_inode(inode); |
441 | int error, cache; | 436 | int error, cache; |
442 | 437 | ||
443 | vn_trace_entry(vp, "clear_inode", (inst_t *)__return_address); | 438 | vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); |
444 | 439 | ||
445 | XFS_STATS_INC(vn_rele); | 440 | XFS_STATS_INC(vn_rele); |
446 | XFS_STATS_INC(vn_remove); | 441 | XFS_STATS_INC(vn_remove); |
@@ -516,7 +511,7 @@ void | |||
516 | xfs_flush_inode( | 511 | xfs_flush_inode( |
517 | xfs_inode_t *ip) | 512 | xfs_inode_t *ip) |
518 | { | 513 | { |
519 | struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); | 514 | struct inode *inode = vn_to_inode(XFS_ITOV(ip)); |
520 | struct vfs *vfs = XFS_MTOVFS(ip->i_mount); | 515 | struct vfs *vfs = XFS_MTOVFS(ip->i_mount); |
521 | 516 | ||
522 | igrab(inode); | 517 | igrab(inode); |
@@ -541,7 +536,7 @@ void | |||
541 | xfs_flush_device( | 536 | xfs_flush_device( |
542 | xfs_inode_t *ip) | 537 | xfs_inode_t *ip) |
543 | { | 538 | { |
544 | struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); | 539 | struct inode *inode = vn_to_inode(XFS_ITOV(ip)); |
545 | struct vfs *vfs = XFS_MTOVFS(ip->i_mount); | 540 | struct vfs *vfs = XFS_MTOVFS(ip->i_mount); |
546 | 541 | ||
547 | igrab(inode); | 542 | igrab(inode); |
@@ -550,7 +545,7 @@ xfs_flush_device( | |||
550 | xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); | 545 | xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); |
551 | } | 546 | } |
552 | 547 | ||
553 | #define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR) | 548 | #define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR|SYNC_REFCACHE) |
554 | STATIC void | 549 | STATIC void |
555 | vfs_sync_worker( | 550 | vfs_sync_worker( |
556 | vfs_t *vfsp, | 551 | vfs_t *vfsp, |
@@ -613,7 +608,7 @@ xfssyncd( | |||
613 | } | 608 | } |
614 | 609 | ||
615 | STATIC int | 610 | STATIC int |
616 | linvfs_start_syncd( | 611 | xfs_fs_start_syncd( |
617 | vfs_t *vfsp) | 612 | vfs_t *vfsp) |
618 | { | 613 | { |
619 | vfsp->vfs_sync_work.w_syncer = vfs_sync_worker; | 614 | vfsp->vfs_sync_work.w_syncer = vfs_sync_worker; |
@@ -625,20 +620,20 @@ linvfs_start_syncd( | |||
625 | } | 620 | } |
626 | 621 | ||
627 | STATIC void | 622 | STATIC void |
628 | linvfs_stop_syncd( | 623 | xfs_fs_stop_syncd( |
629 | vfs_t *vfsp) | 624 | vfs_t *vfsp) |
630 | { | 625 | { |
631 | kthread_stop(vfsp->vfs_sync_task); | 626 | kthread_stop(vfsp->vfs_sync_task); |
632 | } | 627 | } |
633 | 628 | ||
634 | STATIC void | 629 | STATIC void |
635 | linvfs_put_super( | 630 | xfs_fs_put_super( |
636 | struct super_block *sb) | 631 | struct super_block *sb) |
637 | { | 632 | { |
638 | vfs_t *vfsp = LINVFS_GET_VFS(sb); | 633 | vfs_t *vfsp = vfs_from_sb(sb); |
639 | int error; | 634 | int error; |
640 | 635 | ||
641 | linvfs_stop_syncd(vfsp); | 636 | xfs_fs_stop_syncd(vfsp); |
642 | VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error); | 637 | VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error); |
643 | if (!error) | 638 | if (!error) |
644 | VFS_UNMOUNT(vfsp, 0, NULL, error); | 639 | VFS_UNMOUNT(vfsp, 0, NULL, error); |
@@ -652,10 +647,10 @@ linvfs_put_super( | |||
652 | } | 647 | } |
653 | 648 | ||
654 | STATIC void | 649 | STATIC void |
655 | linvfs_write_super( | 650 | xfs_fs_write_super( |
656 | struct super_block *sb) | 651 | struct super_block *sb) |
657 | { | 652 | { |
658 | vfs_t *vfsp = LINVFS_GET_VFS(sb); | 653 | vfs_t *vfsp = vfs_from_sb(sb); |
659 | int error; | 654 | int error; |
660 | 655 | ||
661 | if (sb->s_flags & MS_RDONLY) { | 656 | if (sb->s_flags & MS_RDONLY) { |
@@ -668,11 +663,11 @@ linvfs_write_super( | |||
668 | } | 663 | } |
669 | 664 | ||
670 | STATIC int | 665 | STATIC int |
671 | linvfs_sync_super( | 666 | xfs_fs_sync_super( |
672 | struct super_block *sb, | 667 | struct super_block *sb, |
673 | int wait) | 668 | int wait) |
674 | { | 669 | { |
675 | vfs_t *vfsp = LINVFS_GET_VFS(sb); | 670 | vfs_t *vfsp = vfs_from_sb(sb); |
676 | int error; | 671 | int error; |
677 | int flags = SYNC_FSDATA; | 672 | int flags = SYNC_FSDATA; |
678 | 673 | ||
@@ -707,11 +702,11 @@ linvfs_sync_super( | |||
707 | } | 702 | } |
708 | 703 | ||
709 | STATIC int | 704 | STATIC int |
710 | linvfs_statfs( | 705 | xfs_fs_statfs( |
711 | struct super_block *sb, | 706 | struct super_block *sb, |
712 | struct kstatfs *statp) | 707 | struct kstatfs *statp) |
713 | { | 708 | { |
714 | vfs_t *vfsp = LINVFS_GET_VFS(sb); | 709 | vfs_t *vfsp = vfs_from_sb(sb); |
715 | int error; | 710 | int error; |
716 | 711 | ||
717 | VFS_STATVFS(vfsp, statp, NULL, error); | 712 | VFS_STATVFS(vfsp, statp, NULL, error); |
@@ -719,12 +714,12 @@ linvfs_statfs( | |||
719 | } | 714 | } |
720 | 715 | ||
721 | STATIC int | 716 | STATIC int |
722 | linvfs_remount( | 717 | xfs_fs_remount( |
723 | struct super_block *sb, | 718 | struct super_block *sb, |
724 | int *flags, | 719 | int *flags, |
725 | char *options) | 720 | char *options) |
726 | { | 721 | { |
727 | vfs_t *vfsp = LINVFS_GET_VFS(sb); | 722 | vfs_t *vfsp = vfs_from_sb(sb); |
728 | struct xfs_mount_args *args = xfs_args_allocate(sb); | 723 | struct xfs_mount_args *args = xfs_args_allocate(sb); |
729 | int error; | 724 | int error; |
730 | 725 | ||
@@ -736,18 +731,18 @@ linvfs_remount( | |||
736 | } | 731 | } |
737 | 732 | ||
738 | STATIC void | 733 | STATIC void |
739 | linvfs_freeze_fs( | 734 | xfs_fs_lockfs( |
740 | struct super_block *sb) | 735 | struct super_block *sb) |
741 | { | 736 | { |
742 | VFS_FREEZE(LINVFS_GET_VFS(sb)); | 737 | VFS_FREEZE(vfs_from_sb(sb)); |
743 | } | 738 | } |
744 | 739 | ||
745 | STATIC int | 740 | STATIC int |
746 | linvfs_show_options( | 741 | xfs_fs_show_options( |
747 | struct seq_file *m, | 742 | struct seq_file *m, |
748 | struct vfsmount *mnt) | 743 | struct vfsmount *mnt) |
749 | { | 744 | { |
750 | struct vfs *vfsp = LINVFS_GET_VFS(mnt->mnt_sb); | 745 | struct vfs *vfsp = vfs_from_sb(mnt->mnt_sb); |
751 | int error; | 746 | int error; |
752 | 747 | ||
753 | VFS_SHOWARGS(vfsp, m, error); | 748 | VFS_SHOWARGS(vfsp, m, error); |
@@ -755,11 +750,11 @@ linvfs_show_options( | |||
755 | } | 750 | } |
756 | 751 | ||
757 | STATIC int | 752 | STATIC int |
758 | linvfs_quotasync( | 753 | xfs_fs_quotasync( |
759 | struct super_block *sb, | 754 | struct super_block *sb, |
760 | int type) | 755 | int type) |
761 | { | 756 | { |
762 | struct vfs *vfsp = LINVFS_GET_VFS(sb); | 757 | struct vfs *vfsp = vfs_from_sb(sb); |
763 | int error; | 758 | int error; |
764 | 759 | ||
765 | VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error); | 760 | VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error); |
@@ -767,11 +762,11 @@ linvfs_quotasync( | |||
767 | } | 762 | } |
768 | 763 | ||
769 | STATIC int | 764 | STATIC int |
770 | linvfs_getxstate( | 765 | xfs_fs_getxstate( |
771 | struct super_block *sb, | 766 | struct super_block *sb, |
772 | struct fs_quota_stat *fqs) | 767 | struct fs_quota_stat *fqs) |
773 | { | 768 | { |
774 | struct vfs *vfsp = LINVFS_GET_VFS(sb); | 769 | struct vfs *vfsp = vfs_from_sb(sb); |
775 | int error; | 770 | int error; |
776 | 771 | ||
777 | VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error); | 772 | VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error); |
@@ -779,12 +774,12 @@ linvfs_getxstate( | |||
779 | } | 774 | } |
780 | 775 | ||
781 | STATIC int | 776 | STATIC int |
782 | linvfs_setxstate( | 777 | xfs_fs_setxstate( |
783 | struct super_block *sb, | 778 | struct super_block *sb, |
784 | unsigned int flags, | 779 | unsigned int flags, |
785 | int op) | 780 | int op) |
786 | { | 781 | { |
787 | struct vfs *vfsp = LINVFS_GET_VFS(sb); | 782 | struct vfs *vfsp = vfs_from_sb(sb); |
788 | int error; | 783 | int error; |
789 | 784 | ||
790 | VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error); | 785 | VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error); |
@@ -792,13 +787,13 @@ linvfs_setxstate( | |||
792 | } | 787 | } |
793 | 788 | ||
794 | STATIC int | 789 | STATIC int |
795 | linvfs_getxquota( | 790 | xfs_fs_getxquota( |
796 | struct super_block *sb, | 791 | struct super_block *sb, |
797 | int type, | 792 | int type, |
798 | qid_t id, | 793 | qid_t id, |
799 | struct fs_disk_quota *fdq) | 794 | struct fs_disk_quota *fdq) |
800 | { | 795 | { |
801 | struct vfs *vfsp = LINVFS_GET_VFS(sb); | 796 | struct vfs *vfsp = vfs_from_sb(sb); |
802 | int error, getmode; | 797 | int error, getmode; |
803 | 798 | ||
804 | getmode = (type == USRQUOTA) ? Q_XGETQUOTA : | 799 | getmode = (type == USRQUOTA) ? Q_XGETQUOTA : |
@@ -808,13 +803,13 @@ linvfs_getxquota( | |||
808 | } | 803 | } |
809 | 804 | ||
810 | STATIC int | 805 | STATIC int |
811 | linvfs_setxquota( | 806 | xfs_fs_setxquota( |
812 | struct super_block *sb, | 807 | struct super_block *sb, |
813 | int type, | 808 | int type, |
814 | qid_t id, | 809 | qid_t id, |
815 | struct fs_disk_quota *fdq) | 810 | struct fs_disk_quota *fdq) |
816 | { | 811 | { |
817 | struct vfs *vfsp = LINVFS_GET_VFS(sb); | 812 | struct vfs *vfsp = vfs_from_sb(sb); |
818 | int error, setmode; | 813 | int error, setmode; |
819 | 814 | ||
820 | setmode = (type == USRQUOTA) ? Q_XSETQLIM : | 815 | setmode = (type == USRQUOTA) ? Q_XSETQLIM : |
@@ -824,21 +819,17 @@ linvfs_setxquota( | |||
824 | } | 819 | } |
825 | 820 | ||
826 | STATIC int | 821 | STATIC int |
827 | linvfs_fill_super( | 822 | xfs_fs_fill_super( |
828 | struct super_block *sb, | 823 | struct super_block *sb, |
829 | void *data, | 824 | void *data, |
830 | int silent) | 825 | int silent) |
831 | { | 826 | { |
832 | vnode_t *rootvp; | 827 | vnode_t *rootvp; |
833 | struct vfs *vfsp = vfs_allocate(); | 828 | struct vfs *vfsp = vfs_allocate(sb); |
834 | struct xfs_mount_args *args = xfs_args_allocate(sb); | 829 | struct xfs_mount_args *args = xfs_args_allocate(sb); |
835 | struct kstatfs statvfs; | 830 | struct kstatfs statvfs; |
836 | int error, error2; | 831 | int error, error2; |
837 | 832 | ||
838 | vfsp->vfs_super = sb; | ||
839 | LINVFS_SET_VFS(sb, vfsp); | ||
840 | if (sb->s_flags & MS_RDONLY) | ||
841 | vfsp->vfs_flag |= VFS_RDONLY; | ||
842 | bhv_insert_all_vfsops(vfsp); | 833 | bhv_insert_all_vfsops(vfsp); |
843 | 834 | ||
844 | VFS_PARSEARGS(vfsp, (char *)data, args, 0, error); | 835 | VFS_PARSEARGS(vfsp, (char *)data, args, 0, error); |
@@ -849,10 +840,10 @@ linvfs_fill_super( | |||
849 | 840 | ||
850 | sb_min_blocksize(sb, BBSIZE); | 841 | sb_min_blocksize(sb, BBSIZE); |
851 | #ifdef CONFIG_XFS_EXPORT | 842 | #ifdef CONFIG_XFS_EXPORT |
852 | sb->s_export_op = &linvfs_export_ops; | 843 | sb->s_export_op = &xfs_export_operations; |
853 | #endif | 844 | #endif |
854 | sb->s_qcop = &linvfs_qops; | 845 | sb->s_qcop = &xfs_quotactl_operations; |
855 | sb->s_op = &linvfs_sops; | 846 | sb->s_op = &xfs_super_operations; |
856 | 847 | ||
857 | VFS_MOUNT(vfsp, args, NULL, error); | 848 | VFS_MOUNT(vfsp, args, NULL, error); |
858 | if (error) { | 849 | if (error) { |
@@ -876,7 +867,7 @@ linvfs_fill_super( | |||
876 | if (error) | 867 | if (error) |
877 | goto fail_unmount; | 868 | goto fail_unmount; |
878 | 869 | ||
879 | sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp)); | 870 | sb->s_root = d_alloc_root(vn_to_inode(rootvp)); |
880 | if (!sb->s_root) { | 871 | if (!sb->s_root) { |
881 | error = ENOMEM; | 872 | error = ENOMEM; |
882 | goto fail_vnrele; | 873 | goto fail_vnrele; |
@@ -885,7 +876,7 @@ linvfs_fill_super( | |||
885 | error = EINVAL; | 876 | error = EINVAL; |
886 | goto fail_vnrele; | 877 | goto fail_vnrele; |
887 | } | 878 | } |
888 | if ((error = linvfs_start_syncd(vfsp))) | 879 | if ((error = xfs_fs_start_syncd(vfsp))) |
889 | goto fail_vnrele; | 880 | goto fail_vnrele; |
890 | vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address); | 881 | vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address); |
891 | 882 | ||
@@ -910,41 +901,41 @@ fail_vfsop: | |||
910 | } | 901 | } |
911 | 902 | ||
912 | STATIC struct super_block * | 903 | STATIC struct super_block * |
913 | linvfs_get_sb( | 904 | xfs_fs_get_sb( |
914 | struct file_system_type *fs_type, | 905 | struct file_system_type *fs_type, |
915 | int flags, | 906 | int flags, |
916 | const char *dev_name, | 907 | const char *dev_name, |
917 | void *data) | 908 | void *data) |
918 | { | 909 | { |
919 | return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super); | 910 | return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super); |
920 | } | 911 | } |
921 | 912 | ||
922 | STATIC struct super_operations linvfs_sops = { | 913 | STATIC struct super_operations xfs_super_operations = { |
923 | .alloc_inode = linvfs_alloc_inode, | 914 | .alloc_inode = xfs_fs_alloc_inode, |
924 | .destroy_inode = linvfs_destroy_inode, | 915 | .destroy_inode = xfs_fs_destroy_inode, |
925 | .write_inode = linvfs_write_inode, | 916 | .write_inode = xfs_fs_write_inode, |
926 | .clear_inode = linvfs_clear_inode, | 917 | .clear_inode = xfs_fs_clear_inode, |
927 | .put_super = linvfs_put_super, | 918 | .put_super = xfs_fs_put_super, |
928 | .write_super = linvfs_write_super, | 919 | .write_super = xfs_fs_write_super, |
929 | .sync_fs = linvfs_sync_super, | 920 | .sync_fs = xfs_fs_sync_super, |
930 | .write_super_lockfs = linvfs_freeze_fs, | 921 | .write_super_lockfs = xfs_fs_lockfs, |
931 | .statfs = linvfs_statfs, | 922 | .statfs = xfs_fs_statfs, |
932 | .remount_fs = linvfs_remount, | 923 | .remount_fs = xfs_fs_remount, |
933 | .show_options = linvfs_show_options, | 924 | .show_options = xfs_fs_show_options, |
934 | }; | 925 | }; |
935 | 926 | ||
936 | STATIC struct quotactl_ops linvfs_qops = { | 927 | STATIC struct quotactl_ops xfs_quotactl_operations = { |
937 | .quota_sync = linvfs_quotasync, | 928 | .quota_sync = xfs_fs_quotasync, |
938 | .get_xstate = linvfs_getxstate, | 929 | .get_xstate = xfs_fs_getxstate, |
939 | .set_xstate = linvfs_setxstate, | 930 | .set_xstate = xfs_fs_setxstate, |
940 | .get_xquota = linvfs_getxquota, | 931 | .get_xquota = xfs_fs_getxquota, |
941 | .set_xquota = linvfs_setxquota, | 932 | .set_xquota = xfs_fs_setxquota, |
942 | }; | 933 | }; |
943 | 934 | ||
944 | STATIC struct file_system_type xfs_fs_type = { | 935 | STATIC struct file_system_type xfs_fs_type = { |
945 | .owner = THIS_MODULE, | 936 | .owner = THIS_MODULE, |
946 | .name = "xfs", | 937 | .name = "xfs", |
947 | .get_sb = linvfs_get_sb, | 938 | .get_sb = xfs_fs_get_sb, |
948 | .kill_sb = kill_block_super, | 939 | .kill_sb = kill_block_super, |
949 | .fs_flags = FS_REQUIRES_DEV, | 940 | .fs_flags = FS_REQUIRES_DEV, |
950 | }; | 941 | }; |
@@ -965,7 +956,7 @@ init_xfs_fs( void ) | |||
965 | 956 | ||
966 | ktrace_init(64); | 957 | ktrace_init(64); |
967 | 958 | ||
968 | error = linvfs_init_zones(); | 959 | error = xfs_init_zones(); |
969 | if (error < 0) | 960 | if (error < 0) |
970 | goto undo_zones; | 961 | goto undo_zones; |
971 | 962 | ||
@@ -981,14 +972,13 @@ init_xfs_fs( void ) | |||
981 | error = register_filesystem(&xfs_fs_type); | 972 | error = register_filesystem(&xfs_fs_type); |
982 | if (error) | 973 | if (error) |
983 | goto undo_register; | 974 | goto undo_register; |
984 | XFS_DM_INIT(&xfs_fs_type); | ||
985 | return 0; | 975 | return 0; |
986 | 976 | ||
987 | undo_register: | 977 | undo_register: |
988 | xfs_buf_terminate(); | 978 | xfs_buf_terminate(); |
989 | 979 | ||
990 | undo_buffers: | 980 | undo_buffers: |
991 | linvfs_destroy_zones(); | 981 | xfs_destroy_zones(); |
992 | 982 | ||
993 | undo_zones: | 983 | undo_zones: |
994 | return error; | 984 | return error; |
@@ -998,11 +988,10 @@ STATIC void __exit | |||
998 | exit_xfs_fs( void ) | 988 | exit_xfs_fs( void ) |
999 | { | 989 | { |
1000 | vfs_exitquota(); | 990 | vfs_exitquota(); |
1001 | XFS_DM_EXIT(&xfs_fs_type); | ||
1002 | unregister_filesystem(&xfs_fs_type); | 991 | unregister_filesystem(&xfs_fs_type); |
1003 | xfs_cleanup(); | 992 | xfs_cleanup(); |
1004 | xfs_buf_terminate(); | 993 | xfs_buf_terminate(); |
1005 | linvfs_destroy_zones(); | 994 | xfs_destroy_zones(); |
1006 | ktrace_uninit(); | 995 | ktrace_uninit(); |
1007 | } | 996 | } |
1008 | 997 | ||
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index df59408dca06..376b96cb513a 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h | |||
@@ -98,11 +98,6 @@ extern void xfs_qm_exit(void); | |||
98 | XFS_DMAPI_STRING \ | 98 | XFS_DMAPI_STRING \ |
99 | XFS_DBG_STRING /* DBG must be last */ | 99 | XFS_DBG_STRING /* DBG must be last */ |
100 | 100 | ||
101 | #define LINVFS_GET_VFS(s) \ | ||
102 | (vfs_t *)((s)->s_fs_info) | ||
103 | #define LINVFS_SET_VFS(s, vfsp) \ | ||
104 | ((s)->s_fs_info = vfsp) | ||
105 | |||
106 | struct xfs_inode; | 101 | struct xfs_inode; |
107 | struct xfs_mount; | 102 | struct xfs_mount; |
108 | struct xfs_buftarg; | 103 | struct xfs_buftarg; |
@@ -120,6 +115,6 @@ extern int xfs_blkdev_get(struct xfs_mount *, const char *, | |||
120 | extern void xfs_blkdev_put(struct block_device *); | 115 | extern void xfs_blkdev_put(struct block_device *); |
121 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); | 116 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); |
122 | 117 | ||
123 | extern struct export_operations linvfs_export_ops; | 118 | extern struct export_operations xfs_export_operations; |
124 | 119 | ||
125 | #endif /* __XFS_SUPER_H__ */ | 120 | #endif /* __XFS_SUPER_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c index c855d62e5344..6f7c9f7a8624 100644 --- a/fs/xfs/linux-2.6/xfs_vfs.c +++ b/fs/xfs/linux-2.6/xfs_vfs.c | |||
@@ -227,7 +227,8 @@ vfs_freeze( | |||
227 | } | 227 | } |
228 | 228 | ||
229 | vfs_t * | 229 | vfs_t * |
230 | vfs_allocate( void ) | 230 | vfs_allocate( |
231 | struct super_block *sb) | ||
231 | { | 232 | { |
232 | struct vfs *vfsp; | 233 | struct vfs *vfsp; |
233 | 234 | ||
@@ -236,9 +237,23 @@ vfs_allocate( void ) | |||
236 | INIT_LIST_HEAD(&vfsp->vfs_sync_list); | 237 | INIT_LIST_HEAD(&vfsp->vfs_sync_list); |
237 | spin_lock_init(&vfsp->vfs_sync_lock); | 238 | spin_lock_init(&vfsp->vfs_sync_lock); |
238 | init_waitqueue_head(&vfsp->vfs_wait_single_sync_task); | 239 | init_waitqueue_head(&vfsp->vfs_wait_single_sync_task); |
240 | |||
241 | vfsp->vfs_super = sb; | ||
242 | sb->s_fs_info = vfsp; | ||
243 | |||
244 | if (sb->s_flags & MS_RDONLY) | ||
245 | vfsp->vfs_flag |= VFS_RDONLY; | ||
246 | |||
239 | return vfsp; | 247 | return vfsp; |
240 | } | 248 | } |
241 | 249 | ||
250 | vfs_t * | ||
251 | vfs_from_sb( | ||
252 | struct super_block *sb) | ||
253 | { | ||
254 | return (vfs_t *)sb->s_fs_info; | ||
255 | } | ||
256 | |||
242 | void | 257 | void |
243 | vfs_deallocate( | 258 | vfs_deallocate( |
244 | struct vfs *vfsp) | 259 | struct vfs *vfsp) |
@@ -295,7 +310,7 @@ bhv_remove_all_vfsops( | |||
295 | bhv_remove_vfsops(vfsp, VFS_POSITION_DM); | 310 | bhv_remove_vfsops(vfsp, VFS_POSITION_DM); |
296 | if (!freebase) | 311 | if (!freebase) |
297 | return; | 312 | return; |
298 | mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops)); | 313 | mp = XFS_VFSTOM(vfsp); |
299 | VFS_REMOVEBHV(vfsp, &mp->m_bhv); | 314 | VFS_REMOVEBHV(vfsp, &mp->m_bhv); |
300 | xfs_mount_free(mp, 0); | 315 | xfs_mount_free(mp, 0); |
301 | } | 316 | } |
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h index 57caf9eddee0..8fed356db055 100644 --- a/fs/xfs/linux-2.6/xfs_vfs.h +++ b/fs/xfs/linux-2.6/xfs_vfs.h | |||
@@ -193,7 +193,8 @@ typedef struct bhv_vfsops { | |||
193 | #define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o)) | 193 | #define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o)) |
194 | #define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL ) | 194 | #define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL ) |
195 | 195 | ||
196 | extern vfs_t *vfs_allocate(void); | 196 | extern vfs_t *vfs_allocate(struct super_block *); |
197 | extern vfs_t *vfs_from_sb(struct super_block *); | ||
197 | extern void vfs_deallocate(vfs_t *); | 198 | extern void vfs_deallocate(vfs_t *); |
198 | extern void vfs_insertops(vfs_t *, bhv_vfsops_t *); | 199 | extern void vfs_insertops(vfs_t *, bhv_vfsops_t *); |
199 | extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *); | 200 | extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *); |
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c index 260dd8415dd7..d27c25b27ccd 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.c +++ b/fs/xfs/linux-2.6/xfs_vnode.c | |||
@@ -58,7 +58,7 @@ struct vnode * | |||
58 | vn_initialize( | 58 | vn_initialize( |
59 | struct inode *inode) | 59 | struct inode *inode) |
60 | { | 60 | { |
61 | struct vnode *vp = LINVFS_GET_VP(inode); | 61 | struct vnode *vp = vn_from_inode(inode); |
62 | 62 | ||
63 | XFS_STATS_INC(vn_active); | 63 | XFS_STATS_INC(vn_active); |
64 | XFS_STATS_INC(vn_alloc); | 64 | XFS_STATS_INC(vn_alloc); |
@@ -83,7 +83,7 @@ vn_initialize( | |||
83 | vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); | 83 | vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); |
84 | #endif /* XFS_VNODE_TRACE */ | 84 | #endif /* XFS_VNODE_TRACE */ |
85 | 85 | ||
86 | vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address); | 86 | vn_trace_exit(vp, __FUNCTION__, (inst_t *)__return_address); |
87 | return vp; | 87 | return vp; |
88 | } | 88 | } |
89 | 89 | ||
@@ -97,7 +97,7 @@ vn_revalidate_core( | |||
97 | struct vnode *vp, | 97 | struct vnode *vp, |
98 | vattr_t *vap) | 98 | vattr_t *vap) |
99 | { | 99 | { |
100 | struct inode *inode = LINVFS_GET_IP(vp); | 100 | struct inode *inode = vn_to_inode(vp); |
101 | 101 | ||
102 | inode->i_mode = vap->va_mode; | 102 | inode->i_mode = vap->va_mode; |
103 | inode->i_nlink = vap->va_nlink; | 103 | inode->i_nlink = vap->va_nlink; |
@@ -129,24 +129,31 @@ vn_revalidate_core( | |||
129 | * Revalidate the Linux inode from the vnode. | 129 | * Revalidate the Linux inode from the vnode. |
130 | */ | 130 | */ |
131 | int | 131 | int |
132 | vn_revalidate( | 132 | __vn_revalidate( |
133 | struct vnode *vp) | 133 | struct vnode *vp, |
134 | struct vattr *vattr) | ||
134 | { | 135 | { |
135 | vattr_t va; | ||
136 | int error; | 136 | int error; |
137 | 137 | ||
138 | vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address); | 138 | vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); |
139 | ASSERT(vp->v_fbhv != NULL); | 139 | vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS; |
140 | 140 | VOP_GETATTR(vp, vattr, 0, NULL, error); | |
141 | va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS; | 141 | if (likely(!error)) { |
142 | VOP_GETATTR(vp, &va, 0, NULL, error); | 142 | vn_revalidate_core(vp, vattr); |
143 | if (!error) { | ||
144 | vn_revalidate_core(vp, &va); | ||
145 | VUNMODIFY(vp); | 143 | VUNMODIFY(vp); |
146 | } | 144 | } |
147 | return -error; | 145 | return -error; |
148 | } | 146 | } |
149 | 147 | ||
148 | int | ||
149 | vn_revalidate( | ||
150 | struct vnode *vp) | ||
151 | { | ||
152 | vattr_t vattr; | ||
153 | |||
154 | return __vn_revalidate(vp, &vattr); | ||
155 | } | ||
156 | |||
150 | /* | 157 | /* |
151 | * Add a reference to a referenced vnode. | 158 | * Add a reference to a referenced vnode. |
152 | */ | 159 | */ |
@@ -159,7 +166,7 @@ vn_hold( | |||
159 | XFS_STATS_INC(vn_hold); | 166 | XFS_STATS_INC(vn_hold); |
160 | 167 | ||
161 | VN_LOCK(vp); | 168 | VN_LOCK(vp); |
162 | inode = igrab(LINVFS_GET_IP(vp)); | 169 | inode = igrab(vn_to_inode(vp)); |
163 | ASSERT(inode); | 170 | ASSERT(inode); |
164 | VN_UNLOCK(vp, 0); | 171 | VN_UNLOCK(vp, 0); |
165 | 172 | ||
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h index 0fe2419461d6..06f5845e9568 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/linux-2.6/xfs_vnode.h | |||
@@ -116,8 +116,14 @@ typedef enum { | |||
116 | /* | 116 | /* |
117 | * Vnode to Linux inode mapping. | 117 | * Vnode to Linux inode mapping. |
118 | */ | 118 | */ |
119 | #define LINVFS_GET_VP(inode) ((vnode_t *)list_entry(inode, vnode_t, v_inode)) | 119 | static inline struct vnode *vn_from_inode(struct inode *inode) |
120 | #define LINVFS_GET_IP(vp) (&(vp)->v_inode) | 120 | { |
121 | return (vnode_t *)list_entry(inode, vnode_t, v_inode); | ||
122 | } | ||
123 | static inline struct inode *vn_to_inode(struct vnode *vnode) | ||
124 | { | ||
125 | return &vnode->v_inode; | ||
126 | } | ||
121 | 127 | ||
122 | /* | 128 | /* |
123 | * Vnode flags. | 129 | * Vnode flags. |
@@ -490,6 +496,7 @@ typedef struct vnode_map { | |||
490 | (vmap).v_ino = (vp)->v_inode.i_ino; } | 496 | (vmap).v_ino = (vp)->v_inode.i_ino; } |
491 | 497 | ||
492 | extern int vn_revalidate(struct vnode *); | 498 | extern int vn_revalidate(struct vnode *); |
499 | extern int __vn_revalidate(struct vnode *, vattr_t *); | ||
493 | extern void vn_revalidate_core(struct vnode *, vattr_t *); | 500 | extern void vn_revalidate_core(struct vnode *, vattr_t *); |
494 | 501 | ||
495 | extern void vn_iowait(struct vnode *vp); | 502 | extern void vn_iowait(struct vnode *vp); |
@@ -497,7 +504,7 @@ extern void vn_iowake(struct vnode *vp); | |||
497 | 504 | ||
498 | static inline int vn_count(struct vnode *vp) | 505 | static inline int vn_count(struct vnode *vp) |
499 | { | 506 | { |
500 | return atomic_read(&LINVFS_GET_IP(vp)->i_count); | 507 | return atomic_read(&vn_to_inode(vp)->i_count); |
501 | } | 508 | } |
502 | 509 | ||
503 | /* | 510 | /* |
@@ -511,16 +518,16 @@ extern vnode_t *vn_hold(struct vnode *); | |||
511 | vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address)) | 518 | vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address)) |
512 | #define VN_RELE(vp) \ | 519 | #define VN_RELE(vp) \ |
513 | (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \ | 520 | (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \ |
514 | iput(LINVFS_GET_IP(vp))) | 521 | iput(vn_to_inode(vp))) |
515 | #else | 522 | #else |
516 | #define VN_HOLD(vp) ((void)vn_hold(vp)) | 523 | #define VN_HOLD(vp) ((void)vn_hold(vp)) |
517 | #define VN_RELE(vp) (iput(LINVFS_GET_IP(vp))) | 524 | #define VN_RELE(vp) (iput(vn_to_inode(vp))) |
518 | #endif | 525 | #endif |
519 | 526 | ||
520 | static inline struct vnode *vn_grab(struct vnode *vp) | 527 | static inline struct vnode *vn_grab(struct vnode *vp) |
521 | { | 528 | { |
522 | struct inode *inode = igrab(LINVFS_GET_IP(vp)); | 529 | struct inode *inode = igrab(vn_to_inode(vp)); |
523 | return inode ? LINVFS_GET_VP(inode) : NULL; | 530 | return inode ? vn_from_inode(inode) : NULL; |
524 | } | 531 | } |
525 | 532 | ||
526 | /* | 533 | /* |
@@ -528,7 +535,7 @@ static inline struct vnode *vn_grab(struct vnode *vp) | |||
528 | */ | 535 | */ |
529 | #define VNAME(dentry) ((char *) (dentry)->d_name.name) | 536 | #define VNAME(dentry) ((char *) (dentry)->d_name.name) |
530 | #define VNAMELEN(dentry) ((dentry)->d_name.len) | 537 | #define VNAMELEN(dentry) ((dentry)->d_name.len) |
531 | #define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode)) | 538 | #define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode)) |
532 | 539 | ||
533 | /* | 540 | /* |
534 | * Vnode spinlock manipulation. | 541 | * Vnode spinlock manipulation. |
@@ -557,12 +564,12 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag) | |||
557 | */ | 564 | */ |
558 | static inline void vn_mark_bad(struct vnode *vp) | 565 | static inline void vn_mark_bad(struct vnode *vp) |
559 | { | 566 | { |
560 | make_bad_inode(LINVFS_GET_IP(vp)); | 567 | make_bad_inode(vn_to_inode(vp)); |
561 | } | 568 | } |
562 | 569 | ||
563 | static inline int VN_BAD(struct vnode *vp) | 570 | static inline int VN_BAD(struct vnode *vp) |
564 | { | 571 | { |
565 | return is_bad_inode(LINVFS_GET_IP(vp)); | 572 | return is_bad_inode(vn_to_inode(vp)); |
566 | } | 573 | } |
567 | 574 | ||
568 | /* | 575 | /* |
@@ -587,9 +594,9 @@ static inline void vn_atime_to_time_t(struct vnode *vp, time_t *tt) | |||
587 | /* | 594 | /* |
588 | * Some useful predicates. | 595 | * Some useful predicates. |
589 | */ | 596 | */ |
590 | #define VN_MAPPED(vp) mapping_mapped(LINVFS_GET_IP(vp)->i_mapping) | 597 | #define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping) |
591 | #define VN_CACHED(vp) (LINVFS_GET_IP(vp)->i_mapping->nrpages) | 598 | #define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages) |
592 | #define VN_DIRTY(vp) mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \ | 599 | #define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \ |
593 | PAGECACHE_TAG_DIRTY) | 600 | PAGECACHE_TAG_DIRTY) |
594 | #define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED) | 601 | #define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED) |
595 | #define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED) | 602 | #define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED) |
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c index 2ec6b441849c..e4e5f05b841b 100644 --- a/fs/xfs/quota/xfs_dquot_item.c +++ b/fs/xfs/quota/xfs_dquot_item.c | |||
@@ -79,9 +79,11 @@ xfs_qm_dquot_logitem_format( | |||
79 | 79 | ||
80 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_format; | 80 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_format; |
81 | logvec->i_len = sizeof(xfs_dq_logformat_t); | 81 | logvec->i_len = sizeof(xfs_dq_logformat_t); |
82 | XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_QFORMAT); | ||
82 | logvec++; | 83 | logvec++; |
83 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core; | 84 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core; |
84 | logvec->i_len = sizeof(xfs_disk_dquot_t); | 85 | logvec->i_len = sizeof(xfs_disk_dquot_t); |
86 | XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_DQUOT); | ||
85 | 87 | ||
86 | ASSERT(2 == logitem->qli_item.li_desc->lid_size); | 88 | ASSERT(2 == logitem->qli_item.li_desc->lid_size); |
87 | logitem->qli_format.qlf_size = 2; | 89 | logitem->qli_format.qlf_size = 2; |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 7c0e39dc6189..1fb757ef3f41 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -1704,9 +1704,9 @@ xfs_qm_get_rtblks( | |||
1704 | xfs_qcnt_t *O_rtblks) | 1704 | xfs_qcnt_t *O_rtblks) |
1705 | { | 1705 | { |
1706 | xfs_filblks_t rtblks; /* total rt blks */ | 1706 | xfs_filblks_t rtblks; /* total rt blks */ |
1707 | xfs_extnum_t idx; /* extent record index */ | ||
1707 | xfs_ifork_t *ifp; /* inode fork pointer */ | 1708 | xfs_ifork_t *ifp; /* inode fork pointer */ |
1708 | xfs_extnum_t nextents; /* number of extent entries */ | 1709 | xfs_extnum_t nextents; /* number of extent entries */ |
1709 | xfs_bmbt_rec_t *base; /* base of extent array */ | ||
1710 | xfs_bmbt_rec_t *ep; /* pointer to an extent entry */ | 1710 | xfs_bmbt_rec_t *ep; /* pointer to an extent entry */ |
1711 | int error; | 1711 | int error; |
1712 | 1712 | ||
@@ -1717,10 +1717,11 @@ xfs_qm_get_rtblks( | |||
1717 | return error; | 1717 | return error; |
1718 | } | 1718 | } |
1719 | rtblks = 0; | 1719 | rtblks = 0; |
1720 | nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t); | 1720 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
1721 | base = &ifp->if_u1.if_extents[0]; | 1721 | for (idx = 0; idx < nextents; idx++) { |
1722 | for (ep = base; ep < &base[nextents]; ep++) | 1722 | ep = xfs_iext_get_ext(ifp, idx); |
1723 | rtblks += xfs_bmbt_get_blockcount(ep); | 1723 | rtblks += xfs_bmbt_get_blockcount(ep); |
1724 | } | ||
1724 | *O_rtblks = (xfs_qcnt_t)rtblks; | 1725 | *O_rtblks = (xfs_qcnt_t)rtblks; |
1725 | return 0; | 1726 | return 0; |
1726 | } | 1727 | } |
@@ -2788,9 +2789,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql) | |||
2788 | xfs_qm_dqdestroy(dqp); | 2789 | xfs_qm_dqdestroy(dqp); |
2789 | dqp = nextdqp; | 2790 | dqp = nextdqp; |
2790 | } | 2791 | } |
2791 | /* | 2792 | mutex_unlock(&ql->qh_lock); |
2792 | * Don't bother about unlocking. | ||
2793 | */ | ||
2794 | mutex_destroy(&ql->qh_lock); | 2793 | mutex_destroy(&ql->qh_lock); |
2795 | 2794 | ||
2796 | ASSERT(ql->qh_nelems == 0); | 2795 | ASSERT(ql->qh_nelems == 0); |
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c index 90402a1c3983..6838b36d95a9 100644 --- a/fs/xfs/quota/xfs_qm_bhv.c +++ b/fs/xfs/quota/xfs_qm_bhv.c | |||
@@ -374,7 +374,7 @@ xfs_qm_exit(void) | |||
374 | vfs_bhv_clr_custom(&xfs_qmops); | 374 | vfs_bhv_clr_custom(&xfs_qmops); |
375 | xfs_qm_cleanup_procfs(); | 375 | xfs_qm_cleanup_procfs(); |
376 | if (qm_dqzone) | 376 | if (qm_dqzone) |
377 | kmem_cache_destroy(qm_dqzone); | 377 | kmem_zone_destroy(qm_dqzone); |
378 | if (qm_dqtrxzone) | 378 | if (qm_dqtrxzone) |
379 | kmem_cache_destroy(qm_dqtrxzone); | 379 | kmem_zone_destroy(qm_dqtrxzone); |
380 | } | 380 | } |
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c index 841aa4c15b8a..addf5a7ea06c 100644 --- a/fs/xfs/support/ktrace.c +++ b/fs/xfs/support/ktrace.c | |||
@@ -39,8 +39,8 @@ ktrace_init(int zentries) | |||
39 | void | 39 | void |
40 | ktrace_uninit(void) | 40 | ktrace_uninit(void) |
41 | { | 41 | { |
42 | kmem_cache_destroy(ktrace_hdr_zone); | 42 | kmem_zone_destroy(ktrace_hdr_zone); |
43 | kmem_cache_destroy(ktrace_ent_zone); | 43 | kmem_zone_destroy(ktrace_ent_zone); |
44 | } | 44 | } |
45 | 45 | ||
46 | /* | 46 | /* |
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/support/uuid.c index a3d565a67734..e157015c70ff 100644 --- a/fs/xfs/support/uuid.c +++ b/fs/xfs/support/uuid.c | |||
@@ -21,13 +21,6 @@ static mutex_t uuid_monitor; | |||
21 | static int uuid_table_size; | 21 | static int uuid_table_size; |
22 | static uuid_t *uuid_table; | 22 | static uuid_t *uuid_table; |
23 | 23 | ||
24 | void | ||
25 | uuid_init(void) | ||
26 | { | ||
27 | mutex_init(&uuid_monitor); | ||
28 | } | ||
29 | |||
30 | |||
31 | /* IRIX interpretation of an uuid_t */ | 24 | /* IRIX interpretation of an uuid_t */ |
32 | typedef struct { | 25 | typedef struct { |
33 | __be32 uu_timelow; | 26 | __be32 uu_timelow; |
@@ -50,7 +43,7 @@ uuid_getnodeuniq(uuid_t *uuid, int fsid [2]) | |||
50 | 43 | ||
51 | fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) | | 44 | fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) | |
52 | be16_to_cpu(uup->uu_timemid); | 45 | be16_to_cpu(uup->uu_timemid); |
53 | fsid[1] = be16_to_cpu(uup->uu_timelow); | 46 | fsid[1] = be32_to_cpu(uup->uu_timelow); |
54 | } | 47 | } |
55 | 48 | ||
56 | void | 49 | void |
@@ -139,3 +132,9 @@ uuid_table_remove(uuid_t *uuid) | |||
139 | ASSERT(i < uuid_table_size); | 132 | ASSERT(i < uuid_table_size); |
140 | mutex_unlock(&uuid_monitor); | 133 | mutex_unlock(&uuid_monitor); |
141 | } | 134 | } |
135 | |||
136 | void | ||
137 | uuid_init(void) | ||
138 | { | ||
139 | mutex_init(&uuid_monitor); | ||
140 | } | ||
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h index f9315bc960cb..538d0d65b04c 100644 --- a/fs/xfs/xfs_acl.h +++ b/fs/xfs/xfs_acl.h | |||
@@ -55,8 +55,8 @@ struct xfs_inode; | |||
55 | 55 | ||
56 | extern struct kmem_zone *xfs_acl_zone; | 56 | extern struct kmem_zone *xfs_acl_zone; |
57 | #define xfs_acl_zone_init(zone, name) \ | 57 | #define xfs_acl_zone_init(zone, name) \ |
58 | (zone) = kmem_zone_init(sizeof(xfs_acl_t), name) | 58 | (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name)) |
59 | #define xfs_acl_zone_destroy(zone) kmem_cache_destroy(zone) | 59 | #define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone) |
60 | 60 | ||
61 | extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *); | 61 | extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *); |
62 | extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *); | 62 | extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *); |
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index e5e91e9c7e89..093fac476bda 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) | |||
1127 | return(error); | 1127 | return(error); |
1128 | ASSERT(bp != NULL); | 1128 | ASSERT(bp != NULL); |
1129 | leaf = bp->data; | 1129 | leaf = bp->data; |
1130 | if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1130 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) { |
1131 | != XFS_ATTR_LEAF_MAGIC)) { | ||
1132 | XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, | 1131 | XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, |
1133 | context->dp->i_mount, leaf); | 1132 | context->dp->i_mount, leaf); |
1134 | xfs_da_brelse(NULL, bp); | 1133 | xfs_da_brelse(NULL, bp); |
@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1541 | XFS_ATTR_FORK); | 1540 | XFS_ATTR_FORK); |
1542 | if (error) | 1541 | if (error) |
1543 | goto out; | 1542 | goto out; |
1544 | ASSERT(INT_GET(((xfs_attr_leafblock_t *) | 1543 | ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *) |
1545 | bp->data)->hdr.info.magic, ARCH_CONVERT) | 1544 | bp->data)->hdr.info.magic) |
1546 | == XFS_ATTR_LEAF_MAGIC); | 1545 | == XFS_ATTR_LEAF_MAGIC); |
1547 | 1546 | ||
1548 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { | 1547 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1763 | return(error); | 1762 | return(error); |
1764 | if (bp) { | 1763 | if (bp) { |
1765 | node = bp->data; | 1764 | node = bp->data; |
1766 | switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) { | 1765 | switch (be16_to_cpu(node->hdr.info.magic)) { |
1767 | case XFS_DA_NODE_MAGIC: | 1766 | case XFS_DA_NODE_MAGIC: |
1768 | xfs_attr_trace_l_cn("wrong blk", context, node); | 1767 | xfs_attr_trace_l_cn("wrong blk", context, node); |
1769 | xfs_da_brelse(NULL, bp); | 1768 | xfs_da_brelse(NULL, bp); |
@@ -1771,18 +1770,14 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1771 | break; | 1770 | break; |
1772 | case XFS_ATTR_LEAF_MAGIC: | 1771 | case XFS_ATTR_LEAF_MAGIC: |
1773 | leaf = bp->data; | 1772 | leaf = bp->data; |
1774 | if (cursor->hashval > | 1773 | if (cursor->hashval > be32_to_cpu(leaf->entries[ |
1775 | INT_GET(leaf->entries[ | 1774 | be16_to_cpu(leaf->hdr.count)-1].hashval)) { |
1776 | INT_GET(leaf->hdr.count, | ||
1777 | ARCH_CONVERT)-1].hashval, | ||
1778 | ARCH_CONVERT)) { | ||
1779 | xfs_attr_trace_l_cl("wrong blk", | 1775 | xfs_attr_trace_l_cl("wrong blk", |
1780 | context, leaf); | 1776 | context, leaf); |
1781 | xfs_da_brelse(NULL, bp); | 1777 | xfs_da_brelse(NULL, bp); |
1782 | bp = NULL; | 1778 | bp = NULL; |
1783 | } else if (cursor->hashval <= | 1779 | } else if (cursor->hashval <= |
1784 | INT_GET(leaf->entries[0].hashval, | 1780 | be32_to_cpu(leaf->entries[0].hashval)) { |
1785 | ARCH_CONVERT)) { | ||
1786 | xfs_attr_trace_l_cl("maybe wrong blk", | 1781 | xfs_attr_trace_l_cl("maybe wrong blk", |
1787 | context, leaf); | 1782 | context, leaf); |
1788 | xfs_da_brelse(NULL, bp); | 1783 | xfs_da_brelse(NULL, bp); |
@@ -1817,10 +1812,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1817 | return(XFS_ERROR(EFSCORRUPTED)); | 1812 | return(XFS_ERROR(EFSCORRUPTED)); |
1818 | } | 1813 | } |
1819 | node = bp->data; | 1814 | node = bp->data; |
1820 | if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 1815 | if (be16_to_cpu(node->hdr.info.magic) |
1821 | == XFS_ATTR_LEAF_MAGIC) | 1816 | == XFS_ATTR_LEAF_MAGIC) |
1822 | break; | 1817 | break; |
1823 | if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 1818 | if (unlikely(be16_to_cpu(node->hdr.info.magic) |
1824 | != XFS_DA_NODE_MAGIC)) { | 1819 | != XFS_DA_NODE_MAGIC)) { |
1825 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", | 1820 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", |
1826 | XFS_ERRLEVEL_LOW, | 1821 | XFS_ERRLEVEL_LOW, |
@@ -1830,19 +1825,17 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1830 | return(XFS_ERROR(EFSCORRUPTED)); | 1825 | return(XFS_ERROR(EFSCORRUPTED)); |
1831 | } | 1826 | } |
1832 | btree = node->btree; | 1827 | btree = node->btree; |
1833 | for (i = 0; | 1828 | for (i = 0; i < be16_to_cpu(node->hdr.count); |
1834 | i < INT_GET(node->hdr.count, ARCH_CONVERT); | ||
1835 | btree++, i++) { | 1829 | btree++, i++) { |
1836 | if (cursor->hashval | 1830 | if (cursor->hashval |
1837 | <= INT_GET(btree->hashval, | 1831 | <= be32_to_cpu(btree->hashval)) { |
1838 | ARCH_CONVERT)) { | 1832 | cursor->blkno = be32_to_cpu(btree->before); |
1839 | cursor->blkno = INT_GET(btree->before, ARCH_CONVERT); | ||
1840 | xfs_attr_trace_l_cb("descending", | 1833 | xfs_attr_trace_l_cb("descending", |
1841 | context, btree); | 1834 | context, btree); |
1842 | break; | 1835 | break; |
1843 | } | 1836 | } |
1844 | } | 1837 | } |
1845 | if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) { | 1838 | if (i == be16_to_cpu(node->hdr.count)) { |
1846 | xfs_da_brelse(NULL, bp); | 1839 | xfs_da_brelse(NULL, bp); |
1847 | return(0); | 1840 | return(0); |
1848 | } | 1841 | } |
@@ -1858,7 +1851,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1858 | */ | 1851 | */ |
1859 | for (;;) { | 1852 | for (;;) { |
1860 | leaf = bp->data; | 1853 | leaf = bp->data; |
1861 | if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1854 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) |
1862 | != XFS_ATTR_LEAF_MAGIC)) { | 1855 | != XFS_ATTR_LEAF_MAGIC)) { |
1863 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", | 1856 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", |
1864 | XFS_ERRLEVEL_LOW, | 1857 | XFS_ERRLEVEL_LOW, |
@@ -1869,7 +1862,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1869 | error = xfs_attr_leaf_list_int(bp, context); | 1862 | error = xfs_attr_leaf_list_int(bp, context); |
1870 | if (error || !leaf->hdr.info.forw) | 1863 | if (error || !leaf->hdr.info.forw) |
1871 | break; /* not really an error, buffer full or EOF */ | 1864 | break; /* not really an error, buffer full or EOF */ |
1872 | cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT); | 1865 | cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); |
1873 | xfs_da_brelse(NULL, bp); | 1866 | xfs_da_brelse(NULL, bp); |
1874 | error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, | 1867 | error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, |
1875 | &bp, XFS_ATTR_FORK); | 1868 | &bp, XFS_ATTR_FORK); |
@@ -2232,9 +2225,10 @@ xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context, | |||
2232 | : 0, | 2225 | : 0, |
2233 | (__psunsigned_t)context->dupcnt, | 2226 | (__psunsigned_t)context->dupcnt, |
2234 | (__psunsigned_t)context->flags, | 2227 | (__psunsigned_t)context->flags, |
2235 | (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT), | 2228 | (__psunsigned_t)be16_to_cpu(node->hdr.count), |
2236 | (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT), | 2229 | (__psunsigned_t)be32_to_cpu(node->btree[0].hashval), |
2237 | (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); | 2230 | (__psunsigned_t)be32_to_cpu(node->btree[ |
2231 | be16_to_cpu(node->hdr.count)-1].hashval)); | ||
2238 | } | 2232 | } |
2239 | 2233 | ||
2240 | /* | 2234 | /* |
@@ -2261,8 +2255,8 @@ xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context, | |||
2261 | : 0, | 2255 | : 0, |
2262 | (__psunsigned_t)context->dupcnt, | 2256 | (__psunsigned_t)context->dupcnt, |
2263 | (__psunsigned_t)context->flags, | 2257 | (__psunsigned_t)context->flags, |
2264 | (__psunsigned_t)INT_GET(btree->hashval, ARCH_CONVERT), | 2258 | (__psunsigned_t)be32_to_cpu(btree->hashval), |
2265 | (__psunsigned_t)INT_GET(btree->before, ARCH_CONVERT), | 2259 | (__psunsigned_t)be32_to_cpu(btree->before), |
2266 | (__psunsigned_t)NULL); | 2260 | (__psunsigned_t)NULL); |
2267 | } | 2261 | } |
2268 | 2262 | ||
@@ -2290,9 +2284,10 @@ xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context, | |||
2290 | : 0, | 2284 | : 0, |
2291 | (__psunsigned_t)context->dupcnt, | 2285 | (__psunsigned_t)context->dupcnt, |
2292 | (__psunsigned_t)context->flags, | 2286 | (__psunsigned_t)context->flags, |
2293 | (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT), | 2287 | (__psunsigned_t)be16_to_cpu(leaf->hdr.count), |
2294 | (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT), | 2288 | (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval), |
2295 | (__psunsigned_t)INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); | 2289 | (__psunsigned_t)be32_to_cpu(leaf->entries[ |
2290 | be16_to_cpu(leaf->hdr.count)-1].hashval)); | ||
2296 | } | 2291 | } |
2297 | 2292 | ||
2298 | /* | 2293 | /* |
@@ -2522,7 +2517,7 @@ attr_user_capable( | |||
2522 | struct vnode *vp, | 2517 | struct vnode *vp, |
2523 | cred_t *cred) | 2518 | cred_t *cred) |
2524 | { | 2519 | { |
2525 | struct inode *inode = LINVFS_GET_IP(vp); | 2520 | struct inode *inode = vn_to_inode(vp); |
2526 | 2521 | ||
2527 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | 2522 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
2528 | return -EPERM; | 2523 | return -EPERM; |
@@ -2540,7 +2535,7 @@ attr_trusted_capable( | |||
2540 | struct vnode *vp, | 2535 | struct vnode *vp, |
2541 | cred_t *cred) | 2536 | cred_t *cred) |
2542 | { | 2537 | { |
2543 | struct inode *inode = LINVFS_GET_IP(vp); | 2538 | struct inode *inode = vn_to_inode(vp); |
2544 | 2539 | ||
2545 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | 2540 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
2546 | return -EPERM; | 2541 | return -EPERM; |
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index fe91eac4e2a7..717682747bd2 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -194,7 +194,7 @@ xfs_attr_shortform_create(xfs_da_args_t *args) | |||
194 | xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); | 194 | xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); |
195 | hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; | 195 | hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; |
196 | hdr->count = 0; | 196 | hdr->count = 0; |
197 | INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); | 197 | hdr->totsize = cpu_to_be16(sizeof(*hdr)); |
198 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 198 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); |
199 | } | 199 | } |
200 | 200 | ||
@@ -224,8 +224,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) | |||
224 | ASSERT(ifp->if_flags & XFS_IFINLINE); | 224 | ASSERT(ifp->if_flags & XFS_IFINLINE); |
225 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 225 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
226 | sfe = &sf->list[0]; | 226 | sfe = &sf->list[0]; |
227 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 227 | for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
228 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | ||
229 | #ifdef DEBUG | 228 | #ifdef DEBUG |
230 | if (sfe->namelen != args->namelen) | 229 | if (sfe->namelen != args->namelen) |
231 | continue; | 230 | continue; |
@@ -248,13 +247,13 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) | |||
248 | sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); | 247 | sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); |
249 | 248 | ||
250 | sfe->namelen = args->namelen; | 249 | sfe->namelen = args->namelen; |
251 | INT_SET(sfe->valuelen, ARCH_CONVERT, args->valuelen); | 250 | sfe->valuelen = args->valuelen; |
252 | sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : | 251 | sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : |
253 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); | 252 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); |
254 | memcpy(sfe->nameval, args->name, args->namelen); | 253 | memcpy(sfe->nameval, args->name, args->namelen); |
255 | memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); | 254 | memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); |
256 | INT_MOD(sf->hdr.count, ARCH_CONVERT, 1); | 255 | sf->hdr.count++; |
257 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); | 256 | be16_add(&sf->hdr.totsize, size); |
258 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 257 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); |
259 | 258 | ||
260 | xfs_sbversion_add_attr2(mp, args->trans); | 259 | xfs_sbversion_add_attr2(mp, args->trans); |
@@ -277,7 +276,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
277 | base = sizeof(xfs_attr_sf_hdr_t); | 276 | base = sizeof(xfs_attr_sf_hdr_t); |
278 | sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; | 277 | sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; |
279 | sfe = &sf->list[0]; | 278 | sfe = &sf->list[0]; |
280 | end = INT_GET(sf->hdr.count, ARCH_CONVERT); | 279 | end = sf->hdr.count; |
281 | for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), | 280 | for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), |
282 | base += size, i++) { | 281 | base += size, i++) { |
283 | size = XFS_ATTR_SF_ENTSIZE(sfe); | 282 | size = XFS_ATTR_SF_ENTSIZE(sfe); |
@@ -300,11 +299,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
300 | * Fix up the attribute fork data, covering the hole | 299 | * Fix up the attribute fork data, covering the hole |
301 | */ | 300 | */ |
302 | end = base + size; | 301 | end = base + size; |
303 | totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); | 302 | totsize = be16_to_cpu(sf->hdr.totsize); |
304 | if (end != totsize) | 303 | if (end != totsize) |
305 | memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); | 304 | memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); |
306 | INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); | 305 | sf->hdr.count--; |
307 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); | 306 | be16_add(&sf->hdr.totsize, -size); |
308 | 307 | ||
309 | /* | 308 | /* |
310 | * Fix up the start offset of the attribute fork | 309 | * Fix up the start offset of the attribute fork |
@@ -360,7 +359,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) | |||
360 | ASSERT(ifp->if_flags & XFS_IFINLINE); | 359 | ASSERT(ifp->if_flags & XFS_IFINLINE); |
361 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 360 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
362 | sfe = &sf->list[0]; | 361 | sfe = &sf->list[0]; |
363 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 362 | for (i = 0; i < sf->hdr.count; |
364 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | 363 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
365 | if (sfe->namelen != args->namelen) | 364 | if (sfe->namelen != args->namelen) |
366 | continue; | 365 | continue; |
@@ -391,7 +390,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) | |||
391 | ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE); | 390 | ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE); |
392 | sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data; | 391 | sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data; |
393 | sfe = &sf->list[0]; | 392 | sfe = &sf->list[0]; |
394 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 393 | for (i = 0; i < sf->hdr.count; |
395 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | 394 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
396 | if (sfe->namelen != args->namelen) | 395 | if (sfe->namelen != args->namelen) |
397 | continue; | 396 | continue; |
@@ -404,14 +403,14 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) | |||
404 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | 403 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) |
405 | continue; | 404 | continue; |
406 | if (args->flags & ATTR_KERNOVAL) { | 405 | if (args->flags & ATTR_KERNOVAL) { |
407 | args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 406 | args->valuelen = sfe->valuelen; |
408 | return(XFS_ERROR(EEXIST)); | 407 | return(XFS_ERROR(EEXIST)); |
409 | } | 408 | } |
410 | if (args->valuelen < INT_GET(sfe->valuelen, ARCH_CONVERT)) { | 409 | if (args->valuelen < sfe->valuelen) { |
411 | args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 410 | args->valuelen = sfe->valuelen; |
412 | return(XFS_ERROR(ERANGE)); | 411 | return(XFS_ERROR(ERANGE)); |
413 | } | 412 | } |
414 | args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 413 | args->valuelen = sfe->valuelen; |
415 | memcpy(args->value, &sfe->nameval[args->namelen], | 414 | memcpy(args->value, &sfe->nameval[args->namelen], |
416 | args->valuelen); | 415 | args->valuelen); |
417 | return(XFS_ERROR(EEXIST)); | 416 | return(XFS_ERROR(EEXIST)); |
@@ -438,7 +437,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
438 | dp = args->dp; | 437 | dp = args->dp; |
439 | ifp = dp->i_afp; | 438 | ifp = dp->i_afp; |
440 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 439 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
441 | size = INT_GET(sf->hdr.totsize, ARCH_CONVERT); | 440 | size = be16_to_cpu(sf->hdr.totsize); |
442 | tmpbuffer = kmem_alloc(size, KM_SLEEP); | 441 | tmpbuffer = kmem_alloc(size, KM_SLEEP); |
443 | ASSERT(tmpbuffer != NULL); | 442 | ASSERT(tmpbuffer != NULL); |
444 | memcpy(tmpbuffer, ifp->if_u1.if_data, size); | 443 | memcpy(tmpbuffer, ifp->if_u1.if_data, size); |
@@ -481,11 +480,11 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
481 | nargs.oknoent = 1; | 480 | nargs.oknoent = 1; |
482 | 481 | ||
483 | sfe = &sf->list[0]; | 482 | sfe = &sf->list[0]; |
484 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | 483 | for (i = 0; i < sf->hdr.count; i++) { |
485 | nargs.name = (char *)sfe->nameval; | 484 | nargs.name = (char *)sfe->nameval; |
486 | nargs.namelen = sfe->namelen; | 485 | nargs.namelen = sfe->namelen; |
487 | nargs.value = (char *)&sfe->nameval[nargs.namelen]; | 486 | nargs.value = (char *)&sfe->nameval[nargs.namelen]; |
488 | nargs.valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 487 | nargs.valuelen = sfe->valuelen; |
489 | nargs.hashval = xfs_da_hashname((char *)sfe->nameval, | 488 | nargs.hashval = xfs_da_hashname((char *)sfe->nameval, |
490 | sfe->namelen); | 489 | sfe->namelen); |
491 | nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 490 | nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : |
@@ -514,11 +513,9 @@ xfs_attr_shortform_compare(const void *a, const void *b) | |||
514 | 513 | ||
515 | sa = (xfs_attr_sf_sort_t *)a; | 514 | sa = (xfs_attr_sf_sort_t *)a; |
516 | sb = (xfs_attr_sf_sort_t *)b; | 515 | sb = (xfs_attr_sf_sort_t *)b; |
517 | if (INT_GET(sa->hash, ARCH_CONVERT) | 516 | if (sa->hash < sb->hash) { |
518 | < INT_GET(sb->hash, ARCH_CONVERT)) { | ||
519 | return(-1); | 517 | return(-1); |
520 | } else if (INT_GET(sa->hash, ARCH_CONVERT) | 518 | } else if (sa->hash > sb->hash) { |
521 | > INT_GET(sb->hash, ARCH_CONVERT)) { | ||
522 | return(1); | 519 | return(1); |
523 | } else { | 520 | } else { |
524 | return(sa->entno - sb->entno); | 521 | return(sa->entno - sb->entno); |
@@ -560,10 +557,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
560 | * If the buffer is large enough, do not bother with sorting. | 557 | * If the buffer is large enough, do not bother with sorting. |
561 | * Note the generous fudge factor of 16 overhead bytes per entry. | 558 | * Note the generous fudge factor of 16 overhead bytes per entry. |
562 | */ | 559 | */ |
563 | if ((dp->i_afp->if_bytes + INT_GET(sf->hdr.count, ARCH_CONVERT) * 16) | 560 | if ((dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize) { |
564 | < context->bufsize) { | 561 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
565 | for (i = 0, sfe = &sf->list[0]; | ||
566 | i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | ||
567 | attrnames_t *namesp; | 562 | attrnames_t *namesp; |
568 | 563 | ||
569 | if (((context->flags & ATTR_SECURE) != 0) != | 564 | if (((context->flags & ATTR_SECURE) != 0) != |
@@ -584,14 +579,13 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
584 | if (context->flags & ATTR_KERNOVAL) { | 579 | if (context->flags & ATTR_KERNOVAL) { |
585 | ASSERT(context->flags & ATTR_KERNAMELS); | 580 | ASSERT(context->flags & ATTR_KERNAMELS); |
586 | context->count += namesp->attr_namelen + | 581 | context->count += namesp->attr_namelen + |
587 | INT_GET(sfe->namelen, ARCH_CONVERT) + 1; | 582 | sfe->namelen + 1; |
588 | } | 583 | } |
589 | else { | 584 | else { |
590 | if (xfs_attr_put_listent(context, namesp, | 585 | if (xfs_attr_put_listent(context, namesp, |
591 | (char *)sfe->nameval, | 586 | (char *)sfe->nameval, |
592 | (int)sfe->namelen, | 587 | (int)sfe->namelen, |
593 | (int)INT_GET(sfe->valuelen, | 588 | (int)sfe->valuelen)) |
594 | ARCH_CONVERT))) | ||
595 | break; | 589 | break; |
596 | } | 590 | } |
597 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | 591 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); |
@@ -603,7 +597,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
603 | /* | 597 | /* |
604 | * It didn't all fit, so we have to sort everything on hashval. | 598 | * It didn't all fit, so we have to sort everything on hashval. |
605 | */ | 599 | */ |
606 | sbsize = INT_GET(sf->hdr.count, ARCH_CONVERT) * sizeof(*sbuf); | 600 | sbsize = sf->hdr.count * sizeof(*sbuf); |
607 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); | 601 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); |
608 | 602 | ||
609 | /* | 603 | /* |
@@ -611,8 +605,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
611 | * the relevant info from only those that match into a buffer. | 605 | * the relevant info from only those that match into a buffer. |
612 | */ | 606 | */ |
613 | nsbuf = 0; | 607 | nsbuf = 0; |
614 | for (i = 0, sfe = &sf->list[0]; | 608 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
615 | i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | ||
616 | if (unlikely( | 609 | if (unlikely( |
617 | ((char *)sfe < (char *)sf) || | 610 | ((char *)sfe < (char *)sf) || |
618 | ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) { | 611 | ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) { |
@@ -636,8 +629,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
636 | continue; | 629 | continue; |
637 | } | 630 | } |
638 | sbp->entno = i; | 631 | sbp->entno = i; |
639 | INT_SET(sbp->hash, ARCH_CONVERT, | 632 | sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen); |
640 | xfs_da_hashname((char *)sfe->nameval, sfe->namelen)); | ||
641 | sbp->name = (char *)sfe->nameval; | 633 | sbp->name = (char *)sfe->nameval; |
642 | sbp->namelen = sfe->namelen; | 634 | sbp->namelen = sfe->namelen; |
643 | /* These are bytes, and both on-disk, don't endian-flip */ | 635 | /* These are bytes, and both on-disk, don't endian-flip */ |
@@ -660,12 +652,12 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
660 | cursor->initted = 1; | 652 | cursor->initted = 1; |
661 | cursor->blkno = 0; | 653 | cursor->blkno = 0; |
662 | for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) { | 654 | for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) { |
663 | if (INT_GET(sbp->hash, ARCH_CONVERT) == cursor->hashval) { | 655 | if (sbp->hash == cursor->hashval) { |
664 | if (cursor->offset == count) { | 656 | if (cursor->offset == count) { |
665 | break; | 657 | break; |
666 | } | 658 | } |
667 | count++; | 659 | count++; |
668 | } else if (INT_GET(sbp->hash, ARCH_CONVERT) > cursor->hashval) { | 660 | } else if (sbp->hash > cursor->hashval) { |
669 | break; | 661 | break; |
670 | } | 662 | } |
671 | } | 663 | } |
@@ -685,8 +677,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
685 | ((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted : | 677 | ((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted : |
686 | &attr_user); | 678 | &attr_user); |
687 | 679 | ||
688 | if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) { | 680 | if (cursor->hashval != sbp->hash) { |
689 | cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT); | 681 | cursor->hashval = sbp->hash; |
690 | cursor->offset = 0; | 682 | cursor->offset = 0; |
691 | } | 683 | } |
692 | if (context->flags & ATTR_KERNOVAL) { | 684 | if (context->flags & ATTR_KERNOVAL) { |
@@ -696,7 +688,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
696 | } else { | 688 | } else { |
697 | if (xfs_attr_put_listent(context, namesp, | 689 | if (xfs_attr_put_listent(context, namesp, |
698 | sbp->name, sbp->namelen, | 690 | sbp->name, sbp->namelen, |
699 | INT_GET(sbp->valuelen, ARCH_CONVERT))) | 691 | sbp->valuelen)) |
700 | break; | 692 | break; |
701 | } | 693 | } |
702 | cursor->offset++; | 694 | cursor->offset++; |
@@ -720,12 +712,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) | |||
720 | int bytes, i; | 712 | int bytes, i; |
721 | 713 | ||
722 | leaf = bp->data; | 714 | leaf = bp->data; |
723 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 715 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
724 | == XFS_ATTR_LEAF_MAGIC); | ||
725 | 716 | ||
726 | entry = &leaf->entries[0]; | 717 | entry = &leaf->entries[0]; |
727 | bytes = sizeof(struct xfs_attr_sf_hdr); | 718 | bytes = sizeof(struct xfs_attr_sf_hdr); |
728 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 719 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
729 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 720 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
730 | continue; /* don't copy partial entries */ | 721 | continue; /* don't copy partial entries */ |
731 | if (!(entry->flags & XFS_ATTR_LOCAL)) | 722 | if (!(entry->flags & XFS_ATTR_LOCAL)) |
@@ -733,11 +724,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) | |||
733 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); | 724 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); |
734 | if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) | 725 | if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) |
735 | return(0); | 726 | return(0); |
736 | if (INT_GET(name_loc->valuelen, ARCH_CONVERT) >= XFS_ATTR_SF_ENTSIZE_MAX) | 727 | if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) |
737 | return(0); | 728 | return(0); |
738 | bytes += sizeof(struct xfs_attr_sf_entry)-1 | 729 | bytes += sizeof(struct xfs_attr_sf_entry)-1 |
739 | + name_loc->namelen | 730 | + name_loc->namelen |
740 | + INT_GET(name_loc->valuelen, ARCH_CONVERT); | 731 | + be16_to_cpu(name_loc->valuelen); |
741 | } | 732 | } |
742 | if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && | 733 | if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && |
743 | (bytes == sizeof(struct xfs_attr_sf_hdr))) | 734 | (bytes == sizeof(struct xfs_attr_sf_hdr))) |
@@ -766,8 +757,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
766 | ASSERT(bp != NULL); | 757 | ASSERT(bp != NULL); |
767 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); | 758 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); |
768 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; | 759 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; |
769 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 760 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
770 | == XFS_ATTR_LEAF_MAGIC); | ||
771 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); | 761 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); |
772 | 762 | ||
773 | /* | 763 | /* |
@@ -810,7 +800,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
810 | nargs.trans = args->trans; | 800 | nargs.trans = args->trans; |
811 | nargs.oknoent = 1; | 801 | nargs.oknoent = 1; |
812 | entry = &leaf->entries[0]; | 802 | entry = &leaf->entries[0]; |
813 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 803 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
814 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 804 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
815 | continue; /* don't copy partial entries */ | 805 | continue; /* don't copy partial entries */ |
816 | if (!entry->nameidx) | 806 | if (!entry->nameidx) |
@@ -820,8 +810,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
820 | nargs.name = (char *)name_loc->nameval; | 810 | nargs.name = (char *)name_loc->nameval; |
821 | nargs.namelen = name_loc->namelen; | 811 | nargs.namelen = name_loc->namelen; |
822 | nargs.value = (char *)&name_loc->nameval[nargs.namelen]; | 812 | nargs.value = (char *)&name_loc->nameval[nargs.namelen]; |
823 | nargs.valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT); | 813 | nargs.valuelen = be16_to_cpu(name_loc->valuelen); |
824 | nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); | 814 | nargs.hashval = be32_to_cpu(entry->hashval); |
825 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 815 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : |
826 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); | 816 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); |
827 | xfs_attr_shortform_add(&nargs, forkoff); | 817 | xfs_attr_shortform_add(&nargs, forkoff); |
@@ -875,13 +865,12 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args) | |||
875 | goto out; | 865 | goto out; |
876 | node = bp1->data; | 866 | node = bp1->data; |
877 | leaf = bp2->data; | 867 | leaf = bp2->data; |
878 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 868 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
879 | == XFS_ATTR_LEAF_MAGIC); | ||
880 | /* both on-disk, don't endian-flip twice */ | 869 | /* both on-disk, don't endian-flip twice */ |
881 | node->btree[0].hashval = | 870 | node->btree[0].hashval = |
882 | leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval; | 871 | leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval; |
883 | INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); | 872 | node->btree[0].before = cpu_to_be32(blkno); |
884 | INT_SET(node->hdr.count, ARCH_CONVERT, 1); | 873 | node->hdr.count = cpu_to_be16(1); |
885 | xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); | 874 | xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); |
886 | error = 0; | 875 | error = 0; |
887 | out: | 876 | out: |
@@ -920,19 +909,16 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) | |||
920 | leaf = bp->data; | 909 | leaf = bp->data; |
921 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); | 910 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); |
922 | hdr = &leaf->hdr; | 911 | hdr = &leaf->hdr; |
923 | INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC); | 912 | hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC); |
924 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); | 913 | hdr->firstused = cpu_to_be16(XFS_LBSIZE(dp->i_mount)); |
925 | if (!hdr->firstused) { | 914 | if (!hdr->firstused) { |
926 | INT_SET(hdr->firstused, ARCH_CONVERT, | 915 | hdr->firstused = cpu_to_be16( |
927 | XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN); | 916 | XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN); |
928 | } | 917 | } |
929 | 918 | ||
930 | INT_SET(hdr->freemap[0].base, ARCH_CONVERT, | 919 | hdr->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); |
931 | sizeof(xfs_attr_leaf_hdr_t)); | 920 | hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) - |
932 | INT_SET(hdr->freemap[0].size, ARCH_CONVERT, | 921 | sizeof(xfs_attr_leaf_hdr_t)); |
933 | INT_GET(hdr->firstused, ARCH_CONVERT) | ||
934 | - INT_GET(hdr->freemap[0].base, | ||
935 | ARCH_CONVERT)); | ||
936 | 922 | ||
937 | xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); | 923 | xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); |
938 | 924 | ||
@@ -1004,10 +990,9 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1004 | int tablesize, entsize, sum, tmp, i; | 990 | int tablesize, entsize, sum, tmp, i; |
1005 | 991 | ||
1006 | leaf = bp->data; | 992 | leaf = bp->data; |
1007 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 993 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1008 | == XFS_ATTR_LEAF_MAGIC); | ||
1009 | ASSERT((args->index >= 0) | 994 | ASSERT((args->index >= 0) |
1010 | && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 995 | && (args->index <= be16_to_cpu(leaf->hdr.count))); |
1011 | hdr = &leaf->hdr; | 996 | hdr = &leaf->hdr; |
1012 | entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, | 997 | entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1013 | args->trans->t_mountp->m_sb.sb_blocksize, NULL); | 998 | args->trans->t_mountp->m_sb.sb_blocksize, NULL); |
@@ -1016,26 +1001,25 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1016 | * Search through freemap for first-fit on new name length. | 1001 | * Search through freemap for first-fit on new name length. |
1017 | * (may need to figure in size of entry struct too) | 1002 | * (may need to figure in size of entry struct too) |
1018 | */ | 1003 | */ |
1019 | tablesize = (INT_GET(hdr->count, ARCH_CONVERT) + 1) | 1004 | tablesize = (be16_to_cpu(hdr->count) + 1) |
1020 | * sizeof(xfs_attr_leaf_entry_t) | 1005 | * sizeof(xfs_attr_leaf_entry_t) |
1021 | + sizeof(xfs_attr_leaf_hdr_t); | 1006 | + sizeof(xfs_attr_leaf_hdr_t); |
1022 | map = &hdr->freemap[XFS_ATTR_LEAF_MAPSIZE-1]; | 1007 | map = &hdr->freemap[XFS_ATTR_LEAF_MAPSIZE-1]; |
1023 | for (sum = 0, i = XFS_ATTR_LEAF_MAPSIZE-1; i >= 0; map--, i--) { | 1008 | for (sum = 0, i = XFS_ATTR_LEAF_MAPSIZE-1; i >= 0; map--, i--) { |
1024 | if (tablesize > INT_GET(hdr->firstused, ARCH_CONVERT)) { | 1009 | if (tablesize > be16_to_cpu(hdr->firstused)) { |
1025 | sum += INT_GET(map->size, ARCH_CONVERT); | 1010 | sum += be16_to_cpu(map->size); |
1026 | continue; | 1011 | continue; |
1027 | } | 1012 | } |
1028 | if (!map->size) | 1013 | if (!map->size) |
1029 | continue; /* no space in this map */ | 1014 | continue; /* no space in this map */ |
1030 | tmp = entsize; | 1015 | tmp = entsize; |
1031 | if (INT_GET(map->base, ARCH_CONVERT) | 1016 | if (be16_to_cpu(map->base) < be16_to_cpu(hdr->firstused)) |
1032 | < INT_GET(hdr->firstused, ARCH_CONVERT)) | ||
1033 | tmp += sizeof(xfs_attr_leaf_entry_t); | 1017 | tmp += sizeof(xfs_attr_leaf_entry_t); |
1034 | if (INT_GET(map->size, ARCH_CONVERT) >= tmp) { | 1018 | if (be16_to_cpu(map->size) >= tmp) { |
1035 | tmp = xfs_attr_leaf_add_work(bp, args, i); | 1019 | tmp = xfs_attr_leaf_add_work(bp, args, i); |
1036 | return(tmp); | 1020 | return(tmp); |
1037 | } | 1021 | } |
1038 | sum += INT_GET(map->size, ARCH_CONVERT); | 1022 | sum += be16_to_cpu(map->size); |
1039 | } | 1023 | } |
1040 | 1024 | ||
1041 | /* | 1025 | /* |
@@ -1056,7 +1040,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1056 | * After compaction, the block is guaranteed to have only one | 1040 | * After compaction, the block is guaranteed to have only one |
1057 | * free region, in freemap[0]. If it is not big enough, give up. | 1041 | * free region, in freemap[0]. If it is not big enough, give up. |
1058 | */ | 1042 | */ |
1059 | if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT) | 1043 | if (be16_to_cpu(hdr->freemap[0].size) |
1060 | < (entsize + sizeof(xfs_attr_leaf_entry_t))) | 1044 | < (entsize + sizeof(xfs_attr_leaf_entry_t))) |
1061 | return(XFS_ERROR(ENOSPC)); | 1045 | return(XFS_ERROR(ENOSPC)); |
1062 | 1046 | ||
@@ -1079,45 +1063,42 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1079 | int tmp, i; | 1063 | int tmp, i; |
1080 | 1064 | ||
1081 | leaf = bp->data; | 1065 | leaf = bp->data; |
1082 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1066 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1083 | == XFS_ATTR_LEAF_MAGIC); | ||
1084 | hdr = &leaf->hdr; | 1067 | hdr = &leaf->hdr; |
1085 | ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); | 1068 | ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); |
1086 | ASSERT((args->index >= 0) | 1069 | ASSERT((args->index >= 0) && (args->index <= be16_to_cpu(hdr->count))); |
1087 | && (args->index <= INT_GET(hdr->count, ARCH_CONVERT))); | ||
1088 | 1070 | ||
1089 | /* | 1071 | /* |
1090 | * Force open some space in the entry array and fill it in. | 1072 | * Force open some space in the entry array and fill it in. |
1091 | */ | 1073 | */ |
1092 | entry = &leaf->entries[args->index]; | 1074 | entry = &leaf->entries[args->index]; |
1093 | if (args->index < INT_GET(hdr->count, ARCH_CONVERT)) { | 1075 | if (args->index < be16_to_cpu(hdr->count)) { |
1094 | tmp = INT_GET(hdr->count, ARCH_CONVERT) - args->index; | 1076 | tmp = be16_to_cpu(hdr->count) - args->index; |
1095 | tmp *= sizeof(xfs_attr_leaf_entry_t); | 1077 | tmp *= sizeof(xfs_attr_leaf_entry_t); |
1096 | memmove((char *)(entry+1), (char *)entry, tmp); | 1078 | memmove((char *)(entry+1), (char *)entry, tmp); |
1097 | xfs_da_log_buf(args->trans, bp, | 1079 | xfs_da_log_buf(args->trans, bp, |
1098 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); | 1080 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); |
1099 | } | 1081 | } |
1100 | INT_MOD(hdr->count, ARCH_CONVERT, 1); | 1082 | be16_add(&hdr->count, 1); |
1101 | 1083 | ||
1102 | /* | 1084 | /* |
1103 | * Allocate space for the new string (at the end of the run). | 1085 | * Allocate space for the new string (at the end of the run). |
1104 | */ | 1086 | */ |
1105 | map = &hdr->freemap[mapindex]; | 1087 | map = &hdr->freemap[mapindex]; |
1106 | mp = args->trans->t_mountp; | 1088 | mp = args->trans->t_mountp; |
1107 | ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1089 | ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp)); |
1108 | ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); | 1090 | ASSERT((be16_to_cpu(map->base) & 0x3) == 0); |
1109 | ASSERT(INT_GET(map->size, ARCH_CONVERT) >= | 1091 | ASSERT(be16_to_cpu(map->size) >= |
1110 | xfs_attr_leaf_newentsize(args->namelen, args->valuelen, | 1092 | xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1111 | mp->m_sb.sb_blocksize, NULL)); | 1093 | mp->m_sb.sb_blocksize, NULL)); |
1112 | ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1094 | ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); |
1113 | ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); | 1095 | ASSERT((be16_to_cpu(map->size) & 0x3) == 0); |
1114 | INT_MOD(map->size, ARCH_CONVERT, | 1096 | be16_add(&map->size, |
1115 | -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, | 1097 | -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1116 | mp->m_sb.sb_blocksize, &tmp)); | 1098 | mp->m_sb.sb_blocksize, &tmp)); |
1117 | INT_SET(entry->nameidx, ARCH_CONVERT, | 1099 | entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) + |
1118 | INT_GET(map->base, ARCH_CONVERT) | 1100 | be16_to_cpu(map->size)); |
1119 | + INT_GET(map->size, ARCH_CONVERT)); | 1101 | entry->hashval = cpu_to_be32(args->hashval); |
1120 | INT_SET(entry->hashval, ARCH_CONVERT, args->hashval); | ||
1121 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; | 1102 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; |
1122 | entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : | 1103 | entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : |
1123 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); | 1104 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); |
@@ -1130,12 +1111,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1130 | } | 1111 | } |
1131 | xfs_da_log_buf(args->trans, bp, | 1112 | xfs_da_log_buf(args->trans, bp, |
1132 | XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); | 1113 | XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); |
1133 | ASSERT((args->index == 0) || (INT_GET(entry->hashval, ARCH_CONVERT) | 1114 | ASSERT((args->index == 0) || |
1134 | >= INT_GET((entry-1)->hashval, | 1115 | (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval))); |
1135 | ARCH_CONVERT))); | 1116 | ASSERT((args->index == be16_to_cpu(hdr->count)-1) || |
1136 | ASSERT((args->index == INT_GET(hdr->count, ARCH_CONVERT)-1) || | 1117 | (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval))); |
1137 | (INT_GET(entry->hashval, ARCH_CONVERT) | ||
1138 | <= (INT_GET((entry+1)->hashval, ARCH_CONVERT)))); | ||
1139 | 1118 | ||
1140 | /* | 1119 | /* |
1141 | * Copy the attribute name and value into the new space. | 1120 | * Copy the attribute name and value into the new space. |
@@ -1149,10 +1128,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1149 | if (entry->flags & XFS_ATTR_LOCAL) { | 1128 | if (entry->flags & XFS_ATTR_LOCAL) { |
1150 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); | 1129 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); |
1151 | name_loc->namelen = args->namelen; | 1130 | name_loc->namelen = args->namelen; |
1152 | INT_SET(name_loc->valuelen, ARCH_CONVERT, args->valuelen); | 1131 | name_loc->valuelen = cpu_to_be16(args->valuelen); |
1153 | memcpy((char *)name_loc->nameval, args->name, args->namelen); | 1132 | memcpy((char *)name_loc->nameval, args->name, args->namelen); |
1154 | memcpy((char *)&name_loc->nameval[args->namelen], args->value, | 1133 | memcpy((char *)&name_loc->nameval[args->namelen], args->value, |
1155 | INT_GET(name_loc->valuelen, ARCH_CONVERT)); | 1134 | be16_to_cpu(name_loc->valuelen)); |
1156 | } else { | 1135 | } else { |
1157 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); | 1136 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); |
1158 | name_rmt->namelen = args->namelen; | 1137 | name_rmt->namelen = args->namelen; |
@@ -1171,28 +1150,23 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1171 | /* | 1150 | /* |
1172 | * Update the control info for this leaf node | 1151 | * Update the control info for this leaf node |
1173 | */ | 1152 | */ |
1174 | if (INT_GET(entry->nameidx, ARCH_CONVERT) | 1153 | if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused)) { |
1175 | < INT_GET(hdr->firstused, ARCH_CONVERT)) { | ||
1176 | /* both on-disk, don't endian-flip twice */ | 1154 | /* both on-disk, don't endian-flip twice */ |
1177 | hdr->firstused = entry->nameidx; | 1155 | hdr->firstused = entry->nameidx; |
1178 | } | 1156 | } |
1179 | ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT) | 1157 | ASSERT(be16_to_cpu(hdr->firstused) >= |
1180 | >= ((INT_GET(hdr->count, ARCH_CONVERT) | 1158 | ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr))); |
1181 | * sizeof(*entry))+sizeof(*hdr))); | 1159 | tmp = (be16_to_cpu(hdr->count)-1) * sizeof(xfs_attr_leaf_entry_t) |
1182 | tmp = (INT_GET(hdr->count, ARCH_CONVERT)-1) | ||
1183 | * sizeof(xfs_attr_leaf_entry_t) | ||
1184 | + sizeof(xfs_attr_leaf_hdr_t); | 1160 | + sizeof(xfs_attr_leaf_hdr_t); |
1185 | map = &hdr->freemap[0]; | 1161 | map = &hdr->freemap[0]; |
1186 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { | 1162 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { |
1187 | if (INT_GET(map->base, ARCH_CONVERT) == tmp) { | 1163 | if (be16_to_cpu(map->base) == tmp) { |
1188 | INT_MOD(map->base, ARCH_CONVERT, | 1164 | be16_add(&map->base, sizeof(xfs_attr_leaf_entry_t)); |
1189 | sizeof(xfs_attr_leaf_entry_t)); | 1165 | be16_add(&map->size, |
1190 | INT_MOD(map->size, ARCH_CONVERT, | 1166 | -((int)sizeof(xfs_attr_leaf_entry_t))); |
1191 | -sizeof(xfs_attr_leaf_entry_t)); | ||
1192 | } | 1167 | } |
1193 | } | 1168 | } |
1194 | INT_MOD(hdr->usedbytes, ARCH_CONVERT, | 1169 | be16_add(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index)); |
1195 | xfs_attr_leaf_entsize(leaf, args->index)); | ||
1196 | xfs_da_log_buf(args->trans, bp, | 1170 | xfs_da_log_buf(args->trans, bp, |
1197 | XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); | 1171 | XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); |
1198 | return(0); | 1172 | return(0); |
@@ -1223,28 +1197,25 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp) | |||
1223 | hdr_s = &leaf_s->hdr; | 1197 | hdr_s = &leaf_s->hdr; |
1224 | hdr_d = &leaf_d->hdr; | 1198 | hdr_d = &leaf_d->hdr; |
1225 | hdr_d->info = hdr_s->info; /* struct copy */ | 1199 | hdr_d->info = hdr_s->info; /* struct copy */ |
1226 | INT_SET(hdr_d->firstused, ARCH_CONVERT, XFS_LBSIZE(mp)); | 1200 | hdr_d->firstused = cpu_to_be16(XFS_LBSIZE(mp)); |
1227 | /* handle truncation gracefully */ | 1201 | /* handle truncation gracefully */ |
1228 | if (!hdr_d->firstused) { | 1202 | if (!hdr_d->firstused) { |
1229 | INT_SET(hdr_d->firstused, ARCH_CONVERT, | 1203 | hdr_d->firstused = cpu_to_be16( |
1230 | XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN); | 1204 | XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN); |
1231 | } | 1205 | } |
1232 | hdr_d->usedbytes = 0; | 1206 | hdr_d->usedbytes = 0; |
1233 | hdr_d->count = 0; | 1207 | hdr_d->count = 0; |
1234 | hdr_d->holes = 0; | 1208 | hdr_d->holes = 0; |
1235 | INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT, | 1209 | hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); |
1236 | sizeof(xfs_attr_leaf_hdr_t)); | 1210 | hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) - |
1237 | INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT, | 1211 | sizeof(xfs_attr_leaf_hdr_t)); |
1238 | INT_GET(hdr_d->firstused, ARCH_CONVERT) | ||
1239 | - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT)); | ||
1240 | 1212 | ||
1241 | /* | 1213 | /* |
1242 | * Copy all entry's in the same (sorted) order, | 1214 | * Copy all entry's in the same (sorted) order, |
1243 | * but allocate name/value pairs packed and in sequence. | 1215 | * but allocate name/value pairs packed and in sequence. |
1244 | */ | 1216 | */ |
1245 | xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0, | 1217 | xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0, |
1246 | (int)INT_GET(hdr_s->count, ARCH_CONVERT), mp); | 1218 | be16_to_cpu(hdr_s->count), mp); |
1247 | |||
1248 | xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); | 1219 | xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); |
1249 | 1220 | ||
1250 | kmem_free(tmpbuffer, XFS_LBSIZE(mp)); | 1221 | kmem_free(tmpbuffer, XFS_LBSIZE(mp)); |
@@ -1279,10 +1250,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1279 | ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); | 1250 | ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); |
1280 | leaf1 = blk1->bp->data; | 1251 | leaf1 = blk1->bp->data; |
1281 | leaf2 = blk2->bp->data; | 1252 | leaf2 = blk2->bp->data; |
1282 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 1253 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1283 | == XFS_ATTR_LEAF_MAGIC); | 1254 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1284 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | ||
1285 | == XFS_ATTR_LEAF_MAGIC); | ||
1286 | args = state->args; | 1255 | args = state->args; |
1287 | 1256 | ||
1288 | /* | 1257 | /* |
@@ -1319,22 +1288,21 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1319 | /* | 1288 | /* |
1320 | * Move any entries required from leaf to leaf: | 1289 | * Move any entries required from leaf to leaf: |
1321 | */ | 1290 | */ |
1322 | if (count < INT_GET(hdr1->count, ARCH_CONVERT)) { | 1291 | if (count < be16_to_cpu(hdr1->count)) { |
1323 | /* | 1292 | /* |
1324 | * Figure the total bytes to be added to the destination leaf. | 1293 | * Figure the total bytes to be added to the destination leaf. |
1325 | */ | 1294 | */ |
1326 | /* number entries being moved */ | 1295 | /* number entries being moved */ |
1327 | count = INT_GET(hdr1->count, ARCH_CONVERT) - count; | 1296 | count = be16_to_cpu(hdr1->count) - count; |
1328 | space = INT_GET(hdr1->usedbytes, ARCH_CONVERT) - totallen; | 1297 | space = be16_to_cpu(hdr1->usedbytes) - totallen; |
1329 | space += count * sizeof(xfs_attr_leaf_entry_t); | 1298 | space += count * sizeof(xfs_attr_leaf_entry_t); |
1330 | 1299 | ||
1331 | /* | 1300 | /* |
1332 | * leaf2 is the destination, compact it if it looks tight. | 1301 | * leaf2 is the destination, compact it if it looks tight. |
1333 | */ | 1302 | */ |
1334 | max = INT_GET(hdr2->firstused, ARCH_CONVERT) | 1303 | max = be16_to_cpu(hdr2->firstused) |
1335 | - sizeof(xfs_attr_leaf_hdr_t); | 1304 | - sizeof(xfs_attr_leaf_hdr_t); |
1336 | max -= INT_GET(hdr2->count, ARCH_CONVERT) | 1305 | max -= be16_to_cpu(hdr2->count) * sizeof(xfs_attr_leaf_entry_t); |
1337 | * sizeof(xfs_attr_leaf_entry_t); | ||
1338 | if (space > max) { | 1306 | if (space > max) { |
1339 | xfs_attr_leaf_compact(args->trans, blk2->bp); | 1307 | xfs_attr_leaf_compact(args->trans, blk2->bp); |
1340 | } | 1308 | } |
@@ -1342,13 +1310,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1342 | /* | 1310 | /* |
1343 | * Move high entries from leaf1 to low end of leaf2. | 1311 | * Move high entries from leaf1 to low end of leaf2. |
1344 | */ | 1312 | */ |
1345 | xfs_attr_leaf_moveents(leaf1, | 1313 | xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count, |
1346 | INT_GET(hdr1->count, ARCH_CONVERT)-count, | ||
1347 | leaf2, 0, count, state->mp); | 1314 | leaf2, 0, count, state->mp); |
1348 | 1315 | ||
1349 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); | 1316 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); |
1350 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); | 1317 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); |
1351 | } else if (count > INT_GET(hdr1->count, ARCH_CONVERT)) { | 1318 | } else if (count > be16_to_cpu(hdr1->count)) { |
1352 | /* | 1319 | /* |
1353 | * I assert that since all callers pass in an empty | 1320 | * I assert that since all callers pass in an empty |
1354 | * second buffer, this code should never execute. | 1321 | * second buffer, this code should never execute. |
@@ -1358,17 +1325,16 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1358 | * Figure the total bytes to be added to the destination leaf. | 1325 | * Figure the total bytes to be added to the destination leaf. |
1359 | */ | 1326 | */ |
1360 | /* number entries being moved */ | 1327 | /* number entries being moved */ |
1361 | count -= INT_GET(hdr1->count, ARCH_CONVERT); | 1328 | count -= be16_to_cpu(hdr1->count); |
1362 | space = totallen - INT_GET(hdr1->usedbytes, ARCH_CONVERT); | 1329 | space = totallen - be16_to_cpu(hdr1->usedbytes); |
1363 | space += count * sizeof(xfs_attr_leaf_entry_t); | 1330 | space += count * sizeof(xfs_attr_leaf_entry_t); |
1364 | 1331 | ||
1365 | /* | 1332 | /* |
1366 | * leaf1 is the destination, compact it if it looks tight. | 1333 | * leaf1 is the destination, compact it if it looks tight. |
1367 | */ | 1334 | */ |
1368 | max = INT_GET(hdr1->firstused, ARCH_CONVERT) | 1335 | max = be16_to_cpu(hdr1->firstused) |
1369 | - sizeof(xfs_attr_leaf_hdr_t); | 1336 | - sizeof(xfs_attr_leaf_hdr_t); |
1370 | max -= INT_GET(hdr1->count, ARCH_CONVERT) | 1337 | max -= be16_to_cpu(hdr1->count) * sizeof(xfs_attr_leaf_entry_t); |
1371 | * sizeof(xfs_attr_leaf_entry_t); | ||
1372 | if (space > max) { | 1338 | if (space > max) { |
1373 | xfs_attr_leaf_compact(args->trans, blk1->bp); | 1339 | xfs_attr_leaf_compact(args->trans, blk1->bp); |
1374 | } | 1340 | } |
@@ -1377,8 +1343,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1377 | * Move low entries from leaf2 to high end of leaf1. | 1343 | * Move low entries from leaf2 to high end of leaf1. |
1378 | */ | 1344 | */ |
1379 | xfs_attr_leaf_moveents(leaf2, 0, leaf1, | 1345 | xfs_attr_leaf_moveents(leaf2, 0, leaf1, |
1380 | (int)INT_GET(hdr1->count, ARCH_CONVERT), count, | 1346 | be16_to_cpu(hdr1->count), count, state->mp); |
1381 | state->mp); | ||
1382 | 1347 | ||
1383 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); | 1348 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); |
1384 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); | 1349 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); |
@@ -1387,12 +1352,10 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1387 | /* | 1352 | /* |
1388 | * Copy out last hashval in each block for B-tree code. | 1353 | * Copy out last hashval in each block for B-tree code. |
1389 | */ | 1354 | */ |
1390 | blk1->hashval = | 1355 | blk1->hashval = be32_to_cpu( |
1391 | INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count, | 1356 | leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval); |
1392 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT); | 1357 | blk2->hashval = be32_to_cpu( |
1393 | blk2->hashval = | 1358 | leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval); |
1394 | INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count, | ||
1395 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT); | ||
1396 | 1359 | ||
1397 | /* | 1360 | /* |
1398 | * Adjust the expected index for insertion. | 1361 | * Adjust the expected index for insertion. |
@@ -1406,13 +1369,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1406 | * inserting. The index/blkno fields refer to the "old" entry, | 1369 | * inserting. The index/blkno fields refer to the "old" entry, |
1407 | * while the index2/blkno2 fields refer to the "new" entry. | 1370 | * while the index2/blkno2 fields refer to the "new" entry. |
1408 | */ | 1371 | */ |
1409 | if (blk1->index > INT_GET(leaf1->hdr.count, ARCH_CONVERT)) { | 1372 | if (blk1->index > be16_to_cpu(leaf1->hdr.count)) { |
1410 | ASSERT(state->inleaf == 0); | 1373 | ASSERT(state->inleaf == 0); |
1411 | blk2->index = blk1->index | 1374 | blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count); |
1412 | - INT_GET(leaf1->hdr.count, ARCH_CONVERT); | ||
1413 | args->index = args->index2 = blk2->index; | 1375 | args->index = args->index2 = blk2->index; |
1414 | args->blkno = args->blkno2 = blk2->blkno; | 1376 | args->blkno = args->blkno2 = blk2->blkno; |
1415 | } else if (blk1->index == INT_GET(leaf1->hdr.count, ARCH_CONVERT)) { | 1377 | } else if (blk1->index == be16_to_cpu(leaf1->hdr.count)) { |
1416 | if (state->inleaf) { | 1378 | if (state->inleaf) { |
1417 | args->index = blk1->index; | 1379 | args->index = blk1->index; |
1418 | args->blkno = blk1->blkno; | 1380 | args->blkno = blk1->blkno; |
@@ -1420,7 +1382,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1420 | args->blkno2 = blk2->blkno; | 1382 | args->blkno2 = blk2->blkno; |
1421 | } else { | 1383 | } else { |
1422 | blk2->index = blk1->index | 1384 | blk2->index = blk1->index |
1423 | - INT_GET(leaf1->hdr.count, ARCH_CONVERT); | 1385 | - be16_to_cpu(leaf1->hdr.count); |
1424 | args->index = args->index2 = blk2->index; | 1386 | args->index = args->index2 = blk2->index; |
1425 | args->blkno = args->blkno2 = blk2->blkno; | 1387 | args->blkno = args->blkno2 = blk2->blkno; |
1426 | } | 1388 | } |
@@ -1464,15 +1426,14 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1464 | * Examine entries until we reduce the absolute difference in | 1426 | * Examine entries until we reduce the absolute difference in |
1465 | * byte usage between the two blocks to a minimum. | 1427 | * byte usage between the two blocks to a minimum. |
1466 | */ | 1428 | */ |
1467 | max = INT_GET(hdr1->count, ARCH_CONVERT) | 1429 | max = be16_to_cpu(hdr1->count) + be16_to_cpu(hdr2->count); |
1468 | + INT_GET(hdr2->count, ARCH_CONVERT); | ||
1469 | half = (max+1) * sizeof(*entry); | 1430 | half = (max+1) * sizeof(*entry); |
1470 | half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) | 1431 | half += be16_to_cpu(hdr1->usedbytes) + |
1471 | + INT_GET(hdr2->usedbytes, ARCH_CONVERT) | 1432 | be16_to_cpu(hdr2->usedbytes) + |
1472 | + xfs_attr_leaf_newentsize( | 1433 | xfs_attr_leaf_newentsize( |
1473 | state->args->namelen, | 1434 | state->args->namelen, |
1474 | state->args->valuelen, | 1435 | state->args->valuelen, |
1475 | state->blocksize, NULL); | 1436 | state->blocksize, NULL); |
1476 | half /= 2; | 1437 | half /= 2; |
1477 | lastdelta = state->blocksize; | 1438 | lastdelta = state->blocksize; |
1478 | entry = &leaf1->entries[0]; | 1439 | entry = &leaf1->entries[0]; |
@@ -1498,7 +1459,7 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1498 | /* | 1459 | /* |
1499 | * Wrap around into the second block if necessary. | 1460 | * Wrap around into the second block if necessary. |
1500 | */ | 1461 | */ |
1501 | if (count == INT_GET(hdr1->count, ARCH_CONVERT)) { | 1462 | if (count == be16_to_cpu(hdr1->count)) { |
1502 | leaf1 = leaf2; | 1463 | leaf1 = leaf2; |
1503 | entry = &leaf1->entries[0]; | 1464 | entry = &leaf1->entries[0]; |
1504 | index = 0; | 1465 | index = 0; |
@@ -1566,12 +1527,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1566 | */ | 1527 | */ |
1567 | blk = &state->path.blk[ state->path.active-1 ]; | 1528 | blk = &state->path.blk[ state->path.active-1 ]; |
1568 | info = blk->bp->data; | 1529 | info = blk->bp->data; |
1569 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1530 | ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); |
1570 | leaf = (xfs_attr_leafblock_t *)info; | 1531 | leaf = (xfs_attr_leafblock_t *)info; |
1571 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1532 | count = be16_to_cpu(leaf->hdr.count); |
1572 | bytes = sizeof(xfs_attr_leaf_hdr_t) + | 1533 | bytes = sizeof(xfs_attr_leaf_hdr_t) + |
1573 | count * sizeof(xfs_attr_leaf_entry_t) + | 1534 | count * sizeof(xfs_attr_leaf_entry_t) + |
1574 | INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | 1535 | be16_to_cpu(leaf->hdr.usedbytes); |
1575 | if (bytes > (state->blocksize >> 1)) { | 1536 | if (bytes > (state->blocksize >> 1)) { |
1576 | *action = 0; /* blk over 50%, don't try to join */ | 1537 | *action = 0; /* blk over 50%, don't try to join */ |
1577 | return(0); | 1538 | return(0); |
@@ -1588,7 +1549,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1588 | * Make altpath point to the block we want to keep and | 1549 | * Make altpath point to the block we want to keep and |
1589 | * path point to the block we want to drop (this one). | 1550 | * path point to the block we want to drop (this one). |
1590 | */ | 1551 | */ |
1591 | forward = info->forw; | 1552 | forward = (info->forw != 0); |
1592 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1553 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1593 | error = xfs_da_path_shift(state, &state->altpath, forward, | 1554 | error = xfs_da_path_shift(state, &state->altpath, forward, |
1594 | 0, &retval); | 1555 | 0, &retval); |
@@ -1610,13 +1571,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1610 | * to shrink an attribute list over time. | 1571 | * to shrink an attribute list over time. |
1611 | */ | 1572 | */ |
1612 | /* start with smaller blk num */ | 1573 | /* start with smaller blk num */ |
1613 | forward = (INT_GET(info->forw, ARCH_CONVERT) | 1574 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); |
1614 | < INT_GET(info->back, ARCH_CONVERT)); | ||
1615 | for (i = 0; i < 2; forward = !forward, i++) { | 1575 | for (i = 0; i < 2; forward = !forward, i++) { |
1616 | if (forward) | 1576 | if (forward) |
1617 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 1577 | blkno = be32_to_cpu(info->forw); |
1618 | else | 1578 | else |
1619 | blkno = INT_GET(info->back, ARCH_CONVERT); | 1579 | blkno = be32_to_cpu(info->back); |
1620 | if (blkno == 0) | 1580 | if (blkno == 0) |
1621 | continue; | 1581 | continue; |
1622 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 1582 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -1626,14 +1586,13 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1626 | ASSERT(bp != NULL); | 1586 | ASSERT(bp != NULL); |
1627 | 1587 | ||
1628 | leaf = (xfs_attr_leafblock_t *)info; | 1588 | leaf = (xfs_attr_leafblock_t *)info; |
1629 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1589 | count = be16_to_cpu(leaf->hdr.count); |
1630 | bytes = state->blocksize - (state->blocksize>>2); | 1590 | bytes = state->blocksize - (state->blocksize>>2); |
1631 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | 1591 | bytes -= be16_to_cpu(leaf->hdr.usedbytes); |
1632 | leaf = bp->data; | 1592 | leaf = bp->data; |
1633 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1593 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1634 | == XFS_ATTR_LEAF_MAGIC); | 1594 | count += be16_to_cpu(leaf->hdr.count); |
1635 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1595 | bytes -= be16_to_cpu(leaf->hdr.usedbytes); |
1636 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | ||
1637 | bytes -= count * sizeof(xfs_attr_leaf_entry_t); | 1596 | bytes -= count * sizeof(xfs_attr_leaf_entry_t); |
1638 | bytes -= sizeof(xfs_attr_leaf_hdr_t); | 1597 | bytes -= sizeof(xfs_attr_leaf_hdr_t); |
1639 | xfs_da_brelse(state->args->trans, bp); | 1598 | xfs_da_brelse(state->args->trans, bp); |
@@ -1685,21 +1644,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1685 | xfs_mount_t *mp; | 1644 | xfs_mount_t *mp; |
1686 | 1645 | ||
1687 | leaf = bp->data; | 1646 | leaf = bp->data; |
1688 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1647 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1689 | == XFS_ATTR_LEAF_MAGIC); | ||
1690 | hdr = &leaf->hdr; | 1648 | hdr = &leaf->hdr; |
1691 | mp = args->trans->t_mountp; | 1649 | mp = args->trans->t_mountp; |
1692 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) | 1650 | ASSERT((be16_to_cpu(hdr->count) > 0) |
1693 | && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1651 | && (be16_to_cpu(hdr->count) < (XFS_LBSIZE(mp)/8))); |
1694 | ASSERT((args->index >= 0) | 1652 | ASSERT((args->index >= 0) |
1695 | && (args->index < INT_GET(hdr->count, ARCH_CONVERT))); | 1653 | && (args->index < be16_to_cpu(hdr->count))); |
1696 | ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT) | 1654 | ASSERT(be16_to_cpu(hdr->firstused) >= |
1697 | >= ((INT_GET(hdr->count, ARCH_CONVERT) | 1655 | ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr))); |
1698 | * sizeof(*entry))+sizeof(*hdr))); | ||
1699 | entry = &leaf->entries[args->index]; | 1656 | entry = &leaf->entries[args->index]; |
1700 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) | 1657 | ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused)); |
1701 | >= INT_GET(hdr->firstused, ARCH_CONVERT)); | 1658 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); |
1702 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp)); | ||
1703 | 1659 | ||
1704 | /* | 1660 | /* |
1705 | * Scan through free region table: | 1661 | * Scan through free region table: |
@@ -1707,33 +1663,30 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1707 | * find smallest free region in case we need to replace it, | 1663 | * find smallest free region in case we need to replace it, |
1708 | * adjust any map that borders the entry table, | 1664 | * adjust any map that borders the entry table, |
1709 | */ | 1665 | */ |
1710 | tablesize = INT_GET(hdr->count, ARCH_CONVERT) | 1666 | tablesize = be16_to_cpu(hdr->count) * sizeof(xfs_attr_leaf_entry_t) |
1711 | * sizeof(xfs_attr_leaf_entry_t) | ||
1712 | + sizeof(xfs_attr_leaf_hdr_t); | 1667 | + sizeof(xfs_attr_leaf_hdr_t); |
1713 | map = &hdr->freemap[0]; | 1668 | map = &hdr->freemap[0]; |
1714 | tmp = INT_GET(map->size, ARCH_CONVERT); | 1669 | tmp = be16_to_cpu(map->size); |
1715 | before = after = -1; | 1670 | before = after = -1; |
1716 | smallest = XFS_ATTR_LEAF_MAPSIZE - 1; | 1671 | smallest = XFS_ATTR_LEAF_MAPSIZE - 1; |
1717 | entsize = xfs_attr_leaf_entsize(leaf, args->index); | 1672 | entsize = xfs_attr_leaf_entsize(leaf, args->index); |
1718 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { | 1673 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { |
1719 | ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1674 | ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp)); |
1720 | ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1675 | ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); |
1721 | if (INT_GET(map->base, ARCH_CONVERT) == tablesize) { | 1676 | if (be16_to_cpu(map->base) == tablesize) { |
1722 | INT_MOD(map->base, ARCH_CONVERT, | 1677 | be16_add(&map->base, |
1723 | -sizeof(xfs_attr_leaf_entry_t)); | 1678 | -((int)sizeof(xfs_attr_leaf_entry_t))); |
1724 | INT_MOD(map->size, ARCH_CONVERT, | 1679 | be16_add(&map->size, sizeof(xfs_attr_leaf_entry_t)); |
1725 | sizeof(xfs_attr_leaf_entry_t)); | ||
1726 | } | 1680 | } |
1727 | 1681 | ||
1728 | if ((INT_GET(map->base, ARCH_CONVERT) | 1682 | if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) |
1729 | + INT_GET(map->size, ARCH_CONVERT)) | 1683 | == be16_to_cpu(entry->nameidx)) { |
1730 | == INT_GET(entry->nameidx, ARCH_CONVERT)) { | ||
1731 | before = i; | 1684 | before = i; |
1732 | } else if (INT_GET(map->base, ARCH_CONVERT) | 1685 | } else if (be16_to_cpu(map->base) |
1733 | == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) { | 1686 | == (be16_to_cpu(entry->nameidx) + entsize)) { |
1734 | after = i; | 1687 | after = i; |
1735 | } else if (INT_GET(map->size, ARCH_CONVERT) < tmp) { | 1688 | } else if (be16_to_cpu(map->size) < tmp) { |
1736 | tmp = INT_GET(map->size, ARCH_CONVERT); | 1689 | tmp = be16_to_cpu(map->size); |
1737 | smallest = i; | 1690 | smallest = i; |
1738 | } | 1691 | } |
1739 | } | 1692 | } |
@@ -1745,38 +1698,35 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1745 | if ((before >= 0) || (after >= 0)) { | 1698 | if ((before >= 0) || (after >= 0)) { |
1746 | if ((before >= 0) && (after >= 0)) { | 1699 | if ((before >= 0) && (after >= 0)) { |
1747 | map = &hdr->freemap[before]; | 1700 | map = &hdr->freemap[before]; |
1748 | INT_MOD(map->size, ARCH_CONVERT, entsize); | 1701 | be16_add(&map->size, entsize); |
1749 | INT_MOD(map->size, ARCH_CONVERT, | 1702 | be16_add(&map->size, |
1750 | INT_GET(hdr->freemap[after].size, | 1703 | be16_to_cpu(hdr->freemap[after].size)); |
1751 | ARCH_CONVERT)); | ||
1752 | hdr->freemap[after].base = 0; | 1704 | hdr->freemap[after].base = 0; |
1753 | hdr->freemap[after].size = 0; | 1705 | hdr->freemap[after].size = 0; |
1754 | } else if (before >= 0) { | 1706 | } else if (before >= 0) { |
1755 | map = &hdr->freemap[before]; | 1707 | map = &hdr->freemap[before]; |
1756 | INT_MOD(map->size, ARCH_CONVERT, entsize); | 1708 | be16_add(&map->size, entsize); |
1757 | } else { | 1709 | } else { |
1758 | map = &hdr->freemap[after]; | 1710 | map = &hdr->freemap[after]; |
1759 | /* both on-disk, don't endian flip twice */ | 1711 | /* both on-disk, don't endian flip twice */ |
1760 | map->base = entry->nameidx; | 1712 | map->base = entry->nameidx; |
1761 | INT_MOD(map->size, ARCH_CONVERT, entsize); | 1713 | be16_add(&map->size, entsize); |
1762 | } | 1714 | } |
1763 | } else { | 1715 | } else { |
1764 | /* | 1716 | /* |
1765 | * Replace smallest region (if it is smaller than free'd entry) | 1717 | * Replace smallest region (if it is smaller than free'd entry) |
1766 | */ | 1718 | */ |
1767 | map = &hdr->freemap[smallest]; | 1719 | map = &hdr->freemap[smallest]; |
1768 | if (INT_GET(map->size, ARCH_CONVERT) < entsize) { | 1720 | if (be16_to_cpu(map->size) < entsize) { |
1769 | INT_SET(map->base, ARCH_CONVERT, | 1721 | map->base = cpu_to_be16(be16_to_cpu(entry->nameidx)); |
1770 | INT_GET(entry->nameidx, ARCH_CONVERT)); | 1722 | map->size = cpu_to_be16(entsize); |
1771 | INT_SET(map->size, ARCH_CONVERT, entsize); | ||
1772 | } | 1723 | } |
1773 | } | 1724 | } |
1774 | 1725 | ||
1775 | /* | 1726 | /* |
1776 | * Did we remove the first entry? | 1727 | * Did we remove the first entry? |
1777 | */ | 1728 | */ |
1778 | if (INT_GET(entry->nameidx, ARCH_CONVERT) | 1729 | if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused)) |
1779 | == INT_GET(hdr->firstused, ARCH_CONVERT)) | ||
1780 | smallest = 1; | 1730 | smallest = 1; |
1781 | else | 1731 | else |
1782 | smallest = 0; | 1732 | smallest = 0; |
@@ -1785,18 +1735,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1785 | * Compress the remaining entries and zero out the removed stuff. | 1735 | * Compress the remaining entries and zero out the removed stuff. |
1786 | */ | 1736 | */ |
1787 | memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize); | 1737 | memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize); |
1788 | INT_MOD(hdr->usedbytes, ARCH_CONVERT, -entsize); | 1738 | be16_add(&hdr->usedbytes, -entsize); |
1789 | xfs_da_log_buf(args->trans, bp, | 1739 | xfs_da_log_buf(args->trans, bp, |
1790 | XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), | 1740 | XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), |
1791 | entsize)); | 1741 | entsize)); |
1792 | 1742 | ||
1793 | tmp = (INT_GET(hdr->count, ARCH_CONVERT) - args->index) | 1743 | tmp = (be16_to_cpu(hdr->count) - args->index) |
1794 | * sizeof(xfs_attr_leaf_entry_t); | 1744 | * sizeof(xfs_attr_leaf_entry_t); |
1795 | memmove((char *)entry, (char *)(entry+1), tmp); | 1745 | memmove((char *)entry, (char *)(entry+1), tmp); |
1796 | INT_MOD(hdr->count, ARCH_CONVERT, -1); | 1746 | be16_add(&hdr->count, -1); |
1797 | xfs_da_log_buf(args->trans, bp, | 1747 | xfs_da_log_buf(args->trans, bp, |
1798 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); | 1748 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); |
1799 | entry = &leaf->entries[INT_GET(hdr->count, ARCH_CONVERT)]; | 1749 | entry = &leaf->entries[be16_to_cpu(hdr->count)]; |
1800 | memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t)); | 1750 | memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t)); |
1801 | 1751 | ||
1802 | /* | 1752 | /* |
@@ -1808,18 +1758,17 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1808 | if (smallest) { | 1758 | if (smallest) { |
1809 | tmp = XFS_LBSIZE(mp); | 1759 | tmp = XFS_LBSIZE(mp); |
1810 | entry = &leaf->entries[0]; | 1760 | entry = &leaf->entries[0]; |
1811 | for (i = INT_GET(hdr->count, ARCH_CONVERT)-1; | 1761 | for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { |
1812 | i >= 0; entry++, i--) { | 1762 | ASSERT(be16_to_cpu(entry->nameidx) >= |
1813 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) | 1763 | be16_to_cpu(hdr->firstused)); |
1814 | >= INT_GET(hdr->firstused, ARCH_CONVERT)); | 1764 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); |
1815 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) | 1765 | |
1816 | < XFS_LBSIZE(mp)); | 1766 | if (be16_to_cpu(entry->nameidx) < tmp) |
1817 | if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp) | 1767 | tmp = be16_to_cpu(entry->nameidx); |
1818 | tmp = INT_GET(entry->nameidx, ARCH_CONVERT); | ||
1819 | } | 1768 | } |
1820 | INT_SET(hdr->firstused, ARCH_CONVERT, tmp); | 1769 | hdr->firstused = cpu_to_be16(tmp); |
1821 | if (!hdr->firstused) { | 1770 | if (!hdr->firstused) { |
1822 | INT_SET(hdr->firstused, ARCH_CONVERT, | 1771 | hdr->firstused = cpu_to_be16( |
1823 | tmp - XFS_ATTR_LEAF_NAME_ALIGN); | 1772 | tmp - XFS_ATTR_LEAF_NAME_ALIGN); |
1824 | } | 1773 | } |
1825 | } else { | 1774 | } else { |
@@ -1833,9 +1782,8 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1833 | * "join" the leaf with a sibling if so. | 1782 | * "join" the leaf with a sibling if so. |
1834 | */ | 1783 | */ |
1835 | tmp = sizeof(xfs_attr_leaf_hdr_t); | 1784 | tmp = sizeof(xfs_attr_leaf_hdr_t); |
1836 | tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT) | 1785 | tmp += be16_to_cpu(leaf->hdr.count) * sizeof(xfs_attr_leaf_entry_t); |
1837 | * sizeof(xfs_attr_leaf_entry_t); | 1786 | tmp += be16_to_cpu(leaf->hdr.usedbytes); |
1838 | tmp += INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | ||
1839 | return(tmp < mp->m_attr_magicpct); /* leaf is < 37% full */ | 1787 | return(tmp < mp->m_attr_magicpct); /* leaf is < 37% full */ |
1840 | } | 1788 | } |
1841 | 1789 | ||
@@ -1859,20 +1807,16 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1859 | ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1807 | ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1860 | drop_leaf = drop_blk->bp->data; | 1808 | drop_leaf = drop_blk->bp->data; |
1861 | save_leaf = save_blk->bp->data; | 1809 | save_leaf = save_blk->bp->data; |
1862 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) | 1810 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1863 | == XFS_ATTR_LEAF_MAGIC); | 1811 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1864 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) | ||
1865 | == XFS_ATTR_LEAF_MAGIC); | ||
1866 | drop_hdr = &drop_leaf->hdr; | 1812 | drop_hdr = &drop_leaf->hdr; |
1867 | save_hdr = &save_leaf->hdr; | 1813 | save_hdr = &save_leaf->hdr; |
1868 | 1814 | ||
1869 | /* | 1815 | /* |
1870 | * Save last hashval from dying block for later Btree fixup. | 1816 | * Save last hashval from dying block for later Btree fixup. |
1871 | */ | 1817 | */ |
1872 | drop_blk->hashval = | 1818 | drop_blk->hashval = be32_to_cpu( |
1873 | INT_GET(drop_leaf->entries[INT_GET(drop_leaf->hdr.count, | 1819 | drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval); |
1874 | ARCH_CONVERT)-1].hashval, | ||
1875 | ARCH_CONVERT); | ||
1876 | 1820 | ||
1877 | /* | 1821 | /* |
1878 | * Check if we need a temp buffer, or can we do it in place. | 1822 | * Check if we need a temp buffer, or can we do it in place. |
@@ -1886,12 +1830,11 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1886 | */ | 1830 | */ |
1887 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { | 1831 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { |
1888 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, 0, | 1832 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, 0, |
1889 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), mp); | 1833 | be16_to_cpu(drop_hdr->count), mp); |
1890 | } else { | 1834 | } else { |
1891 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, | 1835 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, |
1892 | INT_GET(save_hdr->count, ARCH_CONVERT), | 1836 | be16_to_cpu(save_hdr->count), |
1893 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), | 1837 | be16_to_cpu(drop_hdr->count), mp); |
1894 | mp); | ||
1895 | } | 1838 | } |
1896 | } else { | 1839 | } else { |
1897 | /* | 1840 | /* |
@@ -1905,28 +1848,24 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1905 | tmp_hdr = &tmp_leaf->hdr; | 1848 | tmp_hdr = &tmp_leaf->hdr; |
1906 | tmp_hdr->info = save_hdr->info; /* struct copy */ | 1849 | tmp_hdr->info = save_hdr->info; /* struct copy */ |
1907 | tmp_hdr->count = 0; | 1850 | tmp_hdr->count = 0; |
1908 | INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize); | 1851 | tmp_hdr->firstused = cpu_to_be16(state->blocksize); |
1909 | if (!tmp_hdr->firstused) { | 1852 | if (!tmp_hdr->firstused) { |
1910 | INT_SET(tmp_hdr->firstused, ARCH_CONVERT, | 1853 | tmp_hdr->firstused = cpu_to_be16( |
1911 | state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN); | 1854 | state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN); |
1912 | } | 1855 | } |
1913 | tmp_hdr->usedbytes = 0; | 1856 | tmp_hdr->usedbytes = 0; |
1914 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { | 1857 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { |
1915 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0, | 1858 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0, |
1916 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), | 1859 | be16_to_cpu(drop_hdr->count), mp); |
1917 | mp); | ||
1918 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, | 1860 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, |
1919 | INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT), | 1861 | be16_to_cpu(tmp_leaf->hdr.count), |
1920 | (int)INT_GET(save_hdr->count, ARCH_CONVERT), | 1862 | be16_to_cpu(save_hdr->count), mp); |
1921 | mp); | ||
1922 | } else { | 1863 | } else { |
1923 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, 0, | 1864 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, 0, |
1924 | (int)INT_GET(save_hdr->count, ARCH_CONVERT), | 1865 | be16_to_cpu(save_hdr->count), mp); |
1925 | mp); | ||
1926 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, | 1866 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, |
1927 | INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT), | 1867 | be16_to_cpu(tmp_leaf->hdr.count), |
1928 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), | 1868 | be16_to_cpu(drop_hdr->count), mp); |
1929 | mp); | ||
1930 | } | 1869 | } |
1931 | memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize); | 1870 | memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize); |
1932 | kmem_free(tmpbuffer, state->blocksize); | 1871 | kmem_free(tmpbuffer, state->blocksize); |
@@ -1938,10 +1877,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1938 | /* | 1877 | /* |
1939 | * Copy out last hashval in each block for B-tree code. | 1878 | * Copy out last hashval in each block for B-tree code. |
1940 | */ | 1879 | */ |
1941 | save_blk->hashval = | 1880 | save_blk->hashval = be32_to_cpu( |
1942 | INT_GET(save_leaf->entries[INT_GET(save_leaf->hdr.count, | 1881 | save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1].hashval); |
1943 | ARCH_CONVERT)-1].hashval, | ||
1944 | ARCH_CONVERT); | ||
1945 | } | 1882 | } |
1946 | 1883 | ||
1947 | /*======================================================================== | 1884 | /*======================================================================== |
@@ -1972,48 +1909,45 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1972 | xfs_dahash_t hashval; | 1909 | xfs_dahash_t hashval; |
1973 | 1910 | ||
1974 | leaf = bp->data; | 1911 | leaf = bp->data; |
1975 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1912 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1976 | == XFS_ATTR_LEAF_MAGIC); | 1913 | ASSERT(be16_to_cpu(leaf->hdr.count) |
1977 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) | ||
1978 | < (XFS_LBSIZE(args->dp->i_mount)/8)); | 1914 | < (XFS_LBSIZE(args->dp->i_mount)/8)); |
1979 | 1915 | ||
1980 | /* | 1916 | /* |
1981 | * Binary search. (note: small blocks will skip this loop) | 1917 | * Binary search. (note: small blocks will skip this loop) |
1982 | */ | 1918 | */ |
1983 | hashval = args->hashval; | 1919 | hashval = args->hashval; |
1984 | probe = span = INT_GET(leaf->hdr.count, ARCH_CONVERT) / 2; | 1920 | probe = span = be16_to_cpu(leaf->hdr.count) / 2; |
1985 | for (entry = &leaf->entries[probe]; span > 4; | 1921 | for (entry = &leaf->entries[probe]; span > 4; |
1986 | entry = &leaf->entries[probe]) { | 1922 | entry = &leaf->entries[probe]) { |
1987 | span /= 2; | 1923 | span /= 2; |
1988 | if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval) | 1924 | if (be32_to_cpu(entry->hashval) < hashval) |
1989 | probe += span; | 1925 | probe += span; |
1990 | else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval) | 1926 | else if (be32_to_cpu(entry->hashval) > hashval) |
1991 | probe -= span; | 1927 | probe -= span; |
1992 | else | 1928 | else |
1993 | break; | 1929 | break; |
1994 | } | 1930 | } |
1995 | ASSERT((probe >= 0) && | 1931 | ASSERT((probe >= 0) && |
1996 | (!leaf->hdr.count | 1932 | (!leaf->hdr.count |
1997 | || (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)))); | 1933 | || (probe < be16_to_cpu(leaf->hdr.count)))); |
1998 | ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT) | 1934 | ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval)); |
1999 | == hashval)); | ||
2000 | 1935 | ||
2001 | /* | 1936 | /* |
2002 | * Since we may have duplicate hashval's, find the first matching | 1937 | * Since we may have duplicate hashval's, find the first matching |
2003 | * hashval in the leaf. | 1938 | * hashval in the leaf. |
2004 | */ | 1939 | */ |
2005 | while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT) | 1940 | while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) { |
2006 | >= hashval)) { | ||
2007 | entry--; | 1941 | entry--; |
2008 | probe--; | 1942 | probe--; |
2009 | } | 1943 | } |
2010 | while ((probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 1944 | while ((probe < be16_to_cpu(leaf->hdr.count)) && |
2011 | && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) { | 1945 | (be32_to_cpu(entry->hashval) < hashval)) { |
2012 | entry++; | 1946 | entry++; |
2013 | probe++; | 1947 | probe++; |
2014 | } | 1948 | } |
2015 | if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 1949 | if ((probe == be16_to_cpu(leaf->hdr.count)) || |
2016 | || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { | 1950 | (be32_to_cpu(entry->hashval) != hashval)) { |
2017 | args->index = probe; | 1951 | args->index = probe; |
2018 | return(XFS_ERROR(ENOATTR)); | 1952 | return(XFS_ERROR(ENOATTR)); |
2019 | } | 1953 | } |
@@ -2021,8 +1955,8 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2021 | /* | 1955 | /* |
2022 | * Duplicate keys may be present, so search all of them for a match. | 1956 | * Duplicate keys may be present, so search all of them for a match. |
2023 | */ | 1957 | */ |
2024 | for ( ; (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 1958 | for ( ; (probe < be16_to_cpu(leaf->hdr.count)) && |
2025 | && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval); | 1959 | (be32_to_cpu(entry->hashval) == hashval); |
2026 | entry++, probe++) { | 1960 | entry++, probe++) { |
2027 | /* | 1961 | /* |
2028 | * GROT: Add code to remove incomplete entries. | 1962 | * GROT: Add code to remove incomplete entries. |
@@ -2064,11 +1998,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2064 | ((entry->flags & XFS_ATTR_ROOT) != 0)) | 1998 | ((entry->flags & XFS_ATTR_ROOT) != 0)) |
2065 | continue; | 1999 | continue; |
2066 | args->index = probe; | 2000 | args->index = probe; |
2067 | args->rmtblkno | 2001 | args->rmtblkno = be32_to_cpu(name_rmt->valueblk); |
2068 | = INT_GET(name_rmt->valueblk, ARCH_CONVERT); | ||
2069 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, | 2002 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, |
2070 | INT_GET(name_rmt->valuelen, | 2003 | be32_to_cpu(name_rmt->valuelen)); |
2071 | ARCH_CONVERT)); | ||
2072 | return(XFS_ERROR(EEXIST)); | 2004 | return(XFS_ERROR(EEXIST)); |
2073 | } | 2005 | } |
2074 | } | 2006 | } |
@@ -2090,18 +2022,17 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2090 | xfs_attr_leaf_name_remote_t *name_rmt; | 2022 | xfs_attr_leaf_name_remote_t *name_rmt; |
2091 | 2023 | ||
2092 | leaf = bp->data; | 2024 | leaf = bp->data; |
2093 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2025 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2094 | == XFS_ATTR_LEAF_MAGIC); | 2026 | ASSERT(be16_to_cpu(leaf->hdr.count) |
2095 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) | ||
2096 | < (XFS_LBSIZE(args->dp->i_mount)/8)); | 2027 | < (XFS_LBSIZE(args->dp->i_mount)/8)); |
2097 | ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 2028 | ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); |
2098 | 2029 | ||
2099 | entry = &leaf->entries[args->index]; | 2030 | entry = &leaf->entries[args->index]; |
2100 | if (entry->flags & XFS_ATTR_LOCAL) { | 2031 | if (entry->flags & XFS_ATTR_LOCAL) { |
2101 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); | 2032 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); |
2102 | ASSERT(name_loc->namelen == args->namelen); | 2033 | ASSERT(name_loc->namelen == args->namelen); |
2103 | ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); | 2034 | ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); |
2104 | valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT); | 2035 | valuelen = be16_to_cpu(name_loc->valuelen); |
2105 | if (args->flags & ATTR_KERNOVAL) { | 2036 | if (args->flags & ATTR_KERNOVAL) { |
2106 | args->valuelen = valuelen; | 2037 | args->valuelen = valuelen; |
2107 | return(0); | 2038 | return(0); |
@@ -2116,8 +2047,8 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2116 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); | 2047 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); |
2117 | ASSERT(name_rmt->namelen == args->namelen); | 2048 | ASSERT(name_rmt->namelen == args->namelen); |
2118 | ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); | 2049 | ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); |
2119 | valuelen = INT_GET(name_rmt->valuelen, ARCH_CONVERT); | 2050 | valuelen = be32_to_cpu(name_rmt->valuelen); |
2120 | args->rmtblkno = INT_GET(name_rmt->valueblk, ARCH_CONVERT); | 2051 | args->rmtblkno = be32_to_cpu(name_rmt->valueblk); |
2121 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, valuelen); | 2052 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, valuelen); |
2122 | if (args->flags & ATTR_KERNOVAL) { | 2053 | if (args->flags & ATTR_KERNOVAL) { |
2123 | args->valuelen = valuelen; | 2054 | args->valuelen = valuelen; |
@@ -2159,32 +2090,29 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2159 | /* | 2090 | /* |
2160 | * Set up environment. | 2091 | * Set up environment. |
2161 | */ | 2092 | */ |
2162 | ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) | 2093 | ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2163 | == XFS_ATTR_LEAF_MAGIC); | 2094 | ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2164 | ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) | ||
2165 | == XFS_ATTR_LEAF_MAGIC); | ||
2166 | hdr_s = &leaf_s->hdr; | 2095 | hdr_s = &leaf_s->hdr; |
2167 | hdr_d = &leaf_d->hdr; | 2096 | hdr_d = &leaf_d->hdr; |
2168 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) | 2097 | ASSERT((be16_to_cpu(hdr_s->count) > 0) && |
2169 | && (INT_GET(hdr_s->count, ARCH_CONVERT) | 2098 | (be16_to_cpu(hdr_s->count) < (XFS_LBSIZE(mp)/8))); |
2170 | < (XFS_LBSIZE(mp)/8))); | 2099 | ASSERT(be16_to_cpu(hdr_s->firstused) >= |
2171 | ASSERT(INT_GET(hdr_s->firstused, ARCH_CONVERT) >= | 2100 | ((be16_to_cpu(hdr_s->count) |
2172 | ((INT_GET(hdr_s->count, ARCH_CONVERT) | ||
2173 | * sizeof(*entry_s))+sizeof(*hdr_s))); | 2101 | * sizeof(*entry_s))+sizeof(*hdr_s))); |
2174 | ASSERT(INT_GET(hdr_d->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)); | 2102 | ASSERT(be16_to_cpu(hdr_d->count) < (XFS_LBSIZE(mp)/8)); |
2175 | ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >= | 2103 | ASSERT(be16_to_cpu(hdr_d->firstused) >= |
2176 | ((INT_GET(hdr_d->count, ARCH_CONVERT) | 2104 | ((be16_to_cpu(hdr_d->count) |
2177 | * sizeof(*entry_d))+sizeof(*hdr_d))); | 2105 | * sizeof(*entry_d))+sizeof(*hdr_d))); |
2178 | 2106 | ||
2179 | ASSERT(start_s < INT_GET(hdr_s->count, ARCH_CONVERT)); | 2107 | ASSERT(start_s < be16_to_cpu(hdr_s->count)); |
2180 | ASSERT(start_d <= INT_GET(hdr_d->count, ARCH_CONVERT)); | 2108 | ASSERT(start_d <= be16_to_cpu(hdr_d->count)); |
2181 | ASSERT(count <= INT_GET(hdr_s->count, ARCH_CONVERT)); | 2109 | ASSERT(count <= be16_to_cpu(hdr_s->count)); |
2182 | 2110 | ||
2183 | /* | 2111 | /* |
2184 | * Move the entries in the destination leaf up to make a hole? | 2112 | * Move the entries in the destination leaf up to make a hole? |
2185 | */ | 2113 | */ |
2186 | if (start_d < INT_GET(hdr_d->count, ARCH_CONVERT)) { | 2114 | if (start_d < be16_to_cpu(hdr_d->count)) { |
2187 | tmp = INT_GET(hdr_d->count, ARCH_CONVERT) - start_d; | 2115 | tmp = be16_to_cpu(hdr_d->count) - start_d; |
2188 | tmp *= sizeof(xfs_attr_leaf_entry_t); | 2116 | tmp *= sizeof(xfs_attr_leaf_entry_t); |
2189 | entry_s = &leaf_d->entries[start_d]; | 2117 | entry_s = &leaf_d->entries[start_d]; |
2190 | entry_d = &leaf_d->entries[start_d + count]; | 2118 | entry_d = &leaf_d->entries[start_d + count]; |
@@ -2199,8 +2127,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2199 | entry_d = &leaf_d->entries[start_d]; | 2127 | entry_d = &leaf_d->entries[start_d]; |
2200 | desti = start_d; | 2128 | desti = start_d; |
2201 | for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) { | 2129 | for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) { |
2202 | ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) | 2130 | ASSERT(be16_to_cpu(entry_s->nameidx) |
2203 | >= INT_GET(hdr_s->firstused, ARCH_CONVERT)); | 2131 | >= be16_to_cpu(hdr_s->firstused)); |
2204 | tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i); | 2132 | tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i); |
2205 | #ifdef GROT | 2133 | #ifdef GROT |
2206 | /* | 2134 | /* |
@@ -2210,35 +2138,35 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2210 | */ | 2138 | */ |
2211 | if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */ | 2139 | if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */ |
2212 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); | 2140 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); |
2213 | INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp); | 2141 | be16_add(&hdr_s->usedbytes, -tmp); |
2214 | INT_MOD(hdr_s->count, ARCH_CONVERT, -1); | 2142 | be16_add(&hdr_s->count, -1); |
2215 | entry_d--; /* to compensate for ++ in loop hdr */ | 2143 | entry_d--; /* to compensate for ++ in loop hdr */ |
2216 | desti--; | 2144 | desti--; |
2217 | if ((start_s + i) < offset) | 2145 | if ((start_s + i) < offset) |
2218 | result++; /* insertion index adjustment */ | 2146 | result++; /* insertion index adjustment */ |
2219 | } else { | 2147 | } else { |
2220 | #endif /* GROT */ | 2148 | #endif /* GROT */ |
2221 | INT_MOD(hdr_d->firstused, ARCH_CONVERT, -tmp); | 2149 | be16_add(&hdr_d->firstused, -tmp); |
2222 | /* both on-disk, don't endian flip twice */ | 2150 | /* both on-disk, don't endian flip twice */ |
2223 | entry_d->hashval = entry_s->hashval; | 2151 | entry_d->hashval = entry_s->hashval; |
2224 | /* both on-disk, don't endian flip twice */ | 2152 | /* both on-disk, don't endian flip twice */ |
2225 | entry_d->nameidx = hdr_d->firstused; | 2153 | entry_d->nameidx = hdr_d->firstused; |
2226 | entry_d->flags = entry_s->flags; | 2154 | entry_d->flags = entry_s->flags; |
2227 | ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp | 2155 | ASSERT(be16_to_cpu(entry_d->nameidx) + tmp |
2228 | <= XFS_LBSIZE(mp)); | 2156 | <= XFS_LBSIZE(mp)); |
2229 | memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti), | 2157 | memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti), |
2230 | XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp); | 2158 | XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp); |
2231 | ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp | 2159 | ASSERT(be16_to_cpu(entry_s->nameidx) + tmp |
2232 | <= XFS_LBSIZE(mp)); | 2160 | <= XFS_LBSIZE(mp)); |
2233 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); | 2161 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); |
2234 | INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp); | 2162 | be16_add(&hdr_s->usedbytes, -tmp); |
2235 | INT_MOD(hdr_d->usedbytes, ARCH_CONVERT, tmp); | 2163 | be16_add(&hdr_d->usedbytes, tmp); |
2236 | INT_MOD(hdr_s->count, ARCH_CONVERT, -1); | 2164 | be16_add(&hdr_s->count, -1); |
2237 | INT_MOD(hdr_d->count, ARCH_CONVERT, 1); | 2165 | be16_add(&hdr_d->count, 1); |
2238 | tmp = INT_GET(hdr_d->count, ARCH_CONVERT) | 2166 | tmp = be16_to_cpu(hdr_d->count) |
2239 | * sizeof(xfs_attr_leaf_entry_t) | 2167 | * sizeof(xfs_attr_leaf_entry_t) |
2240 | + sizeof(xfs_attr_leaf_hdr_t); | 2168 | + sizeof(xfs_attr_leaf_hdr_t); |
2241 | ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >= tmp); | 2169 | ASSERT(be16_to_cpu(hdr_d->firstused) >= tmp); |
2242 | #ifdef GROT | 2170 | #ifdef GROT |
2243 | } | 2171 | } |
2244 | #endif /* GROT */ | 2172 | #endif /* GROT */ |
@@ -2247,7 +2175,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2247 | /* | 2175 | /* |
2248 | * Zero out the entries we just copied. | 2176 | * Zero out the entries we just copied. |
2249 | */ | 2177 | */ |
2250 | if (start_s == INT_GET(hdr_s->count, ARCH_CONVERT)) { | 2178 | if (start_s == be16_to_cpu(hdr_s->count)) { |
2251 | tmp = count * sizeof(xfs_attr_leaf_entry_t); | 2179 | tmp = count * sizeof(xfs_attr_leaf_entry_t); |
2252 | entry_s = &leaf_s->entries[start_s]; | 2180 | entry_s = &leaf_s->entries[start_s]; |
2253 | ASSERT(((char *)entry_s + tmp) <= | 2181 | ASSERT(((char *)entry_s + tmp) <= |
@@ -2258,15 +2186,14 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2258 | * Move the remaining entries down to fill the hole, | 2186 | * Move the remaining entries down to fill the hole, |
2259 | * then zero the entries at the top. | 2187 | * then zero the entries at the top. |
2260 | */ | 2188 | */ |
2261 | tmp = INT_GET(hdr_s->count, ARCH_CONVERT) - count; | 2189 | tmp = be16_to_cpu(hdr_s->count) - count; |
2262 | tmp *= sizeof(xfs_attr_leaf_entry_t); | 2190 | tmp *= sizeof(xfs_attr_leaf_entry_t); |
2263 | entry_s = &leaf_s->entries[start_s + count]; | 2191 | entry_s = &leaf_s->entries[start_s + count]; |
2264 | entry_d = &leaf_s->entries[start_s]; | 2192 | entry_d = &leaf_s->entries[start_s]; |
2265 | memmove((char *)entry_d, (char *)entry_s, tmp); | 2193 | memmove((char *)entry_d, (char *)entry_s, tmp); |
2266 | 2194 | ||
2267 | tmp = count * sizeof(xfs_attr_leaf_entry_t); | 2195 | tmp = count * sizeof(xfs_attr_leaf_entry_t); |
2268 | entry_s = &leaf_s->entries[INT_GET(hdr_s->count, | 2196 | entry_s = &leaf_s->entries[be16_to_cpu(hdr_s->count)]; |
2269 | ARCH_CONVERT)]; | ||
2270 | ASSERT(((char *)entry_s + tmp) <= | 2197 | ASSERT(((char *)entry_s + tmp) <= |
2271 | ((char *)leaf_s + XFS_LBSIZE(mp))); | 2198 | ((char *)leaf_s + XFS_LBSIZE(mp))); |
2272 | memset((char *)entry_s, 0, tmp); | 2199 | memset((char *)entry_s, 0, tmp); |
@@ -2275,14 +2202,11 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2275 | /* | 2202 | /* |
2276 | * Fill in the freemap information | 2203 | * Fill in the freemap information |
2277 | */ | 2204 | */ |
2278 | INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT, | 2205 | hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); |
2279 | sizeof(xfs_attr_leaf_hdr_t)); | 2206 | be16_add(&hdr_d->freemap[0].base, be16_to_cpu(hdr_d->count) * |
2280 | INT_MOD(hdr_d->freemap[0].base, ARCH_CONVERT, | 2207 | sizeof(xfs_attr_leaf_entry_t)); |
2281 | INT_GET(hdr_d->count, ARCH_CONVERT) | 2208 | hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) |
2282 | * sizeof(xfs_attr_leaf_entry_t)); | 2209 | - be16_to_cpu(hdr_d->freemap[0].base)); |
2283 | INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT, | ||
2284 | INT_GET(hdr_d->firstused, ARCH_CONVERT) | ||
2285 | - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT)); | ||
2286 | hdr_d->freemap[1].base = 0; | 2210 | hdr_d->freemap[1].base = 0; |
2287 | hdr_d->freemap[2].base = 0; | 2211 | hdr_d->freemap[2].base = 0; |
2288 | hdr_d->freemap[1].size = 0; | 2212 | hdr_d->freemap[1].size = 0; |
@@ -2301,18 +2225,16 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) | |||
2301 | 2225 | ||
2302 | leaf1 = leaf1_bp->data; | 2226 | leaf1 = leaf1_bp->data; |
2303 | leaf2 = leaf2_bp->data; | 2227 | leaf2 = leaf2_bp->data; |
2304 | ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 2228 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) && |
2305 | == XFS_ATTR_LEAF_MAGIC) && | 2229 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC)); |
2306 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2230 | if ((be16_to_cpu(leaf1->hdr.count) > 0) && |
2307 | == XFS_ATTR_LEAF_MAGIC)); | 2231 | (be16_to_cpu(leaf2->hdr.count) > 0) && |
2308 | if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) | 2232 | ((be32_to_cpu(leaf2->entries[0].hashval) < |
2309 | && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) | 2233 | be32_to_cpu(leaf1->entries[0].hashval)) || |
2310 | && ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < | 2234 | (be32_to_cpu(leaf2->entries[ |
2311 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) | 2235 | be16_to_cpu(leaf2->hdr.count)-1].hashval) < |
2312 | || (INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count, | 2236 | be32_to_cpu(leaf1->entries[ |
2313 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT) < | 2237 | be16_to_cpu(leaf1->hdr.count)-1].hashval)))) { |
2314 | INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count, | ||
2315 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT))) ) { | ||
2316 | return(1); | 2238 | return(1); |
2317 | } | 2239 | } |
2318 | return(0); | 2240 | return(0); |
@@ -2327,14 +2249,12 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
2327 | xfs_attr_leafblock_t *leaf; | 2249 | xfs_attr_leafblock_t *leaf; |
2328 | 2250 | ||
2329 | leaf = bp->data; | 2251 | leaf = bp->data; |
2330 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2252 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2331 | == XFS_ATTR_LEAF_MAGIC); | ||
2332 | if (count) | 2253 | if (count) |
2333 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 2254 | *count = be16_to_cpu(leaf->hdr.count); |
2334 | if (!leaf->hdr.count) | 2255 | if (!leaf->hdr.count) |
2335 | return(0); | 2256 | return(0); |
2336 | return(INT_GET(leaf->entries[INT_GET(leaf->hdr.count, | 2257 | return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval); |
2337 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); | ||
2338 | } | 2258 | } |
2339 | 2259 | ||
2340 | /* | 2260 | /* |
@@ -2348,13 +2268,11 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) | |||
2348 | xfs_attr_leaf_name_remote_t *name_rmt; | 2268 | xfs_attr_leaf_name_remote_t *name_rmt; |
2349 | int size; | 2269 | int size; |
2350 | 2270 | ||
2351 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2271 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2352 | == XFS_ATTR_LEAF_MAGIC); | ||
2353 | if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { | 2272 | if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { |
2354 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); | 2273 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); |
2355 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, | 2274 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, |
2356 | INT_GET(name_loc->valuelen, | 2275 | be16_to_cpu(name_loc->valuelen)); |
2357 | ARCH_CONVERT)); | ||
2358 | } else { | 2276 | } else { |
2359 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index); | 2277 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index); |
2360 | size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen); | 2278 | size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen); |
@@ -2412,22 +2330,20 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2412 | */ | 2330 | */ |
2413 | if (context->resynch) { | 2331 | if (context->resynch) { |
2414 | entry = &leaf->entries[0]; | 2332 | entry = &leaf->entries[0]; |
2415 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); | 2333 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
2416 | entry++, i++) { | 2334 | if (be32_to_cpu(entry->hashval) == cursor->hashval) { |
2417 | if (INT_GET(entry->hashval, ARCH_CONVERT) | ||
2418 | == cursor->hashval) { | ||
2419 | if (cursor->offset == context->dupcnt) { | 2335 | if (cursor->offset == context->dupcnt) { |
2420 | context->dupcnt = 0; | 2336 | context->dupcnt = 0; |
2421 | break; | 2337 | break; |
2422 | } | 2338 | } |
2423 | context->dupcnt++; | 2339 | context->dupcnt++; |
2424 | } else if (INT_GET(entry->hashval, ARCH_CONVERT) | 2340 | } else if (be32_to_cpu(entry->hashval) > |
2425 | > cursor->hashval) { | 2341 | cursor->hashval) { |
2426 | context->dupcnt = 0; | 2342 | context->dupcnt = 0; |
2427 | break; | 2343 | break; |
2428 | } | 2344 | } |
2429 | } | 2345 | } |
2430 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { | 2346 | if (i == be16_to_cpu(leaf->hdr.count)) { |
2431 | xfs_attr_trace_l_c("not found", context); | 2347 | xfs_attr_trace_l_c("not found", context); |
2432 | return(0); | 2348 | return(0); |
2433 | } | 2349 | } |
@@ -2441,12 +2357,12 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2441 | * We have found our place, start copying out the new attributes. | 2357 | * We have found our place, start copying out the new attributes. |
2442 | */ | 2358 | */ |
2443 | retval = 0; | 2359 | retval = 0; |
2444 | for ( ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 2360 | for ( ; (i < be16_to_cpu(leaf->hdr.count)) |
2445 | && (retval == 0); entry++, i++) { | 2361 | && (retval == 0); entry++, i++) { |
2446 | attrnames_t *namesp; | 2362 | attrnames_t *namesp; |
2447 | 2363 | ||
2448 | if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) { | 2364 | if (be32_to_cpu(entry->hashval) != cursor->hashval) { |
2449 | cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT); | 2365 | cursor->hashval = be32_to_cpu(entry->hashval); |
2450 | cursor->offset = 0; | 2366 | cursor->offset = 0; |
2451 | } | 2367 | } |
2452 | 2368 | ||
@@ -2475,8 +2391,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2475 | retval = xfs_attr_put_listent(context, namesp, | 2391 | retval = xfs_attr_put_listent(context, namesp, |
2476 | (char *)name_loc->nameval, | 2392 | (char *)name_loc->nameval, |
2477 | (int)name_loc->namelen, | 2393 | (int)name_loc->namelen, |
2478 | (int)INT_GET(name_loc->valuelen, | 2394 | be16_to_cpu(name_loc->valuelen)); |
2479 | ARCH_CONVERT)); | ||
2480 | } | 2395 | } |
2481 | } else { | 2396 | } else { |
2482 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2397 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
@@ -2488,8 +2403,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2488 | retval = xfs_attr_put_listent(context, namesp, | 2403 | retval = xfs_attr_put_listent(context, namesp, |
2489 | (char *)name_rmt->name, | 2404 | (char *)name_rmt->name, |
2490 | (int)name_rmt->namelen, | 2405 | (int)name_rmt->namelen, |
2491 | (int)INT_GET(name_rmt->valuelen, | 2406 | be32_to_cpu(name_rmt->valuelen)); |
2492 | ARCH_CONVERT)); | ||
2493 | } | 2407 | } |
2494 | } | 2408 | } |
2495 | if (retval == 0) { | 2409 | if (retval == 0) { |
@@ -2596,9 +2510,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2596 | ASSERT(bp != NULL); | 2510 | ASSERT(bp != NULL); |
2597 | 2511 | ||
2598 | leaf = bp->data; | 2512 | leaf = bp->data; |
2599 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2513 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2600 | == XFS_ATTR_LEAF_MAGIC); | 2514 | ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); |
2601 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); | ||
2602 | ASSERT(args->index >= 0); | 2515 | ASSERT(args->index >= 0); |
2603 | entry = &leaf->entries[ args->index ]; | 2516 | entry = &leaf->entries[ args->index ]; |
2604 | ASSERT(entry->flags & XFS_ATTR_INCOMPLETE); | 2517 | ASSERT(entry->flags & XFS_ATTR_INCOMPLETE); |
@@ -2613,7 +2526,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2613 | namelen = name_rmt->namelen; | 2526 | namelen = name_rmt->namelen; |
2614 | name = (char *)name_rmt->name; | 2527 | name = (char *)name_rmt->name; |
2615 | } | 2528 | } |
2616 | ASSERT(INT_GET(entry->hashval, ARCH_CONVERT) == args->hashval); | 2529 | ASSERT(be32_to_cpu(entry->hashval) == args->hashval); |
2617 | ASSERT(namelen == args->namelen); | 2530 | ASSERT(namelen == args->namelen); |
2618 | ASSERT(memcmp(name, args->name, namelen) == 0); | 2531 | ASSERT(memcmp(name, args->name, namelen) == 0); |
2619 | #endif /* DEBUG */ | 2532 | #endif /* DEBUG */ |
@@ -2625,8 +2538,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2625 | if (args->rmtblkno) { | 2538 | if (args->rmtblkno) { |
2626 | ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); | 2539 | ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); |
2627 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); | 2540 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); |
2628 | INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno); | 2541 | name_rmt->valueblk = cpu_to_be32(args->rmtblkno); |
2629 | INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen); | 2542 | name_rmt->valuelen = cpu_to_be32(args->valuelen); |
2630 | xfs_da_log_buf(args->trans, bp, | 2543 | xfs_da_log_buf(args->trans, bp, |
2631 | XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); | 2544 | XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); |
2632 | } | 2545 | } |
@@ -2663,9 +2576,8 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args) | |||
2663 | ASSERT(bp != NULL); | 2576 | ASSERT(bp != NULL); |
2664 | 2577 | ||
2665 | leaf = bp->data; | 2578 | leaf = bp->data; |
2666 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2579 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2667 | == XFS_ATTR_LEAF_MAGIC); | 2580 | ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); |
2668 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); | ||
2669 | ASSERT(args->index >= 0); | 2581 | ASSERT(args->index >= 0); |
2670 | entry = &leaf->entries[ args->index ]; | 2582 | entry = &leaf->entries[ args->index ]; |
2671 | 2583 | ||
@@ -2736,16 +2648,14 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2736 | } | 2648 | } |
2737 | 2649 | ||
2738 | leaf1 = bp1->data; | 2650 | leaf1 = bp1->data; |
2739 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 2651 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2740 | == XFS_ATTR_LEAF_MAGIC); | 2652 | ASSERT(args->index < be16_to_cpu(leaf1->hdr.count)); |
2741 | ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT)); | ||
2742 | ASSERT(args->index >= 0); | 2653 | ASSERT(args->index >= 0); |
2743 | entry1 = &leaf1->entries[ args->index ]; | 2654 | entry1 = &leaf1->entries[ args->index ]; |
2744 | 2655 | ||
2745 | leaf2 = bp2->data; | 2656 | leaf2 = bp2->data; |
2746 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2657 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2747 | == XFS_ATTR_LEAF_MAGIC); | 2658 | ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count)); |
2748 | ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT)); | ||
2749 | ASSERT(args->index2 >= 0); | 2659 | ASSERT(args->index2 >= 0); |
2750 | entry2 = &leaf2->entries[ args->index2 ]; | 2660 | entry2 = &leaf2->entries[ args->index2 ]; |
2751 | 2661 | ||
@@ -2768,7 +2678,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2768 | namelen2 = name_rmt->namelen; | 2678 | namelen2 = name_rmt->namelen; |
2769 | name2 = (char *)name_rmt->name; | 2679 | name2 = (char *)name_rmt->name; |
2770 | } | 2680 | } |
2771 | ASSERT(INT_GET(entry1->hashval, ARCH_CONVERT) == INT_GET(entry2->hashval, ARCH_CONVERT)); | 2681 | ASSERT(be32_to_cpu(entry1->hashval) == be32_to_cpu(entry2->hashval)); |
2772 | ASSERT(namelen1 == namelen2); | 2682 | ASSERT(namelen1 == namelen2); |
2773 | ASSERT(memcmp(name1, name2, namelen1) == 0); | 2683 | ASSERT(memcmp(name1, name2, namelen1) == 0); |
2774 | #endif /* DEBUG */ | 2684 | #endif /* DEBUG */ |
@@ -2782,8 +2692,8 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2782 | if (args->rmtblkno) { | 2692 | if (args->rmtblkno) { |
2783 | ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); | 2693 | ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); |
2784 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index); | 2694 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index); |
2785 | INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno); | 2695 | name_rmt->valueblk = cpu_to_be32(args->rmtblkno); |
2786 | INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen); | 2696 | name_rmt->valuelen = cpu_to_be32(args->valuelen); |
2787 | xfs_da_log_buf(args->trans, bp1, | 2697 | xfs_da_log_buf(args->trans, bp1, |
2788 | XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt))); | 2698 | XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt))); |
2789 | } | 2699 | } |
@@ -2842,9 +2752,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp) | |||
2842 | * This is a depth-first traversal! | 2752 | * This is a depth-first traversal! |
2843 | */ | 2753 | */ |
2844 | info = bp->data; | 2754 | info = bp->data; |
2845 | if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 2755 | if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { |
2846 | error = xfs_attr_node_inactive(trans, dp, bp, 1); | 2756 | error = xfs_attr_node_inactive(trans, dp, bp, 1); |
2847 | } else if (INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 2757 | } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { |
2848 | error = xfs_attr_leaf_inactive(trans, dp, bp); | 2758 | error = xfs_attr_leaf_inactive(trans, dp, bp); |
2849 | } else { | 2759 | } else { |
2850 | error = XFS_ERROR(EIO); | 2760 | error = XFS_ERROR(EIO); |
@@ -2892,15 +2802,14 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2892 | } | 2802 | } |
2893 | 2803 | ||
2894 | node = bp->data; | 2804 | node = bp->data; |
2895 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 2805 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
2896 | == XFS_DA_NODE_MAGIC); | ||
2897 | parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ | 2806 | parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ |
2898 | count = INT_GET(node->hdr.count, ARCH_CONVERT); | 2807 | count = be16_to_cpu(node->hdr.count); |
2899 | if (!count) { | 2808 | if (!count) { |
2900 | xfs_da_brelse(*trans, bp); | 2809 | xfs_da_brelse(*trans, bp); |
2901 | return(0); | 2810 | return(0); |
2902 | } | 2811 | } |
2903 | child_fsb = INT_GET(node->btree[0].before, ARCH_CONVERT); | 2812 | child_fsb = be32_to_cpu(node->btree[0].before); |
2904 | xfs_da_brelse(*trans, bp); /* no locks for later trans */ | 2813 | xfs_da_brelse(*trans, bp); /* no locks for later trans */ |
2905 | 2814 | ||
2906 | /* | 2815 | /* |
@@ -2927,12 +2836,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2927 | * Invalidate the subtree, however we have to. | 2836 | * Invalidate the subtree, however we have to. |
2928 | */ | 2837 | */ |
2929 | info = child_bp->data; | 2838 | info = child_bp->data; |
2930 | if (INT_GET(info->magic, ARCH_CONVERT) | 2839 | if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { |
2931 | == XFS_DA_NODE_MAGIC) { | ||
2932 | error = xfs_attr_node_inactive(trans, dp, | 2840 | error = xfs_attr_node_inactive(trans, dp, |
2933 | child_bp, level+1); | 2841 | child_bp, level+1); |
2934 | } else if (INT_GET(info->magic, ARCH_CONVERT) | 2842 | } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { |
2935 | == XFS_ATTR_LEAF_MAGIC) { | ||
2936 | error = xfs_attr_leaf_inactive(trans, dp, | 2843 | error = xfs_attr_leaf_inactive(trans, dp, |
2937 | child_bp); | 2844 | child_bp); |
2938 | } else { | 2845 | } else { |
@@ -2962,7 +2869,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2962 | &bp, XFS_ATTR_FORK); | 2869 | &bp, XFS_ATTR_FORK); |
2963 | if (error) | 2870 | if (error) |
2964 | return(error); | 2871 | return(error); |
2965 | child_fsb = INT_GET(node->btree[i+1].before, ARCH_CONVERT); | 2872 | child_fsb = be32_to_cpu(node->btree[i+1].before); |
2966 | xfs_da_brelse(*trans, bp); | 2873 | xfs_da_brelse(*trans, bp); |
2967 | } | 2874 | } |
2968 | /* | 2875 | /* |
@@ -2991,17 +2898,16 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
2991 | int error, count, size, tmp, i; | 2898 | int error, count, size, tmp, i; |
2992 | 2899 | ||
2993 | leaf = bp->data; | 2900 | leaf = bp->data; |
2994 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2901 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2995 | == XFS_ATTR_LEAF_MAGIC); | ||
2996 | 2902 | ||
2997 | /* | 2903 | /* |
2998 | * Count the number of "remote" value extents. | 2904 | * Count the number of "remote" value extents. |
2999 | */ | 2905 | */ |
3000 | count = 0; | 2906 | count = 0; |
3001 | entry = &leaf->entries[0]; | 2907 | entry = &leaf->entries[0]; |
3002 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 2908 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
3003 | if ( INT_GET(entry->nameidx, ARCH_CONVERT) | 2909 | if (be16_to_cpu(entry->nameidx) && |
3004 | && ((entry->flags & XFS_ATTR_LOCAL) == 0)) { | 2910 | ((entry->flags & XFS_ATTR_LOCAL) == 0)) { |
3005 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2911 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
3006 | if (name_rmt->valueblk) | 2912 | if (name_rmt->valueblk) |
3007 | count++; | 2913 | count++; |
@@ -3027,17 +2933,14 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
3027 | */ | 2933 | */ |
3028 | lp = list; | 2934 | lp = list; |
3029 | entry = &leaf->entries[0]; | 2935 | entry = &leaf->entries[0]; |
3030 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 2936 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
3031 | if ( INT_GET(entry->nameidx, ARCH_CONVERT) | 2937 | if (be16_to_cpu(entry->nameidx) && |
3032 | && ((entry->flags & XFS_ATTR_LOCAL) == 0)) { | 2938 | ((entry->flags & XFS_ATTR_LOCAL) == 0)) { |
3033 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2939 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
3034 | if (name_rmt->valueblk) { | 2940 | if (name_rmt->valueblk) { |
3035 | /* both on-disk, don't endian flip twice */ | 2941 | lp->valueblk = be32_to_cpu(name_rmt->valueblk); |
3036 | lp->valueblk = name_rmt->valueblk; | 2942 | lp->valuelen = XFS_B_TO_FSB(dp->i_mount, |
3037 | INT_SET(lp->valuelen, ARCH_CONVERT, | 2943 | be32_to_cpu(name_rmt->valuelen)); |
3038 | XFS_B_TO_FSB(dp->i_mount, | ||
3039 | INT_GET(name_rmt->valuelen, | ||
3040 | ARCH_CONVERT))); | ||
3041 | lp++; | 2944 | lp++; |
3042 | } | 2945 | } |
3043 | } | 2946 | } |
@@ -3050,10 +2953,8 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
3050 | error = 0; | 2953 | error = 0; |
3051 | for (lp = list, i = 0; i < count; i++, lp++) { | 2954 | for (lp = list, i = 0; i < count; i++, lp++) { |
3052 | tmp = xfs_attr_leaf_freextent(trans, dp, | 2955 | tmp = xfs_attr_leaf_freextent(trans, dp, |
3053 | INT_GET(lp->valueblk, | 2956 | lp->valueblk, lp->valuelen); |
3054 | ARCH_CONVERT), | 2957 | |
3055 | INT_GET(lp->valuelen, | ||
3056 | ARCH_CONVERT)); | ||
3057 | if (error == 0) | 2958 | if (error == 0) |
3058 | error = tmp; /* save only the 1st errno */ | 2959 | error = tmp; /* save only the 1st errno */ |
3059 | } | 2960 | } |
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h index 541e34109bb9..51c3ee156b2f 100644 --- a/fs/xfs/xfs_attr_leaf.h +++ b/fs/xfs/xfs_attr_leaf.h | |||
@@ -73,39 +73,39 @@ struct xfs_trans; | |||
73 | #define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */ | 73 | #define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */ |
74 | 74 | ||
75 | typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */ | 75 | typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */ |
76 | __uint16_t base; /* base of free region */ | 76 | __be16 base; /* base of free region */ |
77 | __uint16_t size; /* length of free region */ | 77 | __be16 size; /* length of free region */ |
78 | } xfs_attr_leaf_map_t; | 78 | } xfs_attr_leaf_map_t; |
79 | 79 | ||
80 | typedef struct xfs_attr_leaf_hdr { /* constant-structure header block */ | 80 | typedef struct xfs_attr_leaf_hdr { /* constant-structure header block */ |
81 | xfs_da_blkinfo_t info; /* block type, links, etc. */ | 81 | xfs_da_blkinfo_t info; /* block type, links, etc. */ |
82 | __uint16_t count; /* count of active leaf_entry's */ | 82 | __be16 count; /* count of active leaf_entry's */ |
83 | __uint16_t usedbytes; /* num bytes of names/values stored */ | 83 | __be16 usedbytes; /* num bytes of names/values stored */ |
84 | __uint16_t firstused; /* first used byte in name area */ | 84 | __be16 firstused; /* first used byte in name area */ |
85 | __uint8_t holes; /* != 0 if blk needs compaction */ | 85 | __u8 holes; /* != 0 if blk needs compaction */ |
86 | __uint8_t pad1; | 86 | __u8 pad1; |
87 | xfs_attr_leaf_map_t freemap[XFS_ATTR_LEAF_MAPSIZE]; | 87 | xfs_attr_leaf_map_t freemap[XFS_ATTR_LEAF_MAPSIZE]; |
88 | /* N largest free regions */ | 88 | /* N largest free regions */ |
89 | } xfs_attr_leaf_hdr_t; | 89 | } xfs_attr_leaf_hdr_t; |
90 | 90 | ||
91 | typedef struct xfs_attr_leaf_entry { /* sorted on key, not name */ | 91 | typedef struct xfs_attr_leaf_entry { /* sorted on key, not name */ |
92 | xfs_dahash_t hashval; /* hash value of name */ | 92 | __be32 hashval; /* hash value of name */ |
93 | __uint16_t nameidx; /* index into buffer of name/value */ | 93 | __be16 nameidx; /* index into buffer of name/value */ |
94 | __uint8_t flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */ | 94 | __u8 flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */ |
95 | __uint8_t pad2; /* unused pad byte */ | 95 | __u8 pad2; /* unused pad byte */ |
96 | } xfs_attr_leaf_entry_t; | 96 | } xfs_attr_leaf_entry_t; |
97 | 97 | ||
98 | typedef struct xfs_attr_leaf_name_local { | 98 | typedef struct xfs_attr_leaf_name_local { |
99 | __uint16_t valuelen; /* number of bytes in value */ | 99 | __be16 valuelen; /* number of bytes in value */ |
100 | __uint8_t namelen; /* length of name bytes */ | 100 | __u8 namelen; /* length of name bytes */ |
101 | __uint8_t nameval[1]; /* name/value bytes */ | 101 | __u8 nameval[1]; /* name/value bytes */ |
102 | } xfs_attr_leaf_name_local_t; | 102 | } xfs_attr_leaf_name_local_t; |
103 | 103 | ||
104 | typedef struct xfs_attr_leaf_name_remote { | 104 | typedef struct xfs_attr_leaf_name_remote { |
105 | xfs_dablk_t valueblk; /* block number of value bytes */ | 105 | __be32 valueblk; /* block number of value bytes */ |
106 | __uint32_t valuelen; /* number of bytes in value */ | 106 | __be32 valuelen; /* number of bytes in value */ |
107 | __uint8_t namelen; /* length of name bytes */ | 107 | __u8 namelen; /* length of name bytes */ |
108 | __uint8_t name[1]; /* name bytes */ | 108 | __u8 name[1]; /* name bytes */ |
109 | } xfs_attr_leaf_name_remote_t; | 109 | } xfs_attr_leaf_name_remote_t; |
110 | 110 | ||
111 | typedef struct xfs_attr_leafblock { | 111 | typedef struct xfs_attr_leafblock { |
@@ -143,8 +143,8 @@ typedef struct xfs_attr_leafblock { | |||
143 | static inline xfs_attr_leaf_name_remote_t * | 143 | static inline xfs_attr_leaf_name_remote_t * |
144 | xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) | 144 | xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) |
145 | { | 145 | { |
146 | return (xfs_attr_leaf_name_remote_t *) &((char *) | 146 | return (xfs_attr_leaf_name_remote_t *) |
147 | (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]; | 147 | &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)]; |
148 | } | 148 | } |
149 | 149 | ||
150 | #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ | 150 | #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ |
@@ -152,16 +152,15 @@ xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) | |||
152 | static inline xfs_attr_leaf_name_local_t * | 152 | static inline xfs_attr_leaf_name_local_t * |
153 | xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx) | 153 | xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx) |
154 | { | 154 | { |
155 | return (xfs_attr_leaf_name_local_t *) &((char *) | 155 | return (xfs_attr_leaf_name_local_t *) |
156 | (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]; | 156 | &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)]; |
157 | } | 157 | } |
158 | 158 | ||
159 | #define XFS_ATTR_LEAF_NAME(leafp,idx) \ | 159 | #define XFS_ATTR_LEAF_NAME(leafp,idx) \ |
160 | xfs_attr_leaf_name(leafp,idx) | 160 | xfs_attr_leaf_name(leafp,idx) |
161 | static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx) | 161 | static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx) |
162 | { | 162 | { |
163 | return (&((char *) | 163 | return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)]; |
164 | (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]); | ||
165 | } | 164 | } |
166 | 165 | ||
167 | /* | 166 | /* |
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/xfs_attr_sf.h index ffed6ca81a52..f67f917803b1 100644 --- a/fs/xfs/xfs_attr_sf.h +++ b/fs/xfs/xfs_attr_sf.h | |||
@@ -32,8 +32,8 @@ struct xfs_inode; | |||
32 | */ | 32 | */ |
33 | typedef struct xfs_attr_shortform { | 33 | typedef struct xfs_attr_shortform { |
34 | struct xfs_attr_sf_hdr { /* constant-structure header block */ | 34 | struct xfs_attr_sf_hdr { /* constant-structure header block */ |
35 | __uint16_t totsize; /* total bytes in shortform list */ | 35 | __be16 totsize; /* total bytes in shortform list */ |
36 | __uint8_t count; /* count of active entries */ | 36 | __u8 count; /* count of active entries */ |
37 | } hdr; | 37 | } hdr; |
38 | struct xfs_attr_sf_entry { | 38 | struct xfs_attr_sf_entry { |
39 | __uint8_t namelen; /* actual length of name (no NULL) */ | 39 | __uint8_t namelen; /* actual length of name (no NULL) */ |
@@ -66,8 +66,8 @@ typedef struct xfs_attr_sf_sort { | |||
66 | #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ | 66 | #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ |
67 | ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) | 67 | ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) |
68 | #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ | 68 | #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ |
69 | (INT_GET(((xfs_attr_shortform_t *) \ | 69 | (be16_to_cpu(((xfs_attr_shortform_t *) \ |
70 | ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT)) | 70 | ((dp)->i_afp->if_u1.if_data))->hdr.totsize)) |
71 | 71 | ||
72 | #if defined(XFS_ATTR_TRACE) | 72 | #if defined(XFS_ATTR_TRACE) |
73 | /* | 73 | /* |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 70625e577c70..2d702e4a74a3 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -89,7 +89,7 @@ xfs_bmap_add_attrfork_local( | |||
89 | int *flags); /* inode logging flags */ | 89 | int *flags); /* inode logging flags */ |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * Called by xfs_bmapi to update extent list structure and the btree | 92 | * Called by xfs_bmapi to update file extent records and the btree |
93 | * after allocating space (or doing a delayed allocation). | 93 | * after allocating space (or doing a delayed allocation). |
94 | */ | 94 | */ |
95 | STATIC int /* error */ | 95 | STATIC int /* error */ |
@@ -97,7 +97,7 @@ xfs_bmap_add_extent( | |||
97 | xfs_inode_t *ip, /* incore inode pointer */ | 97 | xfs_inode_t *ip, /* incore inode pointer */ |
98 | xfs_extnum_t idx, /* extent number to update/insert */ | 98 | xfs_extnum_t idx, /* extent number to update/insert */ |
99 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 99 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
100 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 100 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
101 | xfs_fsblock_t *first, /* pointer to firstblock variable */ | 101 | xfs_fsblock_t *first, /* pointer to firstblock variable */ |
102 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | 102 | xfs_bmap_free_t *flist, /* list of extents to be freed */ |
103 | int *logflagsp, /* inode logging flags */ | 103 | int *logflagsp, /* inode logging flags */ |
@@ -113,7 +113,7 @@ xfs_bmap_add_extent_delay_real( | |||
113 | xfs_inode_t *ip, /* incore inode pointer */ | 113 | xfs_inode_t *ip, /* incore inode pointer */ |
114 | xfs_extnum_t idx, /* extent number to update/insert */ | 114 | xfs_extnum_t idx, /* extent number to update/insert */ |
115 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 115 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
116 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 116 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
117 | xfs_filblks_t *dnew, /* new delayed-alloc indirect blocks */ | 117 | xfs_filblks_t *dnew, /* new delayed-alloc indirect blocks */ |
118 | xfs_fsblock_t *first, /* pointer to firstblock variable */ | 118 | xfs_fsblock_t *first, /* pointer to firstblock variable */ |
119 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | 119 | xfs_bmap_free_t *flist, /* list of extents to be freed */ |
@@ -129,7 +129,7 @@ xfs_bmap_add_extent_hole_delay( | |||
129 | xfs_inode_t *ip, /* incore inode pointer */ | 129 | xfs_inode_t *ip, /* incore inode pointer */ |
130 | xfs_extnum_t idx, /* extent number to update/insert */ | 130 | xfs_extnum_t idx, /* extent number to update/insert */ |
131 | xfs_btree_cur_t *cur, /* if null, not a btree */ | 131 | xfs_btree_cur_t *cur, /* if null, not a btree */ |
132 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 132 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
133 | int *logflagsp,/* inode logging flags */ | 133 | int *logflagsp,/* inode logging flags */ |
134 | int rsvd); /* OK to allocate reserved blocks */ | 134 | int rsvd); /* OK to allocate reserved blocks */ |
135 | 135 | ||
@@ -142,7 +142,7 @@ xfs_bmap_add_extent_hole_real( | |||
142 | xfs_inode_t *ip, /* incore inode pointer */ | 142 | xfs_inode_t *ip, /* incore inode pointer */ |
143 | xfs_extnum_t idx, /* extent number to update/insert */ | 143 | xfs_extnum_t idx, /* extent number to update/insert */ |
144 | xfs_btree_cur_t *cur, /* if null, not a btree */ | 144 | xfs_btree_cur_t *cur, /* if null, not a btree */ |
145 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 145 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
146 | int *logflagsp, /* inode logging flags */ | 146 | int *logflagsp, /* inode logging flags */ |
147 | int whichfork); /* data or attr fork */ | 147 | int whichfork); /* data or attr fork */ |
148 | 148 | ||
@@ -155,7 +155,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
155 | xfs_inode_t *ip, /* incore inode pointer */ | 155 | xfs_inode_t *ip, /* incore inode pointer */ |
156 | xfs_extnum_t idx, /* extent number to update/insert */ | 156 | xfs_extnum_t idx, /* extent number to update/insert */ |
157 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 157 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
158 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 158 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
159 | int *logflagsp); /* inode logging flags */ | 159 | int *logflagsp); /* inode logging flags */ |
160 | 160 | ||
161 | /* | 161 | /* |
@@ -169,7 +169,7 @@ xfs_bmap_alloc( | |||
169 | /* | 169 | /* |
170 | * Transform a btree format file with only one leaf node, where the | 170 | * Transform a btree format file with only one leaf node, where the |
171 | * extents list will fit in the inode, into an extents format file. | 171 | * extents list will fit in the inode, into an extents format file. |
172 | * Since the extent list is already in-core, all we have to do is | 172 | * Since the file extents are already in-core, all we have to do is |
173 | * give up the space for the btree root and pitch the leaf block. | 173 | * give up the space for the btree root and pitch the leaf block. |
174 | */ | 174 | */ |
175 | STATIC int /* error */ | 175 | STATIC int /* error */ |
@@ -191,7 +191,7 @@ xfs_bmap_check_extents( | |||
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | /* | 193 | /* |
194 | * Called by xfs_bmapi to update extent list structure and the btree | 194 | * Called by xfs_bmapi to update file extent records and the btree |
195 | * after removing space (or undoing a delayed allocation). | 195 | * after removing space (or undoing a delayed allocation). |
196 | */ | 196 | */ |
197 | STATIC int /* error */ | 197 | STATIC int /* error */ |
@@ -201,7 +201,7 @@ xfs_bmap_del_extent( | |||
201 | xfs_extnum_t idx, /* extent number to update/insert */ | 201 | xfs_extnum_t idx, /* extent number to update/insert */ |
202 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | 202 | xfs_bmap_free_t *flist, /* list of extents to be freed */ |
203 | xfs_btree_cur_t *cur, /* if null, not a btree */ | 203 | xfs_btree_cur_t *cur, /* if null, not a btree */ |
204 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 204 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
205 | int *logflagsp,/* inode logging flags */ | 205 | int *logflagsp,/* inode logging flags */ |
206 | int whichfork, /* data or attr fork */ | 206 | int whichfork, /* data or attr fork */ |
207 | int rsvd); /* OK to allocate reserved blocks */ | 207 | int rsvd); /* OK to allocate reserved blocks */ |
@@ -217,18 +217,6 @@ xfs_bmap_del_free( | |||
217 | xfs_bmap_free_item_t *free); /* list item to be freed */ | 217 | xfs_bmap_free_item_t *free); /* list item to be freed */ |
218 | 218 | ||
219 | /* | 219 | /* |
220 | * Remove count entries from the extents array for inode "ip", starting | ||
221 | * at index "idx". Copies the remaining items down over the deleted ones, | ||
222 | * and gives back the excess memory. | ||
223 | */ | ||
224 | STATIC void | ||
225 | xfs_bmap_delete_exlist( | ||
226 | xfs_inode_t *ip, /* incode inode pointer */ | ||
227 | xfs_extnum_t idx, /* starting delete index */ | ||
228 | xfs_extnum_t count, /* count of items to delete */ | ||
229 | int whichfork); /* data or attr fork */ | ||
230 | |||
231 | /* | ||
232 | * Convert an extents-format file into a btree-format file. | 220 | * Convert an extents-format file into a btree-format file. |
233 | * The new file will have a root block (in the inode) and a single child block. | 221 | * The new file will have a root block (in the inode) and a single child block. |
234 | */ | 222 | */ |
@@ -244,18 +232,6 @@ xfs_bmap_extents_to_btree( | |||
244 | int whichfork); /* data or attr fork */ | 232 | int whichfork); /* data or attr fork */ |
245 | 233 | ||
246 | /* | 234 | /* |
247 | * Insert new item(s) in the extent list for inode "ip". | ||
248 | * Count new items are inserted at offset idx. | ||
249 | */ | ||
250 | STATIC void | ||
251 | xfs_bmap_insert_exlist( | ||
252 | xfs_inode_t *ip, /* incore inode pointer */ | ||
253 | xfs_extnum_t idx, /* starting index of new items */ | ||
254 | xfs_extnum_t count, /* number of inserted items */ | ||
255 | xfs_bmbt_irec_t *new, /* items to insert */ | ||
256 | int whichfork); /* data or attr fork */ | ||
257 | |||
258 | /* | ||
259 | * Convert a local file to an extents file. | 235 | * Convert a local file to an extents file. |
260 | * This code is sort of bogus, since the file data needs to get | 236 | * This code is sort of bogus, since the file data needs to get |
261 | * logged so it won't be lost. The bmap-level manipulations are ok, though. | 237 | * logged so it won't be lost. The bmap-level manipulations are ok, though. |
@@ -316,7 +292,7 @@ xfs_bmap_trace_addentry( | |||
316 | int whichfork); /* data or attr fork */ | 292 | int whichfork); /* data or attr fork */ |
317 | 293 | ||
318 | /* | 294 | /* |
319 | * Add bmap trace entry prior to a call to xfs_bmap_delete_exlist. | 295 | * Add bmap trace entry prior to a call to xfs_iext_remove. |
320 | */ | 296 | */ |
321 | STATIC void | 297 | STATIC void |
322 | xfs_bmap_trace_delete( | 298 | xfs_bmap_trace_delete( |
@@ -328,7 +304,7 @@ xfs_bmap_trace_delete( | |||
328 | int whichfork); /* data or attr fork */ | 304 | int whichfork); /* data or attr fork */ |
329 | 305 | ||
330 | /* | 306 | /* |
331 | * Add bmap trace entry prior to a call to xfs_bmap_insert_exlist, or | 307 | * Add bmap trace entry prior to a call to xfs_iext_insert, or |
332 | * reading in the extents list from the disk (in the btree). | 308 | * reading in the extents list from the disk (in the btree). |
333 | */ | 309 | */ |
334 | STATIC void | 310 | STATIC void |
@@ -343,7 +319,7 @@ xfs_bmap_trace_insert( | |||
343 | int whichfork); /* data or attr fork */ | 319 | int whichfork); /* data or attr fork */ |
344 | 320 | ||
345 | /* | 321 | /* |
346 | * Add bmap trace entry after updating an extent list entry in place. | 322 | * Add bmap trace entry after updating an extent record in place. |
347 | */ | 323 | */ |
348 | STATIC void | 324 | STATIC void |
349 | xfs_bmap_trace_post_update( | 325 | xfs_bmap_trace_post_update( |
@@ -354,7 +330,7 @@ xfs_bmap_trace_post_update( | |||
354 | int whichfork); /* data or attr fork */ | 330 | int whichfork); /* data or attr fork */ |
355 | 331 | ||
356 | /* | 332 | /* |
357 | * Add bmap trace entry prior to updating an extent list entry in place. | 333 | * Add bmap trace entry prior to updating an extent record in place. |
358 | */ | 334 | */ |
359 | STATIC void | 335 | STATIC void |
360 | xfs_bmap_trace_pre_update( | 336 | xfs_bmap_trace_pre_update( |
@@ -413,19 +389,24 @@ STATIC int | |||
413 | xfs_bmap_count_tree( | 389 | xfs_bmap_count_tree( |
414 | xfs_mount_t *mp, | 390 | xfs_mount_t *mp, |
415 | xfs_trans_t *tp, | 391 | xfs_trans_t *tp, |
392 | xfs_ifork_t *ifp, | ||
416 | xfs_fsblock_t blockno, | 393 | xfs_fsblock_t blockno, |
417 | int levelin, | 394 | int levelin, |
418 | int *count); | 395 | int *count); |
419 | 396 | ||
420 | STATIC int | 397 | STATIC int |
421 | xfs_bmap_count_leaves( | 398 | xfs_bmap_count_leaves( |
422 | xfs_bmbt_rec_t *frp, | 399 | xfs_ifork_t *ifp, |
400 | xfs_extnum_t idx, | ||
423 | int numrecs, | 401 | int numrecs, |
424 | int *count); | 402 | int *count); |
425 | 403 | ||
426 | STATIC int | 404 | STATIC int |
427 | xfs_bmap_disk_count_leaves( | 405 | xfs_bmap_disk_count_leaves( |
428 | xfs_bmbt_rec_t *frp, | 406 | xfs_ifork_t *ifp, |
407 | xfs_mount_t *mp, | ||
408 | xfs_extnum_t idx, | ||
409 | xfs_bmbt_block_t *block, | ||
429 | int numrecs, | 410 | int numrecs, |
430 | int *count); | 411 | int *count); |
431 | 412 | ||
@@ -537,7 +518,7 @@ xfs_bmap_add_attrfork_local( | |||
537 | } | 518 | } |
538 | 519 | ||
539 | /* | 520 | /* |
540 | * Called by xfs_bmapi to update extent list structure and the btree | 521 | * Called by xfs_bmapi to update file extent records and the btree |
541 | * after allocating space (or doing a delayed allocation). | 522 | * after allocating space (or doing a delayed allocation). |
542 | */ | 523 | */ |
543 | STATIC int /* error */ | 524 | STATIC int /* error */ |
@@ -545,7 +526,7 @@ xfs_bmap_add_extent( | |||
545 | xfs_inode_t *ip, /* incore inode pointer */ | 526 | xfs_inode_t *ip, /* incore inode pointer */ |
546 | xfs_extnum_t idx, /* extent number to update/insert */ | 527 | xfs_extnum_t idx, /* extent number to update/insert */ |
547 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 528 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
548 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 529 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
549 | xfs_fsblock_t *first, /* pointer to firstblock variable */ | 530 | xfs_fsblock_t *first, /* pointer to firstblock variable */ |
550 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | 531 | xfs_bmap_free_t *flist, /* list of extents to be freed */ |
551 | int *logflagsp, /* inode logging flags */ | 532 | int *logflagsp, /* inode logging flags */ |
@@ -578,7 +559,7 @@ xfs_bmap_add_extent( | |||
578 | if (nextents == 0) { | 559 | if (nextents == 0) { |
579 | xfs_bmap_trace_insert(fname, "insert empty", ip, 0, 1, new, | 560 | xfs_bmap_trace_insert(fname, "insert empty", ip, 0, 1, new, |
580 | NULL, whichfork); | 561 | NULL, whichfork); |
581 | xfs_bmap_insert_exlist(ip, 0, 1, new, whichfork); | 562 | xfs_iext_insert(ifp, 0, 1, new); |
582 | ASSERT(cur == NULL); | 563 | ASSERT(cur == NULL); |
583 | ifp->if_lastex = 0; | 564 | ifp->if_lastex = 0; |
584 | if (!ISNULLSTARTBLOCK(new->br_startblock)) { | 565 | if (!ISNULLSTARTBLOCK(new->br_startblock)) { |
@@ -614,7 +595,7 @@ xfs_bmap_add_extent( | |||
614 | /* | 595 | /* |
615 | * Get the record referred to by idx. | 596 | * Get the record referred to by idx. |
616 | */ | 597 | */ |
617 | xfs_bmbt_get_all(&ifp->if_u1.if_extents[idx], &prev); | 598 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &prev); |
618 | /* | 599 | /* |
619 | * If it's a real allocation record, and the new allocation ends | 600 | * If it's a real allocation record, and the new allocation ends |
620 | * after the start of the referred to record, then we're filling | 601 | * after the start of the referred to record, then we're filling |
@@ -714,14 +695,13 @@ xfs_bmap_add_extent_delay_real( | |||
714 | xfs_inode_t *ip, /* incore inode pointer */ | 695 | xfs_inode_t *ip, /* incore inode pointer */ |
715 | xfs_extnum_t idx, /* extent number to update/insert */ | 696 | xfs_extnum_t idx, /* extent number to update/insert */ |
716 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 697 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
717 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 698 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
718 | xfs_filblks_t *dnew, /* new delayed-alloc indirect blocks */ | 699 | xfs_filblks_t *dnew, /* new delayed-alloc indirect blocks */ |
719 | xfs_fsblock_t *first, /* pointer to firstblock variable */ | 700 | xfs_fsblock_t *first, /* pointer to firstblock variable */ |
720 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | 701 | xfs_bmap_free_t *flist, /* list of extents to be freed */ |
721 | int *logflagsp, /* inode logging flags */ | 702 | int *logflagsp, /* inode logging flags */ |
722 | int rsvd) /* OK to use reserved data block allocation */ | 703 | int rsvd) /* OK to use reserved data block allocation */ |
723 | { | 704 | { |
724 | xfs_bmbt_rec_t *base; /* base of extent entry list */ | ||
725 | xfs_btree_cur_t *cur; /* btree cursor */ | 705 | xfs_btree_cur_t *cur; /* btree cursor */ |
726 | int diff; /* temp value */ | 706 | int diff; /* temp value */ |
727 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ | 707 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ |
@@ -730,6 +710,7 @@ xfs_bmap_add_extent_delay_real( | |||
730 | static char fname[] = "xfs_bmap_add_extent_delay_real"; | 710 | static char fname[] = "xfs_bmap_add_extent_delay_real"; |
731 | #endif | 711 | #endif |
732 | int i; /* temp state */ | 712 | int i; /* temp state */ |
713 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
733 | xfs_fileoff_t new_endoff; /* end offset of new entry */ | 714 | xfs_fileoff_t new_endoff; /* end offset of new entry */ |
734 | xfs_bmbt_irec_t r[3]; /* neighbor extent entries */ | 715 | xfs_bmbt_irec_t r[3]; /* neighbor extent entries */ |
735 | /* left is 0, right is 1, prev is 2 */ | 716 | /* left is 0, right is 1, prev is 2 */ |
@@ -763,8 +744,8 @@ xfs_bmap_add_extent_delay_real( | |||
763 | * Set up a bunch of variables to make the tests simpler. | 744 | * Set up a bunch of variables to make the tests simpler. |
764 | */ | 745 | */ |
765 | cur = *curp; | 746 | cur = *curp; |
766 | base = ip->i_df.if_u1.if_extents; | 747 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); |
767 | ep = &base[idx]; | 748 | ep = xfs_iext_get_ext(ifp, idx); |
768 | xfs_bmbt_get_all(ep, &PREV); | 749 | xfs_bmbt_get_all(ep, &PREV); |
769 | new_endoff = new->br_startoff + new->br_blockcount; | 750 | new_endoff = new->br_startoff + new->br_blockcount; |
770 | ASSERT(PREV.br_startoff <= new->br_startoff); | 751 | ASSERT(PREV.br_startoff <= new->br_startoff); |
@@ -781,7 +762,7 @@ xfs_bmap_add_extent_delay_real( | |||
781 | * Don't set contiguous if the combined extent would be too large. | 762 | * Don't set contiguous if the combined extent would be too large. |
782 | */ | 763 | */ |
783 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 764 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { |
784 | xfs_bmbt_get_all(ep - 1, &LEFT); | 765 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); |
785 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock)); | 766 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock)); |
786 | } | 767 | } |
787 | STATE_SET(LEFT_CONTIG, | 768 | STATE_SET(LEFT_CONTIG, |
@@ -798,7 +779,7 @@ xfs_bmap_add_extent_delay_real( | |||
798 | if (STATE_SET_TEST(RIGHT_VALID, | 779 | if (STATE_SET_TEST(RIGHT_VALID, |
799 | idx < | 780 | idx < |
800 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { | 781 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { |
801 | xfs_bmbt_get_all(ep + 1, &RIGHT); | 782 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); |
802 | STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock)); | 783 | STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock)); |
803 | } | 784 | } |
804 | STATE_SET(RIGHT_CONTIG, | 785 | STATE_SET(RIGHT_CONTIG, |
@@ -825,14 +806,14 @@ xfs_bmap_add_extent_delay_real( | |||
825 | */ | 806 | */ |
826 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 807 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1, |
827 | XFS_DATA_FORK); | 808 | XFS_DATA_FORK); |
828 | xfs_bmbt_set_blockcount(ep - 1, | 809 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
829 | LEFT.br_blockcount + PREV.br_blockcount + | 810 | LEFT.br_blockcount + PREV.br_blockcount + |
830 | RIGHT.br_blockcount); | 811 | RIGHT.br_blockcount); |
831 | xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 812 | xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1, |
832 | XFS_DATA_FORK); | 813 | XFS_DATA_FORK); |
833 | xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2, | 814 | xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2, |
834 | XFS_DATA_FORK); | 815 | XFS_DATA_FORK); |
835 | xfs_bmap_delete_exlist(ip, idx, 2, XFS_DATA_FORK); | 816 | xfs_iext_remove(ifp, idx, 2); |
836 | ip->i_df.if_lastex = idx - 1; | 817 | ip->i_df.if_lastex = idx - 1; |
837 | ip->i_d.di_nextents--; | 818 | ip->i_d.di_nextents--; |
838 | if (cur == NULL) | 819 | if (cur == NULL) |
@@ -867,14 +848,14 @@ xfs_bmap_add_extent_delay_real( | |||
867 | */ | 848 | */ |
868 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1, | 849 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1, |
869 | XFS_DATA_FORK); | 850 | XFS_DATA_FORK); |
870 | xfs_bmbt_set_blockcount(ep - 1, | 851 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
871 | LEFT.br_blockcount + PREV.br_blockcount); | 852 | LEFT.br_blockcount + PREV.br_blockcount); |
872 | xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1, | 853 | xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1, |
873 | XFS_DATA_FORK); | 854 | XFS_DATA_FORK); |
874 | ip->i_df.if_lastex = idx - 1; | 855 | ip->i_df.if_lastex = idx - 1; |
875 | xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1, | 856 | xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1, |
876 | XFS_DATA_FORK); | 857 | XFS_DATA_FORK); |
877 | xfs_bmap_delete_exlist(ip, idx, 1, XFS_DATA_FORK); | 858 | xfs_iext_remove(ifp, idx, 1); |
878 | if (cur == NULL) | 859 | if (cur == NULL) |
879 | rval = XFS_ILOG_DEXT; | 860 | rval = XFS_ILOG_DEXT; |
880 | else { | 861 | else { |
@@ -908,7 +889,7 @@ xfs_bmap_add_extent_delay_real( | |||
908 | ip->i_df.if_lastex = idx; | 889 | ip->i_df.if_lastex = idx; |
909 | xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1, | 890 | xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1, |
910 | XFS_DATA_FORK); | 891 | XFS_DATA_FORK); |
911 | xfs_bmap_delete_exlist(ip, idx + 1, 1, XFS_DATA_FORK); | 892 | xfs_iext_remove(ifp, idx + 1, 1); |
912 | if (cur == NULL) | 893 | if (cur == NULL) |
913 | rval = XFS_ILOG_DEXT; | 894 | rval = XFS_ILOG_DEXT; |
914 | else { | 895 | else { |
@@ -964,7 +945,7 @@ xfs_bmap_add_extent_delay_real( | |||
964 | */ | 945 | */ |
965 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1, | 946 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1, |
966 | XFS_DATA_FORK); | 947 | XFS_DATA_FORK); |
967 | xfs_bmbt_set_blockcount(ep - 1, | 948 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
968 | LEFT.br_blockcount + new->br_blockcount); | 949 | LEFT.br_blockcount + new->br_blockcount); |
969 | xfs_bmbt_set_startoff(ep, | 950 | xfs_bmbt_set_startoff(ep, |
970 | PREV.br_startoff + new->br_blockcount); | 951 | PREV.br_startoff + new->br_blockcount); |
@@ -1010,7 +991,7 @@ xfs_bmap_add_extent_delay_real( | |||
1010 | xfs_bmbt_set_blockcount(ep, temp); | 991 | xfs_bmbt_set_blockcount(ep, temp); |
1011 | xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL, | 992 | xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL, |
1012 | XFS_DATA_FORK); | 993 | XFS_DATA_FORK); |
1013 | xfs_bmap_insert_exlist(ip, idx, 1, new, XFS_DATA_FORK); | 994 | xfs_iext_insert(ifp, idx, 1, new); |
1014 | ip->i_df.if_lastex = idx; | 995 | ip->i_df.if_lastex = idx; |
1015 | ip->i_d.di_nextents++; | 996 | ip->i_d.di_nextents++; |
1016 | if (cur == NULL) | 997 | if (cur == NULL) |
@@ -1039,8 +1020,7 @@ xfs_bmap_add_extent_delay_real( | |||
1039 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 1020 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
1040 | STARTBLOCKVAL(PREV.br_startblock) - | 1021 | STARTBLOCKVAL(PREV.br_startblock) - |
1041 | (cur ? cur->bc_private.b.allocated : 0)); | 1022 | (cur ? cur->bc_private.b.allocated : 0)); |
1042 | base = ip->i_df.if_u1.if_extents; | 1023 | ep = xfs_iext_get_ext(ifp, idx + 1); |
1043 | ep = &base[idx + 1]; | ||
1044 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1024 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1045 | xfs_bmap_trace_post_update(fname, "LF", ip, idx + 1, | 1025 | xfs_bmap_trace_post_update(fname, "LF", ip, idx + 1, |
1046 | XFS_DATA_FORK); | 1026 | XFS_DATA_FORK); |
@@ -1058,7 +1038,8 @@ xfs_bmap_add_extent_delay_real( | |||
1058 | xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx + 1, | 1038 | xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx + 1, |
1059 | XFS_DATA_FORK); | 1039 | XFS_DATA_FORK); |
1060 | xfs_bmbt_set_blockcount(ep, temp); | 1040 | xfs_bmbt_set_blockcount(ep, temp); |
1061 | xfs_bmbt_set_allf(ep + 1, new->br_startoff, new->br_startblock, | 1041 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), |
1042 | new->br_startoff, new->br_startblock, | ||
1062 | new->br_blockcount + RIGHT.br_blockcount, | 1043 | new->br_blockcount + RIGHT.br_blockcount, |
1063 | RIGHT.br_state); | 1044 | RIGHT.br_state); |
1064 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1, | 1045 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1, |
@@ -1098,7 +1079,7 @@ xfs_bmap_add_extent_delay_real( | |||
1098 | xfs_bmbt_set_blockcount(ep, temp); | 1079 | xfs_bmbt_set_blockcount(ep, temp); |
1099 | xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1, | 1080 | xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1, |
1100 | new, NULL, XFS_DATA_FORK); | 1081 | new, NULL, XFS_DATA_FORK); |
1101 | xfs_bmap_insert_exlist(ip, idx + 1, 1, new, XFS_DATA_FORK); | 1082 | xfs_iext_insert(ifp, idx + 1, 1, new); |
1102 | ip->i_df.if_lastex = idx + 1; | 1083 | ip->i_df.if_lastex = idx + 1; |
1103 | ip->i_d.di_nextents++; | 1084 | ip->i_d.di_nextents++; |
1104 | if (cur == NULL) | 1085 | if (cur == NULL) |
@@ -1127,8 +1108,7 @@ xfs_bmap_add_extent_delay_real( | |||
1127 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 1108 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
1128 | STARTBLOCKVAL(PREV.br_startblock) - | 1109 | STARTBLOCKVAL(PREV.br_startblock) - |
1129 | (cur ? cur->bc_private.b.allocated : 0)); | 1110 | (cur ? cur->bc_private.b.allocated : 0)); |
1130 | base = ip->i_df.if_u1.if_extents; | 1111 | ep = xfs_iext_get_ext(ifp, idx); |
1131 | ep = &base[idx]; | ||
1132 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1112 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1133 | xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK); | 1113 | xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK); |
1134 | *dnew = temp; | 1114 | *dnew = temp; |
@@ -1149,7 +1129,7 @@ xfs_bmap_add_extent_delay_real( | |||
1149 | r[1].br_blockcount = temp2; | 1129 | r[1].br_blockcount = temp2; |
1150 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1], | 1130 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1], |
1151 | XFS_DATA_FORK); | 1131 | XFS_DATA_FORK); |
1152 | xfs_bmap_insert_exlist(ip, idx + 1, 2, &r[0], XFS_DATA_FORK); | 1132 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); |
1153 | ip->i_df.if_lastex = idx + 1; | 1133 | ip->i_df.if_lastex = idx + 1; |
1154 | ip->i_d.di_nextents++; | 1134 | ip->i_d.di_nextents++; |
1155 | if (cur == NULL) | 1135 | if (cur == NULL) |
@@ -1204,13 +1184,13 @@ xfs_bmap_add_extent_delay_real( | |||
1204 | } | 1184 | } |
1205 | } | 1185 | } |
1206 | } | 1186 | } |
1207 | base = ip->i_df.if_u1.if_extents; | 1187 | ep = xfs_iext_get_ext(ifp, idx); |
1208 | ep = &base[idx]; | ||
1209 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1188 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1210 | xfs_bmap_trace_post_update(fname, "0", ip, idx, XFS_DATA_FORK); | 1189 | xfs_bmap_trace_post_update(fname, "0", ip, idx, XFS_DATA_FORK); |
1211 | xfs_bmap_trace_pre_update(fname, "0", ip, idx + 2, | 1190 | xfs_bmap_trace_pre_update(fname, "0", ip, idx + 2, |
1212 | XFS_DATA_FORK); | 1191 | XFS_DATA_FORK); |
1213 | xfs_bmbt_set_startblock(ep + 2, NULLSTARTBLOCK((int)temp2)); | 1192 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2), |
1193 | NULLSTARTBLOCK((int)temp2)); | ||
1214 | xfs_bmap_trace_post_update(fname, "0", ip, idx + 2, | 1194 | xfs_bmap_trace_post_update(fname, "0", ip, idx + 2, |
1215 | XFS_DATA_FORK); | 1195 | XFS_DATA_FORK); |
1216 | *dnew = temp + temp2; | 1196 | *dnew = temp + temp2; |
@@ -1254,10 +1234,9 @@ xfs_bmap_add_extent_unwritten_real( | |||
1254 | xfs_inode_t *ip, /* incore inode pointer */ | 1234 | xfs_inode_t *ip, /* incore inode pointer */ |
1255 | xfs_extnum_t idx, /* extent number to update/insert */ | 1235 | xfs_extnum_t idx, /* extent number to update/insert */ |
1256 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 1236 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
1257 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 1237 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
1258 | int *logflagsp) /* inode logging flags */ | 1238 | int *logflagsp) /* inode logging flags */ |
1259 | { | 1239 | { |
1260 | xfs_bmbt_rec_t *base; /* base of extent entry list */ | ||
1261 | xfs_btree_cur_t *cur; /* btree cursor */ | 1240 | xfs_btree_cur_t *cur; /* btree cursor */ |
1262 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ | 1241 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ |
1263 | int error; /* error return value */ | 1242 | int error; /* error return value */ |
@@ -1265,6 +1244,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1265 | static char fname[] = "xfs_bmap_add_extent_unwritten_real"; | 1244 | static char fname[] = "xfs_bmap_add_extent_unwritten_real"; |
1266 | #endif | 1245 | #endif |
1267 | int i; /* temp state */ | 1246 | int i; /* temp state */ |
1247 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
1268 | xfs_fileoff_t new_endoff; /* end offset of new entry */ | 1248 | xfs_fileoff_t new_endoff; /* end offset of new entry */ |
1269 | xfs_exntst_t newext; /* new extent state */ | 1249 | xfs_exntst_t newext; /* new extent state */ |
1270 | xfs_exntst_t oldext; /* old extent state */ | 1250 | xfs_exntst_t oldext; /* old extent state */ |
@@ -1298,8 +1278,8 @@ xfs_bmap_add_extent_unwritten_real( | |||
1298 | */ | 1278 | */ |
1299 | error = 0; | 1279 | error = 0; |
1300 | cur = *curp; | 1280 | cur = *curp; |
1301 | base = ip->i_df.if_u1.if_extents; | 1281 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); |
1302 | ep = &base[idx]; | 1282 | ep = xfs_iext_get_ext(ifp, idx); |
1303 | xfs_bmbt_get_all(ep, &PREV); | 1283 | xfs_bmbt_get_all(ep, &PREV); |
1304 | newext = new->br_state; | 1284 | newext = new->br_state; |
1305 | oldext = (newext == XFS_EXT_UNWRITTEN) ? | 1285 | oldext = (newext == XFS_EXT_UNWRITTEN) ? |
@@ -1320,7 +1300,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1320 | * Don't set contiguous if the combined extent would be too large. | 1300 | * Don't set contiguous if the combined extent would be too large. |
1321 | */ | 1301 | */ |
1322 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1302 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { |
1323 | xfs_bmbt_get_all(ep - 1, &LEFT); | 1303 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); |
1324 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock)); | 1304 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock)); |
1325 | } | 1305 | } |
1326 | STATE_SET(LEFT_CONTIG, | 1306 | STATE_SET(LEFT_CONTIG, |
@@ -1337,7 +1317,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1337 | if (STATE_SET_TEST(RIGHT_VALID, | 1317 | if (STATE_SET_TEST(RIGHT_VALID, |
1338 | idx < | 1318 | idx < |
1339 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { | 1319 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { |
1340 | xfs_bmbt_get_all(ep + 1, &RIGHT); | 1320 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); |
1341 | STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock)); | 1321 | STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock)); |
1342 | } | 1322 | } |
1343 | STATE_SET(RIGHT_CONTIG, | 1323 | STATE_SET(RIGHT_CONTIG, |
@@ -1363,14 +1343,14 @@ xfs_bmap_add_extent_unwritten_real( | |||
1363 | */ | 1343 | */ |
1364 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 1344 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1, |
1365 | XFS_DATA_FORK); | 1345 | XFS_DATA_FORK); |
1366 | xfs_bmbt_set_blockcount(ep - 1, | 1346 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
1367 | LEFT.br_blockcount + PREV.br_blockcount + | 1347 | LEFT.br_blockcount + PREV.br_blockcount + |
1368 | RIGHT.br_blockcount); | 1348 | RIGHT.br_blockcount); |
1369 | xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 1349 | xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1, |
1370 | XFS_DATA_FORK); | 1350 | XFS_DATA_FORK); |
1371 | xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2, | 1351 | xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2, |
1372 | XFS_DATA_FORK); | 1352 | XFS_DATA_FORK); |
1373 | xfs_bmap_delete_exlist(ip, idx, 2, XFS_DATA_FORK); | 1353 | xfs_iext_remove(ifp, idx, 2); |
1374 | ip->i_df.if_lastex = idx - 1; | 1354 | ip->i_df.if_lastex = idx - 1; |
1375 | ip->i_d.di_nextents -= 2; | 1355 | ip->i_d.di_nextents -= 2; |
1376 | if (cur == NULL) | 1356 | if (cur == NULL) |
@@ -1409,14 +1389,14 @@ xfs_bmap_add_extent_unwritten_real( | |||
1409 | */ | 1389 | */ |
1410 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1, | 1390 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1, |
1411 | XFS_DATA_FORK); | 1391 | XFS_DATA_FORK); |
1412 | xfs_bmbt_set_blockcount(ep - 1, | 1392 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
1413 | LEFT.br_blockcount + PREV.br_blockcount); | 1393 | LEFT.br_blockcount + PREV.br_blockcount); |
1414 | xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1, | 1394 | xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1, |
1415 | XFS_DATA_FORK); | 1395 | XFS_DATA_FORK); |
1416 | ip->i_df.if_lastex = idx - 1; | 1396 | ip->i_df.if_lastex = idx - 1; |
1417 | xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1, | 1397 | xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1, |
1418 | XFS_DATA_FORK); | 1398 | XFS_DATA_FORK); |
1419 | xfs_bmap_delete_exlist(ip, idx, 1, XFS_DATA_FORK); | 1399 | xfs_iext_remove(ifp, idx, 1); |
1420 | ip->i_d.di_nextents--; | 1400 | ip->i_d.di_nextents--; |
1421 | if (cur == NULL) | 1401 | if (cur == NULL) |
1422 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; | 1402 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; |
@@ -1456,7 +1436,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1456 | ip->i_df.if_lastex = idx; | 1436 | ip->i_df.if_lastex = idx; |
1457 | xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1, | 1437 | xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1, |
1458 | XFS_DATA_FORK); | 1438 | XFS_DATA_FORK); |
1459 | xfs_bmap_delete_exlist(ip, idx + 1, 1, XFS_DATA_FORK); | 1439 | xfs_iext_remove(ifp, idx + 1, 1); |
1460 | ip->i_d.di_nextents--; | 1440 | ip->i_d.di_nextents--; |
1461 | if (cur == NULL) | 1441 | if (cur == NULL) |
1462 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; | 1442 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; |
@@ -1516,7 +1496,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1516 | */ | 1496 | */ |
1517 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1, | 1497 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1, |
1518 | XFS_DATA_FORK); | 1498 | XFS_DATA_FORK); |
1519 | xfs_bmbt_set_blockcount(ep - 1, | 1499 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
1520 | LEFT.br_blockcount + new->br_blockcount); | 1500 | LEFT.br_blockcount + new->br_blockcount); |
1521 | xfs_bmbt_set_startoff(ep, | 1501 | xfs_bmbt_set_startoff(ep, |
1522 | PREV.br_startoff + new->br_blockcount); | 1502 | PREV.br_startoff + new->br_blockcount); |
@@ -1571,7 +1551,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1571 | xfs_bmap_trace_post_update(fname, "LF", ip, idx, XFS_DATA_FORK); | 1551 | xfs_bmap_trace_post_update(fname, "LF", ip, idx, XFS_DATA_FORK); |
1572 | xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL, | 1552 | xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL, |
1573 | XFS_DATA_FORK); | 1553 | XFS_DATA_FORK); |
1574 | xfs_bmap_insert_exlist(ip, idx, 1, new, XFS_DATA_FORK); | 1554 | xfs_iext_insert(ifp, idx, 1, new); |
1575 | ip->i_df.if_lastex = idx; | 1555 | ip->i_df.if_lastex = idx; |
1576 | ip->i_d.di_nextents++; | 1556 | ip->i_d.di_nextents++; |
1577 | if (cur == NULL) | 1557 | if (cur == NULL) |
@@ -1609,7 +1589,8 @@ xfs_bmap_add_extent_unwritten_real( | |||
1609 | PREV.br_blockcount - new->br_blockcount); | 1589 | PREV.br_blockcount - new->br_blockcount); |
1610 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx, | 1590 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx, |
1611 | XFS_DATA_FORK); | 1591 | XFS_DATA_FORK); |
1612 | xfs_bmbt_set_allf(ep + 1, new->br_startoff, new->br_startblock, | 1592 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), |
1593 | new->br_startoff, new->br_startblock, | ||
1613 | new->br_blockcount + RIGHT.br_blockcount, newext); | 1594 | new->br_blockcount + RIGHT.br_blockcount, newext); |
1614 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1, | 1595 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1, |
1615 | XFS_DATA_FORK); | 1596 | XFS_DATA_FORK); |
@@ -1649,7 +1630,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1649 | xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK); | 1630 | xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK); |
1650 | xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1, | 1631 | xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1, |
1651 | new, NULL, XFS_DATA_FORK); | 1632 | new, NULL, XFS_DATA_FORK); |
1652 | xfs_bmap_insert_exlist(ip, idx + 1, 1, new, XFS_DATA_FORK); | 1633 | xfs_iext_insert(ifp, idx + 1, 1, new); |
1653 | ip->i_df.if_lastex = idx + 1; | 1634 | ip->i_df.if_lastex = idx + 1; |
1654 | ip->i_d.di_nextents++; | 1635 | ip->i_d.di_nextents++; |
1655 | if (cur == NULL) | 1636 | if (cur == NULL) |
@@ -1696,7 +1677,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1696 | r[1].br_state = oldext; | 1677 | r[1].br_state = oldext; |
1697 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1], | 1678 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1], |
1698 | XFS_DATA_FORK); | 1679 | XFS_DATA_FORK); |
1699 | xfs_bmap_insert_exlist(ip, idx + 1, 2, &r[0], XFS_DATA_FORK); | 1680 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); |
1700 | ip->i_df.if_lastex = idx + 1; | 1681 | ip->i_df.if_lastex = idx + 1; |
1701 | ip->i_d.di_nextents += 2; | 1682 | ip->i_d.di_nextents += 2; |
1702 | if (cur == NULL) | 1683 | if (cur == NULL) |
@@ -1770,15 +1751,15 @@ xfs_bmap_add_extent_hole_delay( | |||
1770 | xfs_inode_t *ip, /* incore inode pointer */ | 1751 | xfs_inode_t *ip, /* incore inode pointer */ |
1771 | xfs_extnum_t idx, /* extent number to update/insert */ | 1752 | xfs_extnum_t idx, /* extent number to update/insert */ |
1772 | xfs_btree_cur_t *cur, /* if null, not a btree */ | 1753 | xfs_btree_cur_t *cur, /* if null, not a btree */ |
1773 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 1754 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
1774 | int *logflagsp, /* inode logging flags */ | 1755 | int *logflagsp, /* inode logging flags */ |
1775 | int rsvd) /* OK to allocate reserved blocks */ | 1756 | int rsvd) /* OK to allocate reserved blocks */ |
1776 | { | 1757 | { |
1777 | xfs_bmbt_rec_t *base; /* base of extent entry list */ | 1758 | xfs_bmbt_rec_t *ep; /* extent record for idx */ |
1778 | xfs_bmbt_rec_t *ep; /* extent list entry for idx */ | ||
1779 | #ifdef XFS_BMAP_TRACE | 1759 | #ifdef XFS_BMAP_TRACE |
1780 | static char fname[] = "xfs_bmap_add_extent_hole_delay"; | 1760 | static char fname[] = "xfs_bmap_add_extent_hole_delay"; |
1781 | #endif | 1761 | #endif |
1762 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
1782 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ | 1763 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ |
1783 | xfs_filblks_t newlen=0; /* new indirect size */ | 1764 | xfs_filblks_t newlen=0; /* new indirect size */ |
1784 | xfs_filblks_t oldlen=0; /* old indirect size */ | 1765 | xfs_filblks_t oldlen=0; /* old indirect size */ |
@@ -1799,15 +1780,15 @@ xfs_bmap_add_extent_hole_delay( | |||
1799 | ((state &= ~MASK(b)), 0)) | 1780 | ((state &= ~MASK(b)), 0)) |
1800 | #define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG)) | 1781 | #define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG)) |
1801 | 1782 | ||
1802 | base = ip->i_df.if_u1.if_extents; | 1783 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); |
1803 | ep = &base[idx]; | 1784 | ep = xfs_iext_get_ext(ifp, idx); |
1804 | state = 0; | 1785 | state = 0; |
1805 | ASSERT(ISNULLSTARTBLOCK(new->br_startblock)); | 1786 | ASSERT(ISNULLSTARTBLOCK(new->br_startblock)); |
1806 | /* | 1787 | /* |
1807 | * Check and set flags if this segment has a left neighbor | 1788 | * Check and set flags if this segment has a left neighbor |
1808 | */ | 1789 | */ |
1809 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1790 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { |
1810 | xfs_bmbt_get_all(ep - 1, &left); | 1791 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); |
1811 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock)); | 1792 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock)); |
1812 | } | 1793 | } |
1813 | /* | 1794 | /* |
@@ -1844,23 +1825,24 @@ xfs_bmap_add_extent_hole_delay( | |||
1844 | /* | 1825 | /* |
1845 | * New allocation is contiguous with delayed allocations | 1826 | * New allocation is contiguous with delayed allocations |
1846 | * on the left and on the right. | 1827 | * on the left and on the right. |
1847 | * Merge all three into a single extent list entry. | 1828 | * Merge all three into a single extent record. |
1848 | */ | 1829 | */ |
1849 | temp = left.br_blockcount + new->br_blockcount + | 1830 | temp = left.br_blockcount + new->br_blockcount + |
1850 | right.br_blockcount; | 1831 | right.br_blockcount; |
1851 | xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1, | 1832 | xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1, |
1852 | XFS_DATA_FORK); | 1833 | XFS_DATA_FORK); |
1853 | xfs_bmbt_set_blockcount(ep - 1, temp); | 1834 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); |
1854 | oldlen = STARTBLOCKVAL(left.br_startblock) + | 1835 | oldlen = STARTBLOCKVAL(left.br_startblock) + |
1855 | STARTBLOCKVAL(new->br_startblock) + | 1836 | STARTBLOCKVAL(new->br_startblock) + |
1856 | STARTBLOCKVAL(right.br_startblock); | 1837 | STARTBLOCKVAL(right.br_startblock); |
1857 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1838 | newlen = xfs_bmap_worst_indlen(ip, temp); |
1858 | xfs_bmbt_set_startblock(ep - 1, NULLSTARTBLOCK((int)newlen)); | 1839 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), |
1840 | NULLSTARTBLOCK((int)newlen)); | ||
1859 | xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1, | 1841 | xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1, |
1860 | XFS_DATA_FORK); | 1842 | XFS_DATA_FORK); |
1861 | xfs_bmap_trace_delete(fname, "LC|RC", ip, idx, 1, | 1843 | xfs_bmap_trace_delete(fname, "LC|RC", ip, idx, 1, |
1862 | XFS_DATA_FORK); | 1844 | XFS_DATA_FORK); |
1863 | xfs_bmap_delete_exlist(ip, idx, 1, XFS_DATA_FORK); | 1845 | xfs_iext_remove(ifp, idx, 1); |
1864 | ip->i_df.if_lastex = idx - 1; | 1846 | ip->i_df.if_lastex = idx - 1; |
1865 | break; | 1847 | break; |
1866 | 1848 | ||
@@ -1873,11 +1855,12 @@ xfs_bmap_add_extent_hole_delay( | |||
1873 | temp = left.br_blockcount + new->br_blockcount; | 1855 | temp = left.br_blockcount + new->br_blockcount; |
1874 | xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, | 1856 | xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, |
1875 | XFS_DATA_FORK); | 1857 | XFS_DATA_FORK); |
1876 | xfs_bmbt_set_blockcount(ep - 1, temp); | 1858 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); |
1877 | oldlen = STARTBLOCKVAL(left.br_startblock) + | 1859 | oldlen = STARTBLOCKVAL(left.br_startblock) + |
1878 | STARTBLOCKVAL(new->br_startblock); | 1860 | STARTBLOCKVAL(new->br_startblock); |
1879 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1861 | newlen = xfs_bmap_worst_indlen(ip, temp); |
1880 | xfs_bmbt_set_startblock(ep - 1, NULLSTARTBLOCK((int)newlen)); | 1862 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), |
1863 | NULLSTARTBLOCK((int)newlen)); | ||
1881 | xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, | 1864 | xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, |
1882 | XFS_DATA_FORK); | 1865 | XFS_DATA_FORK); |
1883 | ip->i_df.if_lastex = idx - 1; | 1866 | ip->i_df.if_lastex = idx - 1; |
@@ -1909,7 +1892,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1909 | oldlen = newlen = 0; | 1892 | oldlen = newlen = 0; |
1910 | xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL, | 1893 | xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL, |
1911 | XFS_DATA_FORK); | 1894 | XFS_DATA_FORK); |
1912 | xfs_bmap_insert_exlist(ip, idx, 1, new, XFS_DATA_FORK); | 1895 | xfs_iext_insert(ifp, idx, 1, new); |
1913 | ip->i_df.if_lastex = idx; | 1896 | ip->i_df.if_lastex = idx; |
1914 | break; | 1897 | break; |
1915 | } | 1898 | } |
@@ -1940,7 +1923,7 @@ xfs_bmap_add_extent_hole_real( | |||
1940 | xfs_inode_t *ip, /* incore inode pointer */ | 1923 | xfs_inode_t *ip, /* incore inode pointer */ |
1941 | xfs_extnum_t idx, /* extent number to update/insert */ | 1924 | xfs_extnum_t idx, /* extent number to update/insert */ |
1942 | xfs_btree_cur_t *cur, /* if null, not a btree */ | 1925 | xfs_btree_cur_t *cur, /* if null, not a btree */ |
1943 | xfs_bmbt_irec_t *new, /* new data to put in extent list */ | 1926 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ |
1944 | int *logflagsp, /* inode logging flags */ | 1927 | int *logflagsp, /* inode logging flags */ |
1945 | int whichfork) /* data or attr fork */ | 1928 | int whichfork) /* data or attr fork */ |
1946 | { | 1929 | { |
@@ -1970,13 +1953,13 @@ xfs_bmap_add_extent_hole_real( | |||
1970 | 1953 | ||
1971 | ifp = XFS_IFORK_PTR(ip, whichfork); | 1954 | ifp = XFS_IFORK_PTR(ip, whichfork); |
1972 | ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); | 1955 | ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); |
1973 | ep = &ifp->if_u1.if_extents[idx]; | 1956 | ep = xfs_iext_get_ext(ifp, idx); |
1974 | state = 0; | 1957 | state = 0; |
1975 | /* | 1958 | /* |
1976 | * Check and set flags if this segment has a left neighbor. | 1959 | * Check and set flags if this segment has a left neighbor. |
1977 | */ | 1960 | */ |
1978 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1961 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { |
1979 | xfs_bmbt_get_all(ep - 1, &left); | 1962 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); |
1980 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock)); | 1963 | STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock)); |
1981 | } | 1964 | } |
1982 | /* | 1965 | /* |
@@ -2019,18 +2002,18 @@ xfs_bmap_add_extent_hole_real( | |||
2019 | /* | 2002 | /* |
2020 | * New allocation is contiguous with real allocations on the | 2003 | * New allocation is contiguous with real allocations on the |
2021 | * left and on the right. | 2004 | * left and on the right. |
2022 | * Merge all three into a single extent list entry. | 2005 | * Merge all three into a single extent record. |
2023 | */ | 2006 | */ |
2024 | xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1, | 2007 | xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1, |
2025 | whichfork); | 2008 | whichfork); |
2026 | xfs_bmbt_set_blockcount(ep - 1, | 2009 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
2027 | left.br_blockcount + new->br_blockcount + | 2010 | left.br_blockcount + new->br_blockcount + |
2028 | right.br_blockcount); | 2011 | right.br_blockcount); |
2029 | xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1, | 2012 | xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1, |
2030 | whichfork); | 2013 | whichfork); |
2031 | xfs_bmap_trace_delete(fname, "LC|RC", ip, | 2014 | xfs_bmap_trace_delete(fname, "LC|RC", ip, |
2032 | idx, 1, whichfork); | 2015 | idx, 1, whichfork); |
2033 | xfs_bmap_delete_exlist(ip, idx, 1, whichfork); | 2016 | xfs_iext_remove(ifp, idx, 1); |
2034 | ifp->if_lastex = idx - 1; | 2017 | ifp->if_lastex = idx - 1; |
2035 | XFS_IFORK_NEXT_SET(ip, whichfork, | 2018 | XFS_IFORK_NEXT_SET(ip, whichfork, |
2036 | XFS_IFORK_NEXTENTS(ip, whichfork) - 1); | 2019 | XFS_IFORK_NEXTENTS(ip, whichfork) - 1); |
@@ -2062,7 +2045,7 @@ xfs_bmap_add_extent_hole_real( | |||
2062 | * Merge the new allocation with the left neighbor. | 2045 | * Merge the new allocation with the left neighbor. |
2063 | */ | 2046 | */ |
2064 | xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, whichfork); | 2047 | xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, whichfork); |
2065 | xfs_bmbt_set_blockcount(ep - 1, | 2048 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
2066 | left.br_blockcount + new->br_blockcount); | 2049 | left.br_blockcount + new->br_blockcount); |
2067 | xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, whichfork); | 2050 | xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, whichfork); |
2068 | ifp->if_lastex = idx - 1; | 2051 | ifp->if_lastex = idx - 1; |
@@ -2116,7 +2099,7 @@ xfs_bmap_add_extent_hole_real( | |||
2116 | */ | 2099 | */ |
2117 | xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL, | 2100 | xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL, |
2118 | whichfork); | 2101 | whichfork); |
2119 | xfs_bmap_insert_exlist(ip, idx, 1, new, whichfork); | 2102 | xfs_iext_insert(ifp, idx, 1, new); |
2120 | ifp->if_lastex = idx; | 2103 | ifp->if_lastex = idx; |
2121 | XFS_IFORK_NEXT_SET(ip, whichfork, | 2104 | XFS_IFORK_NEXT_SET(ip, whichfork, |
2122 | XFS_IFORK_NEXTENTS(ip, whichfork) + 1); | 2105 | XFS_IFORK_NEXTENTS(ip, whichfork) + 1); |
@@ -2311,25 +2294,15 @@ xfs_bmap_extsize_align( | |||
2311 | 2294 | ||
2312 | #define XFS_ALLOC_GAP_UNITS 4 | 2295 | #define XFS_ALLOC_GAP_UNITS 4 |
2313 | 2296 | ||
2314 | /* | ||
2315 | * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file. | ||
2316 | * It figures out where to ask the underlying allocator to put the new extent. | ||
2317 | */ | ||
2318 | STATIC int | 2297 | STATIC int |
2319 | xfs_bmap_alloc( | 2298 | xfs_bmap_adjacent( |
2320 | xfs_bmalloca_t *ap) /* bmap alloc argument struct */ | 2299 | xfs_bmalloca_t *ap) /* bmap alloc argument struct */ |
2321 | { | 2300 | { |
2322 | xfs_fsblock_t adjust; /* adjustment to block numbers */ | 2301 | xfs_fsblock_t adjust; /* adjustment to block numbers */ |
2323 | xfs_alloctype_t atype=0; /* type for allocation routines */ | ||
2324 | int error; /* error return value */ | ||
2325 | xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */ | 2302 | xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */ |
2326 | xfs_mount_t *mp; /* mount point structure */ | 2303 | xfs_mount_t *mp; /* mount point structure */ |
2327 | int nullfb; /* true if ap->firstblock isn't set */ | 2304 | int nullfb; /* true if ap->firstblock isn't set */ |
2328 | int rt; /* true if inode is realtime */ | 2305 | int rt; /* true if inode is realtime */ |
2329 | xfs_extlen_t prod = 0; /* product factor for allocators */ | ||
2330 | xfs_extlen_t ralen = 0; /* realtime allocation length */ | ||
2331 | xfs_extlen_t align; /* minimum allocation alignment */ | ||
2332 | xfs_rtblock_t rtx; | ||
2333 | 2306 | ||
2334 | #define ISVALID(x,y) \ | 2307 | #define ISVALID(x,y) \ |
2335 | (rt ? \ | 2308 | (rt ? \ |
@@ -2338,75 +2311,10 @@ xfs_bmap_alloc( | |||
2338 | XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount && \ | 2311 | XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount && \ |
2339 | XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks) | 2312 | XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks) |
2340 | 2313 | ||
2341 | /* | ||
2342 | * Set up variables. | ||
2343 | */ | ||
2344 | mp = ap->ip->i_mount; | 2314 | mp = ap->ip->i_mount; |
2345 | nullfb = ap->firstblock == NULLFSBLOCK; | 2315 | nullfb = ap->firstblock == NULLFSBLOCK; |
2346 | rt = XFS_IS_REALTIME_INODE(ap->ip) && ap->userdata; | 2316 | rt = XFS_IS_REALTIME_INODE(ap->ip) && ap->userdata; |
2347 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock); | 2317 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock); |
2348 | if (rt) { | ||
2349 | align = ap->ip->i_d.di_extsize ? | ||
2350 | ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize; | ||
2351 | /* Set prod to match the extent size */ | ||
2352 | prod = align / mp->m_sb.sb_rextsize; | ||
2353 | |||
2354 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | ||
2355 | align, rt, ap->eof, 0, | ||
2356 | ap->conv, &ap->off, &ap->alen); | ||
2357 | if (error) | ||
2358 | return error; | ||
2359 | ASSERT(ap->alen); | ||
2360 | ASSERT(ap->alen % mp->m_sb.sb_rextsize == 0); | ||
2361 | |||
2362 | /* | ||
2363 | * If the offset & length are not perfectly aligned | ||
2364 | * then kill prod, it will just get us in trouble. | ||
2365 | */ | ||
2366 | if (do_mod(ap->off, align) || ap->alen % align) | ||
2367 | prod = 1; | ||
2368 | /* | ||
2369 | * Set ralen to be the actual requested length in rtextents. | ||
2370 | */ | ||
2371 | ralen = ap->alen / mp->m_sb.sb_rextsize; | ||
2372 | /* | ||
2373 | * If the old value was close enough to MAXEXTLEN that | ||
2374 | * we rounded up to it, cut it back so it's valid again. | ||
2375 | * Note that if it's a really large request (bigger than | ||
2376 | * MAXEXTLEN), we don't hear about that number, and can't | ||
2377 | * adjust the starting point to match it. | ||
2378 | */ | ||
2379 | if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN) | ||
2380 | ralen = MAXEXTLEN / mp->m_sb.sb_rextsize; | ||
2381 | /* | ||
2382 | * If it's an allocation to an empty file at offset 0, | ||
2383 | * pick an extent that will space things out in the rt area. | ||
2384 | */ | ||
2385 | if (ap->eof && ap->off == 0) { | ||
2386 | error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); | ||
2387 | if (error) | ||
2388 | return error; | ||
2389 | ap->rval = rtx * mp->m_sb.sb_rextsize; | ||
2390 | } else | ||
2391 | ap->rval = 0; | ||
2392 | } else { | ||
2393 | align = (ap->userdata && ap->ip->i_d.di_extsize && | ||
2394 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ? | ||
2395 | ap->ip->i_d.di_extsize : 0; | ||
2396 | if (unlikely(align)) { | ||
2397 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | ||
2398 | align, rt, | ||
2399 | ap->eof, 0, ap->conv, | ||
2400 | &ap->off, &ap->alen); | ||
2401 | ASSERT(!error); | ||
2402 | ASSERT(ap->alen); | ||
2403 | } | ||
2404 | if (nullfb) | ||
2405 | ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino); | ||
2406 | else | ||
2407 | ap->rval = ap->firstblock; | ||
2408 | } | ||
2409 | |||
2410 | /* | 2318 | /* |
2411 | * If allocating at eof, and there's a previous real block, | 2319 | * If allocating at eof, and there's a previous real block, |
2412 | * try to use it's last block as our starting point. | 2320 | * try to use it's last block as our starting point. |
@@ -2531,287 +2439,384 @@ xfs_bmap_alloc( | |||
2531 | else if (gotbno != NULLFSBLOCK) | 2439 | else if (gotbno != NULLFSBLOCK) |
2532 | ap->rval = gotbno; | 2440 | ap->rval = gotbno; |
2533 | } | 2441 | } |
2442 | #undef ISVALID | ||
2443 | return 0; | ||
2444 | } | ||
2445 | |||
2446 | STATIC int | ||
2447 | xfs_bmap_rtalloc( | ||
2448 | xfs_bmalloca_t *ap) /* bmap alloc argument struct */ | ||
2449 | { | ||
2450 | xfs_alloctype_t atype = 0; /* type for allocation routines */ | ||
2451 | int error; /* error return value */ | ||
2452 | xfs_mount_t *mp; /* mount point structure */ | ||
2453 | xfs_extlen_t prod = 0; /* product factor for allocators */ | ||
2454 | xfs_extlen_t ralen = 0; /* realtime allocation length */ | ||
2455 | xfs_extlen_t align; /* minimum allocation alignment */ | ||
2456 | xfs_rtblock_t rtx; /* realtime extent number */ | ||
2457 | xfs_rtblock_t rtb; | ||
2458 | |||
2459 | mp = ap->ip->i_mount; | ||
2460 | align = ap->ip->i_d.di_extsize ? | ||
2461 | ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize; | ||
2462 | prod = align / mp->m_sb.sb_rextsize; | ||
2463 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | ||
2464 | align, 1, ap->eof, 0, | ||
2465 | ap->conv, &ap->off, &ap->alen); | ||
2466 | if (error) | ||
2467 | return error; | ||
2468 | ASSERT(ap->alen); | ||
2469 | ASSERT(ap->alen % mp->m_sb.sb_rextsize == 0); | ||
2470 | |||
2471 | /* | ||
2472 | * If the offset & length are not perfectly aligned | ||
2473 | * then kill prod, it will just get us in trouble. | ||
2474 | */ | ||
2475 | if (do_mod(ap->off, align) || ap->alen % align) | ||
2476 | prod = 1; | ||
2477 | /* | ||
2478 | * Set ralen to be the actual requested length in rtextents. | ||
2479 | */ | ||
2480 | ralen = ap->alen / mp->m_sb.sb_rextsize; | ||
2481 | /* | ||
2482 | * If the old value was close enough to MAXEXTLEN that | ||
2483 | * we rounded up to it, cut it back so it's valid again. | ||
2484 | * Note that if it's a really large request (bigger than | ||
2485 | * MAXEXTLEN), we don't hear about that number, and can't | ||
2486 | * adjust the starting point to match it. | ||
2487 | */ | ||
2488 | if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN) | ||
2489 | ralen = MAXEXTLEN / mp->m_sb.sb_rextsize; | ||
2490 | /* | ||
2491 | * If it's an allocation to an empty file at offset 0, | ||
2492 | * pick an extent that will space things out in the rt area. | ||
2493 | */ | ||
2494 | if (ap->eof && ap->off == 0) { | ||
2495 | error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); | ||
2496 | if (error) | ||
2497 | return error; | ||
2498 | ap->rval = rtx * mp->m_sb.sb_rextsize; | ||
2499 | } else { | ||
2500 | ap->rval = 0; | ||
2501 | } | ||
2502 | |||
2503 | xfs_bmap_adjacent(ap); | ||
2504 | |||
2505 | /* | ||
2506 | * Realtime allocation, done through xfs_rtallocate_extent. | ||
2507 | */ | ||
2508 | atype = ap->rval == 0 ? XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO; | ||
2509 | do_div(ap->rval, mp->m_sb.sb_rextsize); | ||
2510 | rtb = ap->rval; | ||
2511 | ap->alen = ralen; | ||
2512 | if ((error = xfs_rtallocate_extent(ap->tp, ap->rval, 1, ap->alen, | ||
2513 | &ralen, atype, ap->wasdel, prod, &rtb))) | ||
2514 | return error; | ||
2515 | if (rtb == NULLFSBLOCK && prod > 1 && | ||
2516 | (error = xfs_rtallocate_extent(ap->tp, ap->rval, 1, | ||
2517 | ap->alen, &ralen, atype, | ||
2518 | ap->wasdel, 1, &rtb))) | ||
2519 | return error; | ||
2520 | ap->rval = rtb; | ||
2521 | if (ap->rval != NULLFSBLOCK) { | ||
2522 | ap->rval *= mp->m_sb.sb_rextsize; | ||
2523 | ralen *= mp->m_sb.sb_rextsize; | ||
2524 | ap->alen = ralen; | ||
2525 | ap->ip->i_d.di_nblocks += ralen; | ||
2526 | xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); | ||
2527 | if (ap->wasdel) | ||
2528 | ap->ip->i_delayed_blks -= ralen; | ||
2529 | /* | ||
2530 | * Adjust the disk quota also. This was reserved | ||
2531 | * earlier. | ||
2532 | */ | ||
2533 | XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, | ||
2534 | ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : | ||
2535 | XFS_TRANS_DQ_RTBCOUNT, (long) ralen); | ||
2536 | } else { | ||
2537 | ap->alen = 0; | ||
2538 | } | ||
2539 | return 0; | ||
2540 | } | ||
2541 | |||
2542 | STATIC int | ||
2543 | xfs_bmap_btalloc( | ||
2544 | xfs_bmalloca_t *ap) /* bmap alloc argument struct */ | ||
2545 | { | ||
2546 | xfs_mount_t *mp; /* mount point structure */ | ||
2547 | xfs_alloctype_t atype = 0; /* type for allocation routines */ | ||
2548 | xfs_extlen_t align; /* minimum allocation alignment */ | ||
2549 | xfs_agnumber_t ag; | ||
2550 | xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */ | ||
2551 | xfs_agnumber_t startag; | ||
2552 | xfs_alloc_arg_t args; | ||
2553 | xfs_extlen_t blen; | ||
2554 | xfs_extlen_t delta; | ||
2555 | xfs_extlen_t longest; | ||
2556 | xfs_extlen_t need; | ||
2557 | xfs_extlen_t nextminlen = 0; | ||
2558 | xfs_perag_t *pag; | ||
2559 | int nullfb; /* true if ap->firstblock isn't set */ | ||
2560 | int isaligned; | ||
2561 | int notinit; | ||
2562 | int tryagain; | ||
2563 | int error; | ||
2564 | |||
2565 | mp = ap->ip->i_mount; | ||
2566 | align = (ap->userdata && ap->ip->i_d.di_extsize && | ||
2567 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ? | ||
2568 | ap->ip->i_d.di_extsize : 0; | ||
2569 | if (unlikely(align)) { | ||
2570 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | ||
2571 | align, 0, ap->eof, 0, ap->conv, | ||
2572 | &ap->off, &ap->alen); | ||
2573 | ASSERT(!error); | ||
2574 | ASSERT(ap->alen); | ||
2575 | } | ||
2576 | nullfb = ap->firstblock == NULLFSBLOCK; | ||
2577 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock); | ||
2578 | if (nullfb) | ||
2579 | ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino); | ||
2580 | else | ||
2581 | ap->rval = ap->firstblock; | ||
2582 | |||
2583 | xfs_bmap_adjacent(ap); | ||
2584 | |||
2534 | /* | 2585 | /* |
2535 | * If allowed, use ap->rval; otherwise must use firstblock since | 2586 | * If allowed, use ap->rval; otherwise must use firstblock since |
2536 | * it's in the right allocation group. | 2587 | * it's in the right allocation group. |
2537 | */ | 2588 | */ |
2538 | if (nullfb || rt || XFS_FSB_TO_AGNO(mp, ap->rval) == fb_agno) | 2589 | if (nullfb || XFS_FSB_TO_AGNO(mp, ap->rval) == fb_agno) |
2539 | ; | 2590 | ; |
2540 | else | 2591 | else |
2541 | ap->rval = ap->firstblock; | 2592 | ap->rval = ap->firstblock; |
2542 | /* | 2593 | /* |
2543 | * Realtime allocation, done through xfs_rtallocate_extent. | 2594 | * Normal allocation, done through xfs_alloc_vextent. |
2544 | */ | 2595 | */ |
2545 | if (rt) { | 2596 | tryagain = isaligned = 0; |
2546 | #ifndef __KERNEL__ | 2597 | args.tp = ap->tp; |
2547 | ASSERT(0); | 2598 | args.mp = mp; |
2548 | #else | 2599 | args.fsbno = ap->rval; |
2549 | xfs_rtblock_t rtb; | 2600 | args.maxlen = MIN(ap->alen, mp->m_sb.sb_agblocks); |
2550 | 2601 | blen = 0; | |
2551 | atype = ap->rval == 0 ? | 2602 | if (nullfb) { |
2552 | XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO; | 2603 | args.type = XFS_ALLOCTYPE_START_BNO; |
2553 | do_div(ap->rval, mp->m_sb.sb_rextsize); | 2604 | args.total = ap->total; |
2554 | rtb = ap->rval; | 2605 | /* |
2555 | ap->alen = ralen; | 2606 | * Find the longest available space. |
2556 | if ((error = xfs_rtallocate_extent(ap->tp, ap->rval, 1, ap->alen, | 2607 | * We're going to try for the whole allocation at once. |
2557 | &ralen, atype, ap->wasdel, prod, &rtb))) | 2608 | */ |
2558 | return error; | 2609 | startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno); |
2559 | if (rtb == NULLFSBLOCK && prod > 1 && | 2610 | notinit = 0; |
2560 | (error = xfs_rtallocate_extent(ap->tp, ap->rval, 1, | 2611 | down_read(&mp->m_peraglock); |
2561 | ap->alen, &ralen, atype, | 2612 | while (blen < ap->alen) { |
2562 | ap->wasdel, 1, &rtb))) | 2613 | pag = &mp->m_perag[ag]; |
2563 | return error; | 2614 | if (!pag->pagf_init && |
2564 | ap->rval = rtb; | 2615 | (error = xfs_alloc_pagf_init(mp, args.tp, |
2565 | if (ap->rval != NULLFSBLOCK) { | 2616 | ag, XFS_ALLOC_FLAG_TRYLOCK))) { |
2566 | ap->rval *= mp->m_sb.sb_rextsize; | 2617 | up_read(&mp->m_peraglock); |
2567 | ralen *= mp->m_sb.sb_rextsize; | 2618 | return error; |
2568 | ap->alen = ralen; | 2619 | } |
2569 | ap->ip->i_d.di_nblocks += ralen; | ||
2570 | xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); | ||
2571 | if (ap->wasdel) | ||
2572 | ap->ip->i_delayed_blks -= ralen; | ||
2573 | /* | 2620 | /* |
2574 | * Adjust the disk quota also. This was reserved | 2621 | * See xfs_alloc_fix_freelist... |
2575 | * earlier. | ||
2576 | */ | 2622 | */ |
2577 | XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, | 2623 | if (pag->pagf_init) { |
2578 | ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : | 2624 | need = XFS_MIN_FREELIST_PAG(pag, mp); |
2579 | XFS_TRANS_DQ_RTBCOUNT, | 2625 | delta = need > pag->pagf_flcount ? |
2580 | (long) ralen); | 2626 | need - pag->pagf_flcount : 0; |
2581 | } else | 2627 | longest = (pag->pagf_longest > delta) ? |
2582 | ap->alen = 0; | 2628 | (pag->pagf_longest - delta) : |
2583 | #endif /* __KERNEL__ */ | 2629 | (pag->pagf_flcount > 0 || |
2630 | pag->pagf_longest > 0); | ||
2631 | if (blen < longest) | ||
2632 | blen = longest; | ||
2633 | } else | ||
2634 | notinit = 1; | ||
2635 | if (++ag == mp->m_sb.sb_agcount) | ||
2636 | ag = 0; | ||
2637 | if (ag == startag) | ||
2638 | break; | ||
2639 | } | ||
2640 | up_read(&mp->m_peraglock); | ||
2641 | /* | ||
2642 | * Since the above loop did a BUF_TRYLOCK, it is | ||
2643 | * possible that there is space for this request. | ||
2644 | */ | ||
2645 | if (notinit || blen < ap->minlen) | ||
2646 | args.minlen = ap->minlen; | ||
2647 | /* | ||
2648 | * If the best seen length is less than the request | ||
2649 | * length, use the best as the minimum. | ||
2650 | */ | ||
2651 | else if (blen < ap->alen) | ||
2652 | args.minlen = blen; | ||
2653 | /* | ||
2654 | * Otherwise we've seen an extent as big as alen, | ||
2655 | * use that as the minimum. | ||
2656 | */ | ||
2657 | else | ||
2658 | args.minlen = ap->alen; | ||
2659 | } else if (ap->low) { | ||
2660 | args.type = XFS_ALLOCTYPE_FIRST_AG; | ||
2661 | args.total = args.minlen = ap->minlen; | ||
2662 | } else { | ||
2663 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | ||
2664 | args.total = ap->total; | ||
2665 | args.minlen = ap->minlen; | ||
2666 | } | ||
2667 | if (unlikely(ap->userdata && ap->ip->i_d.di_extsize && | ||
2668 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) { | ||
2669 | args.prod = ap->ip->i_d.di_extsize; | ||
2670 | if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) | ||
2671 | args.mod = (xfs_extlen_t)(args.prod - args.mod); | ||
2672 | } else if (unlikely(mp->m_sb.sb_blocksize >= NBPP)) { | ||
2673 | args.prod = 1; | ||
2674 | args.mod = 0; | ||
2675 | } else { | ||
2676 | args.prod = NBPP >> mp->m_sb.sb_blocklog; | ||
2677 | if ((args.mod = (xfs_extlen_t)(do_mod(ap->off, args.prod)))) | ||
2678 | args.mod = (xfs_extlen_t)(args.prod - args.mod); | ||
2584 | } | 2679 | } |
2585 | /* | 2680 | /* |
2586 | * Normal allocation, done through xfs_alloc_vextent. | 2681 | * If we are not low on available data blocks, and the |
2682 | * underlying logical volume manager is a stripe, and | ||
2683 | * the file offset is zero then try to allocate data | ||
2684 | * blocks on stripe unit boundary. | ||
2685 | * NOTE: ap->aeof is only set if the allocation length | ||
2686 | * is >= the stripe unit and the allocation offset is | ||
2687 | * at the end of file. | ||
2587 | */ | 2688 | */ |
2588 | else { | 2689 | if (!ap->low && ap->aeof) { |
2589 | xfs_agnumber_t ag; | 2690 | if (!ap->off) { |
2590 | xfs_alloc_arg_t args; | 2691 | args.alignment = mp->m_dalign; |
2591 | xfs_extlen_t blen; | 2692 | atype = args.type; |
2592 | xfs_extlen_t delta; | 2693 | isaligned = 1; |
2593 | int isaligned; | ||
2594 | xfs_extlen_t longest; | ||
2595 | xfs_extlen_t need; | ||
2596 | xfs_extlen_t nextminlen=0; | ||
2597 | int notinit; | ||
2598 | xfs_perag_t *pag; | ||
2599 | xfs_agnumber_t startag; | ||
2600 | int tryagain; | ||
2601 | |||
2602 | tryagain = isaligned = 0; | ||
2603 | args.tp = ap->tp; | ||
2604 | args.mp = mp; | ||
2605 | args.fsbno = ap->rval; | ||
2606 | args.maxlen = MIN(ap->alen, mp->m_sb.sb_agblocks); | ||
2607 | blen = 0; | ||
2608 | if (nullfb) { | ||
2609 | args.type = XFS_ALLOCTYPE_START_BNO; | ||
2610 | args.total = ap->total; | ||
2611 | /* | ||
2612 | * Find the longest available space. | ||
2613 | * We're going to try for the whole allocation at once. | ||
2614 | */ | ||
2615 | startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno); | ||
2616 | notinit = 0; | ||
2617 | down_read(&mp->m_peraglock); | ||
2618 | while (blen < ap->alen) { | ||
2619 | pag = &mp->m_perag[ag]; | ||
2620 | if (!pag->pagf_init && | ||
2621 | (error = xfs_alloc_pagf_init(mp, args.tp, | ||
2622 | ag, XFS_ALLOC_FLAG_TRYLOCK))) { | ||
2623 | up_read(&mp->m_peraglock); | ||
2624 | return error; | ||
2625 | } | ||
2626 | /* | ||
2627 | * See xfs_alloc_fix_freelist... | ||
2628 | */ | ||
2629 | if (pag->pagf_init) { | ||
2630 | need = XFS_MIN_FREELIST_PAG(pag, mp); | ||
2631 | delta = need > pag->pagf_flcount ? | ||
2632 | need - pag->pagf_flcount : 0; | ||
2633 | longest = (pag->pagf_longest > delta) ? | ||
2634 | (pag->pagf_longest - delta) : | ||
2635 | (pag->pagf_flcount > 0 || | ||
2636 | pag->pagf_longest > 0); | ||
2637 | if (blen < longest) | ||
2638 | blen = longest; | ||
2639 | } else | ||
2640 | notinit = 1; | ||
2641 | if (++ag == mp->m_sb.sb_agcount) | ||
2642 | ag = 0; | ||
2643 | if (ag == startag) | ||
2644 | break; | ||
2645 | } | ||
2646 | up_read(&mp->m_peraglock); | ||
2647 | /* | 2694 | /* |
2648 | * Since the above loop did a BUF_TRYLOCK, it is | 2695 | * Adjust for alignment |
2649 | * possible that there is space for this request. | ||
2650 | */ | 2696 | */ |
2651 | if (notinit || blen < ap->minlen) | 2697 | if (blen > args.alignment && blen <= ap->alen) |
2652 | args.minlen = ap->minlen; | 2698 | args.minlen = blen - args.alignment; |
2699 | args.minalignslop = 0; | ||
2700 | } else { | ||
2653 | /* | 2701 | /* |
2654 | * If the best seen length is less than the request | 2702 | * First try an exact bno allocation. |
2655 | * length, use the best as the minimum. | 2703 | * If it fails then do a near or start bno |
2704 | * allocation with alignment turned on. | ||
2656 | */ | 2705 | */ |
2657 | else if (blen < ap->alen) | 2706 | atype = args.type; |
2658 | args.minlen = blen; | 2707 | tryagain = 1; |
2708 | args.type = XFS_ALLOCTYPE_THIS_BNO; | ||
2709 | args.alignment = 1; | ||
2659 | /* | 2710 | /* |
2660 | * Otherwise we've seen an extent as big as alen, | 2711 | * Compute the minlen+alignment for the |
2661 | * use that as the minimum. | 2712 | * next case. Set slop so that the value |
2713 | * of minlen+alignment+slop doesn't go up | ||
2714 | * between the calls. | ||
2662 | */ | 2715 | */ |
2716 | if (blen > mp->m_dalign && blen <= ap->alen) | ||
2717 | nextminlen = blen - mp->m_dalign; | ||
2663 | else | 2718 | else |
2664 | args.minlen = ap->alen; | 2719 | nextminlen = args.minlen; |
2665 | } else if (ap->low) { | 2720 | if (nextminlen + mp->m_dalign > args.minlen + 1) |
2666 | args.type = XFS_ALLOCTYPE_FIRST_AG; | 2721 | args.minalignslop = |
2667 | args.total = args.minlen = ap->minlen; | 2722 | nextminlen + mp->m_dalign - |
2668 | } else { | 2723 | args.minlen - 1; |
2669 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 2724 | else |
2670 | args.total = ap->total; | 2725 | args.minalignslop = 0; |
2671 | args.minlen = ap->minlen; | ||
2672 | } | ||
2673 | if (unlikely(ap->userdata && ap->ip->i_d.di_extsize && | ||
2674 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) { | ||
2675 | args.prod = ap->ip->i_d.di_extsize; | ||
2676 | if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) | ||
2677 | args.mod = (xfs_extlen_t)(args.prod - args.mod); | ||
2678 | } else if (unlikely(mp->m_sb.sb_blocksize >= NBPP)) { | ||
2679 | args.prod = 1; | ||
2680 | args.mod = 0; | ||
2681 | } else { | ||
2682 | args.prod = NBPP >> mp->m_sb.sb_blocklog; | ||
2683 | if ((args.mod = (xfs_extlen_t)(do_mod(ap->off, args.prod)))) | ||
2684 | args.mod = (xfs_extlen_t)(args.prod - args.mod); | ||
2685 | } | 2726 | } |
2727 | } else { | ||
2728 | args.alignment = 1; | ||
2729 | args.minalignslop = 0; | ||
2730 | } | ||
2731 | args.minleft = ap->minleft; | ||
2732 | args.wasdel = ap->wasdel; | ||
2733 | args.isfl = 0; | ||
2734 | args.userdata = ap->userdata; | ||
2735 | if ((error = xfs_alloc_vextent(&args))) | ||
2736 | return error; | ||
2737 | if (tryagain && args.fsbno == NULLFSBLOCK) { | ||
2686 | /* | 2738 | /* |
2687 | * If we are not low on available data blocks, and the | 2739 | * Exact allocation failed. Now try with alignment |
2688 | * underlying logical volume manager is a stripe, and | 2740 | * turned on. |
2689 | * the file offset is zero then try to allocate data | ||
2690 | * blocks on stripe unit boundary. | ||
2691 | * NOTE: ap->aeof is only set if the allocation length | ||
2692 | * is >= the stripe unit and the allocation offset is | ||
2693 | * at the end of file. | ||
2694 | */ | 2741 | */ |
2695 | if (!ap->low && ap->aeof) { | 2742 | args.type = atype; |
2696 | if (!ap->off) { | 2743 | args.fsbno = ap->rval; |
2697 | args.alignment = mp->m_dalign; | 2744 | args.alignment = mp->m_dalign; |
2698 | atype = args.type; | 2745 | args.minlen = nextminlen; |
2699 | isaligned = 1; | 2746 | args.minalignslop = 0; |
2700 | /* | 2747 | isaligned = 1; |
2701 | * Adjust for alignment | 2748 | if ((error = xfs_alloc_vextent(&args))) |
2702 | */ | 2749 | return error; |
2703 | if (blen > args.alignment && blen <= ap->alen) | 2750 | } |
2704 | args.minlen = blen - args.alignment; | 2751 | if (isaligned && args.fsbno == NULLFSBLOCK) { |
2705 | args.minalignslop = 0; | 2752 | /* |
2706 | } else { | 2753 | * allocation failed, so turn off alignment and |
2707 | /* | 2754 | * try again. |
2708 | * First try an exact bno allocation. | 2755 | */ |
2709 | * If it fails then do a near or start bno | 2756 | args.type = atype; |
2710 | * allocation with alignment turned on. | 2757 | args.fsbno = ap->rval; |
2711 | */ | 2758 | args.alignment = 0; |
2712 | atype = args.type; | 2759 | if ((error = xfs_alloc_vextent(&args))) |
2713 | tryagain = 1; | 2760 | return error; |
2714 | args.type = XFS_ALLOCTYPE_THIS_BNO; | 2761 | } |
2715 | args.alignment = 1; | 2762 | if (args.fsbno == NULLFSBLOCK && nullfb && |
2716 | /* | 2763 | args.minlen > ap->minlen) { |
2717 | * Compute the minlen+alignment for the | 2764 | args.minlen = ap->minlen; |
2718 | * next case. Set slop so that the value | 2765 | args.type = XFS_ALLOCTYPE_START_BNO; |
2719 | * of minlen+alignment+slop doesn't go up | 2766 | args.fsbno = ap->rval; |
2720 | * between the calls. | ||
2721 | */ | ||
2722 | if (blen > mp->m_dalign && blen <= ap->alen) | ||
2723 | nextminlen = blen - mp->m_dalign; | ||
2724 | else | ||
2725 | nextminlen = args.minlen; | ||
2726 | if (nextminlen + mp->m_dalign > args.minlen + 1) | ||
2727 | args.minalignslop = | ||
2728 | nextminlen + mp->m_dalign - | ||
2729 | args.minlen - 1; | ||
2730 | else | ||
2731 | args.minalignslop = 0; | ||
2732 | } | ||
2733 | } else { | ||
2734 | args.alignment = 1; | ||
2735 | args.minalignslop = 0; | ||
2736 | } | ||
2737 | args.minleft = ap->minleft; | ||
2738 | args.wasdel = ap->wasdel; | ||
2739 | args.isfl = 0; | ||
2740 | args.userdata = ap->userdata; | ||
2741 | if ((error = xfs_alloc_vextent(&args))) | 2767 | if ((error = xfs_alloc_vextent(&args))) |
2742 | return error; | 2768 | return error; |
2743 | if (tryagain && args.fsbno == NULLFSBLOCK) { | 2769 | } |
2744 | /* | 2770 | if (args.fsbno == NULLFSBLOCK && nullfb) { |
2745 | * Exact allocation failed. Now try with alignment | 2771 | args.fsbno = 0; |
2746 | * turned on. | 2772 | args.type = XFS_ALLOCTYPE_FIRST_AG; |
2747 | */ | 2773 | args.total = ap->minlen; |
2748 | args.type = atype; | 2774 | args.minleft = 0; |
2749 | args.fsbno = ap->rval; | 2775 | if ((error = xfs_alloc_vextent(&args))) |
2750 | args.alignment = mp->m_dalign; | 2776 | return error; |
2751 | args.minlen = nextminlen; | 2777 | ap->low = 1; |
2752 | args.minalignslop = 0; | 2778 | } |
2753 | isaligned = 1; | 2779 | if (args.fsbno != NULLFSBLOCK) { |
2754 | if ((error = xfs_alloc_vextent(&args))) | 2780 | ap->firstblock = ap->rval = args.fsbno; |
2755 | return error; | 2781 | ASSERT(nullfb || fb_agno == args.agno || |
2756 | } | 2782 | (ap->low && fb_agno < args.agno)); |
2757 | if (isaligned && args.fsbno == NULLFSBLOCK) { | 2783 | ap->alen = args.len; |
2758 | /* | 2784 | ap->ip->i_d.di_nblocks += args.len; |
2759 | * allocation failed, so turn off alignment and | 2785 | xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); |
2760 | * try again. | 2786 | if (ap->wasdel) |
2761 | */ | 2787 | ap->ip->i_delayed_blks -= args.len; |
2762 | args.type = atype; | 2788 | /* |
2763 | args.fsbno = ap->rval; | 2789 | * Adjust the disk quota also. This was reserved |
2764 | args.alignment = 0; | 2790 | * earlier. |
2765 | if ((error = xfs_alloc_vextent(&args))) | 2791 | */ |
2766 | return error; | 2792 | XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, |
2767 | } | 2793 | ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : |
2768 | if (args.fsbno == NULLFSBLOCK && nullfb && | 2794 | XFS_TRANS_DQ_BCOUNT, |
2769 | args.minlen > ap->minlen) { | 2795 | (long) args.len); |
2770 | args.minlen = ap->minlen; | 2796 | } else { |
2771 | args.type = XFS_ALLOCTYPE_START_BNO; | 2797 | ap->rval = NULLFSBLOCK; |
2772 | args.fsbno = ap->rval; | 2798 | ap->alen = 0; |
2773 | if ((error = xfs_alloc_vextent(&args))) | ||
2774 | return error; | ||
2775 | } | ||
2776 | if (args.fsbno == NULLFSBLOCK && nullfb) { | ||
2777 | args.fsbno = 0; | ||
2778 | args.type = XFS_ALLOCTYPE_FIRST_AG; | ||
2779 | args.total = ap->minlen; | ||
2780 | args.minleft = 0; | ||
2781 | if ((error = xfs_alloc_vextent(&args))) | ||
2782 | return error; | ||
2783 | ap->low = 1; | ||
2784 | } | ||
2785 | if (args.fsbno != NULLFSBLOCK) { | ||
2786 | ap->firstblock = ap->rval = args.fsbno; | ||
2787 | ASSERT(nullfb || fb_agno == args.agno || | ||
2788 | (ap->low && fb_agno < args.agno)); | ||
2789 | ap->alen = args.len; | ||
2790 | ap->ip->i_d.di_nblocks += args.len; | ||
2791 | xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); | ||
2792 | if (ap->wasdel) | ||
2793 | ap->ip->i_delayed_blks -= args.len; | ||
2794 | /* | ||
2795 | * Adjust the disk quota also. This was reserved | ||
2796 | * earlier. | ||
2797 | */ | ||
2798 | XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, | ||
2799 | ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : | ||
2800 | XFS_TRANS_DQ_BCOUNT, | ||
2801 | (long) args.len); | ||
2802 | } else { | ||
2803 | ap->rval = NULLFSBLOCK; | ||
2804 | ap->alen = 0; | ||
2805 | } | ||
2806 | } | 2799 | } |
2807 | return 0; | 2800 | return 0; |
2808 | #undef ISVALID | 2801 | } |
2802 | |||
2803 | /* | ||
2804 | * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file. | ||
2805 | * It figures out where to ask the underlying allocator to put the new extent. | ||
2806 | */ | ||
2807 | STATIC int | ||
2808 | xfs_bmap_alloc( | ||
2809 | xfs_bmalloca_t *ap) /* bmap alloc argument struct */ | ||
2810 | { | ||
2811 | if ((ap->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && ap->userdata) | ||
2812 | return xfs_bmap_rtalloc(ap); | ||
2813 | return xfs_bmap_btalloc(ap); | ||
2809 | } | 2814 | } |
2810 | 2815 | ||
2811 | /* | 2816 | /* |
2812 | * Transform a btree format file with only one leaf node, where the | 2817 | * Transform a btree format file with only one leaf node, where the |
2813 | * extents list will fit in the inode, into an extents format file. | 2818 | * extents list will fit in the inode, into an extents format file. |
2814 | * Since the extent list is already in-core, all we have to do is | 2819 | * Since the file extents are already in-core, all we have to do is |
2815 | * give up the space for the btree root and pitch the leaf block. | 2820 | * give up the space for the btree root and pitch the leaf block. |
2816 | */ | 2821 | */ |
2817 | STATIC int /* error */ | 2822 | STATIC int /* error */ |
@@ -2868,7 +2873,7 @@ xfs_bmap_btree_to_extents( | |||
2868 | } | 2873 | } |
2869 | 2874 | ||
2870 | /* | 2875 | /* |
2871 | * Called by xfs_bmapi to update extent list structure and the btree | 2876 | * Called by xfs_bmapi to update file extent records and the btree |
2872 | * after removing space (or undoing a delayed allocation). | 2877 | * after removing space (or undoing a delayed allocation). |
2873 | */ | 2878 | */ |
2874 | STATIC int /* error */ | 2879 | STATIC int /* error */ |
@@ -2878,7 +2883,7 @@ xfs_bmap_del_extent( | |||
2878 | xfs_extnum_t idx, /* extent number to update/delete */ | 2883 | xfs_extnum_t idx, /* extent number to update/delete */ |
2879 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | 2884 | xfs_bmap_free_t *flist, /* list of extents to be freed */ |
2880 | xfs_btree_cur_t *cur, /* if null, not a btree */ | 2885 | xfs_btree_cur_t *cur, /* if null, not a btree */ |
2881 | xfs_bmbt_irec_t *del, /* data to remove from extent list */ | 2886 | xfs_bmbt_irec_t *del, /* data to remove from extents */ |
2882 | int *logflagsp, /* inode logging flags */ | 2887 | int *logflagsp, /* inode logging flags */ |
2883 | int whichfork, /* data or attr fork */ | 2888 | int whichfork, /* data or attr fork */ |
2884 | int rsvd) /* OK to allocate reserved blocks */ | 2889 | int rsvd) /* OK to allocate reserved blocks */ |
@@ -2903,7 +2908,6 @@ xfs_bmap_del_extent( | |||
2903 | xfs_filblks_t nblks; /* quota/sb block count */ | 2908 | xfs_filblks_t nblks; /* quota/sb block count */ |
2904 | xfs_bmbt_irec_t new; /* new record to be inserted */ | 2909 | xfs_bmbt_irec_t new; /* new record to be inserted */ |
2905 | /* REFERENCED */ | 2910 | /* REFERENCED */ |
2906 | xfs_extnum_t nextents; /* number of extents in list */ | ||
2907 | uint qfield; /* quota field to update */ | 2911 | uint qfield; /* quota field to update */ |
2908 | xfs_filblks_t temp; /* for indirect length calculations */ | 2912 | xfs_filblks_t temp; /* for indirect length calculations */ |
2909 | xfs_filblks_t temp2; /* for indirect length calculations */ | 2913 | xfs_filblks_t temp2; /* for indirect length calculations */ |
@@ -2911,10 +2915,10 @@ xfs_bmap_del_extent( | |||
2911 | XFS_STATS_INC(xs_del_exlist); | 2915 | XFS_STATS_INC(xs_del_exlist); |
2912 | mp = ip->i_mount; | 2916 | mp = ip->i_mount; |
2913 | ifp = XFS_IFORK_PTR(ip, whichfork); | 2917 | ifp = XFS_IFORK_PTR(ip, whichfork); |
2914 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 2918 | ASSERT((idx >= 0) && (idx < ifp->if_bytes / |
2915 | ASSERT(idx >= 0 && idx < nextents); | 2919 | (uint)sizeof(xfs_bmbt_rec_t))); |
2916 | ASSERT(del->br_blockcount > 0); | 2920 | ASSERT(del->br_blockcount > 0); |
2917 | ep = &ifp->if_u1.if_extents[idx]; | 2921 | ep = xfs_iext_get_ext(ifp, idx); |
2918 | xfs_bmbt_get_all(ep, &got); | 2922 | xfs_bmbt_get_all(ep, &got); |
2919 | ASSERT(got.br_startoff <= del->br_startoff); | 2923 | ASSERT(got.br_startoff <= del->br_startoff); |
2920 | del_endoff = del->br_startoff + del->br_blockcount; | 2924 | del_endoff = del->br_startoff + del->br_blockcount; |
@@ -2990,7 +2994,7 @@ xfs_bmap_del_extent( | |||
2990 | * Matches the whole extent. Delete the entry. | 2994 | * Matches the whole extent. Delete the entry. |
2991 | */ | 2995 | */ |
2992 | xfs_bmap_trace_delete(fname, "3", ip, idx, 1, whichfork); | 2996 | xfs_bmap_trace_delete(fname, "3", ip, idx, 1, whichfork); |
2993 | xfs_bmap_delete_exlist(ip, idx, 1, whichfork); | 2997 | xfs_iext_remove(ifp, idx, 1); |
2994 | ifp->if_lastex = idx; | 2998 | ifp->if_lastex = idx; |
2995 | if (delay) | 2999 | if (delay) |
2996 | break; | 3000 | break; |
@@ -3160,7 +3164,7 @@ xfs_bmap_del_extent( | |||
3160 | xfs_bmap_trace_post_update(fname, "0", ip, idx, whichfork); | 3164 | xfs_bmap_trace_post_update(fname, "0", ip, idx, whichfork); |
3161 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 1, &new, NULL, | 3165 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 1, &new, NULL, |
3162 | whichfork); | 3166 | whichfork); |
3163 | xfs_bmap_insert_exlist(ip, idx + 1, 1, &new, whichfork); | 3167 | xfs_iext_insert(ifp, idx + 1, 1, &new); |
3164 | ifp->if_lastex = idx + 1; | 3168 | ifp->if_lastex = idx + 1; |
3165 | break; | 3169 | break; |
3166 | } | 3170 | } |
@@ -3213,31 +3217,6 @@ xfs_bmap_del_free( | |||
3213 | } | 3217 | } |
3214 | 3218 | ||
3215 | /* | 3219 | /* |
3216 | * Remove count entries from the extents array for inode "ip", starting | ||
3217 | * at index "idx". Copies the remaining items down over the deleted ones, | ||
3218 | * and gives back the excess memory. | ||
3219 | */ | ||
3220 | STATIC void | ||
3221 | xfs_bmap_delete_exlist( | ||
3222 | xfs_inode_t *ip, /* incore inode pointer */ | ||
3223 | xfs_extnum_t idx, /* starting delete index */ | ||
3224 | xfs_extnum_t count, /* count of items to delete */ | ||
3225 | int whichfork) /* data or attr fork */ | ||
3226 | { | ||
3227 | xfs_bmbt_rec_t *base; /* base of extent list */ | ||
3228 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
3229 | xfs_extnum_t nextents; /* number of extents in list after */ | ||
3230 | |||
3231 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
3232 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | ||
3233 | base = ifp->if_u1.if_extents; | ||
3234 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - count; | ||
3235 | memmove(&base[idx], &base[idx + count], | ||
3236 | (nextents - idx) * sizeof(*base)); | ||
3237 | xfs_iext_realloc(ip, -count, whichfork); | ||
3238 | } | ||
3239 | |||
3240 | /* | ||
3241 | * Convert an extents-format file into a btree-format file. | 3220 | * Convert an extents-format file into a btree-format file. |
3242 | * The new file will have a root block (in the inode) and a single child block. | 3221 | * The new file will have a root block (in the inode) and a single child block. |
3243 | */ | 3222 | */ |
@@ -3258,13 +3237,13 @@ xfs_bmap_extents_to_btree( | |||
3258 | xfs_bmbt_rec_t *arp; /* child record pointer */ | 3237 | xfs_bmbt_rec_t *arp; /* child record pointer */ |
3259 | xfs_bmbt_block_t *block; /* btree root block */ | 3238 | xfs_bmbt_block_t *block; /* btree root block */ |
3260 | xfs_btree_cur_t *cur; /* bmap btree cursor */ | 3239 | xfs_btree_cur_t *cur; /* bmap btree cursor */ |
3261 | xfs_bmbt_rec_t *ep; /* extent list pointer */ | 3240 | xfs_bmbt_rec_t *ep; /* extent record pointer */ |
3262 | int error; /* error return value */ | 3241 | int error; /* error return value */ |
3263 | xfs_extnum_t i, cnt; /* extent list index */ | 3242 | xfs_extnum_t i, cnt; /* extent record index */ |
3264 | xfs_ifork_t *ifp; /* inode fork pointer */ | 3243 | xfs_ifork_t *ifp; /* inode fork pointer */ |
3265 | xfs_bmbt_key_t *kp; /* root block key pointer */ | 3244 | xfs_bmbt_key_t *kp; /* root block key pointer */ |
3266 | xfs_mount_t *mp; /* mount structure */ | 3245 | xfs_mount_t *mp; /* mount structure */ |
3267 | xfs_extnum_t nextents; /* extent list size */ | 3246 | xfs_extnum_t nextents; /* number of file extents */ |
3268 | xfs_bmbt_ptr_t *pp; /* root block address pointer */ | 3247 | xfs_bmbt_ptr_t *pp; /* root block address pointer */ |
3269 | 3248 | ||
3270 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3249 | ifp = XFS_IFORK_PTR(ip, whichfork); |
@@ -3343,7 +3322,8 @@ xfs_bmap_extents_to_btree( | |||
3343 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 3322 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3344 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); | 3323 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); |
3345 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 3324 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
3346 | for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) { | 3325 | for (cnt = i = 0; i < nextents; i++) { |
3326 | ep = xfs_iext_get_ext(ifp, i); | ||
3347 | if (!ISNULLSTARTBLOCK(xfs_bmbt_get_startblock(ep))) { | 3327 | if (!ISNULLSTARTBLOCK(xfs_bmbt_get_startblock(ep))) { |
3348 | arp->l0 = INT_GET(ep->l0, ARCH_CONVERT); | 3328 | arp->l0 = INT_GET(ep->l0, ARCH_CONVERT); |
3349 | arp->l1 = INT_GET(ep->l1, ARCH_CONVERT); | 3329 | arp->l1 = INT_GET(ep->l1, ARCH_CONVERT); |
@@ -3373,34 +3353,6 @@ xfs_bmap_extents_to_btree( | |||
3373 | } | 3353 | } |
3374 | 3354 | ||
3375 | /* | 3355 | /* |
3376 | * Insert new item(s) in the extent list for inode "ip". | ||
3377 | * Count new items are inserted at offset idx. | ||
3378 | */ | ||
3379 | STATIC void | ||
3380 | xfs_bmap_insert_exlist( | ||
3381 | xfs_inode_t *ip, /* incore inode pointer */ | ||
3382 | xfs_extnum_t idx, /* starting index of new items */ | ||
3383 | xfs_extnum_t count, /* number of inserted items */ | ||
3384 | xfs_bmbt_irec_t *new, /* items to insert */ | ||
3385 | int whichfork) /* data or attr fork */ | ||
3386 | { | ||
3387 | xfs_bmbt_rec_t *base; /* extent list base */ | ||
3388 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
3389 | xfs_extnum_t nextents; /* extent list size */ | ||
3390 | xfs_extnum_t to; /* extent list index */ | ||
3391 | |||
3392 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
3393 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | ||
3394 | xfs_iext_realloc(ip, count, whichfork); | ||
3395 | base = ifp->if_u1.if_extents; | ||
3396 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
3397 | memmove(&base[idx + count], &base[idx], | ||
3398 | (nextents - (idx + count)) * sizeof(*base)); | ||
3399 | for (to = idx; to < idx + count; to++, new++) | ||
3400 | xfs_bmbt_set_all(&base[to], new); | ||
3401 | } | ||
3402 | |||
3403 | /* | ||
3404 | * Helper routine to reset inode di_forkoff field when switching | 3356 | * Helper routine to reset inode di_forkoff field when switching |
3405 | * attribute fork from local to extent format - we reset it where | 3357 | * attribute fork from local to extent format - we reset it where |
3406 | * possible to make space available for inline data fork extents. | 3358 | * possible to make space available for inline data fork extents. |
@@ -3457,12 +3409,13 @@ xfs_bmap_local_to_extents( | |||
3457 | error = 0; | 3409 | error = 0; |
3458 | if (ifp->if_bytes) { | 3410 | if (ifp->if_bytes) { |
3459 | xfs_alloc_arg_t args; /* allocation arguments */ | 3411 | xfs_alloc_arg_t args; /* allocation arguments */ |
3460 | xfs_buf_t *bp; /* buffer for extent list block */ | 3412 | xfs_buf_t *bp; /* buffer for extent block */ |
3461 | xfs_bmbt_rec_t *ep; /* extent list pointer */ | 3413 | xfs_bmbt_rec_t *ep; /* extent record pointer */ |
3462 | 3414 | ||
3463 | args.tp = tp; | 3415 | args.tp = tp; |
3464 | args.mp = ip->i_mount; | 3416 | args.mp = ip->i_mount; |
3465 | ASSERT(ifp->if_flags & XFS_IFINLINE); | 3417 | ASSERT((ifp->if_flags & |
3418 | (XFS_IFINLINE|XFS_IFEXTENTS|XFS_IFEXTIREC)) == XFS_IFINLINE); | ||
3466 | /* | 3419 | /* |
3467 | * Allocate a block. We know we need only one, since the | 3420 | * Allocate a block. We know we need only one, since the |
3468 | * file currently fits in an inode. | 3421 | * file currently fits in an inode. |
@@ -3492,8 +3445,8 @@ xfs_bmap_local_to_extents( | |||
3492 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); | 3445 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); |
3493 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); | 3446 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); |
3494 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); | 3447 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); |
3495 | xfs_iext_realloc(ip, 1, whichfork); | 3448 | xfs_iext_add(ifp, 0, 1); |
3496 | ep = ifp->if_u1.if_extents; | 3449 | ep = xfs_iext_get_ext(ifp, 0); |
3497 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); | 3450 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); |
3498 | xfs_bmap_trace_post_update(fname, "new", ip, 0, whichfork); | 3451 | xfs_bmap_trace_post_update(fname, "new", ip, 0, whichfork); |
3499 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); | 3452 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); |
@@ -3518,7 +3471,7 @@ xfs_bmbt_rec_t * /* pointer to found extent entry */ | |||
3518 | xfs_bmap_do_search_extents( | 3471 | xfs_bmap_do_search_extents( |
3519 | xfs_bmbt_rec_t *base, /* base of extent list */ | 3472 | xfs_bmbt_rec_t *base, /* base of extent list */ |
3520 | xfs_extnum_t lastx, /* last extent index used */ | 3473 | xfs_extnum_t lastx, /* last extent index used */ |
3521 | xfs_extnum_t nextents, /* extent list size */ | 3474 | xfs_extnum_t nextents, /* number of file extents */ |
3522 | xfs_fileoff_t bno, /* block number searched for */ | 3475 | xfs_fileoff_t bno, /* block number searched for */ |
3523 | int *eofp, /* out: end of file found */ | 3476 | int *eofp, /* out: end of file found */ |
3524 | xfs_extnum_t *lastxp, /* out: last extent index */ | 3477 | xfs_extnum_t *lastxp, /* out: last extent index */ |
@@ -3569,9 +3522,9 @@ xfs_bmap_do_search_extents( | |||
3569 | got.br_blockcount = xfs_bmbt_get_blockcount(ep); | 3522 | got.br_blockcount = xfs_bmbt_get_blockcount(ep); |
3570 | *eofp = 0; | 3523 | *eofp = 0; |
3571 | } else { | 3524 | } else { |
3572 | /* binary search the extents array */ | ||
3573 | low = 0; | 3525 | low = 0; |
3574 | high = nextents - 1; | 3526 | high = nextents - 1; |
3527 | /* binary search the extents array */ | ||
3575 | while (low <= high) { | 3528 | while (low <= high) { |
3576 | XFS_STATS_INC(xs_cmp_exlist); | 3529 | XFS_STATS_INC(xs_cmp_exlist); |
3577 | lastx = (low + high) >> 1; | 3530 | lastx = (low + high) >> 1; |
@@ -3622,6 +3575,57 @@ xfs_bmap_do_search_extents( | |||
3622 | } | 3575 | } |
3623 | 3576 | ||
3624 | /* | 3577 | /* |
3578 | * Search the extent records for the entry containing block bno. | ||
3579 | * If bno lies in a hole, point to the next entry. If bno lies | ||
3580 | * past eof, *eofp will be set, and *prevp will contain the last | ||
3581 | * entry (null if none). Else, *lastxp will be set to the index | ||
3582 | * of the found entry; *gotp will contain the entry. | ||
3583 | */ | ||
3584 | xfs_bmbt_rec_t * /* pointer to found extent entry */ | ||
3585 | xfs_bmap_search_multi_extents( | ||
3586 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3587 | xfs_fileoff_t bno, /* block number searched for */ | ||
3588 | int *eofp, /* out: end of file found */ | ||
3589 | xfs_extnum_t *lastxp, /* out: last extent index */ | ||
3590 | xfs_bmbt_irec_t *gotp, /* out: extent entry found */ | ||
3591 | xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */ | ||
3592 | { | ||
3593 | xfs_bmbt_rec_t *ep; /* extent record pointer */ | ||
3594 | xfs_extnum_t lastx; /* last extent index */ | ||
3595 | |||
3596 | /* | ||
3597 | * Initialize the extent entry structure to catch access to | ||
3598 | * uninitialized br_startblock field. | ||
3599 | */ | ||
3600 | gotp->br_startoff = 0xffa5a5a5a5a5a5a5LL; | ||
3601 | gotp->br_blockcount = 0xa55a5a5a5a5a5a5aLL; | ||
3602 | gotp->br_state = XFS_EXT_INVALID; | ||
3603 | #if XFS_BIG_BLKNOS | ||
3604 | gotp->br_startblock = 0xffffa5a5a5a5a5a5LL; | ||
3605 | #else | ||
3606 | gotp->br_startblock = 0xffffa5a5; | ||
3607 | #endif | ||
3608 | prevp->br_startoff = NULLFILEOFF; | ||
3609 | |||
3610 | ep = xfs_iext_bno_to_ext(ifp, bno, &lastx); | ||
3611 | if (lastx > 0) { | ||
3612 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx - 1), prevp); | ||
3613 | } | ||
3614 | if (lastx < (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { | ||
3615 | xfs_bmbt_get_all(ep, gotp); | ||
3616 | *eofp = 0; | ||
3617 | } else { | ||
3618 | if (lastx > 0) { | ||
3619 | *gotp = *prevp; | ||
3620 | } | ||
3621 | *eofp = 1; | ||
3622 | ep = NULL; | ||
3623 | } | ||
3624 | *lastxp = lastx; | ||
3625 | return ep; | ||
3626 | } | ||
3627 | |||
3628 | /* | ||
3625 | * Search the extents list for the inode, for the extent containing bno. | 3629 | * Search the extents list for the inode, for the extent containing bno. |
3626 | * If bno lies in a hole, point to the next entry. If bno lies past eof, | 3630 | * If bno lies in a hole, point to the next entry. If bno lies past eof, |
3627 | * *eofp will be set, and *prevp will contain the last entry (null if none). | 3631 | * *eofp will be set, and *prevp will contain the last entry (null if none). |
@@ -3639,20 +3643,14 @@ xfs_bmap_search_extents( | |||
3639 | xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */ | 3643 | xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */ |
3640 | { | 3644 | { |
3641 | xfs_ifork_t *ifp; /* inode fork pointer */ | 3645 | xfs_ifork_t *ifp; /* inode fork pointer */ |
3642 | xfs_bmbt_rec_t *base; /* base of extent list */ | 3646 | xfs_bmbt_rec_t *ep; /* extent record pointer */ |
3643 | xfs_extnum_t lastx; /* last extent index used */ | ||
3644 | xfs_extnum_t nextents; /* extent list size */ | ||
3645 | xfs_bmbt_rec_t *ep; /* extent list entry pointer */ | ||
3646 | int rt; /* realtime flag */ | 3647 | int rt; /* realtime flag */ |
3647 | 3648 | ||
3648 | XFS_STATS_INC(xs_look_exlist); | 3649 | XFS_STATS_INC(xs_look_exlist); |
3649 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3650 | ifp = XFS_IFORK_PTR(ip, whichfork); |
3650 | lastx = ifp->if_lastex; | ||
3651 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
3652 | base = &ifp->if_u1.if_extents[0]; | ||
3653 | 3651 | ||
3654 | ep = xfs_bmap_do_search_extents(base, lastx, nextents, bno, eofp, | 3652 | ep = xfs_bmap_search_multi_extents(ifp, bno, eofp, lastxp, gotp, prevp); |
3655 | lastxp, gotp, prevp); | 3653 | |
3656 | rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); | 3654 | rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); |
3657 | if (unlikely(!rt && !gotp->br_startblock && (*lastxp != NULLEXTNUM))) { | 3655 | if (unlikely(!rt && !gotp->br_startblock && (*lastxp != NULLEXTNUM))) { |
3658 | cmn_err(CE_PANIC,"Access to block zero: fs: <%s> inode: %lld " | 3656 | cmn_err(CE_PANIC,"Access to block zero: fs: <%s> inode: %lld " |
@@ -3732,7 +3730,7 @@ xfs_bmap_trace_addentry( | |||
3732 | } | 3730 | } |
3733 | 3731 | ||
3734 | /* | 3732 | /* |
3735 | * Add bmap trace entry prior to a call to xfs_bmap_delete_exlist. | 3733 | * Add bmap trace entry prior to a call to xfs_iext_remove. |
3736 | */ | 3734 | */ |
3737 | STATIC void | 3735 | STATIC void |
3738 | xfs_bmap_trace_delete( | 3736 | xfs_bmap_trace_delete( |
@@ -3747,13 +3745,13 @@ xfs_bmap_trace_delete( | |||
3747 | 3745 | ||
3748 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3746 | ifp = XFS_IFORK_PTR(ip, whichfork); |
3749 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_DELETE, fname, desc, ip, idx, | 3747 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_DELETE, fname, desc, ip, idx, |
3750 | cnt, &ifp->if_u1.if_extents[idx], | 3748 | cnt, xfs_iext_get_ext(ifp, idx), |
3751 | cnt == 2 ? &ifp->if_u1.if_extents[idx + 1] : NULL, | 3749 | cnt == 2 ? xfs_iext_get_ext(ifp, idx + 1) : NULL, |
3752 | whichfork); | 3750 | whichfork); |
3753 | } | 3751 | } |
3754 | 3752 | ||
3755 | /* | 3753 | /* |
3756 | * Add bmap trace entry prior to a call to xfs_bmap_insert_exlist, or | 3754 | * Add bmap trace entry prior to a call to xfs_iext_insert, or |
3757 | * reading in the extents list from the disk (in the btree). | 3755 | * reading in the extents list from the disk (in the btree). |
3758 | */ | 3756 | */ |
3759 | STATIC void | 3757 | STATIC void |
@@ -3783,7 +3781,7 @@ xfs_bmap_trace_insert( | |||
3783 | } | 3781 | } |
3784 | 3782 | ||
3785 | /* | 3783 | /* |
3786 | * Add bmap trace entry after updating an extent list entry in place. | 3784 | * Add bmap trace entry after updating an extent record in place. |
3787 | */ | 3785 | */ |
3788 | STATIC void | 3786 | STATIC void |
3789 | xfs_bmap_trace_post_update( | 3787 | xfs_bmap_trace_post_update( |
@@ -3797,11 +3795,11 @@ xfs_bmap_trace_post_update( | |||
3797 | 3795 | ||
3798 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3796 | ifp = XFS_IFORK_PTR(ip, whichfork); |
3799 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_POST_UP, fname, desc, ip, idx, | 3797 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_POST_UP, fname, desc, ip, idx, |
3800 | 1, &ifp->if_u1.if_extents[idx], NULL, whichfork); | 3798 | 1, xfs_iext_get_ext(ifp, idx), NULL, whichfork); |
3801 | } | 3799 | } |
3802 | 3800 | ||
3803 | /* | 3801 | /* |
3804 | * Add bmap trace entry prior to updating an extent list entry in place. | 3802 | * Add bmap trace entry prior to updating an extent record in place. |
3805 | */ | 3803 | */ |
3806 | STATIC void | 3804 | STATIC void |
3807 | xfs_bmap_trace_pre_update( | 3805 | xfs_bmap_trace_pre_update( |
@@ -3815,7 +3813,7 @@ xfs_bmap_trace_pre_update( | |||
3815 | 3813 | ||
3816 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3814 | ifp = XFS_IFORK_PTR(ip, whichfork); |
3817 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_PRE_UP, fname, desc, ip, idx, 1, | 3815 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_PRE_UP, fname, desc, ip, idx, 1, |
3818 | &ifp->if_u1.if_extents[idx], NULL, whichfork); | 3816 | xfs_iext_get_ext(ifp, idx), NULL, whichfork); |
3819 | } | 3817 | } |
3820 | #endif /* XFS_BMAP_TRACE */ | 3818 | #endif /* XFS_BMAP_TRACE */ |
3821 | 3819 | ||
@@ -3892,7 +3890,7 @@ xfs_bmap_add_attrfork( | |||
3892 | int rsvd) /* xact may use reserved blks */ | 3890 | int rsvd) /* xact may use reserved blks */ |
3893 | { | 3891 | { |
3894 | xfs_fsblock_t firstblock; /* 1st block/ag allocated */ | 3892 | xfs_fsblock_t firstblock; /* 1st block/ag allocated */ |
3895 | xfs_bmap_free_t flist; /* freed extent list */ | 3893 | xfs_bmap_free_t flist; /* freed extent records */ |
3896 | xfs_mount_t *mp; /* mount structure */ | 3894 | xfs_mount_t *mp; /* mount structure */ |
3897 | xfs_trans_t *tp; /* transaction pointer */ | 3895 | xfs_trans_t *tp; /* transaction pointer */ |
3898 | unsigned long s; /* spinlock spl value */ | 3896 | unsigned long s; /* spinlock spl value */ |
@@ -4146,7 +4144,7 @@ xfs_bmap_finish( | |||
4146 | xfs_efd_log_item_t *efd; /* extent free data */ | 4144 | xfs_efd_log_item_t *efd; /* extent free data */ |
4147 | xfs_efi_log_item_t *efi; /* extent free intention */ | 4145 | xfs_efi_log_item_t *efi; /* extent free intention */ |
4148 | int error; /* error return value */ | 4146 | int error; /* error return value */ |
4149 | xfs_bmap_free_item_t *free; /* free extent list item */ | 4147 | xfs_bmap_free_item_t *free; /* free extent item */ |
4150 | unsigned int logres; /* new log reservation */ | 4148 | unsigned int logres; /* new log reservation */ |
4151 | unsigned int logcount; /* new log count */ | 4149 | unsigned int logcount; /* new log count */ |
4152 | xfs_mount_t *mp; /* filesystem mount structure */ | 4150 | xfs_mount_t *mp; /* filesystem mount structure */ |
@@ -4242,9 +4240,9 @@ xfs_bmap_first_unused( | |||
4242 | xfs_fileoff_t *first_unused, /* unused block */ | 4240 | xfs_fileoff_t *first_unused, /* unused block */ |
4243 | int whichfork) /* data or attr fork */ | 4241 | int whichfork) /* data or attr fork */ |
4244 | { | 4242 | { |
4245 | xfs_bmbt_rec_t *base; /* base of extent array */ | ||
4246 | xfs_bmbt_rec_t *ep; /* pointer to an extent entry */ | 4243 | xfs_bmbt_rec_t *ep; /* pointer to an extent entry */ |
4247 | int error; /* error return value */ | 4244 | int error; /* error return value */ |
4245 | int idx; /* extent record index */ | ||
4248 | xfs_ifork_t *ifp; /* inode fork pointer */ | 4246 | xfs_ifork_t *ifp; /* inode fork pointer */ |
4249 | xfs_fileoff_t lastaddr; /* last block number seen */ | 4247 | xfs_fileoff_t lastaddr; /* last block number seen */ |
4250 | xfs_fileoff_t lowest; /* lowest useful block */ | 4248 | xfs_fileoff_t lowest; /* lowest useful block */ |
@@ -4265,10 +4263,8 @@ xfs_bmap_first_unused( | |||
4265 | return error; | 4263 | return error; |
4266 | lowest = *first_unused; | 4264 | lowest = *first_unused; |
4267 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 4265 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
4268 | base = &ifp->if_u1.if_extents[0]; | 4266 | for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) { |
4269 | for (lastaddr = 0, max = lowest, ep = base; | 4267 | ep = xfs_iext_get_ext(ifp, idx); |
4270 | ep < &base[nextents]; | ||
4271 | ep++) { | ||
4272 | off = xfs_bmbt_get_startoff(ep); | 4268 | off = xfs_bmbt_get_startoff(ep); |
4273 | /* | 4269 | /* |
4274 | * See if the hole before this extent will work. | 4270 | * See if the hole before this extent will work. |
@@ -4287,8 +4283,8 @@ xfs_bmap_first_unused( | |||
4287 | /* | 4283 | /* |
4288 | * Returns the file-relative block number of the last block + 1 before | 4284 | * Returns the file-relative block number of the last block + 1 before |
4289 | * last_block (input value) in the file. | 4285 | * last_block (input value) in the file. |
4290 | * This is not based on i_size, it is based on the extent list. | 4286 | * This is not based on i_size, it is based on the extent records. |
4291 | * Returns 0 for local files, as they do not have an extent list. | 4287 | * Returns 0 for local files, as they do not have extent records. |
4292 | */ | 4288 | */ |
4293 | int /* error */ | 4289 | int /* error */ |
4294 | xfs_bmap_last_before( | 4290 | xfs_bmap_last_before( |
@@ -4335,8 +4331,8 @@ xfs_bmap_last_before( | |||
4335 | 4331 | ||
4336 | /* | 4332 | /* |
4337 | * Returns the file-relative block number of the first block past eof in | 4333 | * Returns the file-relative block number of the first block past eof in |
4338 | * the file. This is not based on i_size, it is based on the extent list. | 4334 | * the file. This is not based on i_size, it is based on the extent records. |
4339 | * Returns 0 for local files, as they do not have an extent list. | 4335 | * Returns 0 for local files, as they do not have extent records. |
4340 | */ | 4336 | */ |
4341 | int /* error */ | 4337 | int /* error */ |
4342 | xfs_bmap_last_offset( | 4338 | xfs_bmap_last_offset( |
@@ -4345,7 +4341,6 @@ xfs_bmap_last_offset( | |||
4345 | xfs_fileoff_t *last_block, /* last block */ | 4341 | xfs_fileoff_t *last_block, /* last block */ |
4346 | int whichfork) /* data or attr fork */ | 4342 | int whichfork) /* data or attr fork */ |
4347 | { | 4343 | { |
4348 | xfs_bmbt_rec_t *base; /* base of extent array */ | ||
4349 | xfs_bmbt_rec_t *ep; /* pointer to last extent */ | 4344 | xfs_bmbt_rec_t *ep; /* pointer to last extent */ |
4350 | int error; /* error return value */ | 4345 | int error; /* error return value */ |
4351 | xfs_ifork_t *ifp; /* inode fork pointer */ | 4346 | xfs_ifork_t *ifp; /* inode fork pointer */ |
@@ -4368,9 +4363,7 @@ xfs_bmap_last_offset( | |||
4368 | *last_block = 0; | 4363 | *last_block = 0; |
4369 | return 0; | 4364 | return 0; |
4370 | } | 4365 | } |
4371 | base = &ifp->if_u1.if_extents[0]; | 4366 | ep = xfs_iext_get_ext(ifp, nextents - 1); |
4372 | ASSERT(base != NULL); | ||
4373 | ep = &base[nextents - 1]; | ||
4374 | *last_block = xfs_bmbt_get_startoff(ep) + xfs_bmbt_get_blockcount(ep); | 4367 | *last_block = xfs_bmbt_get_startoff(ep) + xfs_bmbt_get_blockcount(ep); |
4375 | return 0; | 4368 | return 0; |
4376 | } | 4369 | } |
@@ -4400,7 +4393,7 @@ xfs_bmap_one_block( | |||
4400 | return 0; | 4393 | return 0; |
4401 | ifp = XFS_IFORK_PTR(ip, whichfork); | 4394 | ifp = XFS_IFORK_PTR(ip, whichfork); |
4402 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | 4395 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); |
4403 | ep = ifp->if_u1.if_extents; | 4396 | ep = xfs_iext_get_ext(ifp, 0); |
4404 | xfs_bmbt_get_all(ep, &s); | 4397 | xfs_bmbt_get_all(ep, &s); |
4405 | rval = s.br_startoff == 0 && s.br_blockcount == 1; | 4398 | rval = s.br_startoff == 0 && s.br_blockcount == 1; |
4406 | if (rval && whichfork == XFS_DATA_FORK) | 4399 | if (rval && whichfork == XFS_DATA_FORK) |
@@ -4435,7 +4428,6 @@ xfs_bmap_read_extents( | |||
4435 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 4428 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ |
4436 | /* REFERENCED */ | 4429 | /* REFERENCED */ |
4437 | xfs_extnum_t room; /* number of entries there's room for */ | 4430 | xfs_extnum_t room; /* number of entries there's room for */ |
4438 | xfs_bmbt_rec_t *trp; /* target record pointer */ | ||
4439 | 4431 | ||
4440 | bno = NULLFSBLOCK; | 4432 | bno = NULLFSBLOCK; |
4441 | mp = ip->i_mount; | 4433 | mp = ip->i_mount; |
@@ -4478,16 +4470,16 @@ xfs_bmap_read_extents( | |||
4478 | /* | 4470 | /* |
4479 | * Here with bp and block set to the leftmost leaf node in the tree. | 4471 | * Here with bp and block set to the leftmost leaf node in the tree. |
4480 | */ | 4472 | */ |
4481 | room = ifp->if_bytes / (uint)sizeof(*trp); | 4473 | room = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
4482 | trp = ifp->if_u1.if_extents; | ||
4483 | i = 0; | 4474 | i = 0; |
4484 | /* | 4475 | /* |
4485 | * Loop over all leaf nodes. Copy information to the extent list. | 4476 | * Loop over all leaf nodes. Copy information to the extent records. |
4486 | */ | 4477 | */ |
4487 | for (;;) { | 4478 | for (;;) { |
4488 | xfs_bmbt_rec_t *frp, *temp; | 4479 | xfs_bmbt_rec_t *frp, *trp; |
4489 | xfs_fsblock_t nextbno; | 4480 | xfs_fsblock_t nextbno; |
4490 | xfs_extnum_t num_recs; | 4481 | xfs_extnum_t num_recs; |
4482 | xfs_extnum_t start; | ||
4491 | 4483 | ||
4492 | 4484 | ||
4493 | num_recs = be16_to_cpu(block->bb_numrecs); | 4485 | num_recs = be16_to_cpu(block->bb_numrecs); |
@@ -4511,12 +4503,13 @@ xfs_bmap_read_extents( | |||
4511 | if (nextbno != NULLFSBLOCK) | 4503 | if (nextbno != NULLFSBLOCK) |
4512 | xfs_btree_reada_bufl(mp, nextbno, 1); | 4504 | xfs_btree_reada_bufl(mp, nextbno, 1); |
4513 | /* | 4505 | /* |
4514 | * Copy records into the extent list. | 4506 | * Copy records into the extent records. |
4515 | */ | 4507 | */ |
4516 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, | 4508 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, |
4517 | block, 1, mp->m_bmap_dmxr[0]); | 4509 | block, 1, mp->m_bmap_dmxr[0]); |
4518 | temp = trp; | 4510 | start = i; |
4519 | for (j = 0; j < num_recs; j++, frp++, trp++) { | 4511 | for (j = 0; j < num_recs; j++, i++, frp++) { |
4512 | trp = xfs_iext_get_ext(ifp, i); | ||
4520 | trp->l0 = INT_GET(frp->l0, ARCH_CONVERT); | 4513 | trp->l0 = INT_GET(frp->l0, ARCH_CONVERT); |
4521 | trp->l1 = INT_GET(frp->l1, ARCH_CONVERT); | 4514 | trp->l1 = INT_GET(frp->l1, ARCH_CONVERT); |
4522 | } | 4515 | } |
@@ -4526,14 +4519,14 @@ xfs_bmap_read_extents( | |||
4526 | * any "older" data bmap btree records for a | 4519 | * any "older" data bmap btree records for a |
4527 | * set bit in the "extent flag" position. | 4520 | * set bit in the "extent flag" position. |
4528 | */ | 4521 | */ |
4529 | if (unlikely(xfs_check_nostate_extents(temp, num_recs))) { | 4522 | if (unlikely(xfs_check_nostate_extents(ifp, |
4523 | start, num_recs))) { | ||
4530 | XFS_ERROR_REPORT("xfs_bmap_read_extents(2)", | 4524 | XFS_ERROR_REPORT("xfs_bmap_read_extents(2)", |
4531 | XFS_ERRLEVEL_LOW, | 4525 | XFS_ERRLEVEL_LOW, |
4532 | ip->i_mount); | 4526 | ip->i_mount); |
4533 | goto error0; | 4527 | goto error0; |
4534 | } | 4528 | } |
4535 | } | 4529 | } |
4536 | i += num_recs; | ||
4537 | xfs_trans_brelse(tp, bp); | 4530 | xfs_trans_brelse(tp, bp); |
4538 | bno = nextbno; | 4531 | bno = nextbno; |
4539 | /* | 4532 | /* |
@@ -4546,7 +4539,7 @@ xfs_bmap_read_extents( | |||
4546 | return error; | 4539 | return error; |
4547 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 4540 | block = XFS_BUF_TO_BMBT_BLOCK(bp); |
4548 | } | 4541 | } |
4549 | ASSERT(i == ifp->if_bytes / (uint)sizeof(*trp)); | 4542 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); |
4550 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); | 4543 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); |
4551 | xfs_bmap_trace_exlist(fname, ip, i, whichfork); | 4544 | xfs_bmap_trace_exlist(fname, ip, i, whichfork); |
4552 | return 0; | 4545 | return 0; |
@@ -4557,7 +4550,7 @@ error0: | |||
4557 | 4550 | ||
4558 | #ifdef XFS_BMAP_TRACE | 4551 | #ifdef XFS_BMAP_TRACE |
4559 | /* | 4552 | /* |
4560 | * Add bmap trace insert entries for all the contents of the extent list. | 4553 | * Add bmap trace insert entries for all the contents of the extent records. |
4561 | */ | 4554 | */ |
4562 | void | 4555 | void |
4563 | xfs_bmap_trace_exlist( | 4556 | xfs_bmap_trace_exlist( |
@@ -4566,16 +4559,15 @@ xfs_bmap_trace_exlist( | |||
4566 | xfs_extnum_t cnt, /* count of entries in the list */ | 4559 | xfs_extnum_t cnt, /* count of entries in the list */ |
4567 | int whichfork) /* data or attr fork */ | 4560 | int whichfork) /* data or attr fork */ |
4568 | { | 4561 | { |
4569 | xfs_bmbt_rec_t *base; /* base of extent list */ | 4562 | xfs_bmbt_rec_t *ep; /* current extent record */ |
4570 | xfs_bmbt_rec_t *ep; /* current entry in extent list */ | 4563 | xfs_extnum_t idx; /* extent record index */ |
4571 | xfs_extnum_t idx; /* extent list entry number */ | ||
4572 | xfs_ifork_t *ifp; /* inode fork pointer */ | 4564 | xfs_ifork_t *ifp; /* inode fork pointer */ |
4573 | xfs_bmbt_irec_t s; /* extent list record */ | 4565 | xfs_bmbt_irec_t s; /* file extent record */ |
4574 | 4566 | ||
4575 | ifp = XFS_IFORK_PTR(ip, whichfork); | 4567 | ifp = XFS_IFORK_PTR(ip, whichfork); |
4576 | ASSERT(cnt == ifp->if_bytes / (uint)sizeof(*base)); | 4568 | ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); |
4577 | base = ifp->if_u1.if_extents; | 4569 | for (idx = 0; idx < cnt; idx++) { |
4578 | for (idx = 0, ep = base; idx < cnt; idx++, ep++) { | 4570 | ep = xfs_iext_get_ext(ifp, idx); |
4579 | xfs_bmbt_get_all(ep, &s); | 4571 | xfs_bmbt_get_all(ep, &s); |
4580 | xfs_bmap_trace_insert(fname, "exlist", ip, idx, 1, &s, NULL, | 4572 | xfs_bmap_trace_insert(fname, "exlist", ip, idx, 1, &s, NULL, |
4581 | whichfork); | 4573 | whichfork); |
@@ -4661,14 +4653,10 @@ xfs_bmapi( | |||
4661 | xfs_bmalloca_t bma; /* args for xfs_bmap_alloc */ | 4653 | xfs_bmalloca_t bma; /* args for xfs_bmap_alloc */ |
4662 | xfs_btree_cur_t *cur; /* bmap btree cursor */ | 4654 | xfs_btree_cur_t *cur; /* bmap btree cursor */ |
4663 | xfs_fileoff_t end; /* end of mapped file region */ | 4655 | xfs_fileoff_t end; /* end of mapped file region */ |
4664 | int eof; /* we've hit the end of extent list */ | 4656 | int eof; /* we've hit the end of extents */ |
4665 | char contig; /* allocation must be one extent */ | 4657 | xfs_bmbt_rec_t *ep; /* extent record pointer */ |
4666 | char delay; /* this request is for delayed alloc */ | ||
4667 | char exact; /* don't do all of wasdelayed extent */ | ||
4668 | char convert; /* unwritten extent I/O completion */ | ||
4669 | xfs_bmbt_rec_t *ep; /* extent list entry pointer */ | ||
4670 | int error; /* error return */ | 4658 | int error; /* error return */ |
4671 | xfs_bmbt_irec_t got; /* current extent list record */ | 4659 | xfs_bmbt_irec_t got; /* current file extent record */ |
4672 | xfs_ifork_t *ifp; /* inode fork pointer */ | 4660 | xfs_ifork_t *ifp; /* inode fork pointer */ |
4673 | xfs_extlen_t indlen; /* indirect blocks length */ | 4661 | xfs_extlen_t indlen; /* indirect blocks length */ |
4674 | xfs_extnum_t lastx; /* last useful extent number */ | 4662 | xfs_extnum_t lastx; /* last useful extent number */ |
@@ -4680,17 +4668,13 @@ xfs_bmapi( | |||
4680 | int nallocs; /* number of extents alloc\'d */ | 4668 | int nallocs; /* number of extents alloc\'d */ |
4681 | xfs_extnum_t nextents; /* number of extents in file */ | 4669 | xfs_extnum_t nextents; /* number of extents in file */ |
4682 | xfs_fileoff_t obno; /* old block number (offset) */ | 4670 | xfs_fileoff_t obno; /* old block number (offset) */ |
4683 | xfs_bmbt_irec_t prev; /* previous extent list record */ | 4671 | xfs_bmbt_irec_t prev; /* previous file extent record */ |
4684 | int tmp_logflags; /* temp flags holder */ | 4672 | int tmp_logflags; /* temp flags holder */ |
4685 | int whichfork; /* data or attr fork */ | 4673 | int whichfork; /* data or attr fork */ |
4686 | char inhole; /* current location is hole in file */ | 4674 | char inhole; /* current location is hole in file */ |
4687 | char stateless; /* ignore state flag set */ | ||
4688 | char trim; /* output trimmed to match range */ | ||
4689 | char userdata; /* allocating non-metadata */ | ||
4690 | char wasdelay; /* old extent was delayed */ | 4675 | char wasdelay; /* old extent was delayed */ |
4691 | char wr; /* this is a write request */ | 4676 | char wr; /* this is a write request */ |
4692 | char rt; /* this is a realtime file */ | 4677 | char rt; /* this is a realtime file */ |
4693 | char rsvd; /* OK to allocate reserved blocks */ | ||
4694 | #ifdef DEBUG | 4678 | #ifdef DEBUG |
4695 | xfs_fileoff_t orig_bno; /* original block number value */ | 4679 | xfs_fileoff_t orig_bno; /* original block number value */ |
4696 | int orig_flags; /* original flags arg value */ | 4680 | int orig_flags; /* original flags arg value */ |
@@ -4727,15 +4711,8 @@ xfs_bmapi( | |||
4727 | XFS_STATS_INC(xs_blk_mapw); | 4711 | XFS_STATS_INC(xs_blk_mapw); |
4728 | else | 4712 | else |
4729 | XFS_STATS_INC(xs_blk_mapr); | 4713 | XFS_STATS_INC(xs_blk_mapr); |
4730 | delay = (flags & XFS_BMAPI_DELAY) != 0; | ||
4731 | trim = (flags & XFS_BMAPI_ENTIRE) == 0; | ||
4732 | userdata = (flags & XFS_BMAPI_METADATA) == 0; | ||
4733 | convert = (flags & XFS_BMAPI_CONVERT) != 0; | ||
4734 | exact = (flags & XFS_BMAPI_EXACT) != 0; | ||
4735 | rsvd = (flags & XFS_BMAPI_RSVBLOCKS) != 0; | ||
4736 | contig = (flags & XFS_BMAPI_CONTIG) != 0; | ||
4737 | /* | 4714 | /* |
4738 | * stateless is used to combine extents which | 4715 | * IGSTATE flag is used to combine extents which |
4739 | * differ only due to the state of the extents. | 4716 | * differ only due to the state of the extents. |
4740 | * This technique is used from xfs_getbmap() | 4717 | * This technique is used from xfs_getbmap() |
4741 | * when the caller does not wish to see the | 4718 | * when the caller does not wish to see the |
@@ -4751,10 +4728,9 @@ xfs_bmapi( | |||
4751 | * xfs_strat_comp(), where the xfs_bmapi() call | 4728 | * xfs_strat_comp(), where the xfs_bmapi() call |
4752 | * is transactioned, and the extents combined. | 4729 | * is transactioned, and the extents combined. |
4753 | */ | 4730 | */ |
4754 | stateless = (flags & XFS_BMAPI_IGSTATE) != 0; | 4731 | if ((flags & XFS_BMAPI_IGSTATE) && wr) /* if writing unwritten space */ |
4755 | if (stateless && wr) /* if writing unwritten space, no */ | 4732 | wr = 0; /* no allocations are allowed */ |
4756 | wr = 0; /* allocations are allowed */ | 4733 | ASSERT(wr || !(flags & XFS_BMAPI_DELAY)); |
4757 | ASSERT(wr || !delay); | ||
4758 | logflags = 0; | 4734 | logflags = 0; |
4759 | nallocs = 0; | 4735 | nallocs = 0; |
4760 | cur = NULL; | 4736 | cur = NULL; |
@@ -4789,7 +4765,7 @@ xfs_bmapi( | |||
4789 | if (eof && !wr) | 4765 | if (eof && !wr) |
4790 | got.br_startoff = end; | 4766 | got.br_startoff = end; |
4791 | inhole = eof || got.br_startoff > bno; | 4767 | inhole = eof || got.br_startoff > bno; |
4792 | wasdelay = wr && !inhole && !delay && | 4768 | wasdelay = wr && !inhole && !(flags & XFS_BMAPI_DELAY) && |
4793 | ISNULLSTARTBLOCK(got.br_startblock); | 4769 | ISNULLSTARTBLOCK(got.br_startblock); |
4794 | /* | 4770 | /* |
4795 | * First, deal with the hole before the allocated space | 4771 | * First, deal with the hole before the allocated space |
@@ -4801,11 +4777,11 @@ xfs_bmapi( | |||
4801 | * allocate the stuff asked for in this bmap call | 4777 | * allocate the stuff asked for in this bmap call |
4802 | * but that wouldn't be as good. | 4778 | * but that wouldn't be as good. |
4803 | */ | 4779 | */ |
4804 | if (wasdelay && !exact) { | 4780 | if (wasdelay && !(flags & XFS_BMAPI_EXACT)) { |
4805 | alen = (xfs_extlen_t)got.br_blockcount; | 4781 | alen = (xfs_extlen_t)got.br_blockcount; |
4806 | aoff = got.br_startoff; | 4782 | aoff = got.br_startoff; |
4807 | if (lastx != NULLEXTNUM && lastx) { | 4783 | if (lastx != NULLEXTNUM && lastx) { |
4808 | ep = &ifp->if_u1.if_extents[lastx - 1]; | 4784 | ep = xfs_iext_get_ext(ifp, lastx - 1); |
4809 | xfs_bmbt_get_all(ep, &prev); | 4785 | xfs_bmbt_get_all(ep, &prev); |
4810 | } | 4786 | } |
4811 | } else if (wasdelay) { | 4787 | } else if (wasdelay) { |
@@ -4823,8 +4799,8 @@ xfs_bmapi( | |||
4823 | got.br_startoff - bno); | 4799 | got.br_startoff - bno); |
4824 | aoff = bno; | 4800 | aoff = bno; |
4825 | } | 4801 | } |
4826 | minlen = contig ? alen : 1; | 4802 | minlen = (flags & XFS_BMAPI_CONTIG) ? alen : 1; |
4827 | if (delay) { | 4803 | if (flags & XFS_BMAPI_DELAY) { |
4828 | xfs_extlen_t extsz; | 4804 | xfs_extlen_t extsz; |
4829 | 4805 | ||
4830 | /* Figure out the extent size, adjust alen */ | 4806 | /* Figure out the extent size, adjust alen */ |
@@ -4837,7 +4813,9 @@ xfs_bmapi( | |||
4837 | if (extsz) { | 4813 | if (extsz) { |
4838 | error = xfs_bmap_extsize_align(mp, | 4814 | error = xfs_bmap_extsize_align(mp, |
4839 | &got, &prev, extsz, | 4815 | &got, &prev, extsz, |
4840 | rt, eof, delay, convert, | 4816 | rt, eof, |
4817 | flags&XFS_BMAPI_DELAY, | ||
4818 | flags&XFS_BMAPI_CONVERT, | ||
4841 | &aoff, &alen); | 4819 | &aoff, &alen); |
4842 | ASSERT(!error); | 4820 | ASSERT(!error); |
4843 | } | 4821 | } |
@@ -4875,24 +4853,29 @@ xfs_bmapi( | |||
4875 | if (rt) { | 4853 | if (rt) { |
4876 | error = xfs_mod_incore_sb(mp, | 4854 | error = xfs_mod_incore_sb(mp, |
4877 | XFS_SBS_FREXTENTS, | 4855 | XFS_SBS_FREXTENTS, |
4878 | -(extsz), rsvd); | 4856 | -(extsz), (flags & |
4857 | XFS_BMAPI_RSVBLOCKS)); | ||
4879 | } else { | 4858 | } else { |
4880 | error = xfs_mod_incore_sb(mp, | 4859 | error = xfs_mod_incore_sb(mp, |
4881 | XFS_SBS_FDBLOCKS, | 4860 | XFS_SBS_FDBLOCKS, |
4882 | -(alen), rsvd); | 4861 | -(alen), (flags & |
4862 | XFS_BMAPI_RSVBLOCKS)); | ||
4883 | } | 4863 | } |
4884 | if (!error) { | 4864 | if (!error) { |
4885 | error = xfs_mod_incore_sb(mp, | 4865 | error = xfs_mod_incore_sb(mp, |
4886 | XFS_SBS_FDBLOCKS, | 4866 | XFS_SBS_FDBLOCKS, |
4887 | -(indlen), rsvd); | 4867 | -(indlen), (flags & |
4868 | XFS_BMAPI_RSVBLOCKS)); | ||
4888 | if (error && rt) | 4869 | if (error && rt) |
4889 | xfs_mod_incore_sb(mp, | 4870 | xfs_mod_incore_sb(mp, |
4890 | XFS_SBS_FREXTENTS, | 4871 | XFS_SBS_FREXTENTS, |
4891 | extsz, rsvd); | 4872 | extsz, (flags & |
4873 | XFS_BMAPI_RSVBLOCKS)); | ||
4892 | else if (error) | 4874 | else if (error) |
4893 | xfs_mod_incore_sb(mp, | 4875 | xfs_mod_incore_sb(mp, |
4894 | XFS_SBS_FDBLOCKS, | 4876 | XFS_SBS_FDBLOCKS, |
4895 | alen, rsvd); | 4877 | alen, (flags & |
4878 | XFS_BMAPI_RSVBLOCKS)); | ||
4896 | } | 4879 | } |
4897 | 4880 | ||
4898 | if (error) { | 4881 | if (error) { |
@@ -4925,7 +4908,7 @@ xfs_bmapi( | |||
4925 | /* Indicate if this is the first user data | 4908 | /* Indicate if this is the first user data |
4926 | * in the file, or just any user data. | 4909 | * in the file, or just any user data. |
4927 | */ | 4910 | */ |
4928 | if (userdata) { | 4911 | if (!(flags & XFS_BMAPI_METADATA)) { |
4929 | bma.userdata = (aoff == 0) ? | 4912 | bma.userdata = (aoff == 0) ? |
4930 | XFS_ALLOC_INITIAL_USER_DATA : | 4913 | XFS_ALLOC_INITIAL_USER_DATA : |
4931 | XFS_ALLOC_USERDATA; | 4914 | XFS_ALLOC_USERDATA; |
@@ -4937,7 +4920,7 @@ xfs_bmapi( | |||
4937 | bma.firstblock = *firstblock; | 4920 | bma.firstblock = *firstblock; |
4938 | bma.alen = alen; | 4921 | bma.alen = alen; |
4939 | bma.off = aoff; | 4922 | bma.off = aoff; |
4940 | bma.conv = convert; | 4923 | bma.conv = (flags & XFS_BMAPI_CONVERT); |
4941 | bma.wasdel = wasdelay; | 4924 | bma.wasdel = wasdelay; |
4942 | bma.minlen = minlen; | 4925 | bma.minlen = minlen; |
4943 | bma.low = flist->xbf_low; | 4926 | bma.low = flist->xbf_low; |
@@ -4948,7 +4931,8 @@ xfs_bmapi( | |||
4948 | * is larger than a stripe unit. | 4931 | * is larger than a stripe unit. |
4949 | */ | 4932 | */ |
4950 | if (mp->m_dalign && alen >= mp->m_dalign && | 4933 | if (mp->m_dalign && alen >= mp->m_dalign && |
4951 | userdata && whichfork == XFS_DATA_FORK) { | 4934 | (!(flags & XFS_BMAPI_METADATA)) && |
4935 | (whichfork == XFS_DATA_FORK)) { | ||
4952 | if ((error = xfs_bmap_isaeof(ip, aoff, | 4936 | if ((error = xfs_bmap_isaeof(ip, aoff, |
4953 | whichfork, &bma.aeof))) | 4937 | whichfork, &bma.aeof))) |
4954 | goto error0; | 4938 | goto error0; |
@@ -5011,19 +4995,19 @@ xfs_bmapi( | |||
5011 | } | 4995 | } |
5012 | error = xfs_bmap_add_extent(ip, lastx, &cur, &got, | 4996 | error = xfs_bmap_add_extent(ip, lastx, &cur, &got, |
5013 | firstblock, flist, &tmp_logflags, whichfork, | 4997 | firstblock, flist, &tmp_logflags, whichfork, |
5014 | rsvd); | 4998 | (flags & XFS_BMAPI_RSVBLOCKS)); |
5015 | logflags |= tmp_logflags; | 4999 | logflags |= tmp_logflags; |
5016 | if (error) | 5000 | if (error) |
5017 | goto error0; | 5001 | goto error0; |
5018 | lastx = ifp->if_lastex; | 5002 | lastx = ifp->if_lastex; |
5019 | ep = &ifp->if_u1.if_extents[lastx]; | 5003 | ep = xfs_iext_get_ext(ifp, lastx); |
5020 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 5004 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
5021 | xfs_bmbt_get_all(ep, &got); | 5005 | xfs_bmbt_get_all(ep, &got); |
5022 | ASSERT(got.br_startoff <= aoff); | 5006 | ASSERT(got.br_startoff <= aoff); |
5023 | ASSERT(got.br_startoff + got.br_blockcount >= | 5007 | ASSERT(got.br_startoff + got.br_blockcount >= |
5024 | aoff + alen); | 5008 | aoff + alen); |
5025 | #ifdef DEBUG | 5009 | #ifdef DEBUG |
5026 | if (delay) { | 5010 | if (flags & XFS_BMAPI_DELAY) { |
5027 | ASSERT(ISNULLSTARTBLOCK(got.br_startblock)); | 5011 | ASSERT(ISNULLSTARTBLOCK(got.br_startblock)); |
5028 | ASSERT(STARTBLOCKVAL(got.br_startblock) > 0); | 5012 | ASSERT(STARTBLOCKVAL(got.br_startblock) > 0); |
5029 | } | 5013 | } |
@@ -5052,14 +5036,15 @@ xfs_bmapi( | |||
5052 | * Then deal with the allocated space we found. | 5036 | * Then deal with the allocated space we found. |
5053 | */ | 5037 | */ |
5054 | ASSERT(ep != NULL); | 5038 | ASSERT(ep != NULL); |
5055 | if (trim && (got.br_startoff + got.br_blockcount > obno)) { | 5039 | if (!(flags & XFS_BMAPI_ENTIRE) && |
5040 | (got.br_startoff + got.br_blockcount > obno)) { | ||
5056 | if (obno > bno) | 5041 | if (obno > bno) |
5057 | bno = obno; | 5042 | bno = obno; |
5058 | ASSERT((bno >= obno) || (n == 0)); | 5043 | ASSERT((bno >= obno) || (n == 0)); |
5059 | ASSERT(bno < end); | 5044 | ASSERT(bno < end); |
5060 | mval->br_startoff = bno; | 5045 | mval->br_startoff = bno; |
5061 | if (ISNULLSTARTBLOCK(got.br_startblock)) { | 5046 | if (ISNULLSTARTBLOCK(got.br_startblock)) { |
5062 | ASSERT(!wr || delay); | 5047 | ASSERT(!wr || (flags & XFS_BMAPI_DELAY)); |
5063 | mval->br_startblock = DELAYSTARTBLOCK; | 5048 | mval->br_startblock = DELAYSTARTBLOCK; |
5064 | } else | 5049 | } else |
5065 | mval->br_startblock = | 5050 | mval->br_startblock = |
@@ -5081,7 +5066,7 @@ xfs_bmapi( | |||
5081 | } else { | 5066 | } else { |
5082 | *mval = got; | 5067 | *mval = got; |
5083 | if (ISNULLSTARTBLOCK(mval->br_startblock)) { | 5068 | if (ISNULLSTARTBLOCK(mval->br_startblock)) { |
5084 | ASSERT(!wr || delay); | 5069 | ASSERT(!wr || (flags & XFS_BMAPI_DELAY)); |
5085 | mval->br_startblock = DELAYSTARTBLOCK; | 5070 | mval->br_startblock = DELAYSTARTBLOCK; |
5086 | } | 5071 | } |
5087 | } | 5072 | } |
@@ -5107,12 +5092,12 @@ xfs_bmapi( | |||
5107 | mval->br_state = XFS_EXT_NORM; | 5092 | mval->br_state = XFS_EXT_NORM; |
5108 | error = xfs_bmap_add_extent(ip, lastx, &cur, mval, | 5093 | error = xfs_bmap_add_extent(ip, lastx, &cur, mval, |
5109 | firstblock, flist, &tmp_logflags, whichfork, | 5094 | firstblock, flist, &tmp_logflags, whichfork, |
5110 | rsvd); | 5095 | (flags & XFS_BMAPI_RSVBLOCKS)); |
5111 | logflags |= tmp_logflags; | 5096 | logflags |= tmp_logflags; |
5112 | if (error) | 5097 | if (error) |
5113 | goto error0; | 5098 | goto error0; |
5114 | lastx = ifp->if_lastex; | 5099 | lastx = ifp->if_lastex; |
5115 | ep = &ifp->if_u1.if_extents[lastx]; | 5100 | ep = xfs_iext_get_ext(ifp, lastx); |
5116 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 5101 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
5117 | xfs_bmbt_get_all(ep, &got); | 5102 | xfs_bmbt_get_all(ep, &got); |
5118 | /* | 5103 | /* |
@@ -5124,9 +5109,10 @@ xfs_bmapi( | |||
5124 | continue; | 5109 | continue; |
5125 | } | 5110 | } |
5126 | 5111 | ||
5127 | ASSERT(!trim || | 5112 | ASSERT((flags & XFS_BMAPI_ENTIRE) || |
5128 | ((mval->br_startoff + mval->br_blockcount) <= end)); | 5113 | ((mval->br_startoff + mval->br_blockcount) <= end)); |
5129 | ASSERT(!trim || (mval->br_blockcount <= len) || | 5114 | ASSERT((flags & XFS_BMAPI_ENTIRE) || |
5115 | (mval->br_blockcount <= len) || | ||
5130 | (mval->br_startoff < obno)); | 5116 | (mval->br_startoff < obno)); |
5131 | bno = mval->br_startoff + mval->br_blockcount; | 5117 | bno = mval->br_startoff + mval->br_blockcount; |
5132 | len = end - bno; | 5118 | len = end - bno; |
@@ -5141,7 +5127,8 @@ xfs_bmapi( | |||
5141 | mval[-1].br_startblock != HOLESTARTBLOCK && | 5127 | mval[-1].br_startblock != HOLESTARTBLOCK && |
5142 | mval->br_startblock == | 5128 | mval->br_startblock == |
5143 | mval[-1].br_startblock + mval[-1].br_blockcount && | 5129 | mval[-1].br_startblock + mval[-1].br_blockcount && |
5144 | (stateless || mval[-1].br_state == mval->br_state)) { | 5130 | ((flags & XFS_BMAPI_IGSTATE) || |
5131 | mval[-1].br_state == mval->br_state)) { | ||
5145 | ASSERT(mval->br_startoff == | 5132 | ASSERT(mval->br_startoff == |
5146 | mval[-1].br_startoff + mval[-1].br_blockcount); | 5133 | mval[-1].br_startoff + mval[-1].br_blockcount); |
5147 | mval[-1].br_blockcount += mval->br_blockcount; | 5134 | mval[-1].br_blockcount += mval->br_blockcount; |
@@ -5168,8 +5155,7 @@ xfs_bmapi( | |||
5168 | /* | 5155 | /* |
5169 | * Else go on to the next record. | 5156 | * Else go on to the next record. |
5170 | */ | 5157 | */ |
5171 | ep++; | 5158 | ep = xfs_iext_get_ext(ifp, ++lastx); |
5172 | lastx++; | ||
5173 | if (lastx >= nextents) { | 5159 | if (lastx >= nextents) { |
5174 | eof = 1; | 5160 | eof = 1; |
5175 | prev = got; | 5161 | prev = got; |
@@ -5199,7 +5185,7 @@ xfs_bmapi( | |||
5199 | error0: | 5185 | error0: |
5200 | /* | 5186 | /* |
5201 | * Log everything. Do this after conversion, there's no point in | 5187 | * Log everything. Do this after conversion, there's no point in |
5202 | * logging the extent list if we've converted to btree format. | 5188 | * logging the extent records if we've converted to btree format. |
5203 | */ | 5189 | */ |
5204 | if ((logflags & XFS_ILOG_FEXT(whichfork)) && | 5190 | if ((logflags & XFS_ILOG_FEXT(whichfork)) && |
5205 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) | 5191 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) |
@@ -5252,12 +5238,12 @@ xfs_bmapi_single( | |||
5252 | xfs_fsblock_t *fsb, /* output: mapped block */ | 5238 | xfs_fsblock_t *fsb, /* output: mapped block */ |
5253 | xfs_fileoff_t bno) /* starting file offs. mapped */ | 5239 | xfs_fileoff_t bno) /* starting file offs. mapped */ |
5254 | { | 5240 | { |
5255 | int eof; /* we've hit the end of extent list */ | 5241 | int eof; /* we've hit the end of extents */ |
5256 | int error; /* error return */ | 5242 | int error; /* error return */ |
5257 | xfs_bmbt_irec_t got; /* current extent list record */ | 5243 | xfs_bmbt_irec_t got; /* current file extent record */ |
5258 | xfs_ifork_t *ifp; /* inode fork pointer */ | 5244 | xfs_ifork_t *ifp; /* inode fork pointer */ |
5259 | xfs_extnum_t lastx; /* last useful extent number */ | 5245 | xfs_extnum_t lastx; /* last useful extent number */ |
5260 | xfs_bmbt_irec_t prev; /* previous extent list record */ | 5246 | xfs_bmbt_irec_t prev; /* previous file extent record */ |
5261 | 5247 | ||
5262 | ifp = XFS_IFORK_PTR(ip, whichfork); | 5248 | ifp = XFS_IFORK_PTR(ip, whichfork); |
5263 | if (unlikely( | 5249 | if (unlikely( |
@@ -5312,18 +5298,18 @@ xfs_bunmapi( | |||
5312 | xfs_btree_cur_t *cur; /* bmap btree cursor */ | 5298 | xfs_btree_cur_t *cur; /* bmap btree cursor */ |
5313 | xfs_bmbt_irec_t del; /* extent being deleted */ | 5299 | xfs_bmbt_irec_t del; /* extent being deleted */ |
5314 | int eof; /* is deleting at eof */ | 5300 | int eof; /* is deleting at eof */ |
5315 | xfs_bmbt_rec_t *ep; /* extent list entry pointer */ | 5301 | xfs_bmbt_rec_t *ep; /* extent record pointer */ |
5316 | int error; /* error return value */ | 5302 | int error; /* error return value */ |
5317 | xfs_extnum_t extno; /* extent number in list */ | 5303 | xfs_extnum_t extno; /* extent number in list */ |
5318 | xfs_bmbt_irec_t got; /* current extent list entry */ | 5304 | xfs_bmbt_irec_t got; /* current extent record */ |
5319 | xfs_ifork_t *ifp; /* inode fork pointer */ | 5305 | xfs_ifork_t *ifp; /* inode fork pointer */ |
5320 | int isrt; /* freeing in rt area */ | 5306 | int isrt; /* freeing in rt area */ |
5321 | xfs_extnum_t lastx; /* last extent index used */ | 5307 | xfs_extnum_t lastx; /* last extent index used */ |
5322 | int logflags; /* transaction logging flags */ | 5308 | int logflags; /* transaction logging flags */ |
5323 | xfs_extlen_t mod; /* rt extent offset */ | 5309 | xfs_extlen_t mod; /* rt extent offset */ |
5324 | xfs_mount_t *mp; /* mount structure */ | 5310 | xfs_mount_t *mp; /* mount structure */ |
5325 | xfs_extnum_t nextents; /* size of extent list */ | 5311 | xfs_extnum_t nextents; /* number of file extents */ |
5326 | xfs_bmbt_irec_t prev; /* previous extent list entry */ | 5312 | xfs_bmbt_irec_t prev; /* previous extent record */ |
5327 | xfs_fileoff_t start; /* first file offset deleted */ | 5313 | xfs_fileoff_t start; /* first file offset deleted */ |
5328 | int tmp_logflags; /* partial logging flags */ | 5314 | int tmp_logflags; /* partial logging flags */ |
5329 | int wasdel; /* was a delayed alloc extent */ | 5315 | int wasdel; /* was a delayed alloc extent */ |
@@ -5369,7 +5355,7 @@ xfs_bunmapi( | |||
5369 | * file, back up to the last block if so... | 5355 | * file, back up to the last block if so... |
5370 | */ | 5356 | */ |
5371 | if (eof) { | 5357 | if (eof) { |
5372 | ep = &ifp->if_u1.if_extents[--lastx]; | 5358 | ep = xfs_iext_get_ext(ifp, --lastx); |
5373 | xfs_bmbt_get_all(ep, &got); | 5359 | xfs_bmbt_get_all(ep, &got); |
5374 | bno = got.br_startoff + got.br_blockcount - 1; | 5360 | bno = got.br_startoff + got.br_blockcount - 1; |
5375 | } | 5361 | } |
@@ -5393,7 +5379,7 @@ xfs_bunmapi( | |||
5393 | if (got.br_startoff > bno) { | 5379 | if (got.br_startoff > bno) { |
5394 | if (--lastx < 0) | 5380 | if (--lastx < 0) |
5395 | break; | 5381 | break; |
5396 | ep--; | 5382 | ep = xfs_iext_get_ext(ifp, lastx); |
5397 | xfs_bmbt_get_all(ep, &got); | 5383 | xfs_bmbt_get_all(ep, &got); |
5398 | } | 5384 | } |
5399 | /* | 5385 | /* |
@@ -5440,7 +5426,8 @@ xfs_bunmapi( | |||
5440 | del.br_blockcount : mod; | 5426 | del.br_blockcount : mod; |
5441 | if (bno < got.br_startoff) { | 5427 | if (bno < got.br_startoff) { |
5442 | if (--lastx >= 0) | 5428 | if (--lastx >= 0) |
5443 | xfs_bmbt_get_all(--ep, &got); | 5429 | xfs_bmbt_get_all(xfs_iext_get_ext( |
5430 | ifp, lastx), &got); | ||
5444 | } | 5431 | } |
5445 | continue; | 5432 | continue; |
5446 | } | 5433 | } |
@@ -5500,7 +5487,8 @@ xfs_bunmapi( | |||
5500 | * try again. | 5487 | * try again. |
5501 | */ | 5488 | */ |
5502 | ASSERT(lastx > 0); | 5489 | ASSERT(lastx > 0); |
5503 | xfs_bmbt_get_all(ep - 1, &prev); | 5490 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, |
5491 | lastx - 1), &prev); | ||
5504 | ASSERT(prev.br_state == XFS_EXT_NORM); | 5492 | ASSERT(prev.br_state == XFS_EXT_NORM); |
5505 | ASSERT(!ISNULLSTARTBLOCK(prev.br_startblock)); | 5493 | ASSERT(!ISNULLSTARTBLOCK(prev.br_startblock)); |
5506 | ASSERT(del.br_startblock == | 5494 | ASSERT(del.br_startblock == |
@@ -5587,12 +5575,12 @@ nodelete: | |||
5587 | * If not done go on to the next (previous) record. | 5575 | * If not done go on to the next (previous) record. |
5588 | * Reset ep in case the extents array was re-alloced. | 5576 | * Reset ep in case the extents array was re-alloced. |
5589 | */ | 5577 | */ |
5590 | ep = &ifp->if_u1.if_extents[lastx]; | 5578 | ep = xfs_iext_get_ext(ifp, lastx); |
5591 | if (bno != (xfs_fileoff_t)-1 && bno >= start) { | 5579 | if (bno != (xfs_fileoff_t)-1 && bno >= start) { |
5592 | if (lastx >= XFS_IFORK_NEXTENTS(ip, whichfork) || | 5580 | if (lastx >= XFS_IFORK_NEXTENTS(ip, whichfork) || |
5593 | xfs_bmbt_get_startoff(ep) > bno) { | 5581 | xfs_bmbt_get_startoff(ep) > bno) { |
5594 | lastx--; | 5582 | if (--lastx >= 0) |
5595 | ep--; | 5583 | ep = xfs_iext_get_ext(ifp, lastx); |
5596 | } | 5584 | } |
5597 | if (lastx >= 0) | 5585 | if (lastx >= 0) |
5598 | xfs_bmbt_get_all(ep, &got); | 5586 | xfs_bmbt_get_all(ep, &got); |
@@ -5636,7 +5624,7 @@ nodelete: | |||
5636 | error0: | 5624 | error0: |
5637 | /* | 5625 | /* |
5638 | * Log everything. Do this after conversion, there's no point in | 5626 | * Log everything. Do this after conversion, there's no point in |
5639 | * logging the extent list if we've converted to btree format. | 5627 | * logging the extent records if we've converted to btree format. |
5640 | */ | 5628 | */ |
5641 | if ((logflags & XFS_ILOG_FEXT(whichfork)) && | 5629 | if ((logflags & XFS_ILOG_FEXT(whichfork)) && |
5642 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) | 5630 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) |
@@ -5892,9 +5880,9 @@ xfs_bmap_isaeof( | |||
5892 | { | 5880 | { |
5893 | int error; /* error return value */ | 5881 | int error; /* error return value */ |
5894 | xfs_ifork_t *ifp; /* inode fork pointer */ | 5882 | xfs_ifork_t *ifp; /* inode fork pointer */ |
5895 | xfs_bmbt_rec_t *lastrec; /* extent list entry pointer */ | 5883 | xfs_bmbt_rec_t *lastrec; /* extent record pointer */ |
5896 | xfs_extnum_t nextents; /* size of extent list */ | 5884 | xfs_extnum_t nextents; /* number of file extents */ |
5897 | xfs_bmbt_irec_t s; /* expanded extent list entry */ | 5885 | xfs_bmbt_irec_t s; /* expanded extent record */ |
5898 | 5886 | ||
5899 | ASSERT(whichfork == XFS_DATA_FORK); | 5887 | ASSERT(whichfork == XFS_DATA_FORK); |
5900 | ifp = XFS_IFORK_PTR(ip, whichfork); | 5888 | ifp = XFS_IFORK_PTR(ip, whichfork); |
@@ -5909,7 +5897,7 @@ xfs_bmap_isaeof( | |||
5909 | /* | 5897 | /* |
5910 | * Go to the last extent | 5898 | * Go to the last extent |
5911 | */ | 5899 | */ |
5912 | lastrec = &ifp->if_u1.if_extents[nextents - 1]; | 5900 | lastrec = xfs_iext_get_ext(ifp, nextents - 1); |
5913 | xfs_bmbt_get_all(lastrec, &s); | 5901 | xfs_bmbt_get_all(lastrec, &s); |
5914 | /* | 5902 | /* |
5915 | * Check we are allocating in the last extent (for delayed allocations) | 5903 | * Check we are allocating in the last extent (for delayed allocations) |
@@ -5936,8 +5924,8 @@ xfs_bmap_eof( | |||
5936 | xfs_fsblock_t blockcount; /* extent block count */ | 5924 | xfs_fsblock_t blockcount; /* extent block count */ |
5937 | int error; /* error return value */ | 5925 | int error; /* error return value */ |
5938 | xfs_ifork_t *ifp; /* inode fork pointer */ | 5926 | xfs_ifork_t *ifp; /* inode fork pointer */ |
5939 | xfs_bmbt_rec_t *lastrec; /* extent list entry pointer */ | 5927 | xfs_bmbt_rec_t *lastrec; /* extent record pointer */ |
5940 | xfs_extnum_t nextents; /* size of extent list */ | 5928 | xfs_extnum_t nextents; /* number of file extents */ |
5941 | xfs_fileoff_t startoff; /* extent starting file offset */ | 5929 | xfs_fileoff_t startoff; /* extent starting file offset */ |
5942 | 5930 | ||
5943 | ASSERT(whichfork == XFS_DATA_FORK); | 5931 | ASSERT(whichfork == XFS_DATA_FORK); |
@@ -5953,7 +5941,7 @@ xfs_bmap_eof( | |||
5953 | /* | 5941 | /* |
5954 | * Go to the last extent | 5942 | * Go to the last extent |
5955 | */ | 5943 | */ |
5956 | lastrec = &ifp->if_u1.if_extents[nextents - 1]; | 5944 | lastrec = xfs_iext_get_ext(ifp, nextents - 1); |
5957 | startoff = xfs_bmbt_get_startoff(lastrec); | 5945 | startoff = xfs_bmbt_get_startoff(lastrec); |
5958 | blockcount = xfs_bmbt_get_blockcount(lastrec); | 5946 | blockcount = xfs_bmbt_get_blockcount(lastrec); |
5959 | *eof = endoff >= startoff + blockcount; | 5947 | *eof = endoff >= startoff + blockcount; |
@@ -5969,18 +5957,21 @@ xfs_bmap_check_extents( | |||
5969 | xfs_inode_t *ip, /* incore inode pointer */ | 5957 | xfs_inode_t *ip, /* incore inode pointer */ |
5970 | int whichfork) /* data or attr fork */ | 5958 | int whichfork) /* data or attr fork */ |
5971 | { | 5959 | { |
5972 | xfs_bmbt_rec_t *base; /* base of extents list */ | ||
5973 | xfs_bmbt_rec_t *ep; /* current extent entry */ | 5960 | xfs_bmbt_rec_t *ep; /* current extent entry */ |
5961 | xfs_extnum_t idx; /* extent record index */ | ||
5974 | xfs_ifork_t *ifp; /* inode fork pointer */ | 5962 | xfs_ifork_t *ifp; /* inode fork pointer */ |
5975 | xfs_extnum_t nextents; /* number of extents in list */ | 5963 | xfs_extnum_t nextents; /* number of extents in list */ |
5964 | xfs_bmbt_rec_t *nextp; /* next extent entry */ | ||
5976 | 5965 | ||
5977 | ifp = XFS_IFORK_PTR(ip, whichfork); | 5966 | ifp = XFS_IFORK_PTR(ip, whichfork); |
5978 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | 5967 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); |
5979 | base = ifp->if_u1.if_extents; | ||
5980 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 5968 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
5981 | for (ep = base; ep < &base[nextents - 1]; ep++) { | 5969 | ep = xfs_iext_get_ext(ifp, 0); |
5970 | for (idx = 0; idx < nextents - 1; idx++) { | ||
5971 | nextp = xfs_iext_get_ext(ifp, idx + 1); | ||
5982 | xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep, | 5972 | xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep, |
5983 | (void *)(ep + 1)); | 5973 | (void *)(nextp)); |
5974 | ep = nextp; | ||
5984 | } | 5975 | } |
5985 | } | 5976 | } |
5986 | 5977 | ||
@@ -6119,12 +6110,14 @@ xfs_bmap_check_leaf_extents( | |||
6119 | xfs_fsblock_t bno; /* block # of "block" */ | 6110 | xfs_fsblock_t bno; /* block # of "block" */ |
6120 | xfs_buf_t *bp; /* buffer for "block" */ | 6111 | xfs_buf_t *bp; /* buffer for "block" */ |
6121 | int error; /* error return value */ | 6112 | int error; /* error return value */ |
6122 | xfs_extnum_t i=0; /* index into the extents list */ | 6113 | xfs_extnum_t i=0, j; /* index into the extents list */ |
6123 | xfs_ifork_t *ifp; /* fork structure */ | 6114 | xfs_ifork_t *ifp; /* fork structure */ |
6124 | int level; /* btree level, for checking */ | 6115 | int level; /* btree level, for checking */ |
6125 | xfs_mount_t *mp; /* file system mount structure */ | 6116 | xfs_mount_t *mp; /* file system mount structure */ |
6126 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 6117 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ |
6127 | xfs_bmbt_rec_t *ep, *lastp; /* extent pointers in block entry */ | 6118 | xfs_bmbt_rec_t *ep; /* pointer to current extent */ |
6119 | xfs_bmbt_rec_t *lastp; /* pointer to previous extent */ | ||
6120 | xfs_bmbt_rec_t *nextp; /* pointer to next extent */ | ||
6128 | int bp_release = 0; | 6121 | int bp_release = 0; |
6129 | 6122 | ||
6130 | if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) { | 6123 | if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) { |
@@ -6194,7 +6187,6 @@ xfs_bmap_check_leaf_extents( | |||
6194 | */ | 6187 | */ |
6195 | lastp = NULL; | 6188 | lastp = NULL; |
6196 | for (;;) { | 6189 | for (;;) { |
6197 | xfs_bmbt_rec_t *frp; | ||
6198 | xfs_fsblock_t nextbno; | 6190 | xfs_fsblock_t nextbno; |
6199 | xfs_extnum_t num_recs; | 6191 | xfs_extnum_t num_recs; |
6200 | 6192 | ||
@@ -6213,18 +6205,20 @@ xfs_bmap_check_leaf_extents( | |||
6213 | * conform with the first entry in this one. | 6205 | * conform with the first entry in this one. |
6214 | */ | 6206 | */ |
6215 | 6207 | ||
6216 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, | 6208 | ep = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, |
6217 | block, 1, mp->m_bmap_dmxr[0]); | 6209 | block, 1, mp->m_bmap_dmxr[0]); |
6218 | 6210 | for (j = 1; j < num_recs; j++) { | |
6219 | for (ep = frp;ep < frp + (num_recs - 1); ep++) { | 6211 | nextp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, |
6212 | block, j + 1, mp->m_bmap_dmxr[0]); | ||
6220 | if (lastp) { | 6213 | if (lastp) { |
6221 | xfs_btree_check_rec(XFS_BTNUM_BMAP, | 6214 | xfs_btree_check_rec(XFS_BTNUM_BMAP, |
6222 | (void *)lastp, (void *)ep); | 6215 | (void *)lastp, (void *)ep); |
6223 | } | 6216 | } |
6224 | xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep, | 6217 | xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep, |
6225 | (void *)(ep + 1)); | 6218 | (void *)(nextp)); |
6219 | lastp = ep; | ||
6220 | ep = nextp; | ||
6226 | } | 6221 | } |
6227 | lastp = frp + num_recs - 1; /* For the next iteration */ | ||
6228 | 6222 | ||
6229 | i += num_recs; | 6223 | i += num_recs; |
6230 | if (bp_release) { | 6224 | if (bp_release) { |
@@ -6288,7 +6282,7 @@ xfs_bmap_count_blocks( | |||
6288 | mp = ip->i_mount; | 6282 | mp = ip->i_mount; |
6289 | ifp = XFS_IFORK_PTR(ip, whichfork); | 6283 | ifp = XFS_IFORK_PTR(ip, whichfork); |
6290 | if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) { | 6284 | if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) { |
6291 | if (unlikely(xfs_bmap_count_leaves(ifp->if_u1.if_extents, | 6285 | if (unlikely(xfs_bmap_count_leaves(ifp, 0, |
6292 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t), | 6286 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t), |
6293 | count) < 0)) { | 6287 | count) < 0)) { |
6294 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(1)", | 6288 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(1)", |
@@ -6310,7 +6304,7 @@ xfs_bmap_count_blocks( | |||
6310 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 6304 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); |
6311 | bno = INT_GET(*pp, ARCH_CONVERT); | 6305 | bno = INT_GET(*pp, ARCH_CONVERT); |
6312 | 6306 | ||
6313 | if (unlikely(xfs_bmap_count_tree(mp, tp, bno, level, count) < 0)) { | 6307 | if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { |
6314 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, | 6308 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, |
6315 | mp); | 6309 | mp); |
6316 | return XFS_ERROR(EFSCORRUPTED); | 6310 | return XFS_ERROR(EFSCORRUPTED); |
@@ -6327,6 +6321,7 @@ int /* error */ | |||
6327 | xfs_bmap_count_tree( | 6321 | xfs_bmap_count_tree( |
6328 | xfs_mount_t *mp, /* file system mount point */ | 6322 | xfs_mount_t *mp, /* file system mount point */ |
6329 | xfs_trans_t *tp, /* transaction pointer */ | 6323 | xfs_trans_t *tp, /* transaction pointer */ |
6324 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
6330 | xfs_fsblock_t blockno, /* file system block number */ | 6325 | xfs_fsblock_t blockno, /* file system block number */ |
6331 | int levelin, /* level in btree */ | 6326 | int levelin, /* level in btree */ |
6332 | int *count) /* Count of blocks */ | 6327 | int *count) /* Count of blocks */ |
@@ -6339,7 +6334,6 @@ xfs_bmap_count_tree( | |||
6339 | xfs_fsblock_t nextbno; | 6334 | xfs_fsblock_t nextbno; |
6340 | xfs_bmbt_block_t *block, *nextblock; | 6335 | xfs_bmbt_block_t *block, *nextblock; |
6341 | int numrecs; | 6336 | int numrecs; |
6342 | xfs_bmbt_rec_t *frp; | ||
6343 | 6337 | ||
6344 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) | 6338 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) |
6345 | return error; | 6339 | return error; |
@@ -6364,7 +6358,7 @@ xfs_bmap_count_tree( | |||
6364 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); | 6358 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); |
6365 | bno = INT_GET(*pp, ARCH_CONVERT); | 6359 | bno = INT_GET(*pp, ARCH_CONVERT); |
6366 | if (unlikely((error = | 6360 | if (unlikely((error = |
6367 | xfs_bmap_count_tree(mp, tp, bno, level, count)) < 0)) { | 6361 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { |
6368 | xfs_trans_brelse(tp, bp); | 6362 | xfs_trans_brelse(tp, bp); |
6369 | XFS_ERROR_REPORT("xfs_bmap_count_tree(1)", | 6363 | XFS_ERROR_REPORT("xfs_bmap_count_tree(1)", |
6370 | XFS_ERRLEVEL_LOW, mp); | 6364 | XFS_ERRLEVEL_LOW, mp); |
@@ -6376,9 +6370,8 @@ xfs_bmap_count_tree( | |||
6376 | for (;;) { | 6370 | for (;;) { |
6377 | nextbno = be64_to_cpu(block->bb_rightsib); | 6371 | nextbno = be64_to_cpu(block->bb_rightsib); |
6378 | numrecs = be16_to_cpu(block->bb_numrecs); | 6372 | numrecs = be16_to_cpu(block->bb_numrecs); |
6379 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, | 6373 | if (unlikely(xfs_bmap_disk_count_leaves(ifp, mp, |
6380 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]); | 6374 | 0, block, numrecs, count) < 0)) { |
6381 | if (unlikely(xfs_bmap_disk_count_leaves(frp, numrecs, count) < 0)) { | ||
6382 | xfs_trans_brelse(tp, bp); | 6375 | xfs_trans_brelse(tp, bp); |
6383 | XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", | 6376 | XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", |
6384 | XFS_ERRLEVEL_LOW, mp); | 6377 | XFS_ERRLEVEL_LOW, mp); |
@@ -6399,33 +6392,45 @@ xfs_bmap_count_tree( | |||
6399 | } | 6392 | } |
6400 | 6393 | ||
6401 | /* | 6394 | /* |
6402 | * Count leaf blocks given a pointer to an extent list. | 6395 | * Count leaf blocks given a range of extent records. |
6403 | */ | 6396 | */ |
6404 | int | 6397 | int |
6405 | xfs_bmap_count_leaves( | 6398 | xfs_bmap_count_leaves( |
6406 | xfs_bmbt_rec_t *frp, | 6399 | xfs_ifork_t *ifp, |
6400 | xfs_extnum_t idx, | ||
6407 | int numrecs, | 6401 | int numrecs, |
6408 | int *count) | 6402 | int *count) |
6409 | { | 6403 | { |
6410 | int b; | 6404 | int b; |
6405 | xfs_bmbt_rec_t *frp; | ||
6411 | 6406 | ||
6412 | for ( b = 1; b <= numrecs; b++, frp++) | 6407 | for (b = 0; b < numrecs; b++) { |
6408 | frp = xfs_iext_get_ext(ifp, idx + b); | ||
6413 | *count += xfs_bmbt_get_blockcount(frp); | 6409 | *count += xfs_bmbt_get_blockcount(frp); |
6410 | } | ||
6414 | return 0; | 6411 | return 0; |
6415 | } | 6412 | } |
6416 | 6413 | ||
6417 | /* | 6414 | /* |
6418 | * Count leaf blocks given a pointer to an extent list originally in btree format. | 6415 | * Count leaf blocks given a range of extent records originally |
6416 | * in btree format. | ||
6419 | */ | 6417 | */ |
6420 | int | 6418 | int |
6421 | xfs_bmap_disk_count_leaves( | 6419 | xfs_bmap_disk_count_leaves( |
6422 | xfs_bmbt_rec_t *frp, | 6420 | xfs_ifork_t *ifp, |
6421 | xfs_mount_t *mp, | ||
6422 | xfs_extnum_t idx, | ||
6423 | xfs_bmbt_block_t *block, | ||
6423 | int numrecs, | 6424 | int numrecs, |
6424 | int *count) | 6425 | int *count) |
6425 | { | 6426 | { |
6426 | int b; | 6427 | int b; |
6428 | xfs_bmbt_rec_t *frp; | ||
6427 | 6429 | ||
6428 | for ( b = 1; b <= numrecs; b++, frp++) | 6430 | for (b = 1; b <= numrecs; b++) { |
6431 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, | ||
6432 | xfs_bmbt, block, idx + b, mp->m_bmap_dmxr[0]); | ||
6429 | *count += xfs_bmbt_disk_get_blockcount(frp); | 6433 | *count += xfs_bmbt_disk_get_blockcount(frp); |
6434 | } | ||
6430 | return 0; | 6435 | return 0; |
6431 | } | 6436 | } |
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index 12cc63dfc2c4..011ccaa9a1c0 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | struct getbmap; | 21 | struct getbmap; |
22 | struct xfs_bmbt_irec; | 22 | struct xfs_bmbt_irec; |
23 | struct xfs_ifork; | ||
23 | struct xfs_inode; | 24 | struct xfs_inode; |
24 | struct xfs_mount; | 25 | struct xfs_mount; |
25 | struct xfs_trans; | 26 | struct xfs_trans; |
@@ -347,9 +348,28 @@ xfs_bmap_count_blocks( | |||
347 | */ | 348 | */ |
348 | int | 349 | int |
349 | xfs_check_nostate_extents( | 350 | xfs_check_nostate_extents( |
350 | xfs_bmbt_rec_t *ep, | 351 | struct xfs_ifork *ifp, |
352 | xfs_extnum_t idx, | ||
351 | xfs_extnum_t num); | 353 | xfs_extnum_t num); |
352 | 354 | ||
355 | /* | ||
356 | * Call xfs_bmap_do_search_extents() to search for the extent | ||
357 | * record containing block bno. If in multi-level in-core extent | ||
358 | * allocation mode, find and extract the target extent buffer, | ||
359 | * otherwise just use the direct extent list. | ||
360 | */ | ||
361 | xfs_bmbt_rec_t * | ||
362 | xfs_bmap_search_multi_extents(struct xfs_ifork *, xfs_fileoff_t, int *, | ||
363 | xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *); | ||
364 | |||
365 | /* | ||
366 | * Search an extent list for the extent which includes block | ||
367 | * bno. | ||
368 | */ | ||
369 | xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *, | ||
370 | xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *, | ||
371 | xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *); | ||
372 | |||
353 | #endif /* __KERNEL__ */ | 373 | #endif /* __KERNEL__ */ |
354 | 374 | ||
355 | #endif /* __XFS_BMAP_H__ */ | 375 | #endif /* __XFS_BMAP_H__ */ |
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 3f1383d160e8..bea44709afbe 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -2754,7 +2754,7 @@ xfs_bmbt_update( | |||
2754 | } | 2754 | } |
2755 | 2755 | ||
2756 | /* | 2756 | /* |
2757 | * Check an extent list, which has just been read, for | 2757 | * Check extent records, which have just been read, for |
2758 | * any bit in the extent flag field. ASSERT on debug | 2758 | * any bit in the extent flag field. ASSERT on debug |
2759 | * kernels, as this condition should not occur. | 2759 | * kernels, as this condition should not occur. |
2760 | * Return an error condition (1) if any flags found, | 2760 | * Return an error condition (1) if any flags found, |
@@ -2763,10 +2763,14 @@ xfs_bmbt_update( | |||
2763 | 2763 | ||
2764 | int | 2764 | int |
2765 | xfs_check_nostate_extents( | 2765 | xfs_check_nostate_extents( |
2766 | xfs_bmbt_rec_t *ep, | 2766 | xfs_ifork_t *ifp, |
2767 | xfs_extnum_t idx, | ||
2767 | xfs_extnum_t num) | 2768 | xfs_extnum_t num) |
2768 | { | 2769 | { |
2769 | for (; num > 0; num--, ep++) { | 2770 | xfs_bmbt_rec_t *ep; |
2771 | |||
2772 | for (; num > 0; num--, idx++) { | ||
2773 | ep = xfs_iext_get_ext(ifp, idx); | ||
2770 | if ((ep->l0 >> | 2774 | if ((ep->l0 >> |
2771 | (64 - BMBT_EXNTFLAG_BITLEN)) != 0) { | 2775 | (64 - BMBT_EXNTFLAG_BITLEN)) != 0) { |
2772 | ASSERT(0); | 2776 | ASSERT(0); |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index e095a2d344ae..6478cfa0e539 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
@@ -372,14 +372,6 @@ extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *, | |||
372 | xfs_exntst_t *, int *); | 372 | xfs_exntst_t *, int *); |
373 | #endif | 373 | #endif |
374 | 374 | ||
375 | /* | ||
376 | * Search an extent list for the extent which includes block | ||
377 | * bno. | ||
378 | */ | ||
379 | xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *, | ||
380 | xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *, | ||
381 | xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *); | ||
382 | |||
383 | #endif /* __KERNEL__ */ | 375 | #endif /* __KERNEL__ */ |
384 | 376 | ||
385 | #endif /* __XFS_BMAP_BTREE_H__ */ | 377 | #endif /* __XFS_BMAP_BTREE_H__ */ |
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h index f57cc9ac875e..022fff62085b 100644 --- a/fs/xfs/xfs_clnt.h +++ b/fs/xfs/xfs_clnt.h | |||
@@ -68,8 +68,6 @@ struct xfs_mount_args { | |||
68 | * enforcement */ | 68 | * enforcement */ |
69 | #define XFSMNT_PQUOTAENF 0x00000040 /* IRIX project quota limit | 69 | #define XFSMNT_PQUOTAENF 0x00000040 /* IRIX project quota limit |
70 | * enforcement */ | 70 | * enforcement */ |
71 | #define XFSMNT_NOATIME 0x00000100 /* don't modify access | ||
72 | * times on reads */ | ||
73 | #define XFSMNT_NOALIGN 0x00000200 /* don't allocate at | 71 | #define XFSMNT_NOALIGN 0x00000200 /* don't allocate at |
74 | * stripe boundaries*/ | 72 | * stripe boundaries*/ |
75 | #define XFSMNT_RETERR 0x00000400 /* return error to user */ | 73 | #define XFSMNT_RETERR 0x00000400 /* return error to user */ |
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 473671fa5c13..4bae3a76c678 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -126,10 +126,10 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, | |||
126 | node = bp->data; | 126 | node = bp->data; |
127 | node->hdr.info.forw = 0; | 127 | node->hdr.info.forw = 0; |
128 | node->hdr.info.back = 0; | 128 | node->hdr.info.back = 0; |
129 | INT_SET(node->hdr.info.magic, ARCH_CONVERT, XFS_DA_NODE_MAGIC); | 129 | node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC); |
130 | node->hdr.info.pad = 0; | 130 | node->hdr.info.pad = 0; |
131 | node->hdr.count = 0; | 131 | node->hdr.count = 0; |
132 | INT_SET(node->hdr.level, ARCH_CONVERT, level); | 132 | node->hdr.level = cpu_to_be16(level); |
133 | 133 | ||
134 | xfs_da_log_buf(tp, bp, | 134 | xfs_da_log_buf(tp, bp, |
135 | XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); | 135 | XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); |
@@ -290,28 +290,28 @@ xfs_da_split(xfs_da_state_t *state) | |||
290 | 290 | ||
291 | node = oldblk->bp->data; | 291 | node = oldblk->bp->data; |
292 | if (node->hdr.info.forw) { | 292 | if (node->hdr.info.forw) { |
293 | if (INT_GET(node->hdr.info.forw, ARCH_CONVERT) == addblk->blkno) { | 293 | if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) { |
294 | bp = addblk->bp; | 294 | bp = addblk->bp; |
295 | } else { | 295 | } else { |
296 | ASSERT(state->extravalid); | 296 | ASSERT(state->extravalid); |
297 | bp = state->extrablk.bp; | 297 | bp = state->extrablk.bp; |
298 | } | 298 | } |
299 | node = bp->data; | 299 | node = bp->data; |
300 | INT_SET(node->hdr.info.back, ARCH_CONVERT, oldblk->blkno); | 300 | node->hdr.info.back = cpu_to_be32(oldblk->blkno); |
301 | xfs_da_log_buf(state->args->trans, bp, | 301 | xfs_da_log_buf(state->args->trans, bp, |
302 | XFS_DA_LOGRANGE(node, &node->hdr.info, | 302 | XFS_DA_LOGRANGE(node, &node->hdr.info, |
303 | sizeof(node->hdr.info))); | 303 | sizeof(node->hdr.info))); |
304 | } | 304 | } |
305 | node = oldblk->bp->data; | 305 | node = oldblk->bp->data; |
306 | if (INT_GET(node->hdr.info.back, ARCH_CONVERT)) { | 306 | if (node->hdr.info.back) { |
307 | if (INT_GET(node->hdr.info.back, ARCH_CONVERT) == addblk->blkno) { | 307 | if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) { |
308 | bp = addblk->bp; | 308 | bp = addblk->bp; |
309 | } else { | 309 | } else { |
310 | ASSERT(state->extravalid); | 310 | ASSERT(state->extravalid); |
311 | bp = state->extrablk.bp; | 311 | bp = state->extrablk.bp; |
312 | } | 312 | } |
313 | node = bp->data; | 313 | node = bp->data; |
314 | INT_SET(node->hdr.info.forw, ARCH_CONVERT, oldblk->blkno); | 314 | node->hdr.info.forw = cpu_to_be32(oldblk->blkno); |
315 | xfs_da_log_buf(state->args->trans, bp, | 315 | xfs_da_log_buf(state->args->trans, bp, |
316 | XFS_DA_LOGRANGE(node, &node->hdr.info, | 316 | XFS_DA_LOGRANGE(node, &node->hdr.info, |
317 | sizeof(node->hdr.info))); | 317 | sizeof(node->hdr.info))); |
@@ -359,14 +359,14 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
359 | ASSERT(bp != NULL); | 359 | ASSERT(bp != NULL); |
360 | node = bp->data; | 360 | node = bp->data; |
361 | oldroot = blk1->bp->data; | 361 | oldroot = blk1->bp->data; |
362 | if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 362 | if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) { |
363 | size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] - | 363 | size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] - |
364 | (char *)oldroot); | 364 | (char *)oldroot); |
365 | } else { | 365 | } else { |
366 | ASSERT(XFS_DIR_IS_V2(mp)); | 366 | ASSERT(XFS_DIR_IS_V2(mp)); |
367 | ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 367 | ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
368 | leaf = (xfs_dir2_leaf_t *)oldroot; | 368 | leaf = (xfs_dir2_leaf_t *)oldroot; |
369 | size = (int)((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] - | 369 | size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] - |
370 | (char *)leaf); | 370 | (char *)leaf); |
371 | } | 371 | } |
372 | memcpy(node, oldroot, size); | 372 | memcpy(node, oldroot, size); |
@@ -381,18 +381,18 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
381 | error = xfs_da_node_create(args, | 381 | error = xfs_da_node_create(args, |
382 | args->whichfork == XFS_DATA_FORK && | 382 | args->whichfork == XFS_DATA_FORK && |
383 | XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0, | 383 | XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0, |
384 | INT_GET(node->hdr.level, ARCH_CONVERT) + 1, &bp, args->whichfork); | 384 | be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork); |
385 | if (error) | 385 | if (error) |
386 | return(error); | 386 | return(error); |
387 | node = bp->data; | 387 | node = bp->data; |
388 | INT_SET(node->btree[0].hashval, ARCH_CONVERT, blk1->hashval); | 388 | node->btree[0].hashval = cpu_to_be32(blk1->hashval); |
389 | INT_SET(node->btree[0].before, ARCH_CONVERT, blk1->blkno); | 389 | node->btree[0].before = cpu_to_be32(blk1->blkno); |
390 | INT_SET(node->btree[1].hashval, ARCH_CONVERT, blk2->hashval); | 390 | node->btree[1].hashval = cpu_to_be32(blk2->hashval); |
391 | INT_SET(node->btree[1].before, ARCH_CONVERT, blk2->blkno); | 391 | node->btree[1].before = cpu_to_be32(blk2->blkno); |
392 | INT_SET(node->hdr.count, ARCH_CONVERT, 2); | 392 | node->hdr.count = cpu_to_be16(2); |
393 | 393 | ||
394 | #ifdef DEBUG | 394 | #ifdef DEBUG |
395 | if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { | 395 | if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) { |
396 | ASSERT(blk1->blkno >= mp->m_dirleafblk && | 396 | ASSERT(blk1->blkno >= mp->m_dirleafblk && |
397 | blk1->blkno < mp->m_dirfreeblk); | 397 | blk1->blkno < mp->m_dirfreeblk); |
398 | ASSERT(blk2->blkno >= mp->m_dirleafblk && | 398 | ASSERT(blk2->blkno >= mp->m_dirleafblk && |
@@ -424,7 +424,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
424 | int useextra; | 424 | int useextra; |
425 | 425 | ||
426 | node = oldblk->bp->data; | 426 | node = oldblk->bp->data; |
427 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 427 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
428 | 428 | ||
429 | /* | 429 | /* |
430 | * With V2 the extra block is data or freespace. | 430 | * With V2 the extra block is data or freespace. |
@@ -435,7 +435,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
435 | /* | 435 | /* |
436 | * Do we have to split the node? | 436 | * Do we have to split the node? |
437 | */ | 437 | */ |
438 | if ((INT_GET(node->hdr.count, ARCH_CONVERT) + newcount) > state->node_ents) { | 438 | if ((be16_to_cpu(node->hdr.count) + newcount) > state->node_ents) { |
439 | /* | 439 | /* |
440 | * Allocate a new node, add to the doubly linked chain of | 440 | * Allocate a new node, add to the doubly linked chain of |
441 | * nodes, then move some of our excess entries into it. | 441 | * nodes, then move some of our excess entries into it. |
@@ -472,7 +472,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
472 | * If we had double-split op below us, then add the extra block too. | 472 | * If we had double-split op below us, then add the extra block too. |
473 | */ | 473 | */ |
474 | node = oldblk->bp->data; | 474 | node = oldblk->bp->data; |
475 | if (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT)) { | 475 | if (oldblk->index <= be16_to_cpu(node->hdr.count)) { |
476 | oldblk->index++; | 476 | oldblk->index++; |
477 | xfs_da_node_add(state, oldblk, addblk); | 477 | xfs_da_node_add(state, oldblk, addblk); |
478 | if (useextra) { | 478 | if (useextra) { |
@@ -516,17 +516,17 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
516 | * Figure out how many entries need to move, and in which direction. | 516 | * Figure out how many entries need to move, and in which direction. |
517 | * Swap the nodes around if that makes it simpler. | 517 | * Swap the nodes around if that makes it simpler. |
518 | */ | 518 | */ |
519 | if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && | 519 | if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) && |
520 | ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || | 520 | ((be32_to_cpu(node2->btree[0].hashval) < be32_to_cpu(node1->btree[0].hashval)) || |
521 | (INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < | 521 | (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) < |
522 | INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) { | 522 | be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) { |
523 | tmpnode = node1; | 523 | tmpnode = node1; |
524 | node1 = node2; | 524 | node1 = node2; |
525 | node2 = tmpnode; | 525 | node2 = tmpnode; |
526 | } | 526 | } |
527 | ASSERT(INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 527 | ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
528 | ASSERT(INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 528 | ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
529 | count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2; | 529 | count = (be16_to_cpu(node1->hdr.count) - be16_to_cpu(node2->hdr.count)) / 2; |
530 | if (count == 0) | 530 | if (count == 0) |
531 | return; | 531 | return; |
532 | tp = state->args->trans; | 532 | tp = state->args->trans; |
@@ -537,7 +537,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
537 | /* | 537 | /* |
538 | * Move elements in node2 up to make a hole. | 538 | * Move elements in node2 up to make a hole. |
539 | */ | 539 | */ |
540 | if ((tmp = INT_GET(node2->hdr.count, ARCH_CONVERT)) > 0) { | 540 | if ((tmp = be16_to_cpu(node2->hdr.count)) > 0) { |
541 | tmp *= (uint)sizeof(xfs_da_node_entry_t); | 541 | tmp *= (uint)sizeof(xfs_da_node_entry_t); |
542 | btree_s = &node2->btree[0]; | 542 | btree_s = &node2->btree[0]; |
543 | btree_d = &node2->btree[count]; | 543 | btree_d = &node2->btree[count]; |
@@ -548,13 +548,12 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
548 | * Move the req'd B-tree elements from high in node1 to | 548 | * Move the req'd B-tree elements from high in node1 to |
549 | * low in node2. | 549 | * low in node2. |
550 | */ | 550 | */ |
551 | INT_MOD(node2->hdr.count, ARCH_CONVERT, count); | 551 | be16_add(&node2->hdr.count, count); |
552 | tmp = count * (uint)sizeof(xfs_da_node_entry_t); | 552 | tmp = count * (uint)sizeof(xfs_da_node_entry_t); |
553 | btree_s = &node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT) - count]; | 553 | btree_s = &node1->btree[be16_to_cpu(node1->hdr.count) - count]; |
554 | btree_d = &node2->btree[0]; | 554 | btree_d = &node2->btree[0]; |
555 | memcpy(btree_d, btree_s, tmp); | 555 | memcpy(btree_d, btree_s, tmp); |
556 | INT_MOD(node1->hdr.count, ARCH_CONVERT, -(count)); | 556 | be16_add(&node1->hdr.count, -count); |
557 | |||
558 | } else { | 557 | } else { |
559 | /* | 558 | /* |
560 | * Move the req'd B-tree elements from low in node2 to | 559 | * Move the req'd B-tree elements from low in node2 to |
@@ -563,21 +562,21 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
563 | count = -count; | 562 | count = -count; |
564 | tmp = count * (uint)sizeof(xfs_da_node_entry_t); | 563 | tmp = count * (uint)sizeof(xfs_da_node_entry_t); |
565 | btree_s = &node2->btree[0]; | 564 | btree_s = &node2->btree[0]; |
566 | btree_d = &node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT)]; | 565 | btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)]; |
567 | memcpy(btree_d, btree_s, tmp); | 566 | memcpy(btree_d, btree_s, tmp); |
568 | INT_MOD(node1->hdr.count, ARCH_CONVERT, count); | 567 | be16_add(&node1->hdr.count, count); |
569 | xfs_da_log_buf(tp, blk1->bp, | 568 | xfs_da_log_buf(tp, blk1->bp, |
570 | XFS_DA_LOGRANGE(node1, btree_d, tmp)); | 569 | XFS_DA_LOGRANGE(node1, btree_d, tmp)); |
571 | 570 | ||
572 | /* | 571 | /* |
573 | * Move elements in node2 down to fill the hole. | 572 | * Move elements in node2 down to fill the hole. |
574 | */ | 573 | */ |
575 | tmp = INT_GET(node2->hdr.count, ARCH_CONVERT) - count; | 574 | tmp = be16_to_cpu(node2->hdr.count) - count; |
576 | tmp *= (uint)sizeof(xfs_da_node_entry_t); | 575 | tmp *= (uint)sizeof(xfs_da_node_entry_t); |
577 | btree_s = &node2->btree[count]; | 576 | btree_s = &node2->btree[count]; |
578 | btree_d = &node2->btree[0]; | 577 | btree_d = &node2->btree[0]; |
579 | memmove(btree_d, btree_s, tmp); | 578 | memmove(btree_d, btree_s, tmp); |
580 | INT_MOD(node2->hdr.count, ARCH_CONVERT, -(count)); | 579 | be16_add(&node2->hdr.count, -count); |
581 | } | 580 | } |
582 | 581 | ||
583 | /* | 582 | /* |
@@ -588,7 +587,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
588 | xfs_da_log_buf(tp, blk2->bp, | 587 | xfs_da_log_buf(tp, blk2->bp, |
589 | XFS_DA_LOGRANGE(node2, &node2->hdr, | 588 | XFS_DA_LOGRANGE(node2, &node2->hdr, |
590 | sizeof(node2->hdr) + | 589 | sizeof(node2->hdr) + |
591 | sizeof(node2->btree[0]) * INT_GET(node2->hdr.count, ARCH_CONVERT))); | 590 | sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count))); |
592 | 591 | ||
593 | /* | 592 | /* |
594 | * Record the last hashval from each block for upward propagation. | 593 | * Record the last hashval from each block for upward propagation. |
@@ -596,15 +595,15 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
596 | */ | 595 | */ |
597 | node1 = blk1->bp->data; | 596 | node1 = blk1->bp->data; |
598 | node2 = blk2->bp->data; | 597 | node2 = blk2->bp->data; |
599 | blk1->hashval = INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 598 | blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval); |
600 | blk2->hashval = INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 599 | blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval); |
601 | 600 | ||
602 | /* | 601 | /* |
603 | * Adjust the expected index for insertion. | 602 | * Adjust the expected index for insertion. |
604 | */ | 603 | */ |
605 | if (blk1->index >= INT_GET(node1->hdr.count, ARCH_CONVERT)) { | 604 | if (blk1->index >= be16_to_cpu(node1->hdr.count)) { |
606 | blk2->index = blk1->index - INT_GET(node1->hdr.count, ARCH_CONVERT); | 605 | blk2->index = blk1->index - be16_to_cpu(node1->hdr.count); |
607 | blk1->index = INT_GET(node1->hdr.count, ARCH_CONVERT) + 1; /* make it invalid */ | 606 | blk1->index = be16_to_cpu(node1->hdr.count) + 1; /* make it invalid */ |
608 | } | 607 | } |
609 | } | 608 | } |
610 | 609 | ||
@@ -622,8 +621,8 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
622 | 621 | ||
623 | node = oldblk->bp->data; | 622 | node = oldblk->bp->data; |
624 | mp = state->mp; | 623 | mp = state->mp; |
625 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 624 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
626 | ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT))); | 625 | ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); |
627 | ASSERT(newblk->blkno != 0); | 626 | ASSERT(newblk->blkno != 0); |
628 | if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) | 627 | if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) |
629 | ASSERT(newblk->blkno >= mp->m_dirleafblk && | 628 | ASSERT(newblk->blkno >= mp->m_dirleafblk && |
@@ -634,22 +633,22 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
634 | */ | 633 | */ |
635 | tmp = 0; | 634 | tmp = 0; |
636 | btree = &node->btree[ oldblk->index ]; | 635 | btree = &node->btree[ oldblk->index ]; |
637 | if (oldblk->index < INT_GET(node->hdr.count, ARCH_CONVERT)) { | 636 | if (oldblk->index < be16_to_cpu(node->hdr.count)) { |
638 | tmp = (INT_GET(node->hdr.count, ARCH_CONVERT) - oldblk->index) * (uint)sizeof(*btree); | 637 | tmp = (be16_to_cpu(node->hdr.count) - oldblk->index) * (uint)sizeof(*btree); |
639 | memmove(btree + 1, btree, tmp); | 638 | memmove(btree + 1, btree, tmp); |
640 | } | 639 | } |
641 | INT_SET(btree->hashval, ARCH_CONVERT, newblk->hashval); | 640 | btree->hashval = cpu_to_be32(newblk->hashval); |
642 | INT_SET(btree->before, ARCH_CONVERT, newblk->blkno); | 641 | btree->before = cpu_to_be32(newblk->blkno); |
643 | xfs_da_log_buf(state->args->trans, oldblk->bp, | 642 | xfs_da_log_buf(state->args->trans, oldblk->bp, |
644 | XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree))); | 643 | XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree))); |
645 | INT_MOD(node->hdr.count, ARCH_CONVERT, +1); | 644 | be16_add(&node->hdr.count, 1); |
646 | xfs_da_log_buf(state->args->trans, oldblk->bp, | 645 | xfs_da_log_buf(state->args->trans, oldblk->bp, |
647 | XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); | 646 | XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); |
648 | 647 | ||
649 | /* | 648 | /* |
650 | * Copy the last hash value from the oldblk to propagate upwards. | 649 | * Copy the last hash value from the oldblk to propagate upwards. |
651 | */ | 650 | */ |
652 | oldblk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 651 | oldblk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1 ].hashval); |
653 | } | 652 | } |
654 | 653 | ||
655 | /*======================================================================== | 654 | /*======================================================================== |
@@ -768,21 +767,21 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | |||
768 | ASSERT(args != NULL); | 767 | ASSERT(args != NULL); |
769 | ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); | 768 | ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); |
770 | oldroot = root_blk->bp->data; | 769 | oldroot = root_blk->bp->data; |
771 | ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 770 | ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
772 | ASSERT(!oldroot->hdr.info.forw); | 771 | ASSERT(!oldroot->hdr.info.forw); |
773 | ASSERT(!oldroot->hdr.info.back); | 772 | ASSERT(!oldroot->hdr.info.back); |
774 | 773 | ||
775 | /* | 774 | /* |
776 | * If the root has more than one child, then don't do anything. | 775 | * If the root has more than one child, then don't do anything. |
777 | */ | 776 | */ |
778 | if (INT_GET(oldroot->hdr.count, ARCH_CONVERT) > 1) | 777 | if (be16_to_cpu(oldroot->hdr.count) > 1) |
779 | return(0); | 778 | return(0); |
780 | 779 | ||
781 | /* | 780 | /* |
782 | * Read in the (only) child block, then copy those bytes into | 781 | * Read in the (only) child block, then copy those bytes into |
783 | * the root block's buffer and free the original child block. | 782 | * the root block's buffer and free the original child block. |
784 | */ | 783 | */ |
785 | child = INT_GET(oldroot->btree[ 0 ].before, ARCH_CONVERT); | 784 | child = be32_to_cpu(oldroot->btree[0].before); |
786 | ASSERT(child != 0); | 785 | ASSERT(child != 0); |
787 | error = xfs_da_read_buf(args->trans, args->dp, child, -1, &bp, | 786 | error = xfs_da_read_buf(args->trans, args->dp, child, -1, &bp, |
788 | args->whichfork); | 787 | args->whichfork); |
@@ -790,11 +789,11 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | |||
790 | return(error); | 789 | return(error); |
791 | ASSERT(bp != NULL); | 790 | ASSERT(bp != NULL); |
792 | blkinfo = bp->data; | 791 | blkinfo = bp->data; |
793 | if (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) { | 792 | if (be16_to_cpu(oldroot->hdr.level) == 1) { |
794 | ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 793 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || |
795 | INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 794 | be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC); |
796 | } else { | 795 | } else { |
797 | ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 796 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC); |
798 | } | 797 | } |
799 | ASSERT(!blkinfo->forw); | 798 | ASSERT(!blkinfo->forw); |
800 | ASSERT(!blkinfo->back); | 799 | ASSERT(!blkinfo->back); |
@@ -830,9 +829,9 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
830 | */ | 829 | */ |
831 | blk = &state->path.blk[ state->path.active-1 ]; | 830 | blk = &state->path.blk[ state->path.active-1 ]; |
832 | info = blk->bp->data; | 831 | info = blk->bp->data; |
833 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 832 | ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC); |
834 | node = (xfs_da_intnode_t *)info; | 833 | node = (xfs_da_intnode_t *)info; |
835 | count = INT_GET(node->hdr.count, ARCH_CONVERT); | 834 | count = be16_to_cpu(node->hdr.count); |
836 | if (count > (state->node_ents >> 1)) { | 835 | if (count > (state->node_ents >> 1)) { |
837 | *action = 0; /* blk over 50%, don't try to join */ | 836 | *action = 0; /* blk over 50%, don't try to join */ |
838 | return(0); /* blk over 50%, don't try to join */ | 837 | return(0); /* blk over 50%, don't try to join */ |
@@ -849,7 +848,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
849 | * Make altpath point to the block we want to keep and | 848 | * Make altpath point to the block we want to keep and |
850 | * path point to the block we want to drop (this one). | 849 | * path point to the block we want to drop (this one). |
851 | */ | 850 | */ |
852 | forward = info->forw; | 851 | forward = (info->forw != 0); |
853 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 852 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
854 | error = xfs_da_path_shift(state, &state->altpath, forward, | 853 | error = xfs_da_path_shift(state, &state->altpath, forward, |
855 | 0, &retval); | 854 | 0, &retval); |
@@ -871,13 +870,12 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
871 | * to shrink a directory over time. | 870 | * to shrink a directory over time. |
872 | */ | 871 | */ |
873 | /* start with smaller blk num */ | 872 | /* start with smaller blk num */ |
874 | forward = (INT_GET(info->forw, ARCH_CONVERT) | 873 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); |
875 | < INT_GET(info->back, ARCH_CONVERT)); | ||
876 | for (i = 0; i < 2; forward = !forward, i++) { | 874 | for (i = 0; i < 2; forward = !forward, i++) { |
877 | if (forward) | 875 | if (forward) |
878 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 876 | blkno = be32_to_cpu(info->forw); |
879 | else | 877 | else |
880 | blkno = INT_GET(info->back, ARCH_CONVERT); | 878 | blkno = be32_to_cpu(info->back); |
881 | if (blkno == 0) | 879 | if (blkno == 0) |
882 | continue; | 880 | continue; |
883 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 881 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -889,10 +887,10 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
889 | node = (xfs_da_intnode_t *)info; | 887 | node = (xfs_da_intnode_t *)info; |
890 | count = state->node_ents; | 888 | count = state->node_ents; |
891 | count -= state->node_ents >> 2; | 889 | count -= state->node_ents >> 2; |
892 | count -= INT_GET(node->hdr.count, ARCH_CONVERT); | 890 | count -= be16_to_cpu(node->hdr.count); |
893 | node = bp->data; | 891 | node = bp->data; |
894 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 892 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
895 | count -= INT_GET(node->hdr.count, ARCH_CONVERT); | 893 | count -= be16_to_cpu(node->hdr.count); |
896 | xfs_da_brelse(state->args->trans, bp); | 894 | xfs_da_brelse(state->args->trans, bp); |
897 | if (count >= 0) | 895 | if (count >= 0) |
898 | break; /* fits with at least 25% to spare */ | 896 | break; /* fits with at least 25% to spare */ |
@@ -973,16 +971,16 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) | |||
973 | } | 971 | } |
974 | for (blk--, level--; level >= 0; blk--, level--) { | 972 | for (blk--, level--; level >= 0; blk--, level--) { |
975 | node = blk->bp->data; | 973 | node = blk->bp->data; |
976 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 974 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
977 | btree = &node->btree[ blk->index ]; | 975 | btree = &node->btree[ blk->index ]; |
978 | if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash) | 976 | if (be32_to_cpu(btree->hashval) == lasthash) |
979 | break; | 977 | break; |
980 | blk->hashval = lasthash; | 978 | blk->hashval = lasthash; |
981 | INT_SET(btree->hashval, ARCH_CONVERT, lasthash); | 979 | btree->hashval = cpu_to_be32(lasthash); |
982 | xfs_da_log_buf(state->args->trans, blk->bp, | 980 | xfs_da_log_buf(state->args->trans, blk->bp, |
983 | XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); | 981 | XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); |
984 | 982 | ||
985 | lasthash = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 983 | lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); |
986 | } | 984 | } |
987 | } | 985 | } |
988 | 986 | ||
@@ -997,25 +995,25 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk) | |||
997 | int tmp; | 995 | int tmp; |
998 | 996 | ||
999 | node = drop_blk->bp->data; | 997 | node = drop_blk->bp->data; |
1000 | ASSERT(drop_blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)); | 998 | ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count)); |
1001 | ASSERT(drop_blk->index >= 0); | 999 | ASSERT(drop_blk->index >= 0); |
1002 | 1000 | ||
1003 | /* | 1001 | /* |
1004 | * Copy over the offending entry, or just zero it out. | 1002 | * Copy over the offending entry, or just zero it out. |
1005 | */ | 1003 | */ |
1006 | btree = &node->btree[drop_blk->index]; | 1004 | btree = &node->btree[drop_blk->index]; |
1007 | if (drop_blk->index < (INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { | 1005 | if (drop_blk->index < (be16_to_cpu(node->hdr.count)-1)) { |
1008 | tmp = INT_GET(node->hdr.count, ARCH_CONVERT) - drop_blk->index - 1; | 1006 | tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1; |
1009 | tmp *= (uint)sizeof(xfs_da_node_entry_t); | 1007 | tmp *= (uint)sizeof(xfs_da_node_entry_t); |
1010 | memmove(btree, btree + 1, tmp); | 1008 | memmove(btree, btree + 1, tmp); |
1011 | xfs_da_log_buf(state->args->trans, drop_blk->bp, | 1009 | xfs_da_log_buf(state->args->trans, drop_blk->bp, |
1012 | XFS_DA_LOGRANGE(node, btree, tmp)); | 1010 | XFS_DA_LOGRANGE(node, btree, tmp)); |
1013 | btree = &node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ]; | 1011 | btree = &node->btree[be16_to_cpu(node->hdr.count)-1]; |
1014 | } | 1012 | } |
1015 | memset((char *)btree, 0, sizeof(xfs_da_node_entry_t)); | 1013 | memset((char *)btree, 0, sizeof(xfs_da_node_entry_t)); |
1016 | xfs_da_log_buf(state->args->trans, drop_blk->bp, | 1014 | xfs_da_log_buf(state->args->trans, drop_blk->bp, |
1017 | XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); | 1015 | XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); |
1018 | INT_MOD(node->hdr.count, ARCH_CONVERT, -1); | 1016 | be16_add(&node->hdr.count, -1); |
1019 | xfs_da_log_buf(state->args->trans, drop_blk->bp, | 1017 | xfs_da_log_buf(state->args->trans, drop_blk->bp, |
1020 | XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); | 1018 | XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); |
1021 | 1019 | ||
@@ -1023,7 +1021,7 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk) | |||
1023 | * Copy the last hash value from the block to propagate upwards. | 1021 | * Copy the last hash value from the block to propagate upwards. |
1024 | */ | 1022 | */ |
1025 | btree--; | 1023 | btree--; |
1026 | drop_blk->hashval = INT_GET(btree->hashval, ARCH_CONVERT); | 1024 | drop_blk->hashval = be32_to_cpu(btree->hashval); |
1027 | } | 1025 | } |
1028 | 1026 | ||
1029 | /* | 1027 | /* |
@@ -1041,40 +1039,40 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1041 | 1039 | ||
1042 | drop_node = drop_blk->bp->data; | 1040 | drop_node = drop_blk->bp->data; |
1043 | save_node = save_blk->bp->data; | 1041 | save_node = save_blk->bp->data; |
1044 | ASSERT(INT_GET(drop_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1042 | ASSERT(be16_to_cpu(drop_node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1045 | ASSERT(INT_GET(save_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1043 | ASSERT(be16_to_cpu(save_node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1046 | tp = state->args->trans; | 1044 | tp = state->args->trans; |
1047 | 1045 | ||
1048 | /* | 1046 | /* |
1049 | * If the dying block has lower hashvals, then move all the | 1047 | * If the dying block has lower hashvals, then move all the |
1050 | * elements in the remaining block up to make a hole. | 1048 | * elements in the remaining block up to make a hole. |
1051 | */ | 1049 | */ |
1052 | if ((INT_GET(drop_node->btree[ 0 ].hashval, ARCH_CONVERT) < INT_GET(save_node->btree[ 0 ].hashval, ARCH_CONVERT)) || | 1050 | if ((be32_to_cpu(drop_node->btree[0].hashval) < be32_to_cpu(save_node->btree[ 0 ].hashval)) || |
1053 | (INT_GET(drop_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < | 1051 | (be32_to_cpu(drop_node->btree[be16_to_cpu(drop_node->hdr.count)-1].hashval) < |
1054 | INT_GET(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT))) | 1052 | be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval))) |
1055 | { | 1053 | { |
1056 | btree = &save_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT) ]; | 1054 | btree = &save_node->btree[be16_to_cpu(drop_node->hdr.count)]; |
1057 | tmp = INT_GET(save_node->hdr.count, ARCH_CONVERT) * (uint)sizeof(xfs_da_node_entry_t); | 1055 | tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t); |
1058 | memmove(btree, &save_node->btree[0], tmp); | 1056 | memmove(btree, &save_node->btree[0], tmp); |
1059 | btree = &save_node->btree[0]; | 1057 | btree = &save_node->btree[0]; |
1060 | xfs_da_log_buf(tp, save_blk->bp, | 1058 | xfs_da_log_buf(tp, save_blk->bp, |
1061 | XFS_DA_LOGRANGE(save_node, btree, | 1059 | XFS_DA_LOGRANGE(save_node, btree, |
1062 | (INT_GET(save_node->hdr.count, ARCH_CONVERT) + INT_GET(drop_node->hdr.count, ARCH_CONVERT)) * | 1060 | (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) * |
1063 | sizeof(xfs_da_node_entry_t))); | 1061 | sizeof(xfs_da_node_entry_t))); |
1064 | } else { | 1062 | } else { |
1065 | btree = &save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT) ]; | 1063 | btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)]; |
1066 | xfs_da_log_buf(tp, save_blk->bp, | 1064 | xfs_da_log_buf(tp, save_blk->bp, |
1067 | XFS_DA_LOGRANGE(save_node, btree, | 1065 | XFS_DA_LOGRANGE(save_node, btree, |
1068 | INT_GET(drop_node->hdr.count, ARCH_CONVERT) * | 1066 | be16_to_cpu(drop_node->hdr.count) * |
1069 | sizeof(xfs_da_node_entry_t))); | 1067 | sizeof(xfs_da_node_entry_t))); |
1070 | } | 1068 | } |
1071 | 1069 | ||
1072 | /* | 1070 | /* |
1073 | * Move all the B-tree elements from drop_blk to save_blk. | 1071 | * Move all the B-tree elements from drop_blk to save_blk. |
1074 | */ | 1072 | */ |
1075 | tmp = INT_GET(drop_node->hdr.count, ARCH_CONVERT) * (uint)sizeof(xfs_da_node_entry_t); | 1073 | tmp = be16_to_cpu(drop_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t); |
1076 | memcpy(btree, &drop_node->btree[0], tmp); | 1074 | memcpy(btree, &drop_node->btree[0], tmp); |
1077 | INT_MOD(save_node->hdr.count, ARCH_CONVERT, INT_GET(drop_node->hdr.count, ARCH_CONVERT)); | 1075 | be16_add(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count)); |
1078 | 1076 | ||
1079 | xfs_da_log_buf(tp, save_blk->bp, | 1077 | xfs_da_log_buf(tp, save_blk->bp, |
1080 | XFS_DA_LOGRANGE(save_node, &save_node->hdr, | 1078 | XFS_DA_LOGRANGE(save_node, &save_node->hdr, |
@@ -1083,7 +1081,7 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1083 | /* | 1081 | /* |
1084 | * Save the last hashval in the remaining block for upward propagation. | 1082 | * Save the last hashval in the remaining block for upward propagation. |
1085 | */ | 1083 | */ |
1086 | save_blk->hashval = INT_GET(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 1084 | save_blk->hashval = be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval); |
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | /*======================================================================== | 1087 | /*======================================================================== |
@@ -1138,46 +1136,46 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1138 | return(error); | 1136 | return(error); |
1139 | } | 1137 | } |
1140 | curr = blk->bp->data; | 1138 | curr = blk->bp->data; |
1141 | ASSERT(INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || | 1139 | ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC || |
1142 | INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1140 | be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1143 | INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1141 | be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC); |
1144 | 1142 | ||
1145 | /* | 1143 | /* |
1146 | * Search an intermediate node for a match. | 1144 | * Search an intermediate node for a match. |
1147 | */ | 1145 | */ |
1148 | blk->magic = INT_GET(curr->magic, ARCH_CONVERT); | 1146 | blk->magic = be16_to_cpu(curr->magic); |
1149 | if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 1147 | if (blk->magic == XFS_DA_NODE_MAGIC) { |
1150 | node = blk->bp->data; | 1148 | node = blk->bp->data; |
1151 | blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 1149 | blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); |
1152 | 1150 | ||
1153 | /* | 1151 | /* |
1154 | * Binary search. (note: small blocks will skip loop) | 1152 | * Binary search. (note: small blocks will skip loop) |
1155 | */ | 1153 | */ |
1156 | max = INT_GET(node->hdr.count, ARCH_CONVERT); | 1154 | max = be16_to_cpu(node->hdr.count); |
1157 | probe = span = max / 2; | 1155 | probe = span = max / 2; |
1158 | hashval = args->hashval; | 1156 | hashval = args->hashval; |
1159 | for (btree = &node->btree[probe]; span > 4; | 1157 | for (btree = &node->btree[probe]; span > 4; |
1160 | btree = &node->btree[probe]) { | 1158 | btree = &node->btree[probe]) { |
1161 | span /= 2; | 1159 | span /= 2; |
1162 | if (INT_GET(btree->hashval, ARCH_CONVERT) < hashval) | 1160 | if (be32_to_cpu(btree->hashval) < hashval) |
1163 | probe += span; | 1161 | probe += span; |
1164 | else if (INT_GET(btree->hashval, ARCH_CONVERT) > hashval) | 1162 | else if (be32_to_cpu(btree->hashval) > hashval) |
1165 | probe -= span; | 1163 | probe -= span; |
1166 | else | 1164 | else |
1167 | break; | 1165 | break; |
1168 | } | 1166 | } |
1169 | ASSERT((probe >= 0) && (probe < max)); | 1167 | ASSERT((probe >= 0) && (probe < max)); |
1170 | ASSERT((span <= 4) || (INT_GET(btree->hashval, ARCH_CONVERT) == hashval)); | 1168 | ASSERT((span <= 4) || (be32_to_cpu(btree->hashval) == hashval)); |
1171 | 1169 | ||
1172 | /* | 1170 | /* |
1173 | * Since we may have duplicate hashval's, find the first | 1171 | * Since we may have duplicate hashval's, find the first |
1174 | * matching hashval in the node. | 1172 | * matching hashval in the node. |
1175 | */ | 1173 | */ |
1176 | while ((probe > 0) && (INT_GET(btree->hashval, ARCH_CONVERT) >= hashval)) { | 1174 | while ((probe > 0) && (be32_to_cpu(btree->hashval) >= hashval)) { |
1177 | btree--; | 1175 | btree--; |
1178 | probe--; | 1176 | probe--; |
1179 | } | 1177 | } |
1180 | while ((probe < max) && (INT_GET(btree->hashval, ARCH_CONVERT) < hashval)) { | 1178 | while ((probe < max) && (be32_to_cpu(btree->hashval) < hashval)) { |
1181 | btree++; | 1179 | btree++; |
1182 | probe++; | 1180 | probe++; |
1183 | } | 1181 | } |
@@ -1187,21 +1185,21 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1187 | */ | 1185 | */ |
1188 | if (probe == max) { | 1186 | if (probe == max) { |
1189 | blk->index = max-1; | 1187 | blk->index = max-1; |
1190 | blkno = INT_GET(node->btree[ max-1 ].before, ARCH_CONVERT); | 1188 | blkno = be32_to_cpu(node->btree[max-1].before); |
1191 | } else { | 1189 | } else { |
1192 | blk->index = probe; | 1190 | blk->index = probe; |
1193 | blkno = INT_GET(btree->before, ARCH_CONVERT); | 1191 | blkno = be32_to_cpu(btree->before); |
1194 | } | 1192 | } |
1195 | } | 1193 | } |
1196 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 1194 | else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) { |
1197 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); | 1195 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1198 | break; | 1196 | break; |
1199 | } | 1197 | } |
1200 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { | 1198 | else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) { |
1201 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); | 1199 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); |
1202 | break; | 1200 | break; |
1203 | } | 1201 | } |
1204 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { | 1202 | else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1205 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); | 1203 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); |
1206 | break; | 1204 | break; |
1207 | } | 1205 | } |
@@ -1274,8 +1272,8 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1274 | ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || | 1272 | ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || |
1275 | old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1273 | old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1276 | old_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1274 | old_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1277 | ASSERT(old_blk->magic == INT_GET(old_info->magic, ARCH_CONVERT)); | 1275 | ASSERT(old_blk->magic == be16_to_cpu(old_info->magic)); |
1278 | ASSERT(new_blk->magic == INT_GET(new_info->magic, ARCH_CONVERT)); | 1276 | ASSERT(new_blk->magic == be16_to_cpu(new_info->magic)); |
1279 | ASSERT(old_blk->magic == new_blk->magic); | 1277 | ASSERT(old_blk->magic == new_blk->magic); |
1280 | 1278 | ||
1281 | switch (old_blk->magic) { | 1279 | switch (old_blk->magic) { |
@@ -1302,47 +1300,44 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1302 | /* | 1300 | /* |
1303 | * Link new block in before existing block. | 1301 | * Link new block in before existing block. |
1304 | */ | 1302 | */ |
1305 | INT_SET(new_info->forw, ARCH_CONVERT, old_blk->blkno); | 1303 | new_info->forw = cpu_to_be32(old_blk->blkno); |
1306 | new_info->back = old_info->back; /* INT_: direct copy */ | 1304 | new_info->back = old_info->back; |
1307 | if (INT_GET(old_info->back, ARCH_CONVERT)) { | 1305 | if (old_info->back) { |
1308 | error = xfs_da_read_buf(args->trans, args->dp, | 1306 | error = xfs_da_read_buf(args->trans, args->dp, |
1309 | INT_GET(old_info->back, | 1307 | be32_to_cpu(old_info->back), |
1310 | ARCH_CONVERT), -1, &bp, | 1308 | -1, &bp, args->whichfork); |
1311 | args->whichfork); | ||
1312 | if (error) | 1309 | if (error) |
1313 | return(error); | 1310 | return(error); |
1314 | ASSERT(bp != NULL); | 1311 | ASSERT(bp != NULL); |
1315 | tmp_info = bp->data; | 1312 | tmp_info = bp->data; |
1316 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(old_info->magic, ARCH_CONVERT)); | 1313 | ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic)); |
1317 | ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == old_blk->blkno); | 1314 | ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno); |
1318 | INT_SET(tmp_info->forw, ARCH_CONVERT, new_blk->blkno); | 1315 | tmp_info->forw = cpu_to_be32(new_blk->blkno); |
1319 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); | 1316 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); |
1320 | xfs_da_buf_done(bp); | 1317 | xfs_da_buf_done(bp); |
1321 | } | 1318 | } |
1322 | INT_SET(old_info->back, ARCH_CONVERT, new_blk->blkno); | 1319 | old_info->back = cpu_to_be32(new_blk->blkno); |
1323 | } else { | 1320 | } else { |
1324 | /* | 1321 | /* |
1325 | * Link new block in after existing block. | 1322 | * Link new block in after existing block. |
1326 | */ | 1323 | */ |
1327 | new_info->forw = old_info->forw; /* INT_: direct copy */ | 1324 | new_info->forw = old_info->forw; |
1328 | INT_SET(new_info->back, ARCH_CONVERT, old_blk->blkno); | 1325 | new_info->back = cpu_to_be32(old_blk->blkno); |
1329 | if (INT_GET(old_info->forw, ARCH_CONVERT)) { | 1326 | if (old_info->forw) { |
1330 | error = xfs_da_read_buf(args->trans, args->dp, | 1327 | error = xfs_da_read_buf(args->trans, args->dp, |
1331 | INT_GET(old_info->forw, ARCH_CONVERT), -1, &bp, | 1328 | be32_to_cpu(old_info->forw), |
1332 | args->whichfork); | 1329 | -1, &bp, args->whichfork); |
1333 | if (error) | 1330 | if (error) |
1334 | return(error); | 1331 | return(error); |
1335 | ASSERT(bp != NULL); | 1332 | ASSERT(bp != NULL); |
1336 | tmp_info = bp->data; | 1333 | tmp_info = bp->data; |
1337 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) | 1334 | ASSERT(tmp_info->magic == old_info->magic); |
1338 | == INT_GET(old_info->magic, ARCH_CONVERT)); | 1335 | ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno); |
1339 | ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) | 1336 | tmp_info->back = cpu_to_be32(new_blk->blkno); |
1340 | == old_blk->blkno); | ||
1341 | INT_SET(tmp_info->back, ARCH_CONVERT, new_blk->blkno); | ||
1342 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); | 1337 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); |
1343 | xfs_da_buf_done(bp); | 1338 | xfs_da_buf_done(bp); |
1344 | } | 1339 | } |
1345 | INT_SET(old_info->forw, ARCH_CONVERT, new_blk->blkno); | 1340 | old_info->forw = cpu_to_be32(new_blk->blkno); |
1346 | } | 1341 | } |
1347 | 1342 | ||
1348 | xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); | 1343 | xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); |
@@ -1360,13 +1355,13 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp) | |||
1360 | 1355 | ||
1361 | node1 = node1_bp->data; | 1356 | node1 = node1_bp->data; |
1362 | node2 = node2_bp->data; | 1357 | node2 = node2_bp->data; |
1363 | ASSERT((INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) && | 1358 | ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) && |
1364 | (INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC)); | 1359 | (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC)); |
1365 | if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && | 1360 | if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) && |
1366 | ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < | 1361 | ((be32_to_cpu(node2->btree[0].hashval) < |
1367 | INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || | 1362 | be32_to_cpu(node1->btree[0].hashval)) || |
1368 | (INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < | 1363 | (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) < |
1369 | INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) { | 1364 | be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) { |
1370 | return(1); | 1365 | return(1); |
1371 | } | 1366 | } |
1372 | return(0); | 1367 | return(0); |
@@ -1381,12 +1376,12 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) | |||
1381 | xfs_da_intnode_t *node; | 1376 | xfs_da_intnode_t *node; |
1382 | 1377 | ||
1383 | node = bp->data; | 1378 | node = bp->data; |
1384 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1379 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1385 | if (count) | 1380 | if (count) |
1386 | *count = INT_GET(node->hdr.count, ARCH_CONVERT); | 1381 | *count = be16_to_cpu(node->hdr.count); |
1387 | if (!node->hdr.count) | 1382 | if (!node->hdr.count) |
1388 | return(0); | 1383 | return(0); |
1389 | return(INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); | 1384 | return be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); |
1390 | } | 1385 | } |
1391 | 1386 | ||
1392 | /* | 1387 | /* |
@@ -1411,50 +1406,47 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1411 | ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || | 1406 | ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || |
1412 | save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1407 | save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1413 | save_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1408 | save_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1414 | ASSERT(save_blk->magic == INT_GET(save_info->magic, ARCH_CONVERT)); | 1409 | ASSERT(save_blk->magic == be16_to_cpu(save_info->magic)); |
1415 | ASSERT(drop_blk->magic == INT_GET(drop_info->magic, ARCH_CONVERT)); | 1410 | ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic)); |
1416 | ASSERT(save_blk->magic == drop_blk->magic); | 1411 | ASSERT(save_blk->magic == drop_blk->magic); |
1417 | ASSERT((INT_GET(save_info->forw, ARCH_CONVERT) == drop_blk->blkno) || | 1412 | ASSERT((be32_to_cpu(save_info->forw) == drop_blk->blkno) || |
1418 | (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno)); | 1413 | (be32_to_cpu(save_info->back) == drop_blk->blkno)); |
1419 | ASSERT((INT_GET(drop_info->forw, ARCH_CONVERT) == save_blk->blkno) || | 1414 | ASSERT((be32_to_cpu(drop_info->forw) == save_blk->blkno) || |
1420 | (INT_GET(drop_info->back, ARCH_CONVERT) == save_blk->blkno)); | 1415 | (be32_to_cpu(drop_info->back) == save_blk->blkno)); |
1421 | 1416 | ||
1422 | /* | 1417 | /* |
1423 | * Unlink the leaf block from the doubly linked chain of leaves. | 1418 | * Unlink the leaf block from the doubly linked chain of leaves. |
1424 | */ | 1419 | */ |
1425 | if (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno) { | 1420 | if (be32_to_cpu(save_info->back) == drop_blk->blkno) { |
1426 | save_info->back = drop_info->back; /* INT_: direct copy */ | 1421 | save_info->back = drop_info->back; |
1427 | if (INT_GET(drop_info->back, ARCH_CONVERT)) { | 1422 | if (drop_info->back) { |
1428 | error = xfs_da_read_buf(args->trans, args->dp, | 1423 | error = xfs_da_read_buf(args->trans, args->dp, |
1429 | INT_GET(drop_info->back, | 1424 | be32_to_cpu(drop_info->back), |
1430 | ARCH_CONVERT), -1, &bp, | 1425 | -1, &bp, args->whichfork); |
1431 | args->whichfork); | ||
1432 | if (error) | 1426 | if (error) |
1433 | return(error); | 1427 | return(error); |
1434 | ASSERT(bp != NULL); | 1428 | ASSERT(bp != NULL); |
1435 | tmp_info = bp->data; | 1429 | tmp_info = bp->data; |
1436 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(save_info->magic, ARCH_CONVERT)); | 1430 | ASSERT(tmp_info->magic == save_info->magic); |
1437 | ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == drop_blk->blkno); | 1431 | ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno); |
1438 | INT_SET(tmp_info->forw, ARCH_CONVERT, save_blk->blkno); | 1432 | tmp_info->forw = cpu_to_be32(save_blk->blkno); |
1439 | xfs_da_log_buf(args->trans, bp, 0, | 1433 | xfs_da_log_buf(args->trans, bp, 0, |
1440 | sizeof(*tmp_info) - 1); | 1434 | sizeof(*tmp_info) - 1); |
1441 | xfs_da_buf_done(bp); | 1435 | xfs_da_buf_done(bp); |
1442 | } | 1436 | } |
1443 | } else { | 1437 | } else { |
1444 | save_info->forw = drop_info->forw; /* INT_: direct copy */ | 1438 | save_info->forw = drop_info->forw; |
1445 | if (INT_GET(drop_info->forw, ARCH_CONVERT)) { | 1439 | if (drop_info->forw) { |
1446 | error = xfs_da_read_buf(args->trans, args->dp, | 1440 | error = xfs_da_read_buf(args->trans, args->dp, |
1447 | INT_GET(drop_info->forw, ARCH_CONVERT), -1, &bp, | 1441 | be32_to_cpu(drop_info->forw), |
1448 | args->whichfork); | 1442 | -1, &bp, args->whichfork); |
1449 | if (error) | 1443 | if (error) |
1450 | return(error); | 1444 | return(error); |
1451 | ASSERT(bp != NULL); | 1445 | ASSERT(bp != NULL); |
1452 | tmp_info = bp->data; | 1446 | tmp_info = bp->data; |
1453 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) | 1447 | ASSERT(tmp_info->magic == save_info->magic); |
1454 | == INT_GET(save_info->magic, ARCH_CONVERT)); | 1448 | ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno); |
1455 | ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) | 1449 | tmp_info->back = cpu_to_be32(save_blk->blkno); |
1456 | == drop_blk->blkno); | ||
1457 | INT_SET(tmp_info->back, ARCH_CONVERT, save_blk->blkno); | ||
1458 | xfs_da_log_buf(args->trans, bp, 0, | 1450 | xfs_da_log_buf(args->trans, bp, 0, |
1459 | sizeof(*tmp_info) - 1); | 1451 | sizeof(*tmp_info) - 1); |
1460 | xfs_da_buf_done(bp); | 1452 | xfs_da_buf_done(bp); |
@@ -1497,14 +1489,14 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1497 | for (blk = &path->blk[level]; level >= 0; blk--, level--) { | 1489 | for (blk = &path->blk[level]; level >= 0; blk--, level--) { |
1498 | ASSERT(blk->bp != NULL); | 1490 | ASSERT(blk->bp != NULL); |
1499 | node = blk->bp->data; | 1491 | node = blk->bp->data; |
1500 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1492 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1501 | if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { | 1493 | if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) { |
1502 | blk->index++; | 1494 | blk->index++; |
1503 | blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); | 1495 | blkno = be32_to_cpu(node->btree[blk->index].before); |
1504 | break; | 1496 | break; |
1505 | } else if (!forward && (blk->index > 0)) { | 1497 | } else if (!forward && (blk->index > 0)) { |
1506 | blk->index--; | 1498 | blk->index--; |
1507 | blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); | 1499 | blkno = be32_to_cpu(node->btree[blk->index].before); |
1508 | break; | 1500 | break; |
1509 | } | 1501 | } |
1510 | } | 1502 | } |
@@ -1536,18 +1528,18 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1536 | return(error); | 1528 | return(error); |
1537 | ASSERT(blk->bp != NULL); | 1529 | ASSERT(blk->bp != NULL); |
1538 | info = blk->bp->data; | 1530 | info = blk->bp->data; |
1539 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || | 1531 | ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC || |
1540 | INT_GET(info->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1532 | be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1541 | INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1533 | be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); |
1542 | blk->magic = INT_GET(info->magic, ARCH_CONVERT); | 1534 | blk->magic = be16_to_cpu(info->magic); |
1543 | if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 1535 | if (blk->magic == XFS_DA_NODE_MAGIC) { |
1544 | node = (xfs_da_intnode_t *)info; | 1536 | node = (xfs_da_intnode_t *)info; |
1545 | blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 1537 | blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); |
1546 | if (forward) | 1538 | if (forward) |
1547 | blk->index = 0; | 1539 | blk->index = 0; |
1548 | else | 1540 | else |
1549 | blk->index = INT_GET(node->hdr.count, ARCH_CONVERT)-1; | 1541 | blk->index = be16_to_cpu(node->hdr.count)-1; |
1550 | blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); | 1542 | blkno = be32_to_cpu(node->btree[blk->index].before); |
1551 | } else { | 1543 | } else { |
1552 | ASSERT(level == path->active-1); | 1544 | ASSERT(level == path->active-1); |
1553 | blk->index = 0; | 1545 | blk->index = 0; |
@@ -1788,40 +1780,40 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1788 | /* | 1780 | /* |
1789 | * Get values from the moved block. | 1781 | * Get values from the moved block. |
1790 | */ | 1782 | */ |
1791 | if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { | 1783 | if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) { |
1792 | ASSERT(XFS_DIR_IS_V1(mp)); | 1784 | ASSERT(XFS_DIR_IS_V1(mp)); |
1793 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; | 1785 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; |
1794 | dead_level = 0; | 1786 | dead_level = 0; |
1795 | dead_hash = | 1787 | dead_hash = |
1796 | INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1788 | INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); |
1797 | } else if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { | 1789 | } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1798 | ASSERT(XFS_DIR_IS_V2(mp)); | 1790 | ASSERT(XFS_DIR_IS_V2(mp)); |
1799 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; | 1791 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; |
1800 | dead_level = 0; | 1792 | dead_level = 0; |
1801 | dead_hash = INT_GET(dead_leaf2->ents[INT_GET(dead_leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1793 | dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval); |
1802 | } else { | 1794 | } else { |
1803 | ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1795 | ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC); |
1804 | dead_node = (xfs_da_intnode_t *)dead_info; | 1796 | dead_node = (xfs_da_intnode_t *)dead_info; |
1805 | dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT); | 1797 | dead_level = be16_to_cpu(dead_node->hdr.level); |
1806 | dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1798 | dead_hash = be32_to_cpu(dead_node->btree[be16_to_cpu(dead_node->hdr.count) - 1].hashval); |
1807 | } | 1799 | } |
1808 | sib_buf = par_buf = NULL; | 1800 | sib_buf = par_buf = NULL; |
1809 | /* | 1801 | /* |
1810 | * If the moved block has a left sibling, fix up the pointers. | 1802 | * If the moved block has a left sibling, fix up the pointers. |
1811 | */ | 1803 | */ |
1812 | if ((sib_blkno = INT_GET(dead_info->back, ARCH_CONVERT))) { | 1804 | if ((sib_blkno = be32_to_cpu(dead_info->back))) { |
1813 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) | 1805 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) |
1814 | goto done; | 1806 | goto done; |
1815 | sib_info = sib_buf->data; | 1807 | sib_info = sib_buf->data; |
1816 | if (unlikely( | 1808 | if (unlikely( |
1817 | INT_GET(sib_info->forw, ARCH_CONVERT) != last_blkno || | 1809 | be32_to_cpu(sib_info->forw) != last_blkno || |
1818 | INT_GET(sib_info->magic, ARCH_CONVERT) != INT_GET(dead_info->magic, ARCH_CONVERT))) { | 1810 | sib_info->magic != dead_info->magic)) { |
1819 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", | 1811 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", |
1820 | XFS_ERRLEVEL_LOW, mp); | 1812 | XFS_ERRLEVEL_LOW, mp); |
1821 | error = XFS_ERROR(EFSCORRUPTED); | 1813 | error = XFS_ERROR(EFSCORRUPTED); |
1822 | goto done; | 1814 | goto done; |
1823 | } | 1815 | } |
1824 | INT_SET(sib_info->forw, ARCH_CONVERT, dead_blkno); | 1816 | sib_info->forw = cpu_to_be32(dead_blkno); |
1825 | xfs_da_log_buf(tp, sib_buf, | 1817 | xfs_da_log_buf(tp, sib_buf, |
1826 | XFS_DA_LOGRANGE(sib_info, &sib_info->forw, | 1818 | XFS_DA_LOGRANGE(sib_info, &sib_info->forw, |
1827 | sizeof(sib_info->forw))); | 1819 | sizeof(sib_info->forw))); |
@@ -1831,20 +1823,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1831 | /* | 1823 | /* |
1832 | * If the moved block has a right sibling, fix up the pointers. | 1824 | * If the moved block has a right sibling, fix up the pointers. |
1833 | */ | 1825 | */ |
1834 | if ((sib_blkno = INT_GET(dead_info->forw, ARCH_CONVERT))) { | 1826 | if ((sib_blkno = be32_to_cpu(dead_info->forw))) { |
1835 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) | 1827 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) |
1836 | goto done; | 1828 | goto done; |
1837 | sib_info = sib_buf->data; | 1829 | sib_info = sib_buf->data; |
1838 | if (unlikely( | 1830 | if (unlikely( |
1839 | INT_GET(sib_info->back, ARCH_CONVERT) != last_blkno | 1831 | be32_to_cpu(sib_info->back) != last_blkno || |
1840 | || INT_GET(sib_info->magic, ARCH_CONVERT) | 1832 | sib_info->magic != dead_info->magic)) { |
1841 | != INT_GET(dead_info->magic, ARCH_CONVERT))) { | ||
1842 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", | 1833 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", |
1843 | XFS_ERRLEVEL_LOW, mp); | 1834 | XFS_ERRLEVEL_LOW, mp); |
1844 | error = XFS_ERROR(EFSCORRUPTED); | 1835 | error = XFS_ERROR(EFSCORRUPTED); |
1845 | goto done; | 1836 | goto done; |
1846 | } | 1837 | } |
1847 | INT_SET(sib_info->back, ARCH_CONVERT, dead_blkno); | 1838 | sib_info->back = cpu_to_be32(dead_blkno); |
1848 | xfs_da_log_buf(tp, sib_buf, | 1839 | xfs_da_log_buf(tp, sib_buf, |
1849 | XFS_DA_LOGRANGE(sib_info, &sib_info->back, | 1840 | XFS_DA_LOGRANGE(sib_info, &sib_info->back, |
1850 | sizeof(sib_info->back))); | 1841 | sizeof(sib_info->back))); |
@@ -1861,26 +1852,26 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1861 | goto done; | 1852 | goto done; |
1862 | par_node = par_buf->data; | 1853 | par_node = par_buf->data; |
1863 | if (unlikely( | 1854 | if (unlikely( |
1864 | INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC || | 1855 | be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC || |
1865 | (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) { | 1856 | (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) { |
1866 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", | 1857 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", |
1867 | XFS_ERRLEVEL_LOW, mp); | 1858 | XFS_ERRLEVEL_LOW, mp); |
1868 | error = XFS_ERROR(EFSCORRUPTED); | 1859 | error = XFS_ERROR(EFSCORRUPTED); |
1869 | goto done; | 1860 | goto done; |
1870 | } | 1861 | } |
1871 | level = INT_GET(par_node->hdr.level, ARCH_CONVERT); | 1862 | level = be16_to_cpu(par_node->hdr.level); |
1872 | for (entno = 0; | 1863 | for (entno = 0; |
1873 | entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) && | 1864 | entno < be16_to_cpu(par_node->hdr.count) && |
1874 | INT_GET(par_node->btree[entno].hashval, ARCH_CONVERT) < dead_hash; | 1865 | be32_to_cpu(par_node->btree[entno].hashval) < dead_hash; |
1875 | entno++) | 1866 | entno++) |
1876 | continue; | 1867 | continue; |
1877 | if (unlikely(entno == INT_GET(par_node->hdr.count, ARCH_CONVERT))) { | 1868 | if (unlikely(entno == be16_to_cpu(par_node->hdr.count))) { |
1878 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)", | 1869 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)", |
1879 | XFS_ERRLEVEL_LOW, mp); | 1870 | XFS_ERRLEVEL_LOW, mp); |
1880 | error = XFS_ERROR(EFSCORRUPTED); | 1871 | error = XFS_ERROR(EFSCORRUPTED); |
1881 | goto done; | 1872 | goto done; |
1882 | } | 1873 | } |
1883 | par_blkno = INT_GET(par_node->btree[entno].before, ARCH_CONVERT); | 1874 | par_blkno = be32_to_cpu(par_node->btree[entno].before); |
1884 | if (level == dead_level + 1) | 1875 | if (level == dead_level + 1) |
1885 | break; | 1876 | break; |
1886 | xfs_da_brelse(tp, par_buf); | 1877 | xfs_da_brelse(tp, par_buf); |
@@ -1892,13 +1883,13 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1892 | */ | 1883 | */ |
1893 | for (;;) { | 1884 | for (;;) { |
1894 | for (; | 1885 | for (; |
1895 | entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) && | 1886 | entno < be16_to_cpu(par_node->hdr.count) && |
1896 | INT_GET(par_node->btree[entno].before, ARCH_CONVERT) != last_blkno; | 1887 | be32_to_cpu(par_node->btree[entno].before) != last_blkno; |
1897 | entno++) | 1888 | entno++) |
1898 | continue; | 1889 | continue; |
1899 | if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT)) | 1890 | if (entno < be16_to_cpu(par_node->hdr.count)) |
1900 | break; | 1891 | break; |
1901 | par_blkno = INT_GET(par_node->hdr.info.forw, ARCH_CONVERT); | 1892 | par_blkno = be32_to_cpu(par_node->hdr.info.forw); |
1902 | xfs_da_brelse(tp, par_buf); | 1893 | xfs_da_brelse(tp, par_buf); |
1903 | par_buf = NULL; | 1894 | par_buf = NULL; |
1904 | if (unlikely(par_blkno == 0)) { | 1895 | if (unlikely(par_blkno == 0)) { |
@@ -1911,8 +1902,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1911 | goto done; | 1902 | goto done; |
1912 | par_node = par_buf->data; | 1903 | par_node = par_buf->data; |
1913 | if (unlikely( | 1904 | if (unlikely( |
1914 | INT_GET(par_node->hdr.level, ARCH_CONVERT) != level || | 1905 | be16_to_cpu(par_node->hdr.level) != level || |
1915 | INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)) { | 1906 | be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) { |
1916 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", | 1907 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", |
1917 | XFS_ERRLEVEL_LOW, mp); | 1908 | XFS_ERRLEVEL_LOW, mp); |
1918 | error = XFS_ERROR(EFSCORRUPTED); | 1909 | error = XFS_ERROR(EFSCORRUPTED); |
@@ -1923,7 +1914,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1923 | /* | 1914 | /* |
1924 | * Update the parent entry pointing to the moved block. | 1915 | * Update the parent entry pointing to the moved block. |
1925 | */ | 1916 | */ |
1926 | INT_SET(par_node->btree[entno].before, ARCH_CONVERT, dead_blkno); | 1917 | par_node->btree[entno].before = cpu_to_be32(dead_blkno); |
1927 | xfs_da_log_buf(tp, par_buf, | 1918 | xfs_da_log_buf(tp, par_buf, |
1928 | XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before, | 1919 | XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before, |
1929 | sizeof(par_node->btree[entno].before))); | 1920 | sizeof(par_node->btree[entno].before))); |
@@ -2203,8 +2194,8 @@ xfs_da_do_buf( | |||
2203 | info = rbp->data; | 2194 | info = rbp->data; |
2204 | data = rbp->data; | 2195 | data = rbp->data; |
2205 | free = rbp->data; | 2196 | free = rbp->data; |
2206 | magic = INT_GET(info->magic, ARCH_CONVERT); | 2197 | magic = be16_to_cpu(info->magic); |
2207 | magic1 = INT_GET(data->hdr.magic, ARCH_CONVERT); | 2198 | magic1 = be32_to_cpu(data->hdr.magic); |
2208 | if (unlikely( | 2199 | if (unlikely( |
2209 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && | 2200 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && |
2210 | (magic != XFS_DIR_LEAF_MAGIC) && | 2201 | (magic != XFS_DIR_LEAF_MAGIC) && |
@@ -2213,7 +2204,7 @@ xfs_da_do_buf( | |||
2213 | (magic != XFS_DIR2_LEAFN_MAGIC) && | 2204 | (magic != XFS_DIR2_LEAFN_MAGIC) && |
2214 | (magic1 != XFS_DIR2_BLOCK_MAGIC) && | 2205 | (magic1 != XFS_DIR2_BLOCK_MAGIC) && |
2215 | (magic1 != XFS_DIR2_DATA_MAGIC) && | 2206 | (magic1 != XFS_DIR2_DATA_MAGIC) && |
2216 | (INT_GET(free->hdr.magic, ARCH_CONVERT) != XFS_DIR2_FREE_MAGIC), | 2207 | (be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC), |
2217 | mp, XFS_ERRTAG_DA_READ_BUF, | 2208 | mp, XFS_ERRTAG_DA_READ_BUF, |
2218 | XFS_RANDOM_DA_READ_BUF))) { | 2209 | XFS_RANDOM_DA_READ_BUF))) { |
2219 | xfs_buftrace("DA READ ERROR", rbp->bps[0]); | 2210 | xfs_buftrace("DA READ ERROR", rbp->bps[0]); |
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h index 41352113721a..243a730d5ec8 100644 --- a/fs/xfs/xfs_da_btree.h +++ b/fs/xfs/xfs_da_btree.h | |||
@@ -45,10 +45,10 @@ struct zone; | |||
45 | (XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC) | 45 | (XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC) |
46 | 46 | ||
47 | typedef struct xfs_da_blkinfo { | 47 | typedef struct xfs_da_blkinfo { |
48 | xfs_dablk_t forw; /* previous block in list */ | 48 | __be32 forw; /* previous block in list */ |
49 | xfs_dablk_t back; /* following block in list */ | 49 | __be32 back; /* following block in list */ |
50 | __uint16_t magic; /* validity check on block */ | 50 | __be16 magic; /* validity check on block */ |
51 | __uint16_t pad; /* unused */ | 51 | __be16 pad; /* unused */ |
52 | } xfs_da_blkinfo_t; | 52 | } xfs_da_blkinfo_t; |
53 | 53 | ||
54 | /* | 54 | /* |
@@ -65,12 +65,12 @@ typedef struct xfs_da_blkinfo { | |||
65 | typedef struct xfs_da_intnode { | 65 | typedef struct xfs_da_intnode { |
66 | struct xfs_da_node_hdr { /* constant-structure header block */ | 66 | struct xfs_da_node_hdr { /* constant-structure header block */ |
67 | xfs_da_blkinfo_t info; /* block type, links, etc. */ | 67 | xfs_da_blkinfo_t info; /* block type, links, etc. */ |
68 | __uint16_t count; /* count of active entries */ | 68 | __be16 count; /* count of active entries */ |
69 | __uint16_t level; /* level above leaves (leaf == 0) */ | 69 | __be16 level; /* level above leaves (leaf == 0) */ |
70 | } hdr; | 70 | } hdr; |
71 | struct xfs_da_node_entry { | 71 | struct xfs_da_node_entry { |
72 | xfs_dahash_t hashval; /* hash value for this descendant */ | 72 | __be32 hashval; /* hash value for this descendant */ |
73 | xfs_dablk_t before; /* Btree block before this key */ | 73 | __be32 before; /* Btree block before this key */ |
74 | } btree[1]; /* variable sized array of keys */ | 74 | } btree[1]; /* variable sized array of keys */ |
75 | } xfs_da_intnode_t; | 75 | } xfs_da_intnode_t; |
76 | typedef struct xfs_da_node_hdr xfs_da_node_hdr_t; | 76 | typedef struct xfs_da_node_hdr xfs_da_node_hdr_t; |
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index c6191d00ad27..4968a6358e61 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -83,7 +83,7 @@ xfs_swapext( | |||
83 | 83 | ||
84 | /* Pull information for the target fd */ | 84 | /* Pull information for the target fd */ |
85 | if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) || | 85 | if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) || |
86 | ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) { | 86 | ((vp = vn_from_inode(fp->f_dentry->d_inode)) == NULL)) { |
87 | error = XFS_ERROR(EINVAL); | 87 | error = XFS_ERROR(EINVAL); |
88 | goto error0; | 88 | goto error0; |
89 | } | 89 | } |
@@ -95,7 +95,7 @@ xfs_swapext( | |||
95 | } | 95 | } |
96 | 96 | ||
97 | if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || | 97 | if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || |
98 | ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) { | 98 | ((tvp = vn_from_inode(tfp->f_dentry->d_inode)) == NULL)) { |
99 | error = XFS_ERROR(EINVAL); | 99 | error = XFS_ERROR(EINVAL); |
100 | goto error0; | 100 | goto error0; |
101 | } | 101 | } |
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c index bb87d2a700a9..9cc702a839a3 100644 --- a/fs/xfs/xfs_dir.c +++ b/fs/xfs/xfs_dir.c | |||
@@ -634,7 +634,7 @@ xfs_dir_leaf_removename(xfs_da_args_t *args, int *count, int *totallen) | |||
634 | return(retval); | 634 | return(retval); |
635 | ASSERT(bp != NULL); | 635 | ASSERT(bp != NULL); |
636 | leaf = bp->data; | 636 | leaf = bp->data; |
637 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 637 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
638 | retval = xfs_dir_leaf_lookup_int(bp, args, &index); | 638 | retval = xfs_dir_leaf_lookup_int(bp, args, &index); |
639 | if (retval == EEXIST) { | 639 | if (retval == EEXIST) { |
640 | (void)xfs_dir_leaf_remove(args->trans, bp, index); | 640 | (void)xfs_dir_leaf_remove(args->trans, bp, index); |
@@ -912,7 +912,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
912 | return(error); | 912 | return(error); |
913 | if (bp) | 913 | if (bp) |
914 | leaf = bp->data; | 914 | leaf = bp->data; |
915 | if (bp && INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { | 915 | if (bp && be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) { |
916 | xfs_dir_trace_g_dub("node: block not a leaf", | 916 | xfs_dir_trace_g_dub("node: block not a leaf", |
917 | dp, uio, bno); | 917 | dp, uio, bno); |
918 | xfs_da_brelse(trans, bp); | 918 | xfs_da_brelse(trans, bp); |
@@ -949,17 +949,17 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
949 | if (bp == NULL) | 949 | if (bp == NULL) |
950 | return(XFS_ERROR(EFSCORRUPTED)); | 950 | return(XFS_ERROR(EFSCORRUPTED)); |
951 | node = bp->data; | 951 | node = bp->data; |
952 | if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC) | 952 | if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC) |
953 | break; | 953 | break; |
954 | btree = &node->btree[0]; | 954 | btree = &node->btree[0]; |
955 | xfs_dir_trace_g_dun("node: node detail", dp, uio, node); | 955 | xfs_dir_trace_g_dun("node: node detail", dp, uio, node); |
956 | for (i = 0; i < INT_GET(node->hdr.count, ARCH_CONVERT); btree++, i++) { | 956 | for (i = 0; i < be16_to_cpu(node->hdr.count); btree++, i++) { |
957 | if (INT_GET(btree->hashval, ARCH_CONVERT) >= cookhash) { | 957 | if (be32_to_cpu(btree->hashval) >= cookhash) { |
958 | bno = INT_GET(btree->before, ARCH_CONVERT); | 958 | bno = be32_to_cpu(btree->before); |
959 | break; | 959 | break; |
960 | } | 960 | } |
961 | } | 961 | } |
962 | if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) { | 962 | if (i == be16_to_cpu(node->hdr.count)) { |
963 | xfs_da_brelse(trans, bp); | 963 | xfs_da_brelse(trans, bp); |
964 | xfs_dir_trace_g_du("node: hash beyond EOF", | 964 | xfs_dir_trace_g_du("node: hash beyond EOF", |
965 | dp, uio); | 965 | dp, uio); |
@@ -982,7 +982,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
982 | */ | 982 | */ |
983 | for (;;) { | 983 | for (;;) { |
984 | leaf = bp->data; | 984 | leaf = bp->data; |
985 | if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC)) { | 985 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC)) { |
986 | xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf); | 986 | xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf); |
987 | xfs_da_brelse(trans, bp); | 987 | xfs_da_brelse(trans, bp); |
988 | XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)", | 988 | XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)", |
@@ -990,7 +990,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
990 | return XFS_ERROR(EFSCORRUPTED); | 990 | return XFS_ERROR(EFSCORRUPTED); |
991 | } | 991 | } |
992 | xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf); | 992 | xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf); |
993 | if ((nextbno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT))) { | 993 | if ((nextbno = be32_to_cpu(leaf->hdr.info.forw))) { |
994 | nextda = xfs_da_reada_buf(trans, dp, nextbno, | 994 | nextda = xfs_da_reada_buf(trans, dp, nextbno, |
995 | XFS_DATA_FORK); | 995 | XFS_DATA_FORK); |
996 | } else | 996 | } else |
@@ -1118,21 +1118,20 @@ void | |||
1118 | xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio, | 1118 | xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio, |
1119 | xfs_da_intnode_t *node) | 1119 | xfs_da_intnode_t *node) |
1120 | { | 1120 | { |
1121 | int last = INT_GET(node->hdr.count, ARCH_CONVERT) - 1; | 1121 | int last = be16_to_cpu(node->hdr.count) - 1; |
1122 | 1122 | ||
1123 | xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where, | 1123 | xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where, |
1124 | (void *)dp, (void *)dp->i_mount, | 1124 | (void *)dp, (void *)dp->i_mount, |
1125 | (void *)((unsigned long)(uio->uio_offset >> 32)), | 1125 | (void *)((unsigned long)(uio->uio_offset >> 32)), |
1126 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), | 1126 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), |
1127 | (void *)(unsigned long)uio->uio_resid, | 1127 | (void *)(unsigned long)uio->uio_resid, |
1128 | (void *)(unsigned long)be32_to_cpu(node->hdr.info.forw), | ||
1128 | (void *)(unsigned long) | 1129 | (void *)(unsigned long) |
1129 | INT_GET(node->hdr.info.forw, ARCH_CONVERT), | 1130 | be16_to_cpu(node->hdr.count), |
1130 | (void *)(unsigned long) | 1131 | (void *)(unsigned long) |
1131 | INT_GET(node->hdr.count, ARCH_CONVERT), | 1132 | be32_to_cpu(node->btree[0].hashval), |
1132 | (void *)(unsigned long) | 1133 | (void *)(unsigned long) |
1133 | INT_GET(node->btree[0].hashval, ARCH_CONVERT), | 1134 | be32_to_cpu(node->btree[last].hashval), |
1134 | (void *)(unsigned long) | ||
1135 | INT_GET(node->btree[last].hashval, ARCH_CONVERT), | ||
1136 | NULL, NULL, NULL); | 1135 | NULL, NULL, NULL); |
1137 | } | 1136 | } |
1138 | 1137 | ||
@@ -1150,8 +1149,7 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio, | |||
1150 | (void *)((unsigned long)(uio->uio_offset >> 32)), | 1149 | (void *)((unsigned long)(uio->uio_offset >> 32)), |
1151 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), | 1150 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), |
1152 | (void *)(unsigned long)uio->uio_resid, | 1151 | (void *)(unsigned long)uio->uio_resid, |
1153 | (void *)(unsigned long) | 1152 | (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw), |
1154 | INT_GET(leaf->hdr.info.forw, ARCH_CONVERT), | ||
1155 | (void *)(unsigned long) | 1153 | (void *)(unsigned long) |
1156 | INT_GET(leaf->hdr.count, ARCH_CONVERT), | 1154 | INT_GET(leaf->hdr.count, ARCH_CONVERT), |
1157 | (void *)(unsigned long) | 1155 | (void *)(unsigned long) |
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h index 3158f5dc431f..7dd364b1e038 100644 --- a/fs/xfs/xfs_dir2.h +++ b/fs/xfs/xfs_dir2.h | |||
@@ -55,16 +55,16 @@ typedef __uint32_t xfs_dir2_db_t; | |||
55 | /* | 55 | /* |
56 | * Byte offset in a directory. | 56 | * Byte offset in a directory. |
57 | */ | 57 | */ |
58 | typedef xfs_off_t xfs_dir2_off_t; | 58 | typedef xfs_off_t xfs_dir2_off_t; |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * For getdents, argument struct for put routines. | 61 | * For getdents, argument struct for put routines. |
62 | */ | 62 | */ |
63 | typedef int (*xfs_dir2_put_t)(struct xfs_dir2_put_args *pa); | 63 | typedef int (*xfs_dir2_put_t)(struct xfs_dir2_put_args *pa); |
64 | typedef struct xfs_dir2_put_args { | 64 | typedef struct xfs_dir2_put_args { |
65 | xfs_off_t cook; /* cookie of (next) entry */ | 65 | xfs_off_t cook; /* cookie of (next) entry */ |
66 | xfs_intino_t ino; /* inode number */ | 66 | xfs_intino_t ino; /* inode number */ |
67 | struct xfs_dirent *dbp; /* buffer pointer */ | 67 | xfs_dirent_t *dbp; /* buffer pointer */ |
68 | char *name; /* directory entry name */ | 68 | char *name; /* directory entry name */ |
69 | int namelen; /* length of name */ | 69 | int namelen; /* length of name */ |
70 | int done; /* output: set if value was stored */ | 70 | int done; /* output: set if value was stored */ |
@@ -75,18 +75,13 @@ typedef struct xfs_dir2_put_args { | |||
75 | /* | 75 | /* |
76 | * Other interfaces used by the rest of the dir v2 code. | 76 | * Other interfaces used by the rest of the dir v2 code. |
77 | */ | 77 | */ |
78 | extern int | 78 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |
79 | xfs_dir2_grow_inode(struct xfs_da_args *args, int space, | 79 | xfs_dir2_db_t *dbp); |
80 | xfs_dir2_db_t *dbp); | 80 | extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp, |
81 | 81 | int *vp); | |
82 | extern int | 82 | extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, |
83 | xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp, int *vp); | 83 | int *vp); |
84 | 84 | extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, | |
85 | extern int | 85 | struct xfs_dabuf *bp); |
86 | xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, int *vp); | ||
87 | |||
88 | extern int | ||
89 | xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, | ||
90 | struct xfs_dabuf *bp); | ||
91 | 86 | ||
92 | #endif /* __XFS_DIR2_H__ */ | 87 | #endif /* __XFS_DIR2_H__ */ |
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index 31bc99faa704..bd5cee6aa51a 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -81,7 +81,7 @@ xfs_dir2_block_addname( | |||
81 | xfs_mount_t *mp; /* filesystem mount point */ | 81 | xfs_mount_t *mp; /* filesystem mount point */ |
82 | int needlog; /* need to log header */ | 82 | int needlog; /* need to log header */ |
83 | int needscan; /* need to rescan freespace */ | 83 | int needscan; /* need to rescan freespace */ |
84 | xfs_dir2_data_off_t *tagp; /* pointer to tag value */ | 84 | __be16 *tagp; /* pointer to tag value */ |
85 | xfs_trans_t *tp; /* transaction structure */ | 85 | xfs_trans_t *tp; /* transaction structure */ |
86 | 86 | ||
87 | xfs_dir2_trace_args("block_addname", args); | 87 | xfs_dir2_trace_args("block_addname", args); |
@@ -100,8 +100,7 @@ xfs_dir2_block_addname( | |||
100 | /* | 100 | /* |
101 | * Check the magic number, corrupted if wrong. | 101 | * Check the magic number, corrupted if wrong. |
102 | */ | 102 | */ |
103 | if (unlikely(INT_GET(block->hdr.magic, ARCH_CONVERT) | 103 | if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) { |
104 | != XFS_DIR2_BLOCK_MAGIC)) { | ||
105 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", | 104 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", |
106 | XFS_ERRLEVEL_LOW, mp, block); | 105 | XFS_ERRLEVEL_LOW, mp, block); |
107 | xfs_da_brelse(tp, bp); | 106 | xfs_da_brelse(tp, bp); |
@@ -121,38 +120,38 @@ xfs_dir2_block_addname( | |||
121 | /* | 120 | /* |
122 | * Tag just before the first leaf entry. | 121 | * Tag just before the first leaf entry. |
123 | */ | 122 | */ |
124 | tagp = (xfs_dir2_data_off_t *)blp - 1; | 123 | tagp = (__be16 *)blp - 1; |
125 | /* | 124 | /* |
126 | * Data object just before the first leaf entry. | 125 | * Data object just before the first leaf entry. |
127 | */ | 126 | */ |
128 | enddup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT)); | 127 | enddup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp)); |
129 | /* | 128 | /* |
130 | * If it's not free then can't do this add without cleaning up: | 129 | * If it's not free then can't do this add without cleaning up: |
131 | * the space before the first leaf entry needs to be free so it | 130 | * the space before the first leaf entry needs to be free so it |
132 | * can be expanded to hold the pointer to the new entry. | 131 | * can be expanded to hold the pointer to the new entry. |
133 | */ | 132 | */ |
134 | if (INT_GET(enddup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG) | 133 | if (be16_to_cpu(enddup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
135 | dup = enddup = NULL; | 134 | dup = enddup = NULL; |
136 | /* | 135 | /* |
137 | * Check out the biggest freespace and see if it's the same one. | 136 | * Check out the biggest freespace and see if it's the same one. |
138 | */ | 137 | */ |
139 | else { | 138 | else { |
140 | dup = (xfs_dir2_data_unused_t *) | 139 | dup = (xfs_dir2_data_unused_t *) |
141 | ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); | 140 | ((char *)block + be16_to_cpu(bf[0].offset)); |
142 | if (dup == enddup) { | 141 | if (dup == enddup) { |
143 | /* | 142 | /* |
144 | * It is the biggest freespace, is it too small | 143 | * It is the biggest freespace, is it too small |
145 | * to hold the new leaf too? | 144 | * to hold the new leaf too? |
146 | */ | 145 | */ |
147 | if (INT_GET(dup->length, ARCH_CONVERT) < len + (uint)sizeof(*blp)) { | 146 | if (be16_to_cpu(dup->length) < len + (uint)sizeof(*blp)) { |
148 | /* | 147 | /* |
149 | * Yes, we use the second-largest | 148 | * Yes, we use the second-largest |
150 | * entry instead if it works. | 149 | * entry instead if it works. |
151 | */ | 150 | */ |
152 | if (INT_GET(bf[1].length, ARCH_CONVERT) >= len) | 151 | if (be16_to_cpu(bf[1].length) >= len) |
153 | dup = (xfs_dir2_data_unused_t *) | 152 | dup = (xfs_dir2_data_unused_t *) |
154 | ((char *)block + | 153 | ((char *)block + |
155 | INT_GET(bf[1].offset, ARCH_CONVERT)); | 154 | be16_to_cpu(bf[1].offset)); |
156 | else | 155 | else |
157 | dup = NULL; | 156 | dup = NULL; |
158 | } | 157 | } |
@@ -161,7 +160,7 @@ xfs_dir2_block_addname( | |||
161 | * Not the same free entry, | 160 | * Not the same free entry, |
162 | * just check its length. | 161 | * just check its length. |
163 | */ | 162 | */ |
164 | if (INT_GET(dup->length, ARCH_CONVERT) < len) { | 163 | if (be16_to_cpu(dup->length) < len) { |
165 | dup = NULL; | 164 | dup = NULL; |
166 | } | 165 | } |
167 | } | 166 | } |
@@ -172,9 +171,9 @@ xfs_dir2_block_addname( | |||
172 | * If there are stale entries we'll use one for the leaf. | 171 | * If there are stale entries we'll use one for the leaf. |
173 | * Is the biggest entry enough to avoid compaction? | 172 | * Is the biggest entry enough to avoid compaction? |
174 | */ | 173 | */ |
175 | else if (INT_GET(bf[0].length, ARCH_CONVERT) >= len) { | 174 | else if (be16_to_cpu(bf[0].length) >= len) { |
176 | dup = (xfs_dir2_data_unused_t *) | 175 | dup = (xfs_dir2_data_unused_t *) |
177 | ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); | 176 | ((char *)block + be16_to_cpu(bf[0].offset)); |
178 | compact = 0; | 177 | compact = 0; |
179 | } | 178 | } |
180 | /* | 179 | /* |
@@ -184,20 +183,20 @@ xfs_dir2_block_addname( | |||
184 | /* | 183 | /* |
185 | * Tag just before the first leaf entry. | 184 | * Tag just before the first leaf entry. |
186 | */ | 185 | */ |
187 | tagp = (xfs_dir2_data_off_t *)blp - 1; | 186 | tagp = (__be16 *)blp - 1; |
188 | /* | 187 | /* |
189 | * Data object just before the first leaf entry. | 188 | * Data object just before the first leaf entry. |
190 | */ | 189 | */ |
191 | dup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT)); | 190 | dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp)); |
192 | /* | 191 | /* |
193 | * If it's not free then the data will go where the | 192 | * If it's not free then the data will go where the |
194 | * leaf data starts now, if it works at all. | 193 | * leaf data starts now, if it works at all. |
195 | */ | 194 | */ |
196 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 195 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
197 | if (INT_GET(dup->length, ARCH_CONVERT) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) * | 196 | if (be16_to_cpu(dup->length) + (be32_to_cpu(btp->stale) - 1) * |
198 | (uint)sizeof(*blp) < len) | 197 | (uint)sizeof(*blp) < len) |
199 | dup = NULL; | 198 | dup = NULL; |
200 | } else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len) | 199 | } else if ((be32_to_cpu(btp->stale) - 1) * (uint)sizeof(*blp) < len) |
201 | dup = NULL; | 200 | dup = NULL; |
202 | else | 201 | else |
203 | dup = (xfs_dir2_data_unused_t *)blp; | 202 | dup = (xfs_dir2_data_unused_t *)blp; |
@@ -243,11 +242,11 @@ xfs_dir2_block_addname( | |||
243 | int fromidx; /* source leaf index */ | 242 | int fromidx; /* source leaf index */ |
244 | int toidx; /* target leaf index */ | 243 | int toidx; /* target leaf index */ |
245 | 244 | ||
246 | for (fromidx = toidx = INT_GET(btp->count, ARCH_CONVERT) - 1, | 245 | for (fromidx = toidx = be32_to_cpu(btp->count) - 1, |
247 | highstale = lfloghigh = -1; | 246 | highstale = lfloghigh = -1; |
248 | fromidx >= 0; | 247 | fromidx >= 0; |
249 | fromidx--) { | 248 | fromidx--) { |
250 | if (INT_GET(blp[fromidx].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) { | 249 | if (be32_to_cpu(blp[fromidx].address) == XFS_DIR2_NULL_DATAPTR) { |
251 | if (highstale == -1) | 250 | if (highstale == -1) |
252 | highstale = toidx; | 251 | highstale = toidx; |
253 | else { | 252 | else { |
@@ -260,15 +259,15 @@ xfs_dir2_block_addname( | |||
260 | blp[toidx] = blp[fromidx]; | 259 | blp[toidx] = blp[fromidx]; |
261 | toidx--; | 260 | toidx--; |
262 | } | 261 | } |
263 | lfloglow = toidx + 1 - (INT_GET(btp->stale, ARCH_CONVERT) - 1); | 262 | lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1); |
264 | lfloghigh -= INT_GET(btp->stale, ARCH_CONVERT) - 1; | 263 | lfloghigh -= be32_to_cpu(btp->stale) - 1; |
265 | INT_MOD(btp->count, ARCH_CONVERT, -(INT_GET(btp->stale, ARCH_CONVERT) - 1)); | 264 | be32_add(&btp->count, -(be32_to_cpu(btp->stale) - 1)); |
266 | xfs_dir2_data_make_free(tp, bp, | 265 | xfs_dir2_data_make_free(tp, bp, |
267 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), | 266 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), |
268 | (xfs_dir2_data_aoff_t)((INT_GET(btp->stale, ARCH_CONVERT) - 1) * sizeof(*blp)), | 267 | (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), |
269 | &needlog, &needscan); | 268 | &needlog, &needscan); |
270 | blp += INT_GET(btp->stale, ARCH_CONVERT) - 1; | 269 | blp += be32_to_cpu(btp->stale) - 1; |
271 | INT_SET(btp->stale, ARCH_CONVERT, 1); | 270 | btp->stale = cpu_to_be32(1); |
272 | /* | 271 | /* |
273 | * If we now need to rebuild the bestfree map, do so. | 272 | * If we now need to rebuild the bestfree map, do so. |
274 | * This needs to happen before the next call to use_free. | 273 | * This needs to happen before the next call to use_free. |
@@ -283,23 +282,23 @@ xfs_dir2_block_addname( | |||
283 | * Set leaf logging boundaries to impossible state. | 282 | * Set leaf logging boundaries to impossible state. |
284 | * For the no-stale case they're set explicitly. | 283 | * For the no-stale case they're set explicitly. |
285 | */ | 284 | */ |
286 | else if (INT_GET(btp->stale, ARCH_CONVERT)) { | 285 | else if (btp->stale) { |
287 | lfloglow = INT_GET(btp->count, ARCH_CONVERT); | 286 | lfloglow = be32_to_cpu(btp->count); |
288 | lfloghigh = -1; | 287 | lfloghigh = -1; |
289 | } | 288 | } |
290 | /* | 289 | /* |
291 | * Find the slot that's first lower than our hash value, -1 if none. | 290 | * Find the slot that's first lower than our hash value, -1 if none. |
292 | */ | 291 | */ |
293 | for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; low <= high; ) { | 292 | for (low = 0, high = be32_to_cpu(btp->count) - 1; low <= high; ) { |
294 | mid = (low + high) >> 1; | 293 | mid = (low + high) >> 1; |
295 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) | 294 | if ((hash = be32_to_cpu(blp[mid].hashval)) == args->hashval) |
296 | break; | 295 | break; |
297 | if (hash < args->hashval) | 296 | if (hash < args->hashval) |
298 | low = mid + 1; | 297 | low = mid + 1; |
299 | else | 298 | else |
300 | high = mid - 1; | 299 | high = mid - 1; |
301 | } | 300 | } |
302 | while (mid >= 0 && INT_GET(blp[mid].hashval, ARCH_CONVERT) >= args->hashval) { | 301 | while (mid >= 0 && be32_to_cpu(blp[mid].hashval) >= args->hashval) { |
303 | mid--; | 302 | mid--; |
304 | } | 303 | } |
305 | /* | 304 | /* |
@@ -311,14 +310,14 @@ xfs_dir2_block_addname( | |||
311 | */ | 310 | */ |
312 | xfs_dir2_data_use_free(tp, bp, enddup, | 311 | xfs_dir2_data_use_free(tp, bp, enddup, |
313 | (xfs_dir2_data_aoff_t) | 312 | (xfs_dir2_data_aoff_t) |
314 | ((char *)enddup - (char *)block + INT_GET(enddup->length, ARCH_CONVERT) - | 313 | ((char *)enddup - (char *)block + be16_to_cpu(enddup->length) - |
315 | sizeof(*blp)), | 314 | sizeof(*blp)), |
316 | (xfs_dir2_data_aoff_t)sizeof(*blp), | 315 | (xfs_dir2_data_aoff_t)sizeof(*blp), |
317 | &needlog, &needscan); | 316 | &needlog, &needscan); |
318 | /* | 317 | /* |
319 | * Update the tail (entry count). | 318 | * Update the tail (entry count). |
320 | */ | 319 | */ |
321 | INT_MOD(btp->count, ARCH_CONVERT, +1); | 320 | be32_add(&btp->count, 1); |
322 | /* | 321 | /* |
323 | * If we now need to rebuild the bestfree map, do so. | 322 | * If we now need to rebuild the bestfree map, do so. |
324 | * This needs to happen before the next call to use_free. | 323 | * This needs to happen before the next call to use_free. |
@@ -346,12 +345,12 @@ xfs_dir2_block_addname( | |||
346 | else { | 345 | else { |
347 | for (lowstale = mid; | 346 | for (lowstale = mid; |
348 | lowstale >= 0 && | 347 | lowstale >= 0 && |
349 | INT_GET(blp[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR; | 348 | be32_to_cpu(blp[lowstale].address) != XFS_DIR2_NULL_DATAPTR; |
350 | lowstale--) | 349 | lowstale--) |
351 | continue; | 350 | continue; |
352 | for (highstale = mid + 1; | 351 | for (highstale = mid + 1; |
353 | highstale < INT_GET(btp->count, ARCH_CONVERT) && | 352 | highstale < be32_to_cpu(btp->count) && |
354 | INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 353 | be32_to_cpu(blp[highstale].address) != XFS_DIR2_NULL_DATAPTR && |
355 | (lowstale < 0 || mid - lowstale > highstale - mid); | 354 | (lowstale < 0 || mid - lowstale > highstale - mid); |
356 | highstale++) | 355 | highstale++) |
357 | continue; | 356 | continue; |
@@ -359,7 +358,7 @@ xfs_dir2_block_addname( | |||
359 | * Move entries toward the low-numbered stale entry. | 358 | * Move entries toward the low-numbered stale entry. |
360 | */ | 359 | */ |
361 | if (lowstale >= 0 && | 360 | if (lowstale >= 0 && |
362 | (highstale == INT_GET(btp->count, ARCH_CONVERT) || | 361 | (highstale == be32_to_cpu(btp->count) || |
363 | mid - lowstale <= highstale - mid)) { | 362 | mid - lowstale <= highstale - mid)) { |
364 | if (mid - lowstale) | 363 | if (mid - lowstale) |
365 | memmove(&blp[lowstale], &blp[lowstale + 1], | 364 | memmove(&blp[lowstale], &blp[lowstale + 1], |
@@ -371,7 +370,7 @@ xfs_dir2_block_addname( | |||
371 | * Move entries toward the high-numbered stale entry. | 370 | * Move entries toward the high-numbered stale entry. |
372 | */ | 371 | */ |
373 | else { | 372 | else { |
374 | ASSERT(highstale < INT_GET(btp->count, ARCH_CONVERT)); | 373 | ASSERT(highstale < be32_to_cpu(btp->count)); |
375 | mid++; | 374 | mid++; |
376 | if (highstale - mid) | 375 | if (highstale - mid) |
377 | memmove(&blp[mid + 1], &blp[mid], | 376 | memmove(&blp[mid + 1], &blp[mid], |
@@ -379,7 +378,7 @@ xfs_dir2_block_addname( | |||
379 | lfloglow = MIN(mid, lfloglow); | 378 | lfloglow = MIN(mid, lfloglow); |
380 | lfloghigh = MAX(highstale, lfloghigh); | 379 | lfloghigh = MAX(highstale, lfloghigh); |
381 | } | 380 | } |
382 | INT_MOD(btp->stale, ARCH_CONVERT, -1); | 381 | be32_add(&btp->stale, -1); |
383 | } | 382 | } |
384 | /* | 383 | /* |
385 | * Point to the new data entry. | 384 | * Point to the new data entry. |
@@ -388,8 +387,9 @@ xfs_dir2_block_addname( | |||
388 | /* | 387 | /* |
389 | * Fill in the leaf entry. | 388 | * Fill in the leaf entry. |
390 | */ | 389 | */ |
391 | INT_SET(blp[mid].hashval, ARCH_CONVERT, args->hashval); | 390 | blp[mid].hashval = cpu_to_be32(args->hashval); |
392 | INT_SET(blp[mid].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block)); | 391 | blp[mid].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, |
392 | (char *)dep - (char *)block)); | ||
393 | xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); | 393 | xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); |
394 | /* | 394 | /* |
395 | * Mark space for the data entry used. | 395 | * Mark space for the data entry used. |
@@ -404,7 +404,7 @@ xfs_dir2_block_addname( | |||
404 | dep->namelen = args->namelen; | 404 | dep->namelen = args->namelen; |
405 | memcpy(dep->name, args->name, args->namelen); | 405 | memcpy(dep->name, args->name, args->namelen); |
406 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 406 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
407 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 407 | *tagp = cpu_to_be16((char *)dep - (char *)block); |
408 | /* | 408 | /* |
409 | * Clean up the bestfree array and log the header, tail, and entry. | 409 | * Clean up the bestfree array and log the header, tail, and entry. |
410 | */ | 410 | */ |
@@ -485,8 +485,8 @@ xfs_dir2_block_getdents( | |||
485 | /* | 485 | /* |
486 | * Unused, skip it. | 486 | * Unused, skip it. |
487 | */ | 487 | */ |
488 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 488 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
489 | ptr += INT_GET(dup->length, ARCH_CONVERT); | 489 | ptr += be16_to_cpu(dup->length); |
490 | continue; | 490 | continue; |
491 | } | 491 | } |
492 | 492 | ||
@@ -622,7 +622,7 @@ xfs_dir2_block_lookup( | |||
622 | * Get the offset from the leaf entry, to point to the data. | 622 | * Get the offset from the leaf entry, to point to the data. |
623 | */ | 623 | */ |
624 | dep = (xfs_dir2_data_entry_t *) | 624 | dep = (xfs_dir2_data_entry_t *) |
625 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT))); | 625 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); |
626 | /* | 626 | /* |
627 | * Fill in inode number, release the block. | 627 | * Fill in inode number, release the block. |
628 | */ | 628 | */ |
@@ -674,10 +674,10 @@ xfs_dir2_block_lookup_int( | |||
674 | * Loop doing a binary search for our hash value. | 674 | * Loop doing a binary search for our hash value. |
675 | * Find our entry, ENOENT if it's not there. | 675 | * Find our entry, ENOENT if it's not there. |
676 | */ | 676 | */ |
677 | for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; ; ) { | 677 | for (low = 0, high = be32_to_cpu(btp->count) - 1; ; ) { |
678 | ASSERT(low <= high); | 678 | ASSERT(low <= high); |
679 | mid = (low + high) >> 1; | 679 | mid = (low + high) >> 1; |
680 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) | 680 | if ((hash = be32_to_cpu(blp[mid].hashval)) == args->hashval) |
681 | break; | 681 | break; |
682 | if (hash < args->hashval) | 682 | if (hash < args->hashval) |
683 | low = mid + 1; | 683 | low = mid + 1; |
@@ -692,7 +692,7 @@ xfs_dir2_block_lookup_int( | |||
692 | /* | 692 | /* |
693 | * Back up to the first one with the right hash value. | 693 | * Back up to the first one with the right hash value. |
694 | */ | 694 | */ |
695 | while (mid > 0 && INT_GET(blp[mid - 1].hashval, ARCH_CONVERT) == args->hashval) { | 695 | while (mid > 0 && be32_to_cpu(blp[mid - 1].hashval) == args->hashval) { |
696 | mid--; | 696 | mid--; |
697 | } | 697 | } |
698 | /* | 698 | /* |
@@ -700,7 +700,7 @@ xfs_dir2_block_lookup_int( | |||
700 | * right hash value looking for our name. | 700 | * right hash value looking for our name. |
701 | */ | 701 | */ |
702 | do { | 702 | do { |
703 | if ((addr = INT_GET(blp[mid].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR) | 703 | if ((addr = be32_to_cpu(blp[mid].address)) == XFS_DIR2_NULL_DATAPTR) |
704 | continue; | 704 | continue; |
705 | /* | 705 | /* |
706 | * Get pointer to the entry from the leaf. | 706 | * Get pointer to the entry from the leaf. |
@@ -717,7 +717,7 @@ xfs_dir2_block_lookup_int( | |||
717 | *entno = mid; | 717 | *entno = mid; |
718 | return 0; | 718 | return 0; |
719 | } | 719 | } |
720 | } while (++mid < INT_GET(btp->count, ARCH_CONVERT) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash); | 720 | } while (++mid < be32_to_cpu(btp->count) && be32_to_cpu(blp[mid].hashval) == hash); |
721 | /* | 721 | /* |
722 | * No match, release the buffer and return ENOENT. | 722 | * No match, release the buffer and return ENOENT. |
723 | */ | 723 | */ |
@@ -767,7 +767,7 @@ xfs_dir2_block_removename( | |||
767 | * Point to the data entry using the leaf entry. | 767 | * Point to the data entry using the leaf entry. |
768 | */ | 768 | */ |
769 | dep = (xfs_dir2_data_entry_t *) | 769 | dep = (xfs_dir2_data_entry_t *) |
770 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT))); | 770 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); |
771 | /* | 771 | /* |
772 | * Mark the data entry's space free. | 772 | * Mark the data entry's space free. |
773 | */ | 773 | */ |
@@ -778,12 +778,12 @@ xfs_dir2_block_removename( | |||
778 | /* | 778 | /* |
779 | * Fix up the block tail. | 779 | * Fix up the block tail. |
780 | */ | 780 | */ |
781 | INT_MOD(btp->stale, ARCH_CONVERT, +1); | 781 | be32_add(&btp->stale, 1); |
782 | xfs_dir2_block_log_tail(tp, bp); | 782 | xfs_dir2_block_log_tail(tp, bp); |
783 | /* | 783 | /* |
784 | * Remove the leaf entry by marking it stale. | 784 | * Remove the leaf entry by marking it stale. |
785 | */ | 785 | */ |
786 | INT_SET(blp[ent].address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 786 | blp[ent].address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
787 | xfs_dir2_block_log_leaf(tp, bp, ent, ent); | 787 | xfs_dir2_block_log_leaf(tp, bp, ent, ent); |
788 | /* | 788 | /* |
789 | * Fix up bestfree, log the header if necessary. | 789 | * Fix up bestfree, log the header if necessary. |
@@ -843,7 +843,7 @@ xfs_dir2_block_replace( | |||
843 | * Point to the data entry we need to change. | 843 | * Point to the data entry we need to change. |
844 | */ | 844 | */ |
845 | dep = (xfs_dir2_data_entry_t *) | 845 | dep = (xfs_dir2_data_entry_t *) |
846 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT))); | 846 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); |
847 | ASSERT(INT_GET(dep->inumber, ARCH_CONVERT) != args->inumber); | 847 | ASSERT(INT_GET(dep->inumber, ARCH_CONVERT) != args->inumber); |
848 | /* | 848 | /* |
849 | * Change the inode number to the new value. | 849 | * Change the inode number to the new value. |
@@ -868,8 +868,8 @@ xfs_dir2_block_sort( | |||
868 | 868 | ||
869 | la = a; | 869 | la = a; |
870 | lb = b; | 870 | lb = b; |
871 | return INT_GET(la->hashval, ARCH_CONVERT) < INT_GET(lb->hashval, ARCH_CONVERT) ? -1 : | 871 | return be32_to_cpu(la->hashval) < be32_to_cpu(lb->hashval) ? -1 : |
872 | (INT_GET(la->hashval, ARCH_CONVERT) > INT_GET(lb->hashval, ARCH_CONVERT) ? 1 : 0); | 872 | (be32_to_cpu(la->hashval) > be32_to_cpu(lb->hashval) ? 1 : 0); |
873 | } | 873 | } |
874 | 874 | ||
875 | /* | 875 | /* |
@@ -881,7 +881,7 @@ xfs_dir2_leaf_to_block( | |||
881 | xfs_dabuf_t *lbp, /* leaf buffer */ | 881 | xfs_dabuf_t *lbp, /* leaf buffer */ |
882 | xfs_dabuf_t *dbp) /* data buffer */ | 882 | xfs_dabuf_t *dbp) /* data buffer */ |
883 | { | 883 | { |
884 | xfs_dir2_data_off_t *bestsp; /* leaf bests table */ | 884 | __be16 *bestsp; /* leaf bests table */ |
885 | xfs_dir2_block_t *block; /* block structure */ | 885 | xfs_dir2_block_t *block; /* block structure */ |
886 | xfs_dir2_block_tail_t *btp; /* block tail */ | 886 | xfs_dir2_block_tail_t *btp; /* block tail */ |
887 | xfs_inode_t *dp; /* incore directory inode */ | 887 | xfs_inode_t *dp; /* incore directory inode */ |
@@ -896,7 +896,7 @@ xfs_dir2_leaf_to_block( | |||
896 | int needscan; /* need to scan for bestfree */ | 896 | int needscan; /* need to scan for bestfree */ |
897 | xfs_dir2_sf_hdr_t sfh; /* shortform header */ | 897 | xfs_dir2_sf_hdr_t sfh; /* shortform header */ |
898 | int size; /* bytes used */ | 898 | int size; /* bytes used */ |
899 | xfs_dir2_data_off_t *tagp; /* end of entry (tag) */ | 899 | __be16 *tagp; /* end of entry (tag) */ |
900 | int to; /* block/leaf to index */ | 900 | int to; /* block/leaf to index */ |
901 | xfs_trans_t *tp; /* transaction pointer */ | 901 | xfs_trans_t *tp; /* transaction pointer */ |
902 | 902 | ||
@@ -905,7 +905,7 @@ xfs_dir2_leaf_to_block( | |||
905 | tp = args->trans; | 905 | tp = args->trans; |
906 | mp = dp->i_mount; | 906 | mp = dp->i_mount; |
907 | leaf = lbp->data; | 907 | leaf = lbp->data; |
908 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 908 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
909 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 909 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
910 | /* | 910 | /* |
911 | * If there are data blocks other than the first one, take this | 911 | * If there are data blocks other than the first one, take this |
@@ -915,11 +915,11 @@ xfs_dir2_leaf_to_block( | |||
915 | */ | 915 | */ |
916 | while (dp->i_d.di_size > mp->m_dirblksize) { | 916 | while (dp->i_d.di_size > mp->m_dirblksize) { |
917 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 917 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
918 | if (INT_GET(bestsp[INT_GET(ltp->bestcount, ARCH_CONVERT) - 1], ARCH_CONVERT) == | 918 | if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == |
919 | mp->m_dirblksize - (uint)sizeof(block->hdr)) { | 919 | mp->m_dirblksize - (uint)sizeof(block->hdr)) { |
920 | if ((error = | 920 | if ((error = |
921 | xfs_dir2_leaf_trim_data(args, lbp, | 921 | xfs_dir2_leaf_trim_data(args, lbp, |
922 | (xfs_dir2_db_t)(INT_GET(ltp->bestcount, ARCH_CONVERT) - 1)))) | 922 | (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) |
923 | goto out; | 923 | goto out; |
924 | } else { | 924 | } else { |
925 | error = 0; | 925 | error = 0; |
@@ -935,28 +935,29 @@ xfs_dir2_leaf_to_block( | |||
935 | goto out; | 935 | goto out; |
936 | } | 936 | } |
937 | block = dbp->data; | 937 | block = dbp->data; |
938 | ASSERT(INT_GET(block->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | 938 | ASSERT(be32_to_cpu(block->hdr.magic) == XFS_DIR2_DATA_MAGIC); |
939 | /* | 939 | /* |
940 | * Size of the "leaf" area in the block. | 940 | * Size of the "leaf" area in the block. |
941 | */ | 941 | */ |
942 | size = (uint)sizeof(block->tail) + | 942 | size = (uint)sizeof(block->tail) + |
943 | (uint)sizeof(*lep) * (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); | 943 | (uint)sizeof(*lep) * (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); |
944 | /* | 944 | /* |
945 | * Look at the last data entry. | 945 | * Look at the last data entry. |
946 | */ | 946 | */ |
947 | tagp = (xfs_dir2_data_off_t *)((char *)block + mp->m_dirblksize) - 1; | 947 | tagp = (__be16 *)((char *)block + mp->m_dirblksize) - 1; |
948 | dup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT)); | 948 | dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp)); |
949 | /* | 949 | /* |
950 | * If it's not free or is too short we can't do it. | 950 | * If it's not free or is too short we can't do it. |
951 | */ | 951 | */ |
952 | if (INT_GET(dup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG || INT_GET(dup->length, ARCH_CONVERT) < size) { | 952 | if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG || |
953 | be16_to_cpu(dup->length) < size) { | ||
953 | error = 0; | 954 | error = 0; |
954 | goto out; | 955 | goto out; |
955 | } | 956 | } |
956 | /* | 957 | /* |
957 | * Start converting it to block form. | 958 | * Start converting it to block form. |
958 | */ | 959 | */ |
959 | INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); | 960 | block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); |
960 | needlog = 1; | 961 | needlog = 1; |
961 | needscan = 0; | 962 | needscan = 0; |
962 | /* | 963 | /* |
@@ -968,20 +969,20 @@ xfs_dir2_leaf_to_block( | |||
968 | * Initialize the block tail. | 969 | * Initialize the block tail. |
969 | */ | 970 | */ |
970 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); | 971 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); |
971 | INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); | 972 | btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); |
972 | btp->stale = 0; | 973 | btp->stale = 0; |
973 | xfs_dir2_block_log_tail(tp, dbp); | 974 | xfs_dir2_block_log_tail(tp, dbp); |
974 | /* | 975 | /* |
975 | * Initialize the block leaf area. We compact out stale entries. | 976 | * Initialize the block leaf area. We compact out stale entries. |
976 | */ | 977 | */ |
977 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); | 978 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); |
978 | for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 979 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { |
979 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 980 | if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) |
980 | continue; | 981 | continue; |
981 | lep[to++] = leaf->ents[from]; | 982 | lep[to++] = leaf->ents[from]; |
982 | } | 983 | } |
983 | ASSERT(to == INT_GET(btp->count, ARCH_CONVERT)); | 984 | ASSERT(to == be32_to_cpu(btp->count)); |
984 | xfs_dir2_block_log_leaf(tp, dbp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1); | 985 | xfs_dir2_block_log_leaf(tp, dbp, 0, be32_to_cpu(btp->count) - 1); |
985 | /* | 986 | /* |
986 | * Scan the bestfree if we need it and log the data block header. | 987 | * Scan the bestfree if we need it and log the data block header. |
987 | */ | 988 | */ |
@@ -1043,7 +1044,7 @@ xfs_dir2_sf_to_block( | |||
1043 | int offset; /* target block offset */ | 1044 | int offset; /* target block offset */ |
1044 | xfs_dir2_sf_entry_t *sfep; /* sf entry pointer */ | 1045 | xfs_dir2_sf_entry_t *sfep; /* sf entry pointer */ |
1045 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 1046 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
1046 | xfs_dir2_data_off_t *tagp; /* end of data entry */ | 1047 | __be16 *tagp; /* end of data entry */ |
1047 | xfs_trans_t *tp; /* transaction pointer */ | 1048 | xfs_trans_t *tp; /* transaction pointer */ |
1048 | 1049 | ||
1049 | xfs_dir2_trace_args("sf_to_block", args); | 1050 | xfs_dir2_trace_args("sf_to_block", args); |
@@ -1095,12 +1096,12 @@ xfs_dir2_sf_to_block( | |||
1095 | return error; | 1096 | return error; |
1096 | } | 1097 | } |
1097 | block = bp->data; | 1098 | block = bp->data; |
1098 | INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); | 1099 | block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); |
1099 | /* | 1100 | /* |
1100 | * Compute size of block "tail" area. | 1101 | * Compute size of block "tail" area. |
1101 | */ | 1102 | */ |
1102 | i = (uint)sizeof(*btp) + | 1103 | i = (uint)sizeof(*btp) + |
1103 | (INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t); | 1104 | (sfp->hdr.count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t); |
1104 | /* | 1105 | /* |
1105 | * The whole thing is initialized to free by the init routine. | 1106 | * The whole thing is initialized to free by the init routine. |
1106 | * Say we're using the leaf and tail area. | 1107 | * Say we're using the leaf and tail area. |
@@ -1114,7 +1115,7 @@ xfs_dir2_sf_to_block( | |||
1114 | * Fill in the tail. | 1115 | * Fill in the tail. |
1115 | */ | 1116 | */ |
1116 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); | 1117 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); |
1117 | INT_SET(btp->count, ARCH_CONVERT, INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */ | 1118 | btp->count = cpu_to_be32(sfp->hdr.count + 2); /* ., .. */ |
1118 | btp->stale = 0; | 1119 | btp->stale = 0; |
1119 | blp = XFS_DIR2_BLOCK_LEAF_P(btp); | 1120 | blp = XFS_DIR2_BLOCK_LEAF_P(btp); |
1120 | endoffset = (uint)((char *)blp - (char *)block); | 1121 | endoffset = (uint)((char *)blp - (char *)block); |
@@ -1123,7 +1124,7 @@ xfs_dir2_sf_to_block( | |||
1123 | */ | 1124 | */ |
1124 | xfs_dir2_data_use_free(tp, bp, dup, | 1125 | xfs_dir2_data_use_free(tp, bp, dup, |
1125 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)block), | 1126 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)block), |
1126 | INT_GET(dup->length, ARCH_CONVERT), &needlog, &needscan); | 1127 | be16_to_cpu(dup->length), &needlog, &needscan); |
1127 | /* | 1128 | /* |
1128 | * Create entry for . | 1129 | * Create entry for . |
1129 | */ | 1130 | */ |
@@ -1133,10 +1134,11 @@ xfs_dir2_sf_to_block( | |||
1133 | dep->namelen = 1; | 1134 | dep->namelen = 1; |
1134 | dep->name[0] = '.'; | 1135 | dep->name[0] = '.'; |
1135 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1136 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1136 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 1137 | *tagp = cpu_to_be16((char *)dep - (char *)block); |
1137 | xfs_dir2_data_log_entry(tp, bp, dep); | 1138 | xfs_dir2_data_log_entry(tp, bp, dep); |
1138 | INT_SET(blp[0].hashval, ARCH_CONVERT, xfs_dir_hash_dot); | 1139 | blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot); |
1139 | INT_SET(blp[0].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block)); | 1140 | blp[0].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, |
1141 | (char *)dep - (char *)block)); | ||
1140 | /* | 1142 | /* |
1141 | * Create entry for .. | 1143 | * Create entry for .. |
1142 | */ | 1144 | */ |
@@ -1146,15 +1148,16 @@ xfs_dir2_sf_to_block( | |||
1146 | dep->namelen = 2; | 1148 | dep->namelen = 2; |
1147 | dep->name[0] = dep->name[1] = '.'; | 1149 | dep->name[0] = dep->name[1] = '.'; |
1148 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1150 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1149 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 1151 | *tagp = cpu_to_be16((char *)dep - (char *)block); |
1150 | xfs_dir2_data_log_entry(tp, bp, dep); | 1152 | xfs_dir2_data_log_entry(tp, bp, dep); |
1151 | INT_SET(blp[1].hashval, ARCH_CONVERT, xfs_dir_hash_dotdot); | 1153 | blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot); |
1152 | INT_SET(blp[1].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block)); | 1154 | blp[1].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, |
1155 | (char *)dep - (char *)block)); | ||
1153 | offset = XFS_DIR2_DATA_FIRST_OFFSET; | 1156 | offset = XFS_DIR2_DATA_FIRST_OFFSET; |
1154 | /* | 1157 | /* |
1155 | * Loop over existing entries, stuff them in. | 1158 | * Loop over existing entries, stuff them in. |
1156 | */ | 1159 | */ |
1157 | if ((i = 0) == INT_GET(sfp->hdr.count, ARCH_CONVERT)) | 1160 | if ((i = 0) == sfp->hdr.count) |
1158 | sfep = NULL; | 1161 | sfep = NULL; |
1159 | else | 1162 | else |
1160 | sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); | 1163 | sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); |
@@ -1176,15 +1179,14 @@ xfs_dir2_sf_to_block( | |||
1176 | if (offset < newoffset) { | 1179 | if (offset < newoffset) { |
1177 | dup = (xfs_dir2_data_unused_t *) | 1180 | dup = (xfs_dir2_data_unused_t *) |
1178 | ((char *)block + offset); | 1181 | ((char *)block + offset); |
1179 | INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 1182 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
1180 | INT_SET(dup->length, ARCH_CONVERT, newoffset - offset); | 1183 | dup->length = cpu_to_be16(newoffset - offset); |
1181 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, | 1184 | *XFS_DIR2_DATA_UNUSED_TAG_P(dup) = cpu_to_be16( |
1182 | (xfs_dir2_data_off_t) | ||
1183 | ((char *)dup - (char *)block)); | 1185 | ((char *)dup - (char *)block)); |
1184 | xfs_dir2_data_log_unused(tp, bp, dup); | 1186 | xfs_dir2_data_log_unused(tp, bp, dup); |
1185 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block, | 1187 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block, |
1186 | dup, &dummy); | 1188 | dup, &dummy); |
1187 | offset += INT_GET(dup->length, ARCH_CONVERT); | 1189 | offset += be16_to_cpu(dup->length); |
1188 | continue; | 1190 | continue; |
1189 | } | 1191 | } |
1190 | /* | 1192 | /* |
@@ -1196,13 +1198,14 @@ xfs_dir2_sf_to_block( | |||
1196 | dep->namelen = sfep->namelen; | 1198 | dep->namelen = sfep->namelen; |
1197 | memcpy(dep->name, sfep->name, dep->namelen); | 1199 | memcpy(dep->name, sfep->name, dep->namelen); |
1198 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1200 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1199 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 1201 | *tagp = cpu_to_be16((char *)dep - (char *)block); |
1200 | xfs_dir2_data_log_entry(tp, bp, dep); | 1202 | xfs_dir2_data_log_entry(tp, bp, dep); |
1201 | INT_SET(blp[2 + i].hashval, ARCH_CONVERT, xfs_da_hashname((char *)sfep->name, sfep->namelen)); | 1203 | blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname( |
1202 | INT_SET(blp[2 + i].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, | 1204 | (char *)sfep->name, sfep->namelen)); |
1205 | blp[2 + i].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, | ||
1203 | (char *)dep - (char *)block)); | 1206 | (char *)dep - (char *)block)); |
1204 | offset = (int)((char *)(tagp + 1) - (char *)block); | 1207 | offset = (int)((char *)(tagp + 1) - (char *)block); |
1205 | if (++i == INT_GET(sfp->hdr.count, ARCH_CONVERT)) | 1208 | if (++i == sfp->hdr.count) |
1206 | sfep = NULL; | 1209 | sfep = NULL; |
1207 | else | 1210 | else |
1208 | sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); | 1211 | sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); |
@@ -1212,13 +1215,13 @@ xfs_dir2_sf_to_block( | |||
1212 | /* | 1215 | /* |
1213 | * Sort the leaf entries by hash value. | 1216 | * Sort the leaf entries by hash value. |
1214 | */ | 1217 | */ |
1215 | xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort); | 1218 | xfs_sort(blp, be32_to_cpu(btp->count), sizeof(*blp), xfs_dir2_block_sort); |
1216 | /* | 1219 | /* |
1217 | * Log the leaf entry area and tail. | 1220 | * Log the leaf entry area and tail. |
1218 | * Already logged the header in data_init, ignore needlog. | 1221 | * Already logged the header in data_init, ignore needlog. |
1219 | */ | 1222 | */ |
1220 | ASSERT(needscan == 0); | 1223 | ASSERT(needscan == 0); |
1221 | xfs_dir2_block_log_leaf(tp, bp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1); | 1224 | xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1); |
1222 | xfs_dir2_block_log_tail(tp, bp); | 1225 | xfs_dir2_block_log_tail(tp, bp); |
1223 | xfs_dir2_data_check(dp, bp); | 1226 | xfs_dir2_data_check(dp, bp); |
1224 | xfs_da_buf_done(bp); | 1227 | xfs_da_buf_done(bp); |
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h index a2e5cb98a838..6722effd0b20 100644 --- a/fs/xfs/xfs_dir2_block.h +++ b/fs/xfs/xfs_dir2_block.h | |||
@@ -43,8 +43,8 @@ struct xfs_trans; | |||
43 | #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */ | 43 | #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */ |
44 | 44 | ||
45 | typedef struct xfs_dir2_block_tail { | 45 | typedef struct xfs_dir2_block_tail { |
46 | __uint32_t count; /* count of leaf entries */ | 46 | __be32 count; /* count of leaf entries */ |
47 | __uint32_t stale; /* count of stale lf entries */ | 47 | __be32 stale; /* count of stale lf entries */ |
48 | } xfs_dir2_block_tail_t; | 48 | } xfs_dir2_block_tail_t; |
49 | 49 | ||
50 | /* | 50 | /* |
@@ -75,8 +75,7 @@ xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) | |||
75 | static inline struct xfs_dir2_leaf_entry * | 75 | static inline struct xfs_dir2_leaf_entry * |
76 | xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) | 76 | xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) |
77 | { | 77 | { |
78 | return (((struct xfs_dir2_leaf_entry *) | 78 | return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count); |
79 | (btp)) - INT_GET((btp)->count, ARCH_CONVERT)); | ||
80 | } | 79 | } |
81 | 80 | ||
82 | /* | 81 | /* |
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index 5b7c47e2f14a..bb3d03ff002b 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -70,11 +70,11 @@ xfs_dir2_data_check( | |||
70 | 70 | ||
71 | mp = dp->i_mount; | 71 | mp = dp->i_mount; |
72 | d = bp->data; | 72 | d = bp->data; |
73 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 73 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
74 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 74 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
75 | bf = d->hdr.bestfree; | 75 | bf = d->hdr.bestfree; |
76 | p = (char *)d->u; | 76 | p = (char *)d->u; |
77 | if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | 77 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { |
78 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); | 78 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); |
79 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); | 79 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); |
80 | endp = (char *)lep; | 80 | endp = (char *)lep; |
@@ -96,8 +96,8 @@ xfs_dir2_data_check( | |||
96 | ASSERT(!bf[2].offset); | 96 | ASSERT(!bf[2].offset); |
97 | freeseen |= 1 << 2; | 97 | freeseen |= 1 << 2; |
98 | } | 98 | } |
99 | ASSERT(INT_GET(bf[0].length, ARCH_CONVERT) >= INT_GET(bf[1].length, ARCH_CONVERT)); | 99 | ASSERT(be16_to_cpu(bf[0].length) >= be16_to_cpu(bf[1].length)); |
100 | ASSERT(INT_GET(bf[1].length, ARCH_CONVERT) >= INT_GET(bf[2].length, ARCH_CONVERT)); | 100 | ASSERT(be16_to_cpu(bf[1].length) >= be16_to_cpu(bf[2].length)); |
101 | /* | 101 | /* |
102 | * Loop over the data/unused entries. | 102 | * Loop over the data/unused entries. |
103 | */ | 103 | */ |
@@ -108,18 +108,20 @@ xfs_dir2_data_check( | |||
108 | * If we find it, account for that, else make sure it | 108 | * If we find it, account for that, else make sure it |
109 | * doesn't need to be there. | 109 | * doesn't need to be there. |
110 | */ | 110 | */ |
111 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 111 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
112 | ASSERT(lastfree == 0); | 112 | ASSERT(lastfree == 0); |
113 | ASSERT(INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT) == | 113 | ASSERT(be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup)) == |
114 | (char *)dup - (char *)d); | 114 | (char *)dup - (char *)d); |
115 | dfp = xfs_dir2_data_freefind(d, dup); | 115 | dfp = xfs_dir2_data_freefind(d, dup); |
116 | if (dfp) { | 116 | if (dfp) { |
117 | i = (int)(dfp - bf); | 117 | i = (int)(dfp - bf); |
118 | ASSERT((freeseen & (1 << i)) == 0); | 118 | ASSERT((freeseen & (1 << i)) == 0); |
119 | freeseen |= 1 << i; | 119 | freeseen |= 1 << i; |
120 | } else | 120 | } else { |
121 | ASSERT(INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(bf[2].length, ARCH_CONVERT)); | 121 | ASSERT(be16_to_cpu(dup->length) <= |
122 | p += INT_GET(dup->length, ARCH_CONVERT); | 122 | be16_to_cpu(bf[2].length)); |
123 | } | ||
124 | p += be16_to_cpu(dup->length); | ||
123 | lastfree = 1; | 125 | lastfree = 1; |
124 | continue; | 126 | continue; |
125 | } | 127 | } |
@@ -132,21 +134,21 @@ xfs_dir2_data_check( | |||
132 | dep = (xfs_dir2_data_entry_t *)p; | 134 | dep = (xfs_dir2_data_entry_t *)p; |
133 | ASSERT(dep->namelen != 0); | 135 | ASSERT(dep->namelen != 0); |
134 | ASSERT(xfs_dir_ino_validate(mp, INT_GET(dep->inumber, ARCH_CONVERT)) == 0); | 136 | ASSERT(xfs_dir_ino_validate(mp, INT_GET(dep->inumber, ARCH_CONVERT)) == 0); |
135 | ASSERT(INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT) == | 137 | ASSERT(be16_to_cpu(*XFS_DIR2_DATA_ENTRY_TAG_P(dep)) == |
136 | (char *)dep - (char *)d); | 138 | (char *)dep - (char *)d); |
137 | count++; | 139 | count++; |
138 | lastfree = 0; | 140 | lastfree = 0; |
139 | if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | 141 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { |
140 | addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, | 142 | addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, |
141 | (xfs_dir2_data_aoff_t) | 143 | (xfs_dir2_data_aoff_t) |
142 | ((char *)dep - (char *)d)); | 144 | ((char *)dep - (char *)d)); |
143 | hash = xfs_da_hashname((char *)dep->name, dep->namelen); | 145 | hash = xfs_da_hashname((char *)dep->name, dep->namelen); |
144 | for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { | 146 | for (i = 0; i < be32_to_cpu(btp->count); i++) { |
145 | if (INT_GET(lep[i].address, ARCH_CONVERT) == addr && | 147 | if (be32_to_cpu(lep[i].address) == addr && |
146 | INT_GET(lep[i].hashval, ARCH_CONVERT) == hash) | 148 | be32_to_cpu(lep[i].hashval) == hash) |
147 | break; | 149 | break; |
148 | } | 150 | } |
149 | ASSERT(i < INT_GET(btp->count, ARCH_CONVERT)); | 151 | ASSERT(i < be32_to_cpu(btp->count)); |
150 | } | 152 | } |
151 | p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); | 153 | p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); |
152 | } | 154 | } |
@@ -154,15 +156,15 @@ xfs_dir2_data_check( | |||
154 | * Need to have seen all the entries and all the bestfree slots. | 156 | * Need to have seen all the entries and all the bestfree slots. |
155 | */ | 157 | */ |
156 | ASSERT(freeseen == 7); | 158 | ASSERT(freeseen == 7); |
157 | if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | 159 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { |
158 | for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { | 160 | for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { |
159 | if (INT_GET(lep[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 161 | if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR) |
160 | stale++; | 162 | stale++; |
161 | if (i > 0) | 163 | if (i > 0) |
162 | ASSERT(INT_GET(lep[i].hashval, ARCH_CONVERT) >= INT_GET(lep[i - 1].hashval, ARCH_CONVERT)); | 164 | ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval)); |
163 | } | 165 | } |
164 | ASSERT(count == INT_GET(btp->count, ARCH_CONVERT) - INT_GET(btp->stale, ARCH_CONVERT)); | 166 | ASSERT(count == be32_to_cpu(btp->count) - be32_to_cpu(btp->stale)); |
165 | ASSERT(stale == INT_GET(btp->stale, ARCH_CONVERT)); | 167 | ASSERT(stale == be32_to_cpu(btp->stale)); |
166 | } | 168 | } |
167 | } | 169 | } |
168 | #endif | 170 | #endif |
@@ -190,8 +192,8 @@ xfs_dir2_data_freefind( | |||
190 | * Check order, non-overlapping entries, and if we find the | 192 | * Check order, non-overlapping entries, and if we find the |
191 | * one we're looking for it has to be exact. | 193 | * one we're looking for it has to be exact. |
192 | */ | 194 | */ |
193 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 195 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
194 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 196 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
195 | for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0; | 197 | for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0; |
196 | dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; | 198 | dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; |
197 | dfp++) { | 199 | dfp++) { |
@@ -201,23 +203,24 @@ xfs_dir2_data_freefind( | |||
201 | continue; | 203 | continue; |
202 | } | 204 | } |
203 | ASSERT(seenzero == 0); | 205 | ASSERT(seenzero == 0); |
204 | if (INT_GET(dfp->offset, ARCH_CONVERT) == off) { | 206 | if (be16_to_cpu(dfp->offset) == off) { |
205 | matched = 1; | 207 | matched = 1; |
206 | ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(dup->length, ARCH_CONVERT)); | 208 | ASSERT(dfp->length == dup->length); |
207 | } else if (off < INT_GET(dfp->offset, ARCH_CONVERT)) | 209 | } else if (off < be16_to_cpu(dfp->offset)) |
208 | ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(dfp->offset, ARCH_CONVERT)); | 210 | ASSERT(off + be16_to_cpu(dup->length) <= be16_to_cpu(dfp->offset)); |
209 | else | 211 | else |
210 | ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) + INT_GET(dfp->length, ARCH_CONVERT) <= off); | 212 | ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off); |
211 | ASSERT(matched || INT_GET(dfp->length, ARCH_CONVERT) >= INT_GET(dup->length, ARCH_CONVERT)); | 213 | ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length)); |
212 | if (dfp > &d->hdr.bestfree[0]) | 214 | if (dfp > &d->hdr.bestfree[0]) |
213 | ASSERT(INT_GET(dfp[-1].length, ARCH_CONVERT) >= INT_GET(dfp[0].length, ARCH_CONVERT)); | 215 | ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length)); |
214 | } | 216 | } |
215 | #endif | 217 | #endif |
216 | /* | 218 | /* |
217 | * If this is smaller than the smallest bestfree entry, | 219 | * If this is smaller than the smallest bestfree entry, |
218 | * it can't be there since they're sorted. | 220 | * it can't be there since they're sorted. |
219 | */ | 221 | */ |
220 | if (INT_GET(dup->length, ARCH_CONVERT) < INT_GET(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length, ARCH_CONVERT)) | 222 | if (be16_to_cpu(dup->length) < |
223 | be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length)) | ||
221 | return NULL; | 224 | return NULL; |
222 | /* | 225 | /* |
223 | * Look at the three bestfree entries for our guy. | 226 | * Look at the three bestfree entries for our guy. |
@@ -227,7 +230,7 @@ xfs_dir2_data_freefind( | |||
227 | dfp++) { | 230 | dfp++) { |
228 | if (!dfp->offset) | 231 | if (!dfp->offset) |
229 | return NULL; | 232 | return NULL; |
230 | if (INT_GET(dfp->offset, ARCH_CONVERT) == off) | 233 | if (be16_to_cpu(dfp->offset) == off) |
231 | return dfp; | 234 | return dfp; |
232 | } | 235 | } |
233 | /* | 236 | /* |
@@ -249,29 +252,29 @@ xfs_dir2_data_freeinsert( | |||
249 | xfs_dir2_data_free_t new; /* new bestfree entry */ | 252 | xfs_dir2_data_free_t new; /* new bestfree entry */ |
250 | 253 | ||
251 | #ifdef __KERNEL__ | 254 | #ifdef __KERNEL__ |
252 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 255 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
253 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 256 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
254 | #endif | 257 | #endif |
255 | dfp = d->hdr.bestfree; | 258 | dfp = d->hdr.bestfree; |
256 | INT_COPY(new.length, dup->length, ARCH_CONVERT); | 259 | new.length = dup->length; |
257 | INT_SET(new.offset, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dup - (char *)d)); | 260 | new.offset = cpu_to_be16((char *)dup - (char *)d); |
258 | /* | 261 | /* |
259 | * Insert at position 0, 1, or 2; or not at all. | 262 | * Insert at position 0, 1, or 2; or not at all. |
260 | */ | 263 | */ |
261 | if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[0].length, ARCH_CONVERT)) { | 264 | if (be16_to_cpu(new.length) > be16_to_cpu(dfp[0].length)) { |
262 | dfp[2] = dfp[1]; | 265 | dfp[2] = dfp[1]; |
263 | dfp[1] = dfp[0]; | 266 | dfp[1] = dfp[0]; |
264 | dfp[0] = new; | 267 | dfp[0] = new; |
265 | *loghead = 1; | 268 | *loghead = 1; |
266 | return &dfp[0]; | 269 | return &dfp[0]; |
267 | } | 270 | } |
268 | if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[1].length, ARCH_CONVERT)) { | 271 | if (be16_to_cpu(new.length) > be16_to_cpu(dfp[1].length)) { |
269 | dfp[2] = dfp[1]; | 272 | dfp[2] = dfp[1]; |
270 | dfp[1] = new; | 273 | dfp[1] = new; |
271 | *loghead = 1; | 274 | *loghead = 1; |
272 | return &dfp[1]; | 275 | return &dfp[1]; |
273 | } | 276 | } |
274 | if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[2].length, ARCH_CONVERT)) { | 277 | if (be16_to_cpu(new.length) > be16_to_cpu(dfp[2].length)) { |
275 | dfp[2] = new; | 278 | dfp[2] = new; |
276 | *loghead = 1; | 279 | *loghead = 1; |
277 | return &dfp[2]; | 280 | return &dfp[2]; |
@@ -289,8 +292,8 @@ xfs_dir2_data_freeremove( | |||
289 | int *loghead) /* out: log data header */ | 292 | int *loghead) /* out: log data header */ |
290 | { | 293 | { |
291 | #ifdef __KERNEL__ | 294 | #ifdef __KERNEL__ |
292 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 295 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
293 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 296 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
294 | #endif | 297 | #endif |
295 | /* | 298 | /* |
296 | * It's the first entry, slide the next 2 up. | 299 | * It's the first entry, slide the next 2 up. |
@@ -334,8 +337,8 @@ xfs_dir2_data_freescan( | |||
334 | char *p; /* current entry pointer */ | 337 | char *p; /* current entry pointer */ |
335 | 338 | ||
336 | #ifdef __KERNEL__ | 339 | #ifdef __KERNEL__ |
337 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 340 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
338 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 341 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
339 | #endif | 342 | #endif |
340 | /* | 343 | /* |
341 | * Start by clearing the table. | 344 | * Start by clearing the table. |
@@ -348,7 +351,7 @@ xfs_dir2_data_freescan( | |||
348 | p = (char *)d->u; | 351 | p = (char *)d->u; |
349 | if (aendp) | 352 | if (aendp) |
350 | endp = aendp; | 353 | endp = aendp; |
351 | else if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | 354 | else if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { |
352 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); | 355 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); |
353 | endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); | 356 | endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); |
354 | } else | 357 | } else |
@@ -361,11 +364,11 @@ xfs_dir2_data_freescan( | |||
361 | /* | 364 | /* |
362 | * If it's a free entry, insert it. | 365 | * If it's a free entry, insert it. |
363 | */ | 366 | */ |
364 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 367 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
365 | ASSERT((char *)dup - (char *)d == | 368 | ASSERT((char *)dup - (char *)d == |
366 | INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT)); | 369 | be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup))); |
367 | xfs_dir2_data_freeinsert(d, dup, loghead); | 370 | xfs_dir2_data_freeinsert(d, dup, loghead); |
368 | p += INT_GET(dup->length, ARCH_CONVERT); | 371 | p += be16_to_cpu(dup->length); |
369 | } | 372 | } |
370 | /* | 373 | /* |
371 | * For active entries, check their tags and skip them. | 374 | * For active entries, check their tags and skip them. |
@@ -373,7 +376,7 @@ xfs_dir2_data_freescan( | |||
373 | else { | 376 | else { |
374 | dep = (xfs_dir2_data_entry_t *)p; | 377 | dep = (xfs_dir2_data_entry_t *)p; |
375 | ASSERT((char *)dep - (char *)d == | 378 | ASSERT((char *)dep - (char *)d == |
376 | INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT)); | 379 | be16_to_cpu(*XFS_DIR2_DATA_ENTRY_TAG_P(dep))); |
377 | p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); | 380 | p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); |
378 | } | 381 | } |
379 | } | 382 | } |
@@ -415,8 +418,8 @@ xfs_dir2_data_init( | |||
415 | * Initialize the header. | 418 | * Initialize the header. |
416 | */ | 419 | */ |
417 | d = bp->data; | 420 | d = bp->data; |
418 | INT_SET(d->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); | 421 | d->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); |
419 | INT_SET(d->hdr.bestfree[0].offset, ARCH_CONVERT, (xfs_dir2_data_off_t)sizeof(d->hdr)); | 422 | d->hdr.bestfree[0].offset = cpu_to_be16(sizeof(d->hdr)); |
420 | for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { | 423 | for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { |
421 | d->hdr.bestfree[i].length = 0; | 424 | d->hdr.bestfree[i].length = 0; |
422 | d->hdr.bestfree[i].offset = 0; | 425 | d->hdr.bestfree[i].offset = 0; |
@@ -425,13 +428,12 @@ xfs_dir2_data_init( | |||
425 | * Set up an unused entry for the block's body. | 428 | * Set up an unused entry for the block's body. |
426 | */ | 429 | */ |
427 | dup = &d->u[0].unused; | 430 | dup = &d->u[0].unused; |
428 | INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 431 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
429 | 432 | ||
430 | t=mp->m_dirblksize - (uint)sizeof(d->hdr); | 433 | t=mp->m_dirblksize - (uint)sizeof(d->hdr); |
431 | INT_SET(d->hdr.bestfree[0].length, ARCH_CONVERT, t); | 434 | d->hdr.bestfree[0].length = cpu_to_be16(t); |
432 | INT_SET(dup->length, ARCH_CONVERT, t); | 435 | dup->length = cpu_to_be16(t); |
433 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, | 436 | *XFS_DIR2_DATA_UNUSED_TAG_P(dup) = cpu_to_be16((char *)dup - (char *)d); |
434 | (xfs_dir2_data_off_t)((char *)dup - (char *)d)); | ||
435 | /* | 437 | /* |
436 | * Log it and return it. | 438 | * Log it and return it. |
437 | */ | 439 | */ |
@@ -453,8 +455,8 @@ xfs_dir2_data_log_entry( | |||
453 | xfs_dir2_data_t *d; /* data block pointer */ | 455 | xfs_dir2_data_t *d; /* data block pointer */ |
454 | 456 | ||
455 | d = bp->data; | 457 | d = bp->data; |
456 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 458 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
457 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 459 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
458 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d), | 460 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d), |
459 | (uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) - | 461 | (uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) - |
460 | (char *)d - 1)); | 462 | (char *)d - 1)); |
@@ -471,8 +473,8 @@ xfs_dir2_data_log_header( | |||
471 | xfs_dir2_data_t *d; /* data block pointer */ | 473 | xfs_dir2_data_t *d; /* data block pointer */ |
472 | 474 | ||
473 | d = bp->data; | 475 | d = bp->data; |
474 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 476 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
475 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 477 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
476 | xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d), | 478 | xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d), |
477 | (uint)(sizeof(d->hdr) - 1)); | 479 | (uint)(sizeof(d->hdr) - 1)); |
478 | } | 480 | } |
@@ -489,8 +491,8 @@ xfs_dir2_data_log_unused( | |||
489 | xfs_dir2_data_t *d; /* data block pointer */ | 491 | xfs_dir2_data_t *d; /* data block pointer */ |
490 | 492 | ||
491 | d = bp->data; | 493 | d = bp->data; |
492 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 494 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
493 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 495 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
494 | /* | 496 | /* |
495 | * Log the first part of the unused entry. | 497 | * Log the first part of the unused entry. |
496 | */ | 498 | */ |
@@ -533,12 +535,12 @@ xfs_dir2_data_make_free( | |||
533 | /* | 535 | /* |
534 | * Figure out where the end of the data area is. | 536 | * Figure out where the end of the data area is. |
535 | */ | 537 | */ |
536 | if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC) | 538 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC) |
537 | endptr = (char *)d + mp->m_dirblksize; | 539 | endptr = (char *)d + mp->m_dirblksize; |
538 | else { | 540 | else { |
539 | xfs_dir2_block_tail_t *btp; /* block tail */ | 541 | xfs_dir2_block_tail_t *btp; /* block tail */ |
540 | 542 | ||
541 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 543 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
542 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); | 544 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); |
543 | endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); | 545 | endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); |
544 | } | 546 | } |
@@ -547,11 +549,11 @@ xfs_dir2_data_make_free( | |||
547 | * the previous entry and see if it's free. | 549 | * the previous entry and see if it's free. |
548 | */ | 550 | */ |
549 | if (offset > sizeof(d->hdr)) { | 551 | if (offset > sizeof(d->hdr)) { |
550 | xfs_dir2_data_off_t *tagp; /* tag just before us */ | 552 | __be16 *tagp; /* tag just before us */ |
551 | 553 | ||
552 | tagp = (xfs_dir2_data_off_t *)((char *)d + offset) - 1; | 554 | tagp = (__be16 *)((char *)d + offset) - 1; |
553 | prevdup = (xfs_dir2_data_unused_t *)((char *)d + INT_GET(*tagp, ARCH_CONVERT)); | 555 | prevdup = (xfs_dir2_data_unused_t *)((char *)d + be16_to_cpu(*tagp)); |
554 | if (INT_GET(prevdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG) | 556 | if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
555 | prevdup = NULL; | 557 | prevdup = NULL; |
556 | } else | 558 | } else |
557 | prevdup = NULL; | 559 | prevdup = NULL; |
@@ -562,7 +564,7 @@ xfs_dir2_data_make_free( | |||
562 | if ((char *)d + offset + len < endptr) { | 564 | if ((char *)d + offset + len < endptr) { |
563 | postdup = | 565 | postdup = |
564 | (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 566 | (xfs_dir2_data_unused_t *)((char *)d + offset + len); |
565 | if (INT_GET(postdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG) | 567 | if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
566 | postdup = NULL; | 568 | postdup = NULL; |
567 | } else | 569 | } else |
568 | postdup = NULL; | 570 | postdup = NULL; |
@@ -586,13 +588,13 @@ xfs_dir2_data_make_free( | |||
586 | * since the third bestfree is there, there might be more | 588 | * since the third bestfree is there, there might be more |
587 | * entries. | 589 | * entries. |
588 | */ | 590 | */ |
589 | needscan = d->hdr.bestfree[2].length; | 591 | needscan = (d->hdr.bestfree[2].length != 0); |
590 | /* | 592 | /* |
591 | * Fix up the new big freespace. | 593 | * Fix up the new big freespace. |
592 | */ | 594 | */ |
593 | INT_MOD(prevdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT)); | 595 | be16_add(&prevdup->length, len + be16_to_cpu(postdup->length)); |
594 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT, | 596 | *XFS_DIR2_DATA_UNUSED_TAG_P(prevdup) = |
595 | (xfs_dir2_data_off_t)((char *)prevdup - (char *)d)); | 597 | cpu_to_be16((char *)prevdup - (char *)d); |
596 | xfs_dir2_data_log_unused(tp, bp, prevdup); | 598 | xfs_dir2_data_log_unused(tp, bp, prevdup); |
597 | if (!needscan) { | 599 | if (!needscan) { |
598 | /* | 600 | /* |
@@ -614,7 +616,7 @@ xfs_dir2_data_make_free( | |||
614 | */ | 616 | */ |
615 | dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); | 617 | dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); |
616 | ASSERT(dfp == &d->hdr.bestfree[0]); | 618 | ASSERT(dfp == &d->hdr.bestfree[0]); |
617 | ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(prevdup->length, ARCH_CONVERT)); | 619 | ASSERT(dfp->length == prevdup->length); |
618 | ASSERT(!dfp[1].length); | 620 | ASSERT(!dfp[1].length); |
619 | ASSERT(!dfp[2].length); | 621 | ASSERT(!dfp[2].length); |
620 | } | 622 | } |
@@ -624,9 +626,9 @@ xfs_dir2_data_make_free( | |||
624 | */ | 626 | */ |
625 | else if (prevdup) { | 627 | else if (prevdup) { |
626 | dfp = xfs_dir2_data_freefind(d, prevdup); | 628 | dfp = xfs_dir2_data_freefind(d, prevdup); |
627 | INT_MOD(prevdup->length, ARCH_CONVERT, len); | 629 | be16_add(&prevdup->length, len); |
628 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT, | 630 | *XFS_DIR2_DATA_UNUSED_TAG_P(prevdup) = |
629 | (xfs_dir2_data_off_t)((char *)prevdup - (char *)d)); | 631 | cpu_to_be16((char *)prevdup - (char *)d); |
630 | xfs_dir2_data_log_unused(tp, bp, prevdup); | 632 | xfs_dir2_data_log_unused(tp, bp, prevdup); |
631 | /* | 633 | /* |
632 | * If the previous entry was in the table, the new entry | 634 | * If the previous entry was in the table, the new entry |
@@ -640,8 +642,10 @@ xfs_dir2_data_make_free( | |||
640 | /* | 642 | /* |
641 | * Otherwise we need a scan if the new entry is big enough. | 643 | * Otherwise we need a scan if the new entry is big enough. |
642 | */ | 644 | */ |
643 | else | 645 | else { |
644 | needscan = INT_GET(prevdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT); | 646 | needscan = be16_to_cpu(prevdup->length) > |
647 | be16_to_cpu(d->hdr.bestfree[2].length); | ||
648 | } | ||
645 | } | 649 | } |
646 | /* | 650 | /* |
647 | * The following entry is free, merge with it. | 651 | * The following entry is free, merge with it. |
@@ -649,10 +653,10 @@ xfs_dir2_data_make_free( | |||
649 | else if (postdup) { | 653 | else if (postdup) { |
650 | dfp = xfs_dir2_data_freefind(d, postdup); | 654 | dfp = xfs_dir2_data_freefind(d, postdup); |
651 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); | 655 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); |
652 | INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 656 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
653 | INT_SET(newdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT)); | 657 | newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); |
654 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 658 | *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = |
655 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 659 | cpu_to_be16((char *)newdup - (char *)d); |
656 | xfs_dir2_data_log_unused(tp, bp, newdup); | 660 | xfs_dir2_data_log_unused(tp, bp, newdup); |
657 | /* | 661 | /* |
658 | * If the following entry was in the table, the new entry | 662 | * If the following entry was in the table, the new entry |
@@ -666,18 +670,20 @@ xfs_dir2_data_make_free( | |||
666 | /* | 670 | /* |
667 | * Otherwise we need a scan if the new entry is big enough. | 671 | * Otherwise we need a scan if the new entry is big enough. |
668 | */ | 672 | */ |
669 | else | 673 | else { |
670 | needscan = INT_GET(newdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT); | 674 | needscan = be16_to_cpu(newdup->length) > |
675 | be16_to_cpu(d->hdr.bestfree[2].length); | ||
676 | } | ||
671 | } | 677 | } |
672 | /* | 678 | /* |
673 | * Neither neighbor is free. Make a new entry. | 679 | * Neither neighbor is free. Make a new entry. |
674 | */ | 680 | */ |
675 | else { | 681 | else { |
676 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); | 682 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); |
677 | INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 683 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
678 | INT_SET(newdup->length, ARCH_CONVERT, len); | 684 | newdup->length = cpu_to_be16(len); |
679 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 685 | *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = |
680 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 686 | cpu_to_be16((char *)newdup - (char *)d); |
681 | xfs_dir2_data_log_unused(tp, bp, newdup); | 687 | xfs_dir2_data_log_unused(tp, bp, newdup); |
682 | (void)xfs_dir2_data_freeinsert(d, newdup, needlogp); | 688 | (void)xfs_dir2_data_freeinsert(d, newdup, needlogp); |
683 | } | 689 | } |
@@ -707,18 +713,18 @@ xfs_dir2_data_use_free( | |||
707 | int oldlen; /* old unused entry's length */ | 713 | int oldlen; /* old unused entry's length */ |
708 | 714 | ||
709 | d = bp->data; | 715 | d = bp->data; |
710 | ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | 716 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
711 | INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | 717 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
712 | ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG); | 718 | ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); |
713 | ASSERT(offset >= (char *)dup - (char *)d); | 719 | ASSERT(offset >= (char *)dup - (char *)d); |
714 | ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d); | 720 | ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d); |
715 | ASSERT((char *)dup - (char *)d == INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT)); | 721 | ASSERT((char *)dup - (char *)d == be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup))); |
716 | /* | 722 | /* |
717 | * Look up the entry in the bestfree table. | 723 | * Look up the entry in the bestfree table. |
718 | */ | 724 | */ |
719 | dfp = xfs_dir2_data_freefind(d, dup); | 725 | dfp = xfs_dir2_data_freefind(d, dup); |
720 | oldlen = INT_GET(dup->length, ARCH_CONVERT); | 726 | oldlen = be16_to_cpu(dup->length); |
721 | ASSERT(dfp || oldlen <= INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT)); | 727 | ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length)); |
722 | /* | 728 | /* |
723 | * Check for alignment with front and back of the entry. | 729 | * Check for alignment with front and back of the entry. |
724 | */ | 730 | */ |
@@ -732,7 +738,7 @@ xfs_dir2_data_use_free( | |||
732 | */ | 738 | */ |
733 | if (matchfront && matchback) { | 739 | if (matchfront && matchback) { |
734 | if (dfp) { | 740 | if (dfp) { |
735 | needscan = d->hdr.bestfree[2].offset; | 741 | needscan = (d->hdr.bestfree[2].offset != 0); |
736 | if (!needscan) | 742 | if (!needscan) |
737 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 743 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
738 | } | 744 | } |
@@ -743,10 +749,10 @@ xfs_dir2_data_use_free( | |||
743 | */ | 749 | */ |
744 | else if (matchfront) { | 750 | else if (matchfront) { |
745 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 751 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len); |
746 | INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 752 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
747 | INT_SET(newdup->length, ARCH_CONVERT, oldlen - len); | 753 | newdup->length = cpu_to_be16(oldlen - len); |
748 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 754 | *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = |
749 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 755 | cpu_to_be16((char *)newdup - (char *)d); |
750 | xfs_dir2_data_log_unused(tp, bp, newdup); | 756 | xfs_dir2_data_log_unused(tp, bp, newdup); |
751 | /* | 757 | /* |
752 | * If it was in the table, remove it and add the new one. | 758 | * If it was in the table, remove it and add the new one. |
@@ -755,8 +761,8 @@ xfs_dir2_data_use_free( | |||
755 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 761 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
756 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); | 762 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); |
757 | ASSERT(dfp != NULL); | 763 | ASSERT(dfp != NULL); |
758 | ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT)); | 764 | ASSERT(dfp->length == newdup->length); |
759 | ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d); | 765 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); |
760 | /* | 766 | /* |
761 | * If we got inserted at the last slot, | 767 | * If we got inserted at the last slot, |
762 | * that means we don't know if there was a better | 768 | * that means we don't know if there was a better |
@@ -771,10 +777,9 @@ xfs_dir2_data_use_free( | |||
771 | */ | 777 | */ |
772 | else if (matchback) { | 778 | else if (matchback) { |
773 | newdup = dup; | 779 | newdup = dup; |
774 | INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t) | 780 | newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); |
775 | (((char *)d + offset) - (char *)newdup)); | 781 | *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = |
776 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 782 | cpu_to_be16((char *)newdup - (char *)d); |
777 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | ||
778 | xfs_dir2_data_log_unused(tp, bp, newdup); | 783 | xfs_dir2_data_log_unused(tp, bp, newdup); |
779 | /* | 784 | /* |
780 | * If it was in the table, remove it and add the new one. | 785 | * If it was in the table, remove it and add the new one. |
@@ -783,8 +788,8 @@ xfs_dir2_data_use_free( | |||
783 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 788 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
784 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); | 789 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); |
785 | ASSERT(dfp != NULL); | 790 | ASSERT(dfp != NULL); |
786 | ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT)); | 791 | ASSERT(dfp->length == newdup->length); |
787 | ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d); | 792 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); |
788 | /* | 793 | /* |
789 | * If we got inserted at the last slot, | 794 | * If we got inserted at the last slot, |
790 | * that means we don't know if there was a better | 795 | * that means we don't know if there was a better |
@@ -799,16 +804,15 @@ xfs_dir2_data_use_free( | |||
799 | */ | 804 | */ |
800 | else { | 805 | else { |
801 | newdup = dup; | 806 | newdup = dup; |
802 | INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t) | 807 | newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); |
803 | (((char *)d + offset) - (char *)newdup)); | 808 | *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = |
804 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 809 | cpu_to_be16((char *)newdup - (char *)d); |
805 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | ||
806 | xfs_dir2_data_log_unused(tp, bp, newdup); | 810 | xfs_dir2_data_log_unused(tp, bp, newdup); |
807 | newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 811 | newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len); |
808 | INT_SET(newdup2->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 812 | newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
809 | INT_SET(newdup2->length, ARCH_CONVERT, oldlen - len - INT_GET(newdup->length, ARCH_CONVERT)); | 813 | newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); |
810 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2), ARCH_CONVERT, | 814 | *XFS_DIR2_DATA_UNUSED_TAG_P(newdup2) = |
811 | (xfs_dir2_data_off_t)((char *)newdup2 - (char *)d)); | 815 | cpu_to_be16((char *)newdup2 - (char *)d); |
812 | xfs_dir2_data_log_unused(tp, bp, newdup2); | 816 | xfs_dir2_data_log_unused(tp, bp, newdup2); |
813 | /* | 817 | /* |
814 | * If the old entry was in the table, we need to scan | 818 | * If the old entry was in the table, we need to scan |
@@ -819,7 +823,7 @@ xfs_dir2_data_use_free( | |||
819 | * the 2 new will work. | 823 | * the 2 new will work. |
820 | */ | 824 | */ |
821 | if (dfp) { | 825 | if (dfp) { |
822 | needscan = d->hdr.bestfree[2].length; | 826 | needscan = (d->hdr.bestfree[2].length != 0); |
823 | if (!needscan) { | 827 | if (!needscan) { |
824 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 828 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
825 | (void)xfs_dir2_data_freeinsert(d, newdup, | 829 | (void)xfs_dir2_data_freeinsert(d, newdup, |
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h index 5e3a7f9ec735..0847cbb53e17 100644 --- a/fs/xfs/xfs_dir2_data.h +++ b/fs/xfs/xfs_dir2_data.h | |||
@@ -65,8 +65,8 @@ struct xfs_trans; | |||
65 | * The freespace will be formatted as a xfs_dir2_data_unused_t. | 65 | * The freespace will be formatted as a xfs_dir2_data_unused_t. |
66 | */ | 66 | */ |
67 | typedef struct xfs_dir2_data_free { | 67 | typedef struct xfs_dir2_data_free { |
68 | xfs_dir2_data_off_t offset; /* start of freespace */ | 68 | __be16 offset; /* start of freespace */ |
69 | xfs_dir2_data_off_t length; /* length of freespace */ | 69 | __be16 length; /* length of freespace */ |
70 | } xfs_dir2_data_free_t; | 70 | } xfs_dir2_data_free_t; |
71 | 71 | ||
72 | /* | 72 | /* |
@@ -75,7 +75,7 @@ typedef struct xfs_dir2_data_free { | |||
75 | * The code knows that XFS_DIR2_DATA_FD_COUNT is 3. | 75 | * The code knows that XFS_DIR2_DATA_FD_COUNT is 3. |
76 | */ | 76 | */ |
77 | typedef struct xfs_dir2_data_hdr { | 77 | typedef struct xfs_dir2_data_hdr { |
78 | __uint32_t magic; /* XFS_DIR2_DATA_MAGIC */ | 78 | __be32 magic; /* XFS_DIR2_DATA_MAGIC */ |
79 | /* or XFS_DIR2_BLOCK_MAGIC */ | 79 | /* or XFS_DIR2_BLOCK_MAGIC */ |
80 | xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT]; | 80 | xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT]; |
81 | } xfs_dir2_data_hdr_t; | 81 | } xfs_dir2_data_hdr_t; |
@@ -97,10 +97,10 @@ typedef struct xfs_dir2_data_entry { | |||
97 | * Tag appears as the last 2 bytes. | 97 | * Tag appears as the last 2 bytes. |
98 | */ | 98 | */ |
99 | typedef struct xfs_dir2_data_unused { | 99 | typedef struct xfs_dir2_data_unused { |
100 | __uint16_t freetag; /* XFS_DIR2_DATA_FREE_TAG */ | 100 | __be16 freetag; /* XFS_DIR2_DATA_FREE_TAG */ |
101 | xfs_dir2_data_off_t length; /* total free length */ | 101 | __be16 length; /* total free length */ |
102 | /* variable offset */ | 102 | /* variable offset */ |
103 | xfs_dir2_data_off_t tag; /* starting offset of us */ | 103 | __be16 tag; /* starting offset of us */ |
104 | } xfs_dir2_data_unused_t; | 104 | } xfs_dir2_data_unused_t; |
105 | 105 | ||
106 | typedef union { | 106 | typedef union { |
@@ -134,12 +134,11 @@ static inline int xfs_dir2_data_entsize(int n) | |||
134 | * Pointer to an entry's tag word. | 134 | * Pointer to an entry's tag word. |
135 | */ | 135 | */ |
136 | #define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep) | 136 | #define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep) |
137 | static inline xfs_dir2_data_off_t * | 137 | static inline __be16 * |
138 | xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep) | 138 | xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep) |
139 | { | 139 | { |
140 | return (xfs_dir2_data_off_t *) \ | 140 | return (__be16 *)((char *)dep + |
141 | ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \ | 141 | XFS_DIR2_DATA_ENTSIZE(dep->namelen) - sizeof(__be16)); |
142 | (uint)sizeof(xfs_dir2_data_off_t)); | ||
143 | } | 142 | } |
144 | 143 | ||
145 | /* | 144 | /* |
@@ -147,12 +146,11 @@ xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep) | |||
147 | */ | 146 | */ |
148 | #define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ | 147 | #define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ |
149 | xfs_dir2_data_unused_tag_p(dup) | 148 | xfs_dir2_data_unused_tag_p(dup) |
150 | static inline xfs_dir2_data_off_t * | 149 | static inline __be16 * |
151 | xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) | 150 | xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) |
152 | { | 151 | { |
153 | return (xfs_dir2_data_off_t *) \ | 152 | return (__be16 *)((char *)dup + |
154 | ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \ | 153 | be16_to_cpu(dup->length) - sizeof(__be16)); |
155 | - (uint)sizeof(xfs_dir2_data_off_t)); | ||
156 | } | 154 | } |
157 | 155 | ||
158 | /* | 156 | /* |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index d342b6b55239..08648b18265c 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -66,7 +66,7 @@ xfs_dir2_block_to_leaf( | |||
66 | xfs_da_args_t *args, /* operation arguments */ | 66 | xfs_da_args_t *args, /* operation arguments */ |
67 | xfs_dabuf_t *dbp) /* input block's buffer */ | 67 | xfs_dabuf_t *dbp) /* input block's buffer */ |
68 | { | 68 | { |
69 | xfs_dir2_data_off_t *bestsp; /* leaf's bestsp entries */ | 69 | __be16 *bestsp; /* leaf's bestsp entries */ |
70 | xfs_dablk_t blkno; /* leaf block's bno */ | 70 | xfs_dablk_t blkno; /* leaf block's bno */ |
71 | xfs_dir2_block_t *block; /* block structure */ | 71 | xfs_dir2_block_t *block; /* block structure */ |
72 | xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ | 72 | xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ |
@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf( | |||
111 | /* | 111 | /* |
112 | * Set the counts in the leaf header. | 112 | * Set the counts in the leaf header. |
113 | */ | 113 | */ |
114 | INT_COPY(leaf->hdr.count, btp->count, ARCH_CONVERT); /* INT_: type change */ | 114 | leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count)); |
115 | INT_COPY(leaf->hdr.stale, btp->stale, ARCH_CONVERT); /* INT_: type change */ | 115 | leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale)); |
116 | /* | 116 | /* |
117 | * Could compact these but I think we always do the conversion | 117 | * Could compact these but I think we always do the conversion |
118 | * after squeezing out stale entries. | 118 | * after squeezing out stale entries. |
119 | */ | 119 | */ |
120 | memcpy(leaf->ents, blp, INT_GET(btp->count, ARCH_CONVERT) * sizeof(xfs_dir2_leaf_entry_t)); | 120 | memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); |
121 | xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1); | 121 | xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1); |
122 | needscan = 0; | 122 | needscan = 0; |
123 | needlog = 1; | 123 | needlog = 1; |
124 | /* | 124 | /* |
@@ -133,7 +133,7 @@ xfs_dir2_block_to_leaf( | |||
133 | /* | 133 | /* |
134 | * Fix up the block header, make it a data block. | 134 | * Fix up the block header, make it a data block. |
135 | */ | 135 | */ |
136 | INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); | 136 | block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); |
137 | if (needscan) | 137 | if (needscan) |
138 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, | 138 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, |
139 | NULL); | 139 | NULL); |
@@ -141,9 +141,9 @@ xfs_dir2_block_to_leaf( | |||
141 | * Set up leaf tail and bests table. | 141 | * Set up leaf tail and bests table. |
142 | */ | 142 | */ |
143 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 143 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
144 | INT_SET(ltp->bestcount, ARCH_CONVERT, 1); | 144 | ltp->bestcount = cpu_to_be32(1); |
145 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 145 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
146 | INT_COPY(bestsp[0], block->hdr.bestfree[0].length, ARCH_CONVERT); | 146 | bestsp[0] = block->hdr.bestfree[0].length; |
147 | /* | 147 | /* |
148 | * Log the data header and leaf bests table. | 148 | * Log the data header and leaf bests table. |
149 | */ | 149 | */ |
@@ -163,7 +163,7 @@ int /* error */ | |||
163 | xfs_dir2_leaf_addname( | 163 | xfs_dir2_leaf_addname( |
164 | xfs_da_args_t *args) /* operation arguments */ | 164 | xfs_da_args_t *args) /* operation arguments */ |
165 | { | 165 | { |
166 | xfs_dir2_data_off_t *bestsp; /* freespace table in leaf */ | 166 | __be16 *bestsp; /* freespace table in leaf */ |
167 | int compact; /* need to compact leaves */ | 167 | int compact; /* need to compact leaves */ |
168 | xfs_dir2_data_t *data; /* data block structure */ | 168 | xfs_dir2_data_t *data; /* data block structure */ |
169 | xfs_dabuf_t *dbp; /* data block buffer */ | 169 | xfs_dabuf_t *dbp; /* data block buffer */ |
@@ -187,7 +187,7 @@ xfs_dir2_leaf_addname( | |||
187 | int needbytes; /* leaf block bytes needed */ | 187 | int needbytes; /* leaf block bytes needed */ |
188 | int needlog; /* need to log data header */ | 188 | int needlog; /* need to log data header */ |
189 | int needscan; /* need to rescan data free */ | 189 | int needscan; /* need to rescan data free */ |
190 | xfs_dir2_data_off_t *tagp; /* end of data entry */ | 190 | __be16 *tagp; /* end of data entry */ |
191 | xfs_trans_t *tp; /* transaction pointer */ | 191 | xfs_trans_t *tp; /* transaction pointer */ |
192 | xfs_dir2_db_t use_block; /* data block number */ | 192 | xfs_dir2_db_t use_block; /* data block number */ |
193 | 193 | ||
@@ -222,14 +222,14 @@ xfs_dir2_leaf_addname( | |||
222 | * in a data block, improving the lookup of those entries. | 222 | * in a data block, improving the lookup of those entries. |
223 | */ | 223 | */ |
224 | for (use_block = -1, lep = &leaf->ents[index]; | 224 | for (use_block = -1, lep = &leaf->ents[index]; |
225 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 225 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
226 | index++, lep++) { | 226 | index++, lep++) { |
227 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 227 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
228 | continue; | 228 | continue; |
229 | i = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 229 | i = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
230 | ASSERT(i < INT_GET(ltp->bestcount, ARCH_CONVERT)); | 230 | ASSERT(i < be32_to_cpu(ltp->bestcount)); |
231 | ASSERT(INT_GET(bestsp[i], ARCH_CONVERT) != NULLDATAOFF); | 231 | ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF); |
232 | if (INT_GET(bestsp[i], ARCH_CONVERT) >= length) { | 232 | if (be16_to_cpu(bestsp[i]) >= length) { |
233 | use_block = i; | 233 | use_block = i; |
234 | break; | 234 | break; |
235 | } | 235 | } |
@@ -238,13 +238,13 @@ xfs_dir2_leaf_addname( | |||
238 | * Didn't find a block yet, linear search all the data blocks. | 238 | * Didn't find a block yet, linear search all the data blocks. |
239 | */ | 239 | */ |
240 | if (use_block == -1) { | 240 | if (use_block == -1) { |
241 | for (i = 0; i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++) { | 241 | for (i = 0; i < be32_to_cpu(ltp->bestcount); i++) { |
242 | /* | 242 | /* |
243 | * Remember a block we see that's missing. | 243 | * Remember a block we see that's missing. |
244 | */ | 244 | */ |
245 | if (INT_GET(bestsp[i], ARCH_CONVERT) == NULLDATAOFF && use_block == -1) | 245 | if (be16_to_cpu(bestsp[i]) == NULLDATAOFF && use_block == -1) |
246 | use_block = i; | 246 | use_block = i; |
247 | else if (INT_GET(bestsp[i], ARCH_CONVERT) >= length) { | 247 | else if (be16_to_cpu(bestsp[i]) >= length) { |
248 | use_block = i; | 248 | use_block = i; |
249 | break; | 249 | break; |
250 | } | 250 | } |
@@ -260,21 +260,21 @@ xfs_dir2_leaf_addname( | |||
260 | * Now kill use_block if it refers to a missing block, so we | 260 | * Now kill use_block if it refers to a missing block, so we |
261 | * can use it as an indication of allocation needed. | 261 | * can use it as an indication of allocation needed. |
262 | */ | 262 | */ |
263 | if (use_block != -1 && INT_GET(bestsp[use_block], ARCH_CONVERT) == NULLDATAOFF) | 263 | if (use_block != -1 && be16_to_cpu(bestsp[use_block]) == NULLDATAOFF) |
264 | use_block = -1; | 264 | use_block = -1; |
265 | /* | 265 | /* |
266 | * If we don't have enough free bytes but we can make enough | 266 | * If we don't have enough free bytes but we can make enough |
267 | * by compacting out stale entries, we'll do that. | 267 | * by compacting out stale entries, we'll do that. |
268 | */ | 268 | */ |
269 | if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes && | 269 | if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes && |
270 | INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) { | 270 | be16_to_cpu(leaf->hdr.stale) > 1) { |
271 | compact = 1; | 271 | compact = 1; |
272 | } | 272 | } |
273 | /* | 273 | /* |
274 | * Otherwise if we don't have enough free bytes we need to | 274 | * Otherwise if we don't have enough free bytes we need to |
275 | * convert to node form. | 275 | * convert to node form. |
276 | */ | 276 | */ |
277 | else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < | 277 | else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < |
278 | needbytes) { | 278 | needbytes) { |
279 | /* | 279 | /* |
280 | * Just checking or no space reservation, give up. | 280 | * Just checking or no space reservation, give up. |
@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname( | |||
330 | * There are stale entries, so we'll need log-low and log-high | 330 | * There are stale entries, so we'll need log-low and log-high |
331 | * impossibly bad values later. | 331 | * impossibly bad values later. |
332 | */ | 332 | */ |
333 | else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) { | 333 | else if (be16_to_cpu(leaf->hdr.stale)) { |
334 | lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 334 | lfloglow = be16_to_cpu(leaf->hdr.count); |
335 | lfloghigh = -1; | 335 | lfloghigh = -1; |
336 | } | 336 | } |
337 | /* | 337 | /* |
@@ -358,13 +358,13 @@ xfs_dir2_leaf_addname( | |||
358 | * If we're adding a new data block on the end we need to | 358 | * If we're adding a new data block on the end we need to |
359 | * extend the bests table. Copy it up one entry. | 359 | * extend the bests table. Copy it up one entry. |
360 | */ | 360 | */ |
361 | if (use_block >= INT_GET(ltp->bestcount, ARCH_CONVERT)) { | 361 | if (use_block >= be32_to_cpu(ltp->bestcount)) { |
362 | bestsp--; | 362 | bestsp--; |
363 | memmove(&bestsp[0], &bestsp[1], | 363 | memmove(&bestsp[0], &bestsp[1], |
364 | INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(bestsp[0])); | 364 | be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0])); |
365 | INT_MOD(ltp->bestcount, ARCH_CONVERT, +1); | 365 | be32_add(<p->bestcount, 1); |
366 | xfs_dir2_leaf_log_tail(tp, lbp); | 366 | xfs_dir2_leaf_log_tail(tp, lbp); |
367 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 367 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
368 | } | 368 | } |
369 | /* | 369 | /* |
370 | * If we're filling in a previously empty block just log it. | 370 | * If we're filling in a previously empty block just log it. |
@@ -372,7 +372,7 @@ xfs_dir2_leaf_addname( | |||
372 | else | 372 | else |
373 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); | 373 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
374 | data = dbp->data; | 374 | data = dbp->data; |
375 | INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); | 375 | bestsp[use_block] = data->hdr.bestfree[0].length; |
376 | grown = 1; | 376 | grown = 1; |
377 | } | 377 | } |
378 | /* | 378 | /* |
@@ -394,8 +394,8 @@ xfs_dir2_leaf_addname( | |||
394 | * Point to the biggest freespace in our data block. | 394 | * Point to the biggest freespace in our data block. |
395 | */ | 395 | */ |
396 | dup = (xfs_dir2_data_unused_t *) | 396 | dup = (xfs_dir2_data_unused_t *) |
397 | ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); | 397 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); |
398 | ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length); | 398 | ASSERT(be16_to_cpu(dup->length) >= length); |
399 | needscan = needlog = 0; | 399 | needscan = needlog = 0; |
400 | /* | 400 | /* |
401 | * Mark the initial part of our freespace in use for the new entry. | 401 | * Mark the initial part of our freespace in use for the new entry. |
@@ -411,7 +411,7 @@ xfs_dir2_leaf_addname( | |||
411 | dep->namelen = args->namelen; | 411 | dep->namelen = args->namelen; |
412 | memcpy(dep->name, args->name, dep->namelen); | 412 | memcpy(dep->name, args->name, dep->namelen); |
413 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 413 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
414 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data)); | 414 | *tagp = cpu_to_be16((char *)dep - (char *)data); |
415 | /* | 415 | /* |
416 | * Need to scan fix up the bestfree table. | 416 | * Need to scan fix up the bestfree table. |
417 | */ | 417 | */ |
@@ -427,8 +427,8 @@ xfs_dir2_leaf_addname( | |||
427 | * If the bests table needs to be changed, do it. | 427 | * If the bests table needs to be changed, do it. |
428 | * Log the change unless we've already done that. | 428 | * Log the change unless we've already done that. |
429 | */ | 429 | */ |
430 | if (INT_GET(bestsp[use_block], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | 430 | if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(data->hdr.bestfree[0].length)) { |
431 | INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); | 431 | bestsp[use_block] = data->hdr.bestfree[0].length; |
432 | if (!grown) | 432 | if (!grown) |
433 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); | 433 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
434 | } | 434 | } |
@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname( | |||
440 | /* | 440 | /* |
441 | * lep is still good as the index leaf entry. | 441 | * lep is still good as the index leaf entry. |
442 | */ | 442 | */ |
443 | if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 443 | if (index < be16_to_cpu(leaf->hdr.count)) |
444 | memmove(lep + 1, lep, | 444 | memmove(lep + 1, lep, |
445 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); | 445 | (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep)); |
446 | /* | 446 | /* |
447 | * Record low and high logging indices for the leaf. | 447 | * Record low and high logging indices for the leaf. |
448 | */ | 448 | */ |
449 | lfloglow = index; | 449 | lfloglow = index; |
450 | lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 450 | lfloghigh = be16_to_cpu(leaf->hdr.count); |
451 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); | 451 | be16_add(&leaf->hdr.count, 1); |
452 | } | 452 | } |
453 | /* | 453 | /* |
454 | * There are stale entries. | 454 | * There are stale entries. |
@@ -468,7 +468,7 @@ xfs_dir2_leaf_addname( | |||
468 | */ | 468 | */ |
469 | for (lowstale = index - 1; | 469 | for (lowstale = index - 1; |
470 | lowstale >= 0 && | 470 | lowstale >= 0 && |
471 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != | 471 | be32_to_cpu(leaf->ents[lowstale].address) != |
472 | XFS_DIR2_NULL_DATAPTR; | 472 | XFS_DIR2_NULL_DATAPTR; |
473 | lowstale--) | 473 | lowstale--) |
474 | continue; | 474 | continue; |
@@ -478,8 +478,8 @@ xfs_dir2_leaf_addname( | |||
478 | * lowstale entry would be better. | 478 | * lowstale entry would be better. |
479 | */ | 479 | */ |
480 | for (highstale = index; | 480 | for (highstale = index; |
481 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 481 | highstale < be16_to_cpu(leaf->hdr.count) && |
482 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != | 482 | be32_to_cpu(leaf->ents[highstale].address) != |
483 | XFS_DIR2_NULL_DATAPTR && | 483 | XFS_DIR2_NULL_DATAPTR && |
484 | (lowstale < 0 || | 484 | (lowstale < 0 || |
485 | index - lowstale - 1 >= highstale - index); | 485 | index - lowstale - 1 >= highstale - index); |
@@ -490,10 +490,10 @@ xfs_dir2_leaf_addname( | |||
490 | * If the low one is better, use it. | 490 | * If the low one is better, use it. |
491 | */ | 491 | */ |
492 | if (lowstale >= 0 && | 492 | if (lowstale >= 0 && |
493 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 493 | (highstale == be16_to_cpu(leaf->hdr.count) || |
494 | index - lowstale - 1 < highstale - index)) { | 494 | index - lowstale - 1 < highstale - index)) { |
495 | ASSERT(index - lowstale - 1 >= 0); | 495 | ASSERT(index - lowstale - 1 >= 0); |
496 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == | 496 | ASSERT(be32_to_cpu(leaf->ents[lowstale].address) == |
497 | XFS_DIR2_NULL_DATAPTR); | 497 | XFS_DIR2_NULL_DATAPTR); |
498 | /* | 498 | /* |
499 | * Copy entries up to cover the stale entry | 499 | * Copy entries up to cover the stale entry |
@@ -512,7 +512,7 @@ xfs_dir2_leaf_addname( | |||
512 | */ | 512 | */ |
513 | else { | 513 | else { |
514 | ASSERT(highstale - index >= 0); | 514 | ASSERT(highstale - index >= 0); |
515 | ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) == | 515 | ASSERT(be32_to_cpu(leaf->ents[highstale].address) == |
516 | XFS_DIR2_NULL_DATAPTR); | 516 | XFS_DIR2_NULL_DATAPTR); |
517 | /* | 517 | /* |
518 | * Copy entries down to copver the stale entry | 518 | * Copy entries down to copver the stale entry |
@@ -526,13 +526,14 @@ xfs_dir2_leaf_addname( | |||
526 | lfloglow = MIN(index, lfloglow); | 526 | lfloglow = MIN(index, lfloglow); |
527 | lfloghigh = MAX(highstale, lfloghigh); | 527 | lfloghigh = MAX(highstale, lfloghigh); |
528 | } | 528 | } |
529 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); | 529 | be16_add(&leaf->hdr.stale, -1); |
530 | } | 530 | } |
531 | /* | 531 | /* |
532 | * Fill in the new leaf entry. | 532 | * Fill in the new leaf entry. |
533 | */ | 533 | */ |
534 | INT_SET(lep->hashval, ARCH_CONVERT, args->hashval); | 534 | lep->hashval = cpu_to_be32(args->hashval); |
535 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, INT_GET(*tagp, ARCH_CONVERT))); | 535 | lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, |
536 | be16_to_cpu(*tagp))); | ||
536 | /* | 537 | /* |
537 | * Log the leaf fields and give up the buffers. | 538 | * Log the leaf fields and give up the buffers. |
538 | */ | 539 | */ |
@@ -563,30 +564,30 @@ xfs_dir2_leaf_check( | |||
563 | 564 | ||
564 | leaf = bp->data; | 565 | leaf = bp->data; |
565 | mp = dp->i_mount; | 566 | mp = dp->i_mount; |
566 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 567 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
567 | /* | 568 | /* |
568 | * This value is not restrictive enough. | 569 | * This value is not restrictive enough. |
569 | * Should factor in the size of the bests table as well. | 570 | * Should factor in the size of the bests table as well. |
570 | * We can deduce a value for that from di_size. | 571 | * We can deduce a value for that from di_size. |
571 | */ | 572 | */ |
572 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); | 573 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); |
573 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 574 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
574 | /* | 575 | /* |
575 | * Leaves and bests don't overlap. | 576 | * Leaves and bests don't overlap. |
576 | */ | 577 | */ |
577 | ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <= | 578 | ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <= |
578 | (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); | 579 | (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); |
579 | /* | 580 | /* |
580 | * Check hash value order, count stale entries. | 581 | * Check hash value order, count stale entries. |
581 | */ | 582 | */ |
582 | for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { | 583 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
583 | if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 584 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) |
584 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= | 585 | ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= |
585 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); | 586 | be32_to_cpu(leaf->ents[i + 1].hashval)); |
586 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 587 | if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
587 | stale++; | 588 | stale++; |
588 | } | 589 | } |
589 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); | 590 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); |
590 | } | 591 | } |
591 | #endif /* DEBUG */ | 592 | #endif /* DEBUG */ |
592 | 593 | ||
@@ -611,8 +612,8 @@ xfs_dir2_leaf_compact( | |||
611 | /* | 612 | /* |
612 | * Compress out the stale entries in place. | 613 | * Compress out the stale entries in place. |
613 | */ | 614 | */ |
614 | for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 615 | for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) { |
615 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 616 | if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) |
616 | continue; | 617 | continue; |
617 | /* | 618 | /* |
618 | * Only actually copy the entries that are different. | 619 | * Only actually copy the entries that are different. |
@@ -627,8 +628,8 @@ xfs_dir2_leaf_compact( | |||
627 | /* | 628 | /* |
628 | * Update and log the header, log the leaf entries. | 629 | * Update and log the header, log the leaf entries. |
629 | */ | 630 | */ |
630 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to); | 631 | ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to); |
631 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT))); | 632 | be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale))); |
632 | leaf->hdr.stale = 0; | 633 | leaf->hdr.stale = 0; |
633 | xfs_dir2_leaf_log_header(args->trans, bp); | 634 | xfs_dir2_leaf_log_header(args->trans, bp); |
634 | if (loglow != -1) | 635 | if (loglow != -1) |
@@ -662,14 +663,14 @@ xfs_dir2_leaf_compact_x1( | |||
662 | int to; /* destination copy index */ | 663 | int to; /* destination copy index */ |
663 | 664 | ||
664 | leaf = bp->data; | 665 | leaf = bp->data; |
665 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1); | 666 | ASSERT(be16_to_cpu(leaf->hdr.stale) > 1); |
666 | index = *indexp; | 667 | index = *indexp; |
667 | /* | 668 | /* |
668 | * Find the first stale entry before our index, if any. | 669 | * Find the first stale entry before our index, if any. |
669 | */ | 670 | */ |
670 | for (lowstale = index - 1; | 671 | for (lowstale = index - 1; |
671 | lowstale >= 0 && | 672 | lowstale >= 0 && |
672 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR; | 673 | be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR; |
673 | lowstale--) | 674 | lowstale--) |
674 | continue; | 675 | continue; |
675 | /* | 676 | /* |
@@ -677,8 +678,8 @@ xfs_dir2_leaf_compact_x1( | |||
677 | * Stop if the answer would be worse than lowstale. | 678 | * Stop if the answer would be worse than lowstale. |
678 | */ | 679 | */ |
679 | for (highstale = index; | 680 | for (highstale = index; |
680 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 681 | highstale < be16_to_cpu(leaf->hdr.count) && |
681 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 682 | be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR && |
682 | (lowstale < 0 || index - lowstale > highstale - index); | 683 | (lowstale < 0 || index - lowstale > highstale - index); |
683 | highstale++) | 684 | highstale++) |
684 | continue; | 685 | continue; |
@@ -686,7 +687,7 @@ xfs_dir2_leaf_compact_x1( | |||
686 | * Pick the better of lowstale and highstale. | 687 | * Pick the better of lowstale and highstale. |
687 | */ | 688 | */ |
688 | if (lowstale >= 0 && | 689 | if (lowstale >= 0 && |
689 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 690 | (highstale == be16_to_cpu(leaf->hdr.count) || |
690 | index - lowstale <= highstale - index)) | 691 | index - lowstale <= highstale - index)) |
691 | keepstale = lowstale; | 692 | keepstale = lowstale; |
692 | else | 693 | else |
@@ -695,14 +696,14 @@ xfs_dir2_leaf_compact_x1( | |||
695 | * Copy the entries in place, removing all the stale entries | 696 | * Copy the entries in place, removing all the stale entries |
696 | * except keepstale. | 697 | * except keepstale. |
697 | */ | 698 | */ |
698 | for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 699 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { |
699 | /* | 700 | /* |
700 | * Notice the new value of index. | 701 | * Notice the new value of index. |
701 | */ | 702 | */ |
702 | if (index == from) | 703 | if (index == from) |
703 | newindex = to; | 704 | newindex = to; |
704 | if (from != keepstale && | 705 | if (from != keepstale && |
705 | INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) { | 706 | be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) { |
706 | if (from == to) | 707 | if (from == to) |
707 | *lowlogp = to; | 708 | *lowlogp = to; |
708 | continue; | 709 | continue; |
@@ -730,8 +731,8 @@ xfs_dir2_leaf_compact_x1( | |||
730 | /* | 731 | /* |
731 | * Adjust the leaf header values. | 732 | * Adjust the leaf header values. |
732 | */ | 733 | */ |
733 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to)); | 734 | be16_add(&leaf->hdr.count, -(from - to)); |
734 | INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1); | 735 | leaf->hdr.stale = cpu_to_be16(1); |
735 | /* | 736 | /* |
736 | * Remember the low/high stale value only in the "right" | 737 | * Remember the low/high stale value only in the "right" |
737 | * direction. | 738 | * direction. |
@@ -739,8 +740,8 @@ xfs_dir2_leaf_compact_x1( | |||
739 | if (lowstale >= newindex) | 740 | if (lowstale >= newindex) |
740 | lowstale = -1; | 741 | lowstale = -1; |
741 | else | 742 | else |
742 | highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 743 | highstale = be16_to_cpu(leaf->hdr.count); |
743 | *highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1; | 744 | *highlogp = be16_to_cpu(leaf->hdr.count) - 1; |
744 | *lowstalep = lowstale; | 745 | *lowstalep = lowstale; |
745 | *highstalep = highstale; | 746 | *highstalep = highstale; |
746 | } | 747 | } |
@@ -766,7 +767,7 @@ xfs_dir2_leaf_getdents( | |||
766 | xfs_dir2_data_entry_t *dep; /* data entry */ | 767 | xfs_dir2_data_entry_t *dep; /* data entry */ |
767 | xfs_dir2_data_unused_t *dup; /* unused entry */ | 768 | xfs_dir2_data_unused_t *dup; /* unused entry */ |
768 | int eof; /* reached end of directory */ | 769 | int eof; /* reached end of directory */ |
769 | int error=0; /* error return value */ | 770 | int error = 0; /* error return value */ |
770 | int i; /* temporary loop index */ | 771 | int i; /* temporary loop index */ |
771 | int j; /* temporary loop index */ | 772 | int j; /* temporary loop index */ |
772 | int length; /* temporary length value */ | 773 | int length; /* temporary length value */ |
@@ -778,8 +779,8 @@ xfs_dir2_leaf_getdents( | |||
778 | xfs_mount_t *mp; /* filesystem mount point */ | 779 | xfs_mount_t *mp; /* filesystem mount point */ |
779 | xfs_dir2_off_t newoff; /* new curoff after new blk */ | 780 | xfs_dir2_off_t newoff; /* new curoff after new blk */ |
780 | int nmap; /* mappings to ask xfs_bmapi */ | 781 | int nmap; /* mappings to ask xfs_bmapi */ |
781 | xfs_dir2_put_args_t p; /* formatting arg bundle */ | 782 | xfs_dir2_put_args_t *p; /* formatting arg bundle */ |
782 | char *ptr=NULL; /* pointer to current data */ | 783 | char *ptr = NULL; /* pointer to current data */ |
783 | int ra_current; /* number of read-ahead blks */ | 784 | int ra_current; /* number of read-ahead blks */ |
784 | int ra_index; /* *map index for read-ahead */ | 785 | int ra_index; /* *map index for read-ahead */ |
785 | int ra_offset; /* map entry offset for ra */ | 786 | int ra_offset; /* map entry offset for ra */ |
@@ -797,9 +798,10 @@ xfs_dir2_leaf_getdents( | |||
797 | /* | 798 | /* |
798 | * Setup formatting arguments. | 799 | * Setup formatting arguments. |
799 | */ | 800 | */ |
800 | p.dbp = dbp; | 801 | p = kmem_alloc(sizeof(*p), KM_SLEEP); |
801 | p.put = put; | 802 | p->dbp = dbp; |
802 | p.uio = uio; | 803 | p->put = put; |
804 | p->uio = uio; | ||
803 | /* | 805 | /* |
804 | * Set up to bmap a number of blocks based on the caller's | 806 | * Set up to bmap a number of blocks based on the caller's |
805 | * buffer size, the directory block size, and the filesystem | 807 | * buffer size, the directory block size, and the filesystem |
@@ -1046,11 +1048,10 @@ xfs_dir2_leaf_getdents( | |||
1046 | while ((char *)ptr - (char *)data < byteoff) { | 1048 | while ((char *)ptr - (char *)data < byteoff) { |
1047 | dup = (xfs_dir2_data_unused_t *)ptr; | 1049 | dup = (xfs_dir2_data_unused_t *)ptr; |
1048 | 1050 | ||
1049 | if (INT_GET(dup->freetag, ARCH_CONVERT) | 1051 | if (be16_to_cpu(dup->freetag) |
1050 | == XFS_DIR2_DATA_FREE_TAG) { | 1052 | == XFS_DIR2_DATA_FREE_TAG) { |
1051 | 1053 | ||
1052 | length = INT_GET(dup->length, | 1054 | length = be16_to_cpu(dup->length); |
1053 | ARCH_CONVERT); | ||
1054 | ptr += length; | 1055 | ptr += length; |
1055 | continue; | 1056 | continue; |
1056 | } | 1057 | } |
@@ -1079,9 +1080,8 @@ xfs_dir2_leaf_getdents( | |||
1079 | /* | 1080 | /* |
1080 | * No, it's unused, skip over it. | 1081 | * No, it's unused, skip over it. |
1081 | */ | 1082 | */ |
1082 | if (INT_GET(dup->freetag, ARCH_CONVERT) | 1083 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
1083 | == XFS_DIR2_DATA_FREE_TAG) { | 1084 | length = be16_to_cpu(dup->length); |
1084 | length = INT_GET(dup->length, ARCH_CONVERT); | ||
1085 | ptr += length; | 1085 | ptr += length; |
1086 | curoff += length; | 1086 | curoff += length; |
1087 | continue; | 1087 | continue; |
@@ -1092,24 +1092,24 @@ xfs_dir2_leaf_getdents( | |||
1092 | */ | 1092 | */ |
1093 | dep = (xfs_dir2_data_entry_t *)ptr; | 1093 | dep = (xfs_dir2_data_entry_t *)ptr; |
1094 | 1094 | ||
1095 | p.namelen = dep->namelen; | 1095 | p->namelen = dep->namelen; |
1096 | 1096 | ||
1097 | length = XFS_DIR2_DATA_ENTSIZE(p.namelen); | 1097 | length = XFS_DIR2_DATA_ENTSIZE(p->namelen); |
1098 | 1098 | ||
1099 | p.cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length); | 1099 | p->cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length); |
1100 | 1100 | ||
1101 | p.ino = INT_GET(dep->inumber, ARCH_CONVERT); | 1101 | p->ino = INT_GET(dep->inumber, ARCH_CONVERT); |
1102 | #if XFS_BIG_INUMS | 1102 | #if XFS_BIG_INUMS |
1103 | p.ino += mp->m_inoadd; | 1103 | p->ino += mp->m_inoadd; |
1104 | #endif | 1104 | #endif |
1105 | p.name = (char *)dep->name; | 1105 | p->name = (char *)dep->name; |
1106 | 1106 | ||
1107 | error = p.put(&p); | 1107 | error = p->put(p); |
1108 | 1108 | ||
1109 | /* | 1109 | /* |
1110 | * Won't fit. Return to caller. | 1110 | * Won't fit. Return to caller. |
1111 | */ | 1111 | */ |
1112 | if (!p.done) { | 1112 | if (!p->done) { |
1113 | eof = 0; | 1113 | eof = 0; |
1114 | break; | 1114 | break; |
1115 | } | 1115 | } |
@@ -1129,6 +1129,7 @@ xfs_dir2_leaf_getdents( | |||
1129 | else | 1129 | else |
1130 | uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff); | 1130 | uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff); |
1131 | kmem_free(map, map_size * sizeof(*map)); | 1131 | kmem_free(map, map_size * sizeof(*map)); |
1132 | kmem_free(p, sizeof(*p)); | ||
1132 | if (bp) | 1133 | if (bp) |
1133 | xfs_da_brelse(tp, bp); | 1134 | xfs_da_brelse(tp, bp); |
1134 | return error; | 1135 | return error; |
@@ -1171,7 +1172,7 @@ xfs_dir2_leaf_init( | |||
1171 | /* | 1172 | /* |
1172 | * Initialize the header. | 1173 | * Initialize the header. |
1173 | */ | 1174 | */ |
1174 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, magic); | 1175 | leaf->hdr.info.magic = cpu_to_be16(magic); |
1175 | leaf->hdr.info.forw = 0; | 1176 | leaf->hdr.info.forw = 0; |
1176 | leaf->hdr.info.back = 0; | 1177 | leaf->hdr.info.back = 0; |
1177 | leaf->hdr.count = 0; | 1178 | leaf->hdr.count = 0; |
@@ -1201,13 +1202,13 @@ xfs_dir2_leaf_log_bests( | |||
1201 | int first, /* first entry to log */ | 1202 | int first, /* first entry to log */ |
1202 | int last) /* last entry to log */ | 1203 | int last) /* last entry to log */ |
1203 | { | 1204 | { |
1204 | xfs_dir2_data_off_t *firstb; /* pointer to first entry */ | 1205 | __be16 *firstb; /* pointer to first entry */ |
1205 | xfs_dir2_data_off_t *lastb; /* pointer to last entry */ | 1206 | __be16 *lastb; /* pointer to last entry */ |
1206 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1207 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1207 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 1208 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
1208 | 1209 | ||
1209 | leaf = bp->data; | 1210 | leaf = bp->data; |
1210 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 1211 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
1211 | ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); | 1212 | ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); |
1212 | firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; | 1213 | firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; |
1213 | lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; | 1214 | lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; |
@@ -1230,8 +1231,8 @@ xfs_dir2_leaf_log_ents( | |||
1230 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1231 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1231 | 1232 | ||
1232 | leaf = bp->data; | 1233 | leaf = bp->data; |
1233 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || | 1234 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || |
1234 | INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1235 | be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1235 | firstlep = &leaf->ents[first]; | 1236 | firstlep = &leaf->ents[first]; |
1236 | lastlep = &leaf->ents[last]; | 1237 | lastlep = &leaf->ents[last]; |
1237 | xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), | 1238 | xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), |
@@ -1249,8 +1250,8 @@ xfs_dir2_leaf_log_header( | |||
1249 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1250 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1250 | 1251 | ||
1251 | leaf = bp->data; | 1252 | leaf = bp->data; |
1252 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || | 1253 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || |
1253 | INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1254 | be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1254 | xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), | 1255 | xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), |
1255 | (uint)(sizeof(leaf->hdr) - 1)); | 1256 | (uint)(sizeof(leaf->hdr) - 1)); |
1256 | } | 1257 | } |
@@ -1269,7 +1270,7 @@ xfs_dir2_leaf_log_tail( | |||
1269 | 1270 | ||
1270 | mp = tp->t_mountp; | 1271 | mp = tp->t_mountp; |
1271 | leaf = bp->data; | 1272 | leaf = bp->data; |
1272 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 1273 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
1273 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1274 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1274 | xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), | 1275 | xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), |
1275 | (uint)(mp->m_dirblksize - 1)); | 1276 | (uint)(mp->m_dirblksize - 1)); |
@@ -1314,7 +1315,7 @@ xfs_dir2_leaf_lookup( | |||
1314 | */ | 1315 | */ |
1315 | dep = (xfs_dir2_data_entry_t *) | 1316 | dep = (xfs_dir2_data_entry_t *) |
1316 | ((char *)dbp->data + | 1317 | ((char *)dbp->data + |
1317 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT))); | 1318 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); |
1318 | /* | 1319 | /* |
1319 | * Return the found inode number. | 1320 | * Return the found inode number. |
1320 | */ | 1321 | */ |
@@ -1373,17 +1374,17 @@ xfs_dir2_leaf_lookup_int( | |||
1373 | * looking to match the name. | 1374 | * looking to match the name. |
1374 | */ | 1375 | */ |
1375 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; | 1376 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; |
1376 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 1377 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
1377 | lep++, index++) { | 1378 | lep++, index++) { |
1378 | /* | 1379 | /* |
1379 | * Skip over stale leaf entries. | 1380 | * Skip over stale leaf entries. |
1380 | */ | 1381 | */ |
1381 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 1382 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
1382 | continue; | 1383 | continue; |
1383 | /* | 1384 | /* |
1384 | * Get the new data block number. | 1385 | * Get the new data block number. |
1385 | */ | 1386 | */ |
1386 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 1387 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
1387 | /* | 1388 | /* |
1388 | * If it's not the same as the old data block number, | 1389 | * If it's not the same as the old data block number, |
1389 | * need to pitch the old one and read the new one. | 1390 | * need to pitch the old one and read the new one. |
@@ -1406,7 +1407,7 @@ xfs_dir2_leaf_lookup_int( | |||
1406 | */ | 1407 | */ |
1407 | dep = (xfs_dir2_data_entry_t *) | 1408 | dep = (xfs_dir2_data_entry_t *) |
1408 | ((char *)dbp->data + | 1409 | ((char *)dbp->data + |
1409 | XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 1410 | XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
1410 | /* | 1411 | /* |
1411 | * If it matches then return it. | 1412 | * If it matches then return it. |
1412 | */ | 1413 | */ |
@@ -1435,7 +1436,7 @@ int /* error */ | |||
1435 | xfs_dir2_leaf_removename( | 1436 | xfs_dir2_leaf_removename( |
1436 | xfs_da_args_t *args) /* operation arguments */ | 1437 | xfs_da_args_t *args) /* operation arguments */ |
1437 | { | 1438 | { |
1438 | xfs_dir2_data_off_t *bestsp; /* leaf block best freespace */ | 1439 | __be16 *bestsp; /* leaf block best freespace */ |
1439 | xfs_dir2_data_t *data; /* data block structure */ | 1440 | xfs_dir2_data_t *data; /* data block structure */ |
1440 | xfs_dir2_db_t db; /* data block number */ | 1441 | xfs_dir2_db_t db; /* data block number */ |
1441 | xfs_dabuf_t *dbp; /* data block buffer */ | 1442 | xfs_dabuf_t *dbp; /* data block buffer */ |
@@ -1471,14 +1472,14 @@ xfs_dir2_leaf_removename( | |||
1471 | * Point to the leaf entry, use that to point to the data entry. | 1472 | * Point to the leaf entry, use that to point to the data entry. |
1472 | */ | 1473 | */ |
1473 | lep = &leaf->ents[index]; | 1474 | lep = &leaf->ents[index]; |
1474 | db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 1475 | db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
1475 | dep = (xfs_dir2_data_entry_t *) | 1476 | dep = (xfs_dir2_data_entry_t *) |
1476 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 1477 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
1477 | needscan = needlog = 0; | 1478 | needscan = needlog = 0; |
1478 | oldbest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | 1479 | oldbest = be16_to_cpu(data->hdr.bestfree[0].length); |
1479 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1480 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1480 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 1481 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
1481 | ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest); | 1482 | ASSERT(be16_to_cpu(bestsp[db]) == oldbest); |
1482 | /* | 1483 | /* |
1483 | * Mark the former data entry unused. | 1484 | * Mark the former data entry unused. |
1484 | */ | 1485 | */ |
@@ -1488,9 +1489,9 @@ xfs_dir2_leaf_removename( | |||
1488 | /* | 1489 | /* |
1489 | * We just mark the leaf entry stale by putting a null in it. | 1490 | * We just mark the leaf entry stale by putting a null in it. |
1490 | */ | 1491 | */ |
1491 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); | 1492 | be16_add(&leaf->hdr.stale, 1); |
1492 | xfs_dir2_leaf_log_header(tp, lbp); | 1493 | xfs_dir2_leaf_log_header(tp, lbp); |
1493 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 1494 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
1494 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); | 1495 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); |
1495 | /* | 1496 | /* |
1496 | * Scan the freespace in the data block again if necessary, | 1497 | * Scan the freespace in the data block again if necessary, |
@@ -1504,15 +1505,15 @@ xfs_dir2_leaf_removename( | |||
1504 | * If the longest freespace in the data block has changed, | 1505 | * If the longest freespace in the data block has changed, |
1505 | * put the new value in the bests table and log that. | 1506 | * put the new value in the bests table and log that. |
1506 | */ | 1507 | */ |
1507 | if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) != oldbest) { | 1508 | if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) { |
1508 | INT_COPY(bestsp[db], data->hdr.bestfree[0].length, ARCH_CONVERT); | 1509 | bestsp[db] = data->hdr.bestfree[0].length; |
1509 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); | 1510 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); |
1510 | } | 1511 | } |
1511 | xfs_dir2_data_check(dp, dbp); | 1512 | xfs_dir2_data_check(dp, dbp); |
1512 | /* | 1513 | /* |
1513 | * If the data block is now empty then get rid of the data block. | 1514 | * If the data block is now empty then get rid of the data block. |
1514 | */ | 1515 | */ |
1515 | if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == | 1516 | if (be16_to_cpu(data->hdr.bestfree[0].length) == |
1516 | mp->m_dirblksize - (uint)sizeof(data->hdr)) { | 1517 | mp->m_dirblksize - (uint)sizeof(data->hdr)) { |
1517 | ASSERT(db != mp->m_dirdatablk); | 1518 | ASSERT(db != mp->m_dirdatablk); |
1518 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { | 1519 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { |
@@ -1535,12 +1536,12 @@ xfs_dir2_leaf_removename( | |||
1535 | * If this is the last data block then compact the | 1536 | * If this is the last data block then compact the |
1536 | * bests table by getting rid of entries. | 1537 | * bests table by getting rid of entries. |
1537 | */ | 1538 | */ |
1538 | if (db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1) { | 1539 | if (db == be32_to_cpu(ltp->bestcount) - 1) { |
1539 | /* | 1540 | /* |
1540 | * Look for the last active entry (i). | 1541 | * Look for the last active entry (i). |
1541 | */ | 1542 | */ |
1542 | for (i = db - 1; i > 0; i--) { | 1543 | for (i = db - 1; i > 0; i--) { |
1543 | if (INT_GET(bestsp[i], ARCH_CONVERT) != NULLDATAOFF) | 1544 | if (be16_to_cpu(bestsp[i]) != NULLDATAOFF) |
1544 | break; | 1545 | break; |
1545 | } | 1546 | } |
1546 | /* | 1547 | /* |
@@ -1548,12 +1549,12 @@ xfs_dir2_leaf_removename( | |||
1548 | * end are removed. | 1549 | * end are removed. |
1549 | */ | 1550 | */ |
1550 | memmove(&bestsp[db - i], bestsp, | 1551 | memmove(&bestsp[db - i], bestsp, |
1551 | (INT_GET(ltp->bestcount, ARCH_CONVERT) - (db - i)) * sizeof(*bestsp)); | 1552 | (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp)); |
1552 | INT_MOD(ltp->bestcount, ARCH_CONVERT, -(db - i)); | 1553 | be32_add(<p->bestcount, -(db - i)); |
1553 | xfs_dir2_leaf_log_tail(tp, lbp); | 1554 | xfs_dir2_leaf_log_tail(tp, lbp); |
1554 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1555 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1555 | } else | 1556 | } else |
1556 | INT_SET(bestsp[db], ARCH_CONVERT, NULLDATAOFF); | 1557 | bestsp[db] = cpu_to_be16(NULLDATAOFF); |
1557 | } | 1558 | } |
1558 | /* | 1559 | /* |
1559 | * If the data block was not the first one, drop it. | 1560 | * If the data block was not the first one, drop it. |
@@ -1604,7 +1605,7 @@ xfs_dir2_leaf_replace( | |||
1604 | */ | 1605 | */ |
1605 | dep = (xfs_dir2_data_entry_t *) | 1606 | dep = (xfs_dir2_data_entry_t *) |
1606 | ((char *)dbp->data + | 1607 | ((char *)dbp->data + |
1607 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT))); | 1608 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); |
1608 | ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT)); | 1609 | ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT)); |
1609 | /* | 1610 | /* |
1610 | * Put the new inode number in, log it. | 1611 | * Put the new inode number in, log it. |
@@ -1645,11 +1646,11 @@ xfs_dir2_leaf_search_hash( | |||
1645 | * Note, the table cannot be empty, so we have to go through the loop. | 1646 | * Note, the table cannot be empty, so we have to go through the loop. |
1646 | * Binary search the leaf entries looking for our hash value. | 1647 | * Binary search the leaf entries looking for our hash value. |
1647 | */ | 1648 | */ |
1648 | for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1, | 1649 | for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1, |
1649 | hashwant = args->hashval; | 1650 | hashwant = args->hashval; |
1650 | low <= high; ) { | 1651 | low <= high; ) { |
1651 | mid = (low + high) >> 1; | 1652 | mid = (low + high) >> 1; |
1652 | if ((hash = INT_GET(lep[mid].hashval, ARCH_CONVERT)) == hashwant) | 1653 | if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant) |
1653 | break; | 1654 | break; |
1654 | if (hash < hashwant) | 1655 | if (hash < hashwant) |
1655 | low = mid + 1; | 1656 | low = mid + 1; |
@@ -1660,7 +1661,7 @@ xfs_dir2_leaf_search_hash( | |||
1660 | * Found one, back up through all the equal hash values. | 1661 | * Found one, back up through all the equal hash values. |
1661 | */ | 1662 | */ |
1662 | if (hash == hashwant) { | 1663 | if (hash == hashwant) { |
1663 | while (mid > 0 && INT_GET(lep[mid - 1].hashval, ARCH_CONVERT) == hashwant) { | 1664 | while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant) { |
1664 | mid--; | 1665 | mid--; |
1665 | } | 1666 | } |
1666 | } | 1667 | } |
@@ -1682,7 +1683,7 @@ xfs_dir2_leaf_trim_data( | |||
1682 | xfs_dabuf_t *lbp, /* leaf buffer */ | 1683 | xfs_dabuf_t *lbp, /* leaf buffer */ |
1683 | xfs_dir2_db_t db) /* data block number */ | 1684 | xfs_dir2_db_t db) /* data block number */ |
1684 | { | 1685 | { |
1685 | xfs_dir2_data_off_t *bestsp; /* leaf bests table */ | 1686 | __be16 *bestsp; /* leaf bests table */ |
1686 | #ifdef DEBUG | 1687 | #ifdef DEBUG |
1687 | xfs_dir2_data_t *data; /* data block structure */ | 1688 | xfs_dir2_data_t *data; /* data block structure */ |
1688 | #endif | 1689 | #endif |
@@ -1706,7 +1707,7 @@ xfs_dir2_leaf_trim_data( | |||
1706 | } | 1707 | } |
1707 | #ifdef DEBUG | 1708 | #ifdef DEBUG |
1708 | data = dbp->data; | 1709 | data = dbp->data; |
1709 | ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | 1710 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); |
1710 | #endif | 1711 | #endif |
1711 | /* this seems to be an error | 1712 | /* this seems to be an error |
1712 | * data is only valid if DEBUG is defined? | 1713 | * data is only valid if DEBUG is defined? |
@@ -1715,9 +1716,9 @@ xfs_dir2_leaf_trim_data( | |||
1715 | 1716 | ||
1716 | leaf = lbp->data; | 1717 | leaf = lbp->data; |
1717 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1718 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1718 | ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == | 1719 | ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) == |
1719 | mp->m_dirblksize - (uint)sizeof(data->hdr)); | 1720 | mp->m_dirblksize - (uint)sizeof(data->hdr)); |
1720 | ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1721 | ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); |
1721 | /* | 1722 | /* |
1722 | * Get rid of the data block. | 1723 | * Get rid of the data block. |
1723 | */ | 1724 | */ |
@@ -1730,10 +1731,10 @@ xfs_dir2_leaf_trim_data( | |||
1730 | * Eliminate the last bests entry from the table. | 1731 | * Eliminate the last bests entry from the table. |
1731 | */ | 1732 | */ |
1732 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 1733 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
1733 | INT_MOD(ltp->bestcount, ARCH_CONVERT, -1); | 1734 | be32_add(<p->bestcount, -1); |
1734 | memmove(&bestsp[1], &bestsp[0], INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(*bestsp)); | 1735 | memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp)); |
1735 | xfs_dir2_leaf_log_tail(tp, lbp); | 1736 | xfs_dir2_leaf_log_tail(tp, lbp); |
1736 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1737 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1737 | return 0; | 1738 | return 0; |
1738 | } | 1739 | } |
1739 | 1740 | ||
@@ -1805,7 +1806,7 @@ xfs_dir2_node_to_leaf( | |||
1805 | return 0; | 1806 | return 0; |
1806 | lbp = state->path.blk[0].bp; | 1807 | lbp = state->path.blk[0].bp; |
1807 | leaf = lbp->data; | 1808 | leaf = lbp->data; |
1808 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1809 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1809 | /* | 1810 | /* |
1810 | * Read the freespace block. | 1811 | * Read the freespace block. |
1811 | */ | 1812 | */ |
@@ -1814,15 +1815,15 @@ xfs_dir2_node_to_leaf( | |||
1814 | return error; | 1815 | return error; |
1815 | } | 1816 | } |
1816 | free = fbp->data; | 1817 | free = fbp->data; |
1817 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1818 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1818 | ASSERT(!free->hdr.firstdb); | 1819 | ASSERT(!free->hdr.firstdb); |
1819 | /* | 1820 | /* |
1820 | * Now see if the leafn and free data will fit in a leaf1. | 1821 | * Now see if the leafn and free data will fit in a leaf1. |
1821 | * If not, release the buffer and give up. | 1822 | * If not, release the buffer and give up. |
1822 | */ | 1823 | */ |
1823 | if ((uint)sizeof(leaf->hdr) + | 1824 | if ((uint)sizeof(leaf->hdr) + |
1824 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) + | 1825 | (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) + |
1825 | INT_GET(free->hdr.nvalid, ARCH_CONVERT) * (uint)sizeof(leaf->bests[0]) + | 1826 | be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) + |
1826 | (uint)sizeof(leaf->tail) > | 1827 | (uint)sizeof(leaf->tail) > |
1827 | mp->m_dirblksize) { | 1828 | mp->m_dirblksize) { |
1828 | xfs_da_brelse(tp, fbp); | 1829 | xfs_da_brelse(tp, fbp); |
@@ -1832,22 +1833,22 @@ xfs_dir2_node_to_leaf( | |||
1832 | * If the leaf has any stale entries in it, compress them out. | 1833 | * If the leaf has any stale entries in it, compress them out. |
1833 | * The compact routine will log the header. | 1834 | * The compact routine will log the header. |
1834 | */ | 1835 | */ |
1835 | if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) | 1836 | if (be16_to_cpu(leaf->hdr.stale)) |
1836 | xfs_dir2_leaf_compact(args, lbp); | 1837 | xfs_dir2_leaf_compact(args, lbp); |
1837 | else | 1838 | else |
1838 | xfs_dir2_leaf_log_header(tp, lbp); | 1839 | xfs_dir2_leaf_log_header(tp, lbp); |
1839 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAF1_MAGIC); | 1840 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC); |
1840 | /* | 1841 | /* |
1841 | * Set up the leaf tail from the freespace block. | 1842 | * Set up the leaf tail from the freespace block. |
1842 | */ | 1843 | */ |
1843 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1844 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1844 | INT_COPY(ltp->bestcount, free->hdr.nvalid, ARCH_CONVERT); | 1845 | ltp->bestcount = free->hdr.nvalid; |
1845 | /* | 1846 | /* |
1846 | * Set up the leaf bests table. | 1847 | * Set up the leaf bests table. |
1847 | */ | 1848 | */ |
1848 | memcpy(XFS_DIR2_LEAF_BESTS_P(ltp), free->bests, | 1849 | memcpy(XFS_DIR2_LEAF_BESTS_P(ltp), free->bests, |
1849 | INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(leaf->bests[0])); | 1850 | be32_to_cpu(ltp->bestcount) * sizeof(leaf->bests[0])); |
1850 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1851 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1851 | xfs_dir2_leaf_log_tail(tp, lbp); | 1852 | xfs_dir2_leaf_log_tail(tp, lbp); |
1852 | xfs_dir2_leaf_check(dp, lbp); | 1853 | xfs_dir2_leaf_check(dp, lbp); |
1853 | /* | 1854 | /* |
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h index 1393993d61e9..f57ca1162412 100644 --- a/fs/xfs/xfs_dir2_leaf.h +++ b/fs/xfs/xfs_dir2_leaf.h | |||
@@ -46,23 +46,23 @@ typedef __uint32_t xfs_dir2_dataptr_t; | |||
46 | */ | 46 | */ |
47 | typedef struct xfs_dir2_leaf_hdr { | 47 | typedef struct xfs_dir2_leaf_hdr { |
48 | xfs_da_blkinfo_t info; /* header for da routines */ | 48 | xfs_da_blkinfo_t info; /* header for da routines */ |
49 | __uint16_t count; /* count of entries */ | 49 | __be16 count; /* count of entries */ |
50 | __uint16_t stale; /* count of stale entries */ | 50 | __be16 stale; /* count of stale entries */ |
51 | } xfs_dir2_leaf_hdr_t; | 51 | } xfs_dir2_leaf_hdr_t; |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * Leaf block entry. | 54 | * Leaf block entry. |
55 | */ | 55 | */ |
56 | typedef struct xfs_dir2_leaf_entry { | 56 | typedef struct xfs_dir2_leaf_entry { |
57 | xfs_dahash_t hashval; /* hash value of name */ | 57 | __be32 hashval; /* hash value of name */ |
58 | xfs_dir2_dataptr_t address; /* address of data entry */ | 58 | __be32 address; /* address of data entry */ |
59 | } xfs_dir2_leaf_entry_t; | 59 | } xfs_dir2_leaf_entry_t; |
60 | 60 | ||
61 | /* | 61 | /* |
62 | * Leaf block tail. | 62 | * Leaf block tail. |
63 | */ | 63 | */ |
64 | typedef struct xfs_dir2_leaf_tail { | 64 | typedef struct xfs_dir2_leaf_tail { |
65 | __uint32_t bestcount; | 65 | __be32 bestcount; |
66 | } xfs_dir2_leaf_tail_t; | 66 | } xfs_dir2_leaf_tail_t; |
67 | 67 | ||
68 | /* | 68 | /* |
@@ -105,11 +105,10 @@ xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp) | |||
105 | * Get address of the bests array in the single-leaf block. | 105 | * Get address of the bests array in the single-leaf block. |
106 | */ | 106 | */ |
107 | #define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp) | 107 | #define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp) |
108 | static inline xfs_dir2_data_off_t * | 108 | static inline __be16 * |
109 | xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) | 109 | xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) |
110 | { | 110 | { |
111 | return (xfs_dir2_data_off_t *) | 111 | return (__be16 *)ltp - be32_to_cpu(ltp->bestcount); |
112 | (ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT); | ||
113 | } | 112 | } |
114 | 113 | ||
115 | /* | 114 | /* |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 641f8633d254..af556f16a0c7 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -76,7 +76,7 @@ xfs_dir2_free_log_bests( | |||
76 | xfs_dir2_free_t *free; /* freespace structure */ | 76 | xfs_dir2_free_t *free; /* freespace structure */ |
77 | 77 | ||
78 | free = bp->data; | 78 | free = bp->data; |
79 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 79 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
80 | xfs_da_log_buf(tp, bp, | 80 | xfs_da_log_buf(tp, bp, |
81 | (uint)((char *)&free->bests[first] - (char *)free), | 81 | (uint)((char *)&free->bests[first] - (char *)free), |
82 | (uint)((char *)&free->bests[last] - (char *)free + | 82 | (uint)((char *)&free->bests[last] - (char *)free + |
@@ -94,7 +94,7 @@ xfs_dir2_free_log_header( | |||
94 | xfs_dir2_free_t *free; /* freespace structure */ | 94 | xfs_dir2_free_t *free; /* freespace structure */ |
95 | 95 | ||
96 | free = bp->data; | 96 | free = bp->data; |
97 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 97 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
98 | xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), | 98 | xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), |
99 | (uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); | 99 | (uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); |
100 | } | 100 | } |
@@ -114,14 +114,14 @@ xfs_dir2_leaf_to_node( | |||
114 | xfs_dabuf_t *fbp; /* freespace buffer */ | 114 | xfs_dabuf_t *fbp; /* freespace buffer */ |
115 | xfs_dir2_db_t fdb; /* freespace block number */ | 115 | xfs_dir2_db_t fdb; /* freespace block number */ |
116 | xfs_dir2_free_t *free; /* freespace structure */ | 116 | xfs_dir2_free_t *free; /* freespace structure */ |
117 | xfs_dir2_data_off_t *from; /* pointer to freespace entry */ | 117 | __be16 *from; /* pointer to freespace entry */ |
118 | int i; /* leaf freespace index */ | 118 | int i; /* leaf freespace index */ |
119 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 119 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
120 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 120 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
121 | xfs_mount_t *mp; /* filesystem mount point */ | 121 | xfs_mount_t *mp; /* filesystem mount point */ |
122 | int n; /* count of live freespc ents */ | 122 | int n; /* count of live freespc ents */ |
123 | xfs_dir2_data_off_t off; /* freespace entry value */ | 123 | xfs_dir2_data_off_t off; /* freespace entry value */ |
124 | xfs_dir2_data_off_t *to; /* pointer to freespace entry */ | 124 | __be16 *to; /* pointer to freespace entry */ |
125 | xfs_trans_t *tp; /* transaction pointer */ | 125 | xfs_trans_t *tp; /* transaction pointer */ |
126 | 126 | ||
127 | xfs_dir2_trace_args_b("leaf_to_node", args, lbp); | 127 | xfs_dir2_trace_args_b("leaf_to_node", args, lbp); |
@@ -149,28 +149,28 @@ xfs_dir2_leaf_to_node( | |||
149 | /* | 149 | /* |
150 | * Initialize the freespace block header. | 150 | * Initialize the freespace block header. |
151 | */ | 151 | */ |
152 | INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC); | 152 | free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); |
153 | free->hdr.firstdb = 0; | 153 | free->hdr.firstdb = 0; |
154 | ASSERT(INT_GET(ltp->bestcount, ARCH_CONVERT) <= (uint)dp->i_d.di_size / mp->m_dirblksize); | 154 | ASSERT(be32_to_cpu(ltp->bestcount) <= (uint)dp->i_d.di_size / mp->m_dirblksize); |
155 | INT_COPY(free->hdr.nvalid, ltp->bestcount, ARCH_CONVERT); | 155 | free->hdr.nvalid = ltp->bestcount; |
156 | /* | 156 | /* |
157 | * Copy freespace entries from the leaf block to the new block. | 157 | * Copy freespace entries from the leaf block to the new block. |
158 | * Count active entries. | 158 | * Count active entries. |
159 | */ | 159 | */ |
160 | for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests; | 160 | for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests; |
161 | i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++, from++, to++) { | 161 | i < be32_to_cpu(ltp->bestcount); i++, from++, to++) { |
162 | if ((off = INT_GET(*from, ARCH_CONVERT)) != NULLDATAOFF) | 162 | if ((off = be16_to_cpu(*from)) != NULLDATAOFF) |
163 | n++; | 163 | n++; |
164 | INT_SET(*to, ARCH_CONVERT, off); | 164 | *to = cpu_to_be16(off); |
165 | } | 165 | } |
166 | INT_SET(free->hdr.nused, ARCH_CONVERT, n); | 166 | free->hdr.nused = cpu_to_be32(n); |
167 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAFN_MAGIC); | 167 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC); |
168 | /* | 168 | /* |
169 | * Log everything. | 169 | * Log everything. |
170 | */ | 170 | */ |
171 | xfs_dir2_leaf_log_header(tp, lbp); | 171 | xfs_dir2_leaf_log_header(tp, lbp); |
172 | xfs_dir2_free_log_header(tp, fbp); | 172 | xfs_dir2_free_log_header(tp, fbp); |
173 | xfs_dir2_free_log_bests(tp, fbp, 0, INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1); | 173 | xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1); |
174 | xfs_da_buf_done(fbp); | 174 | xfs_da_buf_done(fbp); |
175 | xfs_dir2_leafn_check(dp, lbp); | 175 | xfs_dir2_leafn_check(dp, lbp); |
176 | return 0; | 176 | return 0; |
@@ -217,15 +217,15 @@ xfs_dir2_leafn_add( | |||
217 | * a compact. | 217 | * a compact. |
218 | */ | 218 | */ |
219 | 219 | ||
220 | if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == XFS_DIR2_MAX_LEAF_ENTS(mp)) { | 220 | if (be16_to_cpu(leaf->hdr.count) == XFS_DIR2_MAX_LEAF_ENTS(mp)) { |
221 | if (!leaf->hdr.stale) | 221 | if (!leaf->hdr.stale) |
222 | return XFS_ERROR(ENOSPC); | 222 | return XFS_ERROR(ENOSPC); |
223 | compact = INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1; | 223 | compact = be16_to_cpu(leaf->hdr.stale) > 1; |
224 | } else | 224 | } else |
225 | compact = 0; | 225 | compact = 0; |
226 | ASSERT(index == 0 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval); | 226 | ASSERT(index == 0 || be32_to_cpu(leaf->ents[index - 1].hashval) <= args->hashval); |
227 | ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 227 | ASSERT(index == be16_to_cpu(leaf->hdr.count) || |
228 | INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval); | 228 | be32_to_cpu(leaf->ents[index].hashval) >= args->hashval); |
229 | 229 | ||
230 | if (args->justcheck) | 230 | if (args->justcheck) |
231 | return 0; | 231 | return 0; |
@@ -242,7 +242,7 @@ xfs_dir2_leafn_add( | |||
242 | * Set impossible logging indices for this case. | 242 | * Set impossible logging indices for this case. |
243 | */ | 243 | */ |
244 | else if (leaf->hdr.stale) { | 244 | else if (leaf->hdr.stale) { |
245 | lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 245 | lfloglow = be16_to_cpu(leaf->hdr.count); |
246 | lfloghigh = -1; | 246 | lfloghigh = -1; |
247 | } | 247 | } |
248 | /* | 248 | /* |
@@ -250,12 +250,12 @@ xfs_dir2_leafn_add( | |||
250 | */ | 250 | */ |
251 | if (!leaf->hdr.stale) { | 251 | if (!leaf->hdr.stale) { |
252 | lep = &leaf->ents[index]; | 252 | lep = &leaf->ents[index]; |
253 | if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 253 | if (index < be16_to_cpu(leaf->hdr.count)) |
254 | memmove(lep + 1, lep, | 254 | memmove(lep + 1, lep, |
255 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); | 255 | (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep)); |
256 | lfloglow = index; | 256 | lfloglow = index; |
257 | lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 257 | lfloghigh = be16_to_cpu(leaf->hdr.count); |
258 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); | 258 | be16_add(&leaf->hdr.count, 1); |
259 | } | 259 | } |
260 | /* | 260 | /* |
261 | * There are stale entries. We'll use one for the new entry. | 261 | * There are stale entries. We'll use one for the new entry. |
@@ -271,7 +271,7 @@ xfs_dir2_leafn_add( | |||
271 | */ | 271 | */ |
272 | for (lowstale = index - 1; | 272 | for (lowstale = index - 1; |
273 | lowstale >= 0 && | 273 | lowstale >= 0 && |
274 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != | 274 | be32_to_cpu(leaf->ents[lowstale].address) != |
275 | XFS_DIR2_NULL_DATAPTR; | 275 | XFS_DIR2_NULL_DATAPTR; |
276 | lowstale--) | 276 | lowstale--) |
277 | continue; | 277 | continue; |
@@ -281,8 +281,8 @@ xfs_dir2_leafn_add( | |||
281 | * lowstale already found. | 281 | * lowstale already found. |
282 | */ | 282 | */ |
283 | for (highstale = index; | 283 | for (highstale = index; |
284 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 284 | highstale < be16_to_cpu(leaf->hdr.count) && |
285 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != | 285 | be32_to_cpu(leaf->ents[highstale].address) != |
286 | XFS_DIR2_NULL_DATAPTR && | 286 | XFS_DIR2_NULL_DATAPTR && |
287 | (lowstale < 0 || | 287 | (lowstale < 0 || |
288 | index - lowstale - 1 >= highstale - index); | 288 | index - lowstale - 1 >= highstale - index); |
@@ -294,9 +294,9 @@ xfs_dir2_leafn_add( | |||
294 | * Shift entries up toward the stale slot. | 294 | * Shift entries up toward the stale slot. |
295 | */ | 295 | */ |
296 | if (lowstale >= 0 && | 296 | if (lowstale >= 0 && |
297 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 297 | (highstale == be16_to_cpu(leaf->hdr.count) || |
298 | index - lowstale - 1 < highstale - index)) { | 298 | index - lowstale - 1 < highstale - index)) { |
299 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == | 299 | ASSERT(be32_to_cpu(leaf->ents[lowstale].address) == |
300 | XFS_DIR2_NULL_DATAPTR); | 300 | XFS_DIR2_NULL_DATAPTR); |
301 | ASSERT(index - lowstale - 1 >= 0); | 301 | ASSERT(index - lowstale - 1 >= 0); |
302 | if (index - lowstale - 1 > 0) | 302 | if (index - lowstale - 1 > 0) |
@@ -312,7 +312,7 @@ xfs_dir2_leafn_add( | |||
312 | * Shift entries down toward the stale slot. | 312 | * Shift entries down toward the stale slot. |
313 | */ | 313 | */ |
314 | else { | 314 | else { |
315 | ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) == | 315 | ASSERT(be32_to_cpu(leaf->ents[highstale].address) == |
316 | XFS_DIR2_NULL_DATAPTR); | 316 | XFS_DIR2_NULL_DATAPTR); |
317 | ASSERT(highstale - index >= 0); | 317 | ASSERT(highstale - index >= 0); |
318 | if (highstale - index > 0) | 318 | if (highstale - index > 0) |
@@ -323,13 +323,14 @@ xfs_dir2_leafn_add( | |||
323 | lfloglow = MIN(index, lfloglow); | 323 | lfloglow = MIN(index, lfloglow); |
324 | lfloghigh = MAX(highstale, lfloghigh); | 324 | lfloghigh = MAX(highstale, lfloghigh); |
325 | } | 325 | } |
326 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); | 326 | be16_add(&leaf->hdr.stale, -1); |
327 | } | 327 | } |
328 | /* | 328 | /* |
329 | * Insert the new entry, log everything. | 329 | * Insert the new entry, log everything. |
330 | */ | 330 | */ |
331 | INT_SET(lep->hashval, ARCH_CONVERT, args->hashval); | 331 | lep->hashval = cpu_to_be32(args->hashval); |
332 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, args->blkno, args->index)); | 332 | lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, |
333 | args->blkno, args->index)); | ||
333 | xfs_dir2_leaf_log_header(tp, bp); | 334 | xfs_dir2_leaf_log_header(tp, bp); |
334 | xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh); | 335 | xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh); |
335 | xfs_dir2_leafn_check(dp, bp); | 336 | xfs_dir2_leafn_check(dp, bp); |
@@ -352,17 +353,17 @@ xfs_dir2_leafn_check( | |||
352 | 353 | ||
353 | leaf = bp->data; | 354 | leaf = bp->data; |
354 | mp = dp->i_mount; | 355 | mp = dp->i_mount; |
355 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 356 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
356 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); | 357 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); |
357 | for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { | 358 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
358 | if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) { | 359 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) { |
359 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= | 360 | ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= |
360 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); | 361 | be32_to_cpu(leaf->ents[i + 1].hashval)); |
361 | } | 362 | } |
362 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 363 | if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
363 | stale++; | 364 | stale++; |
364 | } | 365 | } |
365 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); | 366 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); |
366 | } | 367 | } |
367 | #endif /* DEBUG */ | 368 | #endif /* DEBUG */ |
368 | 369 | ||
@@ -378,12 +379,12 @@ xfs_dir2_leafn_lasthash( | |||
378 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 379 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
379 | 380 | ||
380 | leaf = bp->data; | 381 | leaf = bp->data; |
381 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 382 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
382 | if (count) | 383 | if (count) |
383 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 384 | *count = be16_to_cpu(leaf->hdr.count); |
384 | if (!leaf->hdr.count) | 385 | if (!leaf->hdr.count) |
385 | return 0; | 386 | return 0; |
386 | return INT_GET(leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 387 | return be32_to_cpu(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval); |
387 | } | 388 | } |
388 | 389 | ||
389 | /* | 390 | /* |
@@ -419,9 +420,9 @@ xfs_dir2_leafn_lookup_int( | |||
419 | tp = args->trans; | 420 | tp = args->trans; |
420 | mp = dp->i_mount; | 421 | mp = dp->i_mount; |
421 | leaf = bp->data; | 422 | leaf = bp->data; |
422 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 423 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
423 | #ifdef __KERNEL__ | 424 | #ifdef __KERNEL__ |
424 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) > 0); | 425 | ASSERT(be16_to_cpu(leaf->hdr.count) > 0); |
425 | #endif | 426 | #endif |
426 | xfs_dir2_leafn_check(dp, bp); | 427 | xfs_dir2_leafn_check(dp, bp); |
427 | /* | 428 | /* |
@@ -443,7 +444,7 @@ xfs_dir2_leafn_lookup_int( | |||
443 | curdb = -1; | 444 | curdb = -1; |
444 | length = XFS_DIR2_DATA_ENTSIZE(args->namelen); | 445 | length = XFS_DIR2_DATA_ENTSIZE(args->namelen); |
445 | if ((free = (curbp ? curbp->data : NULL))) | 446 | if ((free = (curbp ? curbp->data : NULL))) |
446 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 447 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
447 | } | 448 | } |
448 | /* | 449 | /* |
449 | * For others, it's a data block buffer, get the block number. | 450 | * For others, it's a data block buffer, get the block number. |
@@ -456,17 +457,17 @@ xfs_dir2_leafn_lookup_int( | |||
456 | * Loop over leaf entries with the right hash value. | 457 | * Loop over leaf entries with the right hash value. |
457 | */ | 458 | */ |
458 | for (lep = &leaf->ents[index]; | 459 | for (lep = &leaf->ents[index]; |
459 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 460 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
460 | lep++, index++) { | 461 | lep++, index++) { |
461 | /* | 462 | /* |
462 | * Skip stale leaf entries. | 463 | * Skip stale leaf entries. |
463 | */ | 464 | */ |
464 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 465 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
465 | continue; | 466 | continue; |
466 | /* | 467 | /* |
467 | * Pull the data block number from the entry. | 468 | * Pull the data block number from the entry. |
468 | */ | 469 | */ |
469 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 470 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
470 | /* | 471 | /* |
471 | * For addname, we're looking for a place to put the new entry. | 472 | * For addname, we're looking for a place to put the new entry. |
472 | * We want to use a data block with an entry of equal | 473 | * We want to use a data block with an entry of equal |
@@ -506,15 +507,15 @@ xfs_dir2_leafn_lookup_int( | |||
506 | } | 507 | } |
507 | curfdb = newfdb; | 508 | curfdb = newfdb; |
508 | free = curbp->data; | 509 | free = curbp->data; |
509 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == | 510 | ASSERT(be32_to_cpu(free->hdr.magic) == |
510 | XFS_DIR2_FREE_MAGIC); | 511 | XFS_DIR2_FREE_MAGIC); |
511 | ASSERT((INT_GET(free->hdr.firstdb, ARCH_CONVERT) % | 512 | ASSERT((be32_to_cpu(free->hdr.firstdb) % |
512 | XFS_DIR2_MAX_FREE_BESTS(mp)) == | 513 | XFS_DIR2_MAX_FREE_BESTS(mp)) == |
513 | 0); | 514 | 0); |
514 | ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) <= curdb); | 515 | ASSERT(be32_to_cpu(free->hdr.firstdb) <= curdb); |
515 | ASSERT(curdb < | 516 | ASSERT(curdb < |
516 | INT_GET(free->hdr.firstdb, ARCH_CONVERT) + | 517 | be32_to_cpu(free->hdr.firstdb) + |
517 | INT_GET(free->hdr.nvalid, ARCH_CONVERT)); | 518 | be32_to_cpu(free->hdr.nvalid)); |
518 | } | 519 | } |
519 | /* | 520 | /* |
520 | * Get the index for our entry. | 521 | * Get the index for our entry. |
@@ -523,12 +524,12 @@ xfs_dir2_leafn_lookup_int( | |||
523 | /* | 524 | /* |
524 | * If it has room, return it. | 525 | * If it has room, return it. |
525 | */ | 526 | */ |
526 | if (unlikely(INT_GET(free->bests[fi], ARCH_CONVERT) == NULLDATAOFF)) { | 527 | if (unlikely(be16_to_cpu(free->bests[fi]) == NULLDATAOFF)) { |
527 | XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", | 528 | XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", |
528 | XFS_ERRLEVEL_LOW, mp); | 529 | XFS_ERRLEVEL_LOW, mp); |
529 | return XFS_ERROR(EFSCORRUPTED); | 530 | return XFS_ERROR(EFSCORRUPTED); |
530 | } | 531 | } |
531 | if (INT_GET(free->bests[fi], ARCH_CONVERT) >= length) { | 532 | if (be16_to_cpu(free->bests[fi]) >= length) { |
532 | *indexp = index; | 533 | *indexp = index; |
533 | state->extravalid = 1; | 534 | state->extravalid = 1; |
534 | state->extrablk.bp = curbp; | 535 | state->extrablk.bp = curbp; |
@@ -572,7 +573,7 @@ xfs_dir2_leafn_lookup_int( | |||
572 | */ | 573 | */ |
573 | dep = (xfs_dir2_data_entry_t *) | 574 | dep = (xfs_dir2_data_entry_t *) |
574 | ((char *)curbp->data + | 575 | ((char *)curbp->data + |
575 | XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 576 | XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
576 | /* | 577 | /* |
577 | * Compare the entry, return it if it matches. | 578 | * Compare the entry, return it if it matches. |
578 | */ | 579 | */ |
@@ -619,7 +620,7 @@ xfs_dir2_leafn_lookup_int( | |||
619 | * Return the final index, that will be the insertion point. | 620 | * Return the final index, that will be the insertion point. |
620 | */ | 621 | */ |
621 | *indexp = index; | 622 | *indexp = index; |
622 | ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent); | 623 | ASSERT(index == be16_to_cpu(leaf->hdr.count) || args->oknoent); |
623 | return XFS_ERROR(ENOENT); | 624 | return XFS_ERROR(ENOENT); |
624 | } | 625 | } |
625 | 626 | ||
@@ -657,12 +658,12 @@ xfs_dir2_leafn_moveents( | |||
657 | * destination leaf entries, open up a hole in the destination | 658 | * destination leaf entries, open up a hole in the destination |
658 | * to hold the new entries. | 659 | * to hold the new entries. |
659 | */ | 660 | */ |
660 | if (start_d < INT_GET(leaf_d->hdr.count, ARCH_CONVERT)) { | 661 | if (start_d < be16_to_cpu(leaf_d->hdr.count)) { |
661 | memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d], | 662 | memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d], |
662 | (INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - start_d) * | 663 | (be16_to_cpu(leaf_d->hdr.count) - start_d) * |
663 | sizeof(xfs_dir2_leaf_entry_t)); | 664 | sizeof(xfs_dir2_leaf_entry_t)); |
664 | xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count, | 665 | xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count, |
665 | count + INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - 1); | 666 | count + be16_to_cpu(leaf_d->hdr.count) - 1); |
666 | } | 667 | } |
667 | /* | 668 | /* |
668 | * If the source has stale leaves, count the ones in the copy range | 669 | * If the source has stale leaves, count the ones in the copy range |
@@ -672,7 +673,7 @@ xfs_dir2_leafn_moveents( | |||
672 | int i; /* temp leaf index */ | 673 | int i; /* temp leaf index */ |
673 | 674 | ||
674 | for (i = start_s, stale = 0; i < start_s + count; i++) { | 675 | for (i = start_s, stale = 0; i < start_s + count; i++) { |
675 | if (INT_GET(leaf_s->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 676 | if (be32_to_cpu(leaf_s->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
676 | stale++; | 677 | stale++; |
677 | } | 678 | } |
678 | } else | 679 | } else |
@@ -687,7 +688,7 @@ xfs_dir2_leafn_moveents( | |||
687 | * If there are source entries after the ones we copied, | 688 | * If there are source entries after the ones we copied, |
688 | * delete the ones we copied by sliding the next ones down. | 689 | * delete the ones we copied by sliding the next ones down. |
689 | */ | 690 | */ |
690 | if (start_s + count < INT_GET(leaf_s->hdr.count, ARCH_CONVERT)) { | 691 | if (start_s + count < be16_to_cpu(leaf_s->hdr.count)) { |
691 | memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count], | 692 | memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count], |
692 | count * sizeof(xfs_dir2_leaf_entry_t)); | 693 | count * sizeof(xfs_dir2_leaf_entry_t)); |
693 | xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1); | 694 | xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1); |
@@ -695,10 +696,10 @@ xfs_dir2_leafn_moveents( | |||
695 | /* | 696 | /* |
696 | * Update the headers and log them. | 697 | * Update the headers and log them. |
697 | */ | 698 | */ |
698 | INT_MOD(leaf_s->hdr.count, ARCH_CONVERT, -(count)); | 699 | be16_add(&leaf_s->hdr.count, -(count)); |
699 | INT_MOD(leaf_s->hdr.stale, ARCH_CONVERT, -(stale)); | 700 | be16_add(&leaf_s->hdr.stale, -(stale)); |
700 | INT_MOD(leaf_d->hdr.count, ARCH_CONVERT, count); | 701 | be16_add(&leaf_d->hdr.count, count); |
701 | INT_MOD(leaf_d->hdr.stale, ARCH_CONVERT, stale); | 702 | be16_add(&leaf_d->hdr.stale, stale); |
702 | xfs_dir2_leaf_log_header(tp, bp_s); | 703 | xfs_dir2_leaf_log_header(tp, bp_s); |
703 | xfs_dir2_leaf_log_header(tp, bp_d); | 704 | xfs_dir2_leaf_log_header(tp, bp_d); |
704 | xfs_dir2_leafn_check(args->dp, bp_s); | 705 | xfs_dir2_leafn_check(args->dp, bp_s); |
@@ -719,13 +720,13 @@ xfs_dir2_leafn_order( | |||
719 | 720 | ||
720 | leaf1 = leaf1_bp->data; | 721 | leaf1 = leaf1_bp->data; |
721 | leaf2 = leaf2_bp->data; | 722 | leaf2 = leaf2_bp->data; |
722 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 723 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
723 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 724 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
724 | if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0 && | 725 | if (be16_to_cpu(leaf1->hdr.count) > 0 && |
725 | INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0 && | 726 | be16_to_cpu(leaf2->hdr.count) > 0 && |
726 | (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) || | 727 | (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) || |
727 | INT_GET(leaf2->ents[INT_GET(leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT) < | 728 | be32_to_cpu(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval) < |
728 | INT_GET(leaf1->ents[INT_GET(leaf1->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT))) | 729 | be32_to_cpu(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval))) |
729 | return 1; | 730 | return 1; |
730 | return 0; | 731 | return 0; |
731 | } | 732 | } |
@@ -768,9 +769,9 @@ xfs_dir2_leafn_rebalance( | |||
768 | } | 769 | } |
769 | leaf1 = blk1->bp->data; | 770 | leaf1 = blk1->bp->data; |
770 | leaf2 = blk2->bp->data; | 771 | leaf2 = blk2->bp->data; |
771 | oldsum = INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT); | 772 | oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count); |
772 | #ifdef DEBUG | 773 | #ifdef DEBUG |
773 | oldstale = INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT); | 774 | oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale); |
774 | #endif | 775 | #endif |
775 | mid = oldsum >> 1; | 776 | mid = oldsum >> 1; |
776 | /* | 777 | /* |
@@ -780,10 +781,10 @@ xfs_dir2_leafn_rebalance( | |||
780 | if (oldsum & 1) { | 781 | if (oldsum & 1) { |
781 | xfs_dahash_t midhash; /* middle entry hash value */ | 782 | xfs_dahash_t midhash; /* middle entry hash value */ |
782 | 783 | ||
783 | if (mid >= INT_GET(leaf1->hdr.count, ARCH_CONVERT)) | 784 | if (mid >= be16_to_cpu(leaf1->hdr.count)) |
784 | midhash = INT_GET(leaf2->ents[mid - INT_GET(leaf1->hdr.count, ARCH_CONVERT)].hashval, ARCH_CONVERT); | 785 | midhash = be32_to_cpu(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval); |
785 | else | 786 | else |
786 | midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT); | 787 | midhash = be32_to_cpu(leaf1->ents[mid].hashval); |
787 | isleft = args->hashval <= midhash; | 788 | isleft = args->hashval <= midhash; |
788 | } | 789 | } |
789 | /* | 790 | /* |
@@ -797,30 +798,30 @@ xfs_dir2_leafn_rebalance( | |||
797 | * Calculate moved entry count. Positive means left-to-right, | 798 | * Calculate moved entry count. Positive means left-to-right, |
798 | * negative means right-to-left. Then move the entries. | 799 | * negative means right-to-left. Then move the entries. |
799 | */ | 800 | */ |
800 | count = INT_GET(leaf1->hdr.count, ARCH_CONVERT) - mid + (isleft == 0); | 801 | count = be16_to_cpu(leaf1->hdr.count) - mid + (isleft == 0); |
801 | if (count > 0) | 802 | if (count > 0) |
802 | xfs_dir2_leafn_moveents(args, blk1->bp, | 803 | xfs_dir2_leafn_moveents(args, blk1->bp, |
803 | INT_GET(leaf1->hdr.count, ARCH_CONVERT) - count, blk2->bp, 0, count); | 804 | be16_to_cpu(leaf1->hdr.count) - count, blk2->bp, 0, count); |
804 | else if (count < 0) | 805 | else if (count < 0) |
805 | xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp, | 806 | xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp, |
806 | INT_GET(leaf1->hdr.count, ARCH_CONVERT), count); | 807 | be16_to_cpu(leaf1->hdr.count), count); |
807 | ASSERT(INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT) == oldsum); | 808 | ASSERT(be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count) == oldsum); |
808 | ASSERT(INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT) == oldstale); | 809 | ASSERT(be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale) == oldstale); |
809 | /* | 810 | /* |
810 | * Mark whether we're inserting into the old or new leaf. | 811 | * Mark whether we're inserting into the old or new leaf. |
811 | */ | 812 | */ |
812 | if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) < INT_GET(leaf2->hdr.count, ARCH_CONVERT)) | 813 | if (be16_to_cpu(leaf1->hdr.count) < be16_to_cpu(leaf2->hdr.count)) |
813 | state->inleaf = swap; | 814 | state->inleaf = swap; |
814 | else if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > INT_GET(leaf2->hdr.count, ARCH_CONVERT)) | 815 | else if (be16_to_cpu(leaf1->hdr.count) > be16_to_cpu(leaf2->hdr.count)) |
815 | state->inleaf = !swap; | 816 | state->inleaf = !swap; |
816 | else | 817 | else |
817 | state->inleaf = | 818 | state->inleaf = |
818 | swap ^ (blk1->index <= INT_GET(leaf1->hdr.count, ARCH_CONVERT)); | 819 | swap ^ (blk1->index <= be16_to_cpu(leaf1->hdr.count)); |
819 | /* | 820 | /* |
820 | * Adjust the expected index for insertion. | 821 | * Adjust the expected index for insertion. |
821 | */ | 822 | */ |
822 | if (!state->inleaf) | 823 | if (!state->inleaf) |
823 | blk2->index = blk1->index - INT_GET(leaf1->hdr.count, ARCH_CONVERT); | 824 | blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count); |
824 | 825 | ||
825 | /* | 826 | /* |
826 | * Finally sanity check just to make sure we are not returning a negative index | 827 | * Finally sanity check just to make sure we are not returning a negative index |
@@ -867,7 +868,7 @@ xfs_dir2_leafn_remove( | |||
867 | tp = args->trans; | 868 | tp = args->trans; |
868 | mp = dp->i_mount; | 869 | mp = dp->i_mount; |
869 | leaf = bp->data; | 870 | leaf = bp->data; |
870 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 871 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
871 | /* | 872 | /* |
872 | * Point to the entry we're removing. | 873 | * Point to the entry we're removing. |
873 | */ | 874 | */ |
@@ -875,17 +876,17 @@ xfs_dir2_leafn_remove( | |||
875 | /* | 876 | /* |
876 | * Extract the data block and offset from the entry. | 877 | * Extract the data block and offset from the entry. |
877 | */ | 878 | */ |
878 | db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 879 | db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
879 | ASSERT(dblk->blkno == db); | 880 | ASSERT(dblk->blkno == db); |
880 | off = XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)); | 881 | off = XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)); |
881 | ASSERT(dblk->index == off); | 882 | ASSERT(dblk->index == off); |
882 | /* | 883 | /* |
883 | * Kill the leaf entry by marking it stale. | 884 | * Kill the leaf entry by marking it stale. |
884 | * Log the leaf block changes. | 885 | * Log the leaf block changes. |
885 | */ | 886 | */ |
886 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); | 887 | be16_add(&leaf->hdr.stale, 1); |
887 | xfs_dir2_leaf_log_header(tp, bp); | 888 | xfs_dir2_leaf_log_header(tp, bp); |
888 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 889 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
889 | xfs_dir2_leaf_log_ents(tp, bp, index, index); | 890 | xfs_dir2_leaf_log_ents(tp, bp, index, index); |
890 | /* | 891 | /* |
891 | * Make the data entry free. Keep track of the longest freespace | 892 | * Make the data entry free. Keep track of the longest freespace |
@@ -894,7 +895,7 @@ xfs_dir2_leafn_remove( | |||
894 | dbp = dblk->bp; | 895 | dbp = dblk->bp; |
895 | data = dbp->data; | 896 | data = dbp->data; |
896 | dep = (xfs_dir2_data_entry_t *)((char *)data + off); | 897 | dep = (xfs_dir2_data_entry_t *)((char *)data + off); |
897 | longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | 898 | longest = be16_to_cpu(data->hdr.bestfree[0].length); |
898 | needlog = needscan = 0; | 899 | needlog = needscan = 0; |
899 | xfs_dir2_data_make_free(tp, dbp, off, | 900 | xfs_dir2_data_make_free(tp, dbp, off, |
900 | XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); | 901 | XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); |
@@ -911,7 +912,7 @@ xfs_dir2_leafn_remove( | |||
911 | * If the longest data block freespace changes, need to update | 912 | * If the longest data block freespace changes, need to update |
912 | * the corresponding freeblock entry. | 913 | * the corresponding freeblock entry. |
913 | */ | 914 | */ |
914 | if (longest < INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | 915 | if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) { |
915 | int error; /* error return value */ | 916 | int error; /* error return value */ |
916 | xfs_dabuf_t *fbp; /* freeblock buffer */ | 917 | xfs_dabuf_t *fbp; /* freeblock buffer */ |
917 | xfs_dir2_db_t fdb; /* freeblock block number */ | 918 | xfs_dir2_db_t fdb; /* freeblock block number */ |
@@ -929,15 +930,15 @@ xfs_dir2_leafn_remove( | |||
929 | return error; | 930 | return error; |
930 | } | 931 | } |
931 | free = fbp->data; | 932 | free = fbp->data; |
932 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 933 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
933 | ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) == | 934 | ASSERT(be32_to_cpu(free->hdr.firstdb) == |
934 | XFS_DIR2_MAX_FREE_BESTS(mp) * | 935 | XFS_DIR2_MAX_FREE_BESTS(mp) * |
935 | (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); | 936 | (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); |
936 | /* | 937 | /* |
937 | * Calculate which entry we need to fix. | 938 | * Calculate which entry we need to fix. |
938 | */ | 939 | */ |
939 | findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); | 940 | findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); |
940 | longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | 941 | longest = be16_to_cpu(data->hdr.bestfree[0].length); |
941 | /* | 942 | /* |
942 | * If the data block is now empty we can get rid of it | 943 | * If the data block is now empty we can get rid of it |
943 | * (usually). | 944 | * (usually). |
@@ -969,7 +970,7 @@ xfs_dir2_leafn_remove( | |||
969 | /* | 970 | /* |
970 | * One less used entry in the free table. | 971 | * One less used entry in the free table. |
971 | */ | 972 | */ |
972 | INT_MOD(free->hdr.nused, ARCH_CONVERT, -1); | 973 | free->hdr.nused = cpu_to_be32(-1); |
973 | xfs_dir2_free_log_header(tp, fbp); | 974 | xfs_dir2_free_log_header(tp, fbp); |
974 | /* | 975 | /* |
975 | * If this was the last entry in the table, we can | 976 | * If this was the last entry in the table, we can |
@@ -977,21 +978,21 @@ xfs_dir2_leafn_remove( | |||
977 | * entries at the end referring to non-existent | 978 | * entries at the end referring to non-existent |
978 | * data blocks, get those too. | 979 | * data blocks, get those too. |
979 | */ | 980 | */ |
980 | if (findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1) { | 981 | if (findex == be32_to_cpu(free->hdr.nvalid) - 1) { |
981 | int i; /* free entry index */ | 982 | int i; /* free entry index */ |
982 | 983 | ||
983 | for (i = findex - 1; | 984 | for (i = findex - 1; |
984 | i >= 0 && INT_GET(free->bests[i], ARCH_CONVERT) == NULLDATAOFF; | 985 | i >= 0 && be16_to_cpu(free->bests[i]) == NULLDATAOFF; |
985 | i--) | 986 | i--) |
986 | continue; | 987 | continue; |
987 | INT_SET(free->hdr.nvalid, ARCH_CONVERT, i + 1); | 988 | free->hdr.nvalid = cpu_to_be32(i + 1); |
988 | logfree = 0; | 989 | logfree = 0; |
989 | } | 990 | } |
990 | /* | 991 | /* |
991 | * Not the last entry, just punch it out. | 992 | * Not the last entry, just punch it out. |
992 | */ | 993 | */ |
993 | else { | 994 | else { |
994 | INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF); | 995 | free->bests[findex] = cpu_to_be16(NULLDATAOFF); |
995 | logfree = 1; | 996 | logfree = 1; |
996 | } | 997 | } |
997 | /* | 998 | /* |
@@ -1017,7 +1018,7 @@ xfs_dir2_leafn_remove( | |||
1017 | * the new value. | 1018 | * the new value. |
1018 | */ | 1019 | */ |
1019 | else { | 1020 | else { |
1020 | INT_SET(free->bests[findex], ARCH_CONVERT, longest); | 1021 | free->bests[findex] = cpu_to_be16(longest); |
1021 | logfree = 1; | 1022 | logfree = 1; |
1022 | } | 1023 | } |
1023 | /* | 1024 | /* |
@@ -1039,7 +1040,7 @@ xfs_dir2_leafn_remove( | |||
1039 | *rval = | 1040 | *rval = |
1040 | ((uint)sizeof(leaf->hdr) + | 1041 | ((uint)sizeof(leaf->hdr) + |
1041 | (uint)sizeof(leaf->ents[0]) * | 1042 | (uint)sizeof(leaf->ents[0]) * |
1042 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT))) < | 1043 | (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale))) < |
1043 | mp->m_dir_magicpct; | 1044 | mp->m_dir_magicpct; |
1044 | return 0; | 1045 | return 0; |
1045 | } | 1046 | } |
@@ -1138,9 +1139,9 @@ xfs_dir2_leafn_toosmall( | |||
1138 | */ | 1139 | */ |
1139 | blk = &state->path.blk[state->path.active - 1]; | 1140 | blk = &state->path.blk[state->path.active - 1]; |
1140 | info = blk->bp->data; | 1141 | info = blk->bp->data; |
1141 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1142 | ASSERT(be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC); |
1142 | leaf = (xfs_dir2_leaf_t *)info; | 1143 | leaf = (xfs_dir2_leaf_t *)info; |
1143 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); | 1144 | count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); |
1144 | bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); | 1145 | bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); |
1145 | if (bytes > (state->blocksize >> 1)) { | 1146 | if (bytes > (state->blocksize >> 1)) { |
1146 | /* | 1147 | /* |
@@ -1160,7 +1161,7 @@ xfs_dir2_leafn_toosmall( | |||
1160 | * Make altpath point to the block we want to keep and | 1161 | * Make altpath point to the block we want to keep and |
1161 | * path point to the block we want to drop (this one). | 1162 | * path point to the block we want to drop (this one). |
1162 | */ | 1163 | */ |
1163 | forward = info->forw; | 1164 | forward = (info->forw != 0); |
1164 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1165 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1165 | error = xfs_da_path_shift(state, &state->altpath, forward, 0, | 1166 | error = xfs_da_path_shift(state, &state->altpath, forward, 0, |
1166 | &rval); | 1167 | &rval); |
@@ -1176,9 +1177,9 @@ xfs_dir2_leafn_toosmall( | |||
1176 | * We prefer coalescing with the lower numbered sibling so as | 1177 | * We prefer coalescing with the lower numbered sibling so as |
1177 | * to shrink a directory over time. | 1178 | * to shrink a directory over time. |
1178 | */ | 1179 | */ |
1179 | forward = INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT); | 1180 | forward = be32_to_cpu(info->forw) < be32_to_cpu(info->back); |
1180 | for (i = 0, bp = NULL; i < 2; forward = !forward, i++) { | 1181 | for (i = 0, bp = NULL; i < 2; forward = !forward, i++) { |
1181 | blkno = forward ?INT_GET( info->forw, ARCH_CONVERT) : INT_GET(info->back, ARCH_CONVERT); | 1182 | blkno = forward ? be32_to_cpu(info->forw) : be32_to_cpu(info->back); |
1182 | if (blkno == 0) | 1183 | if (blkno == 0) |
1183 | continue; | 1184 | continue; |
1184 | /* | 1185 | /* |
@@ -1194,11 +1195,11 @@ xfs_dir2_leafn_toosmall( | |||
1194 | * Count bytes in the two blocks combined. | 1195 | * Count bytes in the two blocks combined. |
1195 | */ | 1196 | */ |
1196 | leaf = (xfs_dir2_leaf_t *)info; | 1197 | leaf = (xfs_dir2_leaf_t *)info; |
1197 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); | 1198 | count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); |
1198 | bytes = state->blocksize - (state->blocksize >> 2); | 1199 | bytes = state->blocksize - (state->blocksize >> 2); |
1199 | leaf = bp->data; | 1200 | leaf = bp->data; |
1200 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1201 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1201 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); | 1202 | count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); |
1202 | bytes -= count * (uint)sizeof(leaf->ents[0]); | 1203 | bytes -= count * (uint)sizeof(leaf->ents[0]); |
1203 | /* | 1204 | /* |
1204 | * Fits with at least 25% to spare. | 1205 | * Fits with at least 25% to spare. |
@@ -1256,27 +1257,27 @@ xfs_dir2_leafn_unbalance( | |||
1256 | ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); | 1257 | ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); |
1257 | drop_leaf = drop_blk->bp->data; | 1258 | drop_leaf = drop_blk->bp->data; |
1258 | save_leaf = save_blk->bp->data; | 1259 | save_leaf = save_blk->bp->data; |
1259 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1260 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1260 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1261 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1261 | /* | 1262 | /* |
1262 | * If there are any stale leaf entries, take this opportunity | 1263 | * If there are any stale leaf entries, take this opportunity |
1263 | * to purge them. | 1264 | * to purge them. |
1264 | */ | 1265 | */ |
1265 | if (INT_GET(drop_leaf->hdr.stale, ARCH_CONVERT)) | 1266 | if (drop_leaf->hdr.stale) |
1266 | xfs_dir2_leaf_compact(args, drop_blk->bp); | 1267 | xfs_dir2_leaf_compact(args, drop_blk->bp); |
1267 | if (INT_GET(save_leaf->hdr.stale, ARCH_CONVERT)) | 1268 | if (save_leaf->hdr.stale) |
1268 | xfs_dir2_leaf_compact(args, save_blk->bp); | 1269 | xfs_dir2_leaf_compact(args, save_blk->bp); |
1269 | /* | 1270 | /* |
1270 | * Move the entries from drop to the appropriate end of save. | 1271 | * Move the entries from drop to the appropriate end of save. |
1271 | */ | 1272 | */ |
1272 | drop_blk->hashval = INT_GET(drop_leaf->ents[INT_GET(drop_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1273 | drop_blk->hashval = be32_to_cpu(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval); |
1273 | if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) | 1274 | if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) |
1274 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0, | 1275 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0, |
1275 | INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); | 1276 | be16_to_cpu(drop_leaf->hdr.count)); |
1276 | else | 1277 | else |
1277 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, | 1278 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, |
1278 | INT_GET(save_leaf->hdr.count, ARCH_CONVERT), INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); | 1279 | be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count)); |
1279 | save_blk->hashval = INT_GET(save_leaf->ents[INT_GET(save_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1280 | save_blk->hashval = be32_to_cpu(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval); |
1280 | xfs_dir2_leafn_check(args->dp, save_blk->bp); | 1281 | xfs_dir2_leafn_check(args->dp, save_blk->bp); |
1281 | } | 1282 | } |
1282 | 1283 | ||
@@ -1378,7 +1379,7 @@ xfs_dir2_node_addname_int( | |||
1378 | xfs_mount_t *mp; /* filesystem mount point */ | 1379 | xfs_mount_t *mp; /* filesystem mount point */ |
1379 | int needlog; /* need to log data header */ | 1380 | int needlog; /* need to log data header */ |
1380 | int needscan; /* need to rescan data frees */ | 1381 | int needscan; /* need to rescan data frees */ |
1381 | xfs_dir2_data_off_t *tagp; /* data entry tag pointer */ | 1382 | __be16 *tagp; /* data entry tag pointer */ |
1382 | xfs_trans_t *tp; /* transaction pointer */ | 1383 | xfs_trans_t *tp; /* transaction pointer */ |
1383 | 1384 | ||
1384 | dp = args->dp; | 1385 | dp = args->dp; |
@@ -1397,7 +1398,7 @@ xfs_dir2_node_addname_int( | |||
1397 | */ | 1398 | */ |
1398 | ifbno = fblk->blkno; | 1399 | ifbno = fblk->blkno; |
1399 | free = fbp->data; | 1400 | free = fbp->data; |
1400 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1401 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1401 | findex = fblk->index; | 1402 | findex = fblk->index; |
1402 | /* | 1403 | /* |
1403 | * This means the free entry showed that the data block had | 1404 | * This means the free entry showed that the data block had |
@@ -1405,10 +1406,10 @@ xfs_dir2_node_addname_int( | |||
1405 | * Use that data block. | 1406 | * Use that data block. |
1406 | */ | 1407 | */ |
1407 | if (findex >= 0) { | 1408 | if (findex >= 0) { |
1408 | ASSERT(findex < INT_GET(free->hdr.nvalid, ARCH_CONVERT)); | 1409 | ASSERT(findex < be32_to_cpu(free->hdr.nvalid)); |
1409 | ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF); | 1410 | ASSERT(be16_to_cpu(free->bests[findex]) != NULLDATAOFF); |
1410 | ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) >= length); | 1411 | ASSERT(be16_to_cpu(free->bests[findex]) >= length); |
1411 | dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex; | 1412 | dbno = be32_to_cpu(free->hdr.firstdb) + findex; |
1412 | } | 1413 | } |
1413 | /* | 1414 | /* |
1414 | * The data block looked at didn't have enough room. | 1415 | * The data block looked at didn't have enough room. |
@@ -1481,20 +1482,20 @@ xfs_dir2_node_addname_int( | |||
1481 | continue; | 1482 | continue; |
1482 | } | 1483 | } |
1483 | free = fbp->data; | 1484 | free = fbp->data; |
1484 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1485 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1485 | findex = 0; | 1486 | findex = 0; |
1486 | } | 1487 | } |
1487 | /* | 1488 | /* |
1488 | * Look at the current free entry. Is it good enough? | 1489 | * Look at the current free entry. Is it good enough? |
1489 | */ | 1490 | */ |
1490 | if (INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF && | 1491 | if (be16_to_cpu(free->bests[findex]) != NULLDATAOFF && |
1491 | INT_GET(free->bests[findex], ARCH_CONVERT) >= length) | 1492 | be16_to_cpu(free->bests[findex]) >= length) |
1492 | dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex; | 1493 | dbno = be32_to_cpu(free->hdr.firstdb) + findex; |
1493 | else { | 1494 | else { |
1494 | /* | 1495 | /* |
1495 | * Are we done with the freeblock? | 1496 | * Are we done with the freeblock? |
1496 | */ | 1497 | */ |
1497 | if (++findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT)) { | 1498 | if (++findex == be32_to_cpu(free->hdr.nvalid)) { |
1498 | /* | 1499 | /* |
1499 | * Drop the block. | 1500 | * Drop the block. |
1500 | */ | 1501 | */ |
@@ -1608,15 +1609,15 @@ xfs_dir2_node_addname_int( | |||
1608 | * its first slot as our empty slot. | 1609 | * its first slot as our empty slot. |
1609 | */ | 1610 | */ |
1610 | free = fbp->data; | 1611 | free = fbp->data; |
1611 | INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC); | 1612 | free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); |
1612 | INT_SET(free->hdr.firstdb, ARCH_CONVERT, | 1613 | free->hdr.firstdb = cpu_to_be32( |
1613 | (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * | 1614 | (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * |
1614 | XFS_DIR2_MAX_FREE_BESTS(mp)); | 1615 | XFS_DIR2_MAX_FREE_BESTS(mp)); |
1615 | free->hdr.nvalid = 0; | 1616 | free->hdr.nvalid = 0; |
1616 | free->hdr.nused = 0; | 1617 | free->hdr.nused = 0; |
1617 | } else { | 1618 | } else { |
1618 | free = fbp->data; | 1619 | free = fbp->data; |
1619 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1620 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1620 | } | 1621 | } |
1621 | 1622 | ||
1622 | /* | 1623 | /* |
@@ -1627,20 +1628,20 @@ xfs_dir2_node_addname_int( | |||
1627 | * If it's after the end of the current entries in the | 1628 | * If it's after the end of the current entries in the |
1628 | * freespace block, extend that table. | 1629 | * freespace block, extend that table. |
1629 | */ | 1630 | */ |
1630 | if (findex >= INT_GET(free->hdr.nvalid, ARCH_CONVERT)) { | 1631 | if (findex >= be32_to_cpu(free->hdr.nvalid)) { |
1631 | ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp)); | 1632 | ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp)); |
1632 | INT_SET(free->hdr.nvalid, ARCH_CONVERT, findex + 1); | 1633 | free->hdr.nvalid = cpu_to_be32(findex + 1); |
1633 | /* | 1634 | /* |
1634 | * Tag new entry so nused will go up. | 1635 | * Tag new entry so nused will go up. |
1635 | */ | 1636 | */ |
1636 | INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF); | 1637 | free->bests[findex] = cpu_to_be16(NULLDATAOFF); |
1637 | } | 1638 | } |
1638 | /* | 1639 | /* |
1639 | * If this entry was for an empty data block | 1640 | * If this entry was for an empty data block |
1640 | * (this should always be true) then update the header. | 1641 | * (this should always be true) then update the header. |
1641 | */ | 1642 | */ |
1642 | if (INT_GET(free->bests[findex], ARCH_CONVERT) == NULLDATAOFF) { | 1643 | if (be16_to_cpu(free->bests[findex]) == NULLDATAOFF) { |
1643 | INT_MOD(free->hdr.nused, ARCH_CONVERT, +1); | 1644 | be32_add(&free->hdr.nused, 1); |
1644 | xfs_dir2_free_log_header(tp, fbp); | 1645 | xfs_dir2_free_log_header(tp, fbp); |
1645 | } | 1646 | } |
1646 | /* | 1647 | /* |
@@ -1649,7 +1650,7 @@ xfs_dir2_node_addname_int( | |||
1649 | * change again. | 1650 | * change again. |
1650 | */ | 1651 | */ |
1651 | data = dbp->data; | 1652 | data = dbp->data; |
1652 | INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); | 1653 | free->bests[findex] = data->hdr.bestfree[0].length; |
1653 | logfree = 1; | 1654 | logfree = 1; |
1654 | } | 1655 | } |
1655 | /* | 1656 | /* |
@@ -1677,12 +1678,12 @@ xfs_dir2_node_addname_int( | |||
1677 | data = dbp->data; | 1678 | data = dbp->data; |
1678 | logfree = 0; | 1679 | logfree = 0; |
1679 | } | 1680 | } |
1680 | ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) >= length); | 1681 | ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length); |
1681 | /* | 1682 | /* |
1682 | * Point to the existing unused space. | 1683 | * Point to the existing unused space. |
1683 | */ | 1684 | */ |
1684 | dup = (xfs_dir2_data_unused_t *) | 1685 | dup = (xfs_dir2_data_unused_t *) |
1685 | ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); | 1686 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); |
1686 | needscan = needlog = 0; | 1687 | needscan = needlog = 0; |
1687 | /* | 1688 | /* |
1688 | * Mark the first part of the unused space, inuse for us. | 1689 | * Mark the first part of the unused space, inuse for us. |
@@ -1698,7 +1699,7 @@ xfs_dir2_node_addname_int( | |||
1698 | dep->namelen = args->namelen; | 1699 | dep->namelen = args->namelen; |
1699 | memcpy(dep->name, args->name, dep->namelen); | 1700 | memcpy(dep->name, args->name, dep->namelen); |
1700 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1701 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1701 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data)); | 1702 | *tagp = cpu_to_be16((char *)dep - (char *)data); |
1702 | xfs_dir2_data_log_entry(tp, dbp, dep); | 1703 | xfs_dir2_data_log_entry(tp, dbp, dep); |
1703 | /* | 1704 | /* |
1704 | * Rescan the block for bestfree if needed. | 1705 | * Rescan the block for bestfree if needed. |
@@ -1713,8 +1714,8 @@ xfs_dir2_node_addname_int( | |||
1713 | /* | 1714 | /* |
1714 | * If the freespace entry is now wrong, update it. | 1715 | * If the freespace entry is now wrong, update it. |
1715 | */ | 1716 | */ |
1716 | if (INT_GET(free->bests[findex], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | 1717 | if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) { |
1717 | INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); | 1718 | free->bests[findex] = data->hdr.bestfree[0].length; |
1718 | logfree = 1; | 1719 | logfree = 1; |
1719 | } | 1720 | } |
1720 | /* | 1721 | /* |
@@ -1731,7 +1732,7 @@ xfs_dir2_node_addname_int( | |||
1731 | * Return the data block and offset in args, then drop the data block. | 1732 | * Return the data block and offset in args, then drop the data block. |
1732 | */ | 1733 | */ |
1733 | args->blkno = (xfs_dablk_t)dbno; | 1734 | args->blkno = (xfs_dablk_t)dbno; |
1734 | args->index = INT_GET(*tagp, ARCH_CONVERT); | 1735 | args->index = be16_to_cpu(*tagp); |
1735 | xfs_da_buf_done(dbp); | 1736 | xfs_da_buf_done(dbp); |
1736 | return 0; | 1737 | return 0; |
1737 | } | 1738 | } |
@@ -1900,10 +1901,10 @@ xfs_dir2_node_replace( | |||
1900 | * Point to the data entry. | 1901 | * Point to the data entry. |
1901 | */ | 1902 | */ |
1902 | data = state->extrablk.bp->data; | 1903 | data = state->extrablk.bp->data; |
1903 | ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | 1904 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); |
1904 | dep = (xfs_dir2_data_entry_t *) | 1905 | dep = (xfs_dir2_data_entry_t *) |
1905 | ((char *)data + | 1906 | ((char *)data + |
1906 | XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT))); | 1907 | XFS_DIR2_DATAPTR_TO_OFF(state->mp, be32_to_cpu(lep->address))); |
1907 | ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT)); | 1908 | ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT)); |
1908 | /* | 1909 | /* |
1909 | * Fill in the new inode number and log the entry. | 1910 | * Fill in the new inode number and log the entry. |
@@ -1966,11 +1967,11 @@ xfs_dir2_node_trim_free( | |||
1966 | return 0; | 1967 | return 0; |
1967 | } | 1968 | } |
1968 | free = bp->data; | 1969 | free = bp->data; |
1969 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1970 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1970 | /* | 1971 | /* |
1971 | * If there are used entries, there's nothing to do. | 1972 | * If there are used entries, there's nothing to do. |
1972 | */ | 1973 | */ |
1973 | if (INT_GET(free->hdr.nused, ARCH_CONVERT) > 0) { | 1974 | if (be32_to_cpu(free->hdr.nused) > 0) { |
1974 | xfs_da_brelse(tp, bp); | 1975 | xfs_da_brelse(tp, bp); |
1975 | *rvalp = 0; | 1976 | *rvalp = 0; |
1976 | return 0; | 1977 | return 0; |
diff --git a/fs/xfs/xfs_dir2_node.h b/fs/xfs/xfs_dir2_node.h index 0ab8fbd59512..c7c870ee7857 100644 --- a/fs/xfs/xfs_dir2_node.h +++ b/fs/xfs/xfs_dir2_node.h | |||
@@ -41,15 +41,15 @@ struct xfs_trans; | |||
41 | #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */ | 41 | #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */ |
42 | 42 | ||
43 | typedef struct xfs_dir2_free_hdr { | 43 | typedef struct xfs_dir2_free_hdr { |
44 | __uint32_t magic; /* XFS_DIR2_FREE_MAGIC */ | 44 | __be32 magic; /* XFS_DIR2_FREE_MAGIC */ |
45 | __int32_t firstdb; /* db of first entry */ | 45 | __be32 firstdb; /* db of first entry */ |
46 | __int32_t nvalid; /* count of valid entries */ | 46 | __be32 nvalid; /* count of valid entries */ |
47 | __int32_t nused; /* count of used entries */ | 47 | __be32 nused; /* count of used entries */ |
48 | } xfs_dir2_free_hdr_t; | 48 | } xfs_dir2_free_hdr_t; |
49 | 49 | ||
50 | typedef struct xfs_dir2_free { | 50 | typedef struct xfs_dir2_free { |
51 | xfs_dir2_free_hdr_t hdr; /* block header */ | 51 | xfs_dir2_free_hdr_t hdr; /* block header */ |
52 | xfs_dir2_data_off_t bests[1]; /* best free counts */ | 52 | __be16 bests[1]; /* best free counts */ |
53 | /* unused entries are -1 */ | 53 | /* unused entries are -1 */ |
54 | } xfs_dir2_free_t; | 54 | } xfs_dir2_free_t; |
55 | 55 | ||
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index ec8e7476c8b7..d98a41d1fe63 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
@@ -98,8 +98,8 @@ xfs_dir2_block_sfsize( | |||
98 | /* | 98 | /* |
99 | * Iterate over the block's data entries by using the leaf pointers. | 99 | * Iterate over the block's data entries by using the leaf pointers. |
100 | */ | 100 | */ |
101 | for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { | 101 | for (i = 0; i < be32_to_cpu(btp->count); i++) { |
102 | if ((addr = INT_GET(blp[i].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR) | 102 | if ((addr = be32_to_cpu(blp[i].address)) == XFS_DIR2_NULL_DATAPTR) |
103 | continue; | 103 | continue; |
104 | /* | 104 | /* |
105 | * Calculate the pointer to the entry at hand. | 105 | * Calculate the pointer to the entry at hand. |
@@ -220,8 +220,8 @@ xfs_dir2_block_to_sf( | |||
220 | * If it's unused, just skip over it. | 220 | * If it's unused, just skip over it. |
221 | */ | 221 | */ |
222 | dup = (xfs_dir2_data_unused_t *)ptr; | 222 | dup = (xfs_dir2_data_unused_t *)ptr; |
223 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 223 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
224 | ptr += INT_GET(dup->length, ARCH_CONVERT); | 224 | ptr += be16_to_cpu(dup->length); |
225 | continue; | 225 | continue; |
226 | } | 226 | } |
227 | dep = (xfs_dir2_data_entry_t *)ptr; | 227 | dep = (xfs_dir2_data_entry_t *)ptr; |
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c index e83074016abb..ee88751c3be6 100644 --- a/fs/xfs/xfs_dir_leaf.c +++ b/fs/xfs/xfs_dir_leaf.c | |||
@@ -176,7 +176,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args) | |||
176 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 176 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
177 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; | 177 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; |
178 | sfe = &sf->list[0]; | 178 | sfe = &sf->list[0]; |
179 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 179 | for (i = sf->hdr.count-1; i >= 0; i--) { |
180 | if (sfe->namelen == args->namelen && | 180 | if (sfe->namelen == args->namelen && |
181 | args->name[0] == sfe->name[0] && | 181 | args->name[0] == sfe->name[0] && |
182 | memcmp(args->name, sfe->name, args->namelen) == 0) | 182 | memcmp(args->name, sfe->name, args->namelen) == 0) |
@@ -193,7 +193,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args) | |||
193 | XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); | 193 | XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); |
194 | sfe->namelen = args->namelen; | 194 | sfe->namelen = args->namelen; |
195 | memcpy(sfe->name, args->name, sfe->namelen); | 195 | memcpy(sfe->name, args->name, sfe->namelen); |
196 | INT_MOD(sf->hdr.count, ARCH_CONVERT, +1); | 196 | sf->hdr.count++; |
197 | 197 | ||
198 | dp->i_d.di_size += size; | 198 | dp->i_d.di_size += size; |
199 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 199 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
@@ -227,7 +227,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args) | |||
227 | base = sizeof(xfs_dir_sf_hdr_t); | 227 | base = sizeof(xfs_dir_sf_hdr_t); |
228 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; | 228 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; |
229 | sfe = &sf->list[0]; | 229 | sfe = &sf->list[0]; |
230 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 230 | for (i = sf->hdr.count-1; i >= 0; i--) { |
231 | size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe); | 231 | size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe); |
232 | if (sfe->namelen == args->namelen && | 232 | if (sfe->namelen == args->namelen && |
233 | sfe->name[0] == args->name[0] && | 233 | sfe->name[0] == args->name[0] && |
@@ -245,7 +245,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args) | |||
245 | memmove(&((char *)sf)[base], &((char *)sf)[base+size], | 245 | memmove(&((char *)sf)[base], &((char *)sf)[base+size], |
246 | dp->i_d.di_size - (base+size)); | 246 | dp->i_d.di_size - (base+size)); |
247 | } | 247 | } |
248 | INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); | 248 | sf->hdr.count--; |
249 | 249 | ||
250 | xfs_idata_realloc(dp, -size, XFS_DATA_FORK); | 250 | xfs_idata_realloc(dp, -size, XFS_DATA_FORK); |
251 | dp->i_d.di_size -= size; | 251 | dp->i_d.di_size -= size; |
@@ -288,7 +288,7 @@ xfs_dir_shortform_lookup(xfs_da_args_t *args) | |||
288 | return(XFS_ERROR(EEXIST)); | 288 | return(XFS_ERROR(EEXIST)); |
289 | } | 289 | } |
290 | sfe = &sf->list[0]; | 290 | sfe = &sf->list[0]; |
291 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 291 | for (i = sf->hdr.count-1; i >= 0; i--) { |
292 | if (sfe->namelen == args->namelen && | 292 | if (sfe->namelen == args->namelen && |
293 | sfe->name[0] == args->name[0] && | 293 | sfe->name[0] == args->name[0] && |
294 | memcmp(args->name, sfe->name, args->namelen) == 0) { | 294 | memcmp(args->name, sfe->name, args->namelen) == 0) { |
@@ -375,7 +375,7 @@ xfs_dir_shortform_to_leaf(xfs_da_args_t *iargs) | |||
375 | goto out; | 375 | goto out; |
376 | 376 | ||
377 | sfe = &sf->list[0]; | 377 | sfe = &sf->list[0]; |
378 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | 378 | for (i = 0; i < sf->hdr.count; i++) { |
379 | args.name = (char *)(sfe->name); | 379 | args.name = (char *)(sfe->name); |
380 | args.namelen = sfe->namelen; | 380 | args.namelen = sfe->namelen; |
381 | args.hashval = xfs_da_hashname((char *)(sfe->name), | 381 | args.hashval = xfs_da_hashname((char *)(sfe->name), |
@@ -428,7 +428,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp, | |||
428 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; | 428 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; |
429 | cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset); | 429 | cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset); |
430 | want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); | 430 | want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); |
431 | nsbuf = INT_GET(sf->hdr.count, ARCH_CONVERT) + 2; | 431 | nsbuf = sf->hdr.count + 2; |
432 | sbsize = (nsbuf + 1) * sizeof(*sbuf); | 432 | sbsize = (nsbuf + 1) * sizeof(*sbuf); |
433 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); | 433 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); |
434 | 434 | ||
@@ -460,8 +460,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp, | |||
460 | /* | 460 | /* |
461 | * Scan the directory data for the rest of the entries. | 461 | * Scan the directory data for the rest of the entries. |
462 | */ | 462 | */ |
463 | for (i = 0, sfe = &sf->list[0]; | 463 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
464 | i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | ||
465 | 464 | ||
466 | if (unlikely( | 465 | if (unlikely( |
467 | ((char *)sfe < (char *)sf) || | 466 | ((char *)sfe < (char *)sf) || |
@@ -600,7 +599,7 @@ xfs_dir_shortform_replace(xfs_da_args_t *args) | |||
600 | } | 599 | } |
601 | ASSERT(args->namelen != 1 || args->name[0] != '.'); | 600 | ASSERT(args->namelen != 1 || args->name[0] != '.'); |
602 | sfe = &sf->list[0]; | 601 | sfe = &sf->list[0]; |
603 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 602 | for (i = sf->hdr.count-1; i >= 0; i--) { |
604 | if (sfe->namelen == args->namelen && | 603 | if (sfe->namelen == args->namelen && |
605 | sfe->name[0] == args->name[0] && | 604 | sfe->name[0] == args->name[0] && |
606 | memcmp(args->name, sfe->name, args->namelen) == 0) { | 605 | memcmp(args->name, sfe->name, args->namelen) == 0) { |
@@ -644,7 +643,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) | |||
644 | ASSERT(bp != NULL); | 643 | ASSERT(bp != NULL); |
645 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); | 644 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); |
646 | leaf = (xfs_dir_leafblock_t *)tmpbuffer; | 645 | leaf = (xfs_dir_leafblock_t *)tmpbuffer; |
647 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 646 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
648 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); | 647 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); |
649 | 648 | ||
650 | /* | 649 | /* |
@@ -742,11 +741,13 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) | |||
742 | } | 741 | } |
743 | node = bp1->data; | 742 | node = bp1->data; |
744 | leaf = bp2->data; | 743 | leaf = bp2->data; |
745 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 744 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
746 | INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); | 745 | node->btree[0].hashval = cpu_to_be32( |
746 | INT_GET(leaf->entries[ | ||
747 | INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); | ||
747 | xfs_da_buf_done(bp2); | 748 | xfs_da_buf_done(bp2); |
748 | INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); | 749 | node->btree[0].before = cpu_to_be32(blkno); |
749 | INT_SET(node->hdr.count, ARCH_CONVERT, 1); | 750 | node->hdr.count = cpu_to_be16(1); |
750 | xfs_da_log_buf(args->trans, bp1, | 751 | xfs_da_log_buf(args->trans, bp1, |
751 | XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); | 752 | XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); |
752 | xfs_da_buf_done(bp1); | 753 | xfs_da_buf_done(bp1); |
@@ -781,7 +782,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) | |||
781 | leaf = bp->data; | 782 | leaf = bp->data; |
782 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); | 783 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); |
783 | hdr = &leaf->hdr; | 784 | hdr = &leaf->hdr; |
784 | INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_DIR_LEAF_MAGIC); | 785 | hdr->info.magic = cpu_to_be16(XFS_DIR_LEAF_MAGIC); |
785 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); | 786 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); |
786 | if (!hdr->firstused) | 787 | if (!hdr->firstused) |
787 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); | 788 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); |
@@ -860,7 +861,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) | |||
860 | int tablesize, entsize, sum, i, tmp, error; | 861 | int tablesize, entsize, sum, i, tmp, error; |
861 | 862 | ||
862 | leaf = bp->data; | 863 | leaf = bp->data; |
863 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 864 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
864 | ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 865 | ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); |
865 | hdr = &leaf->hdr; | 866 | hdr = &leaf->hdr; |
866 | entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); | 867 | entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); |
@@ -940,7 +941,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, | |||
940 | int tmp, i; | 941 | int tmp, i; |
941 | 942 | ||
942 | leaf = bp->data; | 943 | leaf = bp->data; |
943 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 944 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
944 | hdr = &leaf->hdr; | 945 | hdr = &leaf->hdr; |
945 | ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); | 946 | ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); |
946 | ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); | 947 | ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); |
@@ -1097,8 +1098,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1097 | ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); | 1098 | ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); |
1098 | leaf1 = blk1->bp->data; | 1099 | leaf1 = blk1->bp->data; |
1099 | leaf2 = blk2->bp->data; | 1100 | leaf2 = blk2->bp->data; |
1100 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1101 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1101 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1102 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1102 | 1103 | ||
1103 | /* | 1104 | /* |
1104 | * Check ordering of blocks, reverse if it makes things simpler. | 1105 | * Check ordering of blocks, reverse if it makes things simpler. |
@@ -1325,7 +1326,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1325 | */ | 1326 | */ |
1326 | blk = &state->path.blk[ state->path.active-1 ]; | 1327 | blk = &state->path.blk[ state->path.active-1 ]; |
1327 | info = blk->bp->data; | 1328 | info = blk->bp->data; |
1328 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1329 | ASSERT(be16_to_cpu(info->magic) == XFS_DIR_LEAF_MAGIC); |
1329 | leaf = (xfs_dir_leafblock_t *)info; | 1330 | leaf = (xfs_dir_leafblock_t *)info; |
1330 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1331 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1331 | bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + | 1332 | bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + |
@@ -1348,7 +1349,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1348 | * Make altpath point to the block we want to keep and | 1349 | * Make altpath point to the block we want to keep and |
1349 | * path point to the block we want to drop (this one). | 1350 | * path point to the block we want to drop (this one). |
1350 | */ | 1351 | */ |
1351 | forward = info->forw; | 1352 | forward = (info->forw != 0); |
1352 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1353 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1353 | error = xfs_da_path_shift(state, &state->altpath, forward, | 1354 | error = xfs_da_path_shift(state, &state->altpath, forward, |
1354 | 0, &retval); | 1355 | 0, &retval); |
@@ -1369,12 +1370,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1369 | * We prefer coalescing with the lower numbered sibling so as | 1370 | * We prefer coalescing with the lower numbered sibling so as |
1370 | * to shrink a directory over time. | 1371 | * to shrink a directory over time. |
1371 | */ | 1372 | */ |
1372 | forward = (INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT)); /* start with smaller blk num */ | 1373 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); /* start with smaller blk num */ |
1373 | for (i = 0; i < 2; forward = !forward, i++) { | 1374 | for (i = 0; i < 2; forward = !forward, i++) { |
1374 | if (forward) | 1375 | if (forward) |
1375 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 1376 | blkno = be32_to_cpu(info->forw); |
1376 | else | 1377 | else |
1377 | blkno = INT_GET(info->back, ARCH_CONVERT); | 1378 | blkno = be32_to_cpu(info->back); |
1378 | if (blkno == 0) | 1379 | if (blkno == 0) |
1379 | continue; | 1380 | continue; |
1380 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 1381 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -1389,7 +1390,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1389 | bytes = state->blocksize - (state->blocksize>>2); | 1390 | bytes = state->blocksize - (state->blocksize>>2); |
1390 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); | 1391 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); |
1391 | leaf = bp->data; | 1392 | leaf = bp->data; |
1392 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1393 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1393 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1394 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1394 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); | 1395 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); |
1395 | bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); | 1396 | bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); |
@@ -1447,7 +1448,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) | |||
1447 | xfs_mount_t *mp; | 1448 | xfs_mount_t *mp; |
1448 | 1449 | ||
1449 | leaf = bp->data; | 1450 | leaf = bp->data; |
1450 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1451 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1451 | hdr = &leaf->hdr; | 1452 | hdr = &leaf->hdr; |
1452 | mp = trans->t_mountp; | 1453 | mp = trans->t_mountp; |
1453 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1454 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); |
@@ -1599,8 +1600,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1599 | ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); | 1600 | ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); |
1600 | drop_leaf = drop_blk->bp->data; | 1601 | drop_leaf = drop_blk->bp->data; |
1601 | save_leaf = save_blk->bp->data; | 1602 | save_leaf = save_blk->bp->data; |
1602 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1603 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1603 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1604 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1604 | drop_hdr = &drop_leaf->hdr; | 1605 | drop_hdr = &drop_leaf->hdr; |
1605 | save_hdr = &save_leaf->hdr; | 1606 | save_hdr = &save_leaf->hdr; |
1606 | 1607 | ||
@@ -1695,7 +1696,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) | |||
1695 | xfs_dahash_t hashval; | 1696 | xfs_dahash_t hashval; |
1696 | 1697 | ||
1697 | leaf = bp->data; | 1698 | leaf = bp->data; |
1698 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1699 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1699 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); | 1700 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); |
1700 | 1701 | ||
1701 | /* | 1702 | /* |
@@ -1782,8 +1783,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s, | |||
1782 | /* | 1783 | /* |
1783 | * Set up environment. | 1784 | * Set up environment. |
1784 | */ | 1785 | */ |
1785 | ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1786 | ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1786 | ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1787 | ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1787 | hdr_s = &leaf_s->hdr; | 1788 | hdr_s = &leaf_s->hdr; |
1788 | hdr_d = &leaf_d->hdr; | 1789 | hdr_d = &leaf_d->hdr; |
1789 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1790 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); |
@@ -1883,8 +1884,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) | |||
1883 | 1884 | ||
1884 | leaf1 = leaf1_bp->data; | 1885 | leaf1 = leaf1_bp->data; |
1885 | leaf2 = leaf2_bp->data; | 1886 | leaf2 = leaf2_bp->data; |
1886 | ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) && | 1887 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) && |
1887 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC)); | 1888 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC)); |
1888 | if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && | 1889 | if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && |
1889 | ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < | 1890 | ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < |
1890 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || | 1891 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || |
@@ -1904,7 +1905,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
1904 | xfs_dir_leafblock_t *leaf; | 1905 | xfs_dir_leafblock_t *leaf; |
1905 | 1906 | ||
1906 | leaf = bp->data; | 1907 | leaf = bp->data; |
1907 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1908 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1908 | if (count) | 1909 | if (count) |
1909 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1910 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1910 | if (!leaf->hdr.count) | 1911 | if (!leaf->hdr.count) |
@@ -1940,7 +1941,7 @@ xfs_dir_leaf_getdents_int( | |||
1940 | 1941 | ||
1941 | mp = dp->i_mount; | 1942 | mp = dp->i_mount; |
1942 | leaf = bp->data; | 1943 | leaf = bp->data; |
1943 | if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { | 1944 | if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) { |
1944 | *eobp = 1; | 1945 | *eobp = 1; |
1945 | return XFS_ERROR(ENOENT); /* XXX wrong code */ | 1946 | return XFS_ERROR(ENOENT); /* XXX wrong code */ |
1946 | } | 1947 | } |
@@ -1992,7 +1993,7 @@ xfs_dir_leaf_getdents_int( | |||
1992 | 1993 | ||
1993 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { | 1994 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { |
1994 | xfs_dir_trace_g_du("leaf: hash not found", dp, uio); | 1995 | xfs_dir_trace_g_du("leaf: hash not found", dp, uio); |
1995 | if (!INT_GET(leaf->hdr.info.forw, ARCH_CONVERT)) | 1996 | if (!leaf->hdr.info.forw) |
1996 | uio->uio_offset = | 1997 | uio->uio_offset = |
1997 | XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); | 1998 | XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); |
1998 | /* | 1999 | /* |
@@ -2047,8 +2048,7 @@ xfs_dir_leaf_getdents_int( | |||
2047 | xfs_dir_trace_g_duc("leaf: middle cookie ", | 2048 | xfs_dir_trace_g_duc("leaf: middle cookie ", |
2048 | dp, uio, p.cook.o); | 2049 | dp, uio, p.cook.o); |
2049 | 2050 | ||
2050 | } else if ((thishash = INT_GET(leaf->hdr.info.forw, | 2051 | } else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) { |
2051 | ARCH_CONVERT))) { | ||
2052 | xfs_dabuf_t *bp2; | 2052 | xfs_dabuf_t *bp2; |
2053 | xfs_dir_leafblock_t *leaf2; | 2053 | xfs_dir_leafblock_t *leaf2; |
2054 | 2054 | ||
@@ -2064,9 +2064,9 @@ xfs_dir_leaf_getdents_int( | |||
2064 | leaf2 = bp2->data; | 2064 | leaf2 = bp2->data; |
2065 | 2065 | ||
2066 | if (unlikely( | 2066 | if (unlikely( |
2067 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2067 | (be16_to_cpu(leaf2->hdr.info.magic) |
2068 | != XFS_DIR_LEAF_MAGIC) | 2068 | != XFS_DIR_LEAF_MAGIC) |
2069 | || (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT) | 2069 | || (be32_to_cpu(leaf2->hdr.info.back) |
2070 | != bno))) { /* GROT */ | 2070 | != bno))) { /* GROT */ |
2071 | XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", | 2071 | XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", |
2072 | XFS_ERRLEVEL_LOW, mp, | 2072 | XFS_ERRLEVEL_LOW, mp, |
diff --git a/fs/xfs/xfs_dir_sf.h b/fs/xfs/xfs_dir_sf.h index fe44c6f4d560..5b20b4d3f57d 100644 --- a/fs/xfs/xfs_dir_sf.h +++ b/fs/xfs/xfs_dir_sf.h | |||
@@ -35,19 +35,21 @@ typedef struct { __uint8_t i[sizeof(xfs_ino_t)]; } xfs_dir_ino_t; | |||
35 | * and the elements much be memcpy'd out into a work area to get correct | 35 | * and the elements much be memcpy'd out into a work area to get correct |
36 | * alignment for the inode number fields. | 36 | * alignment for the inode number fields. |
37 | */ | 37 | */ |
38 | typedef struct xfs_dir_sf_hdr { /* constant-structure header block */ | ||
39 | xfs_dir_ino_t parent; /* parent dir inode number */ | ||
40 | __uint8_t count; /* count of active entries */ | ||
41 | } xfs_dir_sf_hdr_t; | ||
42 | |||
43 | typedef struct xfs_dir_sf_entry { | ||
44 | xfs_dir_ino_t inumber; /* referenced inode number */ | ||
45 | __uint8_t namelen; /* actual length of name (no NULL) */ | ||
46 | __uint8_t name[1]; /* name */ | ||
47 | } xfs_dir_sf_entry_t; | ||
48 | |||
38 | typedef struct xfs_dir_shortform { | 49 | typedef struct xfs_dir_shortform { |
39 | struct xfs_dir_sf_hdr { /* constant-structure header block */ | 50 | xfs_dir_sf_hdr_t hdr; |
40 | xfs_dir_ino_t parent; /* parent dir inode number */ | 51 | xfs_dir_sf_entry_t list[1]; /* variable sized array */ |
41 | __uint8_t count; /* count of active entries */ | ||
42 | } hdr; | ||
43 | struct xfs_dir_sf_entry { | ||
44 | xfs_dir_ino_t inumber; /* referenced inode number */ | ||
45 | __uint8_t namelen; /* actual length of name (no NULL) */ | ||
46 | __uint8_t name[1]; /* name */ | ||
47 | } list[1]; /* variable sized array */ | ||
48 | } xfs_dir_shortform_t; | 52 | } xfs_dir_shortform_t; |
49 | typedef struct xfs_dir_sf_hdr xfs_dir_sf_hdr_t; | ||
50 | typedef struct xfs_dir_sf_entry xfs_dir_sf_entry_t; | ||
51 | 53 | ||
52 | /* | 54 | /* |
53 | * We generate this then sort it, so that readdirs are returned in | 55 | * We generate this then sort it, so that readdirs are returned in |
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h index b4c7f2bc55a0..00b1540f8108 100644 --- a/fs/xfs/xfs_dmapi.h +++ b/fs/xfs/xfs_dmapi.h | |||
@@ -191,14 +191,4 @@ typedef enum { | |||
191 | 191 | ||
192 | extern struct bhv_vfsops xfs_dmops; | 192 | extern struct bhv_vfsops xfs_dmops; |
193 | 193 | ||
194 | #ifdef CONFIG_XFS_DMAPI | ||
195 | void xfs_dm_init(struct file_system_type *); | ||
196 | void xfs_dm_exit(struct file_system_type *); | ||
197 | #define XFS_DM_INIT(fstype) xfs_dm_init(fstype) | ||
198 | #define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype) | ||
199 | #else | ||
200 | #define XFS_DM_INIT(fstype) | ||
201 | #define XFS_DM_EXIT(fstype) | ||
202 | #endif | ||
203 | |||
204 | #endif /* __XFS_DMAPI_H__ */ | 194 | #endif /* __XFS_DMAPI_H__ */ |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index b4d971b01588..56caa88713ab 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -462,6 +462,7 @@ xfs_fs_counts( | |||
462 | { | 462 | { |
463 | unsigned long s; | 463 | unsigned long s; |
464 | 464 | ||
465 | xfs_icsb_sync_counters_lazy(mp); | ||
465 | s = XFS_SB_LOCK(mp); | 466 | s = XFS_SB_LOCK(mp); |
466 | cnt->freedata = mp->m_sb.sb_fdblocks; | 467 | cnt->freedata = mp->m_sb.sb_fdblocks; |
467 | cnt->freertx = mp->m_sb.sb_frextents; | 468 | cnt->freertx = mp->m_sb.sb_frextents; |
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 8f3fae1aa98a..0024892841a3 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -138,8 +138,6 @@ xfs_ialloc_ag_alloc( | |||
138 | int version; /* inode version number to use */ | 138 | int version; /* inode version number to use */ |
139 | int isaligned; /* inode allocation at stripe unit */ | 139 | int isaligned; /* inode allocation at stripe unit */ |
140 | /* boundary */ | 140 | /* boundary */ |
141 | xfs_dinode_core_t dic; /* a dinode_core to copy to new */ | ||
142 | /* inodes */ | ||
143 | 141 | ||
144 | args.tp = tp; | 142 | args.tp = tp; |
145 | args.mp = tp->t_mountp; | 143 | args.mp = tp->t_mountp; |
@@ -250,10 +248,6 @@ xfs_ialloc_ag_alloc( | |||
250 | else | 248 | else |
251 | version = XFS_DINODE_VERSION_1; | 249 | version = XFS_DINODE_VERSION_1; |
252 | 250 | ||
253 | memset(&dic, 0, sizeof(xfs_dinode_core_t)); | ||
254 | INT_SET(dic.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC); | ||
255 | INT_SET(dic.di_version, ARCH_CONVERT, version); | ||
256 | |||
257 | for (j = 0; j < nbufs; j++) { | 251 | for (j = 0; j < nbufs; j++) { |
258 | /* | 252 | /* |
259 | * Get the block. | 253 | * Get the block. |
@@ -266,12 +260,13 @@ xfs_ialloc_ag_alloc( | |||
266 | ASSERT(fbuf); | 260 | ASSERT(fbuf); |
267 | ASSERT(!XFS_BUF_GETERROR(fbuf)); | 261 | ASSERT(!XFS_BUF_GETERROR(fbuf)); |
268 | /* | 262 | /* |
269 | * Loop over the inodes in this buffer. | 263 | * Set initial values for the inodes in this buffer. |
270 | */ | 264 | */ |
271 | 265 | xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog); | |
272 | for (i = 0; i < ninodes; i++) { | 266 | for (i = 0; i < ninodes; i++) { |
273 | free = XFS_MAKE_IPTR(args.mp, fbuf, i); | 267 | free = XFS_MAKE_IPTR(args.mp, fbuf, i); |
274 | memcpy(&(free->di_core), &dic, sizeof(xfs_dinode_core_t)); | 268 | INT_SET(free->di_core.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC); |
269 | INT_SET(free->di_core.di_version, ARCH_CONVERT, version); | ||
275 | INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO); | 270 | INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO); |
276 | xfs_ialloc_log_di(tp, fbuf, i, | 271 | xfs_ialloc_log_di(tp, fbuf, i, |
277 | XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED); | 272 | XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED); |
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c index 8e380a1fb79b..3ce35a6f700b 100644 --- a/fs/xfs/xfs_iget.c +++ b/fs/xfs/xfs_iget.c | |||
@@ -258,7 +258,7 @@ again: | |||
258 | goto finish_inode; | 258 | goto finish_inode; |
259 | 259 | ||
260 | } else if (vp != inode_vp) { | 260 | } else if (vp != inode_vp) { |
261 | struct inode *inode = LINVFS_GET_IP(inode_vp); | 261 | struct inode *inode = vn_to_inode(inode_vp); |
262 | 262 | ||
263 | /* The inode is being torn down, pause and | 263 | /* The inode is being torn down, pause and |
264 | * try again. | 264 | * try again. |
@@ -495,7 +495,7 @@ retry: | |||
495 | if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) { | 495 | if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) { |
496 | xfs_inode_t *ip; | 496 | xfs_inode_t *ip; |
497 | 497 | ||
498 | vp = LINVFS_GET_VP(inode); | 498 | vp = vn_from_inode(inode); |
499 | if (inode->i_state & I_NEW) { | 499 | if (inode->i_state & I_NEW) { |
500 | vn_initialize(inode); | 500 | vn_initialize(inode); |
501 | error = xfs_iget_core(vp, mp, tp, ino, flags, | 501 | error = xfs_iget_core(vp, mp, tp, ino, flags, |
@@ -617,7 +617,7 @@ xfs_iput_new(xfs_inode_t *ip, | |||
617 | uint lock_flags) | 617 | uint lock_flags) |
618 | { | 618 | { |
619 | vnode_t *vp = XFS_ITOV(ip); | 619 | vnode_t *vp = XFS_ITOV(ip); |
620 | struct inode *inode = LINVFS_GET_IP(vp); | 620 | struct inode *inode = vn_to_inode(vp); |
621 | 621 | ||
622 | vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); | 622 | vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); |
623 | 623 | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 1d7f5a7e063e..88a517fad07b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -76,16 +76,18 @@ STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); | |||
76 | */ | 76 | */ |
77 | STATIC void | 77 | STATIC void |
78 | xfs_validate_extents( | 78 | xfs_validate_extents( |
79 | xfs_bmbt_rec_t *ep, | 79 | xfs_ifork_t *ifp, |
80 | int nrecs, | 80 | int nrecs, |
81 | int disk, | 81 | int disk, |
82 | xfs_exntfmt_t fmt) | 82 | xfs_exntfmt_t fmt) |
83 | { | 83 | { |
84 | xfs_bmbt_rec_t *ep; | ||
84 | xfs_bmbt_irec_t irec; | 85 | xfs_bmbt_irec_t irec; |
85 | xfs_bmbt_rec_t rec; | 86 | xfs_bmbt_rec_t rec; |
86 | int i; | 87 | int i; |
87 | 88 | ||
88 | for (i = 0; i < nrecs; i++) { | 89 | for (i = 0; i < nrecs; i++) { |
90 | ep = xfs_iext_get_ext(ifp, i); | ||
89 | rec.l0 = get_unaligned((__uint64_t*)&ep->l0); | 91 | rec.l0 = get_unaligned((__uint64_t*)&ep->l0); |
90 | rec.l1 = get_unaligned((__uint64_t*)&ep->l1); | 92 | rec.l1 = get_unaligned((__uint64_t*)&ep->l1); |
91 | if (disk) | 93 | if (disk) |
@@ -94,11 +96,10 @@ xfs_validate_extents( | |||
94 | xfs_bmbt_get_all(&rec, &irec); | 96 | xfs_bmbt_get_all(&rec, &irec); |
95 | if (fmt == XFS_EXTFMT_NOSTATE) | 97 | if (fmt == XFS_EXTFMT_NOSTATE) |
96 | ASSERT(irec.br_state == XFS_EXT_NORM); | 98 | ASSERT(irec.br_state == XFS_EXT_NORM); |
97 | ep++; | ||
98 | } | 99 | } |
99 | } | 100 | } |
100 | #else /* DEBUG */ | 101 | #else /* DEBUG */ |
101 | #define xfs_validate_extents(ep, nrecs, disk, fmt) | 102 | #define xfs_validate_extents(ifp, nrecs, disk, fmt) |
102 | #endif /* DEBUG */ | 103 | #endif /* DEBUG */ |
103 | 104 | ||
104 | /* | 105 | /* |
@@ -252,7 +253,8 @@ xfs_itobp( | |||
252 | xfs_inode_t *ip, | 253 | xfs_inode_t *ip, |
253 | xfs_dinode_t **dipp, | 254 | xfs_dinode_t **dipp, |
254 | xfs_buf_t **bpp, | 255 | xfs_buf_t **bpp, |
255 | xfs_daddr_t bno) | 256 | xfs_daddr_t bno, |
257 | uint imap_flags) | ||
256 | { | 258 | { |
257 | xfs_buf_t *bp; | 259 | xfs_buf_t *bp; |
258 | int error; | 260 | int error; |
@@ -268,10 +270,9 @@ xfs_itobp( | |||
268 | * inode on disk. | 270 | * inode on disk. |
269 | */ | 271 | */ |
270 | imap.im_blkno = bno; | 272 | imap.im_blkno = bno; |
271 | error = xfs_imap(mp, tp, ip->i_ino, &imap, XFS_IMAP_LOOKUP); | 273 | if ((error = xfs_imap(mp, tp, ip->i_ino, &imap, |
272 | if (error != 0) { | 274 | XFS_IMAP_LOOKUP | imap_flags))) |
273 | return error; | 275 | return error; |
274 | } | ||
275 | 276 | ||
276 | /* | 277 | /* |
277 | * If the inode number maps to a block outside the bounds | 278 | * If the inode number maps to a block outside the bounds |
@@ -335,9 +336,10 @@ xfs_itobp( | |||
335 | * (if DEBUG kernel) or the first inode in the buffer, otherwise. | 336 | * (if DEBUG kernel) or the first inode in the buffer, otherwise. |
336 | */ | 337 | */ |
337 | #ifdef DEBUG | 338 | #ifdef DEBUG |
338 | ni = BBTOB(imap.im_len) >> mp->m_sb.sb_inodelog; | 339 | ni = (imap_flags & XFS_IMAP_BULKSTAT) ? 0 : |
340 | (BBTOB(imap.im_len) >> mp->m_sb.sb_inodelog); | ||
339 | #else | 341 | #else |
340 | ni = 1; | 342 | ni = (imap_flags & XFS_IMAP_BULKSTAT) ? 0 : 1; |
341 | #endif | 343 | #endif |
342 | for (i = 0; i < ni; i++) { | 344 | for (i = 0; i < ni; i++) { |
343 | int di_ok; | 345 | int di_ok; |
@@ -504,7 +506,7 @@ xfs_iformat( | |||
504 | switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) { | 506 | switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) { |
505 | case XFS_DINODE_FMT_LOCAL: | 507 | case XFS_DINODE_FMT_LOCAL: |
506 | atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); | 508 | atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); |
507 | size = (int)INT_GET(atp->hdr.totsize, ARCH_CONVERT); | 509 | size = be16_to_cpu(atp->hdr.totsize); |
508 | error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); | 510 | error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); |
509 | break; | 511 | break; |
510 | case XFS_DINODE_FMT_EXTENTS: | 512 | case XFS_DINODE_FMT_EXTENTS: |
@@ -597,7 +599,6 @@ xfs_iformat_extents( | |||
597 | xfs_bmbt_rec_t *ep, *dp; | 599 | xfs_bmbt_rec_t *ep, *dp; |
598 | xfs_ifork_t *ifp; | 600 | xfs_ifork_t *ifp; |
599 | int nex; | 601 | int nex; |
600 | int real_size; | ||
601 | int size; | 602 | int size; |
602 | int i; | 603 | int i; |
603 | 604 | ||
@@ -619,23 +620,20 @@ xfs_iformat_extents( | |||
619 | return XFS_ERROR(EFSCORRUPTED); | 620 | return XFS_ERROR(EFSCORRUPTED); |
620 | } | 621 | } |
621 | 622 | ||
622 | real_size = 0; | 623 | ifp->if_real_bytes = 0; |
623 | if (nex == 0) | 624 | if (nex == 0) |
624 | ifp->if_u1.if_extents = NULL; | 625 | ifp->if_u1.if_extents = NULL; |
625 | else if (nex <= XFS_INLINE_EXTS) | 626 | else if (nex <= XFS_INLINE_EXTS) |
626 | ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext; | 627 | ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext; |
627 | else { | 628 | else |
628 | ifp->if_u1.if_extents = kmem_alloc(size, KM_SLEEP); | 629 | xfs_iext_add(ifp, 0, nex); |
629 | ASSERT(ifp->if_u1.if_extents != NULL); | 630 | |
630 | real_size = size; | ||
631 | } | ||
632 | ifp->if_bytes = size; | 631 | ifp->if_bytes = size; |
633 | ifp->if_real_bytes = real_size; | ||
634 | if (size) { | 632 | if (size) { |
635 | dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork); | 633 | dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork); |
636 | xfs_validate_extents(dp, nex, 1, XFS_EXTFMT_INODE(ip)); | 634 | xfs_validate_extents(ifp, nex, 1, XFS_EXTFMT_INODE(ip)); |
637 | ep = ifp->if_u1.if_extents; | 635 | for (i = 0; i < nex; i++, dp++) { |
638 | for (i = 0; i < nex; i++, ep++, dp++) { | 636 | ep = xfs_iext_get_ext(ifp, i); |
639 | ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), | 637 | ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), |
640 | ARCH_CONVERT); | 638 | ARCH_CONVERT); |
641 | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), | 639 | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), |
@@ -646,7 +644,7 @@ xfs_iformat_extents( | |||
646 | if (whichfork != XFS_DATA_FORK || | 644 | if (whichfork != XFS_DATA_FORK || |
647 | XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE) | 645 | XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE) |
648 | if (unlikely(xfs_check_nostate_extents( | 646 | if (unlikely(xfs_check_nostate_extents( |
649 | ifp->if_u1.if_extents, nex))) { | 647 | ifp, 0, nex))) { |
650 | XFS_ERROR_REPORT("xfs_iformat_extents(2)", | 648 | XFS_ERROR_REPORT("xfs_iformat_extents(2)", |
651 | XFS_ERRLEVEL_LOW, | 649 | XFS_ERRLEVEL_LOW, |
652 | ip->i_mount); | 650 | ip->i_mount); |
@@ -871,9 +869,8 @@ xfs_iread( | |||
871 | * return NULL as well. Set i_blkno to 0 so that xfs_itobp() will | 869 | * return NULL as well. Set i_blkno to 0 so that xfs_itobp() will |
872 | * know that this is a new incore inode. | 870 | * know that this is a new incore inode. |
873 | */ | 871 | */ |
874 | error = xfs_itobp(mp, tp, ip, &dip, &bp, bno); | 872 | error = xfs_itobp(mp, tp, ip, &dip, &bp, bno, 0); |
875 | 873 | if (error) { | |
876 | if (error != 0) { | ||
877 | kmem_zone_free(xfs_inode_zone, ip); | 874 | kmem_zone_free(xfs_inode_zone, ip); |
878 | return error; | 875 | return error; |
879 | } | 876 | } |
@@ -1015,6 +1012,7 @@ xfs_iread_extents( | |||
1015 | { | 1012 | { |
1016 | int error; | 1013 | int error; |
1017 | xfs_ifork_t *ifp; | 1014 | xfs_ifork_t *ifp; |
1015 | xfs_extnum_t nextents; | ||
1018 | size_t size; | 1016 | size_t size; |
1019 | 1017 | ||
1020 | if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { | 1018 | if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { |
@@ -1022,26 +1020,24 @@ xfs_iread_extents( | |||
1022 | ip->i_mount); | 1020 | ip->i_mount); |
1023 | return XFS_ERROR(EFSCORRUPTED); | 1021 | return XFS_ERROR(EFSCORRUPTED); |
1024 | } | 1022 | } |
1025 | size = XFS_IFORK_NEXTENTS(ip, whichfork) * (uint)sizeof(xfs_bmbt_rec_t); | 1023 | nextents = XFS_IFORK_NEXTENTS(ip, whichfork); |
1024 | size = nextents * sizeof(xfs_bmbt_rec_t); | ||
1026 | ifp = XFS_IFORK_PTR(ip, whichfork); | 1025 | ifp = XFS_IFORK_PTR(ip, whichfork); |
1026 | |||
1027 | /* | 1027 | /* |
1028 | * We know that the size is valid (it's checked in iformat_btree) | 1028 | * We know that the size is valid (it's checked in iformat_btree) |
1029 | */ | 1029 | */ |
1030 | ifp->if_u1.if_extents = kmem_alloc(size, KM_SLEEP); | ||
1031 | ASSERT(ifp->if_u1.if_extents != NULL); | ||
1032 | ifp->if_lastex = NULLEXTNUM; | 1030 | ifp->if_lastex = NULLEXTNUM; |
1033 | ifp->if_bytes = ifp->if_real_bytes = (int)size; | 1031 | ifp->if_bytes = ifp->if_real_bytes = 0; |
1034 | ifp->if_flags |= XFS_IFEXTENTS; | 1032 | ifp->if_flags |= XFS_IFEXTENTS; |
1033 | xfs_iext_add(ifp, 0, nextents); | ||
1035 | error = xfs_bmap_read_extents(tp, ip, whichfork); | 1034 | error = xfs_bmap_read_extents(tp, ip, whichfork); |
1036 | if (error) { | 1035 | if (error) { |
1037 | kmem_free(ifp->if_u1.if_extents, size); | 1036 | xfs_iext_destroy(ifp); |
1038 | ifp->if_u1.if_extents = NULL; | ||
1039 | ifp->if_bytes = ifp->if_real_bytes = 0; | ||
1040 | ifp->if_flags &= ~XFS_IFEXTENTS; | 1037 | ifp->if_flags &= ~XFS_IFEXTENTS; |
1041 | return error; | 1038 | return error; |
1042 | } | 1039 | } |
1043 | xfs_validate_extents((xfs_bmbt_rec_t *)ifp->if_u1.if_extents, | 1040 | xfs_validate_extents(ifp, nextents, 0, XFS_EXTFMT_INODE(ip)); |
1044 | XFS_IFORK_NEXTENTS(ip, whichfork), 0, XFS_EXTFMT_INODE(ip)); | ||
1045 | return 0; | 1041 | return 0; |
1046 | } | 1042 | } |
1047 | 1043 | ||
@@ -1376,10 +1372,10 @@ xfs_itrunc_trace( | |||
1376 | (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff), | 1372 | (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff), |
1377 | (void*)(unsigned long)(toss_finish & 0xffffffff), | 1373 | (void*)(unsigned long)(toss_finish & 0xffffffff), |
1378 | (void*)(unsigned long)current_cpu(), | 1374 | (void*)(unsigned long)current_cpu(), |
1379 | (void*)0, | 1375 | (void*)(unsigned long)current_pid(), |
1380 | (void*)0, | 1376 | (void*)NULL, |
1381 | (void*)0, | 1377 | (void*)NULL, |
1382 | (void*)0); | 1378 | (void*)NULL); |
1383 | } | 1379 | } |
1384 | #else | 1380 | #else |
1385 | #define xfs_itrunc_trace(tag, ip, flag, new_size, toss_start, toss_finish) | 1381 | #define xfs_itrunc_trace(tag, ip, flag, new_size, toss_start, toss_finish) |
@@ -1397,6 +1393,16 @@ xfs_itrunc_trace( | |||
1397 | * calling into the buffer/page cache code and we can't hold the | 1393 | * calling into the buffer/page cache code and we can't hold the |
1398 | * inode lock when we do so. | 1394 | * inode lock when we do so. |
1399 | * | 1395 | * |
1396 | * We need to wait for any direct I/Os in flight to complete before we | ||
1397 | * proceed with the truncate. This is needed to prevent the extents | ||
1398 | * being read or written by the direct I/Os from being removed while the | ||
1399 | * I/O is in flight as there is no other method of synchronising | ||
1400 | * direct I/O with the truncate operation. Also, because we hold | ||
1401 | * the IOLOCK in exclusive mode, we prevent new direct I/Os from being | ||
1402 | * started until the truncate completes and drops the lock. Essentially, | ||
1403 | * the vn_iowait() call forms an I/O barrier that provides strict ordering | ||
1404 | * between direct I/Os and the truncate operation. | ||
1405 | * | ||
1400 | * The flags parameter can have either the value XFS_ITRUNC_DEFINITE | 1406 | * The flags parameter can have either the value XFS_ITRUNC_DEFINITE |
1401 | * or XFS_ITRUNC_MAYBE. The XFS_ITRUNC_MAYBE value should be used | 1407 | * or XFS_ITRUNC_MAYBE. The XFS_ITRUNC_MAYBE value should be used |
1402 | * in the case that the caller is locking things out of order and | 1408 | * in the case that the caller is locking things out of order and |
@@ -1424,6 +1430,9 @@ xfs_itruncate_start( | |||
1424 | 1430 | ||
1425 | mp = ip->i_mount; | 1431 | mp = ip->i_mount; |
1426 | vp = XFS_ITOV(ip); | 1432 | vp = XFS_ITOV(ip); |
1433 | |||
1434 | vn_iowait(vp); /* wait for the completion of any pending DIOs */ | ||
1435 | |||
1427 | /* | 1436 | /* |
1428 | * Call VOP_TOSS_PAGES() or VOP_FLUSHINVAL_PAGES() to get rid of pages and buffers | 1437 | * Call VOP_TOSS_PAGES() or VOP_FLUSHINVAL_PAGES() to get rid of pages and buffers |
1429 | * overlapping the region being removed. We have to use | 1438 | * overlapping the region being removed. We have to use |
@@ -1899,7 +1908,7 @@ xfs_iunlink( | |||
1899 | * Here we put the head pointer into our next pointer, | 1908 | * Here we put the head pointer into our next pointer, |
1900 | * and then we fall through to point the head at us. | 1909 | * and then we fall through to point the head at us. |
1901 | */ | 1910 | */ |
1902 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); | 1911 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0); |
1903 | if (error) { | 1912 | if (error) { |
1904 | return error; | 1913 | return error; |
1905 | } | 1914 | } |
@@ -2008,7 +2017,7 @@ xfs_iunlink_remove( | |||
2008 | * of dealing with the buffer when there is no need to | 2017 | * of dealing with the buffer when there is no need to |
2009 | * change it. | 2018 | * change it. |
2010 | */ | 2019 | */ |
2011 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); | 2020 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0); |
2012 | if (error) { | 2021 | if (error) { |
2013 | cmn_err(CE_WARN, | 2022 | cmn_err(CE_WARN, |
2014 | "xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.", | 2023 | "xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.", |
@@ -2070,7 +2079,7 @@ xfs_iunlink_remove( | |||
2070 | * Now last_ibp points to the buffer previous to us on | 2079 | * Now last_ibp points to the buffer previous to us on |
2071 | * the unlinked list. Pull us from the list. | 2080 | * the unlinked list. Pull us from the list. |
2072 | */ | 2081 | */ |
2073 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); | 2082 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0); |
2074 | if (error) { | 2083 | if (error) { |
2075 | cmn_err(CE_WARN, | 2084 | cmn_err(CE_WARN, |
2076 | "xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.", | 2085 | "xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.", |
@@ -2476,92 +2485,6 @@ xfs_iroot_realloc( | |||
2476 | 2485 | ||
2477 | 2486 | ||
2478 | /* | 2487 | /* |
2479 | * This is called when the amount of space needed for if_extents | ||
2480 | * is increased or decreased. The change in size is indicated by | ||
2481 | * the number of extents that need to be added or deleted in the | ||
2482 | * ext_diff parameter. | ||
2483 | * | ||
2484 | * If the amount of space needed has decreased below the size of the | ||
2485 | * inline buffer, then switch to using the inline buffer. Otherwise, | ||
2486 | * use kmem_realloc() or kmem_alloc() to adjust the size of the buffer | ||
2487 | * to what is needed. | ||
2488 | * | ||
2489 | * ip -- the inode whose if_extents area is changing | ||
2490 | * ext_diff -- the change in the number of extents, positive or negative, | ||
2491 | * requested for the if_extents array. | ||
2492 | */ | ||
2493 | void | ||
2494 | xfs_iext_realloc( | ||
2495 | xfs_inode_t *ip, | ||
2496 | int ext_diff, | ||
2497 | int whichfork) | ||
2498 | { | ||
2499 | int byte_diff; | ||
2500 | xfs_ifork_t *ifp; | ||
2501 | int new_size; | ||
2502 | uint rnew_size; | ||
2503 | |||
2504 | if (ext_diff == 0) { | ||
2505 | return; | ||
2506 | } | ||
2507 | |||
2508 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
2509 | byte_diff = ext_diff * (uint)sizeof(xfs_bmbt_rec_t); | ||
2510 | new_size = (int)ifp->if_bytes + byte_diff; | ||
2511 | ASSERT(new_size >= 0); | ||
2512 | |||
2513 | if (new_size == 0) { | ||
2514 | if (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext) { | ||
2515 | ASSERT(ifp->if_real_bytes != 0); | ||
2516 | kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes); | ||
2517 | } | ||
2518 | ifp->if_u1.if_extents = NULL; | ||
2519 | rnew_size = 0; | ||
2520 | } else if (new_size <= sizeof(ifp->if_u2.if_inline_ext)) { | ||
2521 | /* | ||
2522 | * If the valid extents can fit in if_inline_ext, | ||
2523 | * copy them from the malloc'd vector and free it. | ||
2524 | */ | ||
2525 | if (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext) { | ||
2526 | /* | ||
2527 | * For now, empty files are format EXTENTS, | ||
2528 | * so the if_extents pointer is null. | ||
2529 | */ | ||
2530 | if (ifp->if_u1.if_extents) { | ||
2531 | memcpy(ifp->if_u2.if_inline_ext, | ||
2532 | ifp->if_u1.if_extents, new_size); | ||
2533 | kmem_free(ifp->if_u1.if_extents, | ||
2534 | ifp->if_real_bytes); | ||
2535 | } | ||
2536 | ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext; | ||
2537 | } | ||
2538 | rnew_size = 0; | ||
2539 | } else { | ||
2540 | rnew_size = new_size; | ||
2541 | if ((rnew_size & (rnew_size - 1)) != 0) | ||
2542 | rnew_size = xfs_iroundup(rnew_size); | ||
2543 | /* | ||
2544 | * Stuck with malloc/realloc. | ||
2545 | */ | ||
2546 | if (ifp->if_u1.if_extents == ifp->if_u2.if_inline_ext) { | ||
2547 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ||
2548 | kmem_alloc(rnew_size, KM_SLEEP); | ||
2549 | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, | ||
2550 | sizeof(ifp->if_u2.if_inline_ext)); | ||
2551 | } else if (rnew_size != ifp->if_real_bytes) { | ||
2552 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ||
2553 | kmem_realloc(ifp->if_u1.if_extents, | ||
2554 | rnew_size, | ||
2555 | ifp->if_real_bytes, | ||
2556 | KM_NOFS); | ||
2557 | } | ||
2558 | } | ||
2559 | ifp->if_real_bytes = rnew_size; | ||
2560 | ifp->if_bytes = new_size; | ||
2561 | } | ||
2562 | |||
2563 | |||
2564 | /* | ||
2565 | * This is called when the amount of space needed for if_data | 2488 | * This is called when the amount of space needed for if_data |
2566 | * is increased or decreased. The change in size is indicated by | 2489 | * is increased or decreased. The change in size is indicated by |
2567 | * the number of bytes that need to be added or deleted in the | 2490 | * the number of bytes that need to be added or deleted in the |
@@ -2720,12 +2643,11 @@ xfs_idestroy_fork( | |||
2720 | ifp->if_real_bytes = 0; | 2643 | ifp->if_real_bytes = 0; |
2721 | } | 2644 | } |
2722 | } else if ((ifp->if_flags & XFS_IFEXTENTS) && | 2645 | } else if ((ifp->if_flags & XFS_IFEXTENTS) && |
2723 | (ifp->if_u1.if_extents != NULL) && | 2646 | ((ifp->if_flags & XFS_IFEXTIREC) || |
2724 | (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext)) { | 2647 | ((ifp->if_u1.if_extents != NULL) && |
2648 | (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext)))) { | ||
2725 | ASSERT(ifp->if_real_bytes != 0); | 2649 | ASSERT(ifp->if_real_bytes != 0); |
2726 | kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes); | 2650 | xfs_iext_destroy(ifp); |
2727 | ifp->if_u1.if_extents = NULL; | ||
2728 | ifp->if_real_bytes = 0; | ||
2729 | } | 2651 | } |
2730 | ASSERT(ifp->if_u1.if_extents == NULL || | 2652 | ASSERT(ifp->if_u1.if_extents == NULL || |
2731 | ifp->if_u1.if_extents == ifp->if_u2.if_inline_ext); | 2653 | ifp->if_u1.if_extents == ifp->if_u2.if_inline_ext); |
@@ -2814,7 +2736,7 @@ xfs_iunpin( | |||
2814 | 2736 | ||
2815 | /* make sync come back and flush this inode */ | 2737 | /* make sync come back and flush this inode */ |
2816 | if (vp) { | 2738 | if (vp) { |
2817 | struct inode *inode = LINVFS_GET_IP(vp); | 2739 | struct inode *inode = vn_to_inode(vp); |
2818 | 2740 | ||
2819 | if (!(inode->i_state & I_NEW)) | 2741 | if (!(inode->i_state & I_NEW)) |
2820 | mark_inode_dirty_sync(inode); | 2742 | mark_inode_dirty_sync(inode); |
@@ -2902,16 +2824,15 @@ xfs_iextents_copy( | |||
2902 | * the delayed ones. There must be at least one | 2824 | * the delayed ones. There must be at least one |
2903 | * non-delayed extent. | 2825 | * non-delayed extent. |
2904 | */ | 2826 | */ |
2905 | ep = ifp->if_u1.if_extents; | ||
2906 | dest_ep = buffer; | 2827 | dest_ep = buffer; |
2907 | copied = 0; | 2828 | copied = 0; |
2908 | for (i = 0; i < nrecs; i++) { | 2829 | for (i = 0; i < nrecs; i++) { |
2830 | ep = xfs_iext_get_ext(ifp, i); | ||
2909 | start_block = xfs_bmbt_get_startblock(ep); | 2831 | start_block = xfs_bmbt_get_startblock(ep); |
2910 | if (ISNULLSTARTBLOCK(start_block)) { | 2832 | if (ISNULLSTARTBLOCK(start_block)) { |
2911 | /* | 2833 | /* |
2912 | * It's a delayed allocation extent, so skip it. | 2834 | * It's a delayed allocation extent, so skip it. |
2913 | */ | 2835 | */ |
2914 | ep++; | ||
2915 | continue; | 2836 | continue; |
2916 | } | 2837 | } |
2917 | 2838 | ||
@@ -2921,11 +2842,10 @@ xfs_iextents_copy( | |||
2921 | put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), | 2842 | put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), |
2922 | (__uint64_t*)&dest_ep->l1); | 2843 | (__uint64_t*)&dest_ep->l1); |
2923 | dest_ep++; | 2844 | dest_ep++; |
2924 | ep++; | ||
2925 | copied++; | 2845 | copied++; |
2926 | } | 2846 | } |
2927 | ASSERT(copied != 0); | 2847 | ASSERT(copied != 0); |
2928 | xfs_validate_extents(buffer, copied, 1, XFS_EXTFMT_INODE(ip)); | 2848 | xfs_validate_extents(ifp, copied, 1, XFS_EXTFMT_INODE(ip)); |
2929 | 2849 | ||
2930 | return (copied * (uint)sizeof(xfs_bmbt_rec_t)); | 2850 | return (copied * (uint)sizeof(xfs_bmbt_rec_t)); |
2931 | } | 2851 | } |
@@ -2995,8 +2915,10 @@ xfs_iflush_fork( | |||
2995 | case XFS_DINODE_FMT_EXTENTS: | 2915 | case XFS_DINODE_FMT_EXTENTS: |
2996 | ASSERT((ifp->if_flags & XFS_IFEXTENTS) || | 2916 | ASSERT((ifp->if_flags & XFS_IFEXTENTS) || |
2997 | !(iip->ili_format.ilf_fields & extflag[whichfork])); | 2917 | !(iip->ili_format.ilf_fields & extflag[whichfork])); |
2998 | ASSERT((ifp->if_u1.if_extents != NULL) || (ifp->if_bytes == 0)); | 2918 | ASSERT((xfs_iext_get_ext(ifp, 0) != NULL) || |
2999 | ASSERT((ifp->if_u1.if_extents == NULL) || (ifp->if_bytes > 0)); | 2919 | (ifp->if_bytes == 0)); |
2920 | ASSERT((xfs_iext_get_ext(ifp, 0) == NULL) || | ||
2921 | (ifp->if_bytes > 0)); | ||
3000 | if ((iip->ili_format.ilf_fields & extflag[whichfork]) && | 2922 | if ((iip->ili_format.ilf_fields & extflag[whichfork]) && |
3001 | (ifp->if_bytes > 0)) { | 2923 | (ifp->if_bytes > 0)) { |
3002 | ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) > 0); | 2924 | ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) > 0); |
@@ -3114,8 +3036,8 @@ xfs_iflush( | |||
3114 | /* | 3036 | /* |
3115 | * Get the buffer containing the on-disk inode. | 3037 | * Get the buffer containing the on-disk inode. |
3116 | */ | 3038 | */ |
3117 | error = xfs_itobp(mp, NULL, ip, &dip, &bp, 0); | 3039 | error = xfs_itobp(mp, NULL, ip, &dip, &bp, 0, 0); |
3118 | if (error != 0) { | 3040 | if (error) { |
3119 | xfs_ifunlock(ip); | 3041 | xfs_ifunlock(ip); |
3120 | return error; | 3042 | return error; |
3121 | } | 3043 | } |
@@ -3610,7 +3532,7 @@ xfs_iaccess( | |||
3610 | { | 3532 | { |
3611 | int error; | 3533 | int error; |
3612 | mode_t orgmode = mode; | 3534 | mode_t orgmode = mode; |
3613 | struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); | 3535 | struct inode *inode = vn_to_inode(XFS_ITOV(ip)); |
3614 | 3536 | ||
3615 | if (mode & S_IWUSR) { | 3537 | if (mode & S_IWUSR) { |
3616 | umode_t imode = inode->i_mode; | 3538 | umode_t imode = inode->i_mode; |
@@ -3704,3 +3626,1100 @@ xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra) | |||
3704 | NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); | 3626 | NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); |
3705 | } | 3627 | } |
3706 | #endif | 3628 | #endif |
3629 | |||
3630 | /* | ||
3631 | * Return a pointer to the extent record at file index idx. | ||
3632 | */ | ||
3633 | xfs_bmbt_rec_t * | ||
3634 | xfs_iext_get_ext( | ||
3635 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3636 | xfs_extnum_t idx) /* index of target extent */ | ||
3637 | { | ||
3638 | ASSERT(idx >= 0); | ||
3639 | if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) { | ||
3640 | return ifp->if_u1.if_ext_irec->er_extbuf; | ||
3641 | } else if (ifp->if_flags & XFS_IFEXTIREC) { | ||
3642 | xfs_ext_irec_t *erp; /* irec pointer */ | ||
3643 | int erp_idx = 0; /* irec index */ | ||
3644 | xfs_extnum_t page_idx = idx; /* ext index in target list */ | ||
3645 | |||
3646 | erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0); | ||
3647 | return &erp->er_extbuf[page_idx]; | ||
3648 | } else if (ifp->if_bytes) { | ||
3649 | return &ifp->if_u1.if_extents[idx]; | ||
3650 | } else { | ||
3651 | return NULL; | ||
3652 | } | ||
3653 | } | ||
3654 | |||
3655 | /* | ||
3656 | * Insert new item(s) into the extent records for incore inode | ||
3657 | * fork 'ifp'. 'count' new items are inserted at index 'idx'. | ||
3658 | */ | ||
3659 | void | ||
3660 | xfs_iext_insert( | ||
3661 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3662 | xfs_extnum_t idx, /* starting index of new items */ | ||
3663 | xfs_extnum_t count, /* number of inserted items */ | ||
3664 | xfs_bmbt_irec_t *new) /* items to insert */ | ||
3665 | { | ||
3666 | xfs_bmbt_rec_t *ep; /* extent record pointer */ | ||
3667 | xfs_extnum_t i; /* extent record index */ | ||
3668 | |||
3669 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | ||
3670 | xfs_iext_add(ifp, idx, count); | ||
3671 | for (i = idx; i < idx + count; i++, new++) { | ||
3672 | ep = xfs_iext_get_ext(ifp, i); | ||
3673 | xfs_bmbt_set_all(ep, new); | ||
3674 | } | ||
3675 | } | ||
3676 | |||
3677 | /* | ||
3678 | * This is called when the amount of space required for incore file | ||
3679 | * extents needs to be increased. The ext_diff parameter stores the | ||
3680 | * number of new extents being added and the idx parameter contains | ||
3681 | * the extent index where the new extents will be added. If the new | ||
3682 | * extents are being appended, then we just need to (re)allocate and | ||
3683 | * initialize the space. Otherwise, if the new extents are being | ||
3684 | * inserted into the middle of the existing entries, a bit more work | ||
3685 | * is required to make room for the new extents to be inserted. The | ||
3686 | * caller is responsible for filling in the new extent entries upon | ||
3687 | * return. | ||
3688 | */ | ||
3689 | void | ||
3690 | xfs_iext_add( | ||
3691 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3692 | xfs_extnum_t idx, /* index to begin adding exts */ | ||
3693 | int ext_diff) /* nubmer of extents to add */ | ||
3694 | { | ||
3695 | int byte_diff; /* new bytes being added */ | ||
3696 | int new_size; /* size of extents after adding */ | ||
3697 | xfs_extnum_t nextents; /* number of extents in file */ | ||
3698 | |||
3699 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
3700 | ASSERT((idx >= 0) && (idx <= nextents)); | ||
3701 | byte_diff = ext_diff * sizeof(xfs_bmbt_rec_t); | ||
3702 | new_size = ifp->if_bytes + byte_diff; | ||
3703 | /* | ||
3704 | * If the new number of extents (nextents + ext_diff) | ||
3705 | * fits inside the inode, then continue to use the inline | ||
3706 | * extent buffer. | ||
3707 | */ | ||
3708 | if (nextents + ext_diff <= XFS_INLINE_EXTS) { | ||
3709 | if (idx < nextents) { | ||
3710 | memmove(&ifp->if_u2.if_inline_ext[idx + ext_diff], | ||
3711 | &ifp->if_u2.if_inline_ext[idx], | ||
3712 | (nextents - idx) * sizeof(xfs_bmbt_rec_t)); | ||
3713 | memset(&ifp->if_u2.if_inline_ext[idx], 0, byte_diff); | ||
3714 | } | ||
3715 | ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext; | ||
3716 | ifp->if_real_bytes = 0; | ||
3717 | ifp->if_lastex = nextents + ext_diff; | ||
3718 | } | ||
3719 | /* | ||
3720 | * Otherwise use a linear (direct) extent list. | ||
3721 | * If the extents are currently inside the inode, | ||
3722 | * xfs_iext_realloc_direct will switch us from | ||
3723 | * inline to direct extent allocation mode. | ||
3724 | */ | ||
3725 | else if (nextents + ext_diff <= XFS_LINEAR_EXTS) { | ||
3726 | xfs_iext_realloc_direct(ifp, new_size); | ||
3727 | if (idx < nextents) { | ||
3728 | memmove(&ifp->if_u1.if_extents[idx + ext_diff], | ||
3729 | &ifp->if_u1.if_extents[idx], | ||
3730 | (nextents - idx) * sizeof(xfs_bmbt_rec_t)); | ||
3731 | memset(&ifp->if_u1.if_extents[idx], 0, byte_diff); | ||
3732 | } | ||
3733 | } | ||
3734 | /* Indirection array */ | ||
3735 | else { | ||
3736 | xfs_ext_irec_t *erp; | ||
3737 | int erp_idx = 0; | ||
3738 | int page_idx = idx; | ||
3739 | |||
3740 | ASSERT(nextents + ext_diff > XFS_LINEAR_EXTS); | ||
3741 | if (ifp->if_flags & XFS_IFEXTIREC) { | ||
3742 | erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 1); | ||
3743 | } else { | ||
3744 | xfs_iext_irec_init(ifp); | ||
3745 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
3746 | erp = ifp->if_u1.if_ext_irec; | ||
3747 | } | ||
3748 | /* Extents fit in target extent page */ | ||
3749 | if (erp && erp->er_extcount + ext_diff <= XFS_LINEAR_EXTS) { | ||
3750 | if (page_idx < erp->er_extcount) { | ||
3751 | memmove(&erp->er_extbuf[page_idx + ext_diff], | ||
3752 | &erp->er_extbuf[page_idx], | ||
3753 | (erp->er_extcount - page_idx) * | ||
3754 | sizeof(xfs_bmbt_rec_t)); | ||
3755 | memset(&erp->er_extbuf[page_idx], 0, byte_diff); | ||
3756 | } | ||
3757 | erp->er_extcount += ext_diff; | ||
3758 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, ext_diff); | ||
3759 | } | ||
3760 | /* Insert a new extent page */ | ||
3761 | else if (erp) { | ||
3762 | xfs_iext_add_indirect_multi(ifp, | ||
3763 | erp_idx, page_idx, ext_diff); | ||
3764 | } | ||
3765 | /* | ||
3766 | * If extent(s) are being appended to the last page in | ||
3767 | * the indirection array and the new extent(s) don't fit | ||
3768 | * in the page, then erp is NULL and erp_idx is set to | ||
3769 | * the next index needed in the indirection array. | ||
3770 | */ | ||
3771 | else { | ||
3772 | int count = ext_diff; | ||
3773 | |||
3774 | while (count) { | ||
3775 | erp = xfs_iext_irec_new(ifp, erp_idx); | ||
3776 | erp->er_extcount = count; | ||
3777 | count -= MIN(count, (int)XFS_LINEAR_EXTS); | ||
3778 | if (count) { | ||
3779 | erp_idx++; | ||
3780 | } | ||
3781 | } | ||
3782 | } | ||
3783 | } | ||
3784 | ifp->if_bytes = new_size; | ||
3785 | } | ||
3786 | |||
3787 | /* | ||
3788 | * This is called when incore extents are being added to the indirection | ||
3789 | * array and the new extents do not fit in the target extent list. The | ||
3790 | * erp_idx parameter contains the irec index for the target extent list | ||
3791 | * in the indirection array, and the idx parameter contains the extent | ||
3792 | * index within the list. The number of extents being added is stored | ||
3793 | * in the count parameter. | ||
3794 | * | ||
3795 | * |-------| |-------| | ||
3796 | * | | | | idx - number of extents before idx | ||
3797 | * | idx | | count | | ||
3798 | * | | | | count - number of extents being inserted at idx | ||
3799 | * |-------| |-------| | ||
3800 | * | count | | nex2 | nex2 - number of extents after idx + count | ||
3801 | * |-------| |-------| | ||
3802 | */ | ||
3803 | void | ||
3804 | xfs_iext_add_indirect_multi( | ||
3805 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3806 | int erp_idx, /* target extent irec index */ | ||
3807 | xfs_extnum_t idx, /* index within target list */ | ||
3808 | int count) /* new extents being added */ | ||
3809 | { | ||
3810 | int byte_diff; /* new bytes being added */ | ||
3811 | xfs_ext_irec_t *erp; /* pointer to irec entry */ | ||
3812 | xfs_extnum_t ext_diff; /* number of extents to add */ | ||
3813 | xfs_extnum_t ext_cnt; /* new extents still needed */ | ||
3814 | xfs_extnum_t nex2; /* extents after idx + count */ | ||
3815 | xfs_bmbt_rec_t *nex2_ep = NULL; /* temp list for nex2 extents */ | ||
3816 | int nlists; /* number of irec's (lists) */ | ||
3817 | |||
3818 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
3819 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
3820 | nex2 = erp->er_extcount - idx; | ||
3821 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
3822 | |||
3823 | /* | ||
3824 | * Save second part of target extent list | ||
3825 | * (all extents past */ | ||
3826 | if (nex2) { | ||
3827 | byte_diff = nex2 * sizeof(xfs_bmbt_rec_t); | ||
3828 | nex2_ep = (xfs_bmbt_rec_t *) kmem_alloc(byte_diff, KM_SLEEP); | ||
3829 | memmove(nex2_ep, &erp->er_extbuf[idx], byte_diff); | ||
3830 | erp->er_extcount -= nex2; | ||
3831 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, -nex2); | ||
3832 | memset(&erp->er_extbuf[idx], 0, byte_diff); | ||
3833 | } | ||
3834 | |||
3835 | /* | ||
3836 | * Add the new extents to the end of the target | ||
3837 | * list, then allocate new irec record(s) and | ||
3838 | * extent buffer(s) as needed to store the rest | ||
3839 | * of the new extents. | ||
3840 | */ | ||
3841 | ext_cnt = count; | ||
3842 | ext_diff = MIN(ext_cnt, (int)XFS_LINEAR_EXTS - erp->er_extcount); | ||
3843 | if (ext_diff) { | ||
3844 | erp->er_extcount += ext_diff; | ||
3845 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, ext_diff); | ||
3846 | ext_cnt -= ext_diff; | ||
3847 | } | ||
3848 | while (ext_cnt) { | ||
3849 | erp_idx++; | ||
3850 | erp = xfs_iext_irec_new(ifp, erp_idx); | ||
3851 | ext_diff = MIN(ext_cnt, (int)XFS_LINEAR_EXTS); | ||
3852 | erp->er_extcount = ext_diff; | ||
3853 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, ext_diff); | ||
3854 | ext_cnt -= ext_diff; | ||
3855 | } | ||
3856 | |||
3857 | /* Add nex2 extents back to indirection array */ | ||
3858 | if (nex2) { | ||
3859 | xfs_extnum_t ext_avail; | ||
3860 | int i; | ||
3861 | |||
3862 | byte_diff = nex2 * sizeof(xfs_bmbt_rec_t); | ||
3863 | ext_avail = XFS_LINEAR_EXTS - erp->er_extcount; | ||
3864 | i = 0; | ||
3865 | /* | ||
3866 | * If nex2 extents fit in the current page, append | ||
3867 | * nex2_ep after the new extents. | ||
3868 | */ | ||
3869 | if (nex2 <= ext_avail) { | ||
3870 | i = erp->er_extcount; | ||
3871 | } | ||
3872 | /* | ||
3873 | * Otherwise, check if space is available in the | ||
3874 | * next page. | ||
3875 | */ | ||
3876 | else if ((erp_idx < nlists - 1) && | ||
3877 | (nex2 <= (ext_avail = XFS_LINEAR_EXTS - | ||
3878 | ifp->if_u1.if_ext_irec[erp_idx+1].er_extcount))) { | ||
3879 | erp_idx++; | ||
3880 | erp++; | ||
3881 | /* Create a hole for nex2 extents */ | ||
3882 | memmove(&erp->er_extbuf[nex2], erp->er_extbuf, | ||
3883 | erp->er_extcount * sizeof(xfs_bmbt_rec_t)); | ||
3884 | } | ||
3885 | /* | ||
3886 | * Final choice, create a new extent page for | ||
3887 | * nex2 extents. | ||
3888 | */ | ||
3889 | else { | ||
3890 | erp_idx++; | ||
3891 | erp = xfs_iext_irec_new(ifp, erp_idx); | ||
3892 | } | ||
3893 | memmove(&erp->er_extbuf[i], nex2_ep, byte_diff); | ||
3894 | kmem_free(nex2_ep, byte_diff); | ||
3895 | erp->er_extcount += nex2; | ||
3896 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, nex2); | ||
3897 | } | ||
3898 | } | ||
3899 | |||
3900 | /* | ||
3901 | * This is called when the amount of space required for incore file | ||
3902 | * extents needs to be decreased. The ext_diff parameter stores the | ||
3903 | * number of extents to be removed and the idx parameter contains | ||
3904 | * the extent index where the extents will be removed from. | ||
3905 | * | ||
3906 | * If the amount of space needed has decreased below the linear | ||
3907 | * limit, XFS_IEXT_BUFSZ, then switch to using the contiguous | ||
3908 | * extent array. Otherwise, use kmem_realloc() to adjust the | ||
3909 | * size to what is needed. | ||
3910 | */ | ||
3911 | void | ||
3912 | xfs_iext_remove( | ||
3913 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3914 | xfs_extnum_t idx, /* index to begin removing exts */ | ||
3915 | int ext_diff) /* number of extents to remove */ | ||
3916 | { | ||
3917 | xfs_extnum_t nextents; /* number of extents in file */ | ||
3918 | int new_size; /* size of extents after removal */ | ||
3919 | |||
3920 | ASSERT(ext_diff > 0); | ||
3921 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
3922 | new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t); | ||
3923 | |||
3924 | if (new_size == 0) { | ||
3925 | xfs_iext_destroy(ifp); | ||
3926 | } else if (ifp->if_flags & XFS_IFEXTIREC) { | ||
3927 | xfs_iext_remove_indirect(ifp, idx, ext_diff); | ||
3928 | } else if (ifp->if_real_bytes) { | ||
3929 | xfs_iext_remove_direct(ifp, idx, ext_diff); | ||
3930 | } else { | ||
3931 | xfs_iext_remove_inline(ifp, idx, ext_diff); | ||
3932 | } | ||
3933 | ifp->if_bytes = new_size; | ||
3934 | } | ||
3935 | |||
3936 | /* | ||
3937 | * This removes ext_diff extents from the inline buffer, beginning | ||
3938 | * at extent index idx. | ||
3939 | */ | ||
3940 | void | ||
3941 | xfs_iext_remove_inline( | ||
3942 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3943 | xfs_extnum_t idx, /* index to begin removing exts */ | ||
3944 | int ext_diff) /* number of extents to remove */ | ||
3945 | { | ||
3946 | int nextents; /* number of extents in file */ | ||
3947 | |||
3948 | ASSERT(!(ifp->if_flags & XFS_IFEXTIREC)); | ||
3949 | ASSERT(idx < XFS_INLINE_EXTS); | ||
3950 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
3951 | ASSERT(((nextents - ext_diff) > 0) && | ||
3952 | (nextents - ext_diff) < XFS_INLINE_EXTS); | ||
3953 | |||
3954 | if (idx + ext_diff < nextents) { | ||
3955 | memmove(&ifp->if_u2.if_inline_ext[idx], | ||
3956 | &ifp->if_u2.if_inline_ext[idx + ext_diff], | ||
3957 | (nextents - (idx + ext_diff)) * | ||
3958 | sizeof(xfs_bmbt_rec_t)); | ||
3959 | memset(&ifp->if_u2.if_inline_ext[nextents - ext_diff], | ||
3960 | 0, ext_diff * sizeof(xfs_bmbt_rec_t)); | ||
3961 | } else { | ||
3962 | memset(&ifp->if_u2.if_inline_ext[idx], 0, | ||
3963 | ext_diff * sizeof(xfs_bmbt_rec_t)); | ||
3964 | } | ||
3965 | } | ||
3966 | |||
3967 | /* | ||
3968 | * This removes ext_diff extents from a linear (direct) extent list, | ||
3969 | * beginning at extent index idx. If the extents are being removed | ||
3970 | * from the end of the list (ie. truncate) then we just need to re- | ||
3971 | * allocate the list to remove the extra space. Otherwise, if the | ||
3972 | * extents are being removed from the middle of the existing extent | ||
3973 | * entries, then we first need to move the extent records beginning | ||
3974 | * at idx + ext_diff up in the list to overwrite the records being | ||
3975 | * removed, then remove the extra space via kmem_realloc. | ||
3976 | */ | ||
3977 | void | ||
3978 | xfs_iext_remove_direct( | ||
3979 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
3980 | xfs_extnum_t idx, /* index to begin removing exts */ | ||
3981 | int ext_diff) /* number of extents to remove */ | ||
3982 | { | ||
3983 | xfs_extnum_t nextents; /* number of extents in file */ | ||
3984 | int new_size; /* size of extents after removal */ | ||
3985 | |||
3986 | ASSERT(!(ifp->if_flags & XFS_IFEXTIREC)); | ||
3987 | new_size = ifp->if_bytes - | ||
3988 | (ext_diff * sizeof(xfs_bmbt_rec_t)); | ||
3989 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
3990 | |||
3991 | if (new_size == 0) { | ||
3992 | xfs_iext_destroy(ifp); | ||
3993 | return; | ||
3994 | } | ||
3995 | /* Move extents up in the list (if needed) */ | ||
3996 | if (idx + ext_diff < nextents) { | ||
3997 | memmove(&ifp->if_u1.if_extents[idx], | ||
3998 | &ifp->if_u1.if_extents[idx + ext_diff], | ||
3999 | (nextents - (idx + ext_diff)) * | ||
4000 | sizeof(xfs_bmbt_rec_t)); | ||
4001 | } | ||
4002 | memset(&ifp->if_u1.if_extents[nextents - ext_diff], | ||
4003 | 0, ext_diff * sizeof(xfs_bmbt_rec_t)); | ||
4004 | /* | ||
4005 | * Reallocate the direct extent list. If the extents | ||
4006 | * will fit inside the inode then xfs_iext_realloc_direct | ||
4007 | * will switch from direct to inline extent allocation | ||
4008 | * mode for us. | ||
4009 | */ | ||
4010 | xfs_iext_realloc_direct(ifp, new_size); | ||
4011 | ifp->if_bytes = new_size; | ||
4012 | } | ||
4013 | |||
4014 | /* | ||
4015 | * This is called when incore extents are being removed from the | ||
4016 | * indirection array and the extents being removed span multiple extent | ||
4017 | * buffers. The idx parameter contains the file extent index where we | ||
4018 | * want to begin removing extents, and the count parameter contains | ||
4019 | * how many extents need to be removed. | ||
4020 | * | ||
4021 | * |-------| |-------| | ||
4022 | * | nex1 | | | nex1 - number of extents before idx | ||
4023 | * |-------| | count | | ||
4024 | * | | | | count - number of extents being removed at idx | ||
4025 | * | count | |-------| | ||
4026 | * | | | nex2 | nex2 - number of extents after idx + count | ||
4027 | * |-------| |-------| | ||
4028 | */ | ||
4029 | void | ||
4030 | xfs_iext_remove_indirect( | ||
4031 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4032 | xfs_extnum_t idx, /* index to begin removing extents */ | ||
4033 | int count) /* number of extents to remove */ | ||
4034 | { | ||
4035 | xfs_ext_irec_t *erp; /* indirection array pointer */ | ||
4036 | int erp_idx = 0; /* indirection array index */ | ||
4037 | xfs_extnum_t ext_cnt; /* extents left to remove */ | ||
4038 | xfs_extnum_t ext_diff; /* extents to remove in current list */ | ||
4039 | xfs_extnum_t nex1; /* number of extents before idx */ | ||
4040 | xfs_extnum_t nex2; /* extents after idx + count */ | ||
4041 | int nlists; /* entries in indirecton array */ | ||
4042 | int page_idx = idx; /* index in target extent list */ | ||
4043 | |||
4044 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4045 | erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0); | ||
4046 | ASSERT(erp != NULL); | ||
4047 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4048 | nex1 = page_idx; | ||
4049 | ext_cnt = count; | ||
4050 | while (ext_cnt) { | ||
4051 | nex2 = MAX((erp->er_extcount - (nex1 + ext_cnt)), 0); | ||
4052 | ext_diff = MIN(ext_cnt, (erp->er_extcount - nex1)); | ||
4053 | /* | ||
4054 | * Check for deletion of entire list; | ||
4055 | * xfs_iext_irec_remove() updates extent offsets. | ||
4056 | */ | ||
4057 | if (ext_diff == erp->er_extcount) { | ||
4058 | xfs_iext_irec_remove(ifp, erp_idx); | ||
4059 | ext_cnt -= ext_diff; | ||
4060 | nex1 = 0; | ||
4061 | if (ext_cnt) { | ||
4062 | ASSERT(erp_idx < ifp->if_real_bytes / | ||
4063 | XFS_IEXT_BUFSZ); | ||
4064 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4065 | nex1 = 0; | ||
4066 | continue; | ||
4067 | } else { | ||
4068 | break; | ||
4069 | } | ||
4070 | } | ||
4071 | /* Move extents up (if needed) */ | ||
4072 | if (nex2) { | ||
4073 | memmove(&erp->er_extbuf[nex1], | ||
4074 | &erp->er_extbuf[nex1 + ext_diff], | ||
4075 | nex2 * sizeof(xfs_bmbt_rec_t)); | ||
4076 | } | ||
4077 | /* Zero out rest of page */ | ||
4078 | memset(&erp->er_extbuf[nex1 + nex2], 0, (XFS_IEXT_BUFSZ - | ||
4079 | ((nex1 + nex2) * sizeof(xfs_bmbt_rec_t)))); | ||
4080 | /* Update remaining counters */ | ||
4081 | erp->er_extcount -= ext_diff; | ||
4082 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, -ext_diff); | ||
4083 | ext_cnt -= ext_diff; | ||
4084 | nex1 = 0; | ||
4085 | erp_idx++; | ||
4086 | erp++; | ||
4087 | } | ||
4088 | ifp->if_bytes -= count * sizeof(xfs_bmbt_rec_t); | ||
4089 | xfs_iext_irec_compact(ifp); | ||
4090 | } | ||
4091 | |||
4092 | /* | ||
4093 | * Create, destroy, or resize a linear (direct) block of extents. | ||
4094 | */ | ||
4095 | void | ||
4096 | xfs_iext_realloc_direct( | ||
4097 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4098 | int new_size) /* new size of extents */ | ||
4099 | { | ||
4100 | int rnew_size; /* real new size of extents */ | ||
4101 | |||
4102 | rnew_size = new_size; | ||
4103 | |||
4104 | ASSERT(!(ifp->if_flags & XFS_IFEXTIREC) || | ||
4105 | ((new_size >= 0) && (new_size <= XFS_IEXT_BUFSZ) && | ||
4106 | (new_size != ifp->if_real_bytes))); | ||
4107 | |||
4108 | /* Free extent records */ | ||
4109 | if (new_size == 0) { | ||
4110 | xfs_iext_destroy(ifp); | ||
4111 | } | ||
4112 | /* Resize direct extent list and zero any new bytes */ | ||
4113 | else if (ifp->if_real_bytes) { | ||
4114 | /* Check if extents will fit inside the inode */ | ||
4115 | if (new_size <= XFS_INLINE_EXTS * sizeof(xfs_bmbt_rec_t)) { | ||
4116 | xfs_iext_direct_to_inline(ifp, new_size / | ||
4117 | (uint)sizeof(xfs_bmbt_rec_t)); | ||
4118 | ifp->if_bytes = new_size; | ||
4119 | return; | ||
4120 | } | ||
4121 | if ((new_size & (new_size - 1)) != 0) { | ||
4122 | rnew_size = xfs_iroundup(new_size); | ||
4123 | } | ||
4124 | if (rnew_size != ifp->if_real_bytes) { | ||
4125 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ||
4126 | kmem_realloc(ifp->if_u1.if_extents, | ||
4127 | rnew_size, | ||
4128 | ifp->if_real_bytes, | ||
4129 | KM_SLEEP); | ||
4130 | } | ||
4131 | if (rnew_size > ifp->if_real_bytes) { | ||
4132 | memset(&ifp->if_u1.if_extents[ifp->if_bytes / | ||
4133 | (uint)sizeof(xfs_bmbt_rec_t)], 0, | ||
4134 | rnew_size - ifp->if_real_bytes); | ||
4135 | } | ||
4136 | } | ||
4137 | /* | ||
4138 | * Switch from the inline extent buffer to a direct | ||
4139 | * extent list. Be sure to include the inline extent | ||
4140 | * bytes in new_size. | ||
4141 | */ | ||
4142 | else { | ||
4143 | new_size += ifp->if_bytes; | ||
4144 | if ((new_size & (new_size - 1)) != 0) { | ||
4145 | rnew_size = xfs_iroundup(new_size); | ||
4146 | } | ||
4147 | xfs_iext_inline_to_direct(ifp, rnew_size); | ||
4148 | } | ||
4149 | ifp->if_real_bytes = rnew_size; | ||
4150 | ifp->if_bytes = new_size; | ||
4151 | } | ||
4152 | |||
4153 | /* | ||
4154 | * Switch from linear (direct) extent records to inline buffer. | ||
4155 | */ | ||
4156 | void | ||
4157 | xfs_iext_direct_to_inline( | ||
4158 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4159 | xfs_extnum_t nextents) /* number of extents in file */ | ||
4160 | { | ||
4161 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | ||
4162 | ASSERT(nextents <= XFS_INLINE_EXTS); | ||
4163 | /* | ||
4164 | * The inline buffer was zeroed when we switched | ||
4165 | * from inline to direct extent allocation mode, | ||
4166 | * so we don't need to clear it here. | ||
4167 | */ | ||
4168 | memcpy(ifp->if_u2.if_inline_ext, ifp->if_u1.if_extents, | ||
4169 | nextents * sizeof(xfs_bmbt_rec_t)); | ||
4170 | kmem_free(ifp->if_u1.if_extents, KM_SLEEP); | ||
4171 | ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext; | ||
4172 | ifp->if_real_bytes = 0; | ||
4173 | } | ||
4174 | |||
4175 | /* | ||
4176 | * Switch from inline buffer to linear (direct) extent records. | ||
4177 | * new_size should already be rounded up to the next power of 2 | ||
4178 | * by the caller (when appropriate), so use new_size as it is. | ||
4179 | * However, since new_size may be rounded up, we can't update | ||
4180 | * if_bytes here. It is the caller's responsibility to update | ||
4181 | * if_bytes upon return. | ||
4182 | */ | ||
4183 | void | ||
4184 | xfs_iext_inline_to_direct( | ||
4185 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4186 | int new_size) /* number of extents in file */ | ||
4187 | { | ||
4188 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ||
4189 | kmem_alloc(new_size, KM_SLEEP); | ||
4190 | memset(ifp->if_u1.if_extents, 0, new_size); | ||
4191 | if (ifp->if_bytes) { | ||
4192 | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, | ||
4193 | ifp->if_bytes); | ||
4194 | memset(ifp->if_u2.if_inline_ext, 0, XFS_INLINE_EXTS * | ||
4195 | sizeof(xfs_bmbt_rec_t)); | ||
4196 | } | ||
4197 | ifp->if_real_bytes = new_size; | ||
4198 | } | ||
4199 | |||
4200 | /* | ||
4201 | * Resize an extent indirection array to new_size bytes. | ||
4202 | */ | ||
4203 | void | ||
4204 | xfs_iext_realloc_indirect( | ||
4205 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4206 | int new_size) /* new indirection array size */ | ||
4207 | { | ||
4208 | int nlists; /* number of irec's (ex lists) */ | ||
4209 | int size; /* current indirection array size */ | ||
4210 | |||
4211 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4212 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4213 | size = nlists * sizeof(xfs_ext_irec_t); | ||
4214 | ASSERT(ifp->if_real_bytes); | ||
4215 | ASSERT((new_size >= 0) && (new_size != size)); | ||
4216 | if (new_size == 0) { | ||
4217 | xfs_iext_destroy(ifp); | ||
4218 | } else { | ||
4219 | ifp->if_u1.if_ext_irec = (xfs_ext_irec_t *) | ||
4220 | kmem_realloc(ifp->if_u1.if_ext_irec, | ||
4221 | new_size, size, KM_SLEEP); | ||
4222 | } | ||
4223 | } | ||
4224 | |||
4225 | /* | ||
4226 | * Switch from indirection array to linear (direct) extent allocations. | ||
4227 | */ | ||
4228 | void | ||
4229 | xfs_iext_indirect_to_direct( | ||
4230 | xfs_ifork_t *ifp) /* inode fork pointer */ | ||
4231 | { | ||
4232 | xfs_bmbt_rec_t *ep; /* extent record pointer */ | ||
4233 | xfs_extnum_t nextents; /* number of extents in file */ | ||
4234 | int size; /* size of file extents */ | ||
4235 | |||
4236 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4237 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
4238 | ASSERT(nextents <= XFS_LINEAR_EXTS); | ||
4239 | size = nextents * sizeof(xfs_bmbt_rec_t); | ||
4240 | |||
4241 | xfs_iext_irec_compact_full(ifp); | ||
4242 | ASSERT(ifp->if_real_bytes == XFS_IEXT_BUFSZ); | ||
4243 | |||
4244 | ep = ifp->if_u1.if_ext_irec->er_extbuf; | ||
4245 | kmem_free(ifp->if_u1.if_ext_irec, sizeof(xfs_ext_irec_t)); | ||
4246 | ifp->if_flags &= ~XFS_IFEXTIREC; | ||
4247 | ifp->if_u1.if_extents = ep; | ||
4248 | ifp->if_bytes = size; | ||
4249 | if (nextents < XFS_LINEAR_EXTS) { | ||
4250 | xfs_iext_realloc_direct(ifp, size); | ||
4251 | } | ||
4252 | } | ||
4253 | |||
4254 | /* | ||
4255 | * Free incore file extents. | ||
4256 | */ | ||
4257 | void | ||
4258 | xfs_iext_destroy( | ||
4259 | xfs_ifork_t *ifp) /* inode fork pointer */ | ||
4260 | { | ||
4261 | if (ifp->if_flags & XFS_IFEXTIREC) { | ||
4262 | int erp_idx; | ||
4263 | int nlists; | ||
4264 | |||
4265 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4266 | for (erp_idx = nlists - 1; erp_idx >= 0 ; erp_idx--) { | ||
4267 | xfs_iext_irec_remove(ifp, erp_idx); | ||
4268 | } | ||
4269 | ifp->if_flags &= ~XFS_IFEXTIREC; | ||
4270 | } else if (ifp->if_real_bytes) { | ||
4271 | kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes); | ||
4272 | } else if (ifp->if_bytes) { | ||
4273 | memset(ifp->if_u2.if_inline_ext, 0, XFS_INLINE_EXTS * | ||
4274 | sizeof(xfs_bmbt_rec_t)); | ||
4275 | } | ||
4276 | ifp->if_u1.if_extents = NULL; | ||
4277 | ifp->if_real_bytes = 0; | ||
4278 | ifp->if_bytes = 0; | ||
4279 | } | ||
4280 | |||
4281 | /* | ||
4282 | * Return a pointer to the extent record for file system block bno. | ||
4283 | */ | ||
4284 | xfs_bmbt_rec_t * /* pointer to found extent record */ | ||
4285 | xfs_iext_bno_to_ext( | ||
4286 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4287 | xfs_fileoff_t bno, /* block number to search for */ | ||
4288 | xfs_extnum_t *idxp) /* index of target extent */ | ||
4289 | { | ||
4290 | xfs_bmbt_rec_t *base; /* pointer to first extent */ | ||
4291 | xfs_filblks_t blockcount = 0; /* number of blocks in extent */ | ||
4292 | xfs_bmbt_rec_t *ep = NULL; /* pointer to target extent */ | ||
4293 | xfs_ext_irec_t *erp = NULL; /* indirection array pointer */ | ||
4294 | int high; /* upper boundry in search */ | ||
4295 | xfs_extnum_t idx = 0; /* index of target extent */ | ||
4296 | int low; /* lower boundry in search */ | ||
4297 | xfs_extnum_t nextents; /* number of file extents */ | ||
4298 | xfs_fileoff_t startoff = 0; /* start offset of extent */ | ||
4299 | |||
4300 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
4301 | if (nextents == 0) { | ||
4302 | *idxp = 0; | ||
4303 | return NULL; | ||
4304 | } | ||
4305 | low = 0; | ||
4306 | if (ifp->if_flags & XFS_IFEXTIREC) { | ||
4307 | /* Find target extent list */ | ||
4308 | int erp_idx = 0; | ||
4309 | erp = xfs_iext_bno_to_irec(ifp, bno, &erp_idx); | ||
4310 | base = erp->er_extbuf; | ||
4311 | high = erp->er_extcount - 1; | ||
4312 | } else { | ||
4313 | base = ifp->if_u1.if_extents; | ||
4314 | high = nextents - 1; | ||
4315 | } | ||
4316 | /* Binary search extent records */ | ||
4317 | while (low <= high) { | ||
4318 | idx = (low + high) >> 1; | ||
4319 | ep = base + idx; | ||
4320 | startoff = xfs_bmbt_get_startoff(ep); | ||
4321 | blockcount = xfs_bmbt_get_blockcount(ep); | ||
4322 | if (bno < startoff) { | ||
4323 | high = idx - 1; | ||
4324 | } else if (bno >= startoff + blockcount) { | ||
4325 | low = idx + 1; | ||
4326 | } else { | ||
4327 | /* Convert back to file-based extent index */ | ||
4328 | if (ifp->if_flags & XFS_IFEXTIREC) { | ||
4329 | idx += erp->er_extoff; | ||
4330 | } | ||
4331 | *idxp = idx; | ||
4332 | return ep; | ||
4333 | } | ||
4334 | } | ||
4335 | /* Convert back to file-based extent index */ | ||
4336 | if (ifp->if_flags & XFS_IFEXTIREC) { | ||
4337 | idx += erp->er_extoff; | ||
4338 | } | ||
4339 | if (bno >= startoff + blockcount) { | ||
4340 | if (++idx == nextents) { | ||
4341 | ep = NULL; | ||
4342 | } else { | ||
4343 | ep = xfs_iext_get_ext(ifp, idx); | ||
4344 | } | ||
4345 | } | ||
4346 | *idxp = idx; | ||
4347 | return ep; | ||
4348 | } | ||
4349 | |||
4350 | /* | ||
4351 | * Return a pointer to the indirection array entry containing the | ||
4352 | * extent record for filesystem block bno. Store the index of the | ||
4353 | * target irec in *erp_idxp. | ||
4354 | */ | ||
4355 | xfs_ext_irec_t * /* pointer to found extent record */ | ||
4356 | xfs_iext_bno_to_irec( | ||
4357 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4358 | xfs_fileoff_t bno, /* block number to search for */ | ||
4359 | int *erp_idxp) /* irec index of target ext list */ | ||
4360 | { | ||
4361 | xfs_ext_irec_t *erp = NULL; /* indirection array pointer */ | ||
4362 | xfs_ext_irec_t *erp_next; /* next indirection array entry */ | ||
4363 | int erp_idx; /* indirection array index */ | ||
4364 | int nlists; /* number of extent irec's (lists) */ | ||
4365 | int high; /* binary search upper limit */ | ||
4366 | int low; /* binary search lower limit */ | ||
4367 | |||
4368 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4369 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4370 | erp_idx = 0; | ||
4371 | low = 0; | ||
4372 | high = nlists - 1; | ||
4373 | while (low <= high) { | ||
4374 | erp_idx = (low + high) >> 1; | ||
4375 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4376 | erp_next = erp_idx < nlists - 1 ? erp + 1 : NULL; | ||
4377 | if (bno < xfs_bmbt_get_startoff(erp->er_extbuf)) { | ||
4378 | high = erp_idx - 1; | ||
4379 | } else if (erp_next && bno >= | ||
4380 | xfs_bmbt_get_startoff(erp_next->er_extbuf)) { | ||
4381 | low = erp_idx + 1; | ||
4382 | } else { | ||
4383 | break; | ||
4384 | } | ||
4385 | } | ||
4386 | *erp_idxp = erp_idx; | ||
4387 | return erp; | ||
4388 | } | ||
4389 | |||
4390 | /* | ||
4391 | * Return a pointer to the indirection array entry containing the | ||
4392 | * extent record at file extent index *idxp. Store the index of the | ||
4393 | * target irec in *erp_idxp and store the page index of the target | ||
4394 | * extent record in *idxp. | ||
4395 | */ | ||
4396 | xfs_ext_irec_t * | ||
4397 | xfs_iext_idx_to_irec( | ||
4398 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4399 | xfs_extnum_t *idxp, /* extent index (file -> page) */ | ||
4400 | int *erp_idxp, /* pointer to target irec */ | ||
4401 | int realloc) /* new bytes were just added */ | ||
4402 | { | ||
4403 | xfs_ext_irec_t *prev; /* pointer to previous irec */ | ||
4404 | xfs_ext_irec_t *erp = NULL; /* pointer to current irec */ | ||
4405 | int erp_idx; /* indirection array index */ | ||
4406 | int nlists; /* number of irec's (ex lists) */ | ||
4407 | int high; /* binary search upper limit */ | ||
4408 | int low; /* binary search lower limit */ | ||
4409 | xfs_extnum_t page_idx = *idxp; /* extent index in target list */ | ||
4410 | |||
4411 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4412 | ASSERT(page_idx >= 0 && page_idx <= | ||
4413 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); | ||
4414 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4415 | erp_idx = 0; | ||
4416 | low = 0; | ||
4417 | high = nlists - 1; | ||
4418 | |||
4419 | /* Binary search extent irec's */ | ||
4420 | while (low <= high) { | ||
4421 | erp_idx = (low + high) >> 1; | ||
4422 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4423 | prev = erp_idx > 0 ? erp - 1 : NULL; | ||
4424 | if (page_idx < erp->er_extoff || (page_idx == erp->er_extoff && | ||
4425 | realloc && prev && prev->er_extcount < XFS_LINEAR_EXTS)) { | ||
4426 | high = erp_idx - 1; | ||
4427 | } else if (page_idx > erp->er_extoff + erp->er_extcount || | ||
4428 | (page_idx == erp->er_extoff + erp->er_extcount && | ||
4429 | !realloc)) { | ||
4430 | low = erp_idx + 1; | ||
4431 | } else if (page_idx == erp->er_extoff + erp->er_extcount && | ||
4432 | erp->er_extcount == XFS_LINEAR_EXTS) { | ||
4433 | ASSERT(realloc); | ||
4434 | page_idx = 0; | ||
4435 | erp_idx++; | ||
4436 | erp = erp_idx < nlists ? erp + 1 : NULL; | ||
4437 | break; | ||
4438 | } else { | ||
4439 | page_idx -= erp->er_extoff; | ||
4440 | break; | ||
4441 | } | ||
4442 | } | ||
4443 | *idxp = page_idx; | ||
4444 | *erp_idxp = erp_idx; | ||
4445 | return(erp); | ||
4446 | } | ||
4447 | |||
4448 | /* | ||
4449 | * Allocate and initialize an indirection array once the space needed | ||
4450 | * for incore extents increases above XFS_IEXT_BUFSZ. | ||
4451 | */ | ||
4452 | void | ||
4453 | xfs_iext_irec_init( | ||
4454 | xfs_ifork_t *ifp) /* inode fork pointer */ | ||
4455 | { | ||
4456 | xfs_ext_irec_t *erp; /* indirection array pointer */ | ||
4457 | xfs_extnum_t nextents; /* number of extents in file */ | ||
4458 | |||
4459 | ASSERT(!(ifp->if_flags & XFS_IFEXTIREC)); | ||
4460 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
4461 | ASSERT(nextents <= XFS_LINEAR_EXTS); | ||
4462 | |||
4463 | erp = (xfs_ext_irec_t *) | ||
4464 | kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP); | ||
4465 | |||
4466 | if (nextents == 0) { | ||
4467 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ||
4468 | kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | ||
4469 | } else if (!ifp->if_real_bytes) { | ||
4470 | xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); | ||
4471 | } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { | ||
4472 | xfs_iext_realloc_direct(ifp, XFS_IEXT_BUFSZ); | ||
4473 | } | ||
4474 | erp->er_extbuf = ifp->if_u1.if_extents; | ||
4475 | erp->er_extcount = nextents; | ||
4476 | erp->er_extoff = 0; | ||
4477 | |||
4478 | ifp->if_flags |= XFS_IFEXTIREC; | ||
4479 | ifp->if_real_bytes = XFS_IEXT_BUFSZ; | ||
4480 | ifp->if_bytes = nextents * sizeof(xfs_bmbt_rec_t); | ||
4481 | ifp->if_u1.if_ext_irec = erp; | ||
4482 | |||
4483 | return; | ||
4484 | } | ||
4485 | |||
4486 | /* | ||
4487 | * Allocate and initialize a new entry in the indirection array. | ||
4488 | */ | ||
4489 | xfs_ext_irec_t * | ||
4490 | xfs_iext_irec_new( | ||
4491 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4492 | int erp_idx) /* index for new irec */ | ||
4493 | { | ||
4494 | xfs_ext_irec_t *erp; /* indirection array pointer */ | ||
4495 | int i; /* loop counter */ | ||
4496 | int nlists; /* number of irec's (ex lists) */ | ||
4497 | |||
4498 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4499 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4500 | |||
4501 | /* Resize indirection array */ | ||
4502 | xfs_iext_realloc_indirect(ifp, ++nlists * | ||
4503 | sizeof(xfs_ext_irec_t)); | ||
4504 | /* | ||
4505 | * Move records down in the array so the | ||
4506 | * new page can use erp_idx. | ||
4507 | */ | ||
4508 | erp = ifp->if_u1.if_ext_irec; | ||
4509 | for (i = nlists - 1; i > erp_idx; i--) { | ||
4510 | memmove(&erp[i], &erp[i-1], sizeof(xfs_ext_irec_t)); | ||
4511 | } | ||
4512 | ASSERT(i == erp_idx); | ||
4513 | |||
4514 | /* Initialize new extent record */ | ||
4515 | erp = ifp->if_u1.if_ext_irec; | ||
4516 | erp[erp_idx].er_extbuf = (xfs_bmbt_rec_t *) | ||
4517 | kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | ||
4518 | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; | ||
4519 | memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); | ||
4520 | erp[erp_idx].er_extcount = 0; | ||
4521 | erp[erp_idx].er_extoff = erp_idx > 0 ? | ||
4522 | erp[erp_idx-1].er_extoff + erp[erp_idx-1].er_extcount : 0; | ||
4523 | return (&erp[erp_idx]); | ||
4524 | } | ||
4525 | |||
4526 | /* | ||
4527 | * Remove a record from the indirection array. | ||
4528 | */ | ||
4529 | void | ||
4530 | xfs_iext_irec_remove( | ||
4531 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4532 | int erp_idx) /* irec index to remove */ | ||
4533 | { | ||
4534 | xfs_ext_irec_t *erp; /* indirection array pointer */ | ||
4535 | int i; /* loop counter */ | ||
4536 | int nlists; /* number of irec's (ex lists) */ | ||
4537 | |||
4538 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4539 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4540 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4541 | if (erp->er_extbuf) { | ||
4542 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, | ||
4543 | -erp->er_extcount); | ||
4544 | kmem_free(erp->er_extbuf, XFS_IEXT_BUFSZ); | ||
4545 | } | ||
4546 | /* Compact extent records */ | ||
4547 | erp = ifp->if_u1.if_ext_irec; | ||
4548 | for (i = erp_idx; i < nlists - 1; i++) { | ||
4549 | memmove(&erp[i], &erp[i+1], sizeof(xfs_ext_irec_t)); | ||
4550 | } | ||
4551 | /* | ||
4552 | * Manually free the last extent record from the indirection | ||
4553 | * array. A call to xfs_iext_realloc_indirect() with a size | ||
4554 | * of zero would result in a call to xfs_iext_destroy() which | ||
4555 | * would in turn call this function again, creating a nasty | ||
4556 | * infinite loop. | ||
4557 | */ | ||
4558 | if (--nlists) { | ||
4559 | xfs_iext_realloc_indirect(ifp, | ||
4560 | nlists * sizeof(xfs_ext_irec_t)); | ||
4561 | } else { | ||
4562 | kmem_free(ifp->if_u1.if_ext_irec, | ||
4563 | sizeof(xfs_ext_irec_t)); | ||
4564 | } | ||
4565 | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; | ||
4566 | } | ||
4567 | |||
4568 | /* | ||
4569 | * This is called to clean up large amounts of unused memory allocated | ||
4570 | * by the indirection array. Before compacting anything though, verify | ||
4571 | * that the indirection array is still needed and switch back to the | ||
4572 | * linear extent list (or even the inline buffer) if possible. The | ||
4573 | * compaction policy is as follows: | ||
4574 | * | ||
4575 | * Full Compaction: Extents fit into a single page (or inline buffer) | ||
4576 | * Full Compaction: Extents occupy less than 10% of allocated space | ||
4577 | * Partial Compaction: Extents occupy > 10% and < 50% of allocated space | ||
4578 | * No Compaction: Extents occupy at least 50% of allocated space | ||
4579 | */ | ||
4580 | void | ||
4581 | xfs_iext_irec_compact( | ||
4582 | xfs_ifork_t *ifp) /* inode fork pointer */ | ||
4583 | { | ||
4584 | xfs_extnum_t nextents; /* number of extents in file */ | ||
4585 | int nlists; /* number of irec's (ex lists) */ | ||
4586 | |||
4587 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4588 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4589 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | ||
4590 | |||
4591 | if (nextents == 0) { | ||
4592 | xfs_iext_destroy(ifp); | ||
4593 | } else if (nextents <= XFS_INLINE_EXTS) { | ||
4594 | xfs_iext_indirect_to_direct(ifp); | ||
4595 | xfs_iext_direct_to_inline(ifp, nextents); | ||
4596 | } else if (nextents <= XFS_LINEAR_EXTS) { | ||
4597 | xfs_iext_indirect_to_direct(ifp); | ||
4598 | } else if (nextents < (nlists * XFS_LINEAR_EXTS) >> 3) { | ||
4599 | xfs_iext_irec_compact_full(ifp); | ||
4600 | } else if (nextents < (nlists * XFS_LINEAR_EXTS) >> 1) { | ||
4601 | xfs_iext_irec_compact_pages(ifp); | ||
4602 | } | ||
4603 | } | ||
4604 | |||
4605 | /* | ||
4606 | * Combine extents from neighboring extent pages. | ||
4607 | */ | ||
4608 | void | ||
4609 | xfs_iext_irec_compact_pages( | ||
4610 | xfs_ifork_t *ifp) /* inode fork pointer */ | ||
4611 | { | ||
4612 | xfs_ext_irec_t *erp, *erp_next;/* pointers to irec entries */ | ||
4613 | int erp_idx = 0; /* indirection array index */ | ||
4614 | int nlists; /* number of irec's (ex lists) */ | ||
4615 | |||
4616 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4617 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4618 | while (erp_idx < nlists - 1) { | ||
4619 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4620 | erp_next = erp + 1; | ||
4621 | if (erp_next->er_extcount <= | ||
4622 | (XFS_LINEAR_EXTS - erp->er_extcount)) { | ||
4623 | memmove(&erp->er_extbuf[erp->er_extcount], | ||
4624 | erp_next->er_extbuf, erp_next->er_extcount * | ||
4625 | sizeof(xfs_bmbt_rec_t)); | ||
4626 | erp->er_extcount += erp_next->er_extcount; | ||
4627 | /* | ||
4628 | * Free page before removing extent record | ||
4629 | * so er_extoffs don't get modified in | ||
4630 | * xfs_iext_irec_remove. | ||
4631 | */ | ||
4632 | kmem_free(erp_next->er_extbuf, XFS_IEXT_BUFSZ); | ||
4633 | erp_next->er_extbuf = NULL; | ||
4634 | xfs_iext_irec_remove(ifp, erp_idx + 1); | ||
4635 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4636 | } else { | ||
4637 | erp_idx++; | ||
4638 | } | ||
4639 | } | ||
4640 | } | ||
4641 | |||
4642 | /* | ||
4643 | * Fully compact the extent records managed by the indirection array. | ||
4644 | */ | ||
4645 | void | ||
4646 | xfs_iext_irec_compact_full( | ||
4647 | xfs_ifork_t *ifp) /* inode fork pointer */ | ||
4648 | { | ||
4649 | xfs_bmbt_rec_t *ep, *ep_next; /* extent record pointers */ | ||
4650 | xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */ | ||
4651 | int erp_idx = 0; /* extent irec index */ | ||
4652 | int ext_avail; /* empty entries in ex list */ | ||
4653 | int ext_diff; /* number of exts to add */ | ||
4654 | int nlists; /* number of irec's (ex lists) */ | ||
4655 | |||
4656 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4657 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4658 | erp = ifp->if_u1.if_ext_irec; | ||
4659 | ep = &erp->er_extbuf[erp->er_extcount]; | ||
4660 | erp_next = erp + 1; | ||
4661 | ep_next = erp_next->er_extbuf; | ||
4662 | while (erp_idx < nlists - 1) { | ||
4663 | ext_avail = XFS_LINEAR_EXTS - erp->er_extcount; | ||
4664 | ext_diff = MIN(ext_avail, erp_next->er_extcount); | ||
4665 | memcpy(ep, ep_next, ext_diff * sizeof(xfs_bmbt_rec_t)); | ||
4666 | erp->er_extcount += ext_diff; | ||
4667 | erp_next->er_extcount -= ext_diff; | ||
4668 | /* Remove next page */ | ||
4669 | if (erp_next->er_extcount == 0) { | ||
4670 | /* | ||
4671 | * Free page before removing extent record | ||
4672 | * so er_extoffs don't get modified in | ||
4673 | * xfs_iext_irec_remove. | ||
4674 | */ | ||
4675 | kmem_free(erp_next->er_extbuf, | ||
4676 | erp_next->er_extcount * sizeof(xfs_bmbt_rec_t)); | ||
4677 | erp_next->er_extbuf = NULL; | ||
4678 | xfs_iext_irec_remove(ifp, erp_idx + 1); | ||
4679 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4680 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4681 | /* Update next page */ | ||
4682 | } else { | ||
4683 | /* Move rest of page up to become next new page */ | ||
4684 | memmove(erp_next->er_extbuf, ep_next, | ||
4685 | erp_next->er_extcount * sizeof(xfs_bmbt_rec_t)); | ||
4686 | ep_next = erp_next->er_extbuf; | ||
4687 | memset(&ep_next[erp_next->er_extcount], 0, | ||
4688 | (XFS_LINEAR_EXTS - erp_next->er_extcount) * | ||
4689 | sizeof(xfs_bmbt_rec_t)); | ||
4690 | } | ||
4691 | if (erp->er_extcount == XFS_LINEAR_EXTS) { | ||
4692 | erp_idx++; | ||
4693 | if (erp_idx < nlists) | ||
4694 | erp = &ifp->if_u1.if_ext_irec[erp_idx]; | ||
4695 | else | ||
4696 | break; | ||
4697 | } | ||
4698 | ep = &erp->er_extbuf[erp->er_extcount]; | ||
4699 | erp_next = erp + 1; | ||
4700 | ep_next = erp_next->er_extbuf; | ||
4701 | } | ||
4702 | } | ||
4703 | |||
4704 | /* | ||
4705 | * This is called to update the er_extoff field in the indirection | ||
4706 | * array when extents have been added or removed from one of the | ||
4707 | * extent lists. erp_idx contains the irec index to begin updating | ||
4708 | * at and ext_diff contains the number of extents that were added | ||
4709 | * or removed. | ||
4710 | */ | ||
4711 | void | ||
4712 | xfs_iext_irec_update_extoffs( | ||
4713 | xfs_ifork_t *ifp, /* inode fork pointer */ | ||
4714 | int erp_idx, /* irec index to update */ | ||
4715 | int ext_diff) /* number of new extents */ | ||
4716 | { | ||
4717 | int i; /* loop counter */ | ||
4718 | int nlists; /* number of irec's (ex lists */ | ||
4719 | |||
4720 | ASSERT(ifp->if_flags & XFS_IFEXTIREC); | ||
4721 | nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; | ||
4722 | for (i = erp_idx; i < nlists; i++) { | ||
4723 | ifp->if_u1.if_ext_irec[i].er_extoff += ext_diff; | ||
4724 | } | ||
4725 | } | ||
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 1cfbcf18ce86..39ef9c36ea55 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -25,10 +25,37 @@ | |||
25 | #define XFS_ATTR_FORK 1 | 25 | #define XFS_ATTR_FORK 1 |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * The following xfs_ext_irec_t struct introduces a second (top) level | ||
29 | * to the in-core extent allocation scheme. These structs are allocated | ||
30 | * in a contiguous block, creating an indirection array where each entry | ||
31 | * (irec) contains a pointer to a buffer of in-core extent records which | ||
32 | * it manages. Each extent buffer is 4k in size, since 4k is the system | ||
33 | * page size on Linux i386 and systems with larger page sizes don't seem | ||
34 | * to gain much, if anything, by using their native page size as the | ||
35 | * extent buffer size. Also, using 4k extent buffers everywhere provides | ||
36 | * a consistent interface for CXFS across different platforms. | ||
37 | * | ||
38 | * There is currently no limit on the number of irec's (extent lists) | ||
39 | * allowed, so heavily fragmented files may require an indirection array | ||
40 | * which spans multiple system pages of memory. The number of extents | ||
41 | * which would require this amount of contiguous memory is very large | ||
42 | * and should not cause problems in the foreseeable future. However, | ||
43 | * if the memory needed for the contiguous array ever becomes a problem, | ||
44 | * it is possible that a third level of indirection may be required. | ||
45 | */ | ||
46 | typedef struct xfs_ext_irec { | ||
47 | xfs_bmbt_rec_t *er_extbuf; /* block of extent records */ | ||
48 | xfs_extnum_t er_extoff; /* extent offset in file */ | ||
49 | xfs_extnum_t er_extcount; /* number of extents in page/block */ | ||
50 | } xfs_ext_irec_t; | ||
51 | |||
52 | /* | ||
28 | * File incore extent information, present for each of data & attr forks. | 53 | * File incore extent information, present for each of data & attr forks. |
29 | */ | 54 | */ |
30 | #define XFS_INLINE_EXTS 2 | 55 | #define XFS_IEXT_BUFSZ 4096 |
31 | #define XFS_INLINE_DATA 32 | 56 | #define XFS_LINEAR_EXTS (XFS_IEXT_BUFSZ / (uint)sizeof(xfs_bmbt_rec_t)) |
57 | #define XFS_INLINE_EXTS 2 | ||
58 | #define XFS_INLINE_DATA 32 | ||
32 | typedef struct xfs_ifork { | 59 | typedef struct xfs_ifork { |
33 | int if_bytes; /* bytes in if_u1 */ | 60 | int if_bytes; /* bytes in if_u1 */ |
34 | int if_real_bytes; /* bytes allocated in if_u1 */ | 61 | int if_real_bytes; /* bytes allocated in if_u1 */ |
@@ -39,6 +66,7 @@ typedef struct xfs_ifork { | |||
39 | xfs_extnum_t if_lastex; /* last if_extents used */ | 66 | xfs_extnum_t if_lastex; /* last if_extents used */ |
40 | union { | 67 | union { |
41 | xfs_bmbt_rec_t *if_extents; /* linear map file exts */ | 68 | xfs_bmbt_rec_t *if_extents; /* linear map file exts */ |
69 | xfs_ext_irec_t *if_ext_irec; /* irec map file exts */ | ||
42 | char *if_data; /* inline file data */ | 70 | char *if_data; /* inline file data */ |
43 | } if_u1; | 71 | } if_u1; |
44 | union { | 72 | union { |
@@ -61,20 +89,16 @@ typedef struct xfs_ifork { | |||
61 | /* | 89 | /* |
62 | * Per-fork incore inode flags. | 90 | * Per-fork incore inode flags. |
63 | */ | 91 | */ |
64 | #define XFS_IFINLINE 0x0001 /* Inline data is read in */ | 92 | #define XFS_IFINLINE 0x01 /* Inline data is read in */ |
65 | #define XFS_IFEXTENTS 0x0002 /* All extent pointers are read in */ | 93 | #define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */ |
66 | #define XFS_IFBROOT 0x0004 /* i_broot points to the bmap b-tree root */ | 94 | #define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */ |
95 | #define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */ | ||
67 | 96 | ||
68 | /* | 97 | /* |
69 | * Flags for xfs_imap() and xfs_dilocate(). | 98 | * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate(). |
70 | */ | 99 | */ |
71 | #define XFS_IMAP_LOOKUP 0x1 | 100 | #define XFS_IMAP_LOOKUP 0x1 |
72 | 101 | #define XFS_IMAP_BULKSTAT 0x2 | |
73 | /* | ||
74 | * Maximum number of extent pointers in if_u1.if_extents. | ||
75 | */ | ||
76 | #define XFS_MAX_INCORE_EXTENTS 32768 | ||
77 | |||
78 | 102 | ||
79 | #ifdef __KERNEL__ | 103 | #ifdef __KERNEL__ |
80 | struct bhv_desc; | 104 | struct bhv_desc; |
@@ -398,7 +422,7 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int); | |||
398 | */ | 422 | */ |
399 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, | 423 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, |
400 | xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, | 424 | xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, |
401 | xfs_daddr_t); | 425 | xfs_daddr_t, uint); |
402 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, | 426 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, |
403 | xfs_inode_t **, xfs_daddr_t); | 427 | xfs_inode_t **, xfs_daddr_t); |
404 | int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); | 428 | int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); |
@@ -440,6 +464,32 @@ xfs_inode_t *xfs_vtoi(struct vnode *vp); | |||
440 | 464 | ||
441 | void xfs_synchronize_atime(xfs_inode_t *); | 465 | void xfs_synchronize_atime(xfs_inode_t *); |
442 | 466 | ||
467 | xfs_bmbt_rec_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); | ||
468 | void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, | ||
469 | xfs_bmbt_irec_t *); | ||
470 | void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); | ||
471 | void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int); | ||
472 | void xfs_iext_remove(xfs_ifork_t *, xfs_extnum_t, int); | ||
473 | void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int); | ||
474 | void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); | ||
475 | void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); | ||
476 | void xfs_iext_realloc_direct(xfs_ifork_t *, int); | ||
477 | void xfs_iext_realloc_indirect(xfs_ifork_t *, int); | ||
478 | void xfs_iext_indirect_to_direct(xfs_ifork_t *); | ||
479 | void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t); | ||
480 | void xfs_iext_inline_to_direct(xfs_ifork_t *, int); | ||
481 | void xfs_iext_destroy(xfs_ifork_t *); | ||
482 | xfs_bmbt_rec_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *); | ||
483 | xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *); | ||
484 | xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int); | ||
485 | void xfs_iext_irec_init(xfs_ifork_t *); | ||
486 | xfs_ext_irec_t *xfs_iext_irec_new(xfs_ifork_t *, int); | ||
487 | void xfs_iext_irec_remove(xfs_ifork_t *, int); | ||
488 | void xfs_iext_irec_compact(xfs_ifork_t *); | ||
489 | void xfs_iext_irec_compact_pages(xfs_ifork_t *); | ||
490 | void xfs_iext_irec_compact_full(xfs_ifork_t *); | ||
491 | void xfs_iext_irec_update_extoffs(xfs_ifork_t *, int, int); | ||
492 | |||
443 | #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) | 493 | #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) |
444 | 494 | ||
445 | #ifdef DEBUG | 495 | #ifdef DEBUG |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 788917f355c4..d5dfedcb8922 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -76,7 +76,7 @@ xfs_iomap_enter_trace( | |||
76 | (void *)((unsigned long)count), | 76 | (void *)((unsigned long)count), |
77 | (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), | 77 | (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), |
78 | (void *)((unsigned long)(io->io_new_size & 0xffffffff)), | 78 | (void *)((unsigned long)(io->io_new_size & 0xffffffff)), |
79 | (void *)NULL, | 79 | (void *)((unsigned long)current_pid()), |
80 | (void *)NULL, | 80 | (void *)NULL, |
81 | (void *)NULL, | 81 | (void *)NULL, |
82 | (void *)NULL, | 82 | (void *)NULL, |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index c59450e1be40..32247b6bfee7 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -562,7 +562,8 @@ xfs_bulkstat( | |||
562 | if (bp) | 562 | if (bp) |
563 | xfs_buf_relse(bp); | 563 | xfs_buf_relse(bp); |
564 | error = xfs_itobp(mp, NULL, ip, | 564 | error = xfs_itobp(mp, NULL, ip, |
565 | &dip, &bp, bno); | 565 | &dip, &bp, bno, |
566 | XFS_IMAP_BULKSTAT); | ||
566 | if (!error) | 567 | if (!error) |
567 | clustidx = ip->i_boffset / mp->m_sb.sb_inodesize; | 568 | clustidx = ip->i_boffset / mp->m_sb.sb_inodesize; |
568 | kmem_zone_free(xfs_inode_zone, ip); | 569 | kmem_zone_free(xfs_inode_zone, ip); |
@@ -570,6 +571,8 @@ xfs_bulkstat( | |||
570 | mp, XFS_ERRTAG_BULKSTAT_READ_CHUNK, | 571 | mp, XFS_ERRTAG_BULKSTAT_READ_CHUNK, |
571 | XFS_RANDOM_BULKSTAT_READ_CHUNK)) { | 572 | XFS_RANDOM_BULKSTAT_READ_CHUNK)) { |
572 | bp = NULL; | 573 | bp = NULL; |
574 | ubleft = 0; | ||
575 | rval = error; | ||
573 | break; | 576 | break; |
574 | } | 577 | } |
575 | } | 578 | } |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 7d46cbd6a07a..add13f507ed2 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -3249,7 +3249,7 @@ xlog_recover_process_iunlinks( | |||
3249 | * next inode in the bucket. | 3249 | * next inode in the bucket. |
3250 | */ | 3250 | */ |
3251 | error = xfs_itobp(mp, NULL, ip, &dip, | 3251 | error = xfs_itobp(mp, NULL, ip, &dip, |
3252 | &ibp, 0); | 3252 | &ibp, 0, 0); |
3253 | ASSERT(error || (dip != NULL)); | 3253 | ASSERT(error || (dip != NULL)); |
3254 | } | 3254 | } |
3255 | 3255 | ||
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 62188ea392c7..20e8abc16d18 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -51,11 +51,32 @@ STATIC int xfs_uuid_mount(xfs_mount_t *); | |||
51 | STATIC void xfs_uuid_unmount(xfs_mount_t *mp); | 51 | STATIC void xfs_uuid_unmount(xfs_mount_t *mp); |
52 | STATIC void xfs_unmountfs_wait(xfs_mount_t *); | 52 | STATIC void xfs_unmountfs_wait(xfs_mount_t *); |
53 | 53 | ||
54 | |||
55 | #ifdef HAVE_PERCPU_SB | ||
56 | STATIC void xfs_icsb_destroy_counters(xfs_mount_t *); | ||
57 | STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t, int); | ||
58 | STATIC void xfs_icsb_sync_counters(xfs_mount_t *); | ||
59 | STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t, | ||
60 | int, int); | ||
61 | STATIC int xfs_icsb_modify_counters_locked(xfs_mount_t *, xfs_sb_field_t, | ||
62 | int, int); | ||
63 | STATIC int xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t); | ||
64 | |||
65 | #else | ||
66 | |||
67 | #define xfs_icsb_destroy_counters(mp) do { } while (0) | ||
68 | #define xfs_icsb_balance_counter(mp, a, b) do { } while (0) | ||
69 | #define xfs_icsb_sync_counters(mp) do { } while (0) | ||
70 | #define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0) | ||
71 | #define xfs_icsb_modify_counters_locked(mp, a, b, c) do { } while (0) | ||
72 | |||
73 | #endif | ||
74 | |||
54 | static const struct { | 75 | static const struct { |
55 | short offset; | 76 | short offset; |
56 | short type; /* 0 = integer | 77 | short type; /* 0 = integer |
57 | * 1 = binary / string (no translation) | 78 | * 1 = binary / string (no translation) |
58 | */ | 79 | */ |
59 | } xfs_sb_info[] = { | 80 | } xfs_sb_info[] = { |
60 | { offsetof(xfs_sb_t, sb_magicnum), 0 }, | 81 | { offsetof(xfs_sb_t, sb_magicnum), 0 }, |
61 | { offsetof(xfs_sb_t, sb_blocksize), 0 }, | 82 | { offsetof(xfs_sb_t, sb_blocksize), 0 }, |
@@ -113,7 +134,11 @@ xfs_mount_init(void) | |||
113 | { | 134 | { |
114 | xfs_mount_t *mp; | 135 | xfs_mount_t *mp; |
115 | 136 | ||
116 | mp = kmem_zalloc(sizeof(*mp), KM_SLEEP); | 137 | mp = kmem_zalloc(sizeof(xfs_mount_t), KM_SLEEP); |
138 | |||
139 | if (xfs_icsb_init_counters(mp)) { | ||
140 | mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; | ||
141 | } | ||
117 | 142 | ||
118 | AIL_LOCKINIT(&mp->m_ail_lock, "xfs_ail"); | 143 | AIL_LOCKINIT(&mp->m_ail_lock, "xfs_ail"); |
119 | spinlock_init(&mp->m_sb_lock, "xfs_sb"); | 144 | spinlock_init(&mp->m_sb_lock, "xfs_sb"); |
@@ -136,8 +161,8 @@ xfs_mount_init(void) | |||
136 | */ | 161 | */ |
137 | void | 162 | void |
138 | xfs_mount_free( | 163 | xfs_mount_free( |
139 | xfs_mount_t *mp, | 164 | xfs_mount_t *mp, |
140 | int remove_bhv) | 165 | int remove_bhv) |
141 | { | 166 | { |
142 | if (mp->m_ihash) | 167 | if (mp->m_ihash) |
143 | xfs_ihash_free(mp); | 168 | xfs_ihash_free(mp); |
@@ -177,6 +202,7 @@ xfs_mount_free( | |||
177 | VFS_REMOVEBHV(vfsp, &mp->m_bhv); | 202 | VFS_REMOVEBHV(vfsp, &mp->m_bhv); |
178 | } | 203 | } |
179 | 204 | ||
205 | xfs_icsb_destroy_counters(mp); | ||
180 | kmem_free(mp, sizeof(xfs_mount_t)); | 206 | kmem_free(mp, sizeof(xfs_mount_t)); |
181 | } | 207 | } |
182 | 208 | ||
@@ -242,9 +268,12 @@ xfs_mount_validate_sb( | |||
242 | sbp->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG || | 268 | sbp->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG || |
243 | sbp->sb_inodesize < XFS_DINODE_MIN_SIZE || | 269 | sbp->sb_inodesize < XFS_DINODE_MIN_SIZE || |
244 | sbp->sb_inodesize > XFS_DINODE_MAX_SIZE || | 270 | sbp->sb_inodesize > XFS_DINODE_MAX_SIZE || |
271 | sbp->sb_inodelog < XFS_DINODE_MIN_LOG || | ||
272 | sbp->sb_inodelog > XFS_DINODE_MAX_LOG || | ||
273 | (sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) || | ||
245 | (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) || | 274 | (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) || |
246 | (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) || | 275 | (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) || |
247 | sbp->sb_imax_pct > 100)) { | 276 | (sbp->sb_imax_pct > 100 || sbp->sb_imax_pct < 1))) { |
248 | cmn_err(CE_WARN, "XFS: SB sanity check 1 failed"); | 277 | cmn_err(CE_WARN, "XFS: SB sanity check 1 failed"); |
249 | XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(3)", | 278 | XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(3)", |
250 | XFS_ERRLEVEL_LOW, mp, sbp); | 279 | XFS_ERRLEVEL_LOW, mp, sbp); |
@@ -527,6 +556,10 @@ xfs_readsb(xfs_mount_t *mp) | |||
527 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 556 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); |
528 | } | 557 | } |
529 | 558 | ||
559 | xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0); | ||
560 | xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0); | ||
561 | xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0); | ||
562 | |||
530 | mp->m_sb_bp = bp; | 563 | mp->m_sb_bp = bp; |
531 | xfs_buf_relse(bp); | 564 | xfs_buf_relse(bp); |
532 | ASSERT(XFS_BUF_VALUSEMA(bp) > 0); | 565 | ASSERT(XFS_BUF_VALUSEMA(bp) > 0); |
@@ -1154,6 +1187,9 @@ xfs_unmountfs_writesb(xfs_mount_t *mp) | |||
1154 | sbp = xfs_getsb(mp, 0); | 1187 | sbp = xfs_getsb(mp, 0); |
1155 | if (!(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY || | 1188 | if (!(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY || |
1156 | XFS_FORCED_SHUTDOWN(mp))) { | 1189 | XFS_FORCED_SHUTDOWN(mp))) { |
1190 | |||
1191 | xfs_icsb_sync_counters(mp); | ||
1192 | |||
1157 | /* | 1193 | /* |
1158 | * mark shared-readonly if desired | 1194 | * mark shared-readonly if desired |
1159 | */ | 1195 | */ |
@@ -1227,7 +1263,6 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields) | |||
1227 | 1263 | ||
1228 | xfs_trans_log_buf(tp, bp, first, last); | 1264 | xfs_trans_log_buf(tp, bp, first, last); |
1229 | } | 1265 | } |
1230 | |||
1231 | /* | 1266 | /* |
1232 | * xfs_mod_incore_sb_unlocked() is a utility routine common used to apply | 1267 | * xfs_mod_incore_sb_unlocked() is a utility routine common used to apply |
1233 | * a delta to a specified field in the in-core superblock. Simply | 1268 | * a delta to a specified field in the in-core superblock. Simply |
@@ -1237,7 +1272,7 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields) | |||
1237 | * | 1272 | * |
1238 | * The SB_LOCK must be held when this routine is called. | 1273 | * The SB_LOCK must be held when this routine is called. |
1239 | */ | 1274 | */ |
1240 | STATIC int | 1275 | int |
1241 | xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field, | 1276 | xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field, |
1242 | int delta, int rsvd) | 1277 | int delta, int rsvd) |
1243 | { | 1278 | { |
@@ -1406,9 +1441,26 @@ xfs_mod_incore_sb(xfs_mount_t *mp, xfs_sb_field_t field, int delta, int rsvd) | |||
1406 | unsigned long s; | 1441 | unsigned long s; |
1407 | int status; | 1442 | int status; |
1408 | 1443 | ||
1409 | s = XFS_SB_LOCK(mp); | 1444 | /* check for per-cpu counters */ |
1410 | status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); | 1445 | switch (field) { |
1411 | XFS_SB_UNLOCK(mp, s); | 1446 | #ifdef HAVE_PERCPU_SB |
1447 | case XFS_SBS_ICOUNT: | ||
1448 | case XFS_SBS_IFREE: | ||
1449 | case XFS_SBS_FDBLOCKS: | ||
1450 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { | ||
1451 | status = xfs_icsb_modify_counters(mp, field, | ||
1452 | delta, rsvd); | ||
1453 | break; | ||
1454 | } | ||
1455 | /* FALLTHROUGH */ | ||
1456 | #endif | ||
1457 | default: | ||
1458 | s = XFS_SB_LOCK(mp); | ||
1459 | status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); | ||
1460 | XFS_SB_UNLOCK(mp, s); | ||
1461 | break; | ||
1462 | } | ||
1463 | |||
1412 | return status; | 1464 | return status; |
1413 | } | 1465 | } |
1414 | 1466 | ||
@@ -1445,8 +1497,26 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | |||
1445 | * from the loop so we'll fall into the undo loop | 1497 | * from the loop so we'll fall into the undo loop |
1446 | * below. | 1498 | * below. |
1447 | */ | 1499 | */ |
1448 | status = xfs_mod_incore_sb_unlocked(mp, msbp->msb_field, | 1500 | switch (msbp->msb_field) { |
1449 | msbp->msb_delta, rsvd); | 1501 | #ifdef HAVE_PERCPU_SB |
1502 | case XFS_SBS_ICOUNT: | ||
1503 | case XFS_SBS_IFREE: | ||
1504 | case XFS_SBS_FDBLOCKS: | ||
1505 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { | ||
1506 | status = xfs_icsb_modify_counters_locked(mp, | ||
1507 | msbp->msb_field, | ||
1508 | msbp->msb_delta, rsvd); | ||
1509 | break; | ||
1510 | } | ||
1511 | /* FALLTHROUGH */ | ||
1512 | #endif | ||
1513 | default: | ||
1514 | status = xfs_mod_incore_sb_unlocked(mp, | ||
1515 | msbp->msb_field, | ||
1516 | msbp->msb_delta, rsvd); | ||
1517 | break; | ||
1518 | } | ||
1519 | |||
1450 | if (status != 0) { | 1520 | if (status != 0) { |
1451 | break; | 1521 | break; |
1452 | } | 1522 | } |
@@ -1463,8 +1533,28 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) | |||
1463 | if (status != 0) { | 1533 | if (status != 0) { |
1464 | msbp--; | 1534 | msbp--; |
1465 | while (msbp >= msb) { | 1535 | while (msbp >= msb) { |
1466 | status = xfs_mod_incore_sb_unlocked(mp, | 1536 | switch (msbp->msb_field) { |
1467 | msbp->msb_field, -(msbp->msb_delta), rsvd); | 1537 | #ifdef HAVE_PERCPU_SB |
1538 | case XFS_SBS_ICOUNT: | ||
1539 | case XFS_SBS_IFREE: | ||
1540 | case XFS_SBS_FDBLOCKS: | ||
1541 | if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { | ||
1542 | status = | ||
1543 | xfs_icsb_modify_counters_locked(mp, | ||
1544 | msbp->msb_field, | ||
1545 | -(msbp->msb_delta), | ||
1546 | rsvd); | ||
1547 | break; | ||
1548 | } | ||
1549 | /* FALLTHROUGH */ | ||
1550 | #endif | ||
1551 | default: | ||
1552 | status = xfs_mod_incore_sb_unlocked(mp, | ||
1553 | msbp->msb_field, | ||
1554 | -(msbp->msb_delta), | ||
1555 | rsvd); | ||
1556 | break; | ||
1557 | } | ||
1468 | ASSERT(status == 0); | 1558 | ASSERT(status == 0); |
1469 | msbp--; | 1559 | msbp--; |
1470 | } | 1560 | } |
@@ -1577,3 +1667,525 @@ xfs_mount_log_sbunit( | |||
1577 | xfs_mod_sb(tp, fields); | 1667 | xfs_mod_sb(tp, fields); |
1578 | xfs_trans_commit(tp, 0, NULL); | 1668 | xfs_trans_commit(tp, 0, NULL); |
1579 | } | 1669 | } |
1670 | |||
1671 | |||
1672 | #ifdef HAVE_PERCPU_SB | ||
1673 | /* | ||
1674 | * Per-cpu incore superblock counters | ||
1675 | * | ||
1676 | * Simple concept, difficult implementation | ||
1677 | * | ||
1678 | * Basically, replace the incore superblock counters with a distributed per cpu | ||
1679 | * counter for contended fields (e.g. free block count). | ||
1680 | * | ||
1681 | * Difficulties arise in that the incore sb is used for ENOSPC checking, and | ||
1682 | * hence needs to be accurately read when we are running low on space. Hence | ||
1683 | * there is a method to enable and disable the per-cpu counters based on how | ||
1684 | * much "stuff" is available in them. | ||
1685 | * | ||
1686 | * Basically, a counter is enabled if there is enough free resource to justify | ||
1687 | * running a per-cpu fast-path. If the per-cpu counter runs out (i.e. a local | ||
1688 | * ENOSPC), then we disable the counters to synchronise all callers and | ||
1689 | * re-distribute the available resources. | ||
1690 | * | ||
1691 | * If, once we redistributed the available resources, we still get a failure, | ||
1692 | * we disable the per-cpu counter and go through the slow path. | ||
1693 | * | ||
1694 | * The slow path is the current xfs_mod_incore_sb() function. This means that | ||
1695 | * when we disable a per-cpu counter, we need to drain it's resources back to | ||
1696 | * the global superblock. We do this after disabling the counter to prevent | ||
1697 | * more threads from queueing up on the counter. | ||
1698 | * | ||
1699 | * Essentially, this means that we still need a lock in the fast path to enable | ||
1700 | * synchronisation between the global counters and the per-cpu counters. This | ||
1701 | * is not a problem because the lock will be local to a CPU almost all the time | ||
1702 | * and have little contention except when we get to ENOSPC conditions. | ||
1703 | * | ||
1704 | * Basically, this lock becomes a barrier that enables us to lock out the fast | ||
1705 | * path while we do things like enabling and disabling counters and | ||
1706 | * synchronising the counters. | ||
1707 | * | ||
1708 | * Locking rules: | ||
1709 | * | ||
1710 | * 1. XFS_SB_LOCK() before picking up per-cpu locks | ||
1711 | * 2. per-cpu locks always picked up via for_each_online_cpu() order | ||
1712 | * 3. accurate counter sync requires XFS_SB_LOCK + per cpu locks | ||
1713 | * 4. modifying per-cpu counters requires holding per-cpu lock | ||
1714 | * 5. modifying global counters requires holding XFS_SB_LOCK | ||
1715 | * 6. enabling or disabling a counter requires holding the XFS_SB_LOCK | ||
1716 | * and _none_ of the per-cpu locks. | ||
1717 | * | ||
1718 | * Disabled counters are only ever re-enabled by a balance operation | ||
1719 | * that results in more free resources per CPU than a given threshold. | ||
1720 | * To ensure counters don't remain disabled, they are rebalanced when | ||
1721 | * the global resource goes above a higher threshold (i.e. some hysteresis | ||
1722 | * is present to prevent thrashing). | ||
1723 | */ | ||
1724 | |||
1725 | /* | ||
1726 | * hot-plug CPU notifier support. | ||
1727 | * | ||
1728 | * We cannot use the hotcpu_register() function because it does | ||
1729 | * not allow notifier instances. We need a notifier per filesystem | ||
1730 | * as we need to be able to identify the filesystem to balance | ||
1731 | * the counters out. This is acheived by having a notifier block | ||
1732 | * embedded in the xfs_mount_t and doing pointer magic to get the | ||
1733 | * mount pointer from the notifier block address. | ||
1734 | */ | ||
1735 | STATIC int | ||
1736 | xfs_icsb_cpu_notify( | ||
1737 | struct notifier_block *nfb, | ||
1738 | unsigned long action, | ||
1739 | void *hcpu) | ||
1740 | { | ||
1741 | xfs_icsb_cnts_t *cntp; | ||
1742 | xfs_mount_t *mp; | ||
1743 | int s; | ||
1744 | |||
1745 | mp = (xfs_mount_t *)container_of(nfb, xfs_mount_t, m_icsb_notifier); | ||
1746 | cntp = (xfs_icsb_cnts_t *) | ||
1747 | per_cpu_ptr(mp->m_sb_cnts, (unsigned long)hcpu); | ||
1748 | switch (action) { | ||
1749 | case CPU_UP_PREPARE: | ||
1750 | /* Easy Case - initialize the area and locks, and | ||
1751 | * then rebalance when online does everything else for us. */ | ||
1752 | memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); | ||
1753 | break; | ||
1754 | case CPU_ONLINE: | ||
1755 | xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0); | ||
1756 | xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0); | ||
1757 | xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0); | ||
1758 | break; | ||
1759 | case CPU_DEAD: | ||
1760 | /* Disable all the counters, then fold the dead cpu's | ||
1761 | * count into the total on the global superblock and | ||
1762 | * re-enable the counters. */ | ||
1763 | s = XFS_SB_LOCK(mp); | ||
1764 | xfs_icsb_disable_counter(mp, XFS_SBS_ICOUNT); | ||
1765 | xfs_icsb_disable_counter(mp, XFS_SBS_IFREE); | ||
1766 | xfs_icsb_disable_counter(mp, XFS_SBS_FDBLOCKS); | ||
1767 | |||
1768 | mp->m_sb.sb_icount += cntp->icsb_icount; | ||
1769 | mp->m_sb.sb_ifree += cntp->icsb_ifree; | ||
1770 | mp->m_sb.sb_fdblocks += cntp->icsb_fdblocks; | ||
1771 | |||
1772 | memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); | ||
1773 | |||
1774 | xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, XFS_ICSB_SB_LOCKED); | ||
1775 | xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, XFS_ICSB_SB_LOCKED); | ||
1776 | xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, XFS_ICSB_SB_LOCKED); | ||
1777 | XFS_SB_UNLOCK(mp, s); | ||
1778 | break; | ||
1779 | } | ||
1780 | |||
1781 | return NOTIFY_OK; | ||
1782 | } | ||
1783 | |||
1784 | int | ||
1785 | xfs_icsb_init_counters( | ||
1786 | xfs_mount_t *mp) | ||
1787 | { | ||
1788 | xfs_icsb_cnts_t *cntp; | ||
1789 | int i; | ||
1790 | |||
1791 | mp->m_sb_cnts = alloc_percpu(xfs_icsb_cnts_t); | ||
1792 | if (mp->m_sb_cnts == NULL) | ||
1793 | return -ENOMEM; | ||
1794 | |||
1795 | mp->m_icsb_notifier.notifier_call = xfs_icsb_cpu_notify; | ||
1796 | mp->m_icsb_notifier.priority = 0; | ||
1797 | register_cpu_notifier(&mp->m_icsb_notifier); | ||
1798 | |||
1799 | for_each_online_cpu(i) { | ||
1800 | cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i); | ||
1801 | memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); | ||
1802 | } | ||
1803 | /* | ||
1804 | * start with all counters disabled so that the | ||
1805 | * initial balance kicks us off correctly | ||
1806 | */ | ||
1807 | mp->m_icsb_counters = -1; | ||
1808 | return 0; | ||
1809 | } | ||
1810 | |||
1811 | STATIC void | ||
1812 | xfs_icsb_destroy_counters( | ||
1813 | xfs_mount_t *mp) | ||
1814 | { | ||
1815 | if (mp->m_sb_cnts) { | ||
1816 | unregister_cpu_notifier(&mp->m_icsb_notifier); | ||
1817 | free_percpu(mp->m_sb_cnts); | ||
1818 | } | ||
1819 | } | ||
1820 | |||
1821 | STATIC inline void | ||
1822 | xfs_icsb_lock_cntr( | ||
1823 | xfs_icsb_cnts_t *icsbp) | ||
1824 | { | ||
1825 | while (test_and_set_bit(XFS_ICSB_FLAG_LOCK, &icsbp->icsb_flags)) { | ||
1826 | ndelay(1000); | ||
1827 | } | ||
1828 | } | ||
1829 | |||
1830 | STATIC inline void | ||
1831 | xfs_icsb_unlock_cntr( | ||
1832 | xfs_icsb_cnts_t *icsbp) | ||
1833 | { | ||
1834 | clear_bit(XFS_ICSB_FLAG_LOCK, &icsbp->icsb_flags); | ||
1835 | } | ||
1836 | |||
1837 | |||
1838 | STATIC inline void | ||
1839 | xfs_icsb_lock_all_counters( | ||
1840 | xfs_mount_t *mp) | ||
1841 | { | ||
1842 | xfs_icsb_cnts_t *cntp; | ||
1843 | int i; | ||
1844 | |||
1845 | for_each_online_cpu(i) { | ||
1846 | cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i); | ||
1847 | xfs_icsb_lock_cntr(cntp); | ||
1848 | } | ||
1849 | } | ||
1850 | |||
1851 | STATIC inline void | ||
1852 | xfs_icsb_unlock_all_counters( | ||
1853 | xfs_mount_t *mp) | ||
1854 | { | ||
1855 | xfs_icsb_cnts_t *cntp; | ||
1856 | int i; | ||
1857 | |||
1858 | for_each_online_cpu(i) { | ||
1859 | cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i); | ||
1860 | xfs_icsb_unlock_cntr(cntp); | ||
1861 | } | ||
1862 | } | ||
1863 | |||
1864 | STATIC void | ||
1865 | xfs_icsb_count( | ||
1866 | xfs_mount_t *mp, | ||
1867 | xfs_icsb_cnts_t *cnt, | ||
1868 | int flags) | ||
1869 | { | ||
1870 | xfs_icsb_cnts_t *cntp; | ||
1871 | int i; | ||
1872 | |||
1873 | memset(cnt, 0, sizeof(xfs_icsb_cnts_t)); | ||
1874 | |||
1875 | if (!(flags & XFS_ICSB_LAZY_COUNT)) | ||
1876 | xfs_icsb_lock_all_counters(mp); | ||
1877 | |||
1878 | for_each_online_cpu(i) { | ||
1879 | cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i); | ||
1880 | cnt->icsb_icount += cntp->icsb_icount; | ||
1881 | cnt->icsb_ifree += cntp->icsb_ifree; | ||
1882 | cnt->icsb_fdblocks += cntp->icsb_fdblocks; | ||
1883 | } | ||
1884 | |||
1885 | if (!(flags & XFS_ICSB_LAZY_COUNT)) | ||
1886 | xfs_icsb_unlock_all_counters(mp); | ||
1887 | } | ||
1888 | |||
1889 | STATIC int | ||
1890 | xfs_icsb_counter_disabled( | ||
1891 | xfs_mount_t *mp, | ||
1892 | xfs_sb_field_t field) | ||
1893 | { | ||
1894 | ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS)); | ||
1895 | return test_bit(field, &mp->m_icsb_counters); | ||
1896 | } | ||
1897 | |||
1898 | STATIC int | ||
1899 | xfs_icsb_disable_counter( | ||
1900 | xfs_mount_t *mp, | ||
1901 | xfs_sb_field_t field) | ||
1902 | { | ||
1903 | xfs_icsb_cnts_t cnt; | ||
1904 | |||
1905 | ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS)); | ||
1906 | |||
1907 | xfs_icsb_lock_all_counters(mp); | ||
1908 | if (!test_and_set_bit(field, &mp->m_icsb_counters)) { | ||
1909 | /* drain back to superblock */ | ||
1910 | |||
1911 | xfs_icsb_count(mp, &cnt, XFS_ICSB_SB_LOCKED|XFS_ICSB_LAZY_COUNT); | ||
1912 | switch(field) { | ||
1913 | case XFS_SBS_ICOUNT: | ||
1914 | mp->m_sb.sb_icount = cnt.icsb_icount; | ||
1915 | break; | ||
1916 | case XFS_SBS_IFREE: | ||
1917 | mp->m_sb.sb_ifree = cnt.icsb_ifree; | ||
1918 | break; | ||
1919 | case XFS_SBS_FDBLOCKS: | ||
1920 | mp->m_sb.sb_fdblocks = cnt.icsb_fdblocks; | ||
1921 | break; | ||
1922 | default: | ||
1923 | BUG(); | ||
1924 | } | ||
1925 | } | ||
1926 | |||
1927 | xfs_icsb_unlock_all_counters(mp); | ||
1928 | |||
1929 | return 0; | ||
1930 | } | ||
1931 | |||
1932 | STATIC void | ||
1933 | xfs_icsb_enable_counter( | ||
1934 | xfs_mount_t *mp, | ||
1935 | xfs_sb_field_t field, | ||
1936 | uint64_t count, | ||
1937 | uint64_t resid) | ||
1938 | { | ||
1939 | xfs_icsb_cnts_t *cntp; | ||
1940 | int i; | ||
1941 | |||
1942 | ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS)); | ||
1943 | |||
1944 | xfs_icsb_lock_all_counters(mp); | ||
1945 | for_each_online_cpu(i) { | ||
1946 | cntp = per_cpu_ptr(mp->m_sb_cnts, i); | ||
1947 | switch (field) { | ||
1948 | case XFS_SBS_ICOUNT: | ||
1949 | cntp->icsb_icount = count + resid; | ||
1950 | break; | ||
1951 | case XFS_SBS_IFREE: | ||
1952 | cntp->icsb_ifree = count + resid; | ||
1953 | break; | ||
1954 | case XFS_SBS_FDBLOCKS: | ||
1955 | cntp->icsb_fdblocks = count + resid; | ||
1956 | break; | ||
1957 | default: | ||
1958 | BUG(); | ||
1959 | break; | ||
1960 | } | ||
1961 | resid = 0; | ||
1962 | } | ||
1963 | clear_bit(field, &mp->m_icsb_counters); | ||
1964 | xfs_icsb_unlock_all_counters(mp); | ||
1965 | } | ||
1966 | |||
1967 | STATIC void | ||
1968 | xfs_icsb_sync_counters_int( | ||
1969 | xfs_mount_t *mp, | ||
1970 | int flags) | ||
1971 | { | ||
1972 | xfs_icsb_cnts_t cnt; | ||
1973 | int s; | ||
1974 | |||
1975 | /* Pass 1: lock all counters */ | ||
1976 | if ((flags & XFS_ICSB_SB_LOCKED) == 0) | ||
1977 | s = XFS_SB_LOCK(mp); | ||
1978 | |||
1979 | xfs_icsb_count(mp, &cnt, flags); | ||
1980 | |||
1981 | /* Step 3: update mp->m_sb fields */ | ||
1982 | if (!xfs_icsb_counter_disabled(mp, XFS_SBS_ICOUNT)) | ||
1983 | mp->m_sb.sb_icount = cnt.icsb_icount; | ||
1984 | if (!xfs_icsb_counter_disabled(mp, XFS_SBS_IFREE)) | ||
1985 | mp->m_sb.sb_ifree = cnt.icsb_ifree; | ||
1986 | if (!xfs_icsb_counter_disabled(mp, XFS_SBS_FDBLOCKS)) | ||
1987 | mp->m_sb.sb_fdblocks = cnt.icsb_fdblocks; | ||
1988 | |||
1989 | if ((flags & XFS_ICSB_SB_LOCKED) == 0) | ||
1990 | XFS_SB_UNLOCK(mp, s); | ||
1991 | } | ||
1992 | |||
1993 | /* | ||
1994 | * Accurate update of per-cpu counters to incore superblock | ||
1995 | */ | ||
1996 | STATIC void | ||
1997 | xfs_icsb_sync_counters( | ||
1998 | xfs_mount_t *mp) | ||
1999 | { | ||
2000 | xfs_icsb_sync_counters_int(mp, 0); | ||
2001 | } | ||
2002 | |||
2003 | /* | ||
2004 | * lazy addition used for things like df, background sb syncs, etc | ||
2005 | */ | ||
2006 | void | ||
2007 | xfs_icsb_sync_counters_lazy( | ||
2008 | xfs_mount_t *mp) | ||
2009 | { | ||
2010 | xfs_icsb_sync_counters_int(mp, XFS_ICSB_LAZY_COUNT); | ||
2011 | } | ||
2012 | |||
2013 | /* | ||
2014 | * Balance and enable/disable counters as necessary. | ||
2015 | * | ||
2016 | * Thresholds for re-enabling counters are somewhat magic. | ||
2017 | * inode counts are chosen to be the same number as single | ||
2018 | * on disk allocation chunk per CPU, and free blocks is | ||
2019 | * something far enough zero that we aren't going thrash | ||
2020 | * when we get near ENOSPC. | ||
2021 | */ | ||
2022 | #define XFS_ICSB_INO_CNTR_REENABLE 64 | ||
2023 | #define XFS_ICSB_FDBLK_CNTR_REENABLE 512 | ||
2024 | STATIC void | ||
2025 | xfs_icsb_balance_counter( | ||
2026 | xfs_mount_t *mp, | ||
2027 | xfs_sb_field_t field, | ||
2028 | int flags) | ||
2029 | { | ||
2030 | uint64_t count, resid = 0; | ||
2031 | int weight = num_online_cpus(); | ||
2032 | int s; | ||
2033 | |||
2034 | if (!(flags & XFS_ICSB_SB_LOCKED)) | ||
2035 | s = XFS_SB_LOCK(mp); | ||
2036 | |||
2037 | /* disable counter and sync counter */ | ||
2038 | xfs_icsb_disable_counter(mp, field); | ||
2039 | |||
2040 | /* update counters - first CPU gets residual*/ | ||
2041 | switch (field) { | ||
2042 | case XFS_SBS_ICOUNT: | ||
2043 | count = mp->m_sb.sb_icount; | ||
2044 | resid = do_div(count, weight); | ||
2045 | if (count < XFS_ICSB_INO_CNTR_REENABLE) | ||
2046 | goto out; | ||
2047 | break; | ||
2048 | case XFS_SBS_IFREE: | ||
2049 | count = mp->m_sb.sb_ifree; | ||
2050 | resid = do_div(count, weight); | ||
2051 | if (count < XFS_ICSB_INO_CNTR_REENABLE) | ||
2052 | goto out; | ||
2053 | break; | ||
2054 | case XFS_SBS_FDBLOCKS: | ||
2055 | count = mp->m_sb.sb_fdblocks; | ||
2056 | resid = do_div(count, weight); | ||
2057 | if (count < XFS_ICSB_FDBLK_CNTR_REENABLE) | ||
2058 | goto out; | ||
2059 | break; | ||
2060 | default: | ||
2061 | BUG(); | ||
2062 | break; | ||
2063 | } | ||
2064 | |||
2065 | xfs_icsb_enable_counter(mp, field, count, resid); | ||
2066 | out: | ||
2067 | if (!(flags & XFS_ICSB_SB_LOCKED)) | ||
2068 | XFS_SB_UNLOCK(mp, s); | ||
2069 | } | ||
2070 | |||
2071 | STATIC int | ||
2072 | xfs_icsb_modify_counters_int( | ||
2073 | xfs_mount_t *mp, | ||
2074 | xfs_sb_field_t field, | ||
2075 | int delta, | ||
2076 | int rsvd, | ||
2077 | int flags) | ||
2078 | { | ||
2079 | xfs_icsb_cnts_t *icsbp; | ||
2080 | long long lcounter; /* long counter for 64 bit fields */ | ||
2081 | int cpu, s, locked = 0; | ||
2082 | int ret = 0, balance_done = 0; | ||
2083 | |||
2084 | again: | ||
2085 | cpu = get_cpu(); | ||
2086 | icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu), | ||
2087 | xfs_icsb_lock_cntr(icsbp); | ||
2088 | if (unlikely(xfs_icsb_counter_disabled(mp, field))) | ||
2089 | goto slow_path; | ||
2090 | |||
2091 | switch (field) { | ||
2092 | case XFS_SBS_ICOUNT: | ||
2093 | lcounter = icsbp->icsb_icount; | ||
2094 | lcounter += delta; | ||
2095 | if (unlikely(lcounter < 0)) | ||
2096 | goto slow_path; | ||
2097 | icsbp->icsb_icount = lcounter; | ||
2098 | break; | ||
2099 | |||
2100 | case XFS_SBS_IFREE: | ||
2101 | lcounter = icsbp->icsb_ifree; | ||
2102 | lcounter += delta; | ||
2103 | if (unlikely(lcounter < 0)) | ||
2104 | goto slow_path; | ||
2105 | icsbp->icsb_ifree = lcounter; | ||
2106 | break; | ||
2107 | |||
2108 | case XFS_SBS_FDBLOCKS: | ||
2109 | BUG_ON((mp->m_resblks - mp->m_resblks_avail) != 0); | ||
2110 | |||
2111 | lcounter = icsbp->icsb_fdblocks; | ||
2112 | lcounter += delta; | ||
2113 | if (unlikely(lcounter < 0)) | ||
2114 | goto slow_path; | ||
2115 | icsbp->icsb_fdblocks = lcounter; | ||
2116 | break; | ||
2117 | default: | ||
2118 | BUG(); | ||
2119 | break; | ||
2120 | } | ||
2121 | xfs_icsb_unlock_cntr(icsbp); | ||
2122 | put_cpu(); | ||
2123 | if (locked) | ||
2124 | XFS_SB_UNLOCK(mp, s); | ||
2125 | return 0; | ||
2126 | |||
2127 | /* | ||
2128 | * The slow path needs to be run with the SBLOCK | ||
2129 | * held so that we prevent other threads from | ||
2130 | * attempting to run this path at the same time. | ||
2131 | * this provides exclusion for the balancing code, | ||
2132 | * and exclusive fallback if the balance does not | ||
2133 | * provide enough resources to continue in an unlocked | ||
2134 | * manner. | ||
2135 | */ | ||
2136 | slow_path: | ||
2137 | xfs_icsb_unlock_cntr(icsbp); | ||
2138 | put_cpu(); | ||
2139 | |||
2140 | /* need to hold superblock incase we need | ||
2141 | * to disable a counter */ | ||
2142 | if (!(flags & XFS_ICSB_SB_LOCKED)) { | ||
2143 | s = XFS_SB_LOCK(mp); | ||
2144 | locked = 1; | ||
2145 | flags |= XFS_ICSB_SB_LOCKED; | ||
2146 | } | ||
2147 | if (!balance_done) { | ||
2148 | xfs_icsb_balance_counter(mp, field, flags); | ||
2149 | balance_done = 1; | ||
2150 | goto again; | ||
2151 | } else { | ||
2152 | /* | ||
2153 | * we might not have enough on this local | ||
2154 | * cpu to allocate for a bulk request. | ||
2155 | * We need to drain this field from all CPUs | ||
2156 | * and disable the counter fastpath | ||
2157 | */ | ||
2158 | xfs_icsb_disable_counter(mp, field); | ||
2159 | } | ||
2160 | |||
2161 | ret = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); | ||
2162 | |||
2163 | if (locked) | ||
2164 | XFS_SB_UNLOCK(mp, s); | ||
2165 | return ret; | ||
2166 | } | ||
2167 | |||
2168 | STATIC int | ||
2169 | xfs_icsb_modify_counters( | ||
2170 | xfs_mount_t *mp, | ||
2171 | xfs_sb_field_t field, | ||
2172 | int delta, | ||
2173 | int rsvd) | ||
2174 | { | ||
2175 | return xfs_icsb_modify_counters_int(mp, field, delta, rsvd, 0); | ||
2176 | } | ||
2177 | |||
2178 | /* | ||
2179 | * Called when superblock is already locked | ||
2180 | */ | ||
2181 | STATIC int | ||
2182 | xfs_icsb_modify_counters_locked( | ||
2183 | xfs_mount_t *mp, | ||
2184 | xfs_sb_field_t field, | ||
2185 | int delta, | ||
2186 | int rsvd) | ||
2187 | { | ||
2188 | return xfs_icsb_modify_counters_int(mp, field, delta, | ||
2189 | rsvd, XFS_ICSB_SB_LOCKED); | ||
2190 | } | ||
2191 | #endif | ||
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index cd3cf9613a00..ebd73960e9db 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -267,6 +267,34 @@ typedef struct xfs_ioops { | |||
267 | #define XFS_IODONE(vfsp) \ | 267 | #define XFS_IODONE(vfsp) \ |
268 | (*(mp)->m_io_ops.xfs_iodone)(vfsp) | 268 | (*(mp)->m_io_ops.xfs_iodone)(vfsp) |
269 | 269 | ||
270 | #ifdef HAVE_PERCPU_SB | ||
271 | |||
272 | /* | ||
273 | * Valid per-cpu incore superblock counters. Note that if you add new counters, | ||
274 | * you may need to define new counter disabled bit field descriptors as there | ||
275 | * are more possible fields in the superblock that can fit in a bitfield on a | ||
276 | * 32 bit platform. The XFS_SBS_* values for the current current counters just | ||
277 | * fit. | ||
278 | */ | ||
279 | typedef struct xfs_icsb_cnts { | ||
280 | uint64_t icsb_fdblocks; | ||
281 | uint64_t icsb_ifree; | ||
282 | uint64_t icsb_icount; | ||
283 | unsigned long icsb_flags; | ||
284 | } xfs_icsb_cnts_t; | ||
285 | |||
286 | #define XFS_ICSB_FLAG_LOCK (1 << 0) /* counter lock bit */ | ||
287 | |||
288 | #define XFS_ICSB_SB_LOCKED (1 << 0) /* sb already locked */ | ||
289 | #define XFS_ICSB_LAZY_COUNT (1 << 1) /* accuracy not needed */ | ||
290 | |||
291 | extern int xfs_icsb_init_counters(struct xfs_mount *); | ||
292 | extern void xfs_icsb_sync_counters_lazy(struct xfs_mount *); | ||
293 | |||
294 | #else | ||
295 | #define xfs_icsb_init_counters(mp) (0) | ||
296 | #define xfs_icsb_sync_counters_lazy(mp) do { } while (0) | ||
297 | #endif | ||
270 | 298 | ||
271 | typedef struct xfs_mount { | 299 | typedef struct xfs_mount { |
272 | bhv_desc_t m_bhv; /* vfs xfs behavior */ | 300 | bhv_desc_t m_bhv; /* vfs xfs behavior */ |
@@ -372,6 +400,11 @@ typedef struct xfs_mount { | |||
372 | struct xfs_qmops m_qm_ops; /* vector of XQM ops */ | 400 | struct xfs_qmops m_qm_ops; /* vector of XQM ops */ |
373 | struct xfs_ioops m_io_ops; /* vector of I/O ops */ | 401 | struct xfs_ioops m_io_ops; /* vector of I/O ops */ |
374 | atomic_t m_active_trans; /* number trans frozen */ | 402 | atomic_t m_active_trans; /* number trans frozen */ |
403 | #ifdef HAVE_PERCPU_SB | ||
404 | xfs_icsb_cnts_t *m_sb_cnts; /* per-cpu superblock counters */ | ||
405 | unsigned long m_icsb_counters; /* disabled per-cpu counters */ | ||
406 | struct notifier_block m_icsb_notifier; /* hotplug cpu notifier */ | ||
407 | #endif | ||
375 | } xfs_mount_t; | 408 | } xfs_mount_t; |
376 | 409 | ||
377 | /* | 410 | /* |
@@ -386,8 +419,6 @@ typedef struct xfs_mount { | |||
386 | #define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem | 419 | #define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem |
387 | operations, typically for | 420 | operations, typically for |
388 | disk errors in metadata */ | 421 | disk errors in metadata */ |
389 | #define XFS_MOUNT_NOATIME (1ULL << 5) /* don't modify inode access | ||
390 | times on reads */ | ||
391 | #define XFS_MOUNT_RETERR (1ULL << 6) /* return alignment errors to | 422 | #define XFS_MOUNT_RETERR (1ULL << 6) /* return alignment errors to |
392 | user */ | 423 | user */ |
393 | #define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment | 424 | #define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment |
@@ -411,6 +442,8 @@ typedef struct xfs_mount { | |||
411 | #define XFS_MOUNT_DIRSYNC (1ULL << 21) /* synchronous directory ops */ | 442 | #define XFS_MOUNT_DIRSYNC (1ULL << 21) /* synchronous directory ops */ |
412 | #define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22) /* don't report large preferred | 443 | #define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22) /* don't report large preferred |
413 | * I/O size in stat() */ | 444 | * I/O size in stat() */ |
445 | #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock | ||
446 | counters */ | ||
414 | 447 | ||
415 | 448 | ||
416 | /* | 449 | /* |
@@ -473,11 +506,6 @@ xfs_preferred_iosize(xfs_mount_t *mp) | |||
473 | #define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* Shutdown came from remote cell */ | 506 | #define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* Shutdown came from remote cell */ |
474 | 507 | ||
475 | /* | 508 | /* |
476 | * xflags for xfs_syncsub | ||
477 | */ | ||
478 | #define XFS_XSYNC_RELOC 0x01 | ||
479 | |||
480 | /* | ||
481 | * Flags for xfs_mountfs | 509 | * Flags for xfs_mountfs |
482 | */ | 510 | */ |
483 | #define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */ | 511 | #define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */ |
@@ -548,6 +576,8 @@ extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); | |||
548 | extern int xfs_unmountfs_writesb(xfs_mount_t *); | 576 | extern int xfs_unmountfs_writesb(xfs_mount_t *); |
549 | extern int xfs_unmount_flush(xfs_mount_t *, int); | 577 | extern int xfs_unmount_flush(xfs_mount_t *, int); |
550 | extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int); | 578 | extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int); |
579 | extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t, | ||
580 | int, int); | ||
551 | extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, | 581 | extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, |
552 | uint, int); | 582 | uint, int); |
553 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); | 583 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); |
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h index de85eefb7966..e63795644478 100644 --- a/fs/xfs/xfs_rw.h +++ b/fs/xfs/xfs_rw.h | |||
@@ -89,6 +89,7 @@ extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp, | |||
89 | */ | 89 | */ |
90 | extern int xfs_rwlock(bhv_desc_t *bdp, vrwlock_t write_lock); | 90 | extern int xfs_rwlock(bhv_desc_t *bdp, vrwlock_t write_lock); |
91 | extern void xfs_rwunlock(bhv_desc_t *bdp, vrwlock_t write_lock); | 91 | extern void xfs_rwunlock(bhv_desc_t *bdp, vrwlock_t write_lock); |
92 | extern int xfs_setattr(bhv_desc_t *bdp, vattr_t *vap, int flags, cred_t *credp); | ||
92 | extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf, | 93 | extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf, |
93 | xfs_off_t offset, cred_t *credp, int flags); | 94 | xfs_off_t offset, cred_t *credp, int flags); |
94 | extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state, | 95 | extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state, |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index d3d714e6b32a..2918956553a5 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -55,10 +55,141 @@ STATIC void xfs_trans_committed(xfs_trans_t *, int); | |||
55 | STATIC void xfs_trans_chunk_committed(xfs_log_item_chunk_t *, xfs_lsn_t, int); | 55 | STATIC void xfs_trans_chunk_committed(xfs_log_item_chunk_t *, xfs_lsn_t, int); |
56 | STATIC void xfs_trans_free(xfs_trans_t *); | 56 | STATIC void xfs_trans_free(xfs_trans_t *); |
57 | 57 | ||
58 | kmem_zone_t *xfs_trans_zone; | 58 | kmem_zone_t *xfs_trans_zone; |
59 | 59 | ||
60 | 60 | ||
61 | /* | 61 | /* |
62 | * Reservation functions here avoid a huge stack in xfs_trans_init | ||
63 | * due to register overflow from temporaries in the calculations. | ||
64 | */ | ||
65 | |||
66 | STATIC uint | ||
67 | xfs_calc_write_reservation(xfs_mount_t *mp) | ||
68 | { | ||
69 | return XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
70 | } | ||
71 | |||
72 | STATIC uint | ||
73 | xfs_calc_itruncate_reservation(xfs_mount_t *mp) | ||
74 | { | ||
75 | return XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
76 | } | ||
77 | |||
78 | STATIC uint | ||
79 | xfs_calc_rename_reservation(xfs_mount_t *mp) | ||
80 | { | ||
81 | return XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
82 | } | ||
83 | |||
84 | STATIC uint | ||
85 | xfs_calc_link_reservation(xfs_mount_t *mp) | ||
86 | { | ||
87 | return XFS_CALC_LINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
88 | } | ||
89 | |||
90 | STATIC uint | ||
91 | xfs_calc_remove_reservation(xfs_mount_t *mp) | ||
92 | { | ||
93 | return XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
94 | } | ||
95 | |||
96 | STATIC uint | ||
97 | xfs_calc_symlink_reservation(xfs_mount_t *mp) | ||
98 | { | ||
99 | return XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
100 | } | ||
101 | |||
102 | STATIC uint | ||
103 | xfs_calc_create_reservation(xfs_mount_t *mp) | ||
104 | { | ||
105 | return XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
106 | } | ||
107 | |||
108 | STATIC uint | ||
109 | xfs_calc_mkdir_reservation(xfs_mount_t *mp) | ||
110 | { | ||
111 | return XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
112 | } | ||
113 | |||
114 | STATIC uint | ||
115 | xfs_calc_ifree_reservation(xfs_mount_t *mp) | ||
116 | { | ||
117 | return XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
118 | } | ||
119 | |||
120 | STATIC uint | ||
121 | xfs_calc_ichange_reservation(xfs_mount_t *mp) | ||
122 | { | ||
123 | return XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
124 | } | ||
125 | |||
126 | STATIC uint | ||
127 | xfs_calc_growdata_reservation(xfs_mount_t *mp) | ||
128 | { | ||
129 | return XFS_CALC_GROWDATA_LOG_RES(mp); | ||
130 | } | ||
131 | |||
132 | STATIC uint | ||
133 | xfs_calc_growrtalloc_reservation(xfs_mount_t *mp) | ||
134 | { | ||
135 | return XFS_CALC_GROWRTALLOC_LOG_RES(mp); | ||
136 | } | ||
137 | |||
138 | STATIC uint | ||
139 | xfs_calc_growrtzero_reservation(xfs_mount_t *mp) | ||
140 | { | ||
141 | return XFS_CALC_GROWRTZERO_LOG_RES(mp); | ||
142 | } | ||
143 | |||
144 | STATIC uint | ||
145 | xfs_calc_growrtfree_reservation(xfs_mount_t *mp) | ||
146 | { | ||
147 | return XFS_CALC_GROWRTFREE_LOG_RES(mp); | ||
148 | } | ||
149 | |||
150 | STATIC uint | ||
151 | xfs_calc_swrite_reservation(xfs_mount_t *mp) | ||
152 | { | ||
153 | return XFS_CALC_SWRITE_LOG_RES(mp); | ||
154 | } | ||
155 | |||
156 | STATIC uint | ||
157 | xfs_calc_writeid_reservation(xfs_mount_t *mp) | ||
158 | { | ||
159 | return XFS_CALC_WRITEID_LOG_RES(mp); | ||
160 | } | ||
161 | |||
162 | STATIC uint | ||
163 | xfs_calc_addafork_reservation(xfs_mount_t *mp) | ||
164 | { | ||
165 | return XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
166 | } | ||
167 | |||
168 | STATIC uint | ||
169 | xfs_calc_attrinval_reservation(xfs_mount_t *mp) | ||
170 | { | ||
171 | return XFS_CALC_ATTRINVAL_LOG_RES(mp); | ||
172 | } | ||
173 | |||
174 | STATIC uint | ||
175 | xfs_calc_attrset_reservation(xfs_mount_t *mp) | ||
176 | { | ||
177 | return XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
178 | } | ||
179 | |||
180 | STATIC uint | ||
181 | xfs_calc_attrrm_reservation(xfs_mount_t *mp) | ||
182 | { | ||
183 | return XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp); | ||
184 | } | ||
185 | |||
186 | STATIC uint | ||
187 | xfs_calc_clear_agi_bucket_reservation(xfs_mount_t *mp) | ||
188 | { | ||
189 | return XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp); | ||
190 | } | ||
191 | |||
192 | /* | ||
62 | * Initialize the precomputed transaction reservation values | 193 | * Initialize the precomputed transaction reservation values |
63 | * in the mount structure. | 194 | * in the mount structure. |
64 | */ | 195 | */ |
@@ -69,39 +200,27 @@ xfs_trans_init( | |||
69 | xfs_trans_reservations_t *resp; | 200 | xfs_trans_reservations_t *resp; |
70 | 201 | ||
71 | resp = &(mp->m_reservations); | 202 | resp = &(mp->m_reservations); |
72 | resp->tr_write = | 203 | resp->tr_write = xfs_calc_write_reservation(mp); |
73 | (uint)(XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 204 | resp->tr_itruncate = xfs_calc_itruncate_reservation(mp); |
74 | resp->tr_itruncate = | 205 | resp->tr_rename = xfs_calc_rename_reservation(mp); |
75 | (uint)(XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 206 | resp->tr_link = xfs_calc_link_reservation(mp); |
76 | resp->tr_rename = | 207 | resp->tr_remove = xfs_calc_remove_reservation(mp); |
77 | (uint)(XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 208 | resp->tr_symlink = xfs_calc_symlink_reservation(mp); |
78 | resp->tr_link = (uint)XFS_CALC_LINK_LOG_RES(mp); | 209 | resp->tr_create = xfs_calc_create_reservation(mp); |
79 | resp->tr_remove = | 210 | resp->tr_mkdir = xfs_calc_mkdir_reservation(mp); |
80 | (uint)(XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 211 | resp->tr_ifree = xfs_calc_ifree_reservation(mp); |
81 | resp->tr_symlink = | 212 | resp->tr_ichange = xfs_calc_ichange_reservation(mp); |
82 | (uint)(XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 213 | resp->tr_growdata = xfs_calc_growdata_reservation(mp); |
83 | resp->tr_create = | 214 | resp->tr_swrite = xfs_calc_swrite_reservation(mp); |
84 | (uint)(XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 215 | resp->tr_writeid = xfs_calc_writeid_reservation(mp); |
85 | resp->tr_mkdir = | 216 | resp->tr_addafork = xfs_calc_addafork_reservation(mp); |
86 | (uint)(XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 217 | resp->tr_attrinval = xfs_calc_attrinval_reservation(mp); |
87 | resp->tr_ifree = | 218 | resp->tr_attrset = xfs_calc_attrset_reservation(mp); |
88 | (uint)(XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 219 | resp->tr_attrrm = xfs_calc_attrrm_reservation(mp); |
89 | resp->tr_ichange = | 220 | resp->tr_clearagi = xfs_calc_clear_agi_bucket_reservation(mp); |
90 | (uint)(XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | 221 | resp->tr_growrtalloc = xfs_calc_growrtalloc_reservation(mp); |
91 | resp->tr_growdata = (uint)XFS_CALC_GROWDATA_LOG_RES(mp); | 222 | resp->tr_growrtzero = xfs_calc_growrtzero_reservation(mp); |
92 | resp->tr_swrite = (uint)XFS_CALC_SWRITE_LOG_RES(mp); | 223 | resp->tr_growrtfree = xfs_calc_growrtfree_reservation(mp); |
93 | resp->tr_writeid = (uint)XFS_CALC_WRITEID_LOG_RES(mp); | ||
94 | resp->tr_addafork = | ||
95 | (uint)(XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | ||
96 | resp->tr_attrinval = (uint)XFS_CALC_ATTRINVAL_LOG_RES(mp); | ||
97 | resp->tr_attrset = | ||
98 | (uint)(XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | ||
99 | resp->tr_attrrm = | ||
100 | (uint)(XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp)); | ||
101 | resp->tr_clearagi = (uint)XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp); | ||
102 | resp->tr_growrtalloc = (uint)XFS_CALC_GROWRTALLOC_LOG_RES(mp); | ||
103 | resp->tr_growrtzero = (uint)XFS_CALC_GROWRTZERO_LOG_RES(mp); | ||
104 | resp->tr_growrtfree = (uint)XFS_CALC_GROWRTFREE_LOG_RES(mp); | ||
105 | } | 224 | } |
106 | 225 | ||
107 | /* | 226 | /* |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index d77901c07f63..e48befa4e337 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -380,7 +380,7 @@ typedef struct xfs_trans { | |||
380 | xfs_trans_header_t t_header; /* header for in-log trans */ | 380 | xfs_trans_header_t t_header; /* header for in-log trans */ |
381 | unsigned int t_busy_free; /* busy descs free */ | 381 | unsigned int t_busy_free; /* busy descs free */ |
382 | xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */ | 382 | xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */ |
383 | xfs_pflags_t t_pflags; /* saved pflags state */ | 383 | unsigned long t_pflags; /* saved process flags state */ |
384 | } xfs_trans_t; | 384 | } xfs_trans_t; |
385 | 385 | ||
386 | #endif /* __KERNEL__ */ | 386 | #endif /* __KERNEL__ */ |
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c index b6ad370fab3d..d4ec4dfaf19c 100644 --- a/fs/xfs/xfs_vfsops.c +++ b/fs/xfs/xfs_vfsops.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #include "xfs_clnt.h" | 55 | #include "xfs_clnt.h" |
56 | #include "xfs_fsops.h" | 56 | #include "xfs_fsops.h" |
57 | 57 | ||
58 | STATIC int xfs_sync(bhv_desc_t *, int, cred_t *); | 58 | STATIC int xfs_sync(bhv_desc_t *, int, cred_t *); |
59 | 59 | ||
60 | int | 60 | int |
61 | xfs_init(void) | 61 | xfs_init(void) |
@@ -77,11 +77,12 @@ xfs_init(void) | |||
77 | "xfs_bmap_free_item"); | 77 | "xfs_bmap_free_item"); |
78 | xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t), | 78 | xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t), |
79 | "xfs_btree_cur"); | 79 | "xfs_btree_cur"); |
80 | xfs_inode_zone = kmem_zone_init(sizeof(xfs_inode_t), "xfs_inode"); | ||
81 | xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); | 80 | xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); |
82 | xfs_da_state_zone = | 81 | xfs_da_state_zone = |
83 | kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state"); | 82 | kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state"); |
84 | xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf"); | 83 | xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf"); |
84 | xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); | ||
85 | xfs_acl_zone_init(xfs_acl_zone, "xfs_acl"); | ||
85 | 86 | ||
86 | /* | 87 | /* |
87 | * The size of the zone allocated buf log item is the maximum | 88 | * The size of the zone allocated buf log item is the maximum |
@@ -93,17 +94,30 @@ xfs_init(void) | |||
93 | (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) / | 94 | (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) / |
94 | NBWORD) * sizeof(int))), | 95 | NBWORD) * sizeof(int))), |
95 | "xfs_buf_item"); | 96 | "xfs_buf_item"); |
96 | xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) + | 97 | xfs_efd_zone = |
97 | ((XFS_EFD_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))), | 98 | kmem_zone_init((sizeof(xfs_efd_log_item_t) + |
99 | ((XFS_EFD_MAX_FAST_EXTENTS - 1) * | ||
100 | sizeof(xfs_extent_t))), | ||
98 | "xfs_efd_item"); | 101 | "xfs_efd_item"); |
99 | xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) + | 102 | xfs_efi_zone = |
100 | ((XFS_EFI_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))), | 103 | kmem_zone_init((sizeof(xfs_efi_log_item_t) + |
104 | ((XFS_EFI_MAX_FAST_EXTENTS - 1) * | ||
105 | sizeof(xfs_extent_t))), | ||
101 | "xfs_efi_item"); | 106 | "xfs_efi_item"); |
102 | xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); | 107 | |
103 | xfs_ili_zone = kmem_zone_init(sizeof(xfs_inode_log_item_t), "xfs_ili"); | 108 | /* |
104 | xfs_chashlist_zone = kmem_zone_init(sizeof(xfs_chashlist_t), | 109 | * These zones warrant special memory allocator hints |
105 | "xfs_chashlist"); | 110 | */ |
106 | xfs_acl_zone_init(xfs_acl_zone, "xfs_acl"); | 111 | xfs_inode_zone = |
112 | kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode", | ||
113 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | | ||
114 | KM_ZONE_SPREAD, NULL); | ||
115 | xfs_ili_zone = | ||
116 | kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili", | ||
117 | KM_ZONE_SPREAD, NULL); | ||
118 | xfs_chashlist_zone = | ||
119 | kmem_zone_init_flags(sizeof(xfs_chashlist_t), "xfs_chashlist", | ||
120 | KM_ZONE_SPREAD, NULL); | ||
107 | 121 | ||
108 | /* | 122 | /* |
109 | * Allocate global trace buffers. | 123 | * Allocate global trace buffers. |
@@ -176,18 +190,18 @@ xfs_cleanup(void) | |||
176 | ktrace_free(xfs_alloc_trace_buf); | 190 | ktrace_free(xfs_alloc_trace_buf); |
177 | #endif | 191 | #endif |
178 | 192 | ||
179 | kmem_cache_destroy(xfs_bmap_free_item_zone); | 193 | kmem_zone_destroy(xfs_bmap_free_item_zone); |
180 | kmem_cache_destroy(xfs_btree_cur_zone); | 194 | kmem_zone_destroy(xfs_btree_cur_zone); |
181 | kmem_cache_destroy(xfs_inode_zone); | 195 | kmem_zone_destroy(xfs_inode_zone); |
182 | kmem_cache_destroy(xfs_trans_zone); | 196 | kmem_zone_destroy(xfs_trans_zone); |
183 | kmem_cache_destroy(xfs_da_state_zone); | 197 | kmem_zone_destroy(xfs_da_state_zone); |
184 | kmem_cache_destroy(xfs_dabuf_zone); | 198 | kmem_zone_destroy(xfs_dabuf_zone); |
185 | kmem_cache_destroy(xfs_buf_item_zone); | 199 | kmem_zone_destroy(xfs_buf_item_zone); |
186 | kmem_cache_destroy(xfs_efd_zone); | 200 | kmem_zone_destroy(xfs_efd_zone); |
187 | kmem_cache_destroy(xfs_efi_zone); | 201 | kmem_zone_destroy(xfs_efi_zone); |
188 | kmem_cache_destroy(xfs_ifork_zone); | 202 | kmem_zone_destroy(xfs_ifork_zone); |
189 | kmem_cache_destroy(xfs_ili_zone); | 203 | kmem_zone_destroy(xfs_ili_zone); |
190 | kmem_cache_destroy(xfs_chashlist_zone); | 204 | kmem_zone_destroy(xfs_chashlist_zone); |
191 | } | 205 | } |
192 | 206 | ||
193 | /* | 207 | /* |
@@ -258,8 +272,6 @@ xfs_start_flags( | |||
258 | mp->m_inoadd = XFS_INO64_OFFSET; | 272 | mp->m_inoadd = XFS_INO64_OFFSET; |
259 | } | 273 | } |
260 | #endif | 274 | #endif |
261 | if (ap->flags & XFSMNT_NOATIME) | ||
262 | mp->m_flags |= XFS_MOUNT_NOATIME; | ||
263 | if (ap->flags & XFSMNT_RETERR) | 275 | if (ap->flags & XFSMNT_RETERR) |
264 | mp->m_flags |= XFS_MOUNT_RETERR; | 276 | mp->m_flags |= XFS_MOUNT_RETERR; |
265 | if (ap->flags & XFSMNT_NOALIGN) | 277 | if (ap->flags & XFSMNT_NOALIGN) |
@@ -620,7 +632,7 @@ xfs_quiesce_fs( | |||
620 | xfs_mount_t *mp) | 632 | xfs_mount_t *mp) |
621 | { | 633 | { |
622 | int count = 0, pincount; | 634 | int count = 0, pincount; |
623 | 635 | ||
624 | xfs_refcache_purge_mp(mp); | 636 | xfs_refcache_purge_mp(mp); |
625 | xfs_flush_buftarg(mp->m_ddev_targp, 0); | 637 | xfs_flush_buftarg(mp->m_ddev_targp, 0); |
626 | xfs_finish_reclaim_all(mp, 0); | 638 | xfs_finish_reclaim_all(mp, 0); |
@@ -631,7 +643,7 @@ xfs_quiesce_fs( | |||
631 | * meta data (typically directory updates). | 643 | * meta data (typically directory updates). |
632 | * Which then must be flushed and logged before | 644 | * Which then must be flushed and logged before |
633 | * we can write the unmount record. | 645 | * we can write the unmount record. |
634 | */ | 646 | */ |
635 | do { | 647 | do { |
636 | xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, 0, NULL); | 648 | xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, 0, NULL); |
637 | pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1); | 649 | pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1); |
@@ -654,11 +666,6 @@ xfs_mntupdate( | |||
654 | xfs_mount_t *mp = XFS_BHVTOM(bdp); | 666 | xfs_mount_t *mp = XFS_BHVTOM(bdp); |
655 | int error; | 667 | int error; |
656 | 668 | ||
657 | if (args->flags & XFSMNT_NOATIME) | ||
658 | mp->m_flags |= XFS_MOUNT_NOATIME; | ||
659 | else | ||
660 | mp->m_flags &= ~XFS_MOUNT_NOATIME; | ||
661 | |||
662 | if (args->flags & XFSMNT_BARRIER) | 669 | if (args->flags & XFSMNT_BARRIER) |
663 | mp->m_flags |= XFS_MOUNT_BARRIER; | 670 | mp->m_flags |= XFS_MOUNT_BARRIER; |
664 | else | 671 | else |
@@ -814,6 +821,7 @@ xfs_statvfs( | |||
814 | 821 | ||
815 | statp->f_type = XFS_SB_MAGIC; | 822 | statp->f_type = XFS_SB_MAGIC; |
816 | 823 | ||
824 | xfs_icsb_sync_counters_lazy(mp); | ||
817 | s = XFS_SB_LOCK(mp); | 825 | s = XFS_SB_LOCK(mp); |
818 | statp->f_bsize = sbp->sb_blocksize; | 826 | statp->f_bsize = sbp->sb_blocksize; |
819 | lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; | 827 | lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; |
@@ -1221,7 +1229,7 @@ xfs_sync_inodes( | |||
1221 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 1229 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
1222 | 1230 | ||
1223 | error = xfs_itobp(mp, NULL, ip, | 1231 | error = xfs_itobp(mp, NULL, ip, |
1224 | &dip, &bp, 0); | 1232 | &dip, &bp, 0, 0); |
1225 | if (!error) { | 1233 | if (!error) { |
1226 | xfs_buf_relse(bp); | 1234 | xfs_buf_relse(bp); |
1227 | } else { | 1235 | } else { |
@@ -1690,10 +1698,7 @@ xfs_parseargs( | |||
1690 | int iosize; | 1698 | int iosize; |
1691 | 1699 | ||
1692 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; | 1700 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; |
1693 | 1701 | args->flags |= XFSMNT_IDELETE; | |
1694 | #if 0 /* XXX: off by default, until some remaining issues ironed out */ | ||
1695 | args->flags |= XFSMNT_IDELETE; /* default to on */ | ||
1696 | #endif | ||
1697 | 1702 | ||
1698 | if (!options) | 1703 | if (!options) |
1699 | goto done; | 1704 | goto done; |
@@ -1903,7 +1908,6 @@ xfs_showargs( | |||
1903 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, | 1908 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, |
1904 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, | 1909 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, |
1905 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, | 1910 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, |
1906 | { XFS_MOUNT_IDELETE, "," MNTOPT_NOIKEEP }, | ||
1907 | { 0, NULL } | 1911 | { 0, NULL } |
1908 | }; | 1912 | }; |
1909 | struct proc_xfs_info *xfs_infop; | 1913 | struct proc_xfs_info *xfs_infop; |
@@ -1939,6 +1943,8 @@ xfs_showargs( | |||
1939 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", | 1943 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", |
1940 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); | 1944 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); |
1941 | 1945 | ||
1946 | if (!(mp->m_flags & XFS_MOUNT_IDELETE)) | ||
1947 | seq_printf(m, "," MNTOPT_IKEEP); | ||
1942 | if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)) | 1948 | if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)) |
1943 | seq_printf(m, "," MNTOPT_LARGEIO); | 1949 | seq_printf(m, "," MNTOPT_LARGEIO); |
1944 | if (mp->m_flags & XFS_MOUNT_BARRIER) | 1950 | if (mp->m_flags & XFS_MOUNT_BARRIER) |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index eaab355f5a89..a478f42e63ff 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -615,6 +615,7 @@ xfs_setattr( | |||
615 | code = xfs_igrow_start(ip, vap->va_size, credp); | 615 | code = xfs_igrow_start(ip, vap->va_size, credp); |
616 | } | 616 | } |
617 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 617 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
618 | vn_iowait(vp); /* wait for the completion of any pending DIOs */ | ||
618 | if (!code) | 619 | if (!code) |
619 | code = xfs_itruncate_data(ip, vap->va_size); | 620 | code = xfs_itruncate_data(ip, vap->va_size); |
620 | if (code) { | 621 | if (code) { |
@@ -1556,7 +1557,7 @@ xfs_release( | |||
1556 | if ((error = xfs_inactive_free_eofblocks(mp, ip))) | 1557 | if ((error = xfs_inactive_free_eofblocks(mp, ip))) |
1557 | return error; | 1558 | return error; |
1558 | /* Update linux inode block count after free above */ | 1559 | /* Update linux inode block count after free above */ |
1559 | LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp, | 1560 | vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp, |
1560 | ip->i_d.di_nblocks + ip->i_delayed_blks); | 1561 | ip->i_d.di_nblocks + ip->i_delayed_blks); |
1561 | } | 1562 | } |
1562 | } | 1563 | } |
@@ -1637,7 +1638,7 @@ xfs_inactive( | |||
1637 | if ((error = xfs_inactive_free_eofblocks(mp, ip))) | 1638 | if ((error = xfs_inactive_free_eofblocks(mp, ip))) |
1638 | return VN_INACTIVE_CACHE; | 1639 | return VN_INACTIVE_CACHE; |
1639 | /* Update linux inode block count after free above */ | 1640 | /* Update linux inode block count after free above */ |
1640 | LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp, | 1641 | vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp, |
1641 | ip->i_d.di_nblocks + ip->i_delayed_blks); | 1642 | ip->i_d.di_nblocks + ip->i_delayed_blks); |
1642 | } | 1643 | } |
1643 | goto out; | 1644 | goto out; |
@@ -3186,7 +3187,7 @@ xfs_rmdir( | |||
3186 | 3187 | ||
3187 | /* Fall through to std_return with error = 0 or the errno | 3188 | /* Fall through to std_return with error = 0 or the errno |
3188 | * from xfs_trans_commit. */ | 3189 | * from xfs_trans_commit. */ |
3189 | std_return: | 3190 | std_return: |
3190 | if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_POSTREMOVE)) { | 3191 | if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_POSTREMOVE)) { |
3191 | (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, | 3192 | (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, |
3192 | dir_vp, DM_RIGHT_NULL, | 3193 | dir_vp, DM_RIGHT_NULL, |
@@ -3196,12 +3197,12 @@ std_return: | |||
3196 | } | 3197 | } |
3197 | return error; | 3198 | return error; |
3198 | 3199 | ||
3199 | error1: | 3200 | error1: |
3200 | xfs_bmap_cancel(&free_list); | 3201 | xfs_bmap_cancel(&free_list); |
3201 | cancel_flags |= XFS_TRANS_ABORT; | 3202 | cancel_flags |= XFS_TRANS_ABORT; |
3202 | /* FALLTHROUGH */ | 3203 | /* FALLTHROUGH */ |
3203 | 3204 | ||
3204 | error_return: | 3205 | error_return: |
3205 | xfs_trans_cancel(tp, cancel_flags); | 3206 | xfs_trans_cancel(tp, cancel_flags); |
3206 | goto std_return; | 3207 | goto std_return; |
3207 | } | 3208 | } |
@@ -4310,8 +4311,10 @@ xfs_free_file_space( | |||
4310 | ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1); | 4311 | ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1); |
4311 | if (attr_flags & ATTR_NOLOCK) | 4312 | if (attr_flags & ATTR_NOLOCK) |
4312 | need_iolock = 0; | 4313 | need_iolock = 0; |
4313 | if (need_iolock) | 4314 | if (need_iolock) { |
4314 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | 4315 | xfs_ilock(ip, XFS_IOLOCK_EXCL); |
4316 | vn_iowait(vp); /* wait for the completion of any pending DIOs */ | ||
4317 | } | ||
4315 | 4318 | ||
4316 | rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog), | 4319 | rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog), |
4317 | (__uint8_t)NBPP); | 4320 | (__uint8_t)NBPP); |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 0b54e9a4a8a1..e496fac860ac 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -330,6 +330,7 @@ int acpi_bus_register_driver(struct acpi_driver *driver); | |||
330 | int acpi_bus_unregister_driver(struct acpi_driver *driver); | 330 | int acpi_bus_unregister_driver(struct acpi_driver *driver); |
331 | int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, | 331 | int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, |
332 | acpi_handle handle, int type); | 332 | acpi_handle handle, int type); |
333 | int acpi_bus_trim(struct acpi_device *start, int rmdevice); | ||
333 | int acpi_bus_start(struct acpi_device *device); | 334 | int acpi_bus_start(struct acpi_device *device); |
334 | 335 | ||
335 | int acpi_match_ids(struct acpi_device *device, char *ids); | 336 | int acpi_match_ids(struct acpi_device *device, char *ids); |
diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h index 7eb4004b3601..a90c09d331c1 100644 --- a/include/linux/hwmon-sysfs.h +++ b/include/linux/hwmon-sysfs.h | |||
@@ -27,11 +27,13 @@ struct sensor_device_attribute{ | |||
27 | #define to_sensor_dev_attr(_dev_attr) \ | 27 | #define to_sensor_dev_attr(_dev_attr) \ |
28 | container_of(_dev_attr, struct sensor_device_attribute, dev_attr) | 28 | container_of(_dev_attr, struct sensor_device_attribute, dev_attr) |
29 | 29 | ||
30 | #define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index) \ | 30 | #define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ |
31 | struct sensor_device_attribute sensor_dev_attr_##_name = { \ | 31 | { .dev_attr = __ATTR(_name, _mode, _show, _store), \ |
32 | .dev_attr = __ATTR(_name,_mode,_show,_store), \ | 32 | .index = _index } |
33 | .index = _index, \ | 33 | |
34 | } | 34 | #define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ |
35 | struct sensor_device_attribute sensor_dev_attr_##_name \ | ||
36 | = SENSOR_ATTR(_name, _mode, _show, _store, _index) | ||
35 | 37 | ||
36 | struct sensor_device_attribute_2 { | 38 | struct sensor_device_attribute_2 { |
37 | struct device_attribute dev_attr; | 39 | struct device_attribute dev_attr; |
@@ -41,11 +43,13 @@ struct sensor_device_attribute_2 { | |||
41 | #define to_sensor_dev_attr_2(_dev_attr) \ | 43 | #define to_sensor_dev_attr_2(_dev_attr) \ |
42 | container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) | 44 | container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) |
43 | 45 | ||
46 | #define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ | ||
47 | { .dev_attr = __ATTR(_name, _mode, _show, _store), \ | ||
48 | .index = _index, \ | ||
49 | .nr = _nr } | ||
50 | |||
44 | #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ | 51 | #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ |
45 | struct sensor_device_attribute_2 sensor_dev_attr_##_name = { \ | 52 | struct sensor_device_attribute_2 sensor_dev_attr_##_name \ |
46 | .dev_attr = __ATTR(_name,_mode,_show,_store), \ | 53 | = SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) |
47 | .index = _index, \ | ||
48 | .nr = _nr, \ | ||
49 | } | ||
50 | 54 | ||
51 | #endif /* _LINUX_HWMON_SYSFS_H */ | 55 | #endif /* _LINUX_HWMON_SYSFS_H */ |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 474c8f4f5d4f..ec311bc89439 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -172,7 +172,6 @@ | |||
172 | #define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ | 172 | #define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ |
173 | #define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ | 173 | #define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ |
174 | #define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */ | 174 | #define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */ |
175 | #define I2C_HW_B_FRODO 0x010013 /* 2d3D SA-1110 Development Board */ | ||
176 | #define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */ | 175 | #define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */ |
177 | #define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */ | 176 | #define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */ |
178 | #define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ | 177 | #define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 63f1d63cc1d8..1635ee25918f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/mod_devicetable.h> | 32 | #include <linux/mod_devicetable.h> |
33 | #include <linux/device.h> /* for struct device */ | 33 | #include <linux/device.h> /* for struct device */ |
34 | #include <linux/sched.h> /* for completion */ | 34 | #include <linux/sched.h> /* for completion */ |
35 | #include <asm/semaphore.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | /* --- For i2c-isa ---------------------------------------------------- */ | 37 | /* --- For i2c-isa ---------------------------------------------------- */ |
38 | 38 | ||
@@ -225,8 +225,8 @@ struct i2c_adapter { | |||
225 | int (*client_unregister)(struct i2c_client *); | 225 | int (*client_unregister)(struct i2c_client *); |
226 | 226 | ||
227 | /* data fields that are valid for all devices */ | 227 | /* data fields that are valid for all devices */ |
228 | struct semaphore bus_lock; | 228 | struct mutex bus_lock; |
229 | struct semaphore clist_lock; | 229 | struct mutex clist_lock; |
230 | 230 | ||
231 | int timeout; | 231 | int timeout; |
232 | int retries; | 232 | int retries; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index fe1a2b02fc55..0aad5a378e95 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -95,6 +95,11 @@ enum pci_channel_state { | |||
95 | pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, | 95 | pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | typedef unsigned short __bitwise pci_bus_flags_t; | ||
99 | enum pci_bus_flags { | ||
100 | PCI_BUS_FLAGS_NO_MSI = (pci_bus_flags_t) 1, | ||
101 | }; | ||
102 | |||
98 | /* | 103 | /* |
99 | * The pci_dev structure is used to describe PCI devices. | 104 | * The pci_dev structure is used to describe PCI devices. |
100 | */ | 105 | */ |
@@ -203,7 +208,7 @@ struct pci_bus { | |||
203 | char name[48]; | 208 | char name[48]; |
204 | 209 | ||
205 | unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ | 210 | unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ |
206 | unsigned short pad2; | 211 | pci_bus_flags_t bus_flags; /* Inherited by child busses */ |
207 | struct device *bridge; | 212 | struct device *bridge; |
208 | struct class_device class_dev; | 213 | struct class_device class_dev; |
209 | struct bin_attribute *legacy_io; /* legacy I/O for this bus */ | 214 | struct bin_attribute *legacy_io; /* legacy I/O for this bus */ |
@@ -485,9 +490,9 @@ void pdev_sort_resources(struct pci_dev *, struct resource_list *); | |||
485 | void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), | 490 | void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), |
486 | int (*)(struct pci_dev *, u8, u8)); | 491 | int (*)(struct pci_dev *, u8, u8)); |
487 | #define HAVE_PCI_REQ_REGIONS 2 | 492 | #define HAVE_PCI_REQ_REGIONS 2 |
488 | int pci_request_regions(struct pci_dev *, char *); | 493 | int pci_request_regions(struct pci_dev *, const char *); |
489 | void pci_release_regions(struct pci_dev *); | 494 | void pci_release_regions(struct pci_dev *); |
490 | int pci_request_region(struct pci_dev *, int, char *); | 495 | int pci_request_region(struct pci_dev *, int, const char *); |
491 | void pci_release_region(struct pci_dev *, int); | 496 | void pci_release_region(struct pci_dev *, int); |
492 | 497 | ||
493 | /* drivers/pci/bus.c */ | 498 | /* drivers/pci/bus.c */ |
@@ -516,6 +521,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass | |||
516 | void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), | 521 | void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), |
517 | void *userdata); | 522 | void *userdata); |
518 | int pci_cfg_space_size(struct pci_dev *dev); | 523 | int pci_cfg_space_size(struct pci_dev *dev); |
524 | unsigned char pci_bus_max_busnr(struct pci_bus* bus); | ||
519 | 525 | ||
520 | /* kmem_cache style wrapper around pci_alloc_consistent() */ | 526 | /* kmem_cache style wrapper around pci_alloc_consistent() */ |
521 | 527 | ||
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index ec3c32932620..f3dcf89d5232 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -1371,6 +1371,7 @@ | |||
1371 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 | 1371 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 |
1372 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 | 1372 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 |
1373 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 | 1373 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 |
1374 | #define PCI_DEVICE_ID_SERVERWORKS_HT1000SB 0x0205 | ||
1374 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 | 1375 | #define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 |
1375 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 | 1376 | #define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 |
1376 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 | 1377 | #define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 |
@@ -1864,11 +1865,13 @@ | |||
1864 | #define PCI_DEVICE_ID_TIGON3_5780S 0x166b | 1865 | #define PCI_DEVICE_ID_TIGON3_5780S 0x166b |
1865 | #define PCI_DEVICE_ID_TIGON3_5705F 0x166e | 1866 | #define PCI_DEVICE_ID_TIGON3_5705F 0x166e |
1866 | #define PCI_DEVICE_ID_TIGON3_5754M 0x1672 | 1867 | #define PCI_DEVICE_ID_TIGON3_5754M 0x1672 |
1868 | #define PCI_DEVICE_ID_TIGON3_5755M 0x1673 | ||
1867 | #define PCI_DEVICE_ID_TIGON3_5750 0x1676 | 1869 | #define PCI_DEVICE_ID_TIGON3_5750 0x1676 |
1868 | #define PCI_DEVICE_ID_TIGON3_5751 0x1677 | 1870 | #define PCI_DEVICE_ID_TIGON3_5751 0x1677 |
1869 | #define PCI_DEVICE_ID_TIGON3_5715 0x1678 | 1871 | #define PCI_DEVICE_ID_TIGON3_5715 0x1678 |
1870 | #define PCI_DEVICE_ID_TIGON3_5715S 0x1679 | 1872 | #define PCI_DEVICE_ID_TIGON3_5715S 0x1679 |
1871 | #define PCI_DEVICE_ID_TIGON3_5754 0x167a | 1873 | #define PCI_DEVICE_ID_TIGON3_5754 0x167a |
1874 | #define PCI_DEVICE_ID_TIGON3_5755 0x167b | ||
1872 | #define PCI_DEVICE_ID_TIGON3_5750M 0x167c | 1875 | #define PCI_DEVICE_ID_TIGON3_5750M 0x167c |
1873 | #define PCI_DEVICE_ID_TIGON3_5751M 0x167d | 1876 | #define PCI_DEVICE_ID_TIGON3_5751M 0x167d |
1874 | #define PCI_DEVICE_ID_TIGON3_5751F 0x167e | 1877 | #define PCI_DEVICE_ID_TIGON3_5751F 0x167e |
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index d572d5376319..df0cdd41085c 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h | |||
@@ -839,6 +839,7 @@ enum | |||
839 | #define RTMGRP_IPV4_IFADDR 0x10 | 839 | #define RTMGRP_IPV4_IFADDR 0x10 |
840 | #define RTMGRP_IPV4_MROUTE 0x20 | 840 | #define RTMGRP_IPV4_MROUTE 0x20 |
841 | #define RTMGRP_IPV4_ROUTE 0x40 | 841 | #define RTMGRP_IPV4_ROUTE 0x40 |
842 | #define RTMGRP_IPV4_RULE 0x80 | ||
842 | 843 | ||
843 | #define RTMGRP_IPV6_IFADDR 0x100 | 844 | #define RTMGRP_IPV6_IFADDR 0x100 |
844 | #define RTMGRP_IPV6_MROUTE 0x200 | 845 | #define RTMGRP_IPV6_MROUTE 0x200 |
@@ -869,7 +870,8 @@ enum rtnetlink_groups { | |||
869 | #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE | 870 | #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE |
870 | RTNLGRP_IPV4_ROUTE, | 871 | RTNLGRP_IPV4_ROUTE, |
871 | #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE | 872 | #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE |
872 | RTNLGRP_NOP1, | 873 | RTNLGRP_IPV4_RULE, |
874 | #define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE | ||
873 | RTNLGRP_IPV6_IFADDR, | 875 | RTNLGRP_IPV6_IFADDR, |
874 | #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR | 876 | #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR |
875 | RTNLGRP_IPV6_MROUTE, | 877 | RTNLGRP_IPV6_MROUTE, |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 8eedaedba743..c23e9c06ee23 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -106,6 +106,9 @@ | |||
106 | * | 106 | * |
107 | * interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com> | 107 | * interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com> |
108 | * 050103 | 108 | * 050103 |
109 | * | ||
110 | * MPLS support by Steven Whitehouse <steve@chygwyn.com> | ||
111 | * | ||
109 | */ | 112 | */ |
110 | #include <linux/sys.h> | 113 | #include <linux/sys.h> |
111 | #include <linux/types.h> | 114 | #include <linux/types.h> |
@@ -154,7 +157,7 @@ | |||
154 | #include <asm/div64.h> /* do_div */ | 157 | #include <asm/div64.h> /* do_div */ |
155 | #include <asm/timex.h> | 158 | #include <asm/timex.h> |
156 | 159 | ||
157 | #define VERSION "pktgen v2.66: Packet Generator for packet performance testing.\n" | 160 | #define VERSION "pktgen v2.67: Packet Generator for packet performance testing.\n" |
158 | 161 | ||
159 | /* #define PG_DEBUG(a) a */ | 162 | /* #define PG_DEBUG(a) a */ |
160 | #define PG_DEBUG(a) | 163 | #define PG_DEBUG(a) |
@@ -162,6 +165,8 @@ | |||
162 | /* The buckets are exponential in 'width' */ | 165 | /* The buckets are exponential in 'width' */ |
163 | #define LAT_BUCKETS_MAX 32 | 166 | #define LAT_BUCKETS_MAX 32 |
164 | #define IP_NAME_SZ 32 | 167 | #define IP_NAME_SZ 32 |
168 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ | ||
169 | #define MPLS_STACK_BOTTOM __constant_htonl(0x00000100) | ||
165 | 170 | ||
166 | /* Device flag bits */ | 171 | /* Device flag bits */ |
167 | #define F_IPSRC_RND (1<<0) /* IP-Src Random */ | 172 | #define F_IPSRC_RND (1<<0) /* IP-Src Random */ |
@@ -172,6 +177,7 @@ | |||
172 | #define F_MACDST_RND (1<<5) /* MAC-Dst Random */ | 177 | #define F_MACDST_RND (1<<5) /* MAC-Dst Random */ |
173 | #define F_TXSIZE_RND (1<<6) /* Transmit size is random */ | 178 | #define F_TXSIZE_RND (1<<6) /* Transmit size is random */ |
174 | #define F_IPV6 (1<<7) /* Interface in IPV6 Mode */ | 179 | #define F_IPV6 (1<<7) /* Interface in IPV6 Mode */ |
180 | #define F_MPLS_RND (1<<8) /* Random MPLS labels */ | ||
175 | 181 | ||
176 | /* Thread control flag bits */ | 182 | /* Thread control flag bits */ |
177 | #define T_TERMINATE (1<<0) | 183 | #define T_TERMINATE (1<<0) |
@@ -278,6 +284,10 @@ struct pktgen_dev { | |||
278 | __u16 udp_dst_min; /* inclusive, dest UDP port */ | 284 | __u16 udp_dst_min; /* inclusive, dest UDP port */ |
279 | __u16 udp_dst_max; /* exclusive, dest UDP port */ | 285 | __u16 udp_dst_max; /* exclusive, dest UDP port */ |
280 | 286 | ||
287 | /* MPLS */ | ||
288 | unsigned nr_labels; /* Depth of stack, 0 = no MPLS */ | ||
289 | __be32 labels[MAX_MPLS_LABELS]; | ||
290 | |||
281 | __u32 src_mac_count; /* How many MACs to iterate through */ | 291 | __u32 src_mac_count; /* How many MACs to iterate through */ |
282 | __u32 dst_mac_count; /* How many MACs to iterate through */ | 292 | __u32 dst_mac_count; /* How many MACs to iterate through */ |
283 | 293 | ||
@@ -623,9 +633,19 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
623 | pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); | 633 | pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); |
624 | 634 | ||
625 | seq_printf(seq, | 635 | seq_printf(seq, |
626 | " src_mac_count: %d dst_mac_count: %d \n Flags: ", | 636 | " src_mac_count: %d dst_mac_count: %d\n", |
627 | pkt_dev->src_mac_count, pkt_dev->dst_mac_count); | 637 | pkt_dev->src_mac_count, pkt_dev->dst_mac_count); |
628 | 638 | ||
639 | if (pkt_dev->nr_labels) { | ||
640 | unsigned i; | ||
641 | seq_printf(seq, " mpls: "); | ||
642 | for(i = 0; i < pkt_dev->nr_labels; i++) | ||
643 | seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]), | ||
644 | i == pkt_dev->nr_labels-1 ? "\n" : ", "); | ||
645 | } | ||
646 | |||
647 | seq_printf(seq, " Flags: "); | ||
648 | |||
629 | if (pkt_dev->flags & F_IPV6) | 649 | if (pkt_dev->flags & F_IPV6) |
630 | seq_printf(seq, "IPV6 "); | 650 | seq_printf(seq, "IPV6 "); |
631 | 651 | ||
@@ -644,6 +664,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
644 | if (pkt_dev->flags & F_UDPDST_RND) | 664 | if (pkt_dev->flags & F_UDPDST_RND) |
645 | seq_printf(seq, "UDPDST_RND "); | 665 | seq_printf(seq, "UDPDST_RND "); |
646 | 666 | ||
667 | if (pkt_dev->flags & F_MPLS_RND) | ||
668 | seq_printf(seq, "MPLS_RND "); | ||
669 | |||
647 | if (pkt_dev->flags & F_MACSRC_RND) | 670 | if (pkt_dev->flags & F_MACSRC_RND) |
648 | seq_printf(seq, "MACSRC_RND "); | 671 | seq_printf(seq, "MACSRC_RND "); |
649 | 672 | ||
@@ -691,6 +714,29 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
691 | return 0; | 714 | return 0; |
692 | } | 715 | } |
693 | 716 | ||
717 | |||
718 | static int hex32_arg(const char __user *user_buffer, __u32 *num) | ||
719 | { | ||
720 | int i = 0; | ||
721 | *num = 0; | ||
722 | |||
723 | for(; i < 8; i++) { | ||
724 | char c; | ||
725 | *num <<= 4; | ||
726 | if (get_user(c, &user_buffer[i])) | ||
727 | return -EFAULT; | ||
728 | if ((c >= '0') && (c <= '9')) | ||
729 | *num |= c - '0'; | ||
730 | else if ((c >= 'a') && (c <= 'f')) | ||
731 | *num |= c - 'a' + 10; | ||
732 | else if ((c >= 'A') && (c <= 'F')) | ||
733 | *num |= c - 'A' + 10; | ||
734 | else | ||
735 | break; | ||
736 | } | ||
737 | return i; | ||
738 | } | ||
739 | |||
694 | static int count_trail_chars(const char __user * user_buffer, | 740 | static int count_trail_chars(const char __user * user_buffer, |
695 | unsigned int maxlen) | 741 | unsigned int maxlen) |
696 | { | 742 | { |
@@ -759,6 +805,35 @@ done_str: | |||
759 | return i; | 805 | return i; |
760 | } | 806 | } |
761 | 807 | ||
808 | static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev) | ||
809 | { | ||
810 | unsigned n = 0; | ||
811 | char c; | ||
812 | ssize_t i = 0; | ||
813 | int len; | ||
814 | |||
815 | pkt_dev->nr_labels = 0; | ||
816 | do { | ||
817 | __u32 tmp; | ||
818 | len = hex32_arg(&buffer[i], &tmp); | ||
819 | if (len <= 0) | ||
820 | return len; | ||
821 | pkt_dev->labels[n] = htonl(tmp); | ||
822 | if (pkt_dev->labels[n] & MPLS_STACK_BOTTOM) | ||
823 | pkt_dev->flags |= F_MPLS_RND; | ||
824 | i += len; | ||
825 | if (get_user(c, &buffer[i])) | ||
826 | return -EFAULT; | ||
827 | i++; | ||
828 | n++; | ||
829 | if (n >= MAX_MPLS_LABELS) | ||
830 | return -E2BIG; | ||
831 | } while(c == ','); | ||
832 | |||
833 | pkt_dev->nr_labels = n; | ||
834 | return i; | ||
835 | } | ||
836 | |||
762 | static ssize_t pktgen_if_write(struct file *file, | 837 | static ssize_t pktgen_if_write(struct file *file, |
763 | const char __user * user_buffer, size_t count, | 838 | const char __user * user_buffer, size_t count, |
764 | loff_t * offset) | 839 | loff_t * offset) |
@@ -1059,6 +1134,12 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1059 | else if (strcmp(f, "!MACDST_RND") == 0) | 1134 | else if (strcmp(f, "!MACDST_RND") == 0) |
1060 | pkt_dev->flags &= ~F_MACDST_RND; | 1135 | pkt_dev->flags &= ~F_MACDST_RND; |
1061 | 1136 | ||
1137 | else if (strcmp(f, "MPLS_RND") == 0) | ||
1138 | pkt_dev->flags |= F_MPLS_RND; | ||
1139 | |||
1140 | else if (strcmp(f, "!MPLS_RND") == 0) | ||
1141 | pkt_dev->flags &= ~F_MPLS_RND; | ||
1142 | |||
1062 | else { | 1143 | else { |
1063 | sprintf(pg_result, | 1144 | sprintf(pg_result, |
1064 | "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s", | 1145 | "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s", |
@@ -1354,6 +1435,19 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1354 | return count; | 1435 | return count; |
1355 | } | 1436 | } |
1356 | 1437 | ||
1438 | if (!strcmp(name, "mpls")) { | ||
1439 | unsigned n, offset; | ||
1440 | len = get_labels(&user_buffer[i], pkt_dev); | ||
1441 | if (len < 0) { return len; } | ||
1442 | i += len; | ||
1443 | offset = sprintf(pg_result, "OK: mpls="); | ||
1444 | for(n = 0; n < pkt_dev->nr_labels; n++) | ||
1445 | offset += sprintf(pg_result + offset, | ||
1446 | "%08x%s", ntohl(pkt_dev->labels[n]), | ||
1447 | n == pkt_dev->nr_labels-1 ? "" : ","); | ||
1448 | return count; | ||
1449 | } | ||
1450 | |||
1357 | sprintf(pkt_dev->result, "No such parameter \"%s\"", name); | 1451 | sprintf(pkt_dev->result, "No such parameter \"%s\"", name); |
1358 | return -EINVAL; | 1452 | return -EINVAL; |
1359 | } | 1453 | } |
@@ -1846,6 +1940,15 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
1846 | pkt_dev->hh[1] = tmp; | 1940 | pkt_dev->hh[1] = tmp; |
1847 | } | 1941 | } |
1848 | 1942 | ||
1943 | if (pkt_dev->flags & F_MPLS_RND) { | ||
1944 | unsigned i; | ||
1945 | for(i = 0; i < pkt_dev->nr_labels; i++) | ||
1946 | if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) | ||
1947 | pkt_dev->labels[i] = MPLS_STACK_BOTTOM | | ||
1948 | (pktgen_random() & | ||
1949 | htonl(0x000fffff)); | ||
1950 | } | ||
1951 | |||
1849 | if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) { | 1952 | if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) { |
1850 | if (pkt_dev->flags & F_UDPSRC_RND) | 1953 | if (pkt_dev->flags & F_UDPSRC_RND) |
1851 | pkt_dev->cur_udp_src = | 1954 | pkt_dev->cur_udp_src = |
@@ -1968,6 +2071,16 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
1968 | pkt_dev->flows[flow].count++; | 2071 | pkt_dev->flows[flow].count++; |
1969 | } | 2072 | } |
1970 | 2073 | ||
2074 | static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) | ||
2075 | { | ||
2076 | unsigned i; | ||
2077 | for(i = 0; i < pkt_dev->nr_labels; i++) { | ||
2078 | *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; | ||
2079 | } | ||
2080 | mpls--; | ||
2081 | *mpls |= MPLS_STACK_BOTTOM; | ||
2082 | } | ||
2083 | |||
1971 | static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | 2084 | static struct sk_buff *fill_packet_ipv4(struct net_device *odev, |
1972 | struct pktgen_dev *pkt_dev) | 2085 | struct pktgen_dev *pkt_dev) |
1973 | { | 2086 | { |
@@ -1977,6 +2090,11 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
1977 | int datalen, iplen; | 2090 | int datalen, iplen; |
1978 | struct iphdr *iph; | 2091 | struct iphdr *iph; |
1979 | struct pktgen_hdr *pgh = NULL; | 2092 | struct pktgen_hdr *pgh = NULL; |
2093 | __be16 protocol = __constant_htons(ETH_P_IP); | ||
2094 | __be32 *mpls; | ||
2095 | |||
2096 | if (pkt_dev->nr_labels) | ||
2097 | protocol = __constant_htons(ETH_P_MPLS_UC); | ||
1980 | 2098 | ||
1981 | /* Update any of the values, used when we're incrementing various | 2099 | /* Update any of the values, used when we're incrementing various |
1982 | * fields. | 2100 | * fields. |
@@ -1984,7 +2102,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
1984 | mod_cur_headers(pkt_dev); | 2102 | mod_cur_headers(pkt_dev); |
1985 | 2103 | ||
1986 | datalen = (odev->hard_header_len + 16) & ~0xf; | 2104 | datalen = (odev->hard_header_len + 16) & ~0xf; |
1987 | skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen, GFP_ATOMIC); | 2105 | skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen + |
2106 | pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC); | ||
1988 | if (!skb) { | 2107 | if (!skb) { |
1989 | sprintf(pkt_dev->result, "No memory"); | 2108 | sprintf(pkt_dev->result, "No memory"); |
1990 | return NULL; | 2109 | return NULL; |
@@ -1994,13 +2113,18 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
1994 | 2113 | ||
1995 | /* Reserve for ethernet and IP header */ | 2114 | /* Reserve for ethernet and IP header */ |
1996 | eth = (__u8 *) skb_push(skb, 14); | 2115 | eth = (__u8 *) skb_push(skb, 14); |
2116 | mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32)); | ||
2117 | if (pkt_dev->nr_labels) | ||
2118 | mpls_push(mpls, pkt_dev); | ||
1997 | iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)); | 2119 | iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)); |
1998 | udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); | 2120 | udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); |
1999 | 2121 | ||
2000 | memcpy(eth, pkt_dev->hh, 12); | 2122 | memcpy(eth, pkt_dev->hh, 12); |
2001 | *(u16 *) & eth[12] = __constant_htons(ETH_P_IP); | 2123 | *(u16 *) & eth[12] = protocol; |
2002 | 2124 | ||
2003 | datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8; /* Eth + IPh + UDPh */ | 2125 | /* Eth + IPh + UDPh + mpls */ |
2126 | datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - | ||
2127 | pkt_dev->nr_labels*sizeof(u32); | ||
2004 | if (datalen < sizeof(struct pktgen_hdr)) | 2128 | if (datalen < sizeof(struct pktgen_hdr)) |
2005 | datalen = sizeof(struct pktgen_hdr); | 2129 | datalen = sizeof(struct pktgen_hdr); |
2006 | 2130 | ||
@@ -2021,8 +2145,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
2021 | iph->tot_len = htons(iplen); | 2145 | iph->tot_len = htons(iplen); |
2022 | iph->check = 0; | 2146 | iph->check = 0; |
2023 | iph->check = ip_fast_csum((void *)iph, iph->ihl); | 2147 | iph->check = ip_fast_csum((void *)iph, iph->ihl); |
2024 | skb->protocol = __constant_htons(ETH_P_IP); | 2148 | skb->protocol = protocol; |
2025 | skb->mac.raw = ((u8 *) iph) - 14; | 2149 | skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32); |
2026 | skb->dev = odev; | 2150 | skb->dev = odev; |
2027 | skb->pkt_type = PACKET_HOST; | 2151 | skb->pkt_type = PACKET_HOST; |
2028 | 2152 | ||
@@ -2274,13 +2398,19 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
2274 | int datalen; | 2398 | int datalen; |
2275 | struct ipv6hdr *iph; | 2399 | struct ipv6hdr *iph; |
2276 | struct pktgen_hdr *pgh = NULL; | 2400 | struct pktgen_hdr *pgh = NULL; |
2401 | __be16 protocol = __constant_htons(ETH_P_IPV6); | ||
2402 | __be32 *mpls; | ||
2403 | |||
2404 | if (pkt_dev->nr_labels) | ||
2405 | protocol = __constant_htons(ETH_P_MPLS_UC); | ||
2277 | 2406 | ||
2278 | /* Update any of the values, used when we're incrementing various | 2407 | /* Update any of the values, used when we're incrementing various |
2279 | * fields. | 2408 | * fields. |
2280 | */ | 2409 | */ |
2281 | mod_cur_headers(pkt_dev); | 2410 | mod_cur_headers(pkt_dev); |
2282 | 2411 | ||
2283 | skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16, GFP_ATOMIC); | 2412 | skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 + |
2413 | pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC); | ||
2284 | if (!skb) { | 2414 | if (!skb) { |
2285 | sprintf(pkt_dev->result, "No memory"); | 2415 | sprintf(pkt_dev->result, "No memory"); |
2286 | return NULL; | 2416 | return NULL; |
@@ -2290,13 +2420,19 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
2290 | 2420 | ||
2291 | /* Reserve for ethernet and IP header */ | 2421 | /* Reserve for ethernet and IP header */ |
2292 | eth = (__u8 *) skb_push(skb, 14); | 2422 | eth = (__u8 *) skb_push(skb, 14); |
2423 | mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32)); | ||
2424 | if (pkt_dev->nr_labels) | ||
2425 | mpls_push(mpls, pkt_dev); | ||
2293 | iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr)); | 2426 | iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr)); |
2294 | udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); | 2427 | udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); |
2295 | 2428 | ||
2296 | memcpy(eth, pkt_dev->hh, 12); | 2429 | memcpy(eth, pkt_dev->hh, 12); |
2297 | *(u16 *) & eth[12] = __constant_htons(ETH_P_IPV6); | 2430 | *(u16 *) & eth[12] = __constant_htons(ETH_P_IPV6); |
2298 | 2431 | ||
2299 | datalen = pkt_dev->cur_pkt_size - 14 - sizeof(struct ipv6hdr) - sizeof(struct udphdr); /* Eth + IPh + UDPh */ | 2432 | /* Eth + IPh + UDPh + mpls */ |
2433 | datalen = pkt_dev->cur_pkt_size - 14 - | ||
2434 | sizeof(struct ipv6hdr) - sizeof(struct udphdr) - | ||
2435 | pkt_dev->nr_labels*sizeof(u32); | ||
2300 | 2436 | ||
2301 | if (datalen < sizeof(struct pktgen_hdr)) { | 2437 | if (datalen < sizeof(struct pktgen_hdr)) { |
2302 | datalen = sizeof(struct pktgen_hdr); | 2438 | datalen = sizeof(struct pktgen_hdr); |
@@ -2320,8 +2456,8 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
2320 | ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr); | 2456 | ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr); |
2321 | ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr); | 2457 | ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr); |
2322 | 2458 | ||
2323 | skb->mac.raw = ((u8 *) iph) - 14; | 2459 | skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32); |
2324 | skb->protocol = __constant_htons(ETH_P_IPV6); | 2460 | skb->protocol = protocol; |
2325 | skb->dev = odev; | 2461 | skb->dev = odev; |
2326 | skb->pkt_type = PACKET_HOST; | 2462 | skb->pkt_type = PACKET_HOST; |
2327 | 2463 | ||
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index 768e8f5d7daa..ec566f3e66c7 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
@@ -104,6 +104,8 @@ static struct hlist_head fib_rules; | |||
104 | 104 | ||
105 | /* writer func called from netlink -- rtnl_sem hold*/ | 105 | /* writer func called from netlink -- rtnl_sem hold*/ |
106 | 106 | ||
107 | static void rtmsg_rule(int, struct fib_rule *); | ||
108 | |||
107 | int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | 109 | int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) |
108 | { | 110 | { |
109 | struct rtattr **rta = arg; | 111 | struct rtattr **rta = arg; |
@@ -131,6 +133,7 @@ int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
131 | 133 | ||
132 | hlist_del_rcu(&r->hlist); | 134 | hlist_del_rcu(&r->hlist); |
133 | r->r_dead = 1; | 135 | r->r_dead = 1; |
136 | rtmsg_rule(RTM_DELRULE, r); | ||
134 | fib_rule_put(r); | 137 | fib_rule_put(r); |
135 | err = 0; | 138 | err = 0; |
136 | break; | 139 | break; |
@@ -253,6 +256,7 @@ int inet_rtm_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
253 | else | 256 | else |
254 | hlist_add_before_rcu(&new_r->hlist, &r->hlist); | 257 | hlist_add_before_rcu(&new_r->hlist, &r->hlist); |
255 | 258 | ||
259 | rtmsg_rule(RTM_NEWRULE, new_r); | ||
256 | return 0; | 260 | return 0; |
257 | } | 261 | } |
258 | 262 | ||
@@ -382,14 +386,14 @@ static struct notifier_block fib_rules_notifier = { | |||
382 | 386 | ||
383 | static __inline__ int inet_fill_rule(struct sk_buff *skb, | 387 | static __inline__ int inet_fill_rule(struct sk_buff *skb, |
384 | struct fib_rule *r, | 388 | struct fib_rule *r, |
385 | struct netlink_callback *cb, | 389 | u32 pid, u32 seq, int event, |
386 | unsigned int flags) | 390 | unsigned int flags) |
387 | { | 391 | { |
388 | struct rtmsg *rtm; | 392 | struct rtmsg *rtm; |
389 | struct nlmsghdr *nlh; | 393 | struct nlmsghdr *nlh; |
390 | unsigned char *b = skb->tail; | 394 | unsigned char *b = skb->tail; |
391 | 395 | ||
392 | nlh = NLMSG_NEW_ANSWER(skb, cb, RTM_NEWRULE, sizeof(*rtm), flags); | 396 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags); |
393 | rtm = NLMSG_DATA(nlh); | 397 | rtm = NLMSG_DATA(nlh); |
394 | rtm->rtm_family = AF_INET; | 398 | rtm->rtm_family = AF_INET; |
395 | rtm->rtm_dst_len = r->r_dst_len; | 399 | rtm->rtm_dst_len = r->r_dst_len; |
@@ -430,6 +434,21 @@ rtattr_failure: | |||
430 | 434 | ||
431 | /* callers should hold rtnl semaphore */ | 435 | /* callers should hold rtnl semaphore */ |
432 | 436 | ||
437 | static void rtmsg_rule(int event, struct fib_rule *r) | ||
438 | { | ||
439 | int size = NLMSG_SPACE(sizeof(struct rtmsg) + 128); | ||
440 | struct sk_buff *skb = alloc_skb(size, GFP_KERNEL); | ||
441 | |||
442 | if (!skb) | ||
443 | netlink_set_err(rtnl, 0, RTNLGRP_IPV4_RULE, ENOBUFS); | ||
444 | else if (inet_fill_rule(skb, r, 0, 0, event, 0) < 0) { | ||
445 | kfree_skb(skb); | ||
446 | netlink_set_err(rtnl, 0, RTNLGRP_IPV4_RULE, EINVAL); | ||
447 | } else { | ||
448 | netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV4_RULE, GFP_KERNEL); | ||
449 | } | ||
450 | } | ||
451 | |||
433 | int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb) | 452 | int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb) |
434 | { | 453 | { |
435 | int idx = 0; | 454 | int idx = 0; |
@@ -442,7 +461,9 @@ int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb) | |||
442 | 461 | ||
443 | if (idx < s_idx) | 462 | if (idx < s_idx) |
444 | continue; | 463 | continue; |
445 | if (inet_fill_rule(skb, r, cb, NLM_F_MULTI) < 0) | 464 | if (inet_fill_rule(skb, r, NETLINK_CB(cb->skb).pid, |
465 | cb->nlh->nlmsg_seq, | ||
466 | RTM_NEWRULE, NLM_F_MULTI) < 0) | ||
446 | break; | 467 | break; |
447 | idx++; | 468 | idx++; |
448 | } | 469 | } |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 4fbc40b13f19..e46048974f37 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -161,7 +161,7 @@ int ip6_output(struct sk_buff *skb) | |||
161 | int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | 161 | int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, |
162 | struct ipv6_txoptions *opt, int ipfragok) | 162 | struct ipv6_txoptions *opt, int ipfragok) |
163 | { | 163 | { |
164 | struct ipv6_pinfo *np = sk ? inet6_sk(sk) : NULL; | 164 | struct ipv6_pinfo *np = inet6_sk(sk); |
165 | struct in6_addr *first_hop = &fl->fl6_dst; | 165 | struct in6_addr *first_hop = &fl->fl6_dst; |
166 | struct dst_entry *dst = skb->dst; | 166 | struct dst_entry *dst = skb->dst; |
167 | struct ipv6hdr *hdr; | 167 | struct ipv6hdr *hdr; |
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 2b670479dde1..78e052591fa9 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -347,8 +347,7 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n) | |||
347 | if (n->ht_down) | 347 | if (n->ht_down) |
348 | n->ht_down->refcnt--; | 348 | n->ht_down->refcnt--; |
349 | #ifdef CONFIG_CLS_U32_PERF | 349 | #ifdef CONFIG_CLS_U32_PERF |
350 | if (n) | 350 | kfree(n->pf); |
351 | kfree(n->pf); | ||
352 | #endif | 351 | #endif |
353 | kfree(n); | 352 | kfree(n); |
354 | return 0; | 353 | return 0; |
@@ -680,8 +679,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
680 | return 0; | 679 | return 0; |
681 | } | 680 | } |
682 | #ifdef CONFIG_CLS_U32_PERF | 681 | #ifdef CONFIG_CLS_U32_PERF |
683 | if (n) | 682 | kfree(n->pf); |
684 | kfree(n->pf); | ||
685 | #endif | 683 | #endif |
686 | kfree(n); | 684 | kfree(n); |
687 | return err; | 685 | return err; |
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c index a17375141c3a..6ba8d6f45fe8 100644 --- a/sound/oss/dmasound/dmasound_awacs.c +++ b/sound/oss/dmasound/dmasound_awacs.c | |||
@@ -88,8 +88,6 @@ | |||
88 | #include <linux/pmu.h> | 88 | #include <linux/pmu.h> |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | #include <linux/i2c-dev.h> | ||
92 | |||
93 | #include <asm/uaccess.h> | 91 | #include <asm/uaccess.h> |
94 | #include <asm/prom.h> | 92 | #include <asm/prom.h> |
95 | #include <asm/machdep.h> | 93 | #include <asm/machdep.h> |
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c index 08cde51177d7..aa09ebd9ffb8 100644 --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/i2c-dev.h> | ||
26 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <sound/core.h> | 27 | #include <sound/core.h> |
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index 6058c2dd1b7f..fb05938dcbd9 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/i2c-dev.h> | ||
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <sound/core.h> | 27 | #include <sound/core.h> |
29 | #include "pmac.h" | 28 | #include "pmac.h" |
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c index 053b8f24e4dc..210be20dc27e 100644 --- a/sound/ppc/toonie.c +++ b/sound/ppc/toonie.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/i2c-dev.h> | ||
26 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 838fc113c441..1146dd882bb1 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/i2c-dev.h> | ||
32 | #include <linux/kmod.h> | 31 | #include <linux/kmod.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |