Skip to content

Commit 0ca7ffb

Browse files
committed
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild changes from Michal Marek: - Alias generation in modpost is cross-compile safe. - kernel/timeconst.h is now generated using a bc script instead of perl. - scripts/link-vmlinux.sh now works with an alternative $KCONFIG_CONFIG. - destination-y for exported headers is supported in Kbuild files again. - depmod is called with -P $CONFIG_SYMBOL_PREFIX on architectures that need it. - CONFIG_DEBUG_INFO_REDUCED disables var-tracking - scripts/setlocalversion works with too much translated locales ;) * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kbuild: Fix reading of .config in link-vmlinux.sh kbuild: Unset language specific variables in setlocalversion script Kbuild: Disable var tracking with CONFIG_DEBUG_INFO_REDUCED depmod: pass -P $CONFIG_SYMBOL_PREFIX kbuild: Fix destination-y for installed headers scripts/link-vmlinux.sh: source variables from KCONFIG_CONFIG kernel: Replace timeconst.pl with a bc script mod/file2alias: make modalias generation safe for cross compiling
2 parents 30acd90 + 423a815 commit 0ca7ffb

15 files changed

Lines changed: 749 additions & 758 deletions

‎Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
192192
# "make" in the configured kernel build directory always uses that.
193193
# Default value for CROSS_COMPILE is not to prefix executables
194194
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
195-
export KBUILD_BUILDHOST := $(SUBARCH)
196195
ARCH ?= $(SUBARCH)
197196
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
198197

@@ -620,7 +619,8 @@ KBUILD_AFLAGS += -gdwarf-2
620619
endif
621620

622621
ifdef CONFIG_DEBUG_INFO_REDUCED
623-
KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly)
622+
KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
623+
$(call cc-option,-fno-var-tracking)
624624
endif
625625

626626
ifdef CONFIG_FUNCTION_TRACER
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
13981398
# Run depmod only if we have System.map and depmod is executable
13991399
quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
14001400
cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
1401-
$(KERNELRELEASE)
1401+
$(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))"
14021402

14031403
# Create temporary dir for module support files
14041404
# clean it up only when building all modules

‎include/linux/mod_devicetable.h‎

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ struct ieee1394_device_id {
3333
__u32 model_id;
3434
__u32 specifier_id;
3535
__u32 version;
36-
kernel_ulong_t driver_data
37-
__attribute__((aligned(sizeof(kernel_ulong_t))));
36+
kernel_ulong_t driver_data;
3837
};
3938

4039

@@ -148,8 +147,7 @@ struct hid_device_id {
148147
__u16 group;
149148
__u32 vendor;
150149
__u32 product;
151-
kernel_ulong_t driver_data
152-
__attribute__((aligned(sizeof(kernel_ulong_t))));
150+
kernel_ulong_t driver_data;
153151
};
154152

