diff options
author | Davide Ciminaghi <ciminaghi@gnudd.com> | 2012-11-09 09:19:58 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-11-20 06:21:16 -0500 |
commit | e885ba298098959d03c58d946c6fad8f8ed4a1c7 (patch) | |
tree | 41575ff8bec817be217c803effc7ec0e0fc93d01 /drivers/mfd/sta2x11-mfd.c | |
parent | 3ce26d2f4b08252edd3ee38a0a6e30a76da9a9fa (diff) |
mfd: sta2x11-mfd: Use one lock per device instead of one lock per mfd
The lock is used to implement atomic operations on each platform
device's registers, so it looks reasonable having one lock per
device instead of one common lock for all the devices belonging
to the same sta2x11 instance.
Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/sta2x11-mfd.c')
-rw-r--r-- | drivers/mfd/sta2x11-mfd.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/mfd/sta2x11-mfd.c b/drivers/mfd/sta2x11-mfd.c index 2c8d65e13a67..da65839f1d86 100644 --- a/drivers/mfd/sta2x11-mfd.c +++ b/drivers/mfd/sta2x11-mfd.c | |||
@@ -46,7 +46,7 @@ static inline int __reg_within_range(unsigned int r, | |||
46 | struct sta2x11_mfd { | 46 | struct sta2x11_mfd { |
47 | struct sta2x11_instance *instance; | 47 | struct sta2x11_instance *instance; |
48 | struct regmap *regmap[sta2x11_n_mfd_plat_devs]; | 48 | struct regmap *regmap[sta2x11_n_mfd_plat_devs]; |
49 | spinlock_t lock; | 49 | spinlock_t lock[sta2x11_n_mfd_plat_devs]; |
50 | struct list_head list; | 50 | struct list_head list; |
51 | void __iomem *regs[sta2x11_n_mfd_plat_devs]; | 51 | void __iomem *regs[sta2x11_n_mfd_plat_devs]; |
52 | }; | 52 | }; |
@@ -78,6 +78,7 @@ static struct sta2x11_mfd *sta2x11_mfd_find(struct pci_dev *pdev) | |||
78 | 78 | ||
79 | static int __devinit sta2x11_mfd_add(struct pci_dev *pdev, gfp_t flags) | 79 | static int __devinit sta2x11_mfd_add(struct pci_dev *pdev, gfp_t flags) |
80 | { | 80 | { |
81 | int i; | ||
81 | struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev); | 82 | struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev); |
82 | struct sta2x11_instance *instance; | 83 | struct sta2x11_instance *instance; |
83 | 84 | ||
@@ -90,7 +91,8 @@ static int __devinit sta2x11_mfd_add(struct pci_dev *pdev, gfp_t flags) | |||
90 | if (!mfd) | 91 | if (!mfd) |
91 | return -ENOMEM; | 92 | return -ENOMEM; |
92 | INIT_LIST_HEAD(&mfd->list); | 93 | INIT_LIST_HEAD(&mfd->list); |
93 | spin_lock_init(&mfd->lock); | 94 | for (i = 0; i < ARRAY_SIZE(mfd->lock); i++) |
95 | spin_lock_init(&mfd->lock[i]); | ||
94 | mfd->instance = instance; | 96 | mfd->instance = instance; |
95 | list_add(&mfd->list, &sta2x11_mfd_list); | 97 | list_add(&mfd->list, &sta2x11_mfd_list); |
96 | return 0; | 98 | return 0; |
@@ -124,13 +126,13 @@ u32 __sta2x11_mfd_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val, | |||
124 | dev_warn(&pdev->dev, ": system ctl not initialized\n"); | 126 | dev_warn(&pdev->dev, ": system ctl not initialized\n"); |
125 | return 0; | 127 | return 0; |
126 | } | 128 | } |
127 | spin_lock_irqsave(&mfd->lock, flags); | 129 | spin_lock_irqsave(&mfd->lock[index], flags); |
128 | r = readl(regs + reg); | 130 | r = readl(regs + reg); |
129 | r &= ~mask; | 131 | r &= ~mask; |
130 | r |= val; | 132 | r |= val; |
131 | if (mask) | 133 | if (mask) |
132 | writel(r, regs + reg); | 134 | writel(r, regs + reg); |
133 | spin_unlock_irqrestore(&mfd->lock, flags); | 135 | spin_unlock_irqrestore(&mfd->lock[index], flags); |
134 | return r; | 136 | return r; |
135 | } | 137 | } |
136 | EXPORT_SYMBOL(__sta2x11_mfd_mask); | 138 | EXPORT_SYMBOL(__sta2x11_mfd_mask); |