Re: [PATCH 1/2] pwm: Add __weak attributed functions for pwm operations

2011-05-16 Thread Mohan Pallaka

 On 5/15/2011 4:28 PM, Russell King - ARM Linux wrote:

On Sun, May 15, 2011 at 01:00:31AM -0700, Dmitry Torokhov wrote:

On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:

For chip drivers that support both pwm and non-pwm modes
would encounter compilation errors if the platform doesn't
have support for pwm though the chip is programmed to work
in non-pwm mode. Add __weak attributed pwm functions to avoid
compilation issues in these scenarios.


Russell,

You seem to have authored pwm.h, do you have any objections to this
change?

This seems to be a recipe for an oops.  Have a look at how
linux/regulator/consumer.h deals with this kind of problem, and notice
that we have CONFIG_HAVE_PWM to indicate whether this interface is
supported or not.

Thanks for the suggestion. I'll upload a new patch.

--Mohan.
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


How to use one I2C device from two modules?

2011-05-16 Thread Lars Michael
--- On Fri, 13/5/11, Jean Delvare  wrote:
> On Fri, 13 May 2011 00:47:37 -0700 (PDT), Lars Michael
> wrote:
> > --- On Sat, 7/5/11, Jean Delvare 
> wrote:
> > > On Fri, 6 May 2011 04:30:33 -0700 (PDT), Lars
> Michael
> > > wrote:
> > > > But how do I access the same I2C device from
> several
> > > modules? Ideally I want to specify the adapter
> and slave
> > > address. If a client is found, I get the
> i2c_client
> > > otherwise I have to create it by i2c_new_device
> (or probe
> > > it). Is it possible?
> > > > 
> > > 
> > > In general I would have pointed you to
> drivers/mfd and told
> > > you to
> > > write a mfd core driver for your chip. However in
> your case
> > > I don't
> > > think you have a multifunction device. You have a
> single
> > > function
> > > device (GPIO) with multiple users. So I suggest
> that you
> > > simply write a
> > > proper gpio driver for your chip, and get the
> device
> > > registered as an
> > > I2C GPIO device. Then, in your function drivers
> (power
> > > supply control
> > > and button control) get a reference to the gpio
> device in
> > > question, and
> > > use it.
> > 
> > Thanks for the advice. I wrote a simple driver for my
> chip and
> > instantiated it in the platform code. In order to
> access the
> 
> Please submit your driver for integration in the upstream
> kernel.
> Others are certainly using the same device!

Please note that my driver has no device specific functions. It
only allows the device to be registered so that my function
modules can use the smbus commands and the i2c client handle to
use the device. The GPIO device/lib is not supported. So, I don't
think it's worth submitting it at this point...
 
> > device from the function modules, I exported an
> i2c_client get
> > function, in order to get a reference to the client:
> > 
> > struct i2c_client *pca950x_get_i2c_client(void)
> > .
> > EXPORT_SYMBOL(pca950x_get_i2c_client);
> > 
> > Not sure this is the perfect way to do it, but it
> works.
> 
> No, this doesn't seem right. A given system may have more
> than one
> PCA950x chip. And symbol dependencies are a hell to handle
> as soon as
> things get more complex. Such an export will never be
> accepted upstream.

You are right, and this quick solution was not meant to be submitted.
 
> I can think of 2 ways to handle your problem.
> 
> If neither works for you for whatever reason, maybe we can
> add a helper
> function to i2c-core to retrieve an i2c_client by bus
> number and
> address. Maybe others would find it useful as well.

I was looking for such a function, it could be very handy. And btw
a get adapter by id already exists. 

Thanks and regards,
- Lars 
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html