Prev: [PATCH] Adding four read-only files to /proc/sys/vm
Next: bluetooth:hci_bcsp Fix operation on 'bcsp->msgq_txseq' may be undefined
From: Justin P. Mattock on 29 Jun 2010 18:00 On 06/29/2010 08:47 AM, David Howells wrote: > Justin P. Mattock<justinmattock(a)gmail.com> wrote: > >> + if (fn) { >> + printk(KERN_WARNING "dev%d: Failed to create >> firmware_node: %d\n", status, fn); >> + }else if (pn) { >> + printk(KERN_WARNING "dev%d: Failed to create >> physical_node: %d\n", status, pn); >> + return 0; >> + } > > The if-statement should be correctly indented (it's inside another > if-body, so needs to be one more tab over) and there needs to be a space > before the else. > > You should probably split your printks up so they don't exceed 80 chars too, > for example: > > printk(KERN_WARNING > "dev%d: Failed to create physical_node: %d\n", > status, pn); > > Also 'status' is probably the wrong thing to print as the number in "dev%d". > If it worked, that should be unconditionally AE_OK, I think. Can you not use > dev_warn() or similar instead or printk? > > David > o.k. heres another go at this.. this goes through, using dev_warn but am uncertain about using these three for the right info dev, %p, dev_acpi but give it a look whenever you have the time, and let me know then I'll go from there.. From 34485b5709dc9ad18c57be8c672236580300e05c Mon Sep 17 00:00:00 2001 From: Justin P. Mattock <justinmattock(a)gmail.com> Date: Tue, 29 Jun 2010 14:47:42 -0700 Subject: [PATCH ]ACPI:glue.c Signed-off-by: Justin P. Mattock <justinmattock(a)gmail.com> --- drivers/acpi/glue.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 4af6301..69ca24d 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -145,6 +145,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) { struct acpi_device *acpi_dev; acpi_status status; + int fn, pn; if (dev->archdata.acpi_handle) { dev_warn(dev, "Drivers changed 'acpi_handle'\n"); @@ -160,12 +161,20 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) status = acpi_bus_get_device(handle, &acpi_dev); if (!ACPI_FAILURE(status)) { - int ret; - ret = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, + fn = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, "firmware_node"); - ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, + pn = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, "physical_node"); + if (fn) { + dev_warn(dev, "dev:%p Failed to create firmware_node: %d\n", + acpi_dev, fn); + + } else if (pn) { + dev_warn(dev, "dev:%p Failed to create physical_node: %d\n", + acpi_dev, pn); + return AE_ERROR; + } if (acpi_dev->wakeup.flags.valid) { device_set_wakeup_capable(dev, true); device_set_wakeup_enable(dev, -- 1.7.1.rc1.21.gf3bd6 Justin P. Mattock -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Justin P. Mattock on 30 Jun 2010 09:30 On 06/30/2010 02:13 AM, David Howells wrote: > Justin P. Mattock<justinmattock(a)gmail.com> wrote: > >> if (!ACPI_FAILURE(status)) { >> - int ret; >> >> - ret = sysfs_create_link(&dev->kobj,&acpi_dev->dev.kobj, >> + fn = sysfs_create_link(&dev->kobj,&acpi_dev->dev.kobj, >> "firmware_node"); >> - ret = sysfs_create_link(&acpi_dev->dev.kobj,&dev->kobj, >> + pn = sysfs_create_link(&acpi_dev->dev.kobj,&dev->kobj, >> "physical_node"); >> + if (fn) { > > That new if-statement still needs indenting one more tab stop. It's indented > the same as the previous if-statement, but is actually in the body of that > previous if-statement. > > The body of the second if-statement should be indented one tab beyond the if, > and else/else-if statements and the final closing brace should be indented > level with the if: > > if (...) { > body; > } else if (...) { > body; > } else { > body; > } > > so that they line up vertically. Thanks for the info on this, I really appreciate it. I'll look at this today, and resend. > >> + dev_warn(dev, "dev:%p Failed to create firmware_node: %d\n", >> + acpi_dev, fn); > > The "dev:%p " seems like it ought to be superfluous if you're using > dev_warn(), and certainly, returning the pointer isn't really useful, I > suspect. > I kept receiving an new warning for using acpi_dev the %p was the only option I saw in the Documentation that worked > However, at this point you have two device struct pointers: dev and > &acip_dev->dev, so printing them both is may be good. Perhaps something like: > > + dev_warn(&acpi_dev->dev, > + "Failed to create firmware_node link to %s %s: %d\n", > + dev_driver_string(dev), dev_name(dev), fn); > > David > o.k. I'll look at this today, and see if I can find/locate the device name and string for these. Justin P. Mattock -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Justin P. Mattock on 30 Jun 2010 15:50 o.k. hopefully this is getting close to being right.. I ended up spending the later half of the morning looking for dev_driver_string(dev) until I read device.h and realized you actually use that it's self to gather the debug info etc..(I admit it, I'm a newbie!) anyways here is the updated patch, let me know if something need a changing.. From 16df81551d1899e650ae28ea8d41931f7c391c7a Mon Sep 17 00:00:00 2001 From: Justin P. Mattock <justinmattock(a)gmail.com> Date: Wed, 30 Jun 2010 12:34:32 -0700 Subject: [PATCH]acpi:glue.c Fix Fix warning: variable 'ret' set but not used Fix a warning message generated by gcc: Im getting a warning message when building with gcc 4.6.0 CC drivers/acpi/glue.o drivers/acpi/glue.c: In function 'acpi_bind_one': drivers/acpi/glue.c:163:7: warning: variable 'ret' set but not used Signed-off-by: Justin P. Mattock <justinmattock(a)gmail.com> Signed-off-by: David Howells <dhowells(a)redhat.com> --- drivers/acpi/glue.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 4af6301..11ad510 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -145,6 +145,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) { struct acpi_device *acpi_dev; acpi_status status; + int fn, pn; if (dev->archdata.acpi_handle) { dev_warn(dev, "Drivers changed 'acpi_handle'\n"); @@ -160,12 +161,21 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) status = acpi_bus_get_device(handle, &acpi_dev); if (!ACPI_FAILURE(status)) { - int ret; - ret = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, + fn = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, "firmware_node"); - ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, + pn = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, "physical_node"); + if (fn) { + dev_warn(&acpi_dev->dev, + "Failed to create firmware_node link to %s %s: %d\n", + dev_driver_string(dev), dev_name(dev), fn); + } else if (pn) { + dev_warn(&acpi_dev->dev, + "Failed to create physical_node link to %s %s: %d\n", + dev_driver_string(dev), dev_name(dev), pn); + return AE_ERROR; + } if (acpi_dev->wakeup.flags.valid) { device_set_wakeup_capable(dev, true); device_set_wakeup_enable(dev, -- 1.7.1.rc1.21.gf3bd6 cheers, Justin P. Mattock -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Justin P. Mattock on 1 Jul 2010 09:50 On 07/01/2010 02:31 AM, David Howells wrote: > Justin P. Mattock<justinmattock(a)gmail.com> wrote: > >> + if (fn) { >> + dev_warn(&acpi_dev->dev, >> + "Failed to create firmware_node link to %s %s: %d\n", >> + dev_driver_string(dev), dev_name(dev), fn); >> + } else if (pn) { >> + dev_warn(&acpi_dev->dev, >> + "Failed to create physical_node link to %s %s: %d\n", >> + dev_driver_string(dev), dev_name(dev), pn); >> + return AE_ERROR; >> + } > > There's one more question to ask yourself: do you really need two dev_warn() > statements? You could have just one that prints both error values: > > if (fn || pn) > dev_warn(&acpi_dev->dev, > "Failed to create link(s) to %s %s:" > " fn=%d pn=%d\n", > dev_driver_string(dev), dev_name(dev), > fn, pn); ah... I did think about that a few days ago, but had no idea how to really follow through with this.. and from looking at what you did, it's as simple as a || b > > Not sure it's worth going that far. You could reduce it still further: > > if (fn || pn) > dev_warn(&acpi_dev->dev, > "Failed to create link(s) to %s %s:" > " %d\n", > dev_driver_string(dev), dev_name(dev), > fn ?: pn); I don't mind resending with your change to this. > > Is it that important to know which failed to be created, or that both failed > to be created? > > David > maybe a simple test(prog) case can be created to simulate what this is doing, just to make sure. Justin P. Mattock -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Justin P. Mattock on 1 Jul 2010 16:10
> Not sure it's worth going that far. You could reduce it still further: > > if (fn || pn) > dev_warn(&acpi_dev->dev, > "Failed to create link(s) to %s %s:" > " %d\n", > dev_driver_string(dev), dev_name(dev), > fn ?: pn); > > Is it that important to know which failed to be created, or that both failed > to be created? > > David > I like this.. fn ?: pn (will this give us the results from the above question? _both failed to be created_) a bit confused with the whole: "?:" though *condition ? value if true : value if false* (what if both are true what if both are false or does it matter?) here is the patch itself with the change: Fix a warning message generated by gcc: Im getting a warning message when building with gcc 4.6.0 CC drivers/acpi/glue.o drivers/acpi/glue.c: In function 'acpi_bind_one': drivers/acpi/glue.c:163:7: warning: variable 'ret' set but not used Signed-off-by: Justin P. Mattock <justinmattock(a)gmail.com> Signed-off-by: David Howells <dhowells(a)redhat.com> --- drivers/acpi/glue.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 4af6301..23b16e6 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -145,6 +145,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) { struct acpi_device *acpi_dev; acpi_status status; + int fn, pn; if (dev->archdata.acpi_handle) { dev_warn(dev, "Drivers changed 'acpi_handle'\n"); @@ -160,12 +161,19 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) status = acpi_bus_get_device(handle, &acpi_dev); if (!ACPI_FAILURE(status)) { - int ret; - ret = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, + fn = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, "firmware_node"); - ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, + pn = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, "physical_node"); + if (fn || pn) { + dev_warn(&acpi_dev->dev, + "Failed to create link(s) to %s %s:" + " %d\n", + dev_driver_string(dev), dev_name(dev), + fn ?: pn); + return AE_ERROR; + } if (acpi_dev->wakeup.flags.valid) { device_set_wakeup_capable(dev, true); device_set_wakeup_enable(dev, -- 1.7.1.rc1.21.gf3bd6 Justin P. Mattock -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |