android_kernel_motorola_sm6225/drivers
Yann Droneaud 1cec24c59b driver core/platform: remove unused implicit padding in platform_object
Up to 7 bytes are wasted at the end of struct platform_object
in the form of padding after name field: unfortunately this
padding is not used when allocating the memory to hold the
name.

This patch converts name array from name[1] to C99 flexible
array name[] (equivalent to name[0]) so that no padding is
required by the presence of this field. Memory allocation
is updated to take care of allocating an additional byte for
the NUL terminating character.

Built on Fedora 20, using GCC 4.8, for ARM, i386, SPARC64 and
x86_64 architectures, the data structure layout can be reported
with following command:

  $ pahole drivers/base/platform.o \
           --recursive             \
           --class_name device,pdev_archdata,platform_device,platform_object

Please find below some comparisons of structure layout for arm,
i386, sparc64 and x86_64 architecture before and after the patch.

  --- obj-arm/drivers/base/platform.o.pahole.v3.15-rc7-79-gfe45736f4134	2014-05-30 10:32:06.290960701 +0200
  +++ obj-arm/drivers/base/platform.o.pahole.v3.15-rc7-80-g2cdb06858d71	2014-05-30 11:26:20.851988347 +0200
  @@ -81,10 +81,9 @@
     /* XXX last struct has 4 bytes of padding */

  	/* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
  -	char                       name[1];              /*   392     1 */
  +	char                       name[0];              /*   392     0 */

  -	/* size: 400, cachelines: 7, members: 2 */
  -	/* padding: 7 */
  +	/* size: 392, cachelines: 7, members: 2 */
   	/* paddings: 1, sum paddings: 4 */
  -	/* last cacheline: 16 bytes */
  +	/* last cacheline: 8 bytes */
   };

  --- obj-i386/drivers/base/platform.o.pahole.v3.15-rc7-79-gfe45736f4134 2014-05-30 10:32:06.305960691 +0200
  +++ obj-i386/drivers/base/platform.o.pahole.v3.15-rc7-80-g2cdb06858d71 2014-05-30 11:26:20.875988332 +0200
  @@ -73,9 +73,8 @@
   struct platform_object {
   	struct platform_device     pdev;                 /*     0   396 */
   	/* --- cacheline 6 boundary (384 bytes) was 12 bytes ago --- */
  -	char                       name[1];              /*   396     1 */
  +	char                       name[0];              /*   396     0 */

  -	/* size: 400, cachelines: 7, members: 2 */
  -	/* padding: 3 */
  -	/* last cacheline: 16 bytes */
  +	/* size: 396, cachelines: 7, members: 2 */
  +	/* last cacheline: 12 bytes */
   };

  --- obj-sparc64/drivers/base/platform.o.pahole.v3.15-rc7-79-gfe45736f4134 2014-05-30 10:32:06.406960625 +0200
  +++ obj-sparc64/drivers/base/platform.o.pahole.v3.15-rc7-80-g2cdb06858d71 2014-05-30 11:26:20.971988269 +0200
  @@ -94,9 +94,8 @@
   struct platform_object {
   	struct platform_device     pdev;                 /*     0  2208 */
   	/* --- cacheline 34 boundary (2176 bytes) was 32 bytes ago --- */
  -	char                       name[1];              /*  2208     1 */
  +	char                       name[0];              /*  2208     0 */

  -	/* size: 2216, cachelines: 35, members: 2 */
  -	/* padding: 7 */
  -	/* last cacheline: 40 bytes */
  +	/* size: 2208, cachelines: 35, members: 2 */
  +	/* last cacheline: 32 bytes */
   };

  --- obj-x86_64/drivers/base/platform.o.pahole.v3.15-rc7-79-gfe45736f4134 2014-05-30 10:32:06.432960608 +0200
  +++ obj-x86_64/drivers/base/platform.o.pahole.v3.15-rc7-80-g2cdb06858d71 2014-05-30 11:26:21.000988250 +0200
  @@ -84,9 +84,8 @@
   struct platform_object {
   	struct platform_device     pdev;                 /*     0   720 */
   	/* --- cacheline 11 boundary (704 bytes) was 16 bytes ago --- */
  -	char                       name[1];              /*   720     1 */
  +	char                       name[0];              /*   720     0 */

  -	/* size: 728, cachelines: 12, members: 2 */
  -	/* padding: 7 */
  -	/* last cacheline: 24 bytes */
  +	/* size: 720, cachelines: 12, members: 2 */
  +	/* last cacheline: 16 bytes */
   };

Changes from v5 [1]:
- dropped dma_mask allocation changes and only kept padding
  removal changes (name array length set to 0).

Changes from v4 [2]:
[by Emil Goode <emilgoode@gmail.com>:]
- Split v4 of the patch into two separate patches.
- Generated new object file size and data structure layout info.
- Updated the changelog message.

