aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-03-30 06:53:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-30 11:08:40 -0400
commit727b4ddb48dcd8c9ca81b58ca58191233bdf75aa (patch)
tree96088a843e63d336a39ce903aa49bec74c56d17a
parentba8618e067907407ec84001adc11bc1f184d19a6 (diff)
usb: chipidea: don't redefine __ffs()
chipidea's ffs_nr() is pretty much what __ffs() does. Use that one instead. Signed-off-by: Felipe Balbi <balbi@ti.com> [rebased on top of debug infrastructure rework] Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/chipidea/ci.h15
-rw-r--r--drivers/usb/chipidea/core.c8
-rw-r--r--drivers/usb/chipidea/udc.c12
3 files changed, 11 insertions, 24 deletions
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index c7d4622782ce..68577d1f1c0d 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -235,19 +235,6 @@ enum ci13xxx_regs {
235}; 235};
236 236
237/** 237/**
238 * ffs_nr: find first (least significant) bit set
239 * @x: the word to search
240 *
241 * This function returns bit number (instead of position)
242 */
243static inline int ffs_nr(u32 x)
244{
245 int n = ffs(x);
246
247 return n ? n-1 : 32;
248}
249
250/**
251 * hw_read: reads from a hw register 238 * hw_read: reads from a hw register
252 * @reg: register index 239 * @reg: register index
253 * @mask: bitfield mask 240 * @mask: bitfield mask
@@ -305,7 +292,7 @@ static inline u32 hw_test_and_write(struct ci13xxx *ci, enum ci13xxx_regs reg,
305 u32 val = hw_read(ci, reg, ~0); 292 u32 val = hw_read(ci, reg, ~0);
306 293
307 hw_write(ci, reg, mask, data); 294 hw_write(ci, reg, mask, data);
308 return (val & mask) >> ffs_nr(mask); 295 return (val & mask) >> __ffs(mask);
309} 296}
310 297
311int hw_device_reset(struct ci13xxx *ci, u32 mode); 298int hw_device_reset(struct ci13xxx *ci, u32 mode);
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index a7ce1b8c8fd7..114d4c43abc6 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -155,7 +155,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode)
155 if (mode > TEST_MODE_MAX) 155 if (mode > TEST_MODE_MAX)
156 return -EINVAL; 156 return -EINVAL;
157 157
158 hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << ffs_nr(PORTSC_PTC)); 158 hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << __ffs(PORTSC_PTC));
159 return 0; 159 return 0;
160} 160}
161 161
@@ -166,7 +166,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode)
166 */ 166 */
167u8 hw_port_test_get(struct ci13xxx *ci) 167u8 hw_port_test_get(struct ci13xxx *ci)
168{ 168{
169 return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> ffs_nr(PORTSC_PTC); 169 return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> __ffs(PORTSC_PTC);
170} 170}
171 171
172static int hw_device_init(struct ci13xxx *ci, void __iomem *base) 172static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
@@ -182,7 +182,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
182 182
183 hw_alloc_regmap(ci, false); 183 hw_alloc_regmap(ci, false);
184 reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >> 184 reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
185 ffs_nr(HCCPARAMS_LEN); 185 __ffs(HCCPARAMS_LEN);
186 ci->hw_bank.lpm = reg; 186 ci->hw_bank.lpm = reg;
187 hw_alloc_regmap(ci, !!reg); 187 hw_alloc_regmap(ci, !!reg);
188 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs; 188 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs;
@@ -190,7 +190,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
190 ci->hw_bank.size /= sizeof(u32); 190 ci->hw_bank.size /= sizeof(u32);
191 191
192 reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >> 192 reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >>
193 ffs_nr(DCCPARAMS_DEN); 193 __ffs(DCCPARAMS_DEN);
194 ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */ 194 ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
195 195
196 if (ci->hw_ep_max > ENDPT_MAX) 196 if (ci->hw_ep_max > ENDPT_MAX)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 28c31baebfde..32e6c99b8b98 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -140,7 +140,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int dir, int type)
140 140
141 if (dir) { 141 if (dir) {
142 mask = ENDPTCTRL_TXT; /* type */ 142 mask = ENDPTCTRL_TXT; /* type */
143 data = type << ffs_nr(mask); 143 data = type << __ffs(mask);
144 144
145 mask |= ENDPTCTRL_TXS; /* unstall */ 145 mask |= ENDPTCTRL_TXS; /* unstall */
146 mask |= ENDPTCTRL_TXR; /* reset data toggle */ 146 mask |= ENDPTCTRL_TXR; /* reset data toggle */
@@ -149,7 +149,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int dir, int type)
149 data |= ENDPTCTRL_TXE; 149 data |= ENDPTCTRL_TXE;
150 } else { 150 } else {
151 mask = ENDPTCTRL_RXT; /* type */ 151 mask = ENDPTCTRL_RXT; /* type */
152 data = type << ffs_nr(mask); 152 data = type << __ffs(mask);
153 153
154 mask |= ENDPTCTRL_RXS; /* unstall */ 154 mask |= ENDPTCTRL_RXS; /* unstall */
155 mask |= ENDPTCTRL_RXR; /* reset data toggle */ 155 mask |= ENDPTCTRL_RXR; /* reset data toggle */
@@ -331,7 +331,7 @@ static int hw_test_and_set_setup_guard(struct ci13xxx *ci)
331static void hw_usb_set_address(struct ci13xxx *ci, u8 value) 331static void hw_usb_set_address(struct ci13xxx *ci, u8 value)
332{ 332{
333 hw_write(ci, OP_DEVICEADDR, DEVICEADDR_USBADR, 333 hw_write(ci, OP_DEVICEADDR, DEVICEADDR_USBADR,
334 value << ffs_nr(DEVICEADDR_USBADR)); 334 value << __ffs(DEVICEADDR_USBADR));
335} 335}
336 336
337/** 337/**
@@ -418,7 +418,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
418 * TODO - handle requests which spawns into several TDs 418 * TODO - handle requests which spawns into several TDs
419 */ 419 */
420 memset(mReq->ptr, 0, sizeof(*mReq->ptr)); 420 memset(mReq->ptr, 0, sizeof(*mReq->ptr));
421 mReq->ptr->token = length << ffs_nr(TD_TOTAL_BYTES); 421 mReq->ptr->token = length << __ffs(TD_TOTAL_BYTES);
422 mReq->ptr->token &= TD_TOTAL_BYTES; 422 mReq->ptr->token &= TD_TOTAL_BYTES;
423 mReq->ptr->token |= TD_STATUS_ACTIVE; 423 mReq->ptr->token |= TD_STATUS_ACTIVE;
424 if (mReq->zptr) { 424 if (mReq->zptr) {
@@ -504,7 +504,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
504 mReq->req.status = -1; 504 mReq->req.status = -1;
505 505
506 mReq->req.actual = mReq->ptr->token & TD_TOTAL_BYTES; 506 mReq->req.actual = mReq->ptr->token & TD_TOTAL_BYTES;
507 mReq->req.actual >>= ffs_nr(TD_TOTAL_BYTES); 507 mReq->req.actual >>= __ffs(TD_TOTAL_BYTES);
508 mReq->req.actual = mReq->req.length - mReq->req.actual; 508 mReq->req.actual = mReq->req.length - mReq->req.actual;
509 mReq->req.actual = mReq->req.status ? 0 : mReq->req.actual; 509 mReq->req.actual = mReq->req.status ? 0 : mReq->req.actual;
510 510
@@ -1011,7 +1011,7 @@ static int ep_enable(struct usb_ep *ep,
1011 mEp->qh.ptr->cap &= ~QH_ZLT; 1011 mEp->qh.ptr->cap &= ~QH_ZLT;
1012 1012
1013 mEp->qh.ptr->cap |= 1013 mEp->qh.ptr->cap |=
1014 (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT; 1014 (mEp->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT;
1015 mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */ 1015 mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */
1016 1016
1017 /* 1017 /*