From: Li Yang <leoli@freescale.com>
To: akpm@linux-foundation.org, galak@kernel.crashing.org,
davem@davemloft.net, mporter@kernel.crashing.org
Cc: linuxppc-dev@ozlabs.org, Li Yang <leoli@freescale.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH 5/6] rio: warn_unused_result warnings fix
Date: Tue, 12 May 2009 16:36:02 +0800 [thread overview]
Message-ID: <1242117363-14949-5-git-send-email-leoli@freescale.com> (raw)
In-Reply-To: <1242117363-14949-4-git-send-email-leoli@freescale.com>
Adding failure path for the following two cases.
warning: ignoring return value of 'device_add', declared with attribute warn_unused_result
warning: ignoring return value of 'sysfs_create_bin_file', declared with attribute warn_unused_result
Signed-off-by: Li Yang <leoli@freescale.com>
---
drivers/rapidio/rio-scan.c | 44 ++++++++++++++++++++++++++----------------
drivers/rapidio/rio-sysfs.c | 6 +++-
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 74d0bfa..0838fb2 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -263,15 +263,21 @@ static void rio_route_set_ops(struct rio_dev *rdev)
* device to the RIO device list. Creates the generic sysfs nodes
* for an RIO device.
*/
-static void __devinit rio_add_device(struct rio_dev *rdev)
+static int __devinit rio_add_device(struct rio_dev *rdev)
{
- device_add(&rdev->dev);
+ int err;
+
+ err = device_add(&rdev->dev);
+ if (err)
+ return err;
spin_lock(&rio_global_list_lock);
list_add_tail(&rdev->global_list, &rio_devices);
spin_unlock(&rio_global_list_lock);
rio_create_sysfs_dev_files(rdev);
+
+ return 0;
}
/**
@@ -294,13 +300,14 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
struct rio_mport *port, u16 destid,
u8 hopcount, int do_enum)
{
+ int ret = 0;
struct rio_dev *rdev;
- struct rio_switch *rswitch;
+ struct rio_switch *rswitch = NULL;
int result, rdid;
rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL);
if (!rdev)
- goto out;
+ return NULL;
rdev->net = net;
rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR,
@@ -343,23 +350,16 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
rio_mport_read_config_32(port, destid, hopcount,
RIO_SWP_INFO_CAR, &rdev->swpinfo);
rswitch = kmalloc(sizeof(struct rio_switch), GFP_KERNEL);
- if (!rswitch) {
- kfree(rdev);
- rdev = NULL;
- goto out;
- }
+ if (!rswitch)
+ goto cleanup;
rswitch->switchid = next_switchid;
rswitch->hopcount = hopcount;
rswitch->destid = destid;
rswitch->route_table = kzalloc(sizeof(u8)*
RIO_MAX_ROUTE_ENTRIES(port->sys_size),
GFP_KERNEL);
- if (!rswitch->route_table) {
- kfree(rdev);
- rdev = NULL;
- kfree(rswitch);
- goto out;
- }
+ if (!rswitch->route_table)
+ goto cleanup;
/* Initialize switch route table */
for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size);
rdid++)
@@ -390,10 +390,20 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
0, 0xffff);
- rio_add_device(rdev);
+ ret = rio_add_device(rdev);
+ if (ret)
+ goto cleanup;
- out:
return rdev;
+
+cleanup:
+ if (rswitch) {
+ if (rswitch->route_table)
+ kfree(rswitch->route_table);
+ kfree(rswitch);
+ }
+ kfree(rdev);
+ return NULL;
}
/**
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 97a147f..ba742e8 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -214,9 +214,11 @@ static struct bin_attribute rio_config_attr = {
*/
int rio_create_sysfs_dev_files(struct rio_dev *rdev)
{
- sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr);
+ int err = 0;
- return 0;
+ err = sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr);
+
+ return err;
}
/**
--
1.5.4
next prev parent reply other threads:[~2009-05-12 8:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 8:35 [PATCH 1/6] rapidio: add common mapping APIs for RapidIO memory access Li Yang
2009-05-12 8:35 ` [PATCH 2/6] powerpc/fsl_rio: use LAW address from device tree Li Yang
2009-05-12 8:36 ` [PATCH 3/6] powerpc: add memory map support to Freescale RapidIO block Li Yang
2009-05-12 8:36 ` [PATCH 4/6] rionet: add memory access to simulated Ethernet over rapidio Li Yang
2009-05-12 8:36 ` Li Yang [this message]
2009-05-12 8:36 ` [PATCH 6/6] rio: fix section mismatch Li Yang
2009-05-13 22:08 ` Kumar Gala
2009-05-12 22:11 ` [PATCH 5/6] rio: warn_unused_result warnings fix Andrew Morton
2009-06-11 4:34 ` Kumar Gala
2009-05-12 22:10 ` [PATCH 4/6] rionet: add memory access to simulated Ethernet over rapidio Andrew Morton
2009-05-12 22:05 ` [PATCH 3/6] powerpc: add memory map support to Freescale RapidIO block Andrew Morton
2009-05-21 10:43 ` Li Yang
2009-05-13 22:08 ` [PATCH 2/6] powerpc/fsl_rio: use LAW address from device tree Kumar Gala
2009-06-11 4:13 ` [PATCH 1/6] rapidio: add common mapping APIs for RapidIO memory access Kumar Gala
2009-06-11 9:47 ` Li Yang-R58472
2009-06-11 13:32 ` Kumar Gala
2009-06-12 13:27 ` Li Yang
2009-06-12 13:58 ` Kumar Gala
2009-06-15 10:38 ` Li Yang
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=1242117363-14949-5-git-send-email-leoli@freescale.com \
--to=leoli@freescale.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=galak@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mporter@kernel.crashing.org \
--cc=netdev@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).