linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Wolfram Sang <wsa@the-dreams.de>, David Airlie <airlied@linux.ie>,
	Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
	alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 0/8] i2c: Remove redundant driver field from the i2c_client struct
Date: Sun, 29 Sep 2013 10:50:58 +0200	[thread overview]
Message-ID: <1380444666-12019-1-git-send-email-lars@metafoo.de> (raw)

Hi,

This series removes the redundant driver field from the i2c_client struct. The
field is redundant since the same pointer can be accessed through
to_i2c_driver(client->dev.driver). The commit log suggests that the field has
been around since forever (since before v2.6.12-rc2) and it looks as if it was
simply forgotten to remove it during the conversion of the i2c framework to the
generic device driver model.

Nevertheless there are a still a few users of the field around. This series
first updates all users to use an alternative method of accessing the same data
and then the last patch removes the driver field from the i2c_client struct.

Note that due to this changes on most architectures neither the code size nor
the type of generated instructions will change. This is due to the fact that we
aren't really interested in the pointer value itself, but rather want to
dereference it to access one of the fields of the struct. offset_of() (and hence
to_i2c_driver) works by subtracting a offset from the pointer, so the compiler
can internally create the sum of these two offsets and use that to access the
field.

E.g. on ARM the expression client->driver->command(...) generates

		...
		ldr     r3, [r0, #28]
		ldr     r3, [r3, #32]
		blx     r3
		...

and the expression to_i2c_driver(client->dev.driver)->command(...) generates

		...
		ldr     r3, [r0, #160]
    	ldr     r3, [r3, #-4]
    	blx     r3
		...

Other architectures will generate similar code.

The most common pattern is to use the i2c_driver to get to the device_driver
struct embedded in it. The same struct can easily be accessed through the device
struct embedded in the i2c_client struct.  E.g. client->driver->driver.field can
be replaced by client->dev.driver->field. Here again the generated code is
almost identical and only the offsets differ.

E.g. on ARM the expression 'client->driver->driver.owner' generates

		ldr     r3, [r0, #28]
		ldr     r0, [r3, #44]

and 'client->dev.driver->owner' generates

		ldr     r3, [r0, #160]
		ldr     r0, [r3, #8]

The kernel overall code size is slightly reduced since the code that manages the
driver field is removed and of course also the runtime memory footprint of the
i2c_client struct is reduced.

- Lars

Lars-Peter Clausen (8):
  [media] s5c73m3: Don't use i2c_client->driver
  [media] exynos4-is: Don't use i2c_client->driver
  [media] core: Don't use i2c_client->driver
  drm: encoder_slave: Don't use i2c_client->driver
  drm: nouveau: Don't use i2c_client->driver
  ALSA: ppc: keywest: Don't use i2c_client->driver
  ASoC: imx-wm8962: Don't use i2c_client->driver
  i2c: Remove redundant 'driver' field from the i2c_client struct

 drivers/gpu/drm/drm_encoder_slave.c            |  8 ++++----
 drivers/gpu/drm/nouveau/core/subdev/therm/ic.c |  3 ++-
 drivers/i2c/i2c-core.c                         | 21 ++++++++++++---------
 drivers/i2c/i2c-smbus.c                        | 10 ++++++----
 drivers/media/i2c/s5c73m3/s5c73m3-core.c       |  2 +-
 drivers/media/platform/exynos4-is/media-dev.c  |  6 +++---
 drivers/media/v4l2-core/tuner-core.c           |  6 +++---
 drivers/media/v4l2-core/v4l2-common.c          | 10 +++++-----
 include/linux/i2c.h                            |  2 --
 include/media/v4l2-common.h                    |  2 +-
 sound/ppc/keywest.c                            |  4 ++--
 sound/soc/fsl/imx-wm8962.c                     |  2 +-
 12 files changed, 40 insertions(+), 36 deletions(-)

-- 
1.8.0

             reply	other threads:[~2013-09-29  8:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-29  8:50 Lars-Peter Clausen [this message]
2013-09-29  8:50 ` [PATCH 1/8] [media] s5c73m3: Don't use i2c_client->driver Lars-Peter Clausen
     [not found]   ` <1380444666-12019-2-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-09-29 17:45     ` [alsa-devel] " Sylwester Nawrocki
2013-09-29  8:51 ` [PATCH 2/8] [media] exynos4-is: " Lars-Peter Clausen
     [not found]   ` <1380444666-12019-3-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-09-29 17:46     ` [alsa-devel] " Sylwester Nawrocki
2013-10-17 17:46   ` Mauro Carvalho Chehab
2013-09-29  8:51 ` [PATCH 3/8] [media] core: " Lars-Peter Clausen
2013-09-30 12:49   ` Hans Verkuil
2013-10-17 17:45   ` Mauro Carvalho Chehab
2013-09-29  8:51 ` [PATCH 4/8] drm: encoder_slave: " Lars-Peter Clausen
2013-09-29  8:51 ` [PATCH 5/8] drm: nouveau: " Lars-Peter Clausen
2013-09-29  8:51 ` [PATCH 6/8] ALSA: ppc: keywest: " Lars-Peter Clausen
     [not found]   ` <1380444666-12019-7-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-09-30  9:22     ` Takashi Iwai
2013-09-29  8:51 ` [PATCH 7/8] ASoC: imx-wm8962: " Lars-Peter Clausen
     [not found]   ` <1380444666-12019-8-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-09-29 12:23     ` Mark Brown
2013-09-29  8:51 ` [PATCH 8/8] i2c: Remove redundant 'driver' field from the i2c_client struct Lars-Peter Clausen
     [not found] ` <1380444666-12019-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-09-29 17:41   ` [PATCH 0/8] i2c: Remove redundant driver " Wolfram Sang
2013-10-03 20:38 ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380444666-12019-1-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=airlied@linux.ie \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).