From owner-cvs-all@FreeBSD.ORG Tue Mar 30 11:43:25 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE43916A4CE for ; Tue, 30 Mar 2004 11:43:25 -0800 (PST) Received: from root.org (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 6D9EA43D46 for ; Tue, 30 Mar 2004 11:43:25 -0800 (PST) (envelope-from nate@root.org) Received: (qmail 82135 invoked by uid 1000); 30 Mar 2004 19:43:26 -0000 Date: Tue, 30 Mar 2004 11:43:26 -0800 (PST) From: Nate Lawson To: Takanori Watanabe In-Reply-To: <20040327162613.6C32A16A4E1@hub.freebsd.org> Message-ID: <20040330113454.I81785@root.org> References: <20040327162613.6C32A16A4E1@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/dev/acpica acpi.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2004 19:43:25 -0000 On Sat, 27 Mar 2004, Takanori Watanabe wrote: > Modified files: > sys/dev/acpica acpi.c > Log: > Add ACPI PnP string. This affects devinfo(8) output with -v option. > > Revision Changes Path > 1.129 +46 -0 src/sys/dev/acpica/acpi.c Excellent, thanks for this work. > --- src/sys/dev/acpica/acpi.c:1.128 Thu Mar 18 23:05:01 2004 > +++ src/sys/dev/acpica/acpi.c Sat Mar 27 08:26:00 2004 > @@ -140,6 +140,50 @@ > static int acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); > static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); > static int acpi_pm_func(u_long cmd, void *arg, ...); > +static int acpi_child_location_str_method(device_t acdev, device_t child, > + char *buf, size_t buflen); > +static int acpi_child_pnpinfo_str_method(device_t acdev, device_t child, > + char *buf, size_t buflen); > + > +int > +acpi_child_location_str_method(device_t cbdev, device_t child, char *buf, > + size_t buflen) > +{ > + struct acpi_device *dinfo= device_get_ivars(child); style -- space before '='. You should remove this initialization anyway since it is duplicated below. > + > + dinfo = device_get_ivars(child); > + if(dinfo->ad_handle) style -- space after "if" > + snprintf(buf, buflen, "path=%s", acpi_name(dinfo->ad_handle)); > + else > + snprintf(buf, buflen, "magic=unknown"); > + return (0); > +} style -- use 4 spaces instead of a tab, tabs for 8-space indents. This applies to the whole commit. See other parts of this file. > +int > +acpi_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, > + size_t buflen) > +{ > + struct acpi_device *dinfo = device_get_ivars(child); Duplicate initialization. > + ACPI_DEVICE_INFO adinfo; > + ACPI_BUFFER adbuf = {sizeof(adinfo), &adinfo}; Please dynamically allocate buffer elements as done elsewhere. Our kernel stack is restricted. > + char * end; style -- space after *. > + int error; > + > + dinfo = device_get_ivars(child); > + error = AcpiGetObjectInfo(dinfo->ad_handle, &adbuf); > + > + if(error) style -- space needed after "if" > + snprintf(buf, buflen, "Unknown"); > + else > + snprintf(buf, buflen, "_HID=%s _UID=%u", > + (adinfo.Valid & ACPI_VALID_HID)? > + adinfo.HardwareId.Value : "UNKNOWN", > + (unsigned int)((adinfo.Valid & ACPI_VALID_UID)? > + strtoul(adinfo.UniqueId.Value, &end, 10):0 )); > + > + return (0); > +} How about adding first _CID value if it's valid? Instead of cast, just use "%ul" as the format. This would simplify the statement to: > (adinfo.Valid & ACPI_VALID_UID) ? > strtoul(adinfo.UniqueId.Value, &end, 10) : 0); Also note spaces added above. Thanks, Nate