[media] drivers/media/dvb/siano/smscoreapi.c: use list_for_each_entry
Use list_for_each_entry and perform some other induced simplifications. The semantic match that finds the opportunity for this reorganization is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ struct list_head *pos; struct list_head *head; statement S; @@ *for (pos = (head)->next; pos != (head); pos = pos->next) S // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
26ddcbcca3
commit
0208c15e5c
1 changed files with 16 additions and 23 deletions
|
@ -276,16 +276,13 @@ static void smscore_notify_clients(struct smscore_device_t *coredev)
|
||||||
static int smscore_notify_callbacks(struct smscore_device_t *coredev,
|
static int smscore_notify_callbacks(struct smscore_device_t *coredev,
|
||||||
struct device *device, int arrival)
|
struct device *device, int arrival)
|
||||||
{
|
{
|
||||||
struct list_head *next, *first;
|
struct smscore_device_notifyee_t *elem;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/* note: must be called under g_deviceslock */
|
/* note: must be called under g_deviceslock */
|
||||||
|
|
||||||
first = &g_smscore_notifyees;
|
list_for_each_entry(elem, &g_smscore_notifyees, entry) {
|
||||||
|
rc = elem->hotplug(coredev, device, arrival);
|
||||||
for (next = first->next; next != first; next = next->next) {
|
|
||||||
rc = ((struct smscore_device_notifyee_t *) next)->
|
|
||||||
hotplug(coredev, device, arrival);
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -940,29 +937,25 @@ static struct
|
||||||
smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
|
smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
|
||||||
int data_type, int id)
|
int data_type, int id)
|
||||||
{
|
{
|
||||||
struct smscore_client_t *client = NULL;
|
struct list_head *first;
|
||||||
struct list_head *next, *first;
|
struct smscore_client_t *client;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct list_head *firstid, *nextid;
|
struct list_head *firstid;
|
||||||
|
struct smscore_idlist_t *client_id;
|
||||||
|
|
||||||
spin_lock_irqsave(&coredev->clientslock, flags);
|
spin_lock_irqsave(&coredev->clientslock, flags);
|
||||||
first = &coredev->clients;
|
first = &coredev->clients;
|
||||||
for (next = first->next;
|
list_for_each_entry(client, first, entry) {
|
||||||
(next != first) && !client;
|
firstid = &client->idlist;
|
||||||
next = next->next) {
|
list_for_each_entry(client_id, firstid, entry) {
|
||||||
firstid = &((struct smscore_client_t *)next)->idlist;
|
if ((client_id->id == id) &&
|
||||||
for (nextid = firstid->next;
|
(client_id->data_type == data_type ||
|
||||||
nextid != firstid;
|
(client_id->data_type == 0)))
|
||||||
nextid = nextid->next) {
|
goto found;
|
||||||
if ((((struct smscore_idlist_t *)nextid)->id == id) &&
|
|
||||||
(((struct smscore_idlist_t *)nextid)->data_type == data_type ||
|
|
||||||
(((struct smscore_idlist_t *)nextid)->data_type == 0))) {
|
|
||||||
client = (struct smscore_client_t *) next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
client = NULL;
|
||||||
|
found:
|
||||||
spin_unlock_irqrestore(&coredev->clientslock, flags);
|
spin_unlock_irqrestore(&coredev->clientslock, flags);
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue