dell_rbu: Resubmitting patch for new Dell BIOS update driver
PATCH 1/1 dell_rbu: Resubmitting patch for new Dell BIOS update driver
Resubmitting after cleaning up spaces/tabs etc...
By making a contribution to this project, I certify that:
The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file. Resubmitting after cleaning up spaces/tabs etc...
Thanks,
Abhay Salunke
Software Engineer.
DELL Inc
Documentation/DELL_RBU.txt +70 -0
@@ -0,0 +1,70 @@ +Purpose: +Demonstrate the usage of the DELL_RBU (DELL Remote BIOS Update) driver +for updating BIOS images on Dell hardware. + +Scope: +This document discusses the functionality of the DELL_RBU driver. +This driver is required by BIOS update applications shipped by DELL for updating +BIOS on DELL servers and client systems. + +Overview: +The rbu driver is designed to be running on 2.6 kernel. +This driver is one single dell_rbu.c file (approx 800 lines total). +This driver utilizes the hotplug interface for downloading the BIOS update image +in the contiguous or packetized memory depending upon the update type. +The BIOS then scans the memory to find the image and will then update itself. +There are basically two different mechanisms for writing the BIOS image in to +contiguous memory +1> By writing the image to one monolithic chunk of contiguous physical memory. +2> By writing image in to smaller packet chunks of contiguous physical memory. +The update mechanism is determined by the update application based on the +particular system type. + +Update mechanism using single physical chunk of memory: +The rbu driver on its load time created the following entries in sysfs +/sys/firmware/dell_rbu/monolithic/mono_name +/sys/firmware/dell_rbu/monolithic/mono_size +/sys/firmware/dell_rbu/packetized/packet_name +/sys/firmware/dell_rbu/packetized/packet_size + +Steps to update the BIOS image: + +1> Copy the image file in to /lib/firmware +2> echo the image name in to /sys/firmware/dell_rbu/xxxx/xxxx_name + +This will generate a hotplug event and the data form the image file is +transferred to the memory. +Here xxxx stands for the type of BIOS update mechanism chosen by choosing +monolitich the image is copied to contiguous physical pages and by choosing +the mechanism as packetized the image is treated as one single packet and the +packet size is set to the first packet image size. If a new image packet of +different size form the previous is copied then all the previous packets are +freed and this packet's size is treated as new packet size. + +On a driver unload all the allocated memory is freed. +The user should not unload the driver after downloading the new BIOS image +if it wants to update BIOS with that image. +The user can overwrite the previously loaded monolithich image by echoing a +new file name string to /sys/firmware/dell_rbu/monolithic/mono_name. Make sure +the file is present in /lib/firmware. If the image size is more than +previous image then the previous image is freed and the new alocation is made. + +The user can know of a successful allocation by readind the size files. +cat /sys/firmware/dell_rbu/monolithic/mono_size + +Update using smaller chunks (packets) of contiguous memory: +The disadvantage of contiguous allocation is that it may not be always possible +to get that size of contiuguous chunk of avaliable physical pages as in most +Linux systems the memory gets fragmented immideately after a reboot. +The update using smaller chunks fixes this issue; it also requires the BIOS on +the system to support this feature; the update application needs to query this +with the BIOS on the system before using this technique. + + +NOTE: +Afte updating the BIOS image the appplication needs to communicate with the BIOS +for enabling the update on the next reboot. The application can then choose to +reboot the system imideately or not reboot the system and leave up to the user +to do a reboot. + +
drivers/firmware/dell_rbu.c +680 -0
680 lines not on this page · raw message
drivers/firmware/Kconfig +13 -0
@@ -58,4 +58,17 @@ config EFI_PCDP See <http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf> +config DELL_RBU + tristate "BIOS update support for DELL systems via sysfs" + default n + select FW_LOADER + help + Say Y if you want to have the option of updating the BIOS for your + DELL system. Note you need a supporting application to comunicate + with the BIOS regardin the new image for the image update to + take effect. + + See <file:Documentation/DELL_RBU.txt> for more details on the driver. + + endmenu
drivers/firmware/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_EDD) += edd.o obj-$(CONFIG_EFI_VARS) += efivars.o obj-$(CONFIG_EFI_PCDP) += pcdp.o +obj-$(CONFIG_DELL_RBU) += dell_rbu.o
Hi Abhay,
Quoted 1 line
Resubmitting after cleaning up spaces/tabs etc...
and now starting with the coding style nitpicking ;)
drivers/firmware/dell_rbu.c line 111
Quoted 2 lines
drivers/firmware/dell_rbu.c +2
-0+/* check if we have any packets */ +if (0 == rbu_data.num_packets) {
Make it "if (!rbu_data.num_packets) {".
drivers/firmware/dell_rbu.c line 122
Quoted 3 lines
drivers/firmware/dell_rbu.c +3
-0+while (--packet_count) { + ptemp_list = ptemp_list->next; + }
Don't forget the space between "while" and "(" and the "{"/"}" are not needed.
drivers/firmware/dell_rbu.c line 124
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+ ppacket = list_entry(ptemp_list,struct packet_data, list);
We always put a space after ",".
drivers/firmware/dell_rbu.c line 126
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ((rbu_data.packet_write_count + length) > rbu_data.packetsize) {
Make it "(rbu_data.packet_write_count + length > rbu_data.packetsize)".
drivers/firmware/dell_rbu.c line 136
Quoted 3 lines
drivers/firmware/dell_rbu.c +3
-0+/* copy the incoming data in to the new buffer */ +memcpy ((ppacket->data + rbu_data.packet_write_count), + data, length);
Make it "memcpy(ppacket->data + rbu_data.packet_write_count, ".
drivers/firmware/dell_rbu.c line 145
Quoted 8 lines
drivers/firmware/dell_rbu.c +8
-0+if ((rbu_data.packet_write_count + length) == rbu_data.packetsize) { +/* +this was the last data chunk in the packet +so reinitialize the packet data counter to zero +*/ + rbu_data.packet_write_count =0 ; + }else + rbu_data.packet_write_count += length;
Why not:
rbu_data.packet_write_count += length; if (rbu_data.packet_write_count == rbu_data.packetsize) rbu_data.packet_write_count = 0;
drivers/firmware/dell_rbu.c line 180
Quoted 2 lines
drivers/firmware/dell_rbu.c +2
-0+/* try allocating a new buffer to fit the request */ + pbuf =(unsigned char *)__get_free_pages (GFP_KERNEL , *ordernum);
Forgot a space after "=" and after "...char*)".
drivers/firmware/dell_rbu.c line 182
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (pbuf !=NULL ) {
Make it "if (!pbuf)",
drivers/firmware/dell_rbu.c line 184
Quoted 2 lines
drivers/firmware/dell_rbu.c +2
-0+/* check if the image is with in limits */ + img_buf_phys_addr = (unsigned long )virt_to_phys (pbuf);
Put a space after "...long)".
drivers/firmware/dell_rbu.c line 186
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ((limit !=0 ) && ((img_buf_phys_addr + size) > limit)) {
Make it "if (!limit && img_bug_phys_addr + size > limit)"
drivers/firmware/dell_rbu.c line 193
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+free_pages ((unsigned long )pbuf, *ordernum);
Space.
drivers/firmware/dell_rbu.c line 198
Quoted 4 lines
drivers/firmware/dell_rbu.c +4
-0+Try allocating a new buffer from the +GFP_DMA range as it is with in 16MB range. +*/ + pbuf =(unsigned char *)__get_free_pages(GFP_DMA,
Space.
drivers/firmware/dell_rbu.c line 200
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (pbuf ==NULL )
Use "(!pbuf)".
drivers/firmware/dell_rbu.c line 216
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (rbu_data.packetsize ==0 ) {
Use "if (!rbu_data.packetsize)".
drivers/firmware/dell_rbu.c line 222
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (newpacket ==NULL ) {
Use "if (!newpacket)".
drivers/firmware/dell_rbu.c line 233
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (newpacket->data ==NULL ) {
Use "if (!newpacket->data)"
drivers/firmware/dell_rbu.c line 260
Quoted 4 lines
drivers/firmware/dell_rbu.c +4
-0+if (rbu_data.packet_write_count ==0 ) { +if ((rc =create_packet (length)) !=0 ) +return rc; + }
Use this:
if (!rbu_data.packet_write_count) if (!(rc = create_packet(length))) return rc;
drivers/firmware/dell_rbu.c line 262
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ((rc =fill_last_packet (data, length)) !=0 )
Use "if (!(rc = fill_last_packet(data, length)))".
drivers/firmware/dell_rbu.c line 285
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+free_pages ((unsigned long )newpacket->data, newpacket->ordernum);
Space.
drivers/firmware/dell_rbu.c line 301
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (rbu_data.image_update_buffer ==NULL )
Use "(!rbu_data.image_update_buffer)".
drivers/firmware/dell_rbu.c line 309
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+ free_pages((unsigned long)rbu_data.image_update_buffer,
Space.
drivers/firmware/dell_rbu.c line 337
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ((size !=0 ) && (rbu_data.image_update_buffer ==NULL )) {
Use "if (!size && !rbu_data.image_update_buffer)"
drivers/firmware/dell_rbu.c line 356
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+ image_update_buffer = (unsigned char *)get_free_pages_limited(size,
Space.
drivers/firmware/dell_rbu.c line 363
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (image_update_buffer !=NULL ) {
Use "if (!image_update_buffer)".
drivers/firmware/dell_rbu.c line 367
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+ memset(rbu_data.image_update_buffer,0,
Space.
drivers/firmware/dell_rbu.c line 388
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+sscanf (buf,"%d" ,&size);
Spaces.
drivers/firmware/dell_rbu.c line 389
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (size !=0 )
Use "if (!size)".
Review
Quoted 1 line
(quoted diff) +1
-0+ if (type == MONOLITHIC )
Space.
drivers/firmware/dell_rbu.c line 406
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ( type ==MONOLITHIC )
Spaces.
drivers/firmware/dell_rbu.c line 407
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+ size =sprintf (buf,"%lu\n" , rbu_data.bios_image_size);
Extra space not needed.
Review
Quoted 1 line
(quoted diff) +1
-0+ if (type == MONOLITHIC )
Space.
drivers/firmware/dell_rbu.c line 436
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (strlen (buf) >=256 ) {
Space.
Review
Quoted 1 line
(quoted diff) +1
-0+ if (type == MONOLITHIC ) {
Space.
Review
Quoted 1 line
(quoted diff) +1
-0+ if (type == MONOLITHIC ) {
Space.
drivers/firmware/dell_rbu.c line 465
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (fw_entry->size ==0 )
use "if (!fw_entry->size)".
drivers/firmware/dell_rbu.c line 469
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (rc ==0 ) {
Use "if (!rc)".
drivers/firmware/dell_rbu.c line 481
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ( rbu_data.packetsize != fw_entry->size )
Spaces.
drivers/firmware/dell_rbu.c line 486
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if ( rc ==0 )
Spaces.
Quoted 1 line
+static
decl_subsys(dell_rbu,&ktype_dell_rbu,NULL);
Spaces.
Quoted 1 line
+
memset(rbu_dev, 0, sizeof (*rbu_dev));
No tab.
drivers/firmware/dell_rbu.c line 579
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (type ==MONOLITHIC )
Space.
Review
Quoted 1 line
(quoted diff) +1
-0+ if (type == MONOLITHIC ) {
Space.
drivers/firmware/dell_rbu.c line 628
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (rbu_dev !=NULL ) {
Use "if (!rbu_dev)".
Quoted 1 line
+static int
__initdcdrbu_init(void)
What stand "dcd" for? Why not only "rbu_init"?
drivers/firmware/dell_rbu.c line 651
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (rbu_download_mono ==NULL ) {
Use "if (!rbu_download)".
drivers/firmware/dell_rbu.c line 656
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+ rbu_download_packet=create_rbu_download_entry (PACKETIZED );
Wrong spaces.
drivers/firmware/dell_rbu.c line 657
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+if (rbu_download_packet ==NULL ) {
Use "if (!rbu_download_packet)".
drivers/firmware/dell_rbu.c line 662
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+strncpy (rbu_device.bus_id,"firmware" ,BUS_ID_SIZE );
Space.
Quoted 1 line
+static
__exitvoiddcdrbu_exit( void)
Why "dcd"?
drivers/firmware/Kconfig config EFI_PCDP · line 64
Quoted 4 lines
drivers/firmware/Kconfig +4
-0+config DELL_RBU + tristate "BIOS update support for DELL systems via sysfs" + default n + select FW_LOADER
Space vs tab clash.
Regards
Marcel
Quoted 5 lines · Marcel Holtmann
drivers/firmware/dell_rbu.c line 262
Quoted 2 lines
drivers/firmware/dell_rbu.c +1
-0+if ((rc =fill_last_packet (data, length)) !=0 )Use "if (!(rc =
fill_last_packet(data, length)))".
Even better like this?
rc = fill_last_packet(data, length); if (!rc)
Quoted 5 lines
drivers/firmware/dell_rbu.c line 486
Quoted 2 lines
drivers/firmware/dell_rbu.c +1
-0+if ( rc ==0 )Spaces.
Plus use: if (!rc)
Regards,
Andreas Henriksson
Quoted 6 lines · Marcel Holtmann
Hi Abhay,
Quoted 1 line
Resubmitting after cleaning up spaces/tabs etc...
and now starting with the coding style nitpicking ;)
[snip]
Quoted 4 lines
Quoted 1 line
+ if (pbuf != NULL) {
Make it "if (!pbuf)",
[snip]
You want to make it "if (pbuf)" otherwise you'd be changing the logic.
Signature · 3 lines
Jesper Juhl <[email protected]> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html