Skip to contentSkip to conversation

mutex_lock in designware-i2c

DISCUSSION Rongrong Zou 2 participants 2 messages Jan 11, 2016 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Hi, baruch

I found a mutex lock in dw_i2c_dev for each adapter,

struct dw_i2c_dev {
        struct device           *dev;
        void __iomem            *base;
        struct completion       cmd_complete;
        struct mutex            lock;
        struct clk              *clk;

but there is another lock: adapter->bus_lock, this lock is also for each adapter, why we need both of them ?

Regards,

Rongrong

#1 lore raw

Hi Rongrong Zou,

Quoted 10 lines · Rongrong Zou

I found a mutex lock in dw_i2c_dev for each adapter,

struct dw_i2c_dev {
        struct device           *dev;
        void __iomem            *base;
        struct completion       cmd_complete;
        struct mutex            lock;
        struct clk              *clk;

but there is another lock: adapter->bus_lock, this lock is also for each adapter, why we need both of them ?

As far as I can see from the code the master_xfer callback is never called concurrently for the same adaptor. So indeed the internal lock looks redundant. I can't remember why I put it there.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -