From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, pcihpd-discuss@lists.sourceforge.net
Subject: Re: [PATCH] PCI Hotplug changes for 2.5.59
Date: Wed, 5 Feb 2003 20:08 -0800 [thread overview]
Message-ID: <10445044842980@kroah.com> (raw)
In-Reply-To: <1044504483994@kroah.com>
ChangeSet 1.947.23.2, 2003/02/05 17:15:55+11:00, greg@kroah.com
[PATCH] IBM PCI Hotplug driver: Clean up the slot filename generation logic a lot.
diff -Nru a/drivers/hotplug/ibmphp_ebda.c b/drivers/hotplug/ibmphp_ebda.c
--- a/drivers/hotplug/ibmphp_ebda.c Thu Feb 6 14:52:23 2003
+++ b/drivers/hotplug/ibmphp_ebda.c Thu Feb 6 14:52:23 2003
@@ -65,8 +65,6 @@
static LIST_HEAD (opt_lo_head);
static void *io_mem;
-char *chassis_str, *rxe_str, *str;
-
/* Local functions */
static int ebda_rsrc_controller (void);
static int ebda_rsrc_rsrc (void);
@@ -591,32 +589,6 @@
return 0;
}
-static char *convert_2digits_to_char (int var)
-{
- int bit;
- char *str1;
-
- str = (char *) kmalloc (3, GFP_KERNEL);
- memset (str, 0, 3);
- str1 = (char *) kmalloc (2, GFP_KERNEL);
- memset (str, 0, 3);
- bit = (int)(var / 10);
- switch (bit) {
- case 0:
- //one digit number
- *str = (char)(var + 48);
- return str;
- default:
- //2 digits number
- *str1 = (char)(bit + 48);
- strncpy (str, str1, 1);
- memset (str1, 0, 3);
- *str1 = (char)((var % 10) + 48);
- strcat (str, str1);
- return str;
- }
- return NULL;
-}
/* Since we don't know the max slot number per each chassis, hence go
* through the list of all chassis to find out the range
@@ -701,7 +673,7 @@
{
struct opt_rio *opt_vg_ptr = NULL;
struct opt_rio_lo *opt_lo_ptr = NULL;
- char *ptr_chassis_num, *ptr_rxe_num, *ptr_slot_num;
+ static char str[30];
int which = 0; /* rxe = 1, chassis = 0 */
u8 number = 1; /* either chassis or rxe # */
u8 first_slot = 1;
@@ -715,19 +687,7 @@
slot_num = slot_cur->number;
- chassis_str = (char *) kmalloc (30, GFP_KERNEL);
- memset (chassis_str, 0, 30);
- rxe_str = (char *) kmalloc (30, GFP_KERNEL);
- memset (rxe_str, 0, 30);
- ptr_chassis_num = (char *) kmalloc (3, GFP_KERNEL);
- memset (ptr_chassis_num, 0, 3);
- ptr_rxe_num = (char *) kmalloc (3, GFP_KERNEL);
- memset (ptr_rxe_num, 0, 3);
- ptr_slot_num = (char *) kmalloc (3, GFP_KERNEL);
- memset (ptr_slot_num, 0, 3);
-
- strcpy (chassis_str, "chassis");
- strcpy (rxe_str, "rxe");
+ memset (str, 0, sizeof(str));
if (rio_table_ptr) {
if (rio_table_ptr->ver_num == 3) {
@@ -772,31 +732,10 @@
}
}
- switch (which) {
- case 0:
- /* Chassis */
- *ptr_chassis_num = (char)(number + 48);
- strcat (chassis_str, ptr_chassis_num);
- kfree (ptr_chassis_num);
- strcat (chassis_str, "slot");
- ptr_slot_num = convert_2digits_to_char (slot_num - first_slot + 1);
- strcat (chassis_str, ptr_slot_num);
- kfree (ptr_slot_num);
- return chassis_str;
- break;
- case 1:
- /* RXE */
- *ptr_rxe_num = (char)(number + 48);
- strcat (rxe_str, ptr_rxe_num);
- kfree (ptr_rxe_num);
- strcat (rxe_str, "slot");
- ptr_slot_num = convert_2digits_to_char (slot_num - first_slot + 1);
- strcat (rxe_str, ptr_slot_num);
- kfree (ptr_slot_num);
- return rxe_str;
- break;
- }
- return NULL;
+ sprintf(str, "%s%dslot%d",
+ which == 0 ? "chassis" : "rxe",
+ number, slot_num - first_slot + 1);
+ return str;
}
static struct pci_driver ibmphp_driver;
@@ -1060,10 +999,6 @@
slot_cur = list_entry (list, struct slot, ibm_slot_list);
snprintf (slot_cur->hotplug_slot->name, 30, "%s", create_file_name (slot_cur));
- if (chassis_str)
- kfree (chassis_str);
- if (rxe_str)
- kfree (rxe_str);
pci_hp_register (slot_cur->hotplug_slot);
}
next prev parent reply other threads:[~2003-02-06 4:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-06 4:03 [BK PATCH] PCI Hotplug changes for 2.5.59 Greg KH
2003-02-06 4:08 ` [PATCH] " Greg KH
2003-02-06 4:08 ` Greg KH [this message]
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
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=10445044842980@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pcihpd-discuss@lists.sourceforge.net \
/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