Bluetooth: replace list_for_each with list_for_each_entry whenever possible
When all items in the list have the same type there is no much of a point to use list_for_each except if you want to use the list pointer itself. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:

committed by
Gustavo F. Padovan

parent
457f48507d
commit
8035ded466
@@ -134,13 +134,10 @@ static inline void rfcomm_dev_put(struct rfcomm_dev *dev)
|
||||
static struct rfcomm_dev *__rfcomm_dev_get(int id)
|
||||
{
|
||||
struct rfcomm_dev *dev;
|
||||
struct list_head *p;
|
||||
|
||||
list_for_each(p, &rfcomm_dev_list) {
|
||||
dev = list_entry(p, struct rfcomm_dev, list);
|
||||
list_for_each_entry(dev, &rfcomm_dev_list, list)
|
||||
if (dev->id == id)
|
||||
return dev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -198,7 +195,7 @@ static DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL);
|
||||
|
||||
static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
||||
{
|
||||
struct rfcomm_dev *dev;
|
||||
struct rfcomm_dev *dev, *entry;
|
||||
struct list_head *head = &rfcomm_dev_list, *p;
|
||||
int err = 0;
|
||||
|
||||
@@ -213,8 +210,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
||||
if (req->dev_id < 0) {
|
||||
dev->id = 0;
|
||||
|
||||
list_for_each(p, &rfcomm_dev_list) {
|
||||
if (list_entry(p, struct rfcomm_dev, list)->id != dev->id)
|
||||
list_for_each_entry(entry, &rfcomm_dev_list, list) {
|
||||
if (entry->id != dev->id)
|
||||
break;
|
||||
|
||||
dev->id++;
|
||||
@@ -223,9 +220,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
||||
} else {
|
||||
dev->id = req->dev_id;
|
||||
|
||||
list_for_each(p, &rfcomm_dev_list) {
|
||||
struct rfcomm_dev *entry = list_entry(p, struct rfcomm_dev, list);
|
||||
|
||||
list_for_each_entry(entry, &rfcomm_dev_list, list) {
|
||||
if (entry->id == dev->id) {
|
||||
err = -EADDRINUSE;
|
||||
goto out;
|
||||
@@ -456,9 +451,9 @@ static int rfcomm_release_dev(void __user *arg)
|
||||
|
||||
static int rfcomm_get_dev_list(void __user *arg)
|
||||
{
|
||||
struct rfcomm_dev *dev;
|
||||
struct rfcomm_dev_list_req *dl;
|
||||
struct rfcomm_dev_info *di;
|
||||
struct list_head *p;
|
||||
int n = 0, size, err;
|
||||
u16 dev_num;
|
||||
|
||||
@@ -480,8 +475,7 @@ static int rfcomm_get_dev_list(void __user *arg)
|
||||
|
||||
read_lock_bh(&rfcomm_dev_lock);
|
||||
|
||||
list_for_each(p, &rfcomm_dev_list) {
|
||||
struct rfcomm_dev *dev = list_entry(p, struct rfcomm_dev, list);
|
||||
list_for_each_entry(dev, &rfcomm_dev_list, list) {
|
||||
if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
|
||||
continue;
|
||||
(di + n)->id = dev->id;
|
||||
|
Reference in New Issue
Block a user