diff --git a/[refs] b/[refs] index 656fdde14eac..8d418ae27eb8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c5617b200ac52e35f7e8cf05a17b0a2d50f6b3e9 +refs/heads/master: 4ec37de89d8c758ee8115e0e64b3f994910789ee diff --git a/trunk/Documentation/hwmon/dme1737 b/trunk/Documentation/hwmon/dme1737 index fc5df7654d63..001d2e70bc11 100644 --- a/trunk/Documentation/hwmon/dme1737 +++ b/trunk/Documentation/hwmon/dme1737 @@ -9,15 +9,11 @@ Supported chips: * SMSC SCH3112, SCH3114, SCH3116 Prefix: 'sch311x' Addresses scanned: none, address read from Super-I/O config space - Datasheet: Available on the Internet + Datasheet: http://www.nuhorizons.com/FeaturedProducts/Volume1/SMSC/311x.pdf * SMSC SCH5027 Prefix: 'sch5027' Addresses scanned: I2C 0x2c, 0x2d, 0x2e Datasheet: Provided by SMSC upon request and under NDA - * SMSC SCH5127 - Prefix: 'sch5127' - Addresses scanned: none, address read from Super-I/O config space - Datasheet: Provided by SMSC upon request and under NDA Authors: Juerg Haefliger @@ -40,8 +36,8 @@ Description ----------- This driver implements support for the hardware monitoring capabilities of the -SMSC DME1737 and Asus A8000 (which are the same), SMSC SCH5027, SCH311x, -and SCH5127 Super-I/O chips. These chips feature monitoring of 3 temp sensors +SMSC DME1737 and Asus A8000 (which are the same), SMSC SCH5027, and SMSC +SCH311x Super-I/O chips. These chips feature monitoring of 3 temp sensors temp[1-3] (2 remote diodes and 1 internal), 7 voltages in[0-6] (6 external and 1 internal) and up to 6 fan speeds fan[1-6]. Additionally, the chips implement up to 5 PWM outputs pwm[1-3,5-6] for controlling fan speeds both manually and @@ -52,14 +48,14 @@ Fan[3-6] and pwm[3,5-6] are optional features and their availability depends on the configuration of the chip. The driver will detect which features are present during initialization and create the sysfs attributes accordingly. -For the SCH311x and SCH5127, fan[1-3] and pwm[1-3] are always present and -fan[4-6] and pwm[5-6] don't exist. +For the SCH311x, fan[1-3] and pwm[1-3] are always present and fan[4-6] and +pwm[5-6] don't exist. The hardware monitoring features of the DME1737, A8000, and SCH5027 are only -accessible via SMBus, while the SCH311x and SCH5127 only provide access via -the ISA bus. The driver will therefore register itself as an I2C client driver -if it detects a DME1737, A8000, or SCH5027 and as a platform driver if it -detects a SCH311x or SCH5127 chip. +accessible via SMBus, while the SCH311x only provides access via the ISA bus. +The driver will therefore register itself as an I2C client driver if it detects +a DME1737, A8000, or SCH5027 and as a platform driver if it detects a SCH311x +chip. Voltage Monitoring @@ -80,7 +76,7 @@ DME1737, A8000: in6: Vbat (+3.0V) 0V - 4.38V SCH311x: - in0: +2.5V 0V - 3.32V + in0: +2.5V 0V - 6.64V in1: Vccp (processor core) 0V - 2V in2: VCC (internal +3.3V) 0V - 4.38V in3: +5V 0V - 6.64V @@ -97,15 +93,6 @@ SCH5027: in5: VTR (+3.3V standby) 0V - 4.38V in6: Vbat (+3.0V) 0V - 4.38V -SCH5127: - in0: +2.5 0V - 3.32V - in1: Vccp (processor core) 0V - 3V - in2: VCC (internal +3.3V) 0V - 4.38V - in3: V2_IN 0V - 1.5V - in4: V1_IN 0V - 1.5V - in5: VTR (+3.3V standby) 0V - 4.38V - in6: Vbat (+3.0V) 0V - 4.38V - Each voltage input has associated min and max limits which trigger an alarm when crossed. @@ -306,21 +293,3 @@ pwm[1-3]_auto_point1_pwm RW Auto PWM pwm point. Auto_point1 is the pwm[1-3]_auto_point2_pwm RO Auto PWM pwm point. Auto_point2 is the full-speed duty-cycle which is hard- wired to 255 (100% duty-cycle). - -Chip Differences ----------------- - -Feature dme1737 sch311x sch5027 sch5127 -------------------------------------------------------- -temp[1-3]_offset yes yes -vid yes -zone3 yes yes yes -zone[1-3]_hyst yes yes -pwm min/off yes yes -fan3 opt yes opt yes -pwm3 opt yes opt yes -fan4 opt opt -fan5 opt opt -pwm5 opt opt -fan6 opt opt -pwm6 opt opt diff --git a/trunk/Documentation/hwmon/lm63 b/trunk/Documentation/hwmon/lm63 index b9843eab1afb..31660bf97979 100644 --- a/trunk/Documentation/hwmon/lm63 +++ b/trunk/Documentation/hwmon/lm63 @@ -7,11 +7,6 @@ Supported chips: Addresses scanned: I2C 0x4c Datasheet: Publicly available at the National Semiconductor website http://www.national.com/pf/LM/LM63.html - * National Semiconductor LM64 - Prefix: 'lm64' - Addresses scanned: I2C 0x18 and 0x4e - Datasheet: Publicly available at the National Semiconductor website - http://www.national.com/pf/LM/LM64.html Author: Jean Delvare @@ -60,5 +55,3 @@ The lm63 driver will not update its values more frequently than every second; reading them more often will do no harm, but will return 'old' values. -The LM64 is effectively an LM63 with GPIO lines. The driver does not -support these GPIO lines at present. diff --git a/trunk/Documentation/hwmon/ltc4245 b/trunk/Documentation/hwmon/ltc4245 index 86b5880d8502..02838a47d862 100644 --- a/trunk/Documentation/hwmon/ltc4245 +++ b/trunk/Documentation/hwmon/ltc4245 @@ -72,7 +72,9 @@ in6_min_alarm 5v output undervoltage alarm in7_min_alarm 3v output undervoltage alarm in8_min_alarm Vee (-12v) output undervoltage alarm -in9_input GPIO voltage data +in9_input GPIO #1 voltage data +in10_input GPIO #2 voltage data +in11_input GPIO #3 voltage data power1_input 12v power usage (mW) power2_input 5v power usage (mW) diff --git a/trunk/Documentation/hwmon/sysfs-interface b/trunk/Documentation/hwmon/sysfs-interface index d4e2917c6f18..3de6b0bcb147 100644 --- a/trunk/Documentation/hwmon/sysfs-interface +++ b/trunk/Documentation/hwmon/sysfs-interface @@ -80,9 +80,9 @@ All entries (except name) are optional, and should only be created in a given driver if the chip has the feature. -********************* -* Global attributes * -********************* +******** +* Name * +******** name The chip name. This should be a short, lowercase string, not containing @@ -91,13 +91,6 @@ name The chip name. I2C devices get this attribute created automatically. RO -update_rate The rate at which the chip will update readings. - Unit: millisecond - RW - Some devices have a variable update rate. This attribute - can be used to change the update rate to the desired - frequency. - ************ * Voltages * diff --git a/trunk/Documentation/hwmon/tmp102 b/trunk/Documentation/hwmon/tmp102 deleted file mode 100644 index 8454a7763122..000000000000 --- a/trunk/Documentation/hwmon/tmp102 +++ /dev/null @@ -1,26 +0,0 @@ -Kernel driver tmp102 -==================== - -Supported chips: - * Texas Instruments TMP102 - Prefix: 'tmp102' - Addresses scanned: none - Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp102.html - -Author: - Steven King - -Description ------------ - -The Texas Instruments TMP102 implements one temperature sensor. Limits can be -set through the Overtemperature Shutdown register and Hysteresis register. The -sensor is accurate to 0.5 degree over the range of -25 to +85 C, and to 1.0 -degree from -40 to +125 C. Resolution of the sensor is 0.0625 degree. The -operating temperature has a minimum of -55 C and a maximum of +150 C. - -The TMP102 has a programmable update rate that can select between 8, 4, 1, and -0.5 Hz. (Currently the driver only supports the default of 4 Hz). - -The driver provides the common sysfs-interface for temperatures (see -Documentation/hwmon/sysfs-interface under Temperatures). diff --git a/trunk/arch/arm/mach-mx3/mach-mx31moboard.c b/trunk/arch/arm/mach-mx3/mach-mx31moboard.c index 62b5e40165df..33a8d35498a7 100644 --- a/trunk/arch/arm/mach-mx3/mach-mx31moboard.c +++ b/trunk/arch/arm/mach-mx3/mach-mx31moboard.c @@ -220,54 +220,11 @@ static struct mc13783_regulator_init_data moboard_regulators[] = { }, }; -static struct mc13783_led_platform_data moboard_led[] = { - { - .id = MC13783_LED_R1, - .name = "coreboard-led-4:red", - .max_current = 2, - }, - { - .id = MC13783_LED_G1, - .name = "coreboard-led-4:green", - .max_current = 2, - }, - { - .id = MC13783_LED_B1, - .name = "coreboard-led-4:blue", - .max_current = 2, - }, - { - .id = MC13783_LED_R2, - .name = "coreboard-led-5:red", - .max_current = 3, - }, - { - .id = MC13783_LED_G2, - .name = "coreboard-led-5:green", - .max_current = 3, - }, - { - .id = MC13783_LED_B2, - .name = "coreboard-led-5:blue", - .max_current = 3, - }, -}; - -static struct mc13783_leds_platform_data moboard_leds = { - .num_leds = ARRAY_SIZE(moboard_led), - .led = moboard_led, - .flags = MC13783_LED_SLEWLIMTC, - .abmode = MC13783_LED_AB_DISABLED, - .tc1_period = MC13783_LED_PERIOD_10MS, - .tc2_period = MC13783_LED_PERIOD_10MS, -}; - static struct mc13783_platform_data moboard_pmic = { .regulators = moboard_regulators, .num_regulators = ARRAY_SIZE(moboard_regulators), - .leds = &moboard_leds, .flags = MC13783_USE_REGULATOR | MC13783_USE_RTC | - MC13783_USE_ADC | MC13783_USE_LED, + MC13783_USE_ADC, }; static struct spi_board_info moboard_spi_board_info[] __initdata = { diff --git a/trunk/arch/arm/mach-orion5x/dns323-setup.c b/trunk/arch/arm/mach-orion5x/dns323-setup.c index fe0de1698edc..685f34a9634b 100644 --- a/trunk/arch/arm/mach-orion5x/dns323-setup.c +++ b/trunk/arch/arm/mach-orion5x/dns323-setup.c @@ -240,23 +240,22 @@ static int __init dns323_read_mac_addr(void) #define ORION_BLINK_HALF_PERIOD 100 /* ms */ -static int dns323_gpio_blink_set(unsigned gpio, int state, +static int dns323_gpio_blink_set(unsigned gpio, unsigned long *delay_on, unsigned long *delay_off) { + static int value = 0; - if (delay_on && delay_off && !*delay_on && !*delay_off) + if (!*delay_on && !*delay_off) *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD; - switch(state) { - case GPIO_LED_NO_BLINK_LOW: - case GPIO_LED_NO_BLINK_HIGH: - orion_gpio_set_blink(gpio, 0); - gpio_set_value(gpio, state); - break; - case GPIO_LED_BLINK: - orion_gpio_set_blink(gpio, 1); + if (ORION_BLINK_HALF_PERIOD == *delay_on + && ORION_BLINK_HALF_PERIOD == *delay_off) { + value = !value; + orion_gpio_set_blink(gpio, value); + return 0; } - return 0; + + return -EINVAL; } static struct gpio_led dns323_leds[] = { @@ -264,7 +263,6 @@ static struct gpio_led dns323_leds[] = { .name = "power:blue", .gpio = DNS323_GPIO_LED_POWER2, .default_trigger = "timer", - .active_low = 1, }, { .name = "right:amber", .gpio = DNS323_GPIO_LED_RIGHT_AMBER, diff --git a/trunk/arch/arm/mach-s3c2440/mach-gta02.c b/trunk/arch/arm/mach-s3c2440/mach-gta02.c index 9e39faa283b9..45799c608d8f 100644 --- a/trunk/arch/arm/mach-s3c2440/mach-gta02.c +++ b/trunk/arch/arm/mach-s3c2440/mach-gta02.c @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -56,7 +57,6 @@ #include #include #include -#include #include #include @@ -254,12 +254,6 @@ static char *gta02_batteries[] = { "battery", }; -static struct pcf50633_bl_platform_data gta02_backlight_data = { - .default_brightness = 0x3f, - .default_brightness_limit = 0, - .ramp_time = 5, -}; - struct pcf50633_platform_data gta02_pcf_pdata = { .resumers = { [0] = PCF50633_INT1_USBINS | @@ -277,8 +271,6 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .charger_reference_current_ma = 1000, - .backlight_data = >a02_backlight_data, - .reg_init_data = { [PCF50633_REGULATOR_AUTO] = { .constraints = { @@ -486,6 +478,71 @@ static struct s3c2410_udc_mach_info gta02_udc_cfg = { }; + + +static void gta02_bl_set_intensity(int intensity) +{ + struct pcf50633 *pcf = gta02_pcf; + int old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); + + /* We map 8-bit intensity to 6-bit intensity in hardware. */ + intensity >>= 2; + + /* + * This can happen during, eg, print of panic on blanked console, + * but we can't service i2c without interrupts active, so abort. + */ + if (in_atomic()) { + printk(KERN_ERR "gta02_bl_set_intensity called while atomic\n"); + return; + } + + old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); + if (intensity == old_intensity) + return; + + /* We can't do this anywhere else. */ + pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 5); + + if (!(pcf50633_reg_read(pcf, PCF50633_REG_LEDENA) & 3)) + old_intensity = 0; + + /* + * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60) + * if seen, you have to re-enable the LED unit. + */ + if (!intensity || !old_intensity) + pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0); + + /* Illegal to set LEDOUT to 0. */ + if (!intensity) + pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, 2); + else + pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, + intensity); + + if (intensity) + pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 2); + +} + +static struct generic_bl_info gta02_bl_info = { + .name = "gta02-bl", + .max_intensity = 0xff, + .default_intensity = 0xff, + .set_bl_intensity = gta02_bl_set_intensity, +}; + +static struct platform_device gta02_bl_dev = { + .name = "generic-bl", + .id = 1, + .dev = { + .platform_data = >a02_bl_info, + }, +}; + + + /* USB */ static struct s3c2410_hcd_info gta02_usb_info __initdata = { .port[0] = { @@ -522,6 +579,7 @@ static struct platform_device *gta02_devices[] __initdata = { /* These guys DO need to be children of PMU. */ static struct platform_device *gta02_devices_pmu_children[] = { + >a02_bl_dev, }; diff --git a/trunk/arch/ia64/kernel/smpboot.c b/trunk/arch/ia64/kernel/smpboot.c index 518e876a410d..6a1380e90f87 100644 --- a/trunk/arch/ia64/kernel/smpboot.c +++ b/trunk/arch/ia64/kernel/smpboot.c @@ -390,11 +390,13 @@ smp_callin (void) fix_b0_for_bsp(); +#ifdef CONFIG_NUMA /* * numa_node_id() works after this. */ set_numa_node(cpu_to_node_map[cpuid]); set_numa_mem(local_memory_node(cpu_to_node_map[cpuid])); +#endif ipi_call_lock_irq(); spin_lock(&vector_lock); @@ -638,7 +640,9 @@ void __devinit smp_prepare_boot_cpu(void) { cpu_set(smp_processor_id(), cpu_online_map); cpu_set(smp_processor_id(), cpu_callin_map); +#ifdef CONFIG_NUMA set_numa_node(cpu_to_node_map[smp_processor_id()]); +#endif per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; paravirt_post_smp_prepare_boot_cpu(); } diff --git a/trunk/arch/ia64/mm/numa.c b/trunk/arch/ia64/mm/numa.c index 3efea7d0a351..2437718bd6b1 100644 --- a/trunk/arch/ia64/mm/numa.c +++ b/trunk/arch/ia64/mm/numa.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,22 @@ paddr_to_nid(unsigned long paddr) return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ? -1 : 0); } +/* + * Return the bit number of a random bit set in the nodemask. + * (returns -1 if nodemask is empty) + */ +int __node_random(const nodemask_t *maskp) +{ + int w, bit = -1; + + w = nodes_weight(*maskp); + if (w) + bit = bitmap_ord_to_pos(maskp->bits, + get_random_int() % w, MAX_NUMNODES); + return bit; +} +EXPORT_SYMBOL(__node_random); + #if defined(CONFIG_SPARSEMEM) && defined(CONFIG_NUMA) /* * Because of holes evaluate on section limits. diff --git a/trunk/arch/sparc/kernel/perf_event.c b/trunk/arch/sparc/kernel/perf_event.c index 0ec92c8861dd..34ce49f80eac 100644 --- a/trunk/arch/sparc/kernel/perf_event.c +++ b/trunk/arch/sparc/kernel/perf_event.c @@ -92,8 +92,6 @@ struct cpu_hw_events { /* Enabled/disable state. */ int enabled; - - unsigned int group_flag; }; DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .enabled = 1, }; @@ -983,6 +981,53 @@ static int collect_events(struct perf_event *group, int max_count, return n; } +static void event_sched_in(struct perf_event *event) +{ + event->state = PERF_EVENT_STATE_ACTIVE; + event->oncpu = smp_processor_id(); + event->tstamp_running += event->ctx->time - event->tstamp_stopped; + if (is_software_event(event)) + event->pmu->enable(event); +} + +int hw_perf_group_sched_in(struct perf_event *group_leader, + struct perf_cpu_context *cpuctx, + struct perf_event_context *ctx) +{ + struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); + struct perf_event *sub; + int n0, n; + + if (!sparc_pmu) + return 0; + + n0 = cpuc->n_events; + n = collect_events(group_leader, perf_max_events - n0, + &cpuc->event[n0], &cpuc->events[n0], + &cpuc->current_idx[n0]); + if (n < 0) + return -EAGAIN; + if (check_excludes(cpuc->event, n0, n)) + return -EINVAL; + if (sparc_check_constraints(cpuc->event, cpuc->events, n + n0)) + return -EAGAIN; + cpuc->n_events = n0 + n; + cpuc->n_added += n; + + cpuctx->active_oncpu += n; + n = 1; + event_sched_in(group_leader); + list_for_each_entry(sub, &group_leader->sibling_list, group_entry) { + if (sub->state != PERF_EVENT_STATE_OFF) { + event_sched_in(sub); + n++; + } + } + ctx->nr_active += n; + + return 1; +} + static int sparc_pmu_enable(struct perf_event *event) { struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); @@ -1000,20 +1045,11 @@ static int sparc_pmu_enable(struct perf_event *event) cpuc->events[n0] = event->hw.event_base; cpuc->current_idx[n0] = PIC_NO_INDEX; - /* - * If group events scheduling transaction was started, - * skip the schedulability test here, it will be peformed - * at commit time(->commit_txn) as a whole - */ - if (cpuc->group_flag & PERF_EVENT_TXN_STARTED) - goto nocheck; - if (check_excludes(cpuc->event, n0, 1)) goto out; if (sparc_check_constraints(cpuc->event, cpuc->events, n0 + 1)) goto out; -nocheck: cpuc->n_events++; cpuc->n_added++; @@ -1093,61 +1129,11 @@ static int __hw_perf_event_init(struct perf_event *event) return 0; } -/* - * Start group events scheduling transaction - * Set the flag to make pmu::enable() not perform the - * schedulability test, it will be performed at commit time - */ -static void sparc_pmu_start_txn(const struct pmu *pmu) -{ - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); - - cpuhw->group_flag |= PERF_EVENT_TXN_STARTED; -} - -/* - * Stop group events scheduling transaction - * Clear the flag and pmu::enable() will perform the - * schedulability test. - */ -static void sparc_pmu_cancel_txn(const struct pmu *pmu) -{ - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); - - cpuhw->group_flag &= ~PERF_EVENT_TXN_STARTED; -} - -/* - * Commit group events scheduling transaction - * Perform the group schedulability test as a whole - * Return 0 if success - */ -static int sparc_pmu_commit_txn(const struct pmu *pmu) -{ - struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); - int n; - - if (!sparc_pmu) - return -EINVAL; - - cpuc = &__get_cpu_var(cpu_hw_events); - n = cpuc->n_events; - if (check_excludes(cpuc->event, 0, n)) - return -EINVAL; - if (sparc_check_constraints(cpuc->event, cpuc->events, n)) - return -EAGAIN; - - return 0; -} - static const struct pmu pmu = { .enable = sparc_pmu_enable, .disable = sparc_pmu_disable, .read = sparc_pmu_read, .unthrottle = sparc_pmu_unthrottle, - .start_txn = sparc_pmu_start_txn, - .cancel_txn = sparc_pmu_cancel_txn, - .commit_txn = sparc_pmu_commit_txn, }; const struct pmu *hw_perf_event_init(struct perf_event *event) diff --git a/trunk/arch/x86/include/asm/perf_event_p4.h b/trunk/arch/x86/include/asm/perf_event_p4.h index 64a8ebff06fc..b05400a542ff 100644 --- a/trunk/arch/x86/include/asm/perf_event_p4.h +++ b/trunk/arch/x86/include/asm/perf_event_p4.h @@ -89,8 +89,7 @@ P4_CCCR_ENABLE) /* HT mask */ -#define P4_CCCR_MASK_HT \ - (P4_CCCR_MASK | P4_CCCR_OVF_PMI_T1 | P4_CCCR_THREAD_ANY) +#define P4_CCCR_MASK_HT (P4_CCCR_MASK | P4_CCCR_THREAD_ANY) #define P4_GEN_ESCR_EMASK(class, name, bit) \ class##__##name = ((1 << bit) << P4_ESCR_EVENTMASK_SHIFT) diff --git a/trunk/arch/x86/kernel/cpu/perf_event.c b/trunk/arch/x86/kernel/cpu/perf_event.c index c77586061bcb..fd4db0db3708 100644 --- a/trunk/arch/x86/kernel/cpu/perf_event.c +++ b/trunk/arch/x86/kernel/cpu/perf_event.c @@ -1717,11 +1717,7 @@ void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int ski */ regs->bp = rewind_frame_pointer(skip + 1); regs->cs = __KERNEL_CS; - /* - * We abuse bit 3 to pass exact information, see perf_misc_flags - * and the comment with PERF_EFLAGS_EXACT. - */ - regs->flags = 0; + local_save_flags(regs->flags); } unsigned long perf_instruction_pointer(struct pt_regs *regs) diff --git a/trunk/arch/x86/kernel/cpu/perf_event_p4.c b/trunk/arch/x86/kernel/cpu/perf_event_p4.c index ae85d69644d1..424fc8de68e4 100644 --- a/trunk/arch/x86/kernel/cpu/perf_event_p4.c +++ b/trunk/arch/x86/kernel/cpu/perf_event_p4.c @@ -465,21 +465,15 @@ static int p4_hw_config(struct perf_event *event) return rc; } -static inline int p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc) +static inline void p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc) { - int overflow = 0; - u32 low, high; + unsigned long dummy; - rdmsr(hwc->config_base + hwc->idx, low, high); - - /* we need to check high bit for unflagged overflows */ - if ((low & P4_CCCR_OVF) || !(high & (1 << 31))) { - overflow = 1; + rdmsrl(hwc->config_base + hwc->idx, dummy); + if (dummy & P4_CCCR_OVF) { (void)checking_wrmsrl(hwc->config_base + hwc->idx, - ((u64)low) & ~P4_CCCR_OVF); + ((u64)dummy) & ~P4_CCCR_OVF); } - - return overflow; } static inline void p4_pmu_disable_event(struct perf_event *event) @@ -590,15 +584,21 @@ static int p4_pmu_handle_irq(struct pt_regs *regs) WARN_ON_ONCE(hwc->idx != idx); - /* it might be unflagged overflow */ - handled = p4_pmu_clear_cccr_ovf(hwc); + /* + * FIXME: Redundant call, actually not needed + * but just to check if we're screwed + */ + p4_pmu_clear_cccr_ovf(hwc); val = x86_perf_event_update(event); - if (!handled && (val & (1ULL << (x86_pmu.cntval_bits - 1)))) + if (val & (1ULL << (x86_pmu.cntval_bits - 1))) continue; - /* event overflow for sure */ - data.period = event->hw.last_period; + /* + * event overflow + */ + handled = 1; + data.period = event->hw.last_period; if (!x86_perf_event_set_period(event)) continue; @@ -670,7 +670,7 @@ static void p4_pmu_swap_config_ts(struct hw_perf_event *hwc, int cpu) /* * ESCR address hashing is tricky, ESCRs are not sequential - * in memory but all starts from MSR_P4_BSU_ESCR0 (0x03a0) and + * in memory but all starts from MSR_P4_BSU_ESCR0 (0x03e0) and * the metric between any ESCRs is laid in range [0xa0,0xe1] * * so we make ~70% filled hashtable @@ -735,9 +735,8 @@ static int p4_get_escr_idx(unsigned int addr) { unsigned int idx = P4_ESCR_MSR_IDX(addr); - if (unlikely(idx >= P4_ESCR_MSR_TABLE_SIZE || - !p4_escr_table[idx] || - p4_escr_table[idx] != addr)) { + if (unlikely(idx >= P4_ESCR_MSR_TABLE_SIZE || + !p4_escr_table[idx])) { WARN_ONCE(1, "P4 PMU: Wrong address passed: %x\n", addr); return -1; } @@ -763,7 +762,7 @@ static int p4_pmu_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign { unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; unsigned long escr_mask[BITS_TO_LONGS(P4_ESCR_MSR_TABLE_SIZE)]; - int cpu = smp_processor_id(); + int cpu = raw_smp_processor_id(); struct hw_perf_event *hwc; struct p4_event_bind *bind; unsigned int i, thread, num; diff --git a/trunk/arch/x86/mm/pf_in.c b/trunk/arch/x86/mm/pf_in.c index 308e32570d84..df3d5c861cda 100644 --- a/trunk/arch/x86/mm/pf_in.c +++ b/trunk/arch/x86/mm/pf_in.c @@ -34,7 +34,7 @@ /* IA32 Manual 3, 2-1 */ static unsigned char prefix_codes[] = { 0xF0, 0xF2, 0xF3, 0x2E, 0x36, 0x3E, 0x26, 0x64, - 0x65, 0x66, 0x67 + 0x65, 0x2E, 0x3E, 0x66, 0x67 }; /* IA32 Manual 3, 3-432*/ static unsigned int reg_rop[] = { diff --git a/trunk/drivers/acpi/osl.c b/trunk/drivers/acpi/osl.c index 78418ce4fc78..4bc1c4178f50 100644 --- a/trunk/drivers/acpi/osl.c +++ b/trunk/drivers/acpi/osl.c @@ -1206,15 +1206,6 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n, } EXPORT_SYMBOL(acpi_check_mem_region); -/* - * Let drivers know whether the resource checks are effective - */ -int acpi_resources_are_enforced(void) -{ - return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT; -} -EXPORT_SYMBOL(acpi_resources_are_enforced); - /* * Acquire a spinlock. * diff --git a/trunk/drivers/hwmon/Kconfig b/trunk/drivers/hwmon/Kconfig index e19cf8eb6ccf..6a9ac754ca5d 100644 --- a/trunk/drivers/hwmon/Kconfig +++ b/trunk/drivers/hwmon/Kconfig @@ -447,14 +447,13 @@ config SENSORS_IT87 will be called it87. config SENSORS_LM63 - tristate "National Semiconductor LM63 and LM64" + tristate "National Semiconductor LM63" depends on I2C help - If you say yes here you get support for the National - Semiconductor LM63 and LM64 remote diode digital temperature - sensors with integrated fan control. Such chips are found - on the Tyan S4882 (Thunder K8QS Pro) motherboard, among - others. + If you say yes here you get support for the National Semiconductor + LM63 remote diode digital temperature sensor with integrated fan + control. Such chips are found on the Tyan S4882 (Thunder K8QS Pro) + motherboard, among others. This driver can also be built as a module. If so, the module will be called lm63. @@ -493,8 +492,7 @@ config SENSORS_LM75 - NXP's LM75A - ST Microelectronics STDS75 - TelCom (now Microchip) TCN75 - - Texas Instruments TMP100, TMP101, TMP105, TMP75, TMP175, - TMP275 + - Texas Instruments TMP100, TMP101, TMP75, TMP175, TMP275 This driver supports driver model based binding through board specific I2C device tables. @@ -751,16 +749,6 @@ config SENSORS_DME1737 This driver can also be built as a module. If so, the module will be called dme1737. -config SENSORS_EMC1403 - tristate "SMSC EMC1403 thermal sensor" - depends on I2C - help - If you say yes here you get support for the SMSC EMC1403 - temperature monitoring chip. - - Threshold values can be configured using sysfs. - Data from the different diodes are accessible via sysfs. - config SENSORS_SMSC47M1 tristate "SMSC LPC47M10x and compatibles" help @@ -843,16 +831,6 @@ config SENSORS_THMC50 This driver can also be built as a module. If so, the module will be called thmc50. -config SENSORS_TMP102 - tristate "Texas Instruments TMP102" - depends on I2C && EXPERIMENTAL - help - If you say yes here you get support for Texas Instruments TMP102 - sensor chips. - - This driver can also be built as a module. If so, the module - will be called tmp102. - config SENSORS_TMP401 tristate "Texas Instruments TMP401 and compatibles" depends on I2C && EXPERIMENTAL diff --git a/trunk/drivers/hwmon/Makefile b/trunk/drivers/hwmon/Makefile index 2138ceb1a713..86920fb34118 100644 --- a/trunk/drivers/hwmon/Makefile +++ b/trunk/drivers/hwmon/Makefile @@ -41,7 +41,6 @@ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o obj-$(CONFIG_SENSORS_DME1737) += dme1737.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o -obj-$(CONFIG_SENSORS_EMC1403) += emc1403.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o obj-$(CONFIG_SENSORS_F71882FG) += f71882fg.o obj-$(CONFIG_SENSORS_F75375S) += f75375s.o @@ -91,7 +90,6 @@ obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o obj-$(CONFIG_SENSORS_AMC6821) += amc6821.o obj-$(CONFIG_SENSORS_THMC50) += thmc50.o -obj-$(CONFIG_SENSORS_TMP102) += tmp102.o obj-$(CONFIG_SENSORS_TMP401) += tmp401.o obj-$(CONFIG_SENSORS_TMP421) += tmp421.o obj-$(CONFIG_SENSORS_VIA_CPUTEMP)+= via-cputemp.o diff --git a/trunk/drivers/hwmon/adm1031.c b/trunk/drivers/hwmon/adm1031.c index 15c1a9616af3..1644b92e7cc4 100644 --- a/trunk/drivers/hwmon/adm1031.c +++ b/trunk/drivers/hwmon/adm1031.c @@ -36,7 +36,6 @@ #define ADM1031_REG_FAN_DIV(nr) (0x20 + (nr)) #define ADM1031_REG_PWM (0x22) #define ADM1031_REG_FAN_MIN(nr) (0x10 + (nr)) -#define ADM1031_REG_FAN_FILTER (0x23) #define ADM1031_REG_TEMP_OFFSET(nr) (0x0d + (nr)) #define ADM1031_REG_TEMP_MAX(nr) (0x14 + 4 * (nr)) @@ -62,9 +61,6 @@ #define ADM1031_CONF2_TACH2_ENABLE 0x08 #define ADM1031_CONF2_TEMP_ENABLE(chan) (0x10 << (chan)) -#define ADM1031_UPDATE_RATE_MASK 0x1c -#define ADM1031_UPDATE_RATE_SHIFT 2 - /* Addresses to scan */ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; @@ -79,7 +75,6 @@ struct adm1031_data { int chip_type; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ - unsigned int update_rate; /* In milliseconds */ /* The chan_select_table contains the possible configurations for * auto fan control. */ @@ -743,57 +738,6 @@ static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 12); static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13); static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); -/* Update Rate */ -static const unsigned int update_rates[] = { - 16000, 8000, 4000, 2000, 1000, 500, 250, 125, -}; - -static ssize_t show_update_rate(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct adm1031_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%u\n", data->update_rate); -} - -static ssize_t set_update_rate(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct adm1031_data *data = i2c_get_clientdata(client); - unsigned long val; - int i, err; - u8 reg; - - err = strict_strtoul(buf, 10, &val); - if (err) - return err; - - /* find the nearest update rate from the table */ - for (i = 0; i < ARRAY_SIZE(update_rates) - 1; i++) { - if (val >= update_rates[i]) - break; - } - /* if not found, we point to the last entry (lowest update rate) */ - - /* set the new update rate while preserving other settings */ - reg = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); - reg &= ~ADM1031_UPDATE_RATE_MASK; - reg |= i << ADM1031_UPDATE_RATE_SHIFT; - adm1031_write_value(client, ADM1031_REG_FAN_FILTER, reg); - - mutex_lock(&data->update_lock); - data->update_rate = update_rates[i]; - mutex_unlock(&data->update_lock); - - return count; -} - -static DEVICE_ATTR(update_rate, S_IRUGO | S_IWUSR, show_update_rate, - set_update_rate); - static struct attribute *adm1031_attributes[] = { &sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_fan1_div.dev_attr.attr, @@ -830,7 +774,6 @@ static struct attribute *adm1031_attributes[] = { &sensor_dev_attr_auto_fan1_min_pwm.dev_attr.attr, - &dev_attr_update_rate.attr, &dev_attr_alarms.attr, NULL @@ -957,7 +900,6 @@ static void adm1031_init_client(struct i2c_client *client) { unsigned int read_val; unsigned int mask; - int i; struct adm1031_data *data = i2c_get_clientdata(client); mask = (ADM1031_CONF2_PWM1_ENABLE | ADM1031_CONF2_TACH1_ENABLE); @@ -977,24 +919,18 @@ static void adm1031_init_client(struct i2c_client *client) ADM1031_CONF1_MONITOR_ENABLE); } - /* Read the chip's update rate */ - mask = ADM1031_UPDATE_RATE_MASK; - read_val = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); - i = (read_val & mask) >> ADM1031_UPDATE_RATE_SHIFT; - data->update_rate = update_rates[i]; } static struct adm1031_data *adm1031_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct adm1031_data *data = i2c_get_clientdata(client); - unsigned long next_update; int chan; mutex_lock(&data->update_lock); - next_update = data->last_updated + msecs_to_jiffies(data->update_rate); - if (time_after(jiffies, next_update) || !data->valid) { + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { dev_dbg(&client->dev, "Starting adm1031 update\n"); for (chan = 0; diff --git a/trunk/drivers/hwmon/applesmc.c b/trunk/drivers/hwmon/applesmc.c index b6598aa557a0..f085c18d2905 100644 --- a/trunk/drivers/hwmon/applesmc.c +++ b/trunk/drivers/hwmon/applesmc.c @@ -148,20 +148,6 @@ static const char *temperature_sensors_sets[][41] = { /* Set 18: MacBook Pro 2,2 */ { "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "TM0P", "TTF0", "Th0H", "Th1H", "Tm0P", "Ts0P", NULL }, -/* Set 19: Macbook Pro 5,3 */ - { "TB0T", "TB1T", "TB2T", "TB3T", "TC0D", "TC0F", "TC0P", "TG0D", - "TG0F", "TG0H", "TG0P", "TG0T", "TN0D", "TN0P", "TTF0", "Th2H", - "Tm0P", "Ts0P", "Ts0S", NULL }, -/* Set 20: MacBook Pro 5,4 */ - { "TB0T", "TB1T", "TB2T", "TB3T", "TC0D", "TC0F", "TC0P", "TN0D", - "TN0P", "TTF0", "Th2H", "Ts0P", "Ts0S", NULL }, -/* Set 21: MacBook Pro 6,2 */ - { "TB0T", "TB1T", "TB2T", "TC0C", "TC0D", "TC0P", "TC1C", "TG0D", - "TG0P", "TG0T", "TMCD", "TP0P", "TPCD", "Th1H", "Th2H", "Tm0P", - "Ts0P", "Ts0S", NULL }, -/* Set 22: MacBook Pro 7,1 */ - { "TB0T", "TB1T", "TB2T", "TC0D", "TC0P", "TN0D", "TN0P", "TN0S", - "TN1D", "TN1F", "TN1G", "TN1S", "Th1H", "Ts0P", "Ts0S", NULL }, }; /* List of keys used to read/write fan speeds */ @@ -660,17 +646,6 @@ static ssize_t applesmc_light_show(struct device *dev, return snprintf(sysfsbuf, PAGE_SIZE, "(%d,%d)\n", left, right); } -/* Displays sensor key as label */ -static ssize_t applesmc_show_sensor_label(struct device *dev, - struct device_attribute *devattr, char *sysfsbuf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - const char *key = - temperature_sensors_sets[applesmc_temperature_set][attr->index]; - - return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", key); -} - /* Displays degree Celsius * 1000 */ static ssize_t applesmc_show_temperature(struct device *dev, struct device_attribute *devattr, char *sysfsbuf) @@ -1138,86 +1113,6 @@ static const struct attribute_group fan_attribute_groups[] = { /* * Temperature sensors sysfs entries. */ -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 5); -static SENSOR_DEVICE_ATTR(temp7_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 6); -static SENSOR_DEVICE_ATTR(temp8_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 7); -static SENSOR_DEVICE_ATTR(temp9_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 8); -static SENSOR_DEVICE_ATTR(temp10_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 9); -static SENSOR_DEVICE_ATTR(temp11_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 10); -static SENSOR_DEVICE_ATTR(temp12_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 11); -static SENSOR_DEVICE_ATTR(temp13_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 12); -static SENSOR_DEVICE_ATTR(temp14_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 13); -static SENSOR_DEVICE_ATTR(temp15_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 14); -static SENSOR_DEVICE_ATTR(temp16_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 15); -static SENSOR_DEVICE_ATTR(temp17_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 16); -static SENSOR_DEVICE_ATTR(temp18_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 17); -static SENSOR_DEVICE_ATTR(temp19_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 18); -static SENSOR_DEVICE_ATTR(temp20_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 19); -static SENSOR_DEVICE_ATTR(temp21_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 20); -static SENSOR_DEVICE_ATTR(temp22_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 21); -static SENSOR_DEVICE_ATTR(temp23_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 22); -static SENSOR_DEVICE_ATTR(temp24_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 23); -static SENSOR_DEVICE_ATTR(temp25_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 24); -static SENSOR_DEVICE_ATTR(temp26_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 25); -static SENSOR_DEVICE_ATTR(temp27_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 26); -static SENSOR_DEVICE_ATTR(temp28_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 27); -static SENSOR_DEVICE_ATTR(temp29_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 28); -static SENSOR_DEVICE_ATTR(temp30_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 29); -static SENSOR_DEVICE_ATTR(temp31_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 30); -static SENSOR_DEVICE_ATTR(temp32_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 31); -static SENSOR_DEVICE_ATTR(temp33_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 32); -static SENSOR_DEVICE_ATTR(temp34_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 33); -static SENSOR_DEVICE_ATTR(temp35_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 34); -static SENSOR_DEVICE_ATTR(temp36_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 35); -static SENSOR_DEVICE_ATTR(temp37_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 36); -static SENSOR_DEVICE_ATTR(temp38_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 37); -static SENSOR_DEVICE_ATTR(temp39_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 38); -static SENSOR_DEVICE_ATTR(temp40_label, S_IRUGO, - applesmc_show_sensor_label, NULL, 39); static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, applesmc_show_temperature, NULL, 0); static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, @@ -1299,50 +1194,6 @@ static SENSOR_DEVICE_ATTR(temp39_input, S_IRUGO, static SENSOR_DEVICE_ATTR(temp40_input, S_IRUGO, applesmc_show_temperature, NULL, 39); -static struct attribute *label_attributes[] = { - &sensor_dev_attr_temp1_label.dev_attr.attr, - &sensor_dev_attr_temp2_label.dev_attr.attr, - &sensor_dev_attr_temp3_label.dev_attr.attr, - &sensor_dev_attr_temp4_label.dev_attr.attr, - &sensor_dev_attr_temp5_label.dev_attr.attr, - &sensor_dev_attr_temp6_label.dev_attr.attr, - &sensor_dev_attr_temp7_label.dev_attr.attr, - &sensor_dev_attr_temp8_label.dev_attr.attr, - &sensor_dev_attr_temp9_label.dev_attr.attr, - &sensor_dev_attr_temp10_label.dev_attr.attr, - &sensor_dev_attr_temp11_label.dev_attr.attr, - &sensor_dev_attr_temp12_label.dev_attr.attr, - &sensor_dev_attr_temp13_label.dev_attr.attr, - &sensor_dev_attr_temp14_label.dev_attr.attr, - &sensor_dev_attr_temp15_label.dev_attr.attr, - &sensor_dev_attr_temp16_label.dev_attr.attr, - &sensor_dev_attr_temp17_label.dev_attr.attr, - &sensor_dev_attr_temp18_label.dev_attr.attr, - &sensor_dev_attr_temp19_label.dev_attr.attr, - &sensor_dev_attr_temp20_label.dev_attr.attr, - &sensor_dev_attr_temp21_label.dev_attr.attr, - &sensor_dev_attr_temp22_label.dev_attr.attr, - &sensor_dev_attr_temp23_label.dev_attr.attr, - &sensor_dev_attr_temp24_label.dev_attr.attr, - &sensor_dev_attr_temp25_label.dev_attr.attr, - &sensor_dev_attr_temp26_label.dev_attr.attr, - &sensor_dev_attr_temp27_label.dev_attr.attr, - &sensor_dev_attr_temp28_label.dev_attr.attr, - &sensor_dev_attr_temp29_label.dev_attr.attr, - &sensor_dev_attr_temp30_label.dev_attr.attr, - &sensor_dev_attr_temp31_label.dev_attr.attr, - &sensor_dev_attr_temp32_label.dev_attr.attr, - &sensor_dev_attr_temp33_label.dev_attr.attr, - &sensor_dev_attr_temp34_label.dev_attr.attr, - &sensor_dev_attr_temp35_label.dev_attr.attr, - &sensor_dev_attr_temp36_label.dev_attr.attr, - &sensor_dev_attr_temp37_label.dev_attr.attr, - &sensor_dev_attr_temp38_label.dev_attr.attr, - &sensor_dev_attr_temp39_label.dev_attr.attr, - &sensor_dev_attr_temp40_label.dev_attr.attr, - NULL -}; - static struct attribute *temperature_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp2_input.dev_attr.attr, @@ -1390,10 +1241,6 @@ static struct attribute *temperature_attributes[] = { static const struct attribute_group temperature_attributes_group = { .attrs = temperature_attributes }; -static const struct attribute_group label_attributes_group = { - .attrs = label_attributes -}; - /* Module stuff */ /* @@ -1516,14 +1363,6 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = { { .accelerometer = 0, .light = 0, .temperature_set = 17 }, /* MacBook Pro 2,2: accelerometer, backlight and temperature set 18 */ { .accelerometer = 1, .light = 1, .temperature_set = 18 }, -/* MacBook Pro 5,3: accelerometer, backlight and temperature set 19 */ - { .accelerometer = 1, .light = 1, .temperature_set = 19 }, -/* MacBook Pro 5,4: accelerometer, backlight and temperature set 20 */ - { .accelerometer = 1, .light = 1, .temperature_set = 20 }, -/* MacBook Pro 6,2: accelerometer, backlight and temperature set 21 */ - { .accelerometer = 1, .light = 1, .temperature_set = 21 }, -/* MacBook Pro 7,1: accelerometer, backlight and temperature set 22 */ - { .accelerometer = 1, .light = 1, .temperature_set = 22 }, }; /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". @@ -1537,22 +1376,6 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir") }, &applesmc_dmi_data[7]}, - { applesmc_dmi_match, "Apple MacBook Pro 7", { - DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro7") }, - &applesmc_dmi_data[22]}, - { applesmc_dmi_match, "Apple MacBook Pro 5,4", { - DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5,4") }, - &applesmc_dmi_data[20]}, - { applesmc_dmi_match, "Apple MacBook Pro 5,3", { - DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5,3") }, - &applesmc_dmi_data[19]}, - { applesmc_dmi_match, "Apple MacBook Pro 6", { - DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro6") }, - &applesmc_dmi_data[21]}, { applesmc_dmi_match, "Apple MacBook Pro 5", { DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5") }, @@ -1695,8 +1518,7 @@ static int __init applesmc_init(void) for (i = 0; temperature_sensors_sets[applesmc_temperature_set][i] != NULL; i++) { - if (temperature_attributes[i] == NULL || - label_attributes[i] == NULL) { + if (temperature_attributes[i] == NULL) { printk(KERN_ERR "applesmc: More temperature sensors " "in temperature_sensors_sets (at least %i)" "than available sysfs files in " @@ -1708,10 +1530,6 @@ static int __init applesmc_init(void) temperature_attributes[i]); if (ret) goto out_temperature; - ret = sysfs_create_file(&pdev->dev.kobj, - label_attributes[i]); - if (ret) - goto out_temperature; } if (applesmc_accelerometer) { @@ -1762,7 +1580,6 @@ static int __init applesmc_init(void) if (applesmc_accelerometer) applesmc_release_accelerometer(); out_temperature: - sysfs_remove_group(&pdev->dev.kobj, &label_attributes_group); sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); out_fans: while (fans_handled) @@ -1792,7 +1609,6 @@ static void __exit applesmc_exit(void) } if (applesmc_accelerometer) applesmc_release_accelerometer(); - sysfs_remove_group(&pdev->dev.kobj, &label_attributes_group); sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); while (fans_handled) sysfs_remove_group(&pdev->dev.kobj, diff --git a/trunk/drivers/hwmon/asus_atk0110.c b/trunk/drivers/hwmon/asus_atk0110.c index 653db1bda934..16c420240724 100644 --- a/trunk/drivers/hwmon/asus_atk0110.c +++ b/trunk/drivers/hwmon/asus_atk0110.c @@ -1411,13 +1411,6 @@ static int __init atk0110_init(void) { int ret; - /* Make sure it's safe to access the device through ACPI */ - if (!acpi_resources_are_enforced()) { - pr_err("atk: Resources not safely usable due to " - "acpi_enforce_resources kernel parameter\n"); - return -EBUSY; - } - ret = acpi_bus_register_driver(&atk_driver); if (ret) pr_info("atk: acpi_bus_register_driver failed: %d\n", ret); diff --git a/trunk/drivers/hwmon/dme1737.c b/trunk/drivers/hwmon/dme1737.c index 980c17d5eeae..823dd28a902c 100644 --- a/trunk/drivers/hwmon/dme1737.c +++ b/trunk/drivers/hwmon/dme1737.c @@ -1,14 +1,12 @@ /* - * dme1737.c - Driver for the SMSC DME1737, Asus A8000, SMSC SCH311x, SCH5027, - * and SCH5127 Super-I/O chips integrated hardware monitoring - * features. - * Copyright (c) 2007, 2008, 2009, 2010 Juerg Haefliger + * dme1737.c - Driver for the SMSC DME1737, Asus A8000, SMSC SCH311x and + * SCH5027 Super-I/O chips integrated hardware monitoring features. + * Copyright (c) 2007, 2008 Juerg Haefliger * * This driver is an I2C/ISA hybrid, meaning that it uses the I2C bus to access * the chip registers if a DME1737, A8000, or SCH5027 is found and the ISA bus - * if a SCH311x or SCH5127 chip is found. Both types of chips have very - * similar hardware monitoring capabilities but differ in the way they can be - * accessed. + * if a SCH311x chip is found. Both types of chips have very similar hardware + * monitoring capabilities but differ in the way they can be accessed. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,7 +57,7 @@ MODULE_PARM_DESC(probe_all_addr, "Include probing of non-standard LPC " /* Addresses to scan */ static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; -enum chips { dme1737, sch5027, sch311x, sch5127 }; +enum chips { dme1737, sch5027, sch311x }; /* --------------------------------------------------------------------- * Registers @@ -166,29 +164,10 @@ static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; #define DME1737_VERSTEP_MASK 0xf8 #define SCH311X_DEVICE 0x8c #define SCH5027_VERSTEP 0x69 -#define SCH5127_DEVICE 0x8e - -/* Device ID values (global configuration register index 0x20) */ -#define DME1737_ID_1 0x77 -#define DME1737_ID_2 0x78 -#define SCH3112_ID 0x7c -#define SCH3114_ID 0x7d -#define SCH3116_ID 0x7f -#define SCH5027_ID 0x89 -#define SCH5127_ID 0x86 /* Length of ISA address segment */ #define DME1737_EXTENT 2 -/* chip-dependent features */ -#define HAS_TEMP_OFFSET (1 << 0) /* bit 0 */ -#define HAS_VID (1 << 1) /* bit 1 */ -#define HAS_ZONE3 (1 << 2) /* bit 2 */ -#define HAS_ZONE_HYST (1 << 3) /* bit 3 */ -#define HAS_PWM_MIN (1 << 4) /* bit 4 */ -#define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */ -#define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */ - /* --------------------------------------------------------------------- * Data structures and manipulation thereof * --------------------------------------------------------------------- */ @@ -208,7 +187,8 @@ struct dme1737_data { u8 vid; u8 pwm_rr_en; - u32 has_features; + u8 has_pwm; + u8 has_fan; /* Register values */ u16 in[7]; @@ -244,11 +224,8 @@ static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300, 3300}; static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, 3300}; -static const int IN_NOMINAL_SCH5127[] = {2500, 2250, 3300, 1125, 1125, 3300, - 3300}; #define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ - (type) == sch5127 ? IN_NOMINAL_SCH5127 : \ IN_NOMINAL_DME1737) /* Voltage input @@ -591,7 +568,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) /* Sample register contents every 1 sec */ if (time_after(jiffies, data->last_update + HZ) || !data->valid) { - if (data->has_features & HAS_VID) { + if (data->type == dme1737) { data->vid = dme1737_read(data, DME1737_REG_VID) & 0x3f; } @@ -622,7 +599,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) DME1737_REG_TEMP_MIN(ix)); data->temp_max[ix] = dme1737_read(data, DME1737_REG_TEMP_MAX(ix)); - if (data->has_features & HAS_TEMP_OFFSET) { + if (data->type != sch5027) { data->temp_offset[ix] = dme1737_read(data, DME1737_REG_TEMP_OFFSET(ix)); } @@ -649,7 +626,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) for (ix = 0; ix < ARRAY_SIZE(data->fan); ix++) { /* Skip reading registers if optional fans are not * present */ - if (!(data->has_features & HAS_FAN(ix))) { + if (!(data->has_fan & (1 << ix))) { continue; } data->fan[ix] = dme1737_read(data, @@ -673,7 +650,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) for (ix = 0; ix < ARRAY_SIZE(data->pwm); ix++) { /* Skip reading registers if optional PWMs are not * present */ - if (!(data->has_features & HAS_PWM(ix))) { + if (!(data->has_pwm & (1 << ix))) { continue; } data->pwm[ix] = dme1737_read(data, @@ -695,24 +672,12 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) /* Thermal zone registers */ for (ix = 0; ix < ARRAY_SIZE(data->zone_low); ix++) { - /* Skip reading registers if zone3 is not present */ - if ((ix == 2) && !(data->has_features & HAS_ZONE3)) { - continue; - } - /* sch5127 zone2 registers are special */ - if ((ix == 1) && (data->type == sch5127)) { - data->zone_low[1] = dme1737_read(data, - DME1737_REG_ZONE_LOW(2)); - data->zone_abs[1] = dme1737_read(data, - DME1737_REG_ZONE_ABS(2)); - } else { - data->zone_low[ix] = dme1737_read(data, - DME1737_REG_ZONE_LOW(ix)); - data->zone_abs[ix] = dme1737_read(data, - DME1737_REG_ZONE_ABS(ix)); - } + data->zone_low[ix] = dme1737_read(data, + DME1737_REG_ZONE_LOW(ix)); + data->zone_abs[ix] = dme1737_read(data, + DME1737_REG_ZONE_ABS(ix)); } - if (data->has_features & HAS_ZONE_HYST) { + if (data->type != sch5027) { for (ix = 0; ix < ARRAY_SIZE(data->zone_hyst); ix++) { data->zone_hyst[ix] = dme1737_read(data, DME1737_REG_ZONE_HYST(ix)); @@ -1629,6 +1594,10 @@ static struct attribute *dme1737_attr[] ={ &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, &sensor_dev_attr_zone2_auto_channels_temp.dev_attr.attr, + &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, + &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, + &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, + &sensor_dev_attr_zone3_auto_channels_temp.dev_attr.attr, NULL }; @@ -1636,23 +1605,27 @@ static const struct attribute_group dme1737_group = { .attrs = dme1737_attr, }; -/* The following struct holds temp offset attributes, which are not available - * in all chips. The following chips support them: - * DME1737, SCH311x */ -static struct attribute *dme1737_temp_offset_attr[] = { +/* The following struct holds misc attributes, which are not available in all + * chips. Their creation depends on the chip type which is determined during + * module load. */ +static struct attribute *dme1737_misc_attr[] = { + /* Temperatures */ &sensor_dev_attr_temp1_offset.dev_attr.attr, &sensor_dev_attr_temp2_offset.dev_attr.attr, &sensor_dev_attr_temp3_offset.dev_attr.attr, + /* Zones */ + &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, + &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, + &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, NULL }; -static const struct attribute_group dme1737_temp_offset_group = { - .attrs = dme1737_temp_offset_attr, +static const struct attribute_group dme1737_misc_group = { + .attrs = dme1737_misc_attr, }; -/* The following struct holds VID related attributes, which are not available - * in all chips. The following chips support them: - * DME1737 */ +/* The following struct holds VID-related attributes. Their creation + depends on the chip type which is determined during module load. */ static struct attribute *dme1737_vid_attr[] = { &dev_attr_vrm.attr, &dev_attr_cpu0_vid.attr, @@ -1663,36 +1636,6 @@ static const struct attribute_group dme1737_vid_group = { .attrs = dme1737_vid_attr, }; -/* The following struct holds temp zone 3 related attributes, which are not - * available in all chips. The following chips support them: - * DME1737, SCH311x, SCH5027 */ -static struct attribute *dme1737_zone3_attr[] = { - &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, - &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, - &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, - &sensor_dev_attr_zone3_auto_channels_temp.dev_attr.attr, - NULL -}; - -static const struct attribute_group dme1737_zone3_group = { - .attrs = dme1737_zone3_attr, -}; - - -/* The following struct holds temp zone hysteresis related attributes, which - * are not available in all chips. The following chips support them: - * DME1737, SCH311x */ -static struct attribute *dme1737_zone_hyst_attr[] = { - &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, - &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, - &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, - NULL -}; - -static const struct attribute_group dme1737_zone_hyst_group = { - .attrs = dme1737_zone_hyst_attr, -}; - /* The following structs hold the PWM attributes, some of which are optional. * Their creation depends on the chip configuration which is determined during * module load. */ @@ -1748,10 +1691,10 @@ static const struct attribute_group dme1737_pwm_group[] = { { .attrs = dme1737_pwm6_attr }, }; -/* The following struct holds auto PWM min attributes, which are not available - * in all chips. Their creation depends on the chip type which is determined +/* The following struct holds misc PWM attributes, which are not available in + * all chips. Their creation depends on the chip type which is determined * during module load. */ -static struct attribute *dme1737_auto_pwm_min_attr[] = { +static struct attribute *dme1737_pwm_misc_attr[] = { &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, @@ -1821,25 +1764,14 @@ static struct attribute *dme1737_zone_chmod_attr[] = { &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, - NULL -}; - -static const struct attribute_group dme1737_zone_chmod_group = { - .attrs = dme1737_zone_chmod_attr, -}; - - -/* The permissions of the following zone 3 attributes are changed to read- - * writeable if the chip is *not* locked. Otherwise they stay read-only. */ -static struct attribute *dme1737_zone3_chmod_attr[] = { &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, NULL }; -static const struct attribute_group dme1737_zone3_chmod_group = { - .attrs = dme1737_zone3_chmod_attr, +static const struct attribute_group dme1737_zone_chmod_group = { + .attrs = dme1737_zone_chmod_attr, }; /* The permissions of the following PWM attributes are changed to read- @@ -1955,35 +1887,30 @@ static void dme1737_remove_files(struct device *dev) int ix; for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { - if (data->has_features & HAS_FAN(ix)) { + if (data->has_fan & (1 << ix)) { sysfs_remove_group(&dev->kobj, &dme1737_fan_group[ix]); } } for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { - if (data->has_features & HAS_PWM(ix)) { + if (data->has_pwm & (1 << ix)) { sysfs_remove_group(&dev->kobj, &dme1737_pwm_group[ix]); - if ((data->has_features & HAS_PWM_MIN) && ix < 3) { + if (data->type != sch5027 && ix < 3) { sysfs_remove_file(&dev->kobj, - dme1737_auto_pwm_min_attr[ix]); + dme1737_pwm_misc_attr[ix]); } } } - if (data->has_features & HAS_TEMP_OFFSET) { - sysfs_remove_group(&dev->kobj, &dme1737_temp_offset_group); + if (data->type != sch5027) { + sysfs_remove_group(&dev->kobj, &dme1737_misc_group); } - if (data->has_features & HAS_VID) { + if (data->type == dme1737) { sysfs_remove_group(&dev->kobj, &dme1737_vid_group); } - if (data->has_features & HAS_ZONE3) { - sysfs_remove_group(&dev->kobj, &dme1737_zone3_group); - } - if (data->has_features & HAS_ZONE_HYST) { - sysfs_remove_group(&dev->kobj, &dme1737_zone_hyst_group); - } + sysfs_remove_group(&dev->kobj, &dme1737_group); if (!data->client) { @@ -2007,31 +1934,23 @@ static int dme1737_create_files(struct device *dev) goto exit_remove; } - /* Create chip-dependent sysfs attributes */ - if ((data->has_features & HAS_TEMP_OFFSET) && + /* Create misc sysfs attributes */ + if ((data->type != sch5027) && (err = sysfs_create_group(&dev->kobj, - &dme1737_temp_offset_group))) { + &dme1737_misc_group))) { goto exit_remove; } - if ((data->has_features & HAS_VID) && + + /* Create VID-related sysfs attributes */ + if ((data->type == dme1737) && (err = sysfs_create_group(&dev->kobj, &dme1737_vid_group))) { goto exit_remove; } - if ((data->has_features & HAS_ZONE3) && - (err = sysfs_create_group(&dev->kobj, - &dme1737_zone3_group))) { - goto exit_remove; - } - if ((data->has_features & HAS_ZONE_HYST) && - (err = sysfs_create_group(&dev->kobj, - &dme1737_zone_hyst_group))) { - goto exit_remove; - } /* Create fan sysfs attributes */ for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { - if (data->has_features & HAS_FAN(ix)) { + if (data->has_fan & (1 << ix)) { if ((err = sysfs_create_group(&dev->kobj, &dme1737_fan_group[ix]))) { goto exit_remove; @@ -2041,14 +1960,14 @@ static int dme1737_create_files(struct device *dev) /* Create PWM sysfs attributes */ for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { - if (data->has_features & HAS_PWM(ix)) { + if (data->has_pwm & (1 << ix)) { if ((err = sysfs_create_group(&dev->kobj, &dme1737_pwm_group[ix]))) { goto exit_remove; } - if ((data->has_features & HAS_PWM_MIN) && ix < 3 && + if (data->type != sch5027 && ix < 3 && (err = sysfs_create_file(&dev->kobj, - dme1737_auto_pwm_min_attr[ix]))) { + dme1737_pwm_misc_attr[ix]))) { goto exit_remove; } } @@ -2064,30 +1983,21 @@ static int dme1737_create_files(struct device *dev) dme1737_chmod_group(dev, &dme1737_zone_chmod_group, S_IRUGO | S_IWUSR); - /* Change permissions of chip-dependent sysfs attributes */ - if (data->has_features & HAS_TEMP_OFFSET) { - dme1737_chmod_group(dev, &dme1737_temp_offset_group, - S_IRUGO | S_IWUSR); - } - if (data->has_features & HAS_ZONE3) { - dme1737_chmod_group(dev, &dme1737_zone3_chmod_group, - S_IRUGO | S_IWUSR); - } - if (data->has_features & HAS_ZONE_HYST) { - dme1737_chmod_group(dev, &dme1737_zone_hyst_group, + /* Change permissions of misc sysfs attributes */ + if (data->type != sch5027) { + dme1737_chmod_group(dev, &dme1737_misc_group, S_IRUGO | S_IWUSR); } /* Change permissions of PWM sysfs attributes */ for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_chmod_group); ix++) { - if (data->has_features & HAS_PWM(ix)) { + if (data->has_pwm & (1 << ix)) { dme1737_chmod_group(dev, &dme1737_pwm_chmod_group[ix], S_IRUGO | S_IWUSR); - if ((data->has_features & HAS_PWM_MIN) && - ix < 3) { + if (data->type != sch5027 && ix < 3) { dme1737_chmod_file(dev, - dme1737_auto_pwm_min_attr[ix], + dme1737_pwm_misc_attr[ix], S_IRUGO | S_IWUSR); } } @@ -2095,7 +2005,7 @@ static int dme1737_create_files(struct device *dev) /* Change permissions of pwm[1-3] if in manual mode */ for (ix = 0; ix < 3; ix++) { - if ((data->has_features & HAS_PWM(ix)) && + if ((data->has_pwm & (1 << ix)) && (PWM_EN_FROM_REG(data->pwm_config[ix]) == 1)) { dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], @@ -2142,20 +2052,20 @@ static int dme1737_init_device(struct device *dev) return -EFAULT; } - /* Determine which optional fan and pwm features are enabled (only - * valid for I2C devices) */ + /* Determine which optional fan and pwm features are enabled/present */ if (client) { /* I2C chip */ data->config2 = dme1737_read(data, DME1737_REG_CONFIG2); /* Check if optional fan3 input is enabled */ if (data->config2 & 0x04) { - data->has_features |= HAS_FAN(2); + data->has_fan |= (1 << 2); } /* Fan4 and pwm3 are only available if the client's I2C address * is the default 0x2e. Otherwise the I/Os associated with * these functions are used for addr enable/select. */ if (client->addr == 0x2e) { - data->has_features |= HAS_FAN(3) | HAS_PWM(2); + data->has_fan |= (1 << 3); + data->has_pwm |= (1 << 2); } /* Determine which of the optional fan[5-6] and pwm[5-6] @@ -2167,40 +2077,26 @@ static int dme1737_init_device(struct device *dev) dev_warn(dev, "Failed to query Super-IO for optional " "features.\n"); } + } else { /* ISA chip */ + /* Fan3 and pwm3 are always available. Fan[4-5] and pwm[5-6] + * don't exist in the ISA chip. */ + data->has_fan |= (1 << 2); + data->has_pwm |= (1 << 2); } - /* Fan[1-2] and pwm[1-2] are present in all chips */ - data->has_features |= HAS_FAN(0) | HAS_FAN(1) | HAS_PWM(0) | HAS_PWM(1); - - /* Chip-dependent features */ - switch (data->type) { - case dme1737: - data->has_features |= HAS_TEMP_OFFSET | HAS_VID | HAS_ZONE3 | - HAS_ZONE_HYST | HAS_PWM_MIN; - break; - case sch311x: - data->has_features |= HAS_TEMP_OFFSET | HAS_ZONE3 | - HAS_ZONE_HYST | HAS_PWM_MIN | HAS_FAN(2) | HAS_PWM(2); - break; - case sch5027: - data->has_features |= HAS_ZONE3; - break; - case sch5127: - data->has_features |= HAS_FAN(2) | HAS_PWM(2); - break; - default: - break; - } + /* Fan1, fan2, pwm1, and pwm2 are always present */ + data->has_fan |= 0x03; + data->has_pwm |= 0x03; dev_info(dev, "Optional features: pwm3=%s, pwm5=%s, pwm6=%s, " "fan3=%s, fan4=%s, fan5=%s, fan6=%s.\n", - (data->has_features & HAS_PWM(2)) ? "yes" : "no", - (data->has_features & HAS_PWM(4)) ? "yes" : "no", - (data->has_features & HAS_PWM(5)) ? "yes" : "no", - (data->has_features & HAS_FAN(2)) ? "yes" : "no", - (data->has_features & HAS_FAN(3)) ? "yes" : "no", - (data->has_features & HAS_FAN(4)) ? "yes" : "no", - (data->has_features & HAS_FAN(5)) ? "yes" : "no"); + (data->has_pwm & (1 << 2)) ? "yes" : "no", + (data->has_pwm & (1 << 4)) ? "yes" : "no", + (data->has_pwm & (1 << 5)) ? "yes" : "no", + (data->has_fan & (1 << 2)) ? "yes" : "no", + (data->has_fan & (1 << 3)) ? "yes" : "no", + (data->has_fan & (1 << 4)) ? "yes" : "no", + (data->has_fan & (1 << 5)) ? "yes" : "no"); reg = dme1737_read(data, DME1737_REG_TACH_PWM); /* Inform if fan-to-pwm mapping differs from the default */ @@ -2226,7 +2122,7 @@ static int dme1737_init_device(struct device *dev) for (ix = 0; ix < 3; ix++) { data->pwm_config[ix] = dme1737_read(data, DME1737_REG_PWM_CONFIG(ix)); - if ((data->has_features & HAS_PWM(ix)) && + if ((data->has_pwm & (1 << ix)) && (PWM_EN_FROM_REG(data->pwm_config[ix]) == -1)) { dev_info(dev, "Switching pwm%d to " "manual mode.\n", ix + 1); @@ -2246,7 +2142,7 @@ static int dme1737_init_device(struct device *dev) data->pwm_acz[2] = 4; /* pwm3 -> zone3 */ /* Set VRM */ - if (data->has_features & HAS_VID) { + if (data->type == dme1737) { data->vrm = vid_which_vrm(); } @@ -2267,10 +2163,10 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) dme1737_sio_enter(sio_cip); /* Check device ID - * We currently know about two kinds of DME1737 and SCH5027. */ + * The DME1737 can return either 0x78 or 0x77 as its device ID. + * The SCH5027 returns 0x89 as its device ID. */ reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20); - if (!(reg == DME1737_ID_1 || reg == DME1737_ID_2 || - reg == SCH5027_ID)) { + if (!(reg == 0x77 || reg == 0x78 || reg == 0x89)) { err = -ENODEV; goto exit; } @@ -2289,16 +2185,16 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) * are enabled and available. Bits [3:2] of registers 0x43-0x46 are set * to '10' if the respective feature is enabled. */ if ((inb(addr + 0x43) & 0x0c) == 0x08) { /* fan6 */ - data->has_features |= HAS_FAN(5); + data->has_fan |= (1 << 5); } if ((inb(addr + 0x44) & 0x0c) == 0x08) { /* pwm6 */ - data->has_features |= HAS_PWM(5); + data->has_pwm |= (1 << 5); } if ((inb(addr + 0x45) & 0x0c) == 0x08) { /* fan5 */ - data->has_features |= HAS_FAN(4); + data->has_fan |= (1 << 4); } if ((inb(addr + 0x46) & 0x0c) == 0x08) { /* pwm5 */ - data->has_features |= HAS_PWM(4); + data->has_pwm |= (1 << 4); } exit: @@ -2326,6 +2222,7 @@ static int dme1737_i2c_detect(struct i2c_client *client, if (company == DME1737_COMPANY_SMSC && verstep == SCH5027_VERSTEP) { name = "sch5027"; + } else if (company == DME1737_COMPANY_SMSC && (verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP) { name = "dme1737"; @@ -2432,10 +2329,10 @@ static int __init dme1737_isa_detect(int sio_cip, unsigned short *addr) dme1737_sio_enter(sio_cip); /* Check device ID - * We currently know about SCH3112, SCH3114, SCH3116, and SCH5127 */ + * We currently know about SCH3112 (0x7c), SCH3114 (0x7d), and + * SCH3116 (0x7f). */ reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20); - if (!(reg == SCH3112_ID || reg == SCH3114_ID || reg == SCH3116_ID || - reg == SCH5127_ID)) { + if (!(reg == 0x7c || reg == 0x7d || reg == 0x7f)) { err = -ENODEV; goto exit; } @@ -2527,42 +2424,23 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); /* Skip chip detection if module is loaded with force_id parameter */ - switch (force_id) { - case SCH3112_ID: - case SCH3114_ID: - case SCH3116_ID: - data->type = sch311x; - break; - case SCH5127_ID: - data->type = sch5127; - break; - default: + if (!force_id) { company = dme1737_read(data, DME1737_REG_COMPANY); device = dme1737_read(data, DME1737_REG_DEVICE); - if ((company == DME1737_COMPANY_SMSC) && - (device == SCH311X_DEVICE)) { - data->type = sch311x; - } else if ((company == DME1737_COMPANY_SMSC) && - (device == SCH5127_DEVICE)) { - data->type = sch5127; - } else { + if (!((company == DME1737_COMPANY_SMSC) && + (device == SCH311X_DEVICE))) { err = -ENODEV; goto exit_kfree; } } + data->type = sch311x; - if (data->type == sch5127) { - data->name = "sch5127"; - } else { - data->name = "sch311x"; - } - - /* Initialize the mutex */ + /* Fill in the remaining client fields and initialize the mutex */ + data->name = "sch311x"; mutex_init(&data->update_lock); - dev_info(dev, "Found a %s chip at 0x%04x\n", - data->type == sch5127 ? "SCH5127" : "SCH311x", data->addr); + dev_info(dev, "Found a SCH311x chip at 0x%04x\n", data->addr); /* Initialize the chip */ if ((err = dme1737_init_device(dev))) { diff --git a/trunk/drivers/hwmon/emc1403.c b/trunk/drivers/hwmon/emc1403.c deleted file mode 100644 index 0e4b5642638d..000000000000 --- a/trunk/drivers/hwmon/emc1403.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * emc1403.c - SMSC Thermal Driver - * - * Copyright (C) 2008 Intel Corp - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * TODO - * - cache alarm and critical limit registers - * - add emc1404 support - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define THERMAL_PID_REG 0xfd -#define THERMAL_SMSC_ID_REG 0xfe -#define THERMAL_REVISION_REG 0xff - -struct thermal_data { - struct device *hwmon_dev; - struct mutex mutex; - /* Cache the hyst value so we don't keep re-reading it. In theory - we could cache it forever as nobody else should be writing it. */ - u8 cached_hyst; - unsigned long hyst_valid; -}; - -static ssize_t show_temp(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); - int retval = i2c_smbus_read_byte_data(client, sda->index); - - if (retval < 0) - return retval; - return sprintf(buf, "%d000\n", retval); -} - -static ssize_t show_bit(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); - int retval = i2c_smbus_read_byte_data(client, sda->nr); - - if (retval < 0) - return retval; - retval &= sda->index; - return sprintf(buf, "%d\n", retval ? 1 : 0); -} - -static ssize_t store_temp(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); - struct i2c_client *client = to_i2c_client(dev); - unsigned long val; - int retval; - - if (strict_strtoul(buf, 10, &val)) - return -EINVAL; - retval = i2c_smbus_write_byte_data(client, sda->index, - DIV_ROUND_CLOSEST(val, 1000)); - if (retval < 0) - return retval; - return count; -} - -static ssize_t show_hyst(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct thermal_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); - int retval; - int hyst; - - retval = i2c_smbus_read_byte_data(client, sda->index); - if (retval < 0) - return retval; - - if (time_after(jiffies, data->hyst_valid)) { - hyst = i2c_smbus_read_byte_data(client, 0x21); - if (hyst < 0) - return retval; - data->cached_hyst = hyst; - data->hyst_valid = jiffies + HZ; - } - return sprintf(buf, "%d000\n", retval - data->cached_hyst); -} - -static ssize_t store_hyst(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct thermal_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); - int retval; - int hyst; - unsigned long val; - - if (strict_strtoul(buf, 10, &val)) - return -EINVAL; - - mutex_lock(&data->mutex); - retval = i2c_smbus_read_byte_data(client, sda->index); - if (retval < 0) - goto fail; - - hyst = val - retval * 1000; - hyst = DIV_ROUND_CLOSEST(hyst, 1000); - if (hyst < 0 || hyst > 255) { - retval = -ERANGE; - goto fail; - } - - retval = i2c_smbus_write_byte_data(client, 0x21, hyst); - if (retval == 0) { - retval = count; - data->cached_hyst = hyst; - data->hyst_valid = jiffies + HZ; - } -fail: - mutex_unlock(&data->mutex); - return retval; -} - -/* - * Sensors. We pass the actual i2c register to the methods. - */ - -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x06); -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x05); -static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x20); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0x00); -static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x01); -static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x01); -static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x01); -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, - show_hyst, store_hyst, 0x20); - -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x08); -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x07); -static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x19); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0x01); -static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x02); -static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x02); -static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x02); -static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO | S_IWUSR, - show_hyst, store_hyst, 0x19); - -static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x16); -static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x15); -static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x1A); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 0x23); -static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x04); -static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x04); -static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x04); -static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO | S_IWUSR, - show_hyst, store_hyst, 0x1A); - -static struct attribute *mid_att_thermal[] = { - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp1_crit.dev_attr.attr, - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, - &sensor_dev_attr_temp2_min.dev_attr.attr, - &sensor_dev_attr_temp2_max.dev_attr.attr, - &sensor_dev_attr_temp2_crit.dev_attr.attr, - &sensor_dev_attr_temp2_input.dev_attr.attr, - &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, - &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, - &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, - &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, - &sensor_dev_attr_temp3_min.dev_attr.attr, - &sensor_dev_attr_temp3_max.dev_attr.attr, - &sensor_dev_attr_temp3_crit.dev_attr.attr, - &sensor_dev_attr_temp3_input.dev_attr.attr, - &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, - &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, - &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, - &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, - NULL -}; - -static const struct attribute_group m_thermal_gr = { - .attrs = mid_att_thermal -}; - -static int emc1403_detect(struct i2c_client *client, - struct i2c_board_info *info) -{ - int id; - /* Check if thermal chip is SMSC and EMC1403 */ - - id = i2c_smbus_read_byte_data(client, THERMAL_SMSC_ID_REG); - if (id != 0x5d) - return -ENODEV; - - /* Note: 0x25 is the 1404 which is very similar and this - driver could be extended */ - id = i2c_smbus_read_byte_data(client, THERMAL_PID_REG); - if (id != 0x21) - return -ENODEV; - - id = i2c_smbus_read_byte_data(client, THERMAL_REVISION_REG); - if (id != 0x01) - return -ENODEV; - - strlcpy(info->type, "emc1403", I2C_NAME_SIZE); - return 0; -} - -static int emc1403_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int res; - struct thermal_data *data; - - data = kzalloc(sizeof(struct thermal_data), GFP_KERNEL); - if (data == NULL) { - dev_warn(&client->dev, "out of memory"); - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->mutex); - data->hyst_valid = jiffies - 1; /* Expired */ - - res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr); - if (res) { - dev_warn(&client->dev, "create group failed\n"); - hwmon_device_unregister(data->hwmon_dev); - goto thermal_error1; - } - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - res = PTR_ERR(data->hwmon_dev); - dev_warn(&client->dev, "register hwmon dev failed\n"); - goto thermal_error2; - } - dev_info(&client->dev, "EMC1403 Thermal chip found\n"); - return res; - -thermal_error2: - sysfs_remove_group(&client->dev.kobj, &m_thermal_gr); -thermal_error1: - kfree(data); - return res; -} - -static int emc1403_remove(struct i2c_client *client) -{ - struct thermal_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &m_thermal_gr); - kfree(data); - return 0; -} - -static const unsigned short emc1403_address_list[] = { - 0x18, 0x2a, 0x4c, 0x4d, I2C_CLIENT_END -}; - -static const struct i2c_device_id emc1403_idtable[] = { - { "emc1403", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, emc1403_idtable); - -static struct i2c_driver sensor_emc1403 = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "emc1403", - }, - .detect = emc1403_detect, - .probe = emc1403_probe, - .remove = emc1403_remove, - .id_table = emc1403_idtable, - .address_list = emc1403_address_list, -}; - -static int __init sensor_emc1403_init(void) -{ - return i2c_add_driver(&sensor_emc1403); -} - -static void __exit sensor_emc1403_exit(void) -{ - i2c_del_driver(&sensor_emc1403); -} - -module_init(sensor_emc1403_init); -module_exit(sensor_emc1403_exit); - -MODULE_AUTHOR("Kalhan Trisal addr + ADDR_REG_OFFSET); + val = inb(data->addr + DATA_REG_OFFSET) << 8; + outb(reg, data->addr + ADDR_REG_OFFSET); + val |= inb(data->addr + DATA_REG_OFFSET); return val; } @@ -917,8 +921,10 @@ static void f71882fg_write8(struct f71882fg_data *data, u8 reg, u8 val) static void f71882fg_write16(struct f71882fg_data *data, u8 reg, u16 val) { - f71882fg_write8(data, reg, val >> 8); - f71882fg_write8(data, reg + 1, val & 0xff); + outb(reg++, data->addr + ADDR_REG_OFFSET); + outb(val >> 8, data->addr + DATA_REG_OFFSET); + outb(reg, data->addr + ADDR_REG_OFFSET); + outb(val & 255, data->addr + DATA_REG_OFFSET); } static u16 f71882fg_read_temp(struct f71882fg_data *data, int nr) @@ -939,7 +945,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) mutex_lock(&data->update_lock); /* Update once every 60 seconds */ - if (time_after(jiffies, data->last_limits + 60 * HZ) || + if ( time_after(jiffies, data->last_limits + 60 * HZ ) || !data->valid) { if (data->type == f71882fg || data->type == f71889fg) { data->in1_max = @@ -1121,12 +1127,8 @@ static ssize_t store_fan_full_speed(struct device *dev, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10); val = SENSORS_LIMIT(val, 23, 1500000); val = fan_to_reg(val); @@ -1155,12 +1157,8 @@ static ssize_t store_fan_beep(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - unsigned long val; - - err = strict_strtoul(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + unsigned long val = simple_strtoul(buf, NULL, 10); mutex_lock(&data->update_lock); data->fan_beep = f71882fg_read8(data, F71882FG_REG_FAN_BEEP); @@ -1208,14 +1206,7 @@ static ssize_t store_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - - val /= 8; + long val = simple_strtol(buf, NULL, 10) / 8; val = SENSORS_LIMIT(val, 0, 255); mutex_lock(&data->update_lock); @@ -1242,12 +1233,8 @@ static ssize_t store_in_beep(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - unsigned long val; - - err = strict_strtoul(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + unsigned long val = simple_strtoul(buf, NULL, 10); mutex_lock(&data->update_lock); data->in_beep = f71882fg_read8(data, F71882FG_REG_IN_BEEP); @@ -1312,14 +1299,8 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - - val /= 1000; + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10) / 1000; val = SENSORS_LIMIT(val, 0, 255); mutex_lock(&data->update_lock); @@ -1352,16 +1333,10 @@ static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10) / 1000; ssize_t ret = count; u8 reg; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - - val /= 1000; mutex_lock(&data->update_lock); @@ -1397,14 +1372,8 @@ static ssize_t store_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - - val /= 1000; + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10) / 1000; val = SENSORS_LIMIT(val, 0, 255); mutex_lock(&data->update_lock); @@ -1458,12 +1427,8 @@ static ssize_t store_temp_beep(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - unsigned long val; - - err = strict_strtoul(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + unsigned long val = simple_strtoul(buf, NULL, 10); mutex_lock(&data->update_lock); data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP); @@ -1525,13 +1490,8 @@ static ssize_t store_pwm(struct device *dev, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10); val = SENSORS_LIMIT(val, 0, 255); mutex_lock(&data->update_lock); @@ -1591,12 +1551,8 @@ static ssize_t store_pwm_enable(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10); /* Special case for F8000 pwm channel 3 which only does auto mode */ if (data->type == f8000 && nr == 2 && val != 2) @@ -1670,14 +1626,9 @@ static ssize_t store_pwm_auto_point_pwm(struct device *dev, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, pwm = to_sensor_dev_attr_2(devattr)->index; + int pwm = to_sensor_dev_attr_2(devattr)->index; int point = to_sensor_dev_attr_2(devattr)->nr; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - + long val = simple_strtol(buf, NULL, 10); val = SENSORS_LIMIT(val, 0, 255); mutex_lock(&data->update_lock); @@ -1723,16 +1674,10 @@ static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; + int nr = to_sensor_dev_attr_2(devattr)->index; int point = to_sensor_dev_attr_2(devattr)->nr; + long val = simple_strtol(buf, NULL, 10) / 1000; u8 reg; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - - val /= 1000; mutex_lock(&data->update_lock); data->pwm_auto_point_temp[nr][point] = @@ -1771,12 +1716,8 @@ static ssize_t store_pwm_interpolate(struct device *dev, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - unsigned long val; - - err = strict_strtoul(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + unsigned long val = simple_strtoul(buf, NULL, 10); mutex_lock(&data->update_lock); data->pwm_auto_point_mapping[nr] = @@ -1811,12 +1752,8 @@ static ssize_t store_pwm_auto_point_channel(struct device *dev, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, nr = to_sensor_dev_attr_2(devattr)->index; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; + int nr = to_sensor_dev_attr_2(devattr)->index; + long val = simple_strtol(buf, NULL, 10); switch (val) { case 1: @@ -1861,15 +1798,9 @@ static ssize_t store_pwm_auto_point_temp(struct device *dev, const char *buf, size_t count) { struct f71882fg_data *data = dev_get_drvdata(dev); - int err, pwm = to_sensor_dev_attr_2(devattr)->index; + int pwm = to_sensor_dev_attr_2(devattr)->index; int point = to_sensor_dev_attr_2(devattr)->nr; - long val; - - err = strict_strtol(buf, 10, &val); - if (err) - return err; - - val /= 1000; + long val = simple_strtol(buf, NULL, 10) / 1000; if (data->type == f71889fg) val = SENSORS_LIMIT(val, -128, 127); @@ -2178,13 +2109,6 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, int err = -ENODEV; u16 devid; - /* Don't step on other drivers' I/O space by accident */ - if (!request_region(sioaddr, 2, DRVNAME)) { - printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", - (int)sioaddr); - return -EBUSY; - } - superio_enter(sioaddr); devid = superio_inw(sioaddr, SIO_REG_MANID); @@ -2227,7 +2151,8 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, } *address = superio_inw(sioaddr, SIO_REG_ADDR); - if (*address == 0) { + if (*address == 0) + { printk(KERN_WARNING DRVNAME ": Base address not set\n"); goto exit; } @@ -2239,7 +2164,6 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, (int)superio_inb(sioaddr, SIO_REG_DEVREV)); exit: superio_exit(sioaddr); - release_region(sioaddr, 2); return err; } diff --git a/trunk/drivers/hwmon/lm63.c b/trunk/drivers/hwmon/lm63.c index 776aeb3019d2..bf81aff7051d 100644 --- a/trunk/drivers/hwmon/lm63.c +++ b/trunk/drivers/hwmon/lm63.c @@ -53,7 +53,7 @@ * Address is fully defined internally and cannot be changed. */ -static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END }; +static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; /* * The LM63 registers @@ -131,15 +131,12 @@ static struct lm63_data *lm63_update_device(struct device *dev); static int lm63_detect(struct i2c_client *client, struct i2c_board_info *info); static void lm63_init_client(struct i2c_client *client); -enum chips { lm63, lm64 }; - /* * Driver data (common to all clients) */ static const struct i2c_device_id lm63_id[] = { - { "lm63", lm63 }, - { "lm64", lm64 }, + { "lm63", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, lm63_id); @@ -425,7 +422,6 @@ static int lm63_detect(struct i2c_client *new_client, struct i2c_adapter *adapter = new_client->adapter; u8 man_id, chip_id, reg_config1, reg_config2; u8 reg_alert_status, reg_alert_mask; - int address = new_client->addr; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; @@ -443,6 +439,7 @@ static int lm63_detect(struct i2c_client *new_client, LM63_REG_ALERT_MASK); if (man_id != 0x01 /* National Semiconductor */ + || chip_id != 0x41 /* LM63 */ || (reg_config1 & 0x18) != 0x00 || (reg_config2 & 0xF8) != 0x00 || (reg_alert_status & 0x20) != 0x00 @@ -453,12 +450,7 @@ static int lm63_detect(struct i2c_client *new_client, return -ENODEV; } - if (chip_id == 0x41 && address == 0x4c) - strlcpy(info->type, "lm63", I2C_NAME_SIZE); - else if (chip_id == 0x51 && (address == 0x18 || address == 0x4e)) - strlcpy(info->type, "lm64", I2C_NAME_SIZE); - else - return -ENODEV; + strlcpy(info->type, "lm63", I2C_NAME_SIZE); return 0; } diff --git a/trunk/drivers/hwmon/lm75.c b/trunk/drivers/hwmon/lm75.c index 56463428a419..8ae2cfe2d827 100644 --- a/trunk/drivers/hwmon/lm75.c +++ b/trunk/drivers/hwmon/lm75.c @@ -46,7 +46,6 @@ enum lm75_type { /* keep sorted in alphabetical order */ tcn75, tmp100, tmp101, - tmp105, tmp175, tmp275, tmp75, @@ -221,7 +220,6 @@ static const struct i2c_device_id lm75_ids[] = { { "tcn75", tcn75, }, { "tmp100", tmp100, }, { "tmp101", tmp101, }, - { "tmp105", tmp105, }, { "tmp175", tmp175, }, { "tmp275", tmp275, }, { "tmp75", tmp75, }, diff --git a/trunk/drivers/hwmon/lm90.c b/trunk/drivers/hwmon/lm90.c index 760ef72eea56..7cc2708871ab 100644 --- a/trunk/drivers/hwmon/lm90.c +++ b/trunk/drivers/hwmon/lm90.c @@ -982,8 +982,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) mutex_lock(&data->update_lock); - if (time_after(jiffies, data->last_updated + HZ / 2 + HZ / 10) - || !data->valid) { + if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { u8 h, l; dev_dbg(&client->dev, "Updating lm90 data.\n"); diff --git a/trunk/drivers/hwmon/ltc4245.c b/trunk/drivers/hwmon/ltc4245.c index 21d201befc2c..65c232a9d0c5 100644 --- a/trunk/drivers/hwmon/ltc4245.c +++ b/trunk/drivers/hwmon/ltc4245.c @@ -45,7 +45,9 @@ enum ltc4245_cmd { LTC4245_VEEIN = 0x19, LTC4245_VEESENSE = 0x1a, LTC4245_VEEOUT = 0x1b, - LTC4245_GPIOADC = 0x1c, + LTC4245_GPIOADC1 = 0x1c, + LTC4245_GPIOADC2 = 0x1d, + LTC4245_GPIOADC3 = 0x1e, }; struct ltc4245_data { @@ -59,7 +61,7 @@ struct ltc4245_data { u8 cregs[0x08]; /* Voltage registers */ - u8 vregs[0x0d]; + u8 vregs[0x0f]; }; static struct ltc4245_data *ltc4245_update_device(struct device *dev) @@ -84,7 +86,7 @@ static struct ltc4245_data *ltc4245_update_device(struct device *dev) data->cregs[i] = val; } - /* Read voltage registers -- 0x10 to 0x1c */ + /* Read voltage registers -- 0x10 to 0x1f */ for (i = 0; i < ARRAY_SIZE(data->vregs); i++) { val = i2c_smbus_read_byte_data(client, i+0x10); if (unlikely(val < 0)) @@ -126,7 +128,9 @@ static int ltc4245_get_voltage(struct device *dev, u8 reg) case LTC4245_VEEOUT: voltage = regval * -55; break; - case LTC4245_GPIOADC: + case LTC4245_GPIOADC1: + case LTC4245_GPIOADC2: + case LTC4245_GPIOADC3: voltage = regval * 10; break; default: @@ -293,7 +297,9 @@ LTC4245_ALARM(in7_min_alarm, (1 << 2), LTC4245_FAULT2); LTC4245_ALARM(in8_min_alarm, (1 << 3), LTC4245_FAULT2); /* GPIO voltages */ -LTC4245_VOLTAGE(in9_input, LTC4245_GPIOADC); +LTC4245_VOLTAGE(in9_input, LTC4245_GPIOADC1); +LTC4245_VOLTAGE(in10_input, LTC4245_GPIOADC2); +LTC4245_VOLTAGE(in11_input, LTC4245_GPIOADC3); /* Power Consumption (virtual) */ LTC4245_POWER(power1_input, LTC4245_12VSENSE); @@ -336,6 +342,8 @@ static struct attribute *ltc4245_attributes[] = { &sensor_dev_attr_in8_min_alarm.dev_attr.attr, &sensor_dev_attr_in9_input.dev_attr.attr, + &sensor_dev_attr_in10_input.dev_attr.attr, + &sensor_dev_attr_in11_input.dev_attr.attr, &sensor_dev_attr_power1_input.dev_attr.attr, &sensor_dev_attr_power2_input.dev_attr.attr, diff --git a/trunk/drivers/hwmon/tmp102.c b/trunk/drivers/hwmon/tmp102.c deleted file mode 100644 index 8013895a1faf..000000000000 --- a/trunk/drivers/hwmon/tmp102.c +++ /dev/null @@ -1,321 +0,0 @@ -/* Texas Instruments TMP102 SMBus temperature sensor driver - * - * Copyright (C) 2010 Steven King - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "tmp102" - -#define TMP102_TEMP_REG 0x00 -#define TMP102_CONF_REG 0x01 -/* note: these bit definitions are byte swapped */ -#define TMP102_CONF_SD 0x0100 -#define TMP102_CONF_TM 0x0200 -#define TMP102_CONF_POL 0x0400 -#define TMP102_CONF_F0 0x0800 -#define TMP102_CONF_F1 0x1000 -#define TMP102_CONF_R0 0x2000 -#define TMP102_CONF_R1 0x4000 -#define TMP102_CONF_OS 0x8000 -#define TMP102_CONF_EM 0x0010 -#define TMP102_CONF_AL 0x0020 -#define TMP102_CONF_CR0 0x0040 -#define TMP102_CONF_CR1 0x0080 -#define TMP102_TLOW_REG 0x02 -#define TMP102_THIGH_REG 0x03 - -struct tmp102 { - struct device *hwmon_dev; - struct mutex lock; - u16 config_orig; - unsigned long last_update; - int temp[3]; -}; - -/* SMBus specifies low byte first, but the TMP102 returns high byte first, - * so we have to swab16 the values */ -static inline int tmp102_read_reg(struct i2c_client *client, u8 reg) -{ - int result = i2c_smbus_read_word_data(client, reg); - return result < 0 ? result : swab16(result); -} - -static inline int tmp102_write_reg(struct i2c_client *client, u8 reg, u16 val) -{ - return i2c_smbus_write_word_data(client, reg, swab16(val)); -} - -/* convert left adjusted 13-bit TMP102 register value to milliCelsius */ -static inline int tmp102_reg_to_mC(s16 val) -{ - return ((val & ~0x01) * 1000) / 128; -} - -/* convert milliCelsius to left adjusted 13-bit TMP102 register value */ -static inline u16 tmp102_mC_to_reg(int val) -{ - return (val * 128) / 1000; -} - -static const u8 tmp102_reg[] = { - TMP102_TEMP_REG, - TMP102_TLOW_REG, - TMP102_THIGH_REG, -}; - -static struct tmp102 *tmp102_update_device(struct i2c_client *client) -{ - struct tmp102 *tmp102 = i2c_get_clientdata(client); - - mutex_lock(&tmp102->lock); - if (time_after(jiffies, tmp102->last_update + HZ / 3)) { - int i; - for (i = 0; i < ARRAY_SIZE(tmp102->temp); ++i) { - int status = tmp102_read_reg(client, tmp102_reg[i]); - if (status > -1) - tmp102->temp[i] = tmp102_reg_to_mC(status); - } - tmp102->last_update = jiffies; - } - mutex_unlock(&tmp102->lock); - return tmp102; -} - -static ssize_t tmp102_show_temp(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); - struct tmp102 *tmp102 = tmp102_update_device(to_i2c_client(dev)); - - return sprintf(buf, "%d\n", tmp102->temp[sda->index]); -} - -static ssize_t tmp102_set_temp(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); - struct i2c_client *client = to_i2c_client(dev); - struct tmp102 *tmp102 = i2c_get_clientdata(client); - long val; - int status; - - if (strict_strtol(buf, 10, &val) < 0) - return -EINVAL; - val = SENSORS_LIMIT(val, -256000, 255000); - - mutex_lock(&tmp102->lock); - tmp102->temp[sda->index] = val; - status = tmp102_write_reg(client, tmp102_reg[sda->index], - tmp102_mC_to_reg(val)); - mutex_unlock(&tmp102->lock); - return status ? : count; -} - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, tmp102_show_temp, NULL , 0); - -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, tmp102_show_temp, - tmp102_set_temp, 1); - -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, tmp102_show_temp, - tmp102_set_temp, 2); - -static struct attribute *tmp102_attributes[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_max.dev_attr.attr, - NULL -}; - -static const struct attribute_group tmp102_attr_group = { - .attrs = tmp102_attributes, -}; - -#define TMP102_CONFIG (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1) -#define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL) - -static int __devinit tmp102_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct tmp102 *tmp102; - int status; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WORD_DATA)) { - dev_err(&client->dev, "adapter doesnt support SMBus word " - "transactions\n"); - return -ENODEV; - } - - tmp102 = kzalloc(sizeof(*tmp102), GFP_KERNEL); - if (!tmp102) { - dev_dbg(&client->dev, "kzalloc failed\n"); - return -ENOMEM; - } - i2c_set_clientdata(client, tmp102); - - status = tmp102_read_reg(client, TMP102_CONF_REG); - if (status < 0) { - dev_err(&client->dev, "error reading config register\n"); - goto fail_free; - } - tmp102->config_orig = status; - status = tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONFIG); - if (status < 0) { - dev_err(&client->dev, "error writing config register\n"); - goto fail_restore_config; - } - status = tmp102_read_reg(client, TMP102_CONF_REG); - if (status < 0) { - dev_err(&client->dev, "error reading config register\n"); - goto fail_restore_config; - } - status &= ~TMP102_CONFIG_RD_ONLY; - if (status != TMP102_CONFIG) { - dev_err(&client->dev, "config settings did not stick\n"); - status = -ENODEV; - goto fail_restore_config; - } - tmp102->last_update = jiffies - HZ; - mutex_init(&tmp102->lock); - - status = sysfs_create_group(&client->dev.kobj, &tmp102_attr_group); - if (status) { - dev_dbg(&client->dev, "could not create sysfs files\n"); - goto fail_restore_config; - } - tmp102->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(tmp102->hwmon_dev)) { - dev_dbg(&client->dev, "unable to register hwmon device\n"); - status = PTR_ERR(tmp102->hwmon_dev); - goto fail_remove_sysfs; - } - - dev_info(&client->dev, "initialized\n"); - - return 0; - -fail_remove_sysfs: - sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); -fail_restore_config: - tmp102_write_reg(client, TMP102_CONF_REG, tmp102->config_orig); -fail_free: - i2c_set_clientdata(client, NULL); - kfree(tmp102); - - return status; -} - -static int __devexit tmp102_remove(struct i2c_client *client) -{ - struct tmp102 *tmp102 = i2c_get_clientdata(client); - - hwmon_device_unregister(tmp102->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); - - /* Stop monitoring if device was stopped originally */ - if (tmp102->config_orig & TMP102_CONF_SD) { - int config; - - config = tmp102_read_reg(client, TMP102_CONF_REG); - if (config >= 0) - tmp102_write_reg(client, TMP102_CONF_REG, - config | TMP102_CONF_SD); - } - - i2c_set_clientdata(client, NULL); - kfree(tmp102); - - return 0; -} - -#ifdef CONFIG_PM -static int tmp102_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - int config; - - config = tmp102_read_reg(client, TMP102_CONF_REG); - if (config < 0) - return config; - - config |= TMP102_CONF_SD; - return tmp102_write_reg(client, TMP102_CONF_REG, config); -} - -static int tmp102_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - int config; - - config = tmp102_read_reg(client, TMP102_CONF_REG); - if (config < 0) - return config; - - config &= ~TMP102_CONF_SD; - return tmp102_write_reg(client, TMP102_CONF_REG, config); -} - -static const struct dev_pm_ops tmp102_dev_pm_ops = { - .suspend = tmp102_suspend, - .resume = tmp102_resume, -}; - -#define TMP102_DEV_PM_OPS (&tmp102_dev_pm_ops) -#else -#define TMP102_DEV_PM_OPS NULL -#endif /* CONFIG_PM */ - -static const struct i2c_device_id tmp102_id[] = { - { "tmp102", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, tmp102_id); - -static struct i2c_driver tmp102_driver = { - .driver.name = DRIVER_NAME, - .driver.pm = TMP102_DEV_PM_OPS, - .probe = tmp102_probe, - .remove = __devexit_p(tmp102_remove), - .id_table = tmp102_id, -}; - -static int __init tmp102_init(void) -{ - return i2c_add_driver(&tmp102_driver); -} -module_init(tmp102_init); - -static void __exit tmp102_exit(void) -{ - i2c_del_driver(&tmp102_driver); -} -module_exit(tmp102_exit); - -MODULE_AUTHOR("Steven King "); -MODULE_DESCRIPTION("Texas Instruments TMP102 temperature sensor driver"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/hwmon/tmp401.c b/trunk/drivers/hwmon/tmp401.c index ad8d535235c5..d14a1af9f550 100644 --- a/trunk/drivers/hwmon/tmp401.c +++ b/trunk/drivers/hwmon/tmp401.c @@ -91,6 +91,17 @@ static const u8 TMP411_TEMP_HIGHEST_LSB[2] = { 0x33, 0x37 }; #define TMP401_DEVICE_ID 0x11 #define TMP411_DEVICE_ID 0x12 +/* + * Functions declarations + */ + +static int tmp401_probe(struct i2c_client *client, + const struct i2c_device_id *id); +static int tmp401_detect(struct i2c_client *client, + struct i2c_board_info *info); +static int tmp401_remove(struct i2c_client *client); +static struct tmp401_data *tmp401_update_device(struct device *dev); + /* * Driver data (common to all clients) */ @@ -102,6 +113,18 @@ static const struct i2c_device_id tmp401_id[] = { }; MODULE_DEVICE_TABLE(i2c, tmp401_id); +static struct i2c_driver tmp401_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "tmp401", + }, + .probe = tmp401_probe, + .remove = tmp401_remove, + .id_table = tmp401_id, + .detect = tmp401_detect, + .address_list = normal_i2c, +}; + /* * Client data (each client gets its own) */ @@ -171,71 +194,6 @@ static u8 tmp401_crit_temp_to_register(long temp, u8 config) return (temp + 500) / 1000; } -static struct tmp401_data *tmp401_update_device_reg16( - struct i2c_client *client, struct tmp401_data *data) -{ - int i; - - for (i = 0; i < 2; i++) { - /* - * High byte must be read first immediately followed - * by the low byte - */ - data->temp[i] = i2c_smbus_read_byte_data(client, - TMP401_TEMP_MSB[i]) << 8; - data->temp[i] |= i2c_smbus_read_byte_data(client, - TMP401_TEMP_LSB[i]); - data->temp_low[i] = i2c_smbus_read_byte_data(client, - TMP401_TEMP_LOW_LIMIT_MSB_READ[i]) << 8; - data->temp_low[i] |= i2c_smbus_read_byte_data(client, - TMP401_TEMP_LOW_LIMIT_LSB[i]); - data->temp_high[i] = i2c_smbus_read_byte_data(client, - TMP401_TEMP_HIGH_LIMIT_MSB_READ[i]) << 8; - data->temp_high[i] |= i2c_smbus_read_byte_data(client, - TMP401_TEMP_HIGH_LIMIT_LSB[i]); - data->temp_crit[i] = i2c_smbus_read_byte_data(client, - TMP401_TEMP_CRIT_LIMIT[i]); - - if (data->kind == tmp411) { - data->temp_lowest[i] = i2c_smbus_read_byte_data(client, - TMP411_TEMP_LOWEST_MSB[i]) << 8; - data->temp_lowest[i] |= i2c_smbus_read_byte_data( - client, TMP411_TEMP_LOWEST_LSB[i]); - - data->temp_highest[i] = i2c_smbus_read_byte_data( - client, TMP411_TEMP_HIGHEST_MSB[i]) << 8; - data->temp_highest[i] |= i2c_smbus_read_byte_data( - client, TMP411_TEMP_HIGHEST_LSB[i]); - } - } - return data; -} - -static struct tmp401_data *tmp401_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct tmp401_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { - data->status = i2c_smbus_read_byte_data(client, TMP401_STATUS); - data->config = i2c_smbus_read_byte_data(client, - TMP401_CONFIG_READ); - tmp401_update_device_reg16(client, data); - - data->temp_crit_hyst = i2c_smbus_read_byte_data(client, - TMP401_TEMP_CRIT_HYST); - - data->last_updated = jiffies; - data->valid = 1; - } - - mutex_unlock(&data->update_lock); - - return data; -} - static ssize_t show_temp_value(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -462,36 +420,30 @@ static ssize_t reset_temp_history(struct device *dev, } static struct sensor_device_attribute tmp401_attr[] = { - SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_value, NULL, 0), - SENSOR_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, - store_temp_min, 0), - SENSOR_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, - store_temp_max, 0), - SENSOR_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit, - store_temp_crit, 0), - SENSOR_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_crit_hyst, + SENSOR_ATTR(temp1_input, 0444, show_temp_value, NULL, 0), + SENSOR_ATTR(temp1_min, 0644, show_temp_min, store_temp_min, 0), + SENSOR_ATTR(temp1_max, 0644, show_temp_max, store_temp_max, 0), + SENSOR_ATTR(temp1_crit, 0644, show_temp_crit, store_temp_crit, 0), + SENSOR_ATTR(temp1_crit_hyst, 0644, show_temp_crit_hyst, store_temp_crit_hyst, 0), - SENSOR_ATTR(temp1_min_alarm, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp1_min_alarm, 0444, show_status, NULL, TMP401_STATUS_LOCAL_LOW), - SENSOR_ATTR(temp1_max_alarm, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp1_max_alarm, 0444, show_status, NULL, TMP401_STATUS_LOCAL_HIGH), - SENSOR_ATTR(temp1_crit_alarm, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp1_crit_alarm, 0444, show_status, NULL, TMP401_STATUS_LOCAL_CRIT), - SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_value, NULL, 1), - SENSOR_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, - store_temp_min, 1), - SENSOR_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, - store_temp_max, 1), - SENSOR_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit, - store_temp_crit, 1), - SENSOR_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, 1), - SENSOR_ATTR(temp2_fault, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp2_input, 0444, show_temp_value, NULL, 1), + SENSOR_ATTR(temp2_min, 0644, show_temp_min, store_temp_min, 1), + SENSOR_ATTR(temp2_max, 0644, show_temp_max, store_temp_max, 1), + SENSOR_ATTR(temp2_crit, 0644, show_temp_crit, store_temp_crit, 1), + SENSOR_ATTR(temp2_crit_hyst, 0444, show_temp_crit_hyst, NULL, 1), + SENSOR_ATTR(temp2_fault, 0444, show_status, NULL, TMP401_STATUS_REMOTE_OPEN), - SENSOR_ATTR(temp2_min_alarm, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp2_min_alarm, 0444, show_status, NULL, TMP401_STATUS_REMOTE_LOW), - SENSOR_ATTR(temp2_max_alarm, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp2_max_alarm, 0444, show_status, NULL, TMP401_STATUS_REMOTE_HIGH), - SENSOR_ATTR(temp2_crit_alarm, S_IRUGO, show_status, NULL, + SENSOR_ATTR(temp2_crit_alarm, 0444, show_status, NULL, TMP401_STATUS_REMOTE_CRIT), }; @@ -503,11 +455,11 @@ static struct sensor_device_attribute tmp401_attr[] = { * and remote channels. */ static struct sensor_device_attribute tmp411_attr[] = { - SENSOR_ATTR(temp1_highest, S_IRUGO, show_temp_highest, NULL, 0), - SENSOR_ATTR(temp1_lowest, S_IRUGO, show_temp_lowest, NULL, 0), - SENSOR_ATTR(temp2_highest, S_IRUGO, show_temp_highest, NULL, 1), - SENSOR_ATTR(temp2_lowest, S_IRUGO, show_temp_lowest, NULL, 1), - SENSOR_ATTR(temp_reset_history, S_IWUSR, NULL, reset_temp_history, 0), + SENSOR_ATTR(temp1_highest, 0444, show_temp_highest, NULL, 0), + SENSOR_ATTR(temp1_lowest, 0444, show_temp_lowest, NULL, 0), + SENSOR_ATTR(temp2_highest, 0444, show_temp_highest, NULL, 1), + SENSOR_ATTR(temp2_lowest, 0444, show_temp_lowest, NULL, 1), + SENSOR_ATTR(temp_reset_history, 0200, NULL, reset_temp_history, 0), }; /* @@ -577,27 +529,6 @@ static int tmp401_detect(struct i2c_client *client, return 0; } -static int tmp401_remove(struct i2c_client *client) -{ - struct tmp401_data *data = i2c_get_clientdata(client); - int i; - - if (data->hwmon_dev) - hwmon_device_unregister(data->hwmon_dev); - - for (i = 0; i < ARRAY_SIZE(tmp401_attr); i++) - device_remove_file(&client->dev, &tmp401_attr[i].dev_attr); - - if (data->kind == tmp411) { - for (i = 0; i < ARRAY_SIZE(tmp411_attr); i++) - device_remove_file(&client->dev, - &tmp411_attr[i].dev_attr); - } - - kfree(data); - return 0; -} - static int tmp401_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -650,17 +581,91 @@ static int tmp401_probe(struct i2c_client *client, return err; } -static struct i2c_driver tmp401_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "tmp401", - }, - .probe = tmp401_probe, - .remove = tmp401_remove, - .id_table = tmp401_id, - .detect = tmp401_detect, - .address_list = normal_i2c, -}; +static int tmp401_remove(struct i2c_client *client) +{ + struct tmp401_data *data = i2c_get_clientdata(client); + int i; + + if (data->hwmon_dev) + hwmon_device_unregister(data->hwmon_dev); + + for (i = 0; i < ARRAY_SIZE(tmp401_attr); i++) + device_remove_file(&client->dev, &tmp401_attr[i].dev_attr); + + if (data->kind == tmp411) { + for (i = 0; i < ARRAY_SIZE(tmp411_attr); i++) + device_remove_file(&client->dev, + &tmp411_attr[i].dev_attr); + } + + kfree(data); + return 0; +} + +static struct tmp401_data *tmp401_update_device_reg16( + struct i2c_client *client, struct tmp401_data *data) +{ + int i; + + for (i = 0; i < 2; i++) { + /* + * High byte must be read first immediately followed + * by the low byte + */ + data->temp[i] = i2c_smbus_read_byte_data(client, + TMP401_TEMP_MSB[i]) << 8; + data->temp[i] |= i2c_smbus_read_byte_data(client, + TMP401_TEMP_LSB[i]); + data->temp_low[i] = i2c_smbus_read_byte_data(client, + TMP401_TEMP_LOW_LIMIT_MSB_READ[i]) << 8; + data->temp_low[i] |= i2c_smbus_read_byte_data(client, + TMP401_TEMP_LOW_LIMIT_LSB[i]); + data->temp_high[i] = i2c_smbus_read_byte_data(client, + TMP401_TEMP_HIGH_LIMIT_MSB_READ[i]) << 8; + data->temp_high[i] |= i2c_smbus_read_byte_data(client, + TMP401_TEMP_HIGH_LIMIT_LSB[i]); + data->temp_crit[i] = i2c_smbus_read_byte_data(client, + TMP401_TEMP_CRIT_LIMIT[i]); + + if (data->kind == tmp411) { + data->temp_lowest[i] = i2c_smbus_read_byte_data(client, + TMP411_TEMP_LOWEST_MSB[i]) << 8; + data->temp_lowest[i] |= i2c_smbus_read_byte_data( + client, TMP411_TEMP_LOWEST_LSB[i]); + + data->temp_highest[i] = i2c_smbus_read_byte_data( + client, TMP411_TEMP_HIGHEST_MSB[i]) << 8; + data->temp_highest[i] |= i2c_smbus_read_byte_data( + client, TMP411_TEMP_HIGHEST_LSB[i]); + } + } + return data; +} + +static struct tmp401_data *tmp401_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct tmp401_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { + data->status = i2c_smbus_read_byte_data(client, TMP401_STATUS); + data->config = i2c_smbus_read_byte_data(client, + TMP401_CONFIG_READ); + tmp401_update_device_reg16(client, data); + + data->temp_crit_hyst = i2c_smbus_read_byte_data(client, + TMP401_TEMP_CRIT_HYST); + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} static int __init tmp401_init(void) { diff --git a/trunk/drivers/leds/Kconfig b/trunk/drivers/leds/Kconfig index f98d17a7108b..505eb64c329c 100644 --- a/trunk/drivers/leds/Kconfig +++ b/trunk/drivers/leds/Kconfig @@ -67,16 +67,6 @@ config LEDS_NET48XX This option enables support for the Soekris net4801 and net4826 error LED. -config LEDS_NET5501 - tristate "LED Support for Soekris net5501 series Error LED" - depends on LEDS_CLASS && LEDS_TRIGGERS - depends on LEDS_GPIO_PLATFORM && GPIO_CS5535 - select LEDS_TRIGGER_DEFAULT_ON - default n - help - Add support for the Soekris net5501 board (detection, error led - and GPIO). - config LEDS_FSG tristate "LED Support for the Freecom FSG-3" depends on MACH_FSG @@ -295,13 +285,6 @@ config LEDS_DELL_NETBOOKS This adds support for the Latitude 2100 and similar notebooks that have an external LED. -config LEDS_MC13783 - tristate "LED Support for MC13783 PMIC" - depends on MFD_MC13783 - help - This option enable support for on-chip LED drivers found - on Freescale Semiconductor MC13783 PMIC. - config LEDS_TRIGGERS bool "LED Trigger support" help diff --git a/trunk/drivers/leds/Makefile b/trunk/drivers/leds/Makefile index 2493de499374..0cd8b9957380 100644 --- a/trunk/drivers/leds/Makefile +++ b/trunk/drivers/leds/Makefile @@ -13,7 +13,6 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o -obj-$(CONFIG_LEDS_NET5501) += leds-net5501.o obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o obj-$(CONFIG_LEDS_ALIX2) += leds-alix2.o obj-$(CONFIG_LEDS_H1940) += leds-h1940.o @@ -36,7 +35,6 @@ obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o -obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/trunk/drivers/leds/led-class.c b/trunk/drivers/leds/led-class.c index 260660076507..69e7d86a5143 100644 --- a/trunk/drivers/leds/led-class.c +++ b/trunk/drivers/leds/led-class.c @@ -74,7 +74,7 @@ static ssize_t led_max_brightness_show(struct device *dev, static struct device_attribute led_class_attrs[] = { __ATTR(brightness, 0644, led_brightness_show, led_brightness_store), - __ATTR(max_brightness, 0444, led_max_brightness_show, NULL), + __ATTR(max_brightness, 0644, led_max_brightness_show, NULL), #ifdef CONFIG_LEDS_TRIGGERS __ATTR(trigger, 0644, led_trigger_show, led_trigger_store), #endif diff --git a/trunk/drivers/leds/leds-88pm860x.c b/trunk/drivers/leds/leds-88pm860x.c index b7677106cff8..16a60c06c96c 100644 --- a/trunk/drivers/leds/leds-88pm860x.c +++ b/trunk/drivers/leds/leds-88pm860x.c @@ -256,10 +256,8 @@ static int pm860x_led_probe(struct platform_device *pdev) if (pdev->dev.parent->platform_data) { pm860x_pdata = pdev->dev.parent->platform_data; pdata = pm860x_pdata->led; - } else { - dev_err(&pdev->dev, "missing platform data\n"); - return -EINVAL; - } + } else + pdata = NULL; data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL); if (data == NULL) @@ -270,11 +268,8 @@ static int pm860x_led_probe(struct platform_device *pdev) data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; data->iset = pdata->iset; data->port = __check_device(pdata, data->name); - if (data->port < 0) { - dev_err(&pdev->dev, "check device failed\n"); - kfree(data); + if (data->port < 0) return -EINVAL; - } data->current_brightness = 0; data->cdev.name = data->name; diff --git a/trunk/drivers/leds/leds-gpio.c b/trunk/drivers/leds/leds-gpio.c index 26843dd6b859..6d94b0b9979c 100644 --- a/trunk/drivers/leds/leds-gpio.c +++ b/trunk/drivers/leds/leds-gpio.c @@ -26,8 +26,7 @@ struct gpio_led_data { u8 new_level; u8 can_sleep; u8 active_low; - u8 blinking; - int (*platform_gpio_blink_set)(unsigned gpio, int state, + int (*platform_gpio_blink_set)(unsigned gpio, unsigned long *delay_on, unsigned long *delay_off); }; @@ -36,13 +35,7 @@ static void gpio_led_work(struct work_struct *work) struct gpio_led_data *led_dat = container_of(work, struct gpio_led_data, work); - if (led_dat->blinking) { - led_dat->platform_gpio_blink_set(led_dat->gpio, - led_dat->new_level, - NULL, NULL); - led_dat->blinking = 0; - } else - gpio_set_value_cansleep(led_dat->gpio, led_dat->new_level); + gpio_set_value_cansleep(led_dat->gpio, led_dat->new_level); } static void gpio_led_set(struct led_classdev *led_cdev, @@ -67,14 +60,8 @@ static void gpio_led_set(struct led_classdev *led_cdev, if (led_dat->can_sleep) { led_dat->new_level = level; schedule_work(&led_dat->work); - } else { - if (led_dat->blinking) { - led_dat->platform_gpio_blink_set(led_dat->gpio, level, - NULL, NULL); - led_dat->blinking = 0; - } else - gpio_set_value(led_dat->gpio, level); - } + } else + gpio_set_value(led_dat->gpio, level); } static int gpio_blink_set(struct led_classdev *led_cdev, @@ -83,14 +70,12 @@ static int gpio_blink_set(struct led_classdev *led_cdev, struct gpio_led_data *led_dat = container_of(led_cdev, struct gpio_led_data, cdev); - led_dat->blinking = 1; - return led_dat->platform_gpio_blink_set(led_dat->gpio, GPIO_LED_BLINK, - delay_on, delay_off); + return led_dat->platform_gpio_blink_set(led_dat->gpio, delay_on, delay_off); } static int __devinit create_gpio_led(const struct gpio_led *template, struct gpio_led_data *led_dat, struct device *parent, - int (*blink_set)(unsigned, int, unsigned long *, unsigned long *)) + int (*blink_set)(unsigned, unsigned long *, unsigned long *)) { int ret, state; @@ -112,7 +97,6 @@ static int __devinit create_gpio_led(const struct gpio_led *template, led_dat->gpio = template->gpio; led_dat->can_sleep = gpio_cansleep(template->gpio); led_dat->active_low = template->active_low; - led_dat->blinking = 0; if (blink_set) { led_dat->platform_gpio_blink_set = blink_set; led_dat->cdev.blink_set = gpio_blink_set; @@ -129,7 +113,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template, ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state); if (ret < 0) goto err; - + INIT_WORK(&led_dat->work, gpio_led_work); ret = led_classdev_register(parent, &led_dat->cdev); @@ -250,7 +234,6 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev, led.gpio = of_get_gpio_flags(child, 0, &flags); led.active_low = flags & OF_GPIO_ACTIVE_LOW; led.name = of_get_property(child, "label", NULL) ? : child->name; - led.blinking = 0; led.default_trigger = of_get_property(child, "linux,default-trigger", NULL); state = of_get_property(child, "default-state", NULL); diff --git a/trunk/drivers/leds/leds-lp3944.c b/trunk/drivers/leds/leds-lp3944.c index 932a58da76c4..8d5ecceba181 100644 --- a/trunk/drivers/leds/leds-lp3944.c +++ b/trunk/drivers/leds/leds-lp3944.c @@ -379,7 +379,6 @@ static int __devinit lp3944_probe(struct i2c_client *client, { struct lp3944_platform_data *lp3944_pdata = client->dev.platform_data; struct lp3944_data *data; - int err; if (lp3944_pdata == NULL) { dev_err(&client->dev, "no platform data\n"); @@ -402,13 +401,9 @@ static int __devinit lp3944_probe(struct i2c_client *client, mutex_init(&data->lock); - err = lp3944_configure(client, data, lp3944_pdata); - if (err < 0) { - kfree(data); - return err; - } - dev_info(&client->dev, "lp3944 enabled\n"); + + lp3944_configure(client, data, lp3944_pdata); return 0; } diff --git a/trunk/drivers/leds/leds-mc13783.c b/trunk/drivers/leds/leds-mc13783.c deleted file mode 100644 index f05bb08d0f09..000000000000 --- a/trunk/drivers/leds/leds-mc13783.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * LEDs driver for Freescale MC13783 - * - * Copyright (C) 2010 Philippe Rétornaz - * - * Based on leds-da903x: - * Copyright (C) 2008 Compulab, Ltd. - * Mike Rapoport - * - * Copyright (C) 2006-2008 Marvell International Ltd. - * Eric Miao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -struct mc13783_led { - struct led_classdev cdev; - struct work_struct work; - struct mc13783 *master; - enum led_brightness new_brightness; - int id; -}; - -#define MC13783_REG_LED_CONTROL_0 51 -#define MC13783_LED_C0_ENABLE_BIT (1 << 0) -#define MC13783_LED_C0_TRIODE_MD_BIT (1 << 7) -#define MC13783_LED_C0_TRIODE_AD_BIT (1 << 8) -#define MC13783_LED_C0_TRIODE_KP_BIT (1 << 9) -#define MC13783_LED_C0_BOOST_BIT (1 << 10) -#define MC13783_LED_C0_ABMODE_MASK 0x7 -#define MC13783_LED_C0_ABMODE 11 -#define MC13783_LED_C0_ABREF_MASK 0x3 -#define MC13783_LED_C0_ABREF 14 - -#define MC13783_REG_LED_CONTROL_1 52 -#define MC13783_LED_C1_TC1HALF_BIT (1 << 18) - -#define MC13783_REG_LED_CONTROL_2 53 -#define MC13783_LED_C2_BL_P_MASK 0xf -#define MC13783_LED_C2_MD_P 9 -#define MC13783_LED_C2_AD_P 13 -#define MC13783_LED_C2_KP_P 17 -#define MC13783_LED_C2_BL_C_MASK 0x7 -#define MC13783_LED_C2_MD_C 0 -#define MC13783_LED_C2_AD_C 3 -#define MC13783_LED_C2_KP_C 6 - -#define MC13783_REG_LED_CONTROL_3 54 -#define MC13783_LED_C3_TC_P 6 -#define MC13783_LED_C3_TC_P_MASK 0x1f - -#define MC13783_REG_LED_CONTROL_4 55 -#define MC13783_REG_LED_CONTROL_5 56 - -#define MC13783_LED_Cx_PERIOD 21 -#define MC13783_LED_Cx_PERIOD_MASK 0x3 -#define MC13783_LED_Cx_SLEWLIM_BIT (1 << 23) -#define MC13783_LED_Cx_TRIODE_TC_BIT (1 << 23) -#define MC13783_LED_Cx_TC_C_MASK 0x3 - -static void mc13783_led_work(struct work_struct *work) -{ - struct mc13783_led *led = container_of(work, struct mc13783_led, work); - int reg = 0; - int mask = 0; - int value = 0; - int bank, off, shift; - - switch (led->id) { - case MC13783_LED_MD: - reg = MC13783_REG_LED_CONTROL_2; - mask = MC13783_LED_C2_BL_P_MASK << MC13783_LED_C2_MD_P; - value = (led->new_brightness >> 4) << MC13783_LED_C2_MD_P; - break; - case MC13783_LED_AD: - reg = MC13783_REG_LED_CONTROL_2; - mask = MC13783_LED_C2_BL_P_MASK << MC13783_LED_C2_AD_P; - value = (led->new_brightness >> 4) << MC13783_LED_C2_AD_P; - break; - case MC13783_LED_KP: - reg = MC13783_REG_LED_CONTROL_2; - mask = MC13783_LED_C2_BL_P_MASK << MC13783_LED_C2_KP_P; - value = (led->new_brightness >> 4) << MC13783_LED_C2_KP_P; - break; - case MC13783_LED_R1: - case MC13783_LED_G1: - case MC13783_LED_B1: - case MC13783_LED_R2: - case MC13783_LED_G2: - case MC13783_LED_B2: - case MC13783_LED_R3: - case MC13783_LED_G3: - case MC13783_LED_B3: - off = led->id - MC13783_LED_R1; - bank = off/3; - reg = MC13783_REG_LED_CONTROL_3 + off/3; - shift = (off - bank * 3) * 5 + MC13783_LED_C3_TC_P; - value = (led->new_brightness >> 3) << shift; - mask = MC13783_LED_C3_TC_P_MASK << shift; - break; - } - - mc13783_lock(led->master); - - mc13783_reg_rmw(led->master, reg, mask, value); - - mc13783_unlock(led->master); -} - -static void mc13783_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct mc13783_led *led; - - led = container_of(led_cdev, struct mc13783_led, cdev); - led->new_brightness = value; - schedule_work(&led->work); -} - -static int __devinit mc13783_led_setup(struct mc13783_led *led, int max_current) -{ - int shift = 0; - int mask = 0; - int value = 0; - int reg = 0; - int ret, bank; - - switch (led->id) { - case MC13783_LED_MD: - shift = MC13783_LED_C2_MD_C; - mask = MC13783_LED_C2_BL_C_MASK; - value = max_current & MC13783_LED_C2_BL_C_MASK; - reg = MC13783_REG_LED_CONTROL_2; - break; - case MC13783_LED_AD: - shift = MC13783_LED_C2_AD_C; - mask = MC13783_LED_C2_BL_C_MASK; - value = max_current & MC13783_LED_C2_BL_C_MASK; - reg = MC13783_REG_LED_CONTROL_2; - break; - case MC13783_LED_KP: - shift = MC13783_LED_C2_KP_C; - mask = MC13783_LED_C2_BL_C_MASK; - value = max_current & MC13783_LED_C2_BL_C_MASK; - reg = MC13783_REG_LED_CONTROL_2; - break; - case MC13783_LED_R1: - case MC13783_LED_G1: - case MC13783_LED_B1: - case MC13783_LED_R2: - case MC13783_LED_G2: - case MC13783_LED_B2: - case MC13783_LED_R3: - case MC13783_LED_G3: - case MC13783_LED_B3: - bank = (led->id - MC13783_LED_R1)/3; - reg = MC13783_REG_LED_CONTROL_3 + bank; - shift = ((led->id - MC13783_LED_R1) - bank * 3) * 2; - mask = MC13783_LED_Cx_TC_C_MASK; - value = max_current & MC13783_LED_Cx_TC_C_MASK; - break; - } - - mc13783_lock(led->master); - - ret = mc13783_reg_rmw(led->master, reg, mask << shift, - value << shift); - - mc13783_unlock(led->master); - return ret; -} - -static int __devinit mc13783_leds_prepare(struct platform_device *pdev) -{ - struct mc13783_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); - struct mc13783 *dev = dev_get_drvdata(pdev->dev.parent); - int ret = 0; - int reg = 0; - - mc13783_lock(dev); - - if (pdata->flags & MC13783_LED_TC1HALF) - reg |= MC13783_LED_C1_TC1HALF_BIT; - - if (pdata->flags & MC13783_LED_SLEWLIMTC) - reg |= MC13783_LED_Cx_SLEWLIM_BIT; - - ret = mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_1, reg); - if (ret) - goto out; - - reg = (pdata->bl_period & MC13783_LED_Cx_PERIOD_MASK) << - MC13783_LED_Cx_PERIOD; - - if (pdata->flags & MC13783_LED_SLEWLIMBL) - reg |= MC13783_LED_Cx_SLEWLIM_BIT; - - ret = mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_2, reg); - if (ret) - goto out; - - reg = (pdata->tc1_period & MC13783_LED_Cx_PERIOD_MASK) << - MC13783_LED_Cx_PERIOD; - - if (pdata->flags & MC13783_LED_TRIODE_TC1) - reg |= MC13783_LED_Cx_TRIODE_TC_BIT; - - ret = mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_3, reg); - if (ret) - goto out; - - reg = (pdata->tc2_period & MC13783_LED_Cx_PERIOD_MASK) << - MC13783_LED_Cx_PERIOD; - - if (pdata->flags & MC13783_LED_TRIODE_TC2) - reg |= MC13783_LED_Cx_TRIODE_TC_BIT; - - ret = mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_4, reg); - if (ret) - goto out; - - reg = (pdata->tc3_period & MC13783_LED_Cx_PERIOD_MASK) << - MC13783_LED_Cx_PERIOD; - - if (pdata->flags & MC13783_LED_TRIODE_TC3) - reg |= MC13783_LED_Cx_TRIODE_TC_BIT;; - - ret = mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_5, reg); - if (ret) - goto out; - - reg = MC13783_LED_C0_ENABLE_BIT; - if (pdata->flags & MC13783_LED_TRIODE_MD) - reg |= MC13783_LED_C0_TRIODE_MD_BIT; - if (pdata->flags & MC13783_LED_TRIODE_AD) - reg |= MC13783_LED_C0_TRIODE_AD_BIT; - if (pdata->flags & MC13783_LED_TRIODE_KP) - reg |= MC13783_LED_C0_TRIODE_KP_BIT; - if (pdata->flags & MC13783_LED_BOOST_EN) - reg |= MC13783_LED_C0_BOOST_BIT; - - reg |= (pdata->abmode & MC13783_LED_C0_ABMODE_MASK) << - MC13783_LED_C0_ABMODE; - reg |= (pdata->abref & MC13783_LED_C0_ABREF_MASK) << - MC13783_LED_C0_ABREF; - - ret = mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_0, reg); - -out: - mc13783_unlock(dev); - return ret; -} - -static int __devinit mc13783_led_probe(struct platform_device *pdev) -{ - struct mc13783_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); - struct mc13783_led_platform_data *led_cur; - struct mc13783_led *led, *led_dat; - int ret, i; - int init_led = 0; - - if (pdata == NULL) { - dev_err(&pdev->dev, "missing platform data\n"); - return -ENODEV; - } - - if (pdata->num_leds < 1 || pdata->num_leds > MC13783_LED_MAX) { - dev_err(&pdev->dev, "Invalid led count %d\n", pdata->num_leds); - return -EINVAL; - } - - led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); - if (led == NULL) { - dev_err(&pdev->dev, "failed to alloc memory\n"); - return -ENOMEM; - } - - ret = mc13783_leds_prepare(pdev); - if (ret) { - dev_err(&pdev->dev, "unable to init led driver\n"); - goto err_free; - } - - for (i = 0; i < pdata->num_leds; i++) { - led_dat = &led[i]; - led_cur = &pdata->led[i]; - - if (led_cur->id > MC13783_LED_MAX || led_cur->id < 0) { - dev_err(&pdev->dev, "invalid id %d\n", led_cur->id); - ret = -EINVAL; - goto err_register; - } - - if (init_led & (1 << led_cur->id)) { - dev_err(&pdev->dev, "led %d already initialized\n", - led_cur->id); - ret = -EINVAL; - goto err_register; - } - - init_led |= 1 << led_cur->id; - led_dat->cdev.name = led_cur->name; - led_dat->cdev.default_trigger = led_cur->default_trigger; - led_dat->cdev.brightness_set = mc13783_led_set; - led_dat->cdev.brightness = LED_OFF; - led_dat->id = led_cur->id; - led_dat->master = dev_get_drvdata(pdev->dev.parent); - - INIT_WORK(&led_dat->work, mc13783_led_work); - - ret = led_classdev_register(pdev->dev.parent, &led_dat->cdev); - if (ret) { - dev_err(&pdev->dev, "failed to register led %d\n", - led_dat->id); - goto err_register; - } - - ret = mc13783_led_setup(led_dat, led_cur->max_current); - if (ret) { - dev_err(&pdev->dev, "unable to init led %d\n", - led_dat->id); - i++; - goto err_register; - } - } - - platform_set_drvdata(pdev, led); - return 0; - -err_register: - for (i = i - 1; i >= 0; i--) { - led_classdev_unregister(&led[i].cdev); - cancel_work_sync(&led[i].work); - } - -err_free: - kfree(led); - return ret; -} - -static int __devexit mc13783_led_remove(struct platform_device *pdev) -{ - struct mc13783_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); - struct mc13783_led *led = platform_get_drvdata(pdev); - struct mc13783 *dev = dev_get_drvdata(pdev->dev.parent); - int i; - - for (i = 0; i < pdata->num_leds; i++) { - led_classdev_unregister(&led[i].cdev); - cancel_work_sync(&led[i].work); - } - - mc13783_lock(dev); - - mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_0, 0); - mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_1, 0); - mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_2, 0); - mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_3, 0); - mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_4, 0); - mc13783_reg_write(dev, MC13783_REG_LED_CONTROL_5, 0); - - mc13783_unlock(dev); - - kfree(led); - return 0; -} - -static struct platform_driver mc13783_led_driver = { - .driver = { - .name = "mc13783-led", - .owner = THIS_MODULE, - }, - .probe = mc13783_led_probe, - .remove = __devexit_p(mc13783_led_remove), -}; - -static int __init mc13783_led_init(void) -{ - return platform_driver_register(&mc13783_led_driver); -} -module_init(mc13783_led_init); - -static void __exit mc13783_led_exit(void) -{ - platform_driver_unregister(&mc13783_led_driver); -} -module_exit(mc13783_led_exit); - -MODULE_DESCRIPTION("LEDs driver for Freescale MC13783 PMIC"); -MODULE_AUTHOR("Philippe Retornaz "); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:mc13783-led"); diff --git a/trunk/drivers/leds/leds-net5501.c b/trunk/drivers/leds/leds-net5501.c deleted file mode 100644 index 3063f591f0dc..000000000000 --- a/trunk/drivers/leds/leds-net5501.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Soekris board support code - * - * Copyright (C) 2008-2009 Tower Technologies - * Written by Alessandro Zummo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -static struct gpio_led net5501_leds[] = { - { - .name = "error", - .gpio = 6, - .default_trigger = "default-on", - }, -}; - -static struct gpio_led_platform_data net5501_leds_data = { - .num_leds = ARRAY_SIZE(net5501_leds), - .leds = net5501_leds, -}; - -static struct platform_device net5501_leds_dev = { - .name = "leds-gpio", - .id = -1, - .dev.platform_data = &net5501_leds_data, -}; - -static void __init init_net5501(void) -{ - platform_device_register(&net5501_leds_dev); -} - -struct soekris_board { - u16 offset; - char *sig; - u8 len; - void (*init)(void); -}; - -static struct soekris_board __initdata boards[] = { - { 0xb7b, "net5501", 7, init_net5501 }, /* net5501 v1.33/1.33c */ - { 0xb1f, "net5501", 7, init_net5501 }, /* net5501 v1.32i */ -}; - -static int __init soekris_init(void) -{ - int i; - unsigned char *rombase, *bios; - - if (!is_geode()) - return 0; - - rombase = ioremap(0xffff0000, 0xffff); - if (!rombase) { - printk(KERN_INFO "Soekris net5501 LED driver failed to get rombase"); - return 0; - } - - bios = rombase + 0x20; /* null terminated */ - - if (strncmp(bios, "comBIOS", 7)) - goto unmap; - - for (i = 0; i < ARRAY_SIZE(boards); i++) { - unsigned char *model = rombase + boards[i].offset; - - if (strncmp(model, boards[i].sig, boards[i].len) == 0) { - printk(KERN_INFO "Soekris %s: %s\n", model, bios); - - if (boards[i].init) - boards[i].init(); - break; - } - } - -unmap: - iounmap(rombase); - return 0; -} - -arch_initcall(soekris_init); diff --git a/trunk/drivers/leds/leds-ss4200.c b/trunk/drivers/leds/leds-ss4200.c index a688293abd0b..51477ec71391 100644 --- a/trunk/drivers/leds/leds-ss4200.c +++ b/trunk/drivers/leds/leds-ss4200.c @@ -534,7 +534,7 @@ static int __init nas_gpio_init(void) set_power_light_amber_noblink(); return 0; out_err: - for (i--; i >= 0; i--) + for (; i >= 0; i--) unregister_nasgpio_led(i); pci_unregister_driver(&nas_gpio_pci_driver); return ret; diff --git a/trunk/drivers/mfd/mc13783-core.c b/trunk/drivers/mfd/mc13783-core.c index fecf38a4f025..1f68ecadddc2 100644 --- a/trunk/drivers/mfd/mc13783-core.c +++ b/trunk/drivers/mfd/mc13783-core.c @@ -679,10 +679,6 @@ static int mc13783_probe(struct spi_device *spi) if (pdata->flags & MC13783_USE_TOUCHSCREEN) mc13783_add_subdevice(mc13783, "mc13783-ts"); - if (pdata->flags & MC13783_USE_LED) - mc13783_add_subdevice_pdata(mc13783, "mc13783-led", - pdata->leds, sizeof(*pdata->leds)); - return 0; } diff --git a/trunk/drivers/mfd/pcf50633-core.c b/trunk/drivers/mfd/pcf50633-core.c index dc95ddb708f1..63a614d696c1 100644 --- a/trunk/drivers/mfd/pcf50633-core.c +++ b/trunk/drivers/mfd/pcf50633-core.c @@ -620,9 +620,6 @@ static int __devinit pcf50633_probe(struct i2c_client *client, &pcf->mbc_pdev); pcf50633_client_dev_register(pcf, "pcf50633-adc", &pcf->adc_pdev); - pcf50633_client_dev_register(pcf, "pcf50633-backlight", - &pcf->bl_pdev); - for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { struct platform_device *pdev; diff --git a/trunk/drivers/video/backlight/88pm860x_bl.c b/trunk/drivers/video/backlight/88pm860x_bl.c index 38ffc3fbcbe4..68d2518fadaa 100644 --- a/trunk/drivers/video/backlight/88pm860x_bl.c +++ b/trunk/drivers/video/backlight/88pm860x_bl.c @@ -222,7 +222,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) data->port = __check_device(pdata, name); if (data->port < 0) { dev_err(&pdev->dev, "wrong platform data is assigned"); - kfree(data); return -EINVAL; } @@ -267,7 +266,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) backlight_update_status(bl); return 0; out: - backlight_device_unregister(bl); kfree(data); return ret; } diff --git a/trunk/drivers/video/backlight/Kconfig b/trunk/drivers/video/backlight/Kconfig index e54a337227ea..c025c84601b0 100644 --- a/trunk/drivers/video/backlight/Kconfig +++ b/trunk/drivers/video/backlight/Kconfig @@ -8,13 +8,12 @@ menuconfig BACKLIGHT_LCD_SUPPORT Enable this to be able to choose the drivers for controlling the backlight and the LCD panel on some platforms, for example on PDAs. -if BACKLIGHT_LCD_SUPPORT - # # LCD # config LCD_CLASS_DEVICE tristate "Lowlevel LCD controls" + depends on BACKLIGHT_LCD_SUPPORT default m help This framework adds support for low-level control of LCD. @@ -25,32 +24,31 @@ config LCD_CLASS_DEVICE To have support for your specific LCD panel you will have to select the proper drivers which depend on this option. -if LCD_CLASS_DEVICE - config LCD_CORGI tristate "LCD Panel support for SHARP corgi/spitz model" - depends on SPI_MASTER && PXA_SHARPSL + depends on LCD_CLASS_DEVICE && SPI_MASTER && PXA_SHARPSL help Say y here to support the LCD panels usually found on SHARP corgi (C7x0) and spitz (Cxx00) models. config LCD_L4F00242T03 tristate "Epson L4F00242T03 LCD" - depends on SPI_MASTER && GENERIC_GPIO + depends on LCD_CLASS_DEVICE && SPI_MASTER && GENERIC_GPIO help SPI driver for Epson L4F00242T03. This provides basic support for init and powering the LCD up/down through a sysfs interface. config LCD_LMS283GF05 tristate "Samsung LMS283GF05 LCD" - depends on SPI_MASTER && GENERIC_GPIO + depends on LCD_CLASS_DEVICE && SPI_MASTER && GENERIC_GPIO help SPI driver for Samsung LMS283GF05. This provides basic support for powering the LCD up/down through a sysfs interface. config LCD_LTV350QV tristate "Samsung LTV350QV LCD Panel" - depends on SPI_MASTER + depends on LCD_CLASS_DEVICE && SPI_MASTER + default n help If you have a Samsung LTV350QV LCD panel, say y to include a power control driver for it. The panel starts up in power @@ -61,61 +59,60 @@ config LCD_LTV350QV config LCD_ILI9320 tristate + depends on LCD_CLASS_DEVICE && BACKLIGHT_LCD_SUPPORT + default n help If you have a panel based on the ILI9320 controller chip then say y to include a power driver for it. config LCD_TDO24M tristate "Toppoly TDO24M and TDO35S LCD Panels support" - depends on SPI_MASTER + depends on LCD_CLASS_DEVICE && SPI_MASTER + default n help If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to include the support for it. config LCD_VGG2432A4 tristate "VGG2432A4 LCM device support" - depends on SPI_MASTER + depends on BACKLIGHT_LCD_SUPPORT && LCD_CLASS_DEVICE && SPI_MASTER select LCD_ILI9320 + default n help If you have a VGG2432A4 panel based on the ILI9320 controller chip then say y to include a power driver for it. config LCD_PLATFORM tristate "Platform LCD controls" + depends on LCD_CLASS_DEVICE help This driver provides a platform-device registered LCD power control interface. config LCD_TOSA tristate "Sharp SL-6000 LCD Driver" - depends on SPI && MACH_TOSA + depends on LCD_CLASS_DEVICE && SPI + depends on MACH_TOSA + default n help If you have an Sharp SL-6000 Zaurus say Y to enable a driver for its LCD. config LCD_HP700 tristate "HP Jornada 700 series LCD Driver" + depends on LCD_CLASS_DEVICE depends on SA1100_JORNADA720_SSP && !PREEMPT default y help If you have an HP Jornada 700 series handheld (710/720/728) say Y to enable LCD control driver. -config LCD_S6E63M0 - tristate "S6E63M0 AMOLED LCD Driver" - depends on SPI && BACKLIGHT_CLASS_DEVICE - default n - help - If you have an S6E63M0 LCD Panel, say Y to enable its - LCD control driver. - -endif # LCD_CLASS_DEVICE - # # Backlight # config BACKLIGHT_CLASS_DEVICE tristate "Lowlevel Backlight controls" + depends on BACKLIGHT_LCD_SUPPORT default m help This framework adds support for low-level control of the LCD @@ -124,11 +121,9 @@ config BACKLIGHT_CLASS_DEVICE To have support for your specific LCD panel you will have to select the proper drivers which depend on this option. -if BACKLIGHT_CLASS_DEVICE - config BACKLIGHT_ATMEL_LCDC bool "Atmel LCDC Contrast-as-Backlight control" - depends on FB_ATMEL + depends on BACKLIGHT_CLASS_DEVICE && FB_ATMEL default y if MACH_SAM9261EK || MACH_SAM9G10EK || MACH_SAM9263EK help This provides a backlight control internal to the Atmel LCDC @@ -141,7 +136,8 @@ config BACKLIGHT_ATMEL_LCDC config BACKLIGHT_ATMEL_PWM tristate "Atmel PWM backlight control" - depends on ATMEL_PWM + depends on BACKLIGHT_CLASS_DEVICE && ATMEL_PWM + default n help Say Y here if you want to use the PWM peripheral in Atmel AT91 and AVR32 devices. This driver will need additional platform data to know @@ -150,18 +146,9 @@ config BACKLIGHT_ATMEL_PWM To compile this driver as a module, choose M here: the module will be called atmel-pwm-bl. -config BACKLIGHT_EP93XX - tristate "Cirrus EP93xx Backlight Driver" - depends on FB_EP93XX - help - If you have a LCD backlight connected to the BRIGHT output of - the EP93xx, say Y here to enable this driver. - - To compile this driver as a module, choose M here: the module will - be called ep93xx_bl. - config BACKLIGHT_GENERIC tristate "Generic (aka Sharp Corgi) Backlight Driver" + depends on BACKLIGHT_CLASS_DEVICE default y help Say y to enable the generic platform backlight driver previously @@ -170,7 +157,7 @@ config BACKLIGHT_GENERIC config BACKLIGHT_LOCOMO tristate "Sharp LOCOMO LCD/Backlight Driver" - depends on SHARP_LOCOMO + depends on BACKLIGHT_CLASS_DEVICE && SHARP_LOCOMO default y help If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to @@ -178,7 +165,7 @@ config BACKLIGHT_LOCOMO config BACKLIGHT_OMAP1 tristate "OMAP1 PWL-based LCD Backlight" - depends on ARCH_OMAP1 + depends on BACKLIGHT_CLASS_DEVICE && ARCH_OMAP1 default y help This driver controls the LCD backlight level and power for @@ -187,7 +174,7 @@ config BACKLIGHT_OMAP1 config BACKLIGHT_HP680 tristate "HP Jornada 680 Backlight Driver" - depends on SH_HP6XX + depends on BACKLIGHT_CLASS_DEVICE && SH_HP6XX default y help If you have a HP Jornada 680, say y to enable the @@ -195,6 +182,7 @@ config BACKLIGHT_HP680 config BACKLIGHT_HP700 tristate "HP Jornada 700 series Backlight Driver" + depends on BACKLIGHT_CLASS_DEVICE depends on SA1100_JORNADA720_SSP && !PREEMPT default y help @@ -203,70 +191,76 @@ config BACKLIGHT_HP700 config BACKLIGHT_PROGEAR tristate "Frontpath ProGear Backlight Driver" - depends on PCI && X86 + depends on BACKLIGHT_CLASS_DEVICE && PCI && X86 + default n help If you have a Frontpath ProGear say Y to enable the backlight driver. config BACKLIGHT_CARILLO_RANCH tristate "Intel Carillo Ranch Backlight Driver" - depends on LCD_CLASS_DEVICE && PCI && X86 && FB_LE80578 + depends on BACKLIGHT_CLASS_DEVICE && LCD_CLASS_DEVICE && PCI && X86 && FB_LE80578 + default n help If you have a Intel LE80578 (Carillo Ranch) say Y to enable the backlight driver. config BACKLIGHT_PWM tristate "Generic PWM based Backlight Driver" - depends on HAVE_PWM + depends on BACKLIGHT_CLASS_DEVICE && HAVE_PWM help If you have a LCD backlight adjustable by PWM, say Y to enable this driver. config BACKLIGHT_DA903X tristate "Backlight Driver for DA9030/DA9034 using WLED" - depends on PMIC_DA903X + depends on BACKLIGHT_CLASS_DEVICE && PMIC_DA903X help If you have a LCD backlight connected to the WLED output of DA9030 or DA9034 WLED output, say Y here to enable this driver. config BACKLIGHT_MAX8925 tristate "Backlight driver for MAX8925" - depends on MFD_MAX8925 + depends on BACKLIGHT_CLASS_DEVICE && MFD_MAX8925 help If you have a LCD backlight connected to the WLED output of MAX8925 WLED output, say Y here to enable this driver. config BACKLIGHT_MBP_NVIDIA tristate "MacBook Pro Nvidia Backlight Driver" - depends on X86 + depends on BACKLIGHT_CLASS_DEVICE && X86 + default n help If you have an Apple Macbook Pro with Nvidia graphics hardware say Y to enable a driver for its backlight config BACKLIGHT_TOSA tristate "Sharp SL-6000 Backlight Driver" - depends on I2C && MACH_TOSA && LCD_TOSA + depends on BACKLIGHT_CLASS_DEVICE && I2C + depends on MACH_TOSA && LCD_TOSA + default n help If you have an Sharp SL-6000 Zaurus say Y to enable a driver for its backlight config BACKLIGHT_SAHARA tristate "Tabletkiosk Sahara Touch-iT Backlight Driver" - depends on X86 + depends on BACKLIGHT_CLASS_DEVICE && X86 + default n help If you have a Tabletkiosk Sahara Touch-iT, say y to enable the backlight driver. config BACKLIGHT_WM831X tristate "WM831x PMIC Backlight Driver" - depends on MFD_WM831X + depends on BACKLIGHT_CLASS_DEVICE && MFD_WM831X help If you have a backlight driven by the ISINK and DCDC of a WM831x PMIC say y to enable the backlight driver for it. config BACKLIGHT_ADX tristate "Avionic Design Xanthos Backlight Driver" - depends on ARCH_PXA_ADX + depends on BACKLIGHT_CLASS_DEVICE && ARCH_PXA_ADX default y help Say Y to enable the backlight driver on Avionic Design Xanthos-based @@ -274,7 +268,7 @@ config BACKLIGHT_ADX config BACKLIGHT_ADP5520 tristate "Backlight Driver for ADP5520/ADP5501 using WLED" - depends on PMIC_ADP5520 + depends on BACKLIGHT_CLASS_DEVICE && PMIC_ADP5520 help If you have a LCD backlight connected to the BST/BL_SNK output of ADP5520 or ADP5501, say Y here to enable this driver. @@ -282,31 +276,9 @@ config BACKLIGHT_ADP5520 To compile this driver as a module, choose M here: the module will be called adp5520_bl. -config BACKLIGHT_ADP8860 - tristate "Backlight Driver for ADP8860/ADP8861/ADP8863 using WLED" - depends on BACKLIGHT_CLASS_DEVICE && I2C - select NEW_LEDS - select LEDS_CLASS - help - If you have a LCD backlight connected to the ADP8860, ADP8861 or - ADP8863 say Y here to enable this driver. - - To compile this driver as a module, choose M here: the module will - be called adp8860_bl. - config BACKLIGHT_88PM860X tristate "Backlight Driver for 88PM8606 using WLED" - depends on MFD_88PM860X + depends on BACKLIGHT_CLASS_DEVICE && MFD_88PM860X help Say Y to enable the backlight driver for Marvell 88PM8606. -config BACKLIGHT_PCF50633 - tristate "Backlight driver for NXP PCF50633 MFD" - depends on BACKLIGHT_CLASS_DEVICE && MFD_PCF50633 - help - If you have a backlight driven by a NXP PCF50633 MFD, say Y here to - enable its driver. - -endif # BACKLIGHT_CLASS_DEVICE - -endif # BACKLIGHT_LCD_SUPPORT diff --git a/trunk/drivers/video/backlight/Makefile b/trunk/drivers/video/backlight/Makefile index 44c0f81ad85d..09d1f14d6257 100644 --- a/trunk/drivers/video/backlight/Makefile +++ b/trunk/drivers/video/backlight/Makefile @@ -11,11 +11,9 @@ obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o obj-$(CONFIG_LCD_TDO24M) += tdo24m.o obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o -obj-$(CONFIG_LCD_S6E63M0) += s6e63m0.o obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o -obj-$(CONFIG_BACKLIGHT_EP93XX) += ep93xx_bl.o obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o @@ -32,7 +30,5 @@ obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o obj-$(CONFIG_BACKLIGHT_ADX) += adx_bl.o obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o -obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o -obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o diff --git a/trunk/drivers/video/backlight/adp8860_bl.c b/trunk/drivers/video/backlight/adp8860_bl.c deleted file mode 100644 index 921ca37398f3..000000000000 --- a/trunk/drivers/video/backlight/adp8860_bl.c +++ /dev/null @@ -1,838 +0,0 @@ -/* - * Backlight driver for Analog Devices ADP8860 Backlight Devices - * - * Copyright 2009-2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#define ADP8860_EXT_FEATURES -#define ADP8860_USE_LEDS - -#define ADP8860_MFDVID 0x00 /* Manufacturer and device ID */ -#define ADP8860_MDCR 0x01 /* Device mode and status */ -#define ADP8860_MDCR2 0x02 /* Device mode and Status Register 2 */ -#define ADP8860_INTR_EN 0x03 /* Interrupts enable */ -#define ADP8860_CFGR 0x04 /* Configuration register */ -#define ADP8860_BLSEN 0x05 /* Sink enable backlight or independent */ -#define ADP8860_BLOFF 0x06 /* Backlight off timeout */ -#define ADP8860_BLDIM 0x07 /* Backlight dim timeout */ -#define ADP8860_BLFR 0x08 /* Backlight fade in and out rates */ -#define ADP8860_BLMX1 0x09 /* Backlight (Brightness Level 1-daylight) maximum current */ -#define ADP8860_BLDM1 0x0A /* Backlight (Brightness Level 1-daylight) dim current */ -#define ADP8860_BLMX2 0x0B /* Backlight (Brightness Level 2-office) maximum current */ -#define ADP8860_BLDM2 0x0C /* Backlight (Brightness Level 2-office) dim current */ -#define ADP8860_BLMX3 0x0D /* Backlight (Brightness Level 3-dark) maximum current */ -#define ADP8860_BLDM3 0x0E /* Backlight (Brightness Level 3-dark) dim current */ -#define ADP8860_ISCFR 0x0F /* Independent sink current fade control register */ -#define ADP8860_ISCC 0x10 /* Independent sink current control register */ -#define ADP8860_ISCT1 0x11 /* Independent Sink Current Timer Register LED[7:5] */ -#define ADP8860_ISCT2 0x12 /* Independent Sink Current Timer Register LED[4:1] */ -#define ADP8860_ISCF 0x13 /* Independent sink current fade register */ -#define ADP8860_ISC7 0x14 /* Independent Sink Current LED7 */ -#define ADP8860_ISC6 0x15 /* Independent Sink Current LED6 */ -#define ADP8860_ISC5 0x16 /* Independent Sink Current LED5 */ -#define ADP8860_ISC4 0x17 /* Independent Sink Current LED4 */ -#define ADP8860_ISC3 0x18 /* Independent Sink Current LED3 */ -#define ADP8860_ISC2 0x19 /* Independent Sink Current LED2 */ -#define ADP8860_ISC1 0x1A /* Independent Sink Current LED1 */ -#define ADP8860_CCFG 0x1B /* Comparator configuration */ -#define ADP8860_CCFG2 0x1C /* Second comparator configuration */ -#define ADP8860_L2_TRP 0x1D /* L2 comparator reference */ -#define ADP8860_L2_HYS 0x1E /* L2 hysteresis */ -#define ADP8860_L3_TRP 0x1F /* L3 comparator reference */ -#define ADP8860_L3_HYS 0x20 /* L3 hysteresis */ -#define ADP8860_PH1LEVL 0x21 /* First phototransistor ambient light level-low byte register */ -#define ADP8860_PH1LEVH 0x22 /* First phototransistor ambient light level-high byte register */ -#define ADP8860_PH2LEVL 0x23 /* Second phototransistor ambient light level-low byte register */ -#define ADP8860_PH2LEVH 0x24 /* Second phototransistor ambient light level-high byte register */ - -#define ADP8860_MANUFID 0x0 /* Analog Devices ADP8860 Manufacturer ID */ -#define ADP8861_MANUFID 0x4 /* Analog Devices ADP8861 Manufacturer ID */ -#define ADP8863_MANUFID 0x2 /* Analog Devices ADP8863 Manufacturer ID */ - -#define ADP8860_DEVID(x) ((x) & 0xF) -#define ADP8860_MANID(x) ((x) >> 4) - -/* MDCR Device mode and status */ -#define INT_CFG (1 << 6) -#define NSTBY (1 << 5) -#define DIM_EN (1 << 4) -#define GDWN_DIS (1 << 3) -#define SIS_EN (1 << 2) -#define CMP_AUTOEN (1 << 1) -#define BLEN (1 << 0) - -/* ADP8860_CCFG Main ALS comparator level enable */ -#define L3_EN (1 << 1) -#define L2_EN (1 << 0) - -#define CFGR_BLV_SHIFT 3 -#define CFGR_BLV_MASK 0x3 -#define ADP8860_FLAG_LED_MASK 0xFF - -#define FADE_VAL(in, out) ((0xF & (in)) | ((0xF & (out)) << 4)) -#define BL_CFGR_VAL(law, blv) ((((blv) & CFGR_BLV_MASK) << CFGR_BLV_SHIFT) | ((0x3 & (law)) << 1)) -#define ALS_CCFG_VAL(filt) ((0x7 & filt) << 5) - -enum { - adp8860, - adp8861, - adp8863 -}; - -struct adp8860_led { - struct led_classdev cdev; - struct work_struct work; - struct i2c_client *client; - enum led_brightness new_brightness; - int id; - int flags; -}; - -struct adp8860_bl { - struct i2c_client *client; - struct backlight_device *bl; - struct adp8860_led *led; - struct adp8860_backlight_platform_data *pdata; - struct mutex lock; - unsigned long cached_daylight_max; - int id; - int revid; - int current_brightness; - unsigned en_ambl_sens:1; - unsigned gdwn_dis:1; -}; - -static int adp8860_read(struct i2c_client *client, int reg, uint8_t *val) -{ - int ret; - - ret = i2c_smbus_read_byte_data(client, reg); - if (ret < 0) { - dev_err(&client->dev, "failed reading at 0x%02x\n", reg); - return ret; - } - - *val = (uint8_t)ret; - return 0; -} - -static int adp8860_write(struct i2c_client *client, u8 reg, u8 val) -{ - return i2c_smbus_write_byte_data(client, reg, val); -} - -static int adp8860_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask) -{ - struct adp8860_bl *data = i2c_get_clientdata(client); - uint8_t reg_val; - int ret; - - mutex_lock(&data->lock); - - ret = adp8860_read(client, reg, ®_val); - - if (!ret && ((reg_val & bit_mask) == 0)) { - reg_val |= bit_mask; - ret = adp8860_write(client, reg, reg_val); - } - - mutex_unlock(&data->lock); - return ret; -} - -static int adp8860_clr_bits(struct i2c_client *client, int reg, uint8_t bit_mask) -{ - struct adp8860_bl *data = i2c_get_clientdata(client); - uint8_t reg_val; - int ret; - - mutex_lock(&data->lock); - - ret = adp8860_read(client, reg, ®_val); - - if (!ret && (reg_val & bit_mask)) { - reg_val &= ~bit_mask; - ret = adp8860_write(client, reg, reg_val); - } - - mutex_unlock(&data->lock); - return ret; -} - -/* - * Independent sink / LED - */ -#if defined(ADP8860_USE_LEDS) -static void adp8860_led_work(struct work_struct *work) -{ - struct adp8860_led *led = container_of(work, struct adp8860_led, work); - adp8860_write(led->client, ADP8860_ISC1 - led->id + 1, - led->new_brightness >> 1); -} - -static void adp8860_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct adp8860_led *led; - - led = container_of(led_cdev, struct adp8860_led, cdev); - led->new_brightness = value; - schedule_work(&led->work); -} - -static int adp8860_led_setup(struct adp8860_led *led) -{ - struct i2c_client *client = led->client; - int ret = 0; - - ret = adp8860_write(client, ADP8860_ISC1 - led->id + 1, 0); - ret |= adp8860_set_bits(client, ADP8860_ISCC, 1 << (led->id - 1)); - - if (led->id > 4) - ret |= adp8860_set_bits(client, ADP8860_ISCT1, - (led->flags & 0x3) << ((led->id - 5) * 2)); - else - ret |= adp8860_set_bits(client, ADP8860_ISCT2, - (led->flags & 0x3) << ((led->id - 1) * 2)); - - return ret; -} - -static int __devinit adp8860_led_probe(struct i2c_client *client) -{ - struct adp8860_backlight_platform_data *pdata = - client->dev.platform_data; - struct adp8860_bl *data = i2c_get_clientdata(client); - struct adp8860_led *led, *led_dat; - struct led_info *cur_led; - int ret, i; - - led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); - if (led == NULL) { - dev_err(&client->dev, "failed to alloc memory\n"); - return -ENOMEM; - } - - ret = adp8860_write(client, ADP8860_ISCFR, pdata->led_fade_law); - ret = adp8860_write(client, ADP8860_ISCT1, - (pdata->led_on_time & 0x3) << 6); - ret |= adp8860_write(client, ADP8860_ISCF, - FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); - - if (ret) { - dev_err(&client->dev, "failed to write\n"); - goto err_free; - } - - for (i = 0; i < pdata->num_leds; ++i) { - cur_led = &pdata->leds[i]; - led_dat = &led[i]; - - led_dat->id = cur_led->flags & ADP8860_FLAG_LED_MASK; - - if (led_dat->id > 7 || led_dat->id < 1) { - dev_err(&client->dev, "Invalid LED ID %d\n", - led_dat->id); - goto err; - } - - if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) { - dev_err(&client->dev, "LED %d used by Backlight\n", - led_dat->id); - goto err; - } - - led_dat->cdev.name = cur_led->name; - led_dat->cdev.default_trigger = cur_led->default_trigger; - led_dat->cdev.brightness_set = adp8860_led_set; - led_dat->cdev.brightness = LED_OFF; - led_dat->flags = cur_led->flags >> FLAG_OFFT_SHIFT; - led_dat->client = client; - led_dat->new_brightness = LED_OFF; - INIT_WORK(&led_dat->work, adp8860_led_work); - - ret = led_classdev_register(&client->dev, &led_dat->cdev); - if (ret) { - dev_err(&client->dev, "failed to register LED %d\n", - led_dat->id); - goto err; - } - - ret = adp8860_led_setup(led_dat); - if (ret) { - dev_err(&client->dev, "failed to write\n"); - i++; - goto err; - } - } - - data->led = led; - - return 0; - - err: - for (i = i - 1; i >= 0; --i) { - led_classdev_unregister(&led[i].cdev); - cancel_work_sync(&led[i].work); - } - - err_free: - kfree(led); - - return ret; -} - -static int __devexit adp8860_led_remove(struct i2c_client *client) -{ - struct adp8860_backlight_platform_data *pdata = - client->dev.platform_data; - struct adp8860_bl *data = i2c_get_clientdata(client); - int i; - - for (i = 0; i < pdata->num_leds; i++) { - led_classdev_unregister(&data->led[i].cdev); - cancel_work_sync(&data->led[i].work); - } - - kfree(data->led); - return 0; -} -#else -static int __devinit adp8860_led_probe(struct i2c_client *client) -{ - return 0; -} - -static int __devexit adp8860_led_remove(struct i2c_client *client) -{ - return 0; -} -#endif - -static int adp8860_bl_set(struct backlight_device *bl, int brightness) -{ - struct adp8860_bl *data = bl_get_data(bl); - struct i2c_client *client = data->client; - int ret = 0; - - if (data->en_ambl_sens) { - if ((brightness > 0) && (brightness < ADP8860_MAX_BRIGHTNESS)) { - /* Disable Ambient Light auto adjust */ - ret |= adp8860_clr_bits(client, ADP8860_MDCR, - CMP_AUTOEN); - ret |= adp8860_write(client, ADP8860_BLMX1, brightness); - } else { - /* - * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust - * restore daylight l1 sysfs brightness - */ - ret |= adp8860_write(client, ADP8860_BLMX1, - data->cached_daylight_max); - ret |= adp8860_set_bits(client, ADP8860_MDCR, - CMP_AUTOEN); - } - } else - ret |= adp8860_write(client, ADP8860_BLMX1, brightness); - - if (data->current_brightness && brightness == 0) - ret |= adp8860_set_bits(client, - ADP8860_MDCR, DIM_EN); - else if (data->current_brightness == 0 && brightness) - ret |= adp8860_clr_bits(client, - ADP8860_MDCR, DIM_EN); - - if (!ret) - data->current_brightness = brightness; - - return ret; -} - -static int adp8860_bl_update_status(struct backlight_device *bl) -{ - int brightness = bl->props.brightness; - if (bl->props.power != FB_BLANK_UNBLANK) - brightness = 0; - - if (bl->props.fb_blank != FB_BLANK_UNBLANK) - brightness = 0; - - return adp8860_bl_set(bl, brightness); -} - -static int adp8860_bl_get_brightness(struct backlight_device *bl) -{ - struct adp8860_bl *data = bl_get_data(bl); - - return data->current_brightness; -} - -static const struct backlight_ops adp8860_bl_ops = { - .update_status = adp8860_bl_update_status, - .get_brightness = adp8860_bl_get_brightness, -}; - -static int adp8860_bl_setup(struct backlight_device *bl) -{ - struct adp8860_bl *data = bl_get_data(bl); - struct i2c_client *client = data->client; - struct adp8860_backlight_platform_data *pdata = data->pdata; - int ret = 0; - - ret |= adp8860_write(client, ADP8860_BLSEN, ~pdata->bl_led_assign); - ret |= adp8860_write(client, ADP8860_BLMX1, pdata->l1_daylight_max); - ret |= adp8860_write(client, ADP8860_BLDM1, pdata->l1_daylight_dim); - - if (data->en_ambl_sens) { - data->cached_daylight_max = pdata->l1_daylight_max; - ret |= adp8860_write(client, ADP8860_BLMX2, - pdata->l2_office_max); - ret |= adp8860_write(client, ADP8860_BLDM2, - pdata->l2_office_dim); - ret |= adp8860_write(client, ADP8860_BLMX3, - pdata->l3_dark_max); - ret |= adp8860_write(client, ADP8860_BLDM3, - pdata->l3_dark_dim); - - ret |= adp8860_write(client, ADP8860_L2_TRP, pdata->l2_trip); - ret |= adp8860_write(client, ADP8860_L2_HYS, pdata->l2_hyst); - ret |= adp8860_write(client, ADP8860_L3_TRP, pdata->l3_trip); - ret |= adp8860_write(client, ADP8860_L3_HYS, pdata->l3_hyst); - ret |= adp8860_write(client, ADP8860_CCFG, L2_EN | L3_EN | - ALS_CCFG_VAL(pdata->abml_filt)); - } - - ret |= adp8860_write(client, ADP8860_CFGR, - BL_CFGR_VAL(pdata->bl_fade_law, 0)); - - ret |= adp8860_write(client, ADP8860_BLFR, FADE_VAL(pdata->bl_fade_in, - pdata->bl_fade_out)); - - ret |= adp8860_set_bits(client, ADP8860_MDCR, BLEN | DIM_EN | NSTBY | - (data->gdwn_dis ? GDWN_DIS : 0)); - - return ret; -} - -static ssize_t adp8860_show(struct device *dev, char *buf, int reg) -{ - struct adp8860_bl *data = dev_get_drvdata(dev); - int error; - uint8_t reg_val; - - mutex_lock(&data->lock); - error = adp8860_read(data->client, reg, ®_val); - mutex_unlock(&data->lock); - - if (error < 0) - return error; - - return sprintf(buf, "%u\n", reg_val); -} - -static ssize_t adp8860_store(struct device *dev, const char *buf, - size_t count, int reg) -{ - struct adp8860_bl *data = dev_get_drvdata(dev); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 10, &val); - if (ret) - return ret; - - mutex_lock(&data->lock); - adp8860_write(data->client, reg, val); - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t adp8860_bl_l3_dark_max_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return adp8860_show(dev, buf, ADP8860_BLMX3); -} - -static ssize_t adp8860_bl_l3_dark_max_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - return adp8860_store(dev, buf, count, ADP8860_BLMX3); -} - -static DEVICE_ATTR(l3_dark_max, 0664, adp8860_bl_l3_dark_max_show, - adp8860_bl_l3_dark_max_store); - -static ssize_t adp8860_bl_l2_office_max_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return adp8860_show(dev, buf, ADP8860_BLMX2); -} - -static ssize_t adp8860_bl_l2_office_max_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - return adp8860_store(dev, buf, count, ADP8860_BLMX2); -} -static DEVICE_ATTR(l2_office_max, 0664, adp8860_bl_l2_office_max_show, - adp8860_bl_l2_office_max_store); - -static ssize_t adp8860_bl_l1_daylight_max_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return adp8860_show(dev, buf, ADP8860_BLMX1); -} - -static ssize_t adp8860_bl_l1_daylight_max_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct adp8860_bl *data = dev_get_drvdata(dev); - - strict_strtoul(buf, 10, &data->cached_daylight_max); - return adp8860_store(dev, buf, count, ADP8860_BLMX1); -} -static DEVICE_ATTR(l1_daylight_max, 0664, adp8860_bl_l1_daylight_max_show, - adp8860_bl_l1_daylight_max_store); - -static ssize_t adp8860_bl_l3_dark_dim_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return adp8860_show(dev, buf, ADP8860_BLDM3); -} - -static ssize_t adp8860_bl_l3_dark_dim_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return adp8860_store(dev, buf, count, ADP8860_BLDM3); -} -static DEVICE_ATTR(l3_dark_dim, 0664, adp8860_bl_l3_dark_dim_show, - adp8860_bl_l3_dark_dim_store); - -static ssize_t adp8860_bl_l2_office_dim_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return adp8860_show(dev, buf, ADP8860_BLDM2); -} - -static ssize_t adp8860_bl_l2_office_dim_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return adp8860_store(dev, buf, count, ADP8860_BLDM2); -} -static DEVICE_ATTR(l2_office_dim, 0664, adp8860_bl_l2_office_dim_show, - adp8860_bl_l2_office_dim_store); - -static ssize_t adp8860_bl_l1_daylight_dim_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return adp8860_show(dev, buf, ADP8860_BLDM1); -} - -static ssize_t adp8860_bl_l1_daylight_dim_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return adp8860_store(dev, buf, count, ADP8860_BLDM1); -} -static DEVICE_ATTR(l1_daylight_dim, 0664, adp8860_bl_l1_daylight_dim_show, - adp8860_bl_l1_daylight_dim_store); - -#ifdef ADP8860_EXT_FEATURES -static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct adp8860_bl *data = dev_get_drvdata(dev); - int error; - uint8_t reg_val; - uint16_t ret_val; - - mutex_lock(&data->lock); - error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val); - ret_val = reg_val; - error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val); - mutex_unlock(&data->lock); - - if (error < 0) - return error; - - /* Return 13-bit conversion value for the first light sensor */ - ret_val += (reg_val & 0x1F) << 8; - - return sprintf(buf, "%u\n", ret_val); -} -static DEVICE_ATTR(ambient_light_level, 0444, - adp8860_bl_ambient_light_level_show, NULL); - -static ssize_t adp8860_bl_ambient_light_zone_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct adp8860_bl *data = dev_get_drvdata(dev); - int error; - uint8_t reg_val; - - mutex_lock(&data->lock); - error = adp8860_read(data->client, ADP8860_CFGR, ®_val); - mutex_unlock(&data->lock); - - if (error < 0) - return error; - - return sprintf(buf, "%u\n", - ((reg_val >> CFGR_BLV_SHIFT) & CFGR_BLV_MASK) + 1); -} - -static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct adp8860_bl *data = dev_get_drvdata(dev); - unsigned long val; - uint8_t reg_val; - int ret; - - ret = strict_strtoul(buf, 10, &val); - if (ret) - return ret; - - if (val == 0) { - /* Enable automatic ambient light sensing */ - adp8860_set_bits(data->client, ADP8860_MDCR, CMP_AUTOEN); - } else if ((val > 0) && (val < 6)) { - /* Disable automatic ambient light sensing */ - adp8860_clr_bits(data->client, ADP8860_MDCR, CMP_AUTOEN); - - /* Set user supplied ambient light zone */ - mutex_lock(&data->lock); - adp8860_read(data->client, ADP8860_CFGR, ®_val); - reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); - reg_val |= val << CFGR_BLV_SHIFT; - adp8860_write(data->client, ADP8860_CFGR, reg_val); - mutex_unlock(&data->lock); - } - - return count; -} -static DEVICE_ATTR(ambient_light_zone, 0664, - adp8860_bl_ambient_light_zone_show, - adp8860_bl_ambient_light_zone_store); -#endif - -static struct attribute *adp8860_bl_attributes[] = { - &dev_attr_l3_dark_max.attr, - &dev_attr_l3_dark_dim.attr, - &dev_attr_l2_office_max.attr, - &dev_attr_l2_office_dim.attr, - &dev_attr_l1_daylight_max.attr, - &dev_attr_l1_daylight_dim.attr, -#ifdef ADP8860_EXT_FEATURES - &dev_attr_ambient_light_level.attr, - &dev_attr_ambient_light_zone.attr, -#endif - NULL -}; - -static const struct attribute_group adp8860_bl_attr_group = { - .attrs = adp8860_bl_attributes, -}; - -static int __devinit adp8860_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct backlight_device *bl; - struct adp8860_bl *data; - struct adp8860_backlight_platform_data *pdata = - client->dev.platform_data; - struct backlight_properties props; - uint8_t reg_val; - int ret; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); - return -EIO; - } - - if (!pdata) { - dev_err(&client->dev, "no platform data?\n"); - return -EINVAL; - } - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (data == NULL) - return -ENOMEM; - - ret = adp8860_read(client, ADP8860_MFDVID, ®_val); - if (ret < 0) - goto out2; - - switch (ADP8860_MANID(reg_val)) { - case ADP8863_MANUFID: - data->gdwn_dis = !!pdata->gdwn_dis; - case ADP8860_MANUFID: - data->en_ambl_sens = !!pdata->en_ambl_sens; - break; - case ADP8861_MANUFID: - data->gdwn_dis = !!pdata->gdwn_dis; - break; - default: - dev_err(&client->dev, "failed to probe\n"); - ret = -ENODEV; - goto out2; - } - - /* It's confirmed that the DEVID field is actually a REVID */ - - data->revid = ADP8860_DEVID(reg_val); - data->client = client; - data->pdata = pdata; - data->id = id->driver_data; - data->current_brightness = 0; - i2c_set_clientdata(client, data); - - memset(&props, 0, sizeof(props)); - props.max_brightness = ADP8860_MAX_BRIGHTNESS; - - mutex_init(&data->lock); - - bl = backlight_device_register(dev_driver_string(&client->dev), - &client->dev, data, &adp8860_bl_ops, &props); - if (IS_ERR(bl)) { - dev_err(&client->dev, "failed to register backlight\n"); - ret = PTR_ERR(bl); - goto out2; - } - - bl->props.max_brightness = - bl->props.brightness = ADP8860_MAX_BRIGHTNESS; - - data->bl = bl; - - if (data->en_ambl_sens) - ret = sysfs_create_group(&bl->dev.kobj, - &adp8860_bl_attr_group); - - if (ret) { - dev_err(&client->dev, "failed to register sysfs\n"); - goto out1; - } - - ret = adp8860_bl_setup(bl); - if (ret) { - ret = -EIO; - goto out; - } - - backlight_update_status(bl); - - dev_info(&client->dev, "%s Rev.%d Backlight\n", - client->name, data->revid); - - if (pdata->num_leds) - adp8860_led_probe(client); - - return 0; - -out: - if (data->en_ambl_sens) - sysfs_remove_group(&data->bl->dev.kobj, - &adp8860_bl_attr_group); -out1: - backlight_device_unregister(bl); -out2: - i2c_set_clientdata(client, NULL); - kfree(data); - - return ret; -} - -static int __devexit adp8860_remove(struct i2c_client *client) -{ - struct adp8860_bl *data = i2c_get_clientdata(client); - - adp8860_clr_bits(client, ADP8860_MDCR, NSTBY); - - if (data->led) - adp8860_led_remove(client); - - if (data->en_ambl_sens) - sysfs_remove_group(&data->bl->dev.kobj, - &adp8860_bl_attr_group); - - backlight_device_unregister(data->bl); - i2c_set_clientdata(client, NULL); - kfree(data); - - return 0; -} - -#ifdef CONFIG_PM -static int adp8860_i2c_suspend(struct i2c_client *client, pm_message_t message) -{ - adp8860_clr_bits(client, ADP8860_MDCR, NSTBY); - - return 0; -} - -static int adp8860_i2c_resume(struct i2c_client *client) -{ - adp8860_set_bits(client, ADP8860_MDCR, NSTBY); - - return 0; -} -#else -#define adp8860_i2c_suspend NULL -#define adp8860_i2c_resume NULL -#endif - -static const struct i2c_device_id adp8860_id[] = { - { "adp8860", adp8860 }, - { "adp8861", adp8861 }, - { "adp8863", adp8863 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, adp8860_id); - -static struct i2c_driver adp8860_driver = { - .driver = { - .name = KBUILD_MODNAME, - }, - .probe = adp8860_probe, - .remove = __devexit_p(adp8860_remove), - .suspend = adp8860_i2c_suspend, - .resume = adp8860_i2c_resume, - .id_table = adp8860_id, -}; - -static int __init adp8860_init(void) -{ - return i2c_add_driver(&adp8860_driver); -} -module_init(adp8860_init); - -static void __exit adp8860_exit(void) -{ - i2c_del_driver(&adp8860_driver); -} -module_exit(adp8860_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Michael Hennerich "); -MODULE_DESCRIPTION("ADP8860 Backlight driver"); -MODULE_ALIAS("i2c:adp8860-backlight"); diff --git a/trunk/drivers/video/backlight/adx_bl.c b/trunk/drivers/video/backlight/adx_bl.c index fe9af129c5dd..7f4a7c30a98b 100644 --- a/trunk/drivers/video/backlight/adx_bl.c +++ b/trunk/drivers/video/backlight/adx_bl.c @@ -107,8 +107,8 @@ static int __devinit adx_backlight_probe(struct platform_device *pdev) props.max_brightness = 0xff; bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bl, &adx_backlight_ops, &props); - if (IS_ERR(bldev)) { - ret = PTR_ERR(bldev); + if (!bldev) { + ret = -ENOMEM; goto out; } diff --git a/trunk/drivers/video/backlight/ep93xx_bl.c b/trunk/drivers/video/backlight/ep93xx_bl.c deleted file mode 100644 index b0cc49184803..000000000000 --- a/trunk/drivers/video/backlight/ep93xx_bl.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Driver for the Cirrus EP93xx lcd backlight - * - * Copyright (c) 2010 H Hartley Sweeten - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This driver controls the pulse width modulated brightness control output, - * BRIGHT, on the Cirrus EP9307, EP9312, and EP9315 processors. - */ - - -#include -#include -#include -#include - -#include - -#define EP93XX_RASTER_REG(x) (EP93XX_RASTER_BASE + (x)) -#define EP93XX_RASTER_BRIGHTNESS EP93XX_RASTER_REG(0x20) - -#define EP93XX_MAX_COUNT 255 -#define EP93XX_MAX_BRIGHT 255 -#define EP93XX_DEF_BRIGHT 128 - -struct ep93xxbl { - void __iomem *mmio; - int brightness; -}; - -static int ep93xxbl_set(struct backlight_device *bl, int brightness) -{ - struct ep93xxbl *ep93xxbl = bl_get_data(bl); - - __raw_writel((brightness << 8) | EP93XX_MAX_COUNT, ep93xxbl->mmio); - - ep93xxbl->brightness = brightness; - - return 0; -} - -static int ep93xxbl_update_status(struct backlight_device *bl) -{ - int brightness = bl->props.brightness; - - if (bl->props.power != FB_BLANK_UNBLANK || - bl->props.fb_blank != FB_BLANK_UNBLANK) - brightness = 0; - - return ep93xxbl_set(bl, brightness); -} - -static int ep93xxbl_get_brightness(struct backlight_device *bl) -{ - struct ep93xxbl *ep93xxbl = bl_get_data(bl); - - return ep93xxbl->brightness; -} - -static const struct backlight_ops ep93xxbl_ops = { - .update_status = ep93xxbl_update_status, - .get_brightness = ep93xxbl_get_brightness, -}; - -static int __init ep93xxbl_probe(struct platform_device *dev) -{ - struct ep93xxbl *ep93xxbl; - struct backlight_device *bl; - struct backlight_properties props; - - ep93xxbl = devm_kzalloc(&dev->dev, sizeof(*ep93xxbl), GFP_KERNEL); - if (!ep93xxbl) - return -ENOMEM; - - /* - * This register is located in the range already ioremap'ed by - * the framebuffer driver. A MFD driver seems a bit of overkill - * to handle this so use the static I/O mapping; this address - * is already virtual. - * - * NOTE: No locking is required; the framebuffer does not touch - * this register. - */ - ep93xxbl->mmio = EP93XX_RASTER_BRIGHTNESS; - - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = EP93XX_MAX_BRIGHT; - bl = backlight_device_register(dev->name, &dev->dev, ep93xxbl, - &ep93xxbl_ops, &props); - if (IS_ERR(bl)) - return PTR_ERR(bl); - - bl->props.brightness = EP93XX_DEF_BRIGHT; - - platform_set_drvdata(dev, bl); - - ep93xxbl_update_status(bl); - - return 0; -} - -static int ep93xxbl_remove(struct platform_device *dev) -{ - struct backlight_device *bl = platform_get_drvdata(dev); - - backlight_device_unregister(bl); - platform_set_drvdata(dev, NULL); - return 0; -} - -#ifdef CONFIG_PM -static int ep93xxbl_suspend(struct platform_device *dev, pm_message_t state) -{ - struct backlight_device *bl = platform_get_drvdata(dev); - - return ep93xxbl_set(bl, 0); -} - -static int ep93xxbl_resume(struct platform_device *dev) -{ - struct backlight_device *bl = platform_get_drvdata(dev); - - backlight_update_status(bl); - return 0; -} -#else -#define ep93xxbl_suspend NULL -#define ep93xxbl_resume NULL -#endif - -static struct platform_driver ep93xxbl_driver = { - .driver = { - .name = "ep93xx-bl", - .owner = THIS_MODULE, - }, - .probe = ep93xxbl_probe, - .remove = __devexit_p(ep93xxbl_remove), - .suspend = ep93xxbl_suspend, - .resume = ep93xxbl_resume, -}; - -static int __init ep93xxbl_init(void) -{ - return platform_driver_register(&ep93xxbl_driver); -} -module_init(ep93xxbl_init); - -static void __exit ep93xxbl_exit(void) -{ - platform_driver_unregister(&ep93xxbl_driver); -} -module_exit(ep93xxbl_exit); - -MODULE_DESCRIPTION("EP93xx Backlight Driver"); -MODULE_AUTHOR("H Hartley Sweeten "); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:ep93xx-bl"); diff --git a/trunk/drivers/video/backlight/l4f00242t03.c b/trunk/drivers/video/backlight/l4f00242t03.c index 9093ef0fa869..bcdb12c93efd 100644 --- a/trunk/drivers/video/backlight/l4f00242t03.c +++ b/trunk/drivers/video/backlight/l4f00242t03.c @@ -125,7 +125,8 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) if (priv == NULL) { dev_err(&spi->dev, "No memory for this device.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err; } dev_set_drvdata(&spi->dev, priv); @@ -138,7 +139,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) if (ret) { dev_err(&spi->dev, "Unable to get the lcd l4f00242t03 reset gpio.\n"); - goto err; + return ret; } ret = gpio_direction_output(pdata->reset_gpio, 1); @@ -150,7 +151,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) if (ret) { dev_err(&spi->dev, "Unable to get the lcd l4f00242t03 data en gpio.\n"); - goto err2; + return ret; } ret = gpio_direction_output(pdata->data_enable_gpio, 0); @@ -221,9 +222,9 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi) gpio_free(pdata->reset_gpio); if (priv->io_reg) - regulator_put(priv->io_reg); - if (priv->core_reg) regulator_put(priv->core_reg); + if (priv->core_reg) + regulator_put(priv->io_reg); kfree(priv); diff --git a/trunk/drivers/video/backlight/max8925_bl.c b/trunk/drivers/video/backlight/max8925_bl.c index b2b2c7ba1f63..b5accc957ad3 100644 --- a/trunk/drivers/video/backlight/max8925_bl.c +++ b/trunk/drivers/video/backlight/max8925_bl.c @@ -162,7 +162,6 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev) backlight_update_status(bl); return 0; out: - backlight_device_unregister(bl); kfree(data); return ret; } diff --git a/trunk/drivers/video/backlight/mbp_nvidia_bl.c b/trunk/drivers/video/backlight/mbp_nvidia_bl.c index 9fb533f6373e..1b5d3fe6bbbc 100644 --- a/trunk/drivers/video/backlight/mbp_nvidia_bl.c +++ b/trunk/drivers/video/backlight/mbp_nvidia_bl.c @@ -141,7 +141,7 @@ static const struct dmi_system_id __initdata mbp_device_table[] = { .callback = mbp_dmi_match, .ident = "MacBook 1,1", .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"), }, .driver_data = (void *)&intel_chipset_data, @@ -182,42 +182,6 @@ static const struct dmi_system_id __initdata mbp_device_table[] = { }, .driver_data = (void *)&intel_chipset_data, }, - { - .callback = mbp_dmi_match, - .ident = "MacBookPro 1,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro1,1"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBookPro 1,2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro1,2"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBookPro 2,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,1"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBookPro 2,2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2"), - }, - .driver_data = (void *)&intel_chipset_data, - }, { .callback = mbp_dmi_match, .ident = "MacBookPro 3,1", @@ -272,15 +236,6 @@ static const struct dmi_system_id __initdata mbp_device_table[] = { }, .driver_data = (void *)&nvidia_chipset_data, }, - { - .callback = mbp_dmi_match, - .ident = "MacBook 6,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook6,1"), - }, - .driver_data = (void *)&nvidia_chipset_data, - }, { .callback = mbp_dmi_match, .ident = "MacBookAir 2,1", diff --git a/trunk/drivers/video/backlight/pcf50633-backlight.c b/trunk/drivers/video/backlight/pcf50633-backlight.c deleted file mode 100644 index 3c424f7efdcc..000000000000 --- a/trunk/drivers/video/backlight/pcf50633-backlight.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2009-2010, Lars-Peter Clausen - * PCF50633 backlight device driver - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include - -struct pcf50633_bl { - struct pcf50633 *pcf; - struct backlight_device *bl; - - unsigned int brightness; - unsigned int brightness_limit; -}; - -/* - * pcf50633_bl_set_brightness_limit - * - * Update the brightness limit for the pc50633 backlight. The actual brightness - * will not go above the limit. This is useful to limit power drain for example - * on low battery. - * - * @dev: Pointer to a pcf50633 device - * @limit: The brightness limit. Valid values are 0-63 - */ -int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit) -{ - struct pcf50633_bl *pcf_bl = platform_get_drvdata(pcf->bl_pdev); - - if (!pcf_bl) - return -ENODEV; - - pcf_bl->brightness_limit = limit & 0x3f; - backlight_update_status(pcf_bl->bl); - - return 0; -} - -static int pcf50633_bl_update_status(struct backlight_device *bl) -{ - struct pcf50633_bl *pcf_bl = bl_get_data(bl); - unsigned int new_brightness; - - - if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK) || - bl->props.power != FB_BLANK_UNBLANK) - new_brightness = 0; - else if (bl->props.brightness < pcf_bl->brightness_limit) - new_brightness = bl->props.brightness; - else - new_brightness = pcf_bl->brightness_limit; - - - if (pcf_bl->brightness == new_brightness) - return 0; - - if (new_brightness) { - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDOUT, - new_brightness); - if (!pcf_bl->brightness) - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDENA, 1); - } else { - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDENA, 0); - } - - pcf_bl->brightness = new_brightness; - - return 0; -} - -static int pcf50633_bl_get_brightness(struct backlight_device *bl) -{ - struct pcf50633_bl *pcf_bl = bl_get_data(bl); - return pcf_bl->brightness; -} - -static const struct backlight_ops pcf50633_bl_ops = { - .get_brightness = pcf50633_bl_get_brightness, - .update_status = pcf50633_bl_update_status, - .options = BL_CORE_SUSPENDRESUME, -}; - -static int __devinit pcf50633_bl_probe(struct platform_device *pdev) -{ - int ret; - struct pcf50633_bl *pcf_bl; - struct device *parent = pdev->dev.parent; - struct pcf50633_platform_data *pcf50633_data = parent->platform_data; - struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data; - struct backlight_properties bl_props; - - pcf_bl = kzalloc(sizeof(*pcf_bl), GFP_KERNEL); - if (!pcf_bl) - return -ENOMEM; - - bl_props.max_brightness = 0x3f; - bl_props.power = FB_BLANK_UNBLANK; - - if (pdata) { - bl_props.brightness = pdata->default_brightness; - pcf_bl->brightness_limit = pdata->default_brightness_limit; - } else { - bl_props.brightness = 0x3f; - pcf_bl->brightness_limit = 0x3f; - } - - pcf_bl->pcf = dev_to_pcf50633(pdev->dev.parent); - - pcf_bl->bl = backlight_device_register(pdev->name, &pdev->dev, pcf_bl, - &pcf50633_bl_ops, &bl_props); - - if (IS_ERR(pcf_bl->bl)) { - ret = PTR_ERR(pcf_bl->bl); - goto err_free; - } - - platform_set_drvdata(pdev, pcf_bl); - - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDDIM, pdata->ramp_time); - - /* Should be different from bl_props.brightness, so we do not exit - * update_status early the first time it's called */ - pcf_bl->brightness = pcf_bl->bl->props.brightness + 1; - - backlight_update_status(pcf_bl->bl); - - return 0; - -err_free: - kfree(pcf_bl); - - return ret; -} - -static int __devexit pcf50633_bl_remove(struct platform_device *pdev) -{ - struct pcf50633_bl *pcf_bl = platform_get_drvdata(pdev); - - backlight_device_unregister(pcf_bl->bl); - - platform_set_drvdata(pdev, NULL); - - kfree(pcf_bl); - - return 0; -} - -static struct platform_driver pcf50633_bl_driver = { - .probe = pcf50633_bl_probe, - .remove = __devexit_p(pcf50633_bl_remove), - .driver = { - .name = "pcf50633-backlight", - }, -}; - -static int __init pcf50633_bl_init(void) -{ - return platform_driver_register(&pcf50633_bl_driver); -} -module_init(pcf50633_bl_init); - -static void __exit pcf50633_bl_exit(void) -{ - platform_driver_unregister(&pcf50633_bl_driver); -} -module_exit(pcf50633_bl_exit); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("PCF50633 backlight driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:pcf50633-backlight"); diff --git a/trunk/drivers/video/backlight/s6e63m0.c b/trunk/drivers/video/backlight/s6e63m0.c deleted file mode 100644 index a3128c9cb7ad..000000000000 --- a/trunk/drivers/video/backlight/s6e63m0.c +++ /dev/null @@ -1,920 +0,0 @@ -/* - * S6E63M0 AMOLED LCD panel driver. - * - * Author: InKi Dae - * - * Derived from drivers/video/omap/lcd-apollon.c - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "s6e63m0_gamma.h" - -#define SLEEPMSEC 0x1000 -#define ENDDEF 0x2000 -#define DEFMASK 0xFF00 -#define COMMAND_ONLY 0xFE -#define DATA_ONLY 0xFF - -#define MIN_BRIGHTNESS 0 -#define MAX_BRIGHTNESS 10 - -#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) - -struct s6e63m0 { - struct device *dev; - struct spi_device *spi; - unsigned int power; - unsigned int current_brightness; - unsigned int gamma_mode; - unsigned int gamma_table_count; - struct lcd_device *ld; - struct backlight_device *bd; - struct lcd_platform_data *lcd_pd; -}; - -static const unsigned short SEQ_PANEL_CONDITION_SET[] = { - 0xF8, 0x01, - DATA_ONLY, 0x27, - DATA_ONLY, 0x27, - DATA_ONLY, 0x07, - DATA_ONLY, 0x07, - DATA_ONLY, 0x54, - DATA_ONLY, 0x9f, - DATA_ONLY, 0x63, - DATA_ONLY, 0x86, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x33, - DATA_ONLY, 0x0d, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_DISPLAY_CONDITION_SET[] = { - 0xf2, 0x02, - DATA_ONLY, 0x03, - DATA_ONLY, 0x1c, - DATA_ONLY, 0x10, - DATA_ONLY, 0x10, - - 0xf7, 0x03, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_GAMMA_SETTING[] = { - 0xfa, 0x00, - DATA_ONLY, 0x18, - DATA_ONLY, 0x08, - DATA_ONLY, 0x24, - DATA_ONLY, 0x64, - DATA_ONLY, 0x56, - DATA_ONLY, 0x33, - DATA_ONLY, 0xb6, - DATA_ONLY, 0xba, - DATA_ONLY, 0xa8, - DATA_ONLY, 0xac, - DATA_ONLY, 0xb1, - DATA_ONLY, 0x9d, - DATA_ONLY, 0xc1, - DATA_ONLY, 0xc1, - DATA_ONLY, 0xb7, - DATA_ONLY, 0x00, - DATA_ONLY, 0x9c, - DATA_ONLY, 0x00, - DATA_ONLY, 0x9f, - DATA_ONLY, 0x00, - DATA_ONLY, 0xd6, - - 0xfa, 0x01, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_ETC_CONDITION_SET[] = { - 0xf6, 0x00, - DATA_ONLY, 0x8c, - DATA_ONLY, 0x07, - - 0xb3, 0xc, - - 0xb5, 0x2c, - DATA_ONLY, 0x12, - DATA_ONLY, 0x0c, - DATA_ONLY, 0x0a, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0e, - DATA_ONLY, 0x17, - DATA_ONLY, 0x13, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x2a, - DATA_ONLY, 0x24, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1b, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x17, - - DATA_ONLY, 0x2b, - DATA_ONLY, 0x26, - DATA_ONLY, 0x22, - DATA_ONLY, 0x20, - DATA_ONLY, 0x3a, - DATA_ONLY, 0x34, - DATA_ONLY, 0x30, - DATA_ONLY, 0x2c, - DATA_ONLY, 0x29, - DATA_ONLY, 0x26, - DATA_ONLY, 0x25, - DATA_ONLY, 0x23, - DATA_ONLY, 0x21, - DATA_ONLY, 0x20, - DATA_ONLY, 0x1e, - DATA_ONLY, 0x1e, - - 0xb6, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x11, - DATA_ONLY, 0x22, - DATA_ONLY, 0x33, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - - DATA_ONLY, 0x55, - DATA_ONLY, 0x55, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - - 0xb7, 0x2c, - DATA_ONLY, 0x12, - DATA_ONLY, 0x0c, - DATA_ONLY, 0x0a, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0e, - DATA_ONLY, 0x17, - DATA_ONLY, 0x13, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x2a, - DATA_ONLY, 0x24, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1b, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x17, - - DATA_ONLY, 0x2b, - DATA_ONLY, 0x26, - DATA_ONLY, 0x22, - DATA_ONLY, 0x20, - DATA_ONLY, 0x3a, - DATA_ONLY, 0x34, - DATA_ONLY, 0x30, - DATA_ONLY, 0x2c, - DATA_ONLY, 0x29, - DATA_ONLY, 0x26, - DATA_ONLY, 0x25, - DATA_ONLY, 0x23, - DATA_ONLY, 0x21, - DATA_ONLY, 0x20, - DATA_ONLY, 0x1e, - DATA_ONLY, 0x1e, - - 0xb8, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x11, - DATA_ONLY, 0x22, - DATA_ONLY, 0x33, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - - DATA_ONLY, 0x55, - DATA_ONLY, 0x55, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - - 0xb9, 0x2c, - DATA_ONLY, 0x12, - DATA_ONLY, 0x0c, - DATA_ONLY, 0x0a, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0e, - DATA_ONLY, 0x17, - DATA_ONLY, 0x13, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x2a, - DATA_ONLY, 0x24, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1b, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x17, - - DATA_ONLY, 0x2b, - DATA_ONLY, 0x26, - DATA_ONLY, 0x22, - DATA_ONLY, 0x20, - DATA_ONLY, 0x3a, - DATA_ONLY, 0x34, - DATA_ONLY, 0x30, - DATA_ONLY, 0x2c, - DATA_ONLY, 0x29, - DATA_ONLY, 0x26, - DATA_ONLY, 0x25, - DATA_ONLY, 0x23, - DATA_ONLY, 0x21, - DATA_ONLY, 0x20, - DATA_ONLY, 0x1e, - DATA_ONLY, 0x1e, - - 0xba, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x11, - DATA_ONLY, 0x22, - DATA_ONLY, 0x33, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - - DATA_ONLY, 0x55, - DATA_ONLY, 0x55, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - - 0xc1, 0x4d, - DATA_ONLY, 0x96, - DATA_ONLY, 0x1d, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x01, - DATA_ONLY, 0xdf, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - DATA_ONLY, 0x06, - DATA_ONLY, 0x09, - DATA_ONLY, 0x0d, - DATA_ONLY, 0x0f, - DATA_ONLY, 0x12, - DATA_ONLY, 0x15, - DATA_ONLY, 0x18, - - 0xb2, 0x10, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0b, - DATA_ONLY, 0x05, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_ACL_ON[] = { - /* ACL on */ - 0xc0, 0x01, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_ACL_OFF[] = { - /* ACL off */ - 0xc0, 0x00, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_ELVSS_ON[] = { - /* ELVSS on */ - 0xb1, 0x0b, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_ELVSS_OFF[] = { - /* ELVSS off */ - 0xb1, 0x0a, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_STAND_BY_OFF[] = { - 0x11, COMMAND_ONLY, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_STAND_BY_ON[] = { - 0x10, COMMAND_ONLY, - - ENDDEF, 0x0000 -}; - -static const unsigned short SEQ_DISPLAY_ON[] = { - 0x29, COMMAND_ONLY, - - ENDDEF, 0x0000 -}; - - -static int s6e63m0_spi_write_byte(struct s6e63m0 *lcd, int addr, int data) -{ - u16 buf[1]; - struct spi_message msg; - - struct spi_transfer xfer = { - .len = 2, - .tx_buf = buf, - }; - - buf[0] = (addr << 8) | data; - - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - - return spi_sync(lcd->spi, &msg); -} - -static int s6e63m0_spi_write(struct s6e63m0 *lcd, unsigned char address, - unsigned char command) -{ - int ret = 0; - - if (address != DATA_ONLY) - ret = s6e63m0_spi_write_byte(lcd, 0x0, address); - if (command != COMMAND_ONLY) - ret = s6e63m0_spi_write_byte(lcd, 0x1, command); - - return ret; -} - -static int s6e63m0_panel_send_sequence(struct s6e63m0 *lcd, - const unsigned short *wbuf) -{ - int ret = 0, i = 0; - - while ((wbuf[i] & DEFMASK) != ENDDEF) { - if ((wbuf[i] & DEFMASK) != SLEEPMSEC) { - ret = s6e63m0_spi_write(lcd, wbuf[i], wbuf[i+1]); - if (ret) - break; - } else - udelay(wbuf[i+1]*1000); - i += 2; - } - - return ret; -} - -static int _s6e63m0_gamma_ctl(struct s6e63m0 *lcd, const unsigned int *gamma) -{ - unsigned int i = 0; - int ret = 0; - - /* disable gamma table updating. */ - ret = s6e63m0_spi_write(lcd, 0xfa, 0x00); - if (ret) { - dev_err(lcd->dev, "failed to disable gamma table updating.\n"); - goto gamma_err; - } - - for (i = 0 ; i < GAMMA_TABLE_COUNT; i++) { - ret = s6e63m0_spi_write(lcd, DATA_ONLY, gamma[i]); - if (ret) { - dev_err(lcd->dev, "failed to set gamma table.\n"); - goto gamma_err; - } - } - - /* update gamma table. */ - ret = s6e63m0_spi_write(lcd, 0xfa, 0x01); - if (ret) - dev_err(lcd->dev, "failed to update gamma table.\n"); - -gamma_err: - return ret; -} - -static int s6e63m0_gamma_ctl(struct s6e63m0 *lcd, int gamma) -{ - int ret = 0; - - ret = _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_22_table[gamma]); - - return ret; -} - - -static int s6e63m0_ldi_init(struct s6e63m0 *lcd) -{ - int ret, i; - const unsigned short *init_seq[] = { - SEQ_PANEL_CONDITION_SET, - SEQ_DISPLAY_CONDITION_SET, - SEQ_GAMMA_SETTING, - SEQ_ETC_CONDITION_SET, - SEQ_ACL_ON, - SEQ_ELVSS_ON, - }; - - for (i = 0; i < ARRAY_SIZE(init_seq); i++) { - ret = s6e63m0_panel_send_sequence(lcd, init_seq[i]); - if (ret) - break; - } - - return ret; -} - -static int s6e63m0_ldi_enable(struct s6e63m0 *lcd) -{ - int ret = 0, i; - const unsigned short *enable_seq[] = { - SEQ_STAND_BY_OFF, - SEQ_DISPLAY_ON, - }; - - for (i = 0; i < ARRAY_SIZE(enable_seq); i++) { - ret = s6e63m0_panel_send_sequence(lcd, enable_seq[i]); - if (ret) - break; - } - - return ret; -} - -static int s6e63m0_ldi_disable(struct s6e63m0 *lcd) -{ - int ret; - - ret = s6e63m0_panel_send_sequence(lcd, SEQ_STAND_BY_ON); - - return ret; -} - -static int s6e63m0_power_on(struct s6e63m0 *lcd) -{ - int ret = 0; - struct lcd_platform_data *pd = NULL; - struct backlight_device *bd = NULL; - - pd = lcd->lcd_pd; - if (!pd) { - dev_err(lcd->dev, "platform data is NULL.\n"); - return -EFAULT; - } - - bd = lcd->bd; - if (!bd) { - dev_err(lcd->dev, "backlight device is NULL.\n"); - return -EFAULT; - } - - if (!pd->power_on) { - dev_err(lcd->dev, "power_on is NULL.\n"); - return -EFAULT; - } else { - pd->power_on(lcd->ld, 1); - mdelay(pd->power_on_delay); - } - - if (!pd->reset) { - dev_err(lcd->dev, "reset is NULL.\n"); - return -EFAULT; - } else { - pd->reset(lcd->ld); - mdelay(pd->reset_delay); - } - - ret = s6e63m0_ldi_init(lcd); - if (ret) { - dev_err(lcd->dev, "failed to initialize ldi.\n"); - return ret; - } - - ret = s6e63m0_ldi_enable(lcd); - if (ret) { - dev_err(lcd->dev, "failed to enable ldi.\n"); - return ret; - } - - /* set brightness to current value after power on or resume. */ - ret = s6e63m0_gamma_ctl(lcd, bd->props.brightness); - if (ret) { - dev_err(lcd->dev, "lcd gamma setting failed.\n"); - return ret; - } - - return 0; -} - -static int s6e63m0_power_off(struct s6e63m0 *lcd) -{ - int ret = 0; - struct lcd_platform_data *pd = NULL; - - pd = lcd->lcd_pd; - if (!pd) { - dev_err(lcd->dev, "platform data is NULL.\n"); - return -EFAULT; - } - - ret = s6e63m0_ldi_disable(lcd); - if (ret) { - dev_err(lcd->dev, "lcd setting failed.\n"); - return -EIO; - } - - mdelay(pd->power_off_delay); - - if (!pd->power_on) { - dev_err(lcd->dev, "power_on is NULL.\n"); - return -EFAULT; - } else - pd->power_on(lcd->ld, 0); - - return 0; -} - -static int s6e63m0_power(struct s6e63m0 *lcd, int power) -{ - int ret = 0; - - if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) - ret = s6e63m0_power_on(lcd); - else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) - ret = s6e63m0_power_off(lcd); - - if (!ret) - lcd->power = power; - - return ret; -} - -static int s6e63m0_set_power(struct lcd_device *ld, int power) -{ - struct s6e63m0 *lcd = lcd_get_data(ld); - - if (power != FB_BLANK_UNBLANK && power != FB_BLANK_POWERDOWN && - power != FB_BLANK_NORMAL) { - dev_err(lcd->dev, "power value should be 0, 1 or 4.\n"); - return -EINVAL; - } - - return s6e63m0_power(lcd, power); -} - -static int s6e63m0_get_power(struct lcd_device *ld) -{ - struct s6e63m0 *lcd = lcd_get_data(ld); - - return lcd->power; -} - -static int s6e63m0_get_brightness(struct backlight_device *bd) -{ - return bd->props.brightness; -} - -static int s6e63m0_set_brightness(struct backlight_device *bd) -{ - int ret = 0, brightness = bd->props.brightness; - struct s6e63m0 *lcd = bl_get_data(bd); - - if (brightness < MIN_BRIGHTNESS || - brightness > bd->props.max_brightness) { - dev_err(&bd->dev, "lcd brightness should be %d to %d.\n", - MIN_BRIGHTNESS, MAX_BRIGHTNESS); - return -EINVAL; - } - - ret = s6e63m0_gamma_ctl(lcd, bd->props.brightness); - if (ret) { - dev_err(&bd->dev, "lcd brightness setting failed.\n"); - return -EIO; - } - - return ret; -} - -static struct lcd_ops s6e63m0_lcd_ops = { - .set_power = s6e63m0_set_power, - .get_power = s6e63m0_get_power, -}; - -static const struct backlight_ops s6e63m0_backlight_ops = { - .get_brightness = s6e63m0_get_brightness, - .update_status = s6e63m0_set_brightness, -}; - -static ssize_t s6e63m0_sysfs_show_gamma_mode(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - char temp[10]; - - switch (lcd->gamma_mode) { - case 0: - sprintf(temp, "2.2 mode\n"); - strcat(buf, temp); - break; - case 1: - sprintf(temp, "1.9 mode\n"); - strcat(buf, temp); - break; - case 2: - sprintf(temp, "1.7 mode\n"); - strcat(buf, temp); - break; - default: - dev_info(dev, "gamma mode could be 0:2.2, 1:1.9 or 2:1.7)n"); - break; - } - - return strlen(buf); -} - -static ssize_t s6e63m0_sysfs_store_gamma_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - struct backlight_device *bd = NULL; - int brightness, rc; - - rc = strict_strtoul(buf, 0, (unsigned long *)&lcd->gamma_mode); - if (rc < 0) - return rc; - - bd = lcd->bd; - - brightness = bd->props.brightness; - - switch (lcd->gamma_mode) { - case 0: - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_22_table[brightness]); - break; - case 1: - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_19_table[brightness]); - break; - case 2: - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_17_table[brightness]); - break; - default: - dev_info(dev, "gamma mode could be 0:2.2, 1:1.9 or 2:1.7\n"); - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_22_table[brightness]); - break; - } - return len; -} - -static DEVICE_ATTR(gamma_mode, 0644, - s6e63m0_sysfs_show_gamma_mode, s6e63m0_sysfs_store_gamma_mode); - -static ssize_t s6e63m0_sysfs_show_gamma_table(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - char temp[3]; - - sprintf(temp, "%d\n", lcd->gamma_table_count); - strcpy(buf, temp); - - return strlen(buf); -} -static DEVICE_ATTR(gamma_table, 0644, - s6e63m0_sysfs_show_gamma_table, NULL); - -static int __init s6e63m0_probe(struct spi_device *spi) -{ - int ret = 0; - struct s6e63m0 *lcd = NULL; - struct lcd_device *ld = NULL; - struct backlight_device *bd = NULL; - - lcd = kzalloc(sizeof(struct s6e63m0), GFP_KERNEL); - if (!lcd) - return -ENOMEM; - - /* s6e63m0 lcd panel uses 3-wire 9bits SPI Mode. */ - spi->bits_per_word = 9; - - ret = spi_setup(spi); - if (ret < 0) { - dev_err(&spi->dev, "spi setup failed.\n"); - goto out_free_lcd; - } - - lcd->spi = spi; - lcd->dev = &spi->dev; - - lcd->lcd_pd = (struct lcd_platform_data *)spi->dev.platform_data; - if (!lcd->lcd_pd) { - dev_err(&spi->dev, "platform data is NULL.\n"); - goto out_free_lcd; - } - - ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops); - if (IS_ERR(ld)) { - ret = PTR_ERR(ld); - goto out_free_lcd; - } - - lcd->ld = ld; - - bd = backlight_device_register("s6e63m0bl-bl", &spi->dev, lcd, - &s6e63m0_backlight_ops, NULL); - if (IS_ERR(bd)) { - ret = PTR_ERR(bd); - goto out_lcd_unregister; - } - - bd->props.max_brightness = MAX_BRIGHTNESS; - bd->props.brightness = MAX_BRIGHTNESS; - lcd->bd = bd; - - /* - * it gets gamma table count available so it gets user - * know that. - */ - lcd->gamma_table_count = - sizeof(gamma_table) / (MAX_GAMMA_LEVEL * sizeof(int)); - - ret = device_create_file(&(spi->dev), &dev_attr_gamma_mode); - if (ret < 0) - dev_err(&(spi->dev), "failed to add sysfs entries\n"); - - ret = device_create_file(&(spi->dev), &dev_attr_gamma_table); - if (ret < 0) - dev_err(&(spi->dev), "failed to add sysfs entries\n"); - - /* - * if lcd panel was on from bootloader like u-boot then - * do not lcd on. - */ - if (!lcd->lcd_pd->lcd_enabled) { - /* - * if lcd panel was off from bootloader then - * current lcd status is powerdown and then - * it enables lcd panel. - */ - lcd->power = FB_BLANK_POWERDOWN; - - s6e63m0_power(lcd, FB_BLANK_UNBLANK); - } else - lcd->power = FB_BLANK_UNBLANK; - - dev_set_drvdata(&spi->dev, lcd); - - dev_info(&spi->dev, "s6e63m0 panel driver has been probed.\n"); - - return 0; - -out_lcd_unregister: - lcd_device_unregister(ld); -out_free_lcd: - kfree(lcd); - return ret; -} - -static int __devexit s6e63m0_remove(struct spi_device *spi) -{ - struct s6e63m0 *lcd = dev_get_drvdata(&spi->dev); - - s6e63m0_power(lcd, FB_BLANK_POWERDOWN); - lcd_device_unregister(lcd->ld); - kfree(lcd); - - return 0; -} - -#if defined(CONFIG_PM) -unsigned int before_power; - -static int s6e63m0_suspend(struct spi_device *spi, pm_message_t mesg) -{ - int ret = 0; - struct s6e63m0 *lcd = dev_get_drvdata(&spi->dev); - - dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); - - before_power = lcd->power; - - /* - * when lcd panel is suspend, lcd panel becomes off - * regardless of status. - */ - ret = s6e63m0_power(lcd, FB_BLANK_POWERDOWN); - - return ret; -} - -static int s6e63m0_resume(struct spi_device *spi) -{ - int ret = 0; - struct s6e63m0 *lcd = dev_get_drvdata(&spi->dev); - - /* - * after suspended, if lcd panel status is FB_BLANK_UNBLANK - * (at that time, before_power is FB_BLANK_UNBLANK) then - * it changes that status to FB_BLANK_POWERDOWN to get lcd on. - */ - if (before_power == FB_BLANK_UNBLANK) - lcd->power = FB_BLANK_POWERDOWN; - - dev_dbg(&spi->dev, "before_power = %d\n", before_power); - - ret = s6e63m0_power(lcd, before_power); - - return ret; -} -#else -#define s6e63m0_suspend NULL -#define s6e63m0_resume NULL -#endif - -/* Power down all displays on reboot, poweroff or halt. */ -static void s6e63m0_shutdown(struct spi_device *spi) -{ - struct s6e63m0 *lcd = dev_get_drvdata(&spi->dev); - - s6e63m0_power(lcd, FB_BLANK_POWERDOWN); -} - -static struct spi_driver s6e63m0_driver = { - .driver = { - .name = "s6e63m0", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = s6e63m0_probe, - .remove = __devexit_p(s6e63m0_remove), - .shutdown = s6e63m0_shutdown, - .suspend = s6e63m0_suspend, - .resume = s6e63m0_resume, -}; - -static int __init s6e63m0_init(void) -{ - return spi_register_driver(&s6e63m0_driver); -} - -static void __exit s6e63m0_exit(void) -{ - spi_unregister_driver(&s6e63m0_driver); -} - -module_init(s6e63m0_init); -module_exit(s6e63m0_exit); - -MODULE_AUTHOR("InKi Dae "); -MODULE_DESCRIPTION("S6E63M0 LCD Driver"); -MODULE_LICENSE("GPL"); - diff --git a/trunk/drivers/video/backlight/s6e63m0_gamma.h b/trunk/drivers/video/backlight/s6e63m0_gamma.h deleted file mode 100644 index 2c44bdb0696b..000000000000 --- a/trunk/drivers/video/backlight/s6e63m0_gamma.h +++ /dev/null @@ -1,266 +0,0 @@ -/* linux/drivers/video/samsung/s6e63m0_brightness.h - * - * Gamma level definitions. - * - * Copyright (c) 2009 Samsung Electronics - * InKi Dae - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. -*/ - -#ifndef _S6E63M0_BRIGHTNESS_H -#define _S6E63M0_BRIGHTNESS_H - -#define MAX_GAMMA_LEVEL 11 -#define GAMMA_TABLE_COUNT 21 - -/* gamma value: 2.2 */ -static const unsigned int s6e63m0_22_300[] = { - 0x18, 0x08, 0x24, 0x5f, 0x50, 0x2d, 0xB6, - 0xB9, 0xA7, 0xAd, 0xB1, 0x9f, 0xbe, 0xC0, - 0xB5, 0x00, 0xa0, 0x00, 0xa4, 0x00, 0xdb -}; - -static const unsigned int s6e63m0_22_280[] = { - 0x18, 0x08, 0x24, 0x64, 0x56, 0x33, 0xB6, - 0xBA, 0xA8, 0xAC, 0xB1, 0x9D, 0xC1, 0xC1, - 0xB7, 0x00, 0x9C, 0x00, 0x9F, 0x00, 0xD6 -}; - -static const unsigned int s6e63m0_22_260[] = { - 0x18, 0x08, 0x24, 0x66, 0x58, 0x34, 0xB6, - 0xBA, 0xA7, 0xAF, 0xB3, 0xA0, 0xC1, 0xC2, - 0xB7, 0x00, 0x97, 0x00, 0x9A, 0x00, 0xD1 - -}; - -static const unsigned int s6e63m0_22_240[] = { - 0x18, 0x08, 0x24, 0x62, 0x54, 0x30, 0xB9, - 0xBB, 0xA9, 0xB0, 0xB3, 0xA1, 0xC1, 0xC3, - 0xB7, 0x00, 0x91, 0x00, 0x95, 0x00, 0xDA - -}; -static const unsigned int s6e63m0_22_220[] = { - 0x18, 0x08, 0x24, 0x63, 0x53, 0x31, 0xB8, - 0xBC, 0xA9, 0xB0, 0xB5, 0xA2, 0xC4, 0xC4, - 0xB8, 0x00, 0x8B, 0x00, 0x8E, 0x00, 0xC2 -}; - -static const unsigned int s6e63m0_22_200[] = { - 0x18, 0x08, 0x24, 0x66, 0x55, 0x34, 0xBA, - 0xBD, 0xAB, 0xB1, 0xB5, 0xA3, 0xC5, 0xC6, - 0xB9, 0x00, 0x85, 0x00, 0x88, 0x00, 0xBA -}; - -static const unsigned int s6e63m0_22_170[] = { - 0x18, 0x08, 0x24, 0x69, 0x54, 0x37, 0xBB, - 0xBE, 0xAC, 0xB4, 0xB7, 0xA6, 0xC7, 0xC8, - 0xBC, 0x00, 0x7B, 0x00, 0x7E, 0x00, 0xAB -}; - -static const unsigned int s6e63m0_22_140[] = { - 0x18, 0x08, 0x24, 0x6C, 0x54, 0x3A, 0xBC, - 0xBF, 0xAC, 0xB7, 0xBB, 0xA9, 0xC9, 0xC9, - 0xBE, 0x00, 0x71, 0x00, 0x73, 0x00, 0x9E -}; - -static const unsigned int s6e63m0_22_110[] = { - 0x18, 0x08, 0x24, 0x70, 0x51, 0x3E, 0xBF, - 0xC1, 0xAF, 0xB9, 0xBC, 0xAB, 0xCC, 0xCC, - 0xC2, 0x00, 0x65, 0x00, 0x67, 0x00, 0x8D -}; - -static const unsigned int s6e63m0_22_90[] = { - 0x18, 0x08, 0x24, 0x73, 0x4A, 0x3D, 0xC0, - 0xC2, 0xB1, 0xBB, 0xBE, 0xAC, 0xCE, 0xCF, - 0xC5, 0x00, 0x5D, 0x00, 0x5E, 0x00, 0x82 -}; - -static const unsigned int s6e63m0_22_30[] = { - 0x18, 0x08, 0x24, 0x78, 0xEC, 0x3D, 0xC8, - 0xC2, 0xB6, 0xC4, 0xC7, 0xB6, 0xD5, 0xD7, - 0xCC, 0x00, 0x39, 0x00, 0x36, 0x00, 0x51 -}; - -/* gamma value: 1.9 */ -static const unsigned int s6e63m0_19_300[] = { - 0x18, 0x08, 0x24, 0x61, 0x5F, 0x39, 0xBA, - 0xBD, 0xAD, 0xB1, 0xB6, 0xA5, 0xC4, 0xC5, - 0xBC, 0x00, 0xA0, 0x00, 0xA4, 0x00, 0xDB -}; - -static const unsigned int s6e63m0_19_280[] = { - 0x18, 0x08, 0x24, 0x61, 0x60, 0x39, 0xBB, - 0xBE, 0xAD, 0xB2, 0xB6, 0xA6, 0xC5, 0xC7, - 0xBD, 0x00, 0x9B, 0x00, 0x9E, 0x00, 0xD5 -}; - -static const unsigned int s6e63m0_19_260[] = { - 0x18, 0x08, 0x24, 0x63, 0x61, 0x3B, 0xBA, - 0xBE, 0xAC, 0xB3, 0xB8, 0xA7, 0xC6, 0xC8, - 0xBD, 0x00, 0x96, 0x00, 0x98, 0x00, 0xCF -}; - -static const unsigned int s6e63m0_19_240[] = { - 0x18, 0x08, 0x24, 0x67, 0x64, 0x3F, 0xBB, - 0xBE, 0xAD, 0xB3, 0xB9, 0xA7, 0xC8, 0xC9, - 0xBE, 0x00, 0x90, 0x00, 0x92, 0x00, 0xC8 -}; - -static const unsigned int s6e63m0_19_220[] = { - 0x18, 0x08, 0x24, 0x68, 0x64, 0x40, 0xBC, - 0xBF, 0xAF, 0xB4, 0xBA, 0xA9, 0xC8, 0xCA, - 0xBE, 0x00, 0x8B, 0x00, 0x8C, 0x00, 0xC0 -}; - -static const unsigned int s6e63m0_19_200[] = { - 0x18, 0x08, 0x24, 0x68, 0x64, 0x3F, 0xBE, - 0xC0, 0xB0, 0xB6, 0xBB, 0xAB, 0xC8, 0xCB, - 0xBF, 0x00, 0x85, 0x00, 0x86, 0x00, 0xB8 -}; - -static const unsigned int s6e63m0_19_170[] = { - 0x18, 0x08, 0x24, 0x69, 0x64, 0x40, 0xBF, - 0xC1, 0xB0, 0xB9, 0xBE, 0xAD, 0xCB, 0xCD, - 0xC2, 0x00, 0x7A, 0x00, 0x7B, 0x00, 0xAA -}; - -static const unsigned int s6e63m0_19_140[] = { - 0x18, 0x08, 0x24, 0x6E, 0x65, 0x45, 0xC0, - 0xC3, 0xB2, 0xBA, 0xBE, 0xAE, 0xCD, 0xD0, - 0xC4, 0x00, 0x70, 0x00, 0x70, 0x00, 0x9C -}; - -static const unsigned int s6e63m0_19_110[] = { - 0x18, 0x08, 0x24, 0x6F, 0x65, 0x46, 0xC2, - 0xC4, 0xB3, 0xBF, 0xC2, 0xB2, 0xCF, 0xD1, - 0xC6, 0x00, 0x64, 0x00, 0x64, 0x00, 0x8D -}; - -static const unsigned int s6e63m0_19_90[] = { - 0x18, 0x08, 0x24, 0x74, 0x60, 0x4A, 0xC3, - 0xC6, 0xB5, 0xBF, 0xC3, 0xB2, 0xD2, 0xD3, - 0xC8, 0x00, 0x5B, 0x00, 0x5B, 0x00, 0x81 -}; - -static const unsigned int s6e63m0_19_30[] = { - 0x18, 0x08, 0x24, 0x84, 0x45, 0x4F, 0xCA, - 0xCB, 0xBC, 0xC9, 0xCB, 0xBC, 0xDA, 0xDA, - 0xD0, 0x00, 0x35, 0x00, 0x34, 0x00, 0x4E -}; - -/* gamma value: 1.7 */ -static const unsigned int s6e63m0_17_300[] = { - 0x18, 0x08, 0x24, 0x70, 0x70, 0x4F, 0xBF, - 0xC2, 0xB2, 0xB8, 0xBC, 0xAC, 0xCB, 0xCD, - 0xC3, 0x00, 0xA0, 0x00, 0xA4, 0x00, 0xDB -}; - -static const unsigned int s6e63m0_17_280[] = { - 0x18, 0x08, 0x24, 0x71, 0x71, 0x50, 0xBF, - 0xC2, 0xB2, 0xBA, 0xBE, 0xAE, 0xCB, 0xCD, - 0xC3, 0x00, 0x9C, 0x00, 0x9F, 0x00, 0xD6 -}; - -static const unsigned int s6e63m0_17_260[] = { - 0x18, 0x08, 0x24, 0x72, 0x72, 0x50, 0xC0, - 0xC3, 0xB4, 0xB9, 0xBE, 0xAE, 0xCC, 0xCF, - 0xC4, 0x00, 0x97, 0x00, 0x9A, 0x00, 0xD1 -}; - -static const unsigned int s6e63m0_17_240[] = { - 0x18, 0x08, 0x24, 0x71, 0x72, 0x4F, 0xC2, - 0xC4, 0xB5, 0xBB, 0xBF, 0xB0, 0xCC, 0xCF, - 0xC3, 0x00, 0x91, 0x00, 0x95, 0x00, 0xCA -}; - -static const unsigned int s6e63m0_17_220[] = { - 0x18, 0x08, 0x24, 0x71, 0x73, 0x4F, 0xC2, - 0xC5, 0xB5, 0xBD, 0xC0, 0xB2, 0xCD, 0xD1, - 0xC5, 0x00, 0x8B, 0x00, 0x8E, 0x00, 0xC2 -}; - -static const unsigned int s6e63m0_17_200[] = { - 0x18, 0x08, 0x24, 0x72, 0x75, 0x51, 0xC2, - 0xC6, 0xB5, 0xBF, 0xC1, 0xB3, 0xCE, 0xD1, - 0xC6, 0x00, 0x85, 0x00, 0x88, 0x00, 0xBA -}; - -static const unsigned int s6e63m0_17_170[] = { - 0x18, 0x08, 0x24, 0x75, 0x77, 0x54, 0xC3, - 0xC7, 0xB7, 0xC0, 0xC3, 0xB4, 0xD1, 0xD3, - 0xC9, 0x00, 0x7B, 0x00, 0x7E, 0x00, 0xAB -}; - -static const unsigned int s6e63m0_17_140[] = { - 0x18, 0x08, 0x24, 0x7B, 0x77, 0x58, 0xC3, - 0xC8, 0xB8, 0xC2, 0xC6, 0xB6, 0xD3, 0xD4, - 0xCA, 0x00, 0x71, 0x00, 0x73, 0x00, 0x9E -}; - -static const unsigned int s6e63m0_17_110[] = { - 0x18, 0x08, 0x24, 0x81, 0x7B, 0x5D, 0xC6, - 0xCA, 0xBB, 0xC3, 0xC7, 0xB8, 0xD6, 0xD8, - 0xCD, 0x00, 0x65, 0x00, 0x67, 0x00, 0x8D -}; - -static const unsigned int s6e63m0_17_90[] = { - 0x18, 0x08, 0x24, 0x82, 0x7A, 0x5B, 0xC8, - 0xCB, 0xBD, 0xC5, 0xCA, 0xBA, 0xD6, 0xD8, - 0xCE, 0x00, 0x5D, 0x00, 0x5E, 0x00, 0x82 -}; - -static const unsigned int s6e63m0_17_30[] = { - 0x18, 0x08, 0x24, 0x8F, 0x73, 0x63, 0xD1, - 0xD0, 0xC5, 0xCC, 0xD1, 0xC2, 0xDE, 0xE0, - 0xD6, 0x00, 0x39, 0x00, 0x36, 0x00, 0x51 -}; - -struct s6e63m0_gamma { - unsigned int *gamma_22_table[MAX_GAMMA_LEVEL]; - unsigned int *gamma_19_table[MAX_GAMMA_LEVEL]; - unsigned int *gamma_17_table[MAX_GAMMA_LEVEL]; -}; - -static struct s6e63m0_gamma gamma_table = { - .gamma_22_table[0] = (unsigned int *)&s6e63m0_22_30, - .gamma_22_table[1] = (unsigned int *)&s6e63m0_22_90, - .gamma_22_table[2] = (unsigned int *)&s6e63m0_22_110, - .gamma_22_table[3] = (unsigned int *)&s6e63m0_22_140, - .gamma_22_table[4] = (unsigned int *)&s6e63m0_22_170, - .gamma_22_table[5] = (unsigned int *)&s6e63m0_22_200, - .gamma_22_table[6] = (unsigned int *)&s6e63m0_22_220, - .gamma_22_table[7] = (unsigned int *)&s6e63m0_22_240, - .gamma_22_table[8] = (unsigned int *)&s6e63m0_22_260, - .gamma_22_table[9] = (unsigned int *)&s6e63m0_22_280, - .gamma_22_table[10] = (unsigned int *)&s6e63m0_22_300, - - .gamma_19_table[0] = (unsigned int *)&s6e63m0_19_30, - .gamma_19_table[1] = (unsigned int *)&s6e63m0_19_90, - .gamma_19_table[2] = (unsigned int *)&s6e63m0_19_110, - .gamma_19_table[3] = (unsigned int *)&s6e63m0_19_140, - .gamma_19_table[4] = (unsigned int *)&s6e63m0_19_170, - .gamma_19_table[5] = (unsigned int *)&s6e63m0_19_200, - .gamma_19_table[6] = (unsigned int *)&s6e63m0_19_220, - .gamma_19_table[7] = (unsigned int *)&s6e63m0_19_240, - .gamma_19_table[8] = (unsigned int *)&s6e63m0_19_260, - .gamma_19_table[9] = (unsigned int *)&s6e63m0_19_280, - .gamma_19_table[10] = (unsigned int *)&s6e63m0_19_300, - - .gamma_17_table[0] = (unsigned int *)&s6e63m0_17_30, - .gamma_17_table[1] = (unsigned int *)&s6e63m0_17_90, - .gamma_17_table[2] = (unsigned int *)&s6e63m0_17_110, - .gamma_17_table[3] = (unsigned int *)&s6e63m0_17_140, - .gamma_17_table[4] = (unsigned int *)&s6e63m0_17_170, - .gamma_17_table[5] = (unsigned int *)&s6e63m0_17_200, - .gamma_17_table[6] = (unsigned int *)&s6e63m0_17_220, - .gamma_17_table[7] = (unsigned int *)&s6e63m0_17_240, - .gamma_17_table[8] = (unsigned int *)&s6e63m0_17_260, - .gamma_17_table[9] = (unsigned int *)&s6e63m0_17_280, - .gamma_17_table[10] = (unsigned int *)&s6e63m0_17_300, -}; - -#endif - diff --git a/trunk/include/linux/acpi.h b/trunk/include/linux/acpi.h index 2c60f1f70b38..3da73f5f0ae9 100644 --- a/trunk/include/linux/acpi.h +++ b/trunk/include/linux/acpi.h @@ -248,8 +248,6 @@ int acpi_check_region(resource_size_t start, resource_size_t n, int acpi_check_mem_region(resource_size_t start, resource_size_t n, const char *name); -int acpi_resources_are_enforced(void); - #ifdef CONFIG_PM_SLEEP void __init acpi_no_s4_hw_signature(void); void __init acpi_old_suspend_ordering(void); diff --git a/trunk/include/linux/ftrace_event.h b/trunk/include/linux/ftrace_event.h index 3167f2df4126..c082f223e2fe 100644 --- a/trunk/include/linux/ftrace_event.h +++ b/trunk/include/linux/ftrace_event.h @@ -73,25 +73,18 @@ struct trace_iterator { }; -struct trace_event; - typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter, - int flags, struct trace_event *event); - -struct trace_event_functions { + int flags); +struct trace_event { + struct hlist_node node; + struct list_head list; + int type; trace_print_func trace; trace_print_func raw; trace_print_func hex; trace_print_func binary; }; -struct trace_event { - struct hlist_node node; - struct list_head list; - int type; - struct trace_event_functions *funcs; -}; - extern int register_ftrace_event(struct trace_event *event); extern int unregister_ftrace_event(struct trace_event *event); @@ -123,70 +116,28 @@ void tracing_record_cmdline(struct task_struct *tsk); struct event_filter; -enum trace_reg { - TRACE_REG_REGISTER, - TRACE_REG_UNREGISTER, - TRACE_REG_PERF_REGISTER, - TRACE_REG_PERF_UNREGISTER, -}; - -struct ftrace_event_call; - -struct ftrace_event_class { - char *system; - void *probe; -#ifdef CONFIG_PERF_EVENTS - void *perf_probe; -#endif - int (*reg)(struct ftrace_event_call *event, - enum trace_reg type); - int (*define_fields)(struct ftrace_event_call *); - struct list_head *(*get_fields)(struct ftrace_event_call *); - struct list_head fields; - int (*raw_init)(struct ftrace_event_call *); -}; - -enum { - TRACE_EVENT_FL_ENABLED_BIT, - TRACE_EVENT_FL_FILTERED_BIT, -}; - -enum { - TRACE_EVENT_FL_ENABLED = (1 << TRACE_EVENT_FL_ENABLED_BIT), - TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT), -}; - struct ftrace_event_call { struct list_head list; - struct ftrace_event_class *class; char *name; + char *system; struct dentry *dir; - struct trace_event event; + struct trace_event *event; + int enabled; + int (*regfunc)(struct ftrace_event_call *); + void (*unregfunc)(struct ftrace_event_call *); + int id; const char *print_fmt; + int (*raw_init)(struct ftrace_event_call *); + int (*define_fields)(struct ftrace_event_call *); + struct list_head fields; + int filter_active; struct event_filter *filter; void *mod; void *data; - /* - * 32 bit flags: - * bit 1: enabled - * bit 2: filter_active - * - * Changes to flags must hold the event_mutex. - * - * Note: Reads of flags do not hold the event_mutex since - * they occur in critical sections. But the way flags - * is currently used, these changes do no affect the code - * except that when a change is made, it may have a slight - * delay in propagating the changes to other CPUs due to - * caching and such. - */ - unsigned int flags; - -#ifdef CONFIG_PERF_EVENTS int perf_refcount; - struct hlist_head *perf_events; -#endif + int (*perf_event_enable)(struct ftrace_event_call *); + void (*perf_event_disable)(struct ftrace_event_call *); }; #define PERF_MAX_TRACE_SIZE 2048 @@ -243,22 +194,24 @@ struct perf_event; DECLARE_PER_CPU(struct pt_regs, perf_trace_regs); -extern int perf_trace_init(struct perf_event *event); -extern void perf_trace_destroy(struct perf_event *event); -extern int perf_trace_enable(struct perf_event *event); -extern void perf_trace_disable(struct perf_event *event); -extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, +extern int perf_trace_enable(int event_id); +extern void perf_trace_disable(int event_id); +extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, char *filter_str); extern void ftrace_profile_free_filter(struct perf_event *event); -extern void *perf_trace_buf_prepare(int size, unsigned short type, - struct pt_regs *regs, int *rctxp); +extern void * +perf_trace_buf_prepare(int size, unsigned short type, int *rctxp, + unsigned long *irq_flags); static inline void perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr, - u64 count, struct pt_regs *regs, void *head) + u64 count, unsigned long irq_flags, struct pt_regs *regs) { - perf_tp_event(addr, count, raw_data, size, regs, head); + struct trace_entry *entry = raw_data; + + perf_tp_event(entry->type, addr, count, raw_data, size, regs); perf_swevent_put_recursion_context(rctx); + local_irq_restore(irq_flags); } #endif diff --git a/trunk/include/linux/i2c/adp8860.h b/trunk/include/linux/i2c/adp8860.h deleted file mode 100644 index 0b4d39855c91..000000000000 --- a/trunk/include/linux/i2c/adp8860.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Definitions and platform data for Analog Devices - * Backlight drivers ADP8860 - * - * Copyright 2009-2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#ifndef __LINUX_I2C_ADP8860_H -#define __LINUX_I2C_ADP8860_H - -#include -#include - -#define ID_ADP8860 8860 - -#define ADP8860_MAX_BRIGHTNESS 0x7F -#define FLAG_OFFT_SHIFT 8 - -/* - * LEDs subdevice platform data - */ - -#define ADP8860_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT) -#define ADP8860_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT) -#define ADP8860_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT) -#define ADP8860_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT) - -#define ADP8860_LED_ONT_200ms 0 -#define ADP8860_LED_ONT_600ms 1 -#define ADP8860_LED_ONT_800ms 2 -#define ADP8860_LED_ONT_1200ms 3 - -#define ADP8860_LED_D7 (7) -#define ADP8860_LED_D6 (6) -#define ADP8860_LED_D5 (5) -#define ADP8860_LED_D4 (4) -#define ADP8860_LED_D3 (3) -#define ADP8860_LED_D2 (2) -#define ADP8860_LED_D1 (1) - -/* - * Backlight subdevice platform data - */ - -#define ADP8860_BL_D7 (1 << 6) -#define ADP8860_BL_D6 (1 << 5) -#define ADP8860_BL_D5 (1 << 4) -#define ADP8860_BL_D4 (1 << 3) -#define ADP8860_BL_D3 (1 << 2) -#define ADP8860_BL_D2 (1 << 1) -#define ADP8860_BL_D1 (1 << 0) - -#define ADP8860_FADE_T_DIS 0 /* Fade Timer Disabled */ -#define ADP8860_FADE_T_300ms 1 /* 0.3 Sec */ -#define ADP8860_FADE_T_600ms 2 -#define ADP8860_FADE_T_900ms 3 -#define ADP8860_FADE_T_1200ms 4 -#define ADP8860_FADE_T_1500ms 5 -#define ADP8860_FADE_T_1800ms 6 -#define ADP8860_FADE_T_2100ms 7 -#define ADP8860_FADE_T_2400ms 8 -#define ADP8860_FADE_T_2700ms 9 -#define ADP8860_FADE_T_3000ms 10 -#define ADP8860_FADE_T_3500ms 11 -#define ADP8860_FADE_T_4000ms 12 -#define ADP8860_FADE_T_4500ms 13 -#define ADP8860_FADE_T_5000ms 14 -#define ADP8860_FADE_T_5500ms 15 /* 5.5 Sec */ - -#define ADP8860_FADE_LAW_LINEAR 0 -#define ADP8860_FADE_LAW_SQUARE 1 -#define ADP8860_FADE_LAW_CUBIC1 2 -#define ADP8860_FADE_LAW_CUBIC2 3 - -#define ADP8860_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */ -#define ADP8860_BL_AMBL_FILT_160ms 1 -#define ADP8860_BL_AMBL_FILT_320ms 2 -#define ADP8860_BL_AMBL_FILT_640ms 3 -#define ADP8860_BL_AMBL_FILT_1280ms 4 -#define ADP8860_BL_AMBL_FILT_2560ms 5 -#define ADP8860_BL_AMBL_FILT_5120ms 6 -#define ADP8860_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */ - -/* - * Blacklight current 0..30mA - */ -#define ADP8860_BL_CUR_mA(I) ((I * 127) / 30) - -/* - * L2 comparator current 0..1106uA - */ -#define ADP8860_L2_COMP_CURR_uA(I) ((I * 255) / 1106) - -/* - * L3 comparator current 0..138uA - */ -#define ADP8860_L3_COMP_CURR_uA(I) ((I * 255) / 138) - -struct adp8860_backlight_platform_data { - u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */ - - u8 bl_fade_in; /* Backlight Fade-In Timer */ - u8 bl_fade_out; /* Backlight Fade-Out Timer */ - u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */ - - u8 en_ambl_sens; /* 1 = enable ambient light sensor */ - u8 abml_filt; /* Light sensor filter time */ - - u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l2_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l2_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l3_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l3_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - - u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ - u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ - u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ - u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ - - /** - * Independent Current Sinks / LEDS - * Sinks not assigned to the Backlight can be exposed to - * user space using the LEDS CLASS interface - */ - - int num_leds; - struct led_info *leds; - u8 led_fade_in; /* LED Fade-In Timer */ - u8 led_fade_out; /* LED Fade-Out Timer */ - u8 led_fade_law; /* fade-on/fade-off transfer characteristic */ - u8 led_on_time; - - /** - * Gain down disable. Setting this option does not allow the - * charge pump to switch to lower gains. NOT AVAILABLE on ADP8860 - * 1 = the charge pump doesn't switch down in gain until all LEDs are 0. - * The charge pump switches up in gain as needed. This feature is - * useful if the ADP8863 charge pump is used to drive an external load. - * This feature must be used when utilizing small fly capacitors - * (0402 or smaller). - * 0 = the charge pump automatically switches up and down in gain. - * This provides optimal efficiency, but is not suitable for driving - * loads that are not connected through the ADP8863 diode drivers. - * Additionally, the charge pump fly capacitors should be low ESR - * and sized 0603 or greater. - */ - - u8 gdwn_dis; -}; - -#endif /* __LINUX_I2C_ADP8860_H */ diff --git a/trunk/include/linux/lcd.h b/trunk/include/linux/lcd.h index 8877123f2d6e..c67fecafff90 100644 --- a/trunk/include/linux/lcd.h +++ b/trunk/include/linux/lcd.h @@ -69,29 +69,6 @@ struct lcd_device { struct device dev; }; -struct lcd_platform_data { - /* reset lcd panel device. */ - int (*reset)(struct lcd_device *ld); - /* on or off to lcd panel. if 'enable' is 0 then - lcd power off and 1, lcd power on. */ - int (*power_on)(struct lcd_device *ld, int enable); - - /* it indicates whether lcd panel was enabled - from bootloader or not. */ - int lcd_enabled; - /* it means delay for stable time when it becomes low to high - or high to low that is dependent on whether reset gpio is - low active or high active. */ - unsigned int reset_delay; - /* stable time needing to become lcd power on. */ - unsigned int power_on_delay; - /* stable time needing to become lcd power off. */ - unsigned int power_off_delay; - - /* it could be used for any purpose. */ - void *pdata; -}; - static inline void lcd_set_power(struct lcd_device *ld, int power) { mutex_lock(&ld->update_lock); diff --git a/trunk/include/linux/leds.h b/trunk/include/linux/leds.h index ba6986a11663..d8bf9665e70c 100644 --- a/trunk/include/linux/leds.h +++ b/trunk/include/linux/leds.h @@ -149,18 +149,14 @@ struct gpio_led { unsigned default_state : 2; /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */ }; -#define LEDS_GPIO_DEFSTATE_OFF 0 -#define LEDS_GPIO_DEFSTATE_ON 1 -#define LEDS_GPIO_DEFSTATE_KEEP 2 +#define LEDS_GPIO_DEFSTATE_OFF 0 +#define LEDS_GPIO_DEFSTATE_ON 1 +#define LEDS_GPIO_DEFSTATE_KEEP 2 struct gpio_led_platform_data { int num_leds; struct gpio_led *leds; - -#define GPIO_LED_NO_BLINK_LOW 0 /* No blink GPIO state low */ -#define GPIO_LED_NO_BLINK_HIGH 1 /* No blink GPIO state high */ -#define GPIO_LED_BLINK 2 /* Plase, blink */ - int (*gpio_blink_set)(unsigned gpio, int state, + int (*gpio_blink_set)(unsigned gpio, unsigned long *delay_on, unsigned long *delay_off); }; diff --git a/trunk/include/linux/mfd/mc13783.h b/trunk/include/linux/mfd/mc13783.h index 4a894f688549..8895d9d8879c 100644 --- a/trunk/include/linux/mfd/mc13783.h +++ b/trunk/include/linux/mfd/mc13783.h @@ -64,70 +64,6 @@ static inline int mc13783_ackirq(struct mc13783 *mc13783, int irq) MC13783_ADC0_TSMOD1 | \ MC13783_ADC0_TSMOD2) -struct mc13783_led_platform_data { -#define MC13783_LED_MD 0 -#define MC13783_LED_AD 1 -#define MC13783_LED_KP 2 -#define MC13783_LED_R1 3 -#define MC13783_LED_G1 4 -#define MC13783_LED_B1 5 -#define MC13783_LED_R2 6 -#define MC13783_LED_G2 7 -#define MC13783_LED_B2 8 -#define MC13783_LED_R3 9 -#define MC13783_LED_G3 10 -#define MC13783_LED_B3 11 -#define MC13783_LED_MAX MC13783_LED_B3 - int id; - const char *name; - const char *default_trigger; - -/* Three or two bits current selection depending on the led */ - char max_current; -}; - -struct mc13783_leds_platform_data { - int num_leds; - struct mc13783_led_platform_data *led; - -#define MC13783_LED_TRIODE_MD (1 << 0) -#define MC13783_LED_TRIODE_AD (1 << 1) -#define MC13783_LED_TRIODE_KP (1 << 2) -#define MC13783_LED_BOOST_EN (1 << 3) -#define MC13783_LED_TC1HALF (1 << 4) -#define MC13783_LED_SLEWLIMTC (1 << 5) -#define MC13783_LED_SLEWLIMBL (1 << 6) -#define MC13783_LED_TRIODE_TC1 (1 << 7) -#define MC13783_LED_TRIODE_TC2 (1 << 8) -#define MC13783_LED_TRIODE_TC3 (1 << 9) - int flags; - -#define MC13783_LED_AB_DISABLED 0 -#define MC13783_LED_AB_MD1 1 -#define MC13783_LED_AB_MD12 2 -#define MC13783_LED_AB_MD123 3 -#define MC13783_LED_AB_MD1234 4 -#define MC13783_LED_AB_MD1234_AD1 5 -#define MC13783_LED_AB_MD1234_AD12 6 -#define MC13783_LED_AB_MD1_AD 7 - char abmode; - -#define MC13783_LED_ABREF_200MV 0 -#define MC13783_LED_ABREF_400MV 1 -#define MC13783_LED_ABREF_600MV 2 -#define MC13783_LED_ABREF_800MV 3 - char abref; - -#define MC13783_LED_PERIOD_10MS 0 -#define MC13783_LED_PERIOD_100MS 1 -#define MC13783_LED_PERIOD_500MS 2 -#define MC13783_LED_PERIOD_2S 3 - char bl_period; - char tc1_period; - char tc2_period; - char tc3_period; -}; - /* to be cleaned up */ struct regulator_init_data; @@ -144,14 +80,12 @@ struct mc13783_regulator_platform_data { struct mc13783_platform_data { int num_regulators; struct mc13783_regulator_init_data *regulators; - struct mc13783_leds_platform_data *leds; #define MC13783_USE_TOUCHSCREEN (1 << 0) #define MC13783_USE_CODEC (1 << 1) #define MC13783_USE_ADC (1 << 2) #define MC13783_USE_RTC (1 << 3) #define MC13783_USE_REGULATOR (1 << 4) -#define MC13783_USE_LED (1 << 5) unsigned int flags; }; diff --git a/trunk/include/linux/mfd/pcf50633/backlight.h b/trunk/include/linux/mfd/pcf50633/backlight.h deleted file mode 100644 index 83747e217b27..000000000000 --- a/trunk/include/linux/mfd/pcf50633/backlight.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2009-2010, Lars-Peter Clausen - * PCF50633 backlight device driver - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef __LINUX_MFD_PCF50633_BACKLIGHT -#define __LINUX_MFD_PCF50633_BACKLIGHT - -/* -* @default_brightness: Backlight brightness is initialized to this value -* -* Brightness to be used after the driver has been probed. -* Valid range 0-63. -* -* @default_brightness_limit: The actual brightness is limited by this value -* -* Brightness limit to be used after the driver has been probed. This is useful -* when it is not known how much power is available for the backlight during -* probe. -* Valid range 0-63. Can be changed later with pcf50633_bl_set_brightness_limit. -* -* @ramp_time: Display ramp time when changing brightness -* -* When changing the backlights brightness the change is not instant, instead -* it fades smooth from one state to another. This value specifies how long -* the fade should take. The lower the value the higher the fade time. -* Valid range 0-255 -*/ -struct pcf50633_bl_platform_data { - unsigned int default_brightness; - unsigned int default_brightness_limit; - uint8_t ramp_time; -}; - - -struct pcf50633; - -int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit); - -#endif - diff --git a/trunk/include/linux/mfd/pcf50633/core.h b/trunk/include/linux/mfd/pcf50633/core.h index ad411a78870c..3398bd9aab11 100644 --- a/trunk/include/linux/mfd/pcf50633/core.h +++ b/trunk/include/linux/mfd/pcf50633/core.h @@ -18,7 +18,6 @@ #include #include #include -#include struct pcf50633; @@ -44,8 +43,6 @@ struct pcf50633_platform_data { void (*force_shutdown)(struct pcf50633 *); u8 resumers[5]; - - struct pcf50633_bl_platform_data *backlight_data; }; struct pcf50633_irq { @@ -155,7 +152,6 @@ struct pcf50633 { struct platform_device *mbc_pdev; struct platform_device *adc_pdev; struct platform_device *input_pdev; - struct platform_device *bl_pdev; struct platform_device *regulator_pdev[PCF50633_NUM_REGULATORS]; }; diff --git a/trunk/include/linux/perf_event.h b/trunk/include/linux/perf_event.h index fb6c91eac7e3..3fd5c82e0e18 100644 --- a/trunk/include/linux/perf_event.h +++ b/trunk/include/linux/perf_event.h @@ -485,7 +485,6 @@ struct perf_guest_info_callbacks { #include #include #include -#include #define PERF_MAX_STACK_DEPTH 255 @@ -588,19 +587,21 @@ struct perf_mmap_data { struct rcu_head rcu_head; #ifdef CONFIG_PERF_USE_VMALLOC struct work_struct work; - int page_order; /* allocation order */ #endif + int data_order; int nr_pages; /* nr of data pages */ int writable; /* are we writable */ int nr_locked; /* nr pages mlocked */ atomic_t poll; /* POLL_ for wakeups */ + atomic_t events; /* event_id limit */ - local_t head; /* write position */ - local_t nest; /* nested writers */ - local_t events; /* event limit */ - local_t wakeup; /* wakeup stamp */ - local_t lost; /* nr records lost */ + atomic_long_t head; /* write position */ + atomic_long_t done_head; /* completed head */ + + atomic_t lock; /* concurrent writes */ + atomic_t wakeup; /* needs a wakeup */ + atomic_t lost; /* nr records lost */ long watermark; /* wakeup watermark */ @@ -727,7 +728,6 @@ struct perf_event { perf_overflow_handler_t overflow_handler; #ifdef CONFIG_EVENT_TRACING - struct ftrace_event_call *tp_event; struct event_filter *filter; #endif @@ -803,12 +803,11 @@ struct perf_cpu_context { struct perf_output_handle { struct perf_event *event; struct perf_mmap_data *data; - unsigned long wakeup; - unsigned long size; - void *addr; - int page; + unsigned long head; + unsigned long offset; int nmi; int sample; + int locked; }; #ifdef CONFIG_PERF_EVENTS @@ -994,9 +993,8 @@ static inline bool perf_paranoid_kernel(void) } extern void perf_event_init(void); -extern void perf_tp_event(u64 addr, u64 count, void *record, - int entry_size, struct pt_regs *regs, - struct hlist_head *head); +extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, + int entry_size, struct pt_regs *regs); extern void perf_bp_event(struct perf_event *event, void *data); #ifndef perf_misc_flags diff --git a/trunk/include/linux/syscalls.h b/trunk/include/linux/syscalls.h index a1a86a53bc73..057929b0a651 100644 --- a/trunk/include/linux/syscalls.h +++ b/trunk/include/linux/syscalls.h @@ -103,6 +103,22 @@ struct perf_event_attr; #define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) #define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) +#ifdef CONFIG_PERF_EVENTS + +#define TRACE_SYS_ENTER_PERF_INIT(sname) \ + .perf_event_enable = perf_sysenter_enable, \ + .perf_event_disable = perf_sysenter_disable, + +#define TRACE_SYS_EXIT_PERF_INIT(sname) \ + .perf_event_enable = perf_sysexit_enable, \ + .perf_event_disable = perf_sysexit_disable, +#else +#define TRACE_SYS_ENTER_PERF(sname) +#define TRACE_SYS_ENTER_PERF_INIT(sname) +#define TRACE_SYS_EXIT_PERF(sname) +#define TRACE_SYS_EXIT_PERF_INIT(sname) +#endif /* CONFIG_PERF_EVENTS */ + #ifdef CONFIG_FTRACE_SYSCALLS #define __SC_STR_ADECL1(t, a) #a #define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__) @@ -118,43 +134,54 @@ struct perf_event_attr; #define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__) #define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__) -extern struct ftrace_event_class event_class_syscall_enter; -extern struct ftrace_event_class event_class_syscall_exit; -extern struct trace_event_functions enter_syscall_print_funcs; -extern struct trace_event_functions exit_syscall_print_funcs; - #define SYSCALL_TRACE_ENTER_EVENT(sname) \ - static struct syscall_metadata __syscall_meta_##sname; \ + static const struct syscall_metadata __syscall_meta_##sname; \ static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_enter_##sname; \ + static struct trace_event enter_syscall_print_##sname = { \ + .trace = print_syscall_enter, \ + }; \ static struct ftrace_event_call __used \ __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_enter_##sname = { \ .name = "sys_enter"#sname, \ - .class = &event_class_syscall_enter, \ - .event.funcs = &enter_syscall_print_funcs, \ + .system = "syscalls", \ + .event = &enter_syscall_print_##sname, \ + .raw_init = init_syscall_trace, \ + .define_fields = syscall_enter_define_fields, \ + .regfunc = reg_event_syscall_enter, \ + .unregfunc = unreg_event_syscall_enter, \ .data = (void *)&__syscall_meta_##sname,\ + TRACE_SYS_ENTER_PERF_INIT(sname) \ } #define SYSCALL_TRACE_EXIT_EVENT(sname) \ - static struct syscall_metadata __syscall_meta_##sname; \ + static const struct syscall_metadata __syscall_meta_##sname; \ static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_exit_##sname; \ + static struct trace_event exit_syscall_print_##sname = { \ + .trace = print_syscall_exit, \ + }; \ static struct ftrace_event_call __used \ __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_exit_##sname = { \ .name = "sys_exit"#sname, \ - .class = &event_class_syscall_exit, \ - .event.funcs = &exit_syscall_print_funcs, \ + .system = "syscalls", \ + .event = &exit_syscall_print_##sname, \ + .raw_init = init_syscall_trace, \ + .define_fields = syscall_exit_define_fields, \ + .regfunc = reg_event_syscall_exit, \ + .unregfunc = unreg_event_syscall_exit, \ .data = (void *)&__syscall_meta_##sname,\ + TRACE_SYS_EXIT_PERF_INIT(sname) \ } #define SYSCALL_METADATA(sname, nb) \ SYSCALL_TRACE_ENTER_EVENT(sname); \ SYSCALL_TRACE_EXIT_EVENT(sname); \ - static struct syscall_metadata __used \ + static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta_##sname = { \ @@ -164,14 +191,12 @@ extern struct trace_event_functions exit_syscall_print_funcs; .args = args_##sname, \ .enter_event = &event_enter_##sname, \ .exit_event = &event_exit_##sname, \ - .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \ - .exit_fields = LIST_HEAD_INIT(__syscall_meta_##sname.exit_fields), \ }; #define SYSCALL_DEFINE0(sname) \ SYSCALL_TRACE_ENTER_EVENT(_##sname); \ SYSCALL_TRACE_EXIT_EVENT(_##sname); \ - static struct syscall_metadata __used \ + static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta__##sname = { \ @@ -179,8 +204,6 @@ extern struct trace_event_functions exit_syscall_print_funcs; .nb_args = 0, \ .enter_event = &event_enter__##sname, \ .exit_event = &event_exit__##sname, \ - .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \ - .exit_fields = LIST_HEAD_INIT(__syscall_meta__##sname.exit_fields), \ }; \ asmlinkage long sys_##sname(void) #else diff --git a/trunk/include/linux/tracepoint.h b/trunk/include/linux/tracepoint.h index 9a59d1f98cd4..1d85f9a6a199 100644 --- a/trunk/include/linux/tracepoint.h +++ b/trunk/include/linux/tracepoint.h @@ -20,17 +20,12 @@ struct module; struct tracepoint; -struct tracepoint_func { - void *func; - void *data; -}; - struct tracepoint { const char *name; /* Tracepoint name */ int state; /* State. */ void (*regfunc)(void); void (*unregfunc)(void); - struct tracepoint_func *funcs; + void **funcs; } __attribute__((aligned(32))); /* * Aligned on 32 bytes because it is * globally visible and gcc happily @@ -42,19 +37,16 @@ struct tracepoint { * Connect a probe to a tracepoint. * Internal API, should not be used directly. */ -extern int tracepoint_probe_register(const char *name, void *probe, void *data); +extern int tracepoint_probe_register(const char *name, void *probe); /* * Disconnect a probe from a tracepoint. * Internal API, should not be used directly. */ -extern int -tracepoint_probe_unregister(const char *name, void *probe, void *data); +extern int tracepoint_probe_unregister(const char *name, void *probe); -extern int tracepoint_probe_register_noupdate(const char *name, void *probe, - void *data); -extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe, - void *data); +extern int tracepoint_probe_register_noupdate(const char *name, void *probe); +extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe); extern void tracepoint_probe_update_all(void); struct tracepoint_iter { @@ -110,27 +102,17 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin, /* * it_func[0] is never NULL because there is at least one element in the array * when the array itself is non NULL. - * - * Note, the proto and args passed in includes "__data" as the first parameter. - * The reason for this is to handle the "void" prototype. If a tracepoint - * has a "void" prototype, then it is invalid to declare a function - * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just - * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto". */ #define __DO_TRACE(tp, proto, args) \ do { \ - struct tracepoint_func *it_func_ptr; \ - void *it_func; \ - void *__data; \ + void **it_func; \ \ rcu_read_lock_sched_notrace(); \ - it_func_ptr = rcu_dereference_sched((tp)->funcs); \ - if (it_func_ptr) { \ + it_func = rcu_dereference_sched((tp)->funcs); \ + if (it_func) { \ do { \ - it_func = (it_func_ptr)->func; \ - __data = (it_func_ptr)->data; \ - ((void(*)(proto))(it_func))(args); \ - } while ((++it_func_ptr)->func); \ + ((void(*)(proto))(*it_func))(args); \ + } while (*(++it_func)); \ } \ rcu_read_unlock_sched_notrace(); \ } while (0) @@ -140,32 +122,24 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin, * not add unwanted padding between the beginning of the section and the * structure. Force alignment to the same alignment as the section start. */ -#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \ +#define DECLARE_TRACE(name, proto, args) \ extern struct tracepoint __tracepoint_##name; \ static inline void trace_##name(proto) \ { \ if (unlikely(__tracepoint_##name.state)) \ __DO_TRACE(&__tracepoint_##name, \ - TP_PROTO(data_proto), \ - TP_ARGS(data_args)); \ - } \ - static inline int \ - register_trace_##name(void (*probe)(data_proto), void *data) \ - { \ - return tracepoint_probe_register(#name, (void *)probe, \ - data); \ + TP_PROTO(proto), TP_ARGS(args)); \ } \ - static inline int \ - unregister_trace_##name(void (*probe)(data_proto), void *data) \ + static inline int register_trace_##name(void (*probe)(proto)) \ { \ - return tracepoint_probe_unregister(#name, (void *)probe, \ - data); \ + return tracepoint_probe_register(#name, (void *)probe); \ } \ - static inline void \ - check_trace_callback_type_##name(void (*cb)(data_proto)) \ + static inline int unregister_trace_##name(void (*probe)(proto)) \ { \ + return tracepoint_probe_unregister(#name, (void *)probe);\ } + #define DEFINE_TRACE_FN(name, reg, unreg) \ static const char __tpstrtab_##name[] \ __attribute__((section("__tracepoints_strings"))) = #name; \ @@ -182,23 +156,18 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin, EXPORT_SYMBOL(__tracepoint_##name) #else /* !CONFIG_TRACEPOINTS */ -#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \ +#define DECLARE_TRACE(name, proto, args) \ + static inline void _do_trace_##name(struct tracepoint *tp, proto) \ + { } \ static inline void trace_##name(proto) \ { } \ - static inline int \ - register_trace_##name(void (*probe)(data_proto), \ - void *data) \ + static inline int register_trace_##name(void (*probe)(proto)) \ { \ return -ENOSYS; \ } \ - static inline int \ - unregister_trace_##name(void (*probe)(data_proto), \ - void *data) \ + static inline int unregister_trace_##name(void (*probe)(proto)) \ { \ return -ENOSYS; \ - } \ - static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ - { \ } #define DEFINE_TRACE_FN(name, reg, unreg) @@ -207,29 +176,6 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin, #define EXPORT_TRACEPOINT_SYMBOL(name) #endif /* CONFIG_TRACEPOINTS */ - -/* - * The need for the DECLARE_TRACE_NOARGS() is to handle the prototype - * (void). "void" is a special value in a function prototype and can - * not be combined with other arguments. Since the DECLARE_TRACE() - * macro adds a data element at the beginning of the prototype, - * we need a way to differentiate "(void *data, proto)" from - * "(void *data, void)". The second prototype is invalid. - * - * DECLARE_TRACE_NOARGS() passes "void" as the tracepoint prototype - * and "void *__data" as the callback prototype. - * - * DECLARE_TRACE() passes "proto" as the tracepoint protoype and - * "void *__data, proto" as the callback prototype. - */ -#define DECLARE_TRACE_NOARGS(name) \ - __DECLARE_TRACE(name, void, , void *__data, __data) - -#define DECLARE_TRACE(name, proto, args) \ - __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \ - PARAMS(void *__data, proto), \ - PARAMS(__data, args)) - #endif /* DECLARE_TRACE */ #ifndef TRACE_EVENT diff --git a/trunk/include/trace/ftrace.h b/trunk/include/trace/ftrace.h index 3d685d1f2a03..88c59c13ea7b 100644 --- a/trunk/include/trace/ftrace.h +++ b/trunk/include/trace/ftrace.h @@ -62,13 +62,10 @@ struct trace_entry ent; \ tstruct \ char __data[0]; \ - }; \ - \ - static struct ftrace_event_class event_class_##name; - + }; #undef DEFINE_EVENT #define DEFINE_EVENT(template, name, proto, args) \ - static struct ftrace_event_call __used \ + static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_##name #undef DEFINE_EVENT_PRINT @@ -150,7 +147,7 @@ * * entry = iter->ent; * - * if (entry->type != event_->event.type) { + * if (entry->type != event_.id) { * WARN_ON_ONCE(1); * return TRACE_TYPE_UNHANDLED; * } @@ -209,22 +206,18 @@ #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ static notrace enum print_line_t \ -ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ - struct trace_event *trace_event) \ +ftrace_raw_output_id_##call(int event_id, const char *name, \ + struct trace_iterator *iter, int flags) \ { \ - struct ftrace_event_call *event; \ struct trace_seq *s = &iter->seq; \ struct ftrace_raw_##call *field; \ struct trace_entry *entry; \ struct trace_seq *p; \ int ret; \ \ - event = container_of(trace_event, struct ftrace_event_call, \ - event); \ - \ entry = iter->ent; \ \ - if (entry->type != event->event.type) { \ + if (entry->type != event_id) { \ WARN_ON_ONCE(1); \ return TRACE_TYPE_UNHANDLED; \ } \ @@ -233,7 +226,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ \ p = &get_cpu_var(ftrace_event_seq); \ trace_seq_init(p); \ - ret = trace_seq_printf(s, "%s: ", event->name); \ + ret = trace_seq_printf(s, "%s: ", name); \ if (ret) \ ret = trace_seq_printf(s, print); \ put_cpu(); \ @@ -241,16 +234,21 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ return TRACE_TYPE_PARTIAL_LINE; \ \ return TRACE_TYPE_HANDLED; \ -} \ -static struct trace_event_functions ftrace_event_type_funcs_##call = { \ - .trace = ftrace_raw_output_##call, \ -}; +} + +#undef DEFINE_EVENT +#define DEFINE_EVENT(template, name, proto, args) \ +static notrace enum print_line_t \ +ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \ +{ \ + return ftrace_raw_output_id_##template(event_##name.id, \ + #name, iter, flags); \ +} #undef DEFINE_EVENT_PRINT #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ static notrace enum print_line_t \ -ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ - struct trace_event *event) \ +ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ { \ struct trace_seq *s = &iter->seq; \ struct ftrace_raw_##template *field; \ @@ -260,7 +258,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ \ entry = iter->ent; \ \ - if (entry->type != event_##call.event.type) { \ + if (entry->type != event_##call.id) { \ WARN_ON_ONCE(1); \ return TRACE_TYPE_UNHANDLED; \ } \ @@ -277,10 +275,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ return TRACE_TYPE_PARTIAL_LINE; \ \ return TRACE_TYPE_HANDLED; \ -} \ -static struct trace_event_functions ftrace_event_type_funcs_##call = { \ - .trace = ftrace_raw_output_##call, \ -}; +} #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) @@ -386,18 +381,80 @@ static inline notrace int ftrace_get_offsets_##call( \ #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#ifdef CONFIG_PERF_EVENTS + +/* + * Generate the functions needed for tracepoint perf_event support. + * + * NOTE: The insertion profile callback (ftrace_profile_) is defined later + * + * static int ftrace_profile_enable_(void) + * { + * return register_trace_(ftrace_profile_); + * } + * + * static void ftrace_profile_disable_(void) + * { + * unregister_trace_(ftrace_profile_); + * } + * + */ + +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) + +#undef DEFINE_EVENT +#define DEFINE_EVENT(template, name, proto, args) \ + \ +static void perf_trace_##name(proto); \ + \ +static notrace int \ +perf_trace_enable_##name(struct ftrace_event_call *unused) \ +{ \ + return register_trace_##name(perf_trace_##name); \ +} \ + \ +static notrace void \ +perf_trace_disable_##name(struct ftrace_event_call *unused) \ +{ \ + unregister_trace_##name(perf_trace_##name); \ +} + +#undef DEFINE_EVENT_PRINT +#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ + DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +#endif /* CONFIG_PERF_EVENTS */ + /* * Stage 4 of the trace events. * * Override the macros in to include the following: * + * static void ftrace_event_(proto) + * { + * event_trace_printk(_RET_IP_, ": " ); + * } + * + * static int ftrace_reg_event_(struct ftrace_event_call *unused) + * { + * return register_trace_(ftrace_event_); + * } + * + * static void ftrace_unreg_event_(struct ftrace_event_call *unused) + * { + * unregister_trace_(ftrace_event_); + * } + * + * * For those macros defined with TRACE_EVENT: * * static struct ftrace_event_call event_; * - * static void ftrace_raw_event_(void *__data, proto) + * static void ftrace_raw_event_(proto) * { - * struct ftrace_event_call *event_call = __data; * struct ftrace_data_offsets_ __maybe_unused __data_offsets; * struct ring_buffer_event *event; * struct ftrace_raw_ *entry; <-- defined in stage 1 @@ -412,7 +469,7 @@ static inline notrace int ftrace_get_offsets_##call( \ * __data_size = ftrace_get_offsets_(&__data_offsets, args); * * event = trace_current_buffer_lock_reserve(&buffer, - * event_->event.type, + * event_.id, * sizeof(*entry) + __data_size, * irq_flags, pc); * if (!event) @@ -427,42 +484,43 @@ static inline notrace int ftrace_get_offsets_##call( \ * event, irq_flags, pc); * } * + * static int ftrace_raw_reg_event_(struct ftrace_event_call *unused) + * { + * return register_trace_(ftrace_raw_event_); + * } + * + * static void ftrace_unreg_event_(struct ftrace_event_call *unused) + * { + * unregister_trace_(ftrace_raw_event_); + * } + * * static struct trace_event ftrace_event_type_ = { * .trace = ftrace_raw_output_, <-- stage 2 * }; * * static const char print_fmt_[] = ; * - * static struct ftrace_event_class __used event_class_