lkml.org 
[lkml]   [2014]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] i2c-designware: Intel BayTrail PMIC I2C bus support
On Fri, 12 Sep 2014 10:36:07 -0700
"David E. Box" <david.e.box@linux.intel.com> wrote:

> +#if IS_ENABLED(CONFIG_I2C_SHARED_CONTROLLER)
> +extern int i2c_acquire_ownership(struct device *dev);
> +extern int i2c_release_ownership(struct device *dev);
> +#endif

You can just have the prototypes anyway - no need for more ifdefs than
required


> +#if IS_ENABLED(CONFIG_I2C_SHARED_CONTROLLER)
> +int i2c_shared_controller_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
> + int num)
> +{
> + struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
> + int err;
> +
> + if (dev->shared_host) {
> + err = dev->acquire_ownership(dev->dev);
> + if (!err) {
> + err = i2c_dw_xfer(adap, msgs, num);
> + dev->release_ownership(dev->dev);
> + } else
> + dev_WARN(dev->dev, "couldnt acquire ownership\n");
> +
> + return err;
> + } else
> + return i2c_dw_xfer(adap, msgs, num);
> +}
> +
> +static struct i2c_algorithm i2c_sc_algo = {
> + .master_xfer = i2c_shared_controller_xfer,
> + .functionality = i2c_dw_func,
> +};
> +#endif

I think this might be a lot cleaner if you put these pieces as functions
into i2c-designware-sem.c or a similar file and made the methods NULL
functions in the header in the case it's not supported ? Most of the
ifdeffery would then vanish into the extra file and keep the core code
cleaner ?


Alan


\
 
 \ /
  Last update: 2014-09-17 13:41    [W:0.211 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site