155153
/* s390 CCW devices */
@@ -173,8 +171,6 @@ struct ccw_device_id {
173171
struct ap_device_id {
174172
__u16 match_flags; /* which fields to match against */
175173
__u8 dev_type; /* device type */
176-
__u8 pad1;
177-
__u32 pad2;
178174
kernel_ulong_t driver_info;
179175
};
180176

@@ -184,13 +180,10 @@ struct ap_device_id {
184180
struct css_device_id {
185181
__u8 match_flags;
186182
__u8 type; /* subchannel type */
187-
__u16 pad2;
188-
__u32 pad3;
189183
kernel_ulong_t driver_data;
190184
};
191185

192-
#define ACPI_ID_LEN 16 /* only 9 bytes needed here, 16 bytes are used */
193-
/* to workaround crosscompile issues */
186+
#define ACPI_ID_LEN 9
194187

195188
struct acpi_device_id {
196189
__u8 id[ACPI_ID_LEN];
@@ -231,11 +224,7 @@ struct of_device_id
231224
char name[32];
232225
char type[32];
233226
char compatible[128];
234-
#ifdef __KERNEL__
235227
const void *data;
236-
#else
237-
kernel_ulong_t data;
238-
#endif
239228
};
240229

241230
/* VIO */
@@ -260,24 +249,14 @@ struct pcmcia_device_id {
260249
/* for pseudo multi-function devices */
261250
__u8 device_no;
262251

263-
__u32 prod_id_hash[4]
264-
__attribute__((aligned(sizeof(__u32))));
252+
__u32 prod_id_hash[4];
265253

266254
/* not matched against in kernelspace*/
267-
#ifdef __KERNEL__
268255
const char * prod_id[4];
269-
#else
270-
kernel_ulong_t prod_id[4]
271-
__attribute__((aligned(sizeof(kernel_ulong_t))));
272-
#endif
273256

274257
/* not matched against */
275258
kernel_ulong_t driver_info;
276-
#ifdef __KERNEL__
277259
char * cisfile;
278-
#else
279-
kernel_ulong_t cisfile;
280-
#endif
281260
};
282261

283262
#define PCMCIA_DEV_ID_MATCH_MANF_ID 0x0001
@@ -373,8 +352,7 @@ struct sdio_device_id {
373352
__u8 class; /* Standard interface or SDIO_ANY_ID */
374353
__u16 vendor; /* Vendor or SDIO_ANY_ID */
375354
__u16 device; /* Device ID or SDIO_ANY_ID */
376-
kernel_ulong_t driver_data /* Data private to the driver */
377-
__attribute__((aligned(sizeof(kernel_ulong_t))));
355+
kernel_ulong_t driver_data; /* Data private to the driver */
378356
};
379357

380358
/* SSB core, see drivers/ssb/ */
@@ -420,8 +398,7 @@ struct virtio_device_id {
420398
*/
421399
struct hv_vmbus_device_id {
422400
__u8 guid[16];
423-
kernel_ulong_t driver_data /* Data private to the driver */
424-
__attribute__((aligned(sizeof(kernel_ulong_t))));
401+
kernel_ulong_t driver_data; /* Data private to the driver */
425402
};
426403

427404
/* rpmsg */
@@ -440,8 +417,7 @@ struct rpmsg_device_id {
440417

441418
struct i2c_device_id {
442419
char name[I2C_NAME_SIZE];
443-
kernel_ulong_t driver_data /* Data private to the driver */
444-
__attribute__((aligned(sizeof(kernel_ulong_t))));
420+
kernel_ulong_t driver_data; /* Data private to the driver */
445421
};
446422

447423
/* spi */
@@ -451,8 +427,7 @@ struct i2c_device_id {
451427

452428
struct spi_device_id {
453429
char name[SPI_NAME_SIZE];
454-
kernel_ulong_t driver_data /* Data private to the driver */
455-
__attribute__((aligned(sizeof(kernel_ulong_t))));
430+
kernel_ulong_t driver_data; /* Data private to the driver */
456431
};
457432

458433
/* dmi */
@@ -484,15 +459,6 @@ struct dmi_strmatch {
484459
char substr[79];
485460
};
486461

487-
#ifndef __KERNEL__
488-
struct dmi_system_id {
489-
kernel_ulong_t callback;
490-
kernel_ulong_t ident;
491-
struct dmi_strmatch matches[4];
492-
kernel_ulong_t driver_data
493-
__attribute__((aligned(sizeof(kernel_ulong_t))));
494-
};
495-
#else
496462
struct dmi_system_id {
497463
int (*callback)(const struct dmi_system_id *);
498464
const char *ident;
@@ -506,7 +472,6 @@ struct dmi_system_id {
506472
* error: storage size of '__mod_dmi_device_table' isn't known
507473
*/
508474
#define dmi_device_id dmi_system_id
509-
#endif
510475

511476
#define DMI_MATCH(a, b) { a, b }
512477

@@ -515,8 +480,7 @@ struct dmi_system_id {
515480

516481
struct platform_device_id {
517482
char name[PLATFORM_NAME_SIZE];
518-
kernel_ulong_t driver_data
519-
__attribute__((aligned(sizeof(kernel_ulong_t))));
483+
kernel_ulong_t driver_data;
520484
};
521485

522486
#define MDIO_MODULE_PREFIX "mdio:"
@@ -572,11 +536,7 @@ struct isapnp_device_id {
572536
struct amba_id {
573537
unsigned int id;
574538
unsigned int mask;
575-
#ifndef __KERNEL__
576-
kernel_ulong_t data;
577-
#else
578539
void *data;
579-
#endif
580540
};
581541

582542
/*

‎kernel/Makefile‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,19 @@ $(obj)/config_data.h: $(obj)/config_data.gz FORCE
127127

128128
$(obj)/time.o: $(obj)/timeconst.h
129129

130-
quiet_cmd_timeconst = TIMEC $@
131-
cmd_timeconst = $(PERL) $< $(CONFIG_HZ) > $@
130+
quiet_cmd_hzfile = HZFILE $@
131+
cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@
132+
133+
targets += hz.bc
134+
$(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE
135+
$(call if_changed,hzfile)
136+
137+
quiet_cmd_bc = BC $@
138+
cmd_bc = bc -q $(filter-out FORCE,$^) > $@
139+
132140
targets += timeconst.h
133-
$(obj)/timeconst.h: $(src)/timeconst.pl FORCE
134-
$(call if_changed,timeconst)
141+
$(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE
142+
$(call if_changed,bc)
135143

136144
ifeq ($(CONFIG_MODULE_SIG),y)
137145
#

‎kernel/timeconst.bc‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
scale=0
2+
3+
define gcd(a,b) {
4+
auto t;
5+
while (b) {
6+
t = b;
7+
b = a % b;
8+
a = t;
9+
}
10+
return a;
11+
}
12+
13+
/* Division by reciprocal multiplication. */
14+
define fmul(b,n,d) {
15+
return (2^b*n+d-1)/d;
16+
}
17+
18+
/* Adjustment factor when a ceiling value is used. Use as:
19+
(imul * n) + (fmulxx * n + fadjxx) >> xx) */
20+
define fadj(b,n,d) {
21+
auto v;
22+
d = d/gcd(n,d);
23+
v = 2^b*(d-1)/d;
24+
return v;
25+
}
26+
27+
/* Compute the appropriate mul/adj values as well as a shift count,
28+
which brings the mul value into the range 2^b-1 <= x < 2^b. Such
29+
a shift value will be correct in the signed integer range and off
30+
by at most one in the upper half of the unsigned range. */
31+
define fmuls(b,n,d) {
32+
auto s, m;
33+
for (s = 0; 1; s++) {
34+
m = fmul(s,n,d);
35+
if (m >= 2^(b-1))
36+
return s;
37+
}
38+
return 0;
39+
}
40+
41+
define timeconst(hz) {
42+
print "/* Automatically generated by kernel/timeconst.bc */\n"
43+
print "/* Time conversion constants for HZ == ", hz, " */\n"
44+
print "\n"
45+
46+
print "#ifndef KERNEL_TIMECONST_H\n"
47+
print "#define KERNEL_TIMECONST_H\n\n"
48+
49+
print "#include <linux/param.h>\n"
50+
print "#include <linux/types.h>\n\n"
51+
52+
print "#if HZ != ", hz, "\n"
53+
print "#error \qkernel/timeconst.h has the wrong HZ value!\q\n"
54+
print "#endif\n\n"
55+
56+
if (hz < 2) {
57+
print "#error Totally bogus HZ value!\n"
58+
} else {
59+
s=fmuls(32,1000,hz)
60+
obase=16
61+
print "#define HZ_TO_MSEC_MUL32\tU64_C(0x", fmul(s,1000,hz), ")\n"
62+
print "#define HZ_TO_MSEC_ADJ32\tU64_C(0x", fadj(s,1000,hz), ")\n"
63+
obase=10
64+
print "#define HZ_TO_MSEC_SHR32\t", s, "\n"
65+
66+
s=fmuls(32,hz,1000)
67+
obase=16
68+
print "#define MSEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000), ")\n"
69+
print "#define MSEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000), ")\n"
70+
obase=10
71+
print "#define MSEC_TO_HZ_SHR32\t", s, "\n"
72+
73+
obase=10
74+
cd=gcd(hz,1000)
75+
print "#define HZ_TO_MSEC_NUM\t\t", 1000/cd, "\n"
76+
print "#define HZ_TO_MSEC_DEN\t\t", hz/cd, "\n"
77+
print "#define MSEC_TO_HZ_NUM\t\t", hz/cd, "\n"
78+
print "#define MSEC_TO_HZ_DEN\t\t", 1000/cd, "\n"
79+
print "\n"
80+
81+
s=fmuls(32,1000000,hz)
82+
obase=16
83+
print "#define HZ_TO_USEC_MUL32\tU64_C(0x", fmul(s,1000000,hz), ")\n"
84+
print "#define HZ_TO_USEC_ADJ32\tU64_C(0x", fadj(s,1000000,hz), ")\n"
85+
obase=10
86+
print "#define HZ_TO_USEC_SHR32\t", s, "\n"
87+
88+
s=fmuls(32,hz,1000000)
89+
obase=16
90+
print "#define USEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000000), ")\n"
91+
print "#define USEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000000), ")\n"
92+
obase=10
93+
print "#define USEC_TO_HZ_SHR32\t", s, "\n"
94+
95+
obase=10
96+
cd=gcd(hz,1000000)
97+
print "#define HZ_TO_USEC_NUM\t\t", 1000000/cd, "\n"
98+
print "#define HZ_TO_USEC_DEN\t\t", hz/cd, "\n"
99+
print "#define USEC_TO_HZ_NUM\t\t", hz/cd, "\n"
100+
print "#define USEC_TO_HZ_DEN\t\t", 1000000/cd, "\n"
101+
print "\n"
102+
103+
print "#endif /* KERNEL_TIMECONST_H */\n"
104+
}
105+
halt
106+
}
107+
108+
timeconst(hz)

0 commit comments

Comments
 (0)