Skip to content

Commit 5cb480f

Browse files
committed
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull misc kbuild changes from Michal Marek: "The non-critical part of kbuild is small this time: - Three fixes for make deb-pkg - A new coccinelle check One of the deb-pkg fixes is a leftover from the last merge window, hence the merge commit" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: deb-pkg: Fix building for MIPS big-endian or ARM OABI deb-pkg: Fix cross-building linux-headers package scripts: Coccinelle script for pm_runtime_* return checks with IS_ERR_VALUE deb-pkg: Inhibit initramfs builders if CONFIG_BLK_DEV_INITRD is not set
2 parents 1bda2ac + c5e318f commit 5cb480f

File tree

2 files changed

+126
-8
lines changed

2 files changed

+126
-8
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/// Make sure pm_runtime_* calls does not use unnecessary IS_ERR_VALUE
2+
//
3+
// Keywords: pm_runtime
4+
// Confidence: Medium
5+
// Copyright (C) 2013 Texas Instruments Incorporated - GPLv2.
6+
// URL: http://coccinelle.lip6.fr/
7+
// Options: --include-headers
8+
9+
virtual patch
10+
virtual context
11+
virtual org
12+
virtual report
13+
14+
//----------------------------------------------------------
15+
// Detection
16+
//----------------------------------------------------------
17+
18+
@runtime_bad_err_handle exists@
19+
expression ret;
20+
@@
21+
(
22+
ret = \(pm_runtime_idle\|
23+
pm_runtime_suspend\|
24+
pm_runtime_autosuspend\|
25+
pm_runtime_resume\|
26+
pm_request_idle\|
27+
pm_request_resume\|
28+
pm_request_autosuspend\|
29+
pm_runtime_get\|
30+
pm_runtime_get_sync\|
31+
pm_runtime_put\|
32+
pm_runtime_put_autosuspend\|
33+
pm_runtime_put_sync\|
34+
pm_runtime_put_sync_suspend\|
35+
pm_runtime_put_sync_autosuspend\|
36+
pm_runtime_set_active\|
37+
pm_schedule_suspend\|
38+
pm_runtime_barrier\|
39+
pm_generic_runtime_suspend\|
40+
pm_generic_runtime_resume\)(...);
41+
...
42+
IS_ERR_VALUE(ret)
43+
...
44+
)
45+
46+
//----------------------------------------------------------
47+
// For context mode
48+
//----------------------------------------------------------
49+
50+
@depends on runtime_bad_err_handle && context@
51+
identifier pm_runtime_api;
52+
expression ret;
53+
@@
54+
(
55+
ret = pm_runtime_api(...);
56+
...
57+
* IS_ERR_VALUE(ret)
58+
...
59+
)
60+
61+
//----------------------------------------------------------
62+
// For patch mode
63+
//----------------------------------------------------------
64+
65+
@depends on runtime_bad_err_handle && patch@
66+
identifier pm_runtime_api;
67+
expression ret;
68+
@@
69+
(
70+
ret = pm_runtime_api(...);
71+
...
72+
- IS_ERR_VALUE(ret)
73+
+ ret < 0
74+
...
75+
)
76+
77+
//----------------------------------------------------------
78+
// For org and report mode
79+
//----------------------------------------------------------
80+
81+
@r depends on runtime_bad_err_handle exists@
82+
position p1, p2;
83+
identifier pm_runtime_api;
84+
expression ret;
85+
@@
86+
(
87+
ret = pm_runtime_api@p1(...);
88+
...
89+
IS_ERR_VALUE@p2(ret)
90+
...
91+
)
92+
93+
@script:python depends on org@
94+
p1 << r.p1;
95+
p2 << r.p2;
96+
pm_runtime_api << r.pm_runtime_api;
97+
@@
98+
99+
cocci.print_main(pm_runtime_api,p1)
100+
cocci.print_secs("IS_ERR_VALUE",p2)
101+
102+
@script:python depends on report@
103+
p1 << r.p1;
104+
p2 << r.p2;
105+
pm_runtime_api << r.pm_runtime_api;
106+
@@
107+
108+
msg = "%s returns < 0 as error. Unecessary IS_ERR_VALUE at line %s" % (pm_runtime_api, p2[0].line)
109+
coccilib.report.print_report(p1[0],msg)

scripts/package/builddeb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ create_package() {
4141
parisc*)
4242
debarch=hppa ;;
4343
mips*)
44-
debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el) ;;
44+
debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;;
4545
arm*)
46-
debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el) ;;
46+
debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
4747
*)
4848
echo "" >&2
4949
echo "** ** ** WARNING ** ** **" >&2
@@ -62,7 +62,7 @@ create_package() {
6262
fi
6363

6464
# Create the package
65-
dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
65+
dpkg-gencontrol -isp $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir"
6666
dpkg --build "$pdir" ..
6767
}
6868

@@ -172,8 +172,15 @@ fi
172172

173173
# Install the maintainer scripts
174174
# Note: hook scripts under /etc/kernel are also executed by official Debian
175-
# kernel packages, as well as kernel packages built using make-kpkg
175+
# kernel packages, as well as kernel packages built using make-kpkg.
176+
# make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and
177+
# so do we; recent versions of dracut and initramfs-tools will obey this.
176178
debhookdir=${KDEB_HOOKDIR:-/etc/kernel}
179+
if grep -q '^CONFIG_BLK_DEV_INITRD=y' $KCONFIG_CONFIG; then
180+
want_initrd=Yes
181+
else
182+
want_initrd=No
183+
fi
177184
for script in postinst postrm preinst prerm ; do
178185
mkdir -p "$tmpdir$debhookdir/$script.d"
179186
cat <<EOF > "$tmpdir/DEBIAN/$script"
@@ -184,6 +191,9 @@ set -e
184191
# Pass maintainer script parameters to hook scripts
185192
export DEB_MAINT_PARAMS="\$*"
186193
194+
# Tell initramfs builder whether it's wanted
195+
export INITRD=$want_initrd
196+
187197
test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
188198
exit 0
189199
EOF
@@ -288,15 +298,14 @@ mkdir -p "$destdir"
288298
(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be
289299
ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
290300
rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
291-
arch=$(dpkg --print-architecture)
292301

293302
cat <<EOF >> debian/control
294303
295304
Package: $kernel_headers_packagename
296305
Provides: linux-headers, linux-headers-2.6
297-
Architecture: $arch
298-
Description: Linux kernel headers for $KERNELRELEASE on $arch
299-
This package provides kernel header files for $KERNELRELEASE on $arch
306+
Architecture: any
307+
Description: Linux kernel headers for $KERNELRELEASE on \${kernel:debarch}
308+
This package provides kernel header files for $KERNELRELEASE on \${kernel:debarch}
300309
.
301310
This is useful for people who need to build external modules
302311
EOF

0 commit comments

Comments
 (0)