PNP: minor cleanups
Subsystems (3)
PATCH 2/6 PNPACPI: simplify irq_flags()
In reply to Bjorn HelgaasNo need for a temporary variable; just return the flags once we know them.
drivers/pnp/pnpacpi/rsparser.c +4 -7
@@ -34,20 +34,17 @@*/ static int irq_flags (int triggering,int polarity) { -int flag; -if (triggering ==ACPI_LEVEL_SENSITIVE ) {if (polarity ==ACPI_ACTIVE_LOW ) - flag =IORESOURCE_IRQ_LOWLEVEL ; +return IORESOURCE_IRQ_LOWLEVEL ;else - flag =IORESOURCE_IRQ_HIGHLEVEL ; +return IORESOURCE_IRQ_HIGHLEVEL ; }else {if (polarity ==ACPI_ACTIVE_LOW ) - flag =IORESOURCE_IRQ_LOWEDGE ; +return IORESOURCE_IRQ_LOWEDGE ;else - flag =IORESOURCE_IRQ_HIGHEDGE ; +return IORESOURCE_IRQ_HIGHEDGE ; } -return flag; }static void decode_irq_flags (int flag,int *triggering,int *polarity)
--
PATCH 6/6 PNP: remove null pointer checks
In reply to Bjorn HelgaasRemove some null pointer checks. Null pointers in these areas indicate programming errors, and I think it's better to oops immediately rather than return an error that is easily ignored.
drivers/pnp/core.c +1 -6
@@ -52,9 +52,6 @@int nodenum;struct list_head *pos; -if (!protocol) -return -EINVAL ; -INIT_LIST_HEAD (&protocol->devices);INIT_LIST_HEAD (&protocol->cards); nodenum =0 ;
@@ -94,8 +91,6 @@struct pnp_id *id;struct pnp_id *next; -if (!dev) -return ; id = dev->id;while (id) { next = id->next;
@@ -143,7 +138,7 @@*/ int pnp_add_device (struct pnp_dev *dev) { -if (!dev || !dev->protocol || dev->card) +if (dev->card)return -EINVAL ; dev->dev.parent = &dev->protocol->dev; sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
drivers/pnp/driver.c +0 -4
@@ -232,10 +232,6 @@ {struct pnp_id *ptr; -if (!id) -return -EINVAL ; -if (!dev) -return -EINVAL ; id->next =NULL ; ptr = dev->id;while (ptr && ptr->next)
drivers/pnp/manager.c +0 -23
@@ -21,9 +21,6 @@resource_size_t *start, *end;unsigned long *flags; -if (!dev || !rule) -return -EINVAL ; -if (idx >=PNP_MAX_PORT ) {pnp_err ("More than 4 ports is incompatible with pnp specifications." );
@@ -66,9 +63,6 @@resource_size_t *start, *end;unsigned long *flags; -if (!dev || !rule) -return -EINVAL ; -if (idx >=PNP_MAX_MEM ) {pnp_err ("More than 8 mems is incompatible with pnp specifications." );
@@ -127,9 +121,6 @@5 ,10 ,11 ,12 ,9 ,14 ,15 ,7 ,3 ,4 ,13 ,0 ,1 ,6 ,8 ,2 }; -if (!dev || !rule) -return -EINVAL ; -if (idx >=PNP_MAX_IRQ ) {pnp_err ("More than 2 irqs is incompatible with pnp specifications." );
@@ -181,9 +172,6 @@ 1, 3, 5, 6, 7, 0, 2, 4 }; -if (!dev || !rule) -return -EINVAL ; -if (idx >=PNP_MAX_DMA ) {pnp_err ("More than 2 dmas is incompatible with pnp specifications." );
@@ -410,8 +398,6 @@int i;struct pnp_resource_table *bak; -if (!dev || !res) -return -EINVAL ;if (!pnp_can_configure (dev))return -ENODEV ; bak =pnp_alloc (sizeof (struct pnp_resource_table ));
@@ -460,9 +446,6 @@struct pnp_option *dep;int i =1 ; -if (!dev) -return -EINVAL ; -if (!pnp_can_configure (dev)) {pnp_dbg ("Device %s does not support resource configuration." , dev->dev.bus_id);
@@ -541,8 +524,6 @@ {int error; -if (!dev) -return -EINVAL ;if (dev->active)return 0 ;/* the device is already active */
@@ -568,8 +549,6 @@ {int error; -if (!dev) -return -EINVAL ;if (!dev->active)return 0 ;/* the device is already disabled */
@@ -596,8 +575,6 @@void pnp_resource_change (struct resource *resource,resource_size_t start,resource_size_t size) { -if (resource ==NULL ) -return ; resource->flags &= ~(IORESOURCE_AUTO |IORESOURCE_UNSET ); resource->start = start; resource->end = start + size -1 ;
drivers/pnp/resource.c +0 -26
@@ -47,9 +47,6 @@ {struct pnp_option *option; -if (!dev) -return NULL ; - option =pnp_build_option (PNP_RES_PRIORITY_PREFERRED );/* this should never happen but if it does we'll try to continue */
@@ -64,9 +61,6 @@ {struct pnp_option *option; -if (!dev) -return NULL ; - option =pnp_build_option (priority);if (dev->dependent) {
@@ -83,11 +77,6 @@ {struct pnp_irq *ptr; -if (!option) -return -EINVAL ; -if (!data) -return -EINVAL ; - ptr = option->irq;while (ptr && ptr->next) ptr = ptr->next;
@@ -112,11 +101,6 @@ {struct pnp_dma *ptr; -if (!option) -return -EINVAL ; -if (!data) -return -EINVAL ; - ptr = option->dma;while (ptr && ptr->next) ptr = ptr->next;
@@ -132,11 +116,6 @@ {struct pnp_port *ptr; -if (!option) -return -EINVAL ; -if (!data) -return -EINVAL ; - ptr = option->port;while (ptr && ptr->next) ptr = ptr->next;
@@ -152,11 +131,6 @@ {struct pnp_mem *ptr; -if (!option) -return -EINVAL ; -if (!data) -return -EINVAL ; - ptr = option->mem;while (ptr && ptr->next) ptr = ptr->next;
drivers/pnp/isapnp/core.c +1 -1
@@ -1040,7 +1040,7 @@static int isapnp_disable_resources (struct pnp_dev *dev) { -if (!dev || !dev->active) +if (!dev->active)return -EINVAL ;isapnp_cfg_begin (dev->card->number, dev->number);isapnp_deactivate (dev->number);
--
PATCH 3/6 PNPACPI: remove unnecessary casts of "void *"
In reply to Bjorn HelgaasRemove unnecessary casts of void pointers.
drivers/pnp/pnpacpi/rsparser.c +5 -8
@@ -240,8 +240,7 @@static acpi_status pnpacpi_allocated_resource (struct acpi_resource *res,void *data) { -struct pnp_resource_table *res_table = - (struct pnp_resource_table *)data; +struct pnp_resource_table *res_table = data;int i;switch (res->type) {
@@ -564,8 +563,7 @@ void *data) {int priority =0 ; -struct acpipnp_parse_option_s *parse_data = - (struct acpipnp_parse_option_s *)data; +struct acpipnp_parse_option_s *parse_data = data;struct pnp_dev *dev = parse_data->dev;struct pnp_option *option = parse_data->option;
@@ -703,7 +701,7 @@static acpi_status pnpacpi_count_resources (struct acpi_resource *res,void *data) { -int *res_cnt = (int *)data; +int *res_cnt = data;if (pnpacpi_supported_resource (res)) (*res_cnt)++;
@@ -712,7 +710,7 @@static acpi_status pnpacpi_type_resources (struct acpi_resource *res,void *data) { -struct acpi_resource **resource = (struct acpi_resource **)data; +struct acpi_resource **resource = data;if (pnpacpi_supported_resource (res)) { (*resource)->type = res->type;
@@ -884,8 +882,7 @@int i =0 ;/* pnpacpi_build_resource_template allocates extra mem */ int res_cnt = (buffer->length -1 ) /sizeof (struct acpi_resource ) -1 ; -struct acpi_resource *resource = - (struct acpi_resource *)buffer->pointer; +struct acpi_resource *resource = buffer->pointer;int port =0 , irq =0 , dma =0 , mem =0 ;pnp_dbg ("res cnt %d" , res_cnt);
--
PATCH 5/6 PNP: remove MODULE infrastructure
In reply to Bjorn HelgaasWe don't support building any part of PNP as a module (*drivers* can be modules, of course, but the PNP infrastructure itself can not). Since MODULE will never be defined, remove the ifdefs and dead code.
drivers/pnp/pnpbios/core.c +0 -43
@@ -419,7 +419,6 @@static int pnpbios_disabled;int pnpbios_dont_use_current_config; -#ifndef MODULE static int __init pnpbios_setup (char *str) {int invert;
@@ -443,7 +442,6 @@ }__setup ("pnpbios=" , pnpbios_setup); -#endif /* PnP BIOS signature: "$PnP" */ #define PNP_SIGNATURE (('$' << 0) + ('P' << 8) + ('n' << 16) + ('P' << 24))
@@ -607,48 +605,7 @@return 0 ; } -#ifndef MODULE - -/* init/main.c calls pnpbios_init early */ -/* Start the kernel thread later: */ module_init (pnpbios_thread_init); -#else - -/* -* N.B.: Building pnpbios as a module hasn't been fully implemented -*/ - -MODULE_LICENSE ("GPL" ); - -static int __init pnpbios_init_all (void ) -{ -int r; - - r =pnpbios_init (); -if (r) -return r; - r =pnpbios_thread_init (); -if (r) -return r; -return 0 ; -} - -static void __exit pnpbios_exit(void) -{ -#ifdef CONFIG_HOTPLUG - unloading =1 ; -wait_for_completion (&unload_sem); -#endif -pnpbios_proc_exit (); -/* We ought to free resources here */ -return ; -} - -module_init (pnpbios_init_all); -module_exit (pnpbios_exit); - -#endif -EXPORT_SYMBOL (pnpbios_protocol);
drivers/pnp/isapnp/proc.c +0 -45
54 lines not on this page · raw message
--
cover PNP: minor cleanups
Fix a few more Lindent things and remove some unused code and unnecessary casts.
The last patch removes some null pointer checks in cases where I think it's better to just oops immediately rather than return an error.
Bjorn
--
PATCH 1/6 PNP: fix up after Lindent
More manual fixups after Lindent. No functional change.
drivers/pnp/card.c +8 -8
@@ -25,13 +25,13 @@int found;struct pnp_dev *dev; -if (i ==PNP_MAX_DEVICES - || !*drv_id->devs[i].id) +if (i ==PNP_MAX_DEVICES || + !*drv_id->devs[i].id)return drv_id; found =0 ;card_for_each_dev (card, dev) { -if (compare_pnp_id - (dev->id, drv_id->devs[i].id)) { +if (compare_pnp_id (dev->id, + drv_id->devs[i].id)) { found =1 ;break ; }
@@ -183,7 +183,7 @@return 0 ; - err_name: +err_name:device_remove_file (&card->dev, &dev_attr_name);return rc; }
@@ -321,10 +321,10 @@ pos = pos->next; } - done: +done:return NULL ; - found: +found: dev->card_link = clink; dev->dev.driver = &drv->link.driver;if (pnp_bus_type.probe (&dev->dev))
@@ -334,7 +334,7 @@return dev; - err_out: +err_out: dev->dev.driver =NULL ; dev->card_link =NULL ;return NULL ;
drivers/pnp/driver.c +1 -1
@@ -118,7 +118,7 @@ goto fail;return error; - fail: +fail:pnp_device_detach (pnp_dev);return error; }
drivers/pnp/interface.c +5 -4
@@ -459,7 +459,8 @@up (&pnp_res_mutex); goto done; } - done: + +done:if (retval <0 )return retval;return count;
@@ -499,10 +500,10 @@return 0 ; - err_res: +err_res:device_remove_file (&dev->dev, &dev_attr_resources); - err_opt: +err_opt:device_remove_file (&dev->dev, &dev_attr_options); - err: +err:return rc; }
drivers/pnp/isapnp/core.c +6 -9
@@ -335,7 +335,7 @@ }else if (iteration >1 ) {break ; } - __next: +__next:if (csn ==255 )break ; checksum =0x6a ;
@@ -733,7 +733,7 @@"isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n" , type, dev->number, card->number); } - __skip: +__skip:if (size >0 )isapnp_skip_bytes (size); }
@@ -788,7 +788,7 @@"isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n" , type, card->number); } - __skip: +__skip:if (size >0 )isapnp_skip_bytes (size); }
@@ -940,9 +940,6 @@EXPORT_SYMBOL (isapnp_present);EXPORT_SYMBOL (isapnp_cfg_begin);EXPORT_SYMBOL (isapnp_cfg_end); -#if 0 -EXPORT_SYMBOL (isapnp_read_byte); -#endif EXPORT_SYMBOL (isapnp_write_byte); static int isapnp_read_resources(struct pnp_dev *dev,
@@ -993,6 +990,7 @@ struct pnp_resource_table *res) {int ret; +pnp_init_resource_table (res);isapnp_cfg_begin (dev->card->number, dev->number); ret =isapnp_read_resources (dev, res);
@@ -1148,13 +1146,12 @@ } } } -if (cards) { +if (cards)printk (KERN_INFO "isapnp: %i Plug & Play card%s detected total\n" , cards, cards >1 ?"s" :"" ); - }else { +else printk (KERN_INFO "isapnp: No Plug & Play card found\n" ); - }isapnp_proc_init ();return 0 ;
drivers/pnp/manager.c +2 -2
@@ -390,7 +390,7 @@up (&pnp_res_mutex);return 1 ; - fail: +fail:pnp_clean_resource_table (&dev->res);up (&pnp_res_mutex);return 0 ;
@@ -444,7 +444,7 @@kfree (bak);return 0 ; - fail: +fail: dev->res = *bak;up (&pnp_res_mutex);kfree (bak);
drivers/pnp/pnpacpi/core.c +2 -2
@@ -248,9 +248,9 @@ num++;return AE_OK ; - err1: +err1:kfree (dev_id); - err: +err:kfree (dev);return -EINVAL ; }
drivers/pnp/pnpbios/proc.c +1 -1
@@ -212,7 +212,7 @@ goto out; } ret = count; - out: +out:kfree (node);return ret; }
drivers/pnp/pnpbios/rsparser.c +5 -4
@@ -238,7 +238,7 @@break ;default :/* an unkown tag */ - len_err: +len_err:printk (KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n" , tag, len);
@@ -298,6 +298,7 @@ struct pnp_option *option) {struct pnp_mem *mem; + mem =kzalloc (sizeof (struct pnp_mem ),GFP_KERNEL );if (!mem)return ;
@@ -468,7 +469,7 @@return p +2 ;default :/* an unkown tag */ - len_err: +len_err:printk (KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n" , tag, len);
@@ -562,7 +563,7 @@break ;default :/* an unkown tag */ - len_err: +len_err:printk (KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n" , tag, len);
@@ -756,7 +757,7 @@break ;default :/* an unkown tag */ - len_err: +len_err:printk (KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n" , tag, len);
drivers/pnp/pnpacpi/rsparser.c +1 -0
@@ -35,6 +35,7 @@static int irq_flags (int triggering,int polarity) {int flag; +if (triggering ==ACPI_LEVEL_SENSITIVE ) {if (polarity ==ACPI_ACTIVE_LOW ) flag =IORESOURCE_IRQ_LOWLEVEL ;
drivers/pnp/pnpbios/core.c +1 -0
@@ -591,6 +591,7 @@static int __init pnpbios_thread_init (void ) {struct task_struct *task; +#if defined(CONFIG_PPC_MERGE )if (check_legacy_ioport (PNPBIOS_BASE ))return 0 ;
--
PATCH 4/6 ISAPNP: removed unused isapnp_detected and ISAPNP_DEBUG
In reply to Bjorn HelgaasISAPNP_DEBUG isn't used at all. isapnp_detected is set but never read. So remove them both.
drivers/pnp/isapnp/core.c +0 -7
@@ -47,9 +47,6 @@#if 0 #define ISAPNP_REGION_OK #endif -#if 0 -#define ISAPNP_DEBUG -#endif int isapnp_disable;/* Disable ISA PnP */ static int isapnp_rdp;/* Read Data Port */
@@ -93,7 +90,6 @@static unsigned char isapnp_checksum_value;static DEFINE_MUTEX (isapnp_cfg_mutex); -static int isapnp_detected;static int isapnp_csn_count;/* some prototypes */
@@ -1067,7 +1063,6 @@struct pnp_dev *dev;if (isapnp_disable) { - isapnp_detected =0 ;printk (KERN_INFO "isapnp: ISA Plug & Play support disabled\n" );return 0 ; }
@@ -1115,7 +1110,6 @@ }isapnp_set_rdp (); } - isapnp_detected =1 ;if (isapnp_rdp <0x203 || isapnp_rdp >0x3ff ) { cards =isapnp_isolate ();if (cards <0 || (isapnp_rdp <0x203 || isapnp_rdp >0x3ff )) {
@@ -1123,7 +1117,6 @@release_region (_PIDXR,1 );#endif release_region (_PNPWRP,1 ); - isapnp_detected =0 ;printk (KERN_INFO "isapnp: No Plug & Play device found\n" );return 0 ;
--
Len Brown
reviewerQuoted 6 lines · Bjorn Helgaas
Fix a few more Lindent things and remove some unused code and unnecessary casts.
The last patch removes some null pointer checks in cases where I think it's better to just oops immediately rather than return an error.
These look fine to me.
Unless somebody objects, I'll send them up via my tree.
thanks,
-Len