Changes from v3 [3]:
- fixed commit message so that git am doesn't fail.

Changes from v2 [4]:
- move 'dma_mask' to platform_object so that it's always
  allocated and won't leak on release; remove all previously
  added support functions.
- use C99 flexible array member for 'name' to remove padding
  at the end of platform_object.

Changes from v1 [5]:
- remove unneeded kfree() from error path
- add reference to author/commit adding allocation of dmamask

Changes from v0 [6]:
- small rewrite to squeeze the patch to a bare minimal

[1] http://lkml.kernel.org/r/1401122483-31603-2-git-send-email-emilgoode@gmail.com
    http://lkml.kernel.org/r/1401122483-31603-1-git-send-email-emilgoode@gmail.com
    http://lkml.kernel.org/r/1401122483-31603-3-git-send-email-emilgoode@gmail.com

[2] http://lkml.kernel.org/r/1390817152-30898-1-git-send-email-ydroneaud@opteya.com
    https://patchwork.kernel.org/patch/3541871/

[3] http://lkml.kernel.org/r/1390771138-28348-1-git-send-email-ydroneaud@opteya.com
    https://patchwork.kernel.org/patch/3540081/

[4] http://lkml.kernel.org/r/1389683909-17495-1-git-send-email-ydroneaud@opteya.com
    https://patchwork.kernel.org/patch/3484411/

[5] http://lkml.kernel.org/r/1389649085-7365-1-git-send-email-ydroneaud@opteya.com
    https://patchwork.kernel.org/patch/3480961/

[6] http://lkml.kernel.org/r/1386886207-2735-1-git-send-email-ydroneaud@opteya.com

