LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 08/10] Driver core: device_add_attrs() cleanup
Date: Fri, 16 Feb 2007 15:37:34 -0800	[thread overview]
Message-ID: <11716690802025-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <1171669076436-git-send-email-gregkh@suse.de>

From: Andrew Morton <akpm@linux-foundation.org>

Clean up the coding in device_add_attrs() a bit.

Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/bus.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 472810f..253868e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -324,27 +324,25 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
 	return error;
 }
 
-static int device_add_attrs(struct bus_type * bus, struct device * dev)
+static int device_add_attrs(struct bus_type *bus, struct device *dev)
 {
 	int error = 0;
 	int i;
 
-	if (bus->dev_attrs) {
-		for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
-			error = device_create_file(dev,&bus->dev_attrs[i]);
-			if (error)
-				goto Err;
+	if (!bus->dev_attrs)
+		return 0;
+
+	for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
+		error = device_create_file(dev,&bus->dev_attrs[i]);
+		if (error) {
+			while (--i >= 0)
+				device_remove_file(dev, &bus->dev_attrs[i]);
+			break;
 		}
 	}
- Done:
 	return error;
- Err:
-	while (--i >= 0)
-		device_remove_file(dev,&bus->dev_attrs[i]);
-	goto Done;
 }
 
-
 static void device_remove_attrs(struct bus_type * bus, struct device * dev)
 {
 	int i;
-- 
1.5.0


  reply	other threads:[~2007-02-16 23:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 23:35 [GIT PATCH] more Driver core patches for 2.6.20 Greg KH
2007-02-16 23:37 ` [PATCH 01/10] Driver.h copyright update Greg Kroah-Hartman
2007-02-16 23:37   ` [PATCH 02/10] Driver core: let request_module() send a /sys/modules/kmod/-uevent Greg Kroah-Hartman
2007-02-16 23:37     ` [PATCH 03/10] serial: Add PCMCIA IDs for Quatech DSP-100 dual RS232 adapter Greg Kroah-Hartman
2007-02-16 23:37       ` [PATCH 04/10] kobject: kobj->k_name verification fix Greg Kroah-Hartman
2007-02-16 23:37         ` [PATCH 05/10] Driver: remove redundant kobject_unregister checks Greg Kroah-Hartman
2007-02-16 23:37           ` [PATCH 06/10] debugfs: implement symbolic links Greg Kroah-Hartman
2007-02-16 23:37             ` [PATCH 07/10] debugfs: Remove misleading comments Greg Kroah-Hartman
2007-02-16 23:37               ` Greg Kroah-Hartman [this message]
2007-02-16 23:37                 ` [PATCH 09/10] pcmcia: some class_device fallout Greg Kroah-Hartman
2007-02-16 23:37                   ` [PATCH 10/10] sysfs: fix build errors: uevent with CONFIG_SYSFS=n Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11716690802025-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 08/10] Driver core: device_add_attrs() cleanup' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).