macintosh: no need to initilise statics to 0
PATCH 1/1 macintosh: no need to initilise statics to 0
Global static variables dont need to be initialised to 0. Because the compiler will initilise them.
--- drivers/macintosh/mediabay.c | 10 ++--- drivers/macintosh/via-pmu.c | 78 ++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 44 deletions(-)
drivers/macintosh/mediabay.c +5 -5
@@ -70,7 +70,7 @@ struct media_bay_info {#define MAX_BAYS 2static struct media_bay_info media_bays[MAX_BAYS ]; -static int media_bay_count =0 ; +static int media_bay_count;/* * Wait that number of ms between each step in normal polling mode
@@ -129,7 +129,7 @@ enum {/* * Functions for polling content of media bay */ - +static u8 ohare_mb_content (struct media_bay_info *bay) {
@@ -336,7 +336,7 @@ static inline void set_mb_power(struct media_bay_info* bay, int onoff) bay->ops->power (bay,1 ); bay->state = mb_powering_up;pr_debug ("mediabay%d: powering up\n" , bay->index); - }else { + }else {/* Make sure everything is powered down & disabled */ bay->ops->power (bay,0 ); bay->state = mb_powering_down;
@@ -577,7 +577,7 @@ static int media_bay_attach(struct macio_dev *mdev,macio_release_resources (mdev);return -ENOMEM ; } - + i = media_bay_count++; bay = &media_bays[i]; bay->mdev = mdev;
@@ -745,7 +745,7 @@ static int __init media_bay_init(void)if (!machine_is (powermac))return 0 ; -macio_register_driver (&media_bay_driver); +macio_register_driver (&media_bay_driver);return 0 ; }
drivers/macintosh/via-pmu.c +39 -39
284 lines not on this page · raw message
Signature · 1 line
2.32.0
Le 17/08/2021 à 13:51, Jason Wang a écrit :
Quoted 2 lines
Global static variables dont need to be initialised to 0. Because the compiler will initilise them.
It is not the compiler, it is the Kernel. It is done here:
https://elixir.bootlin.com/linux/v5.14-rc6/source/arch/powerpc/kernel/early_32.c
Quoted 6 lines
Signed-off-by Jason Wang <[email protected]>--- drivers/macintosh/mediabay.c | 10 ++--- drivers/macintosh/via-pmu.c | 78 ++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 44 deletions(-)
Among those 44 changes, only 2 are related to the commit's description.
Quoted 15 lines
drivers/macintosh/mediabay.c +1
-1@@ -70,7 +70,7 @@ struct media_bay_info {#define MAX_BAYS 2static struct media_bay_info media_bays[MAX_BAYS ]; -static int media_bay_count =0 ; +static int media_bay_count;/* * Wait that number of ms between each step in normal polling mode
drivers/macintosh/mediabay.c enum { · line 132
Quoted 5 lines
drivers/macintosh/mediabay.c +1
-1@@ -129,7 +129,7 @@ enum {/* * Functions for polling content of media bay */ - +
What is that change ? Unrelated.
drivers/macintosh/mediabay.c static inline void set_mb_power(struct media_bay_info* bay, int onoff) · line 339
Quoted 9 lines
drivers/macintosh/mediabay.c +1
-1static u8 ohare_mb_content (struct media_bay_info *bay) {@@ -336,7 +336,7 @@ static inline void set_mb_power(struct media_bay_info* bay, int onoff) bay->ops->power (bay,1 ); bay->state = mb_powering_up;pr_debug ("mediabay%d: powering up\n" , bay->index); - }else { + }else {
What is that change ? Unrelated.
drivers/macintosh/mediabay.c static int media_bay_attach(struct macio_dev *mdev, · line 580
Quoted 9 lines
drivers/macintosh/mediabay.c +1
-1/* Make sure everything is powered down & disabled */ bay->ops->power (bay,0 ); bay->state = mb_powering_down;@@ -577,7 +577,7 @@ static int media_bay_attach(struct macio_dev *mdev,macio_release_resources (mdev);return -ENOMEM ; } - +
What is that change ? Unrelated.
drivers/macintosh/mediabay.c static int __init media_bay_init(void) · line 748
Quoted 9 lines
drivers/macintosh/mediabay.c +1
-1i = media_bay_count++; bay = &media_bays[i]; bay->mdev = mdev;@@ -745,7 +745,7 @@ static int __init media_bay_init(void)if (!machine_is (powermac))return 0 ; -macio_register_driver (&media_bay_driver); +macio_register_driver (&media_bay_driver);
What is that change ? Unrelated.
Quoted 17 lines
drivers/macintosh/mediabay.c +0
-0return 0 ; }drivers/macintosh/via-pmu.c +1
-1@@ -158,7 +158,7 @@ static struct device_node *vias;static struct device_node *gpio_node;#endif static unsigned char __iomem *gpio_reg; -static int gpio_irq =0 ; +static int gpio_irq;static int gpio_irq_enabled =-1 ;static volatile int pmu_suspended;static spinlock_t pmu_lock;
drivers/macintosh/via-pmu.c int __init find_via_pmu(void) · line 316
Quoted 5 lines
drivers/macintosh/via-pmu.c +1
-1@@ -313,7 +313,7 @@ int __init find_via_pmu(void)PMU_INT_SNDBRT |PMU_INT_ADB |PMU_INT_TICK ; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c int __init find_via_pmu(void) · line 339
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (of_node_name_eq (vias->parent,"ohare" ) ||of_device_is_compatible (vias->parent,"ohare" )) pmu_kind =PMU_OHARE_BASED ;@@ -336,7 +336,7 @@ int __init find_via_pmu(void)PMU_INT_ADB |PMU_INT_TICK |PMU_INT_ENVIRONMENT ; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c int __init find_via_pmu(void) · line 361
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1gpiop =of_find_node_by_name (NULL ,"gpio" );if (gpiop) { reg =of_get_property (gpiop,"reg" ,NULL );@@ -358,7 +358,7 @@ int __init find_via_pmu(void)printk (KERN_ERR "via-pmu: Can't map address !\n" ); goto fail_via_remap; } - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c int __init find_via_pmu(void) · line 371
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1out_8 (&via1[IER ],IER_CLR |0x7f );/* disable all intrs */ out_8 (&via1[IFR ],0x7f );/* clear IFR */ @@ -368,7 +368,7 @@ int __init find_via_pmu(void) goto fail_init; sys_ctrler =SYS_CTRLER_PMU ; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c init_pmu(void) · line 626
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1return 1 ; fail_init:@@ -623,7 +623,7 @@ init_pmu(void)pmu_wait_complete (&req);if (req.reply_len >0 ) pmu_version = req.reply[0 ]; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static void pmu_set_server_mode(int server_mode) · line 667
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1/* Read server mode setting */ if (pmu_kind ==PMU_KEYLARGO_BASED ) { pmu_request(&req, NULL, 2, PMU_POWER_EVENTS,@@ -664,11 +664,11 @@ static void pmu_set_server_mode(int server_mode)if (server_mode)pmu_request (&req,NULL ,4 ,PMU_POWER_EVENTS ,PMU_PWR_SET_POWERUP_EVENTS , - req.reply[0 ],PMU_PWR_WAKEUP_AC_INSERT ); + req.reply[0 ],PMU_PWR_WAKEUP_AC_INSERT );
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static void pmu_set_server_mode(int server_mode) · line 671
Quoted 5 lines
drivers/macintosh/via-pmu.c +1
-1else pmu_request (&req,NULL ,4 ,PMU_POWER_EVENTS ,PMU_PWR_CLR_POWERUP_EVENTS , - req.reply[0 ],PMU_PWR_WAKEUP_AC_INSERT ); + req.reply[0 ],PMU_PWR_WAKEUP_AC_INSERT );
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_ohare(struct adb_request* req) · line 688
Quoted 11 lines
drivers/macintosh/via-pmu.c +2
-2pmu_wait_complete (&req); }@@ -684,8 +684,8 @@ done_battery_state_ohare(struct adb_request* req)* 0x01 : AC indicator * 0x02 : charging * 0x04 : battery exist -* 0x08 : -* 0x10 : +* 0x08 : +* 0x10 :
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_ohare(struct adb_request* req) · line 711
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1* 0x20 : full charged * 0x40 : pcharge reset * 0x80 : battery exist @@ -708,7 +708,7 @@ done_battery_state_ohare(struct adb_request* req) pmu_power_flags |=PMU_PWR_AC_PRESENT ; else pmu_power_flags &= ~PMU_PWR_AC_PRESENT; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 774
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (mb ==PMAC_TYPE_COMET ) { vmax_charged =189 ; vmax_charging =213 ;@@ -771,26 +771,26 @@ done_battery_state_smart(struct adb_request* req)/* format: * [0] : format of this structure (known: 3,4,5) * [1] : flags -* +*
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 776
Quoted 3 lines
drivers/macintosh/via-pmu.c +1
-1* format 3 & 4: -* +*
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 781
Quoted 6 lines
drivers/macintosh/via-pmu.c +1
-1* [2] : charge * [3] : max charge * [4] : current * [5] : voltage -* +*
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 783
Quoted 3 lines
drivers/macintosh/via-pmu.c +1
-1* format 5: -* +*
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 789
Quoted 7 lines
drivers/macintosh/via-pmu.c +1
-1* [2][3] : charge * [4][5] : max charge * [6][7] : current * [8][9] : voltage */ - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 793
Quoted 5 lines
drivers/macintosh/via-pmu.c +1
-1unsigned int bat_flags =PMU_BATT_TYPE_SMART ;int amperage;unsigned int capa, max, voltage; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c done_battery_state_smart(struct adb_request* req) · line 801
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (req->reply[1 ] &0x01 ) pmu_power_flags |=PMU_PWR_AC_PRESENT ;else @@ -798,7 +798,7 @@ done_battery_state_smart(struct adb_request* req) capa = max = amperage = voltage =0 ; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static int pmu_irqstats_proc_show(struct seq_file *m, void *v) · line 900
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (req->reply[1 ] &0x04 ) { bat_flags |=PMU_BATT_PRESENT ;switch (req->reply[0 ]) {@@ -897,7 +897,7 @@ static int pmu_irqstats_proc_show(struct seq_file *m, void *v)static int pmu_battery_proc_show (struct seq_file *m,void *v) {long batnum = (long )m->private; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static ssize_t pmu_options_proc_write(struct file *file, · line 935
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1seq_putc (m,'\n' );seq_printf (m,"flags : %08x\n" , pmu_batteries[batnum].flags);seq_printf (m,"charge : %d\n" , pmu_batteries[batnum].charge);@@ -932,7 +932,7 @@ static ssize_t pmu_options_proc_write(struct file *file,char tmp[33 ];char *label, *val;size_t fcount = count; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_suspend(void) · line 1307
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (!count)return -EINVAL ;if (count >32 )@@ -1304,7 +1304,7 @@ pmu_suspend(void)if (pmu_state == uninitialized)return ; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_handle_data(unsigned char *data, int len) · line 1433
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1spin_lock_irqsave (&pmu_lock, flags); pmu_suspended++;if (pmu_suspended >1 ) {@@ -1430,7 +1430,7 @@ pmu_handle_data(unsigned char *data, int len) && data[1] == 0x2c && data[3] == 0xff && (data[2] & ~1) == 0xf4))adb_input (data+1 , len-1 ,1 ); -#endif /* CONFIG_ADB */ +#endif /* CONFIG_ADB */
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_sr_intr(void) · line 1557
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1}break ;@@ -1554,7 +1554,7 @@ pmu_sr_intr(void) interrupt_data_len[int_data_last] = data_len; }else { req = current_req; -/* +/*
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c via_pmu_interrupt(int irq, void *arg) · line 1592
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1* For PMU sleep and freq change requests, we lock the * PMU until it's explicitly unlocked. This avoids any * spurrious event polling getting in @@ -1589,7 +1589,7 @@ via_pmu_interrupt(int irq, void *arg)/* This is a bit brutal, we can probably do better */ spin_lock_irqsave (&pmu_lock, flags); ++disable_poll; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c via_pmu_interrupt(int irq, void *arg) · line 1656
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1for (;;) {/* On 68k Macs, VIA interrupts are dispatched individually. * Unless we are polling, the relevant IRQ flag has already @@ -1653,7 +1653,7 @@ via_pmu_interrupt(int irq, void *arg) }else if (current_req)pmu_start (); } -no_free_slot: +no_free_slot:
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c via_pmu_interrupt(int irq, void *arg) · line 1673
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1/* Mark the oldest buffer for flushing */ if (int_data_state[!int_data_last] == int_data_ready) { int_data_state[!int_data_last] = int_data_flush;@@ -1670,7 +1670,7 @@ via_pmu_interrupt(int irq, void *arg)pmu_done (req); req =NULL ; } - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_restart(void) · line 1779
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1/* Deal with interrupt datas outside of the lock */ if (int_data >=0 ) {pmu_handle_data (interrupt_data[int_data], interrupt_data_len[int_data]);@@ -1776,7 +1776,7 @@ pmu_restart(void)local_irq_disable (); drop_interrupts =1 ; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_present(void) · line 1833
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (pmu_kind !=PMU_KEYLARGO_BASED ) {pmu_request (&req,NULL ,2 ,PMU_SET_INTR_MASK ,PMU_INT_ADB |PMU_INT_TICK );@@ -1830,7 +1830,7 @@ pmu_present(void)/* * Put the powerbook to sleep. */ - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static int powerbook_sleep_grackle(void) · line 1904
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1static u32 save_via[8 ];static int __fake_sleep;@@ -1901,7 +1901,7 @@ static int powerbook_sleep_grackle(void)pci_read_config_word (grackle,0x70 , &pmcr1);/* Apparently, MacOS uses NAP mode for Grackle ??? */ - pmcr1 &= ~(GRACKLE_DOZE |GRACKLE_SLEEP ); + pmcr1 &= ~(GRACKLE_DOZE |GRACKLE_SLEEP );
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static int powerbook_sleep_grackle(void) · line 1916
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1pmcr1 |=GRACKLE_PM |GRACKLE_NAP ;pci_write_config_word (grackle,0x70 , pmcr1);@@ -1913,7 +1913,7 @@ static int powerbook_sleep_grackle(void)/* We're awake again, stop grackle PM */ pci_read_config_word (grackle,0x70 , &pmcr1); - pmcr1 &= ~(GRACKLE_PM |GRACKLE_DOZE |GRACKLE_SLEEP |GRACKLE_NAP ); + pmcr1 &= ~(GRACKLE_PM |GRACKLE_DOZE |GRACKLE_SLEEP |GRACKLE_NAP );
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static int powerbook_sleep_grackle(void) · line 1924
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1pci_write_config_word (grackle,0x70 , pmcr1);pci_dev_put (grackle);@@ -1921,11 +1921,11 @@ static int powerbook_sleep_grackle(void)/* Make sure the PMU is idle */ pmac_call_feature (PMAC_FTR_SLEEP_STATE ,NULL ,0 ,0 );restore_via_state (); - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c static int powerbook_sleep_grackle(void) · line 1928
Quoted 5 lines
drivers/macintosh/via-pmu.c +1
-1/* Restore L2 cache */ if (save_l2cr !=0xffffffff && (save_l2cr &L2CR_L2E ) !=0 )_set_L2CR (save_l2cr); - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c powerbook_sleep_Core99(void) · line 1952
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1/* Restore userland MMU context */ switch_mmu_context (NULL , current->active_mm,NULL );@@ -1949,7 +1949,7 @@ powerbook_sleep_Core99(void)unsigned long save_l2cr;unsigned long save_l3cr;struct adb_request req; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c powerbook_sleep_Core99(void) · line 2017
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (pmac_call_feature (PMAC_FTR_SLEEP_STATE ,NULL ,0 ,-1 ) <0 ) {printk (KERN_ERR "Sleep mode not supported on this machine\n" );return -ENOSYS ;@@ -2014,7 +2014,7 @@ powerbook_sleep_Core99(void)/* Restore L3 cache */ if (save_l3cr !=0xffffffff && (save_l3cr &L3CR_L3E ) !=0 )_set_L3CR (save_l3cr); - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_open(struct inode *inode, struct file *file) · line 2176
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1/* Restore userland MMU context */ switch_mmu_context (NULL , current->active_mm,NULL );@@ -2173,7 +2173,7 @@ pmu_open(struct inode *inode, struct file *file)return 0 ; } -static ssize_t +static ssize_t
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_read(struct file *file, char __user *buf, · line 2222
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1pmu_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) {@@ -2219,7 +2219,7 @@ pmu_read(struct file *file, char __user *buf,__set_current_state (TASK_RUNNING );remove_wait_queue (&pp->wait, &wait);spin_unlock_irqrestore (&pp->lock, flags); - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c pmu_fpoll(struct file *filp, poll_table *wait) · line 2239
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1return ret; }@@ -2236,7 +2236,7 @@ pmu_fpoll(struct file *filp, poll_table *wait)struct pmu_private *pp = filp->private_data;__poll_t mask =0 ;unsigned long flags; - +
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c device_initcall(pmu_device_init); · line 2503
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1if (!pp)return 0 ;poll_wait (filp, &pp->wait, wait);@@ -2500,7 +2500,7 @@ device_initcall(pmu_device_init);#ifdef DEBUG_SLEEP -static inline void +static inline void
What is that change ? Unrelated.
drivers/macintosh/via-pmu.c polled_handshake(void) · line 2514
Quoted 9 lines
drivers/macintosh/via-pmu.c +1
-1polled_handshake (void) { via2[B ] &= ~TREQ ;eieio ();@@ -2511,7 +2511,7 @@ polled_handshake(void) ; } -static inline void +static inline void
What is that change ? Unrelated.
Quoted 4 lines
drivers/macintosh/via-pmu.c +0
-0polled_send_byte(int x) { via1[ACR ] |=SR_OUT |SR_EXT ;eieio ();
Quoted 9 lines · Christophe Leroy
Le 17/08/2021 à 13:51, Jason Wang a écrit :
Quoted 2 lines
Global static variables dont need to be initialised to 0. Because the compiler will initilise them.
It is not the compiler, it is the Kernel. It is done here:
https://elixir.bootlin.com/linux/v5.14-rc6/source/arch/powerpc/kernel/early_32.c
This implements part of the C language: everything with static storage duration (which includes all global objects, not just those marked "static") is initialized.
Quoted 1 line
Among those 44 changes, only 2 are related to the commit's description.
Yeah. Don't do that please :-/
Segher
Quoted 8 lines · Christophe Leroy
Le 17/08/2021 à 13:51, Jason Wang a écrit :
Quoted 2 lines
Global static variables dont need to be initialised to 0. Because the compiler will initilise them.
It is not the compiler, it is the Kernel. It is done here:
https://elixir.bootlin.com/linux/v5.14-rc6/source/arch/powerpc/kernel/early_32.c
I don't know why that's done generally.
From memory, it's also required by the c spec unless it's for a union where the first union member is smaller in size than other members.