All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
To: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	eric miao <eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
	Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: RFC: Working around dynamic device allocation in i2c.  Interaction with other subystems.
Date: Thu, 22 Jan 2009 12:55:02 +0000	[thread overview]
Message-ID: <49786CA6.8010303@cam.ac.uk> (raw)
In-Reply-To: <4974D20F.20209-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>

Added spi mailing list (+ likely interested people) as the same approach
is used for device registration as with i2c. 

> Dear All,
> 
> Within board configuration files, i2c devices are currently allocated using
> i2c_board_info structures.  The only element of these that retains it's
> memory address once the struct device elements are allocated (upon adapter
> initialization) is the platform data pointer.
> 
> Several subsystems (regulator and clock for example) use an association
> method based upon a device specific string associated with a pointer to
> a device structure.  Unfortunately as things currently stand there is no
> means of obtaining a suitable device for i2c devices at the point when
> it is required (in the board config).
> 
> So the question is, how to overcome this problem?
> 
> Options that I can come up with are:
> 
> 1) Relax the constraints that the token used for device identification
>    in subsystems using the regulators approach to a void * and use
>    the platform data pointer of an i2c device.  Note this requires
>    every device which may need a regulator to have platform data.
>    Whilst this would work, it is far from ideal.
As Mark Brown pointed out:
This would also remove the ability of the APIs using this to use the
struct device for other things like showing what they're doing in sysfs
or use dev_printk.
> 
> 2) Allow more static allocation of struct i2c_client.  The way of doing
>    this with minimal disruption would be to add a pointer to i2c_board_info
>    to a preallocated i2c_client structure and if this is supplied do not
>    allocate another.  A flag can then be used to indicated whether the
>    structure has been statically allocated or not (thus preventing it
>    being inadvertently freed.
> 
> 3) Allow static allocation of i2c_client structures as a direct alternative
>    to having any i2c_board_info structures at all.  As the majority if not
>    all of i2c_board_info's elements are simply copied into the i2c_client
>    structure anyway, there is considerable overhead in option 2.  Clearly
>    it would not be simple or necessarily advisable to remove i2c_board_info
>    structures so I would propose providing an alternative set of registration
>    functions which would only be used when people cared about the problem
>    we are addressing here.
> 
> What do people think? In particular can anyone come up with any other /
> better way round this issue. (or am I missing something?)
> In particular, are there any similar cases already in kernel that would
> suggest a particular approach to solving this issue?
> 
> I have an implementation of option 2 that works fine and is relatively simple.
> 
> Thanks,
> 
> ---
> Jonathan Cameron
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@cam.ac.uk>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-i2c@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	eric miao <eric.y.miao@gmail.com>,
	Jean Delvare <khali@linux-fr.org>,
	Ben Dooks <ben-linux@fluff.org>,
	David Brownell <david-b@pacbell.net>,
	spi-devel-general@lists.sourceforge.net
Subject: Re: RFC: Working around dynamic device allocation in i2c.  Interaction with other subystems.
Date: Thu, 22 Jan 2009 12:55:02 +0000	[thread overview]
Message-ID: <49786CA6.8010303@cam.ac.uk> (raw)
In-Reply-To: <4974D20F.20209@cam.ac.uk>

Added spi mailing list (+ likely interested people) as the same approach
is used for device registration as with i2c. 

> Dear All,
> 
> Within board configuration files, i2c devices are currently allocated using
> i2c_board_info structures.  The only element of these that retains it's
> memory address once the struct device elements are allocated (upon adapter
> initialization) is the platform data pointer.
> 
> Several subsystems (regulator and clock for example) use an association
> method based upon a device specific string associated with a pointer to
> a device structure.  Unfortunately as things currently stand there is no
> means of obtaining a suitable device for i2c devices at the point when
> it is required (in the board config).
> 
> So the question is, how to overcome this problem?
> 
> Options that I can come up with are:
> 
> 1) Relax the constraints that the token used for device identification
>    in subsystems using the regulators approach to a void * and use
>    the platform data pointer of an i2c device.  Note this requires
>    every device which may need a regulator to have platform data.
>    Whilst this would work, it is far from ideal.
As Mark Brown pointed out:
This would also remove the ability of the APIs using this to use the
struct device for other things like showing what they're doing in sysfs
or use dev_printk.
> 
> 2) Allow more static allocation of struct i2c_client.  The way of doing
>    this with minimal disruption would be to add a pointer to i2c_board_info
>    to a preallocated i2c_client structure and if this is supplied do not
>    allocate another.  A flag can then be used to indicated whether the
>    structure has been statically allocated or not (thus preventing it
>    being inadvertently freed.
> 
> 3) Allow static allocation of i2c_client structures as a direct alternative
>    to having any i2c_board_info structures at all.  As the majority if not
>    all of i2c_board_info's elements are simply copied into the i2c_client
>    structure anyway, there is considerable overhead in option 2.  Clearly
>    it would not be simple or necessarily advisable to remove i2c_board_info
>    structures so I would propose providing an alternative set of registration
>    functions which would only be used when people cared about the problem
>    we are addressing here.
> 
> What do people think? In particular can anyone come up with any other /
> better way round this issue. (or am I missing something?)
> In particular, are there any similar cases already in kernel that would
> suggest a particular approach to solving this issue?
> 
> I have an implementation of option 2 that works fine and is relatively simple.
> 
> Thanks,
> 
> ---
> Jonathan Cameron
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  parent reply	other threads:[~2009-01-22 12:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-19 19:18 RFC: Working around dynamic device allocation in i2c. Interaction with other subystems Jonathan Cameron
     [not found] ` <4974D20F.20209-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2009-01-19 19:37   ` Mark Brown
2009-01-19 19:37     ` Mark Brown
2009-01-22 12:55   ` Jonathan Cameron [this message]
2009-01-22 12:55     ` Jonathan Cameron
     [not found]     ` <49786CA6.8010303-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2009-01-23  6:14       ` David Brownell
2009-01-23  6:14         ` David Brownell

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=49786CA6.8010303@cam.ac.uk \
    --to=jic23-kwpb1pkirijaa/9udqfwiw@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
    --cc=eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.