2005-10-01 Hollis Blanchard <hollis@penguinppc.org>

* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.

	* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
	Remove `flags' argument.  All callers changed.
	* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
	(IEEE1275_IHANDLE_INVALID): New variable.
	(IEEE1275_CELL_INVALID): New variable.
	(grub_ieee1275_finddevice, grub_ieee1275_get_property,
	grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
	grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
	grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
	grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
	codes from Open Firmware.  All callers updated.
	(grub_ieee1275_next_property): Directly return Open Firmware return
	code.
	* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
	Standardize error checking from `grub_ieee1275_get_property'.
	* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
	`devalias' to `aliases'.  Correct comments.  Consolidate error paths.
This commit is contained in:
hollisb 2006-10-01 08:30:09 +00:00
parent cc6d3df39e
commit fba51f4801
6 changed files with 84 additions and 67 deletions

View file

@ -51,19 +51,18 @@ grub_ieee1275_find_options (void)
{
grub_ieee1275_phandle_t options;
grub_ieee1275_phandle_t openprom;
int realmode;
int smartfw;
int rc;
int realmode = 0;
grub_ieee1275_finddevice ("/options", &options);
grub_ieee1275_get_property (options, "real-mode?", &realmode,
sizeof (realmode), 0);
if (realmode)
rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
sizeof realmode, 0);
if ((rc >= 0) && realmode)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
grub_ieee1275_finddevice ("/openprom", &openprom);
smartfw = grub_ieee1275_get_property (openprom, "SmartFirmware-version",
0, 0, 0);
if (smartfw != -1)
rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", 0, 0, 0);
if (rc >= 0)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
}

View file

@ -38,12 +38,10 @@ grub_children_iterate (char *devpath,
grub_ieee1275_phandle_t dev;
grub_ieee1275_phandle_t child;
grub_ieee1275_finddevice (devpath, &dev);
if (dev == (grub_ieee1275_phandle_t) -1)
if (grub_ieee1275_finddevice (devpath, &dev))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
grub_ieee1275_child (dev, &child);
if (child == (grub_ieee1275_phandle_t) -1)
if (grub_ieee1275_child (dev, &child))
return grub_error (GRUB_ERR_BAD_DEVICE, "Device has no children");
do
@ -56,19 +54,16 @@ grub_children_iterate (char *devpath,
struct grub_ieee1275_devalias alias;
int actual;
grub_ieee1275_get_property (child, "device_type", &childtype,
sizeof childtype, &actual);
if (actual == -1)
if (grub_ieee1275_get_property (child, "device_type", &childtype,
sizeof childtype, &actual))
continue;
grub_ieee1275_package_to_path (child, childpath, sizeof childpath,
&actual);
if (actual == -1)
if (grub_ieee1275_package_to_path (child, childpath, sizeof childpath,
&actual))
continue;
grub_ieee1275_get_property (child, "name", &childname,
sizeof childname, &actual);
if (actual == -1)
if (grub_ieee1275_get_property (child, "name", &childname,
sizeof childname, &actual))
continue;
grub_sprintf (fullname, "%s/%s", devpath, childname);
@ -88,62 +83,52 @@ grub_children_iterate (char *devpath,
grub_err_t
grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
{
grub_ieee1275_phandle_t devalias;
grub_ieee1275_phandle_t aliases;
char aliasname[32];
int actual;
struct grub_ieee1275_devalias alias;
if (grub_ieee1275_finddevice ("/aliases", &devalias))
if (grub_ieee1275_finddevice ("/aliases", &aliases))
return -1;
/* XXX: Is this the right way to find the first property? */
/* Find the first property. */
aliasname[0] = '\0';
/* XXX: Are the while conditions correct? */
while (grub_ieee1275_next_property (devalias, aliasname, aliasname, 0))
while (grub_ieee1275_next_property (aliases, aliasname, aliasname))
{
grub_ieee1275_phandle_t dev;
grub_ssize_t pathlen;
char *devpath;
/* XXX: This should be large enough for any possible case. */
char devtype[64];
grub_ieee1275_get_property_length (devalias, aliasname, &pathlen);
grub_ieee1275_get_property_length (aliases, aliasname, &pathlen);
/* The property `name' is a special case we should skip. */
if (!grub_strcmp (aliasname, "name"))
continue;
continue;
devpath = grub_malloc (pathlen);
if (! devpath)
return grub_errno;
if (grub_ieee1275_get_property (devalias, aliasname, devpath, pathlen,
if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
&actual))
{
grub_free (devpath);
continue;
}
if (grub_ieee1275_finddevice (devpath, &dev)
|| dev == (grub_ieee1275_phandle_t) -1)
{
grub_free (devpath);
continue;
}
goto nextprop;
if (grub_ieee1275_get_property (dev, "device_type", devtype, sizeof devtype,
&actual))
{
grub_free (devpath);
continue;
}
if (grub_ieee1275_finddevice (devpath, &dev))
goto nextprop;
if (grub_ieee1275_get_property (dev, "device_type", devtype,
sizeof devtype, &actual))
goto nextprop;
alias.name = aliasname;
alias.path= devpath;
alias.path = devpath;
alias.type = devtype;
hook (&alias);
nextprop:
grub_free (devpath);
}