aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-07-15 04:25:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-30 20:48:05 -0400
commit0208c15e5c639ff08b9767fee907a99bcc94b2f5 (patch)
tree93b4cff07c990aa6cfc50698c3adffd0eedd234a
parent26ddcbcca3057125a0e5f3901b06439a20869640 (diff)
[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>
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index 7331e8450d1a..9cc55546cc30 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -276,16 +276,13 @@ static void smscore_notify_clients(struct smscore_device_t *coredev)
276static int smscore_notify_callbacks(struct smscore_device_t *coredev, 276static int smscore_notify_callbacks(struct smscore_device_t *coredev,
277 struct device *device, int arrival) 277 struct device *device, int arrival)
278{ 278{
279 struct list_head *next, *first; 279 struct smscore_device_notifyee_t *elem;
280 int rc = 0; 280 int rc = 0;
281 281
282 /* note: must be called under g_deviceslock */ 282 /* note: must be called under g_deviceslock */
283 283
284 first = &g_smscore_notifyees; 284 list_for_each_entry(elem, &g_smscore_notifyees, entry) {
285 285 rc = elem->hotplug(coredev, device, arrival);
286 for (next = first->next; next != first; next = next->next) {
287 rc = ((struct smscore_device_notifyee_t *) next)->
288 hotplug(coredev, device, arrival);
289 if (rc < 0) 286 if (rc < 0)
290 break; 287 break;
291 } 288 }
@@ -940,29 +937,25 @@ static struct
940smscore_client_t *smscore_find_client(struct smscore_device_t *coredev, 937smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
941 int data_type, int id) 938 int data_type, int id)
942{ 939{
943 struct smscore_client_t *client = NULL; 940 struct list_head *first;
944 struct list_head *next, *first; 941 struct smscore_client_t *client;
945 unsigned long flags; 942 unsigned long flags;
946 struct list_head *firstid, *nextid; 943 struct list_head *firstid;
947 944 struct smscore_idlist_t *client_id;
948 945
949 spin_lock_irqsave(&coredev->clientslock, flags); 946 spin_lock_irqsave(&coredev->clientslock, flags);
950 first = &coredev->clients; 947 first = &coredev->clients;
951 for (next = first->next; 948 list_for_each_entry(client, first, entry) {
952 (next != first) && !client; 949 firstid = &client->idlist;
953 next = next->next) { 950 list_for_each_entry(client_id, firstid, entry) {
954 firstid = &((struct smscore_client_t *)next)->idlist; 951 if ((client_id->id == id) &&
955 for (nextid = firstid->next; 952 (client_id->data_type == data_type ||
956 nextid != firstid; 953 (client_id->data_type == 0)))
957 nextid = nextid->next) { 954 goto found;
958 if ((((struct smscore_idlist_t *)nextid)->id == id) &&
959 (((struct smscore_idlist_t *)nextid)->data_type == data_type ||
960 (((struct smscore_idlist_t *)nextid)->data_type == 0))) {
961 client = (struct smscore_client_t *) next;
962 break;
963 }
964 } 955 }
965 } 956 }
957 client = NULL;
958found:
966 spin_unlock_irqrestore(&coredev->clientslock, flags); 959 spin_unlock_irqrestore(&coredev->clientslock, flags);
967 return client; 960 return client;
968} 961}