Cc: Emil Goode <emilgoode@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Shawn Guo <shawn.guo@freescale.com>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Olof Johansson <olof@lixom.net>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-08 15:30:39 -07:00
..
accessibility
acpi Merge branches 'acpi-general', 'acpi-processor', 'acpi-lpss' and 'acpi-battery' 2014-06-19 14:40:48 +02:00
amba
ata Merge branch 'for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata 2014-06-09 14:58:36 -07:00
atm atm: fore200e.c: Cleaning up uninitialized variables 2014-06-02 17:11:03 -07:00
auxdisplay
base driver core/platform: remove unused implicit padding in platform_object 2014-07-08 15:30:39 -07:00
bcma
block zram: revalidate disk after capacity change 2014-07-03 09:21:53 -07:00
bluetooth Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
bus Merge branch 'component-for-driver' of git://ftp.arm.linux.org.uk/~rmk/linux-arm into driver-core-next 2014-07-03 12:48:59 -07:00
cdrom Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2014-06-11 08:41:17 -07:00
char random: fix entropy accounting bug introduced in v3.15 2014-06-17 14:23:14 -10:00
clk This pull request contains the second half the of the clk changes for 2014-06-15 16:02:20 -10:00
clocksource clocksource: exynos_mct: Don't reset the counter during boot and resume 2014-06-17 00:23:29 +09:00
connector Char / misc driver patches for 3.16-rc1 2014-06-03 08:06:56 -07:00
cpufreq cpufreq: unlock when failing cpufreq_update_policy() 2014-06-18 21:52:20 +02:00
cpuidle cpuidle: mvebu: Fix the name of the states 2014-06-18 21:54:46 +02:00
crypto crypto/nx: disable NX on little endian builds 2014-06-11 17:03:19 +10:00
dca
devfreq
dio
dma Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2014-06-10 10:28:45 -07:00
dma-buf reservation: add suppport for read-only access using rcu 2014-07-08 13:41:08 -07:00
edac PCI changes for the v3.16 merge window: 2014-06-02 12:15:19 -07:00
eisa
extcon
firewire sound updates for 3.16-rc1 2014-06-04 09:08:25 -07:00
firmware efi-pstore: Fix an overflow on 32-bit builds 2014-06-27 07:30:32 +01:00
fmc
gpio gpio: of: Fix handling for deferred probe for -gpio suffix 2014-06-12 09:57:00 +02:00
gpu dma-buf: use reservation objects 2014-07-08 13:03:20 -07:00
hid Most of this is cleaning up various driver sysfs permissions so we can 2014-06-11 16:09:14 -07:00
hsi hsi: omap_ssi_port: use normal module refcounting 2014-06-05 00:59:05 +02:00
hv Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
hwmon hwmon: (gpio-fan) Change name used in hwmon_device_register_with_groups 2014-06-25 15:16:09 -07:00
hwspinlock
i2c i2c: sun6-p2wi: fix call to snprintf 2014-06-17 14:28:04 +02:00
ide
idle
iio iio: of_iio_channel_get_by_name() returns non-null pointers for error legs 2014-06-21 12:31:38 +01:00
infiniband Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2014-06-12 22:38:32 -07:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2014-06-09 18:46:02 -07:00
iommu iommu/amd: Fix small race between invalidate_range_end/start 2014-06-20 16:14:22 +02:00
ipack
irqchip irqchip: spear_shirq: Fix interrupt offset 2014-06-21 23:26:39 +00:00
isdn isdn: hisax: Drop duplicate Kconfig entry 2014-06-16 21:31:37 -07:00
leds Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds 2014-06-12 13:08:09 -07:00
lguest
macintosh powerpc/macintosh/smu.c: Fix closing brace followed by if 2014-06-24 12:43:15 +10:00
mailbox
mcb
md md: flush writes before starting a recovery. 2014-07-03 10:44:45 +10:00
media dma-buf: use reservation objects 2014-07-08 13:03:20 -07:00
memory
memstick drivers/memstick/host/rtsx_pci_ms.c: add cancel_work when remove driver 2014-06-23 16:47:44 -07:00
message
mfd mfd: ab8500: Fix dt irq mapping 2014-06-26 13:34:15 +01:00
misc ARM: SoC fixes for 3.16 2014-06-25 12:19:01 -07:00
mmc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
mtd Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-06-12 10:30:18 -07:00
net net: allwinner: emac: Add missing free_irq 2014-06-25 16:31:17 -07:00
nfc
ntb
nubus kernel/printk: use symbolic defines for console loglevels 2014-06-04 16:54:17 -07:00
of Devicetree bugfixe for v3.16 2014-07-06 12:11:57 -07:00
oprofile
parisc
parport parport: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:15 -07:00
pci PCI changes for the v3.16 merge window (part 2): 2014-06-12 13:20:24 -07:00
pcmcia
phy
pinctrl This is the bulk of pin control changes for the v3.16 2014-06-03 11:20:32 -07:00
platform Merge branch 'for_linus' of git://cavan.codon.org.uk/platform-drivers-x86 2014-06-10 16:58:32 -07:00
pnp Merge branches 'pnp', 'powercap', 'pm-runtime' and 'pm-opp' 2014-06-03 23:13:00 +02:00
power ACPI and power management updates for 3.16-rc1 2014-06-04 08:57:16 -07:00
powercap
pps
ps3
ptp ptp: ptp_pch depends on x86_32 2014-06-17 15:43:48 -07:00
pwm pwm: Changes for v3.16-rc1 2014-06-11 14:06:55 -07:00
rapidio rapidio/tsi721: use pci_enable_msix_exact() instead of pci_enable_msix() 2014-06-06 16:08:13 -07:00
regulator Merge remote-tracking branches 'regulator/fix/bcm590xx', 'regulator/fix/palmas' and 'regulator/fix/tps65218' into regulator-linus 2014-06-28 14:01:04 +01:00
remoteproc remoteproc: da8xx: don't select CMA on no-MMU 2014-06-17 17:09:36 +02:00
reset ARM: SoC driver changes 2014-06-02 16:35:49 -07:00
rpmsg
rtc drivers/rtc/rtc-puv3.c: remove "&dev->" for typo issue MIME-Version: 1.0 2014-06-20 08:22:39 +08:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2014-06-21 06:47:01 -10:00
sbus
scsi SCSI for-linus on 20140705 2014-07-06 12:08:30 -07:00
sfi
sh SH Driver Update for v3.16 2014-06-06 11:44:09 -07:00
sn
soc
spi Merge remote-tracking branches 'spi/fix/pxa2xx', 'spi/fix/qup' and 'spi/fix/sh-sci' into spi-linus 2014-06-28 14:01:23 +01:00
spmi
ssb
staging android: convert sync to fence api, v6 2014-07-08 13:28:26 -07:00
target iscsi-target: fix iscsit_del_np deadlock on unload 2014-06-27 23:23:35 -07:00
tc TC: Handle device_register() errors. 2014-06-26 10:48:23 +01:00
thermal Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2014-06-11 14:26:21 -07:00
tty ARM: SoC fixes for 3.16 2014-06-25 12:19:01 -07:00
uio Revert "uio: fix vma io range check in mmap" 2014-06-17 16:07:08 -07:00
usb usb: chipidea: udc: delete td from req's td list at ep_dequeue 2014-07-01 23:06:02 -07:00
uwb
vfio A handful of VFIO bug fixes for v3.16 2014-06-07 20:12:15 -07:00
vhost vhost-scsi: don't open-code kvfree 2014-06-23 09:22:48 +03:00
video fb: adv7393: add missing semicolon 2014-07-01 13:18:38 +03:00
virt
virtio
vlynq
vme
w1 w1: mxc_w1: Fix incorrect "presence" status 2014-06-19 17:51:46 -07:00
watchdog Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2014-06-21 06:47:01 -10:00
xen xen: regression and PVH fixes for 3.16-rc1 2014-06-19 07:53:27 -10:00
zorro
Kconfig
Makefile dma-buf: move to drivers/dma-buf 2014-07-08 10:51:06 -07:00