Received: from list by lists.gnu.org with archive (Exim 4.71) id 1euD76-0002rA-8U for mharc-grub-devel@gnu.org; Fri, 09 Mar 2018 03:10:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euD73-0002og-IS for grub-devel@gnu.org; Fri, 09 Mar 2018 03:10:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euD6y-0000Pv-Ga for grub-devel@gnu.org; Fri, 09 Mar 2018 03:10:49 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:48904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1euD6y-0000PU-5w for grub-devel@gnu.org; Fri, 09 Mar 2018 03:10:44 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2986vIE046116 for ; Fri, 9 Mar 2018 08:10:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=y1odixKCZYSXLi6FkqaJKJJEHx7TIczYxh8ti6O32xI=; b=EH2A5spVkpyCU3+Mmlf+9Rdenvgn5K9+xtIANqcvkE9wdZ0wJxk9ybmutGe2tmoPv+Re P5dEZPPYEZJk5A2BMFPMioA66GrAGBYSW7uW+SJJxkXayYW5kcYsnNGnh12u0IzRYyX5 ySB4H6BXkxQEZx+WprFugBMFKOL1z7kdFT/Oy2y4YdavWMNXJ3RInW1VYVxVzkFRF94E ls3Y3LSeI/TyOn3QGLddG0uAt8yG6foRI3ozfLoLm6ewF0pO6mlsj37hfo4rrhKEC5LH mR1iU3egnfN/OWBaCfj7SdA5oPY5B2Bk06TDVcu1qXCtxyrRnPMWYQWdIY/nd6cLQBTS 8w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2gknv4032m-20 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Mar 2018 08:10:41 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w294gn9Y023696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 9 Mar 2018 04:42:49 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w294gmC6018426 for ; Fri, 9 Mar 2018 04:42:48 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Mar 2018 20:42:48 -0800 From: Eric Snowberg To: grub-devel@gnu.org Cc: daniel.kiper@ORACLE.COM, eric.snowberg@ORACLE.COM Subject: [PATCH V2] ieee1275: split up grub_machine_get_bootlocation Date: Thu, 8 Mar 2018 20:42:22 -0800 Message-Id: <1520570542-190536-1-git-send-email-eric.snowberg@oracle.com> X-Mailer: git-send-email 1.7.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8826 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803090107 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2018 08:10:50 -0000 Split up some of the functionality in grub_machine_get_bootlocation into grub_ieee1275_get_boot_dev. This will allow for code reuse in a follow on patch. Signed-off-by: Eric Snowberg --- V2 changes: Coding style changes requested by Daniel Kiper --- grub-core/kern/ieee1275/init.c | 20 ++------------------ grub-core/kern/ieee1275/openfw.c | 27 +++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 1 + 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 1259022..62dfb8a 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -94,28 +94,12 @@ void grub_machine_get_bootlocation (char **device, char **path) { char *bootpath; - grub_ssize_t bootpath_size; char *filename; char *type; - if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", - &bootpath_size) - || bootpath_size <= 0) - { - /* Should never happen. */ - grub_printf ("/chosen/bootpath property missing!\n"); - return; - } - - bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); + bootpath = grub_ieee1275_get_boot_dev (); if (! bootpath) - { - grub_print_error (); - return; - } - grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, - (grub_size_t) bootpath_size + 1, 0); - bootpath[bootpath_size] = '\0'; + return; /* Transform an OF device path to a GRUB path. */ diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c index ddb7783..74a0a23 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -561,3 +561,30 @@ grub_ieee1275_canonicalise_devname (const char *path) return NULL; } +char * +grub_ieee1275_get_boot_dev (void) +{ + char *bootpath; + grub_ssize_t bootpath_size; + + if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", + &bootpath_size) + || bootpath_size <= 0) + { + /* Should never happen. */ + grub_printf ("/chosen/bootpath property missing!\n"); + return NULL; + } + + bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); + if (! bootpath) + { + grub_print_error (); + return NULL; + } + grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, + (grub_size_t) bootpath_size + 1, 0); + bootpath[bootpath_size] = '\0'; + + return bootpath; +} diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index d0dc274..08a8976 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -253,6 +253,7 @@ void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *al void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, struct grub_ieee1275_devalias *alias); +char *EXPORT_FUNC(grub_ieee1275_get_boot_dev) (void); #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) #define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \ -- 1.7.1