aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDonggeun Kim <dg77.kim@samsung.com>2011-12-15 04:20:47 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-01-08 18:37:42 -0500
commit71e58782d2e054798f91473f5452ffe65e2a5ff8 (patch)
tree647cfd474e5e2b94d6c68910d21dd7fe14c1de19 /drivers
parent12aef0ace3758594ab1fcfb027fa690246321e0d (diff)
misc: Remove max8997-muic sysfs attributes
The 'switch' sysfs attribute is used for showing and setting the switch state of the device. However, setting it from the userspace focibly is not appropriate. And showing the state can be handled from other places (e.g. external connector) in a unified manner. This patch removes the sysfs attribute. Plus, uevent messages for interrupts are also removed. The initial max8997-muic driver is merged at: git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6.git for-next Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/max8997-muic.c137
1 files changed, 4 insertions, 133 deletions
diff --git a/drivers/misc/max8997-muic.c b/drivers/misc/max8997-muic.c
index 74a9448a93d2..d74ef41aabd5 100644
--- a/drivers/misc/max8997-muic.c
+++ b/drivers/misc/max8997-muic.c
@@ -307,11 +307,8 @@ static void max8997_muic_irq_work(struct work_struct *work)
307 struct max8997_muic_info, irq_work); 307 struct max8997_muic_info, irq_work);
308 struct max8997_platform_data *pdata = 308 struct max8997_platform_data *pdata =
309 dev_get_platdata(info->iodev->dev); 309 dev_get_platdata(info->iodev->dev);
310 char env_name_str[30], env_state_str[15];
311 char *envp[] = { env_name_str, env_state_str, NULL };
312 u8 status[3]; 310 u8 status[3];
313 u8 adc, adc_low, adc_err; 311 u8 adc, chg_type;
314 u8 vb_volt, db_chg, dcd_tmr, cdr, chg_type, ovp;
315 312
316 int irq_type = info->irq - pdata->irq_base; 313 int irq_type = info->irq - pdata->irq_base;
317 int ret; 314 int ret;
@@ -330,72 +327,24 @@ static void max8997_muic_irq_work(struct work_struct *work)
330 status[0], status[1]); 327 status[0], status[1]);
331 328
332 switch (irq_type) { 329 switch (irq_type) {
333 case MAX8997_MUICIRQ_ADCError:
334 adc_err = status[0] & STATUS1_ADCERR_MASK;
335 adc_err >>= STATUS1_ADCERR_SHIFT;
336 sprintf(env_name_str, "IRQ=%s", "ADC_Error");
337 sprintf(env_state_str, "STATE=%d", adc_err);
338 break;
339 case MAX8997_MUICIRQ_ADCLow:
340 adc_low = status[0] & STATUS1_ADCLOW_MASK;
341 adc_low >>= STATUS1_ADCLOW_SHIFT;
342 sprintf(env_name_str, "IRQ=%s", "ADC_Low");
343 sprintf(env_state_str, "STATE=%d", adc_low);
344 break;
345 case MAX8997_MUICIRQ_ADC: 330 case MAX8997_MUICIRQ_ADC:
346 adc = status[0] & STATUS1_ADC_MASK; 331 adc = status[0] & STATUS1_ADC_MASK;
347 adc >>= STATUS1_ADC_SHIFT; 332 adc >>= STATUS1_ADC_SHIFT;
348 333
349 max8997_muic_handle_adc(info, adc); 334 max8997_muic_handle_adc(info, adc);
350
351 sprintf(env_name_str, "IRQ=%s", "ADC");
352 sprintf(env_state_str, "STATE=%d", adc);
353 break;
354 case MAX8997_MUICIRQ_VBVolt:
355 vb_volt = status[1] & STATUS2_VBVOLT_MASK;
356 vb_volt >>= STATUS2_VBVOLT_SHIFT;
357 sprintf(env_name_str, "IRQ=%s", "VB_Volt");
358 sprintf(env_state_str, "STATE=%d", vb_volt);
359 break;
360 case MAX8997_MUICIRQ_DBChg:
361 db_chg = status[1] & STATUS2_DBCHG_MASK;
362 db_chg >>= STATUS2_DBCHG_SHIFT;
363 sprintf(env_name_str, "IRQ=%s", "DB_CHARGER");
364 sprintf(env_state_str, "STATE=%d", db_chg);
365 break;
366 case MAX8997_MUICIRQ_DCDTmr:
367 dcd_tmr = status[1] & STATUS2_DCDTMR_MASK;
368 dcd_tmr >>= STATUS2_DCDTMR_SHIFT;
369 sprintf(env_name_str, "IRQ=%s", "DCD_TIMER");
370 sprintf(env_state_str, "STATE=%d", dcd_tmr);
371 break;
372 case MAX8997_MUICIRQ_ChgDetRun:
373 cdr = status[1] & STATUS2_CHGDETRUN_MASK;
374 cdr >>= STATUS2_CHGDETRUN_SHIFT;
375 sprintf(env_name_str, "IRQ=%s", "CHG_DET_RUN");
376 sprintf(env_state_str, "STATE=%d", cdr);
377 break; 335 break;
378 case MAX8997_MUICIRQ_ChgTyp: 336 case MAX8997_MUICIRQ_ChgTyp:
379 chg_type = status[1] & STATUS2_CHGTYP_MASK; 337 chg_type = status[1] & STATUS2_CHGTYP_MASK;
380 chg_type >>= STATUS2_CHGTYP_SHIFT; 338 chg_type >>= STATUS2_CHGTYP_SHIFT;
381 339
382 max8997_muic_handle_charger_type(info, chg_type); 340 max8997_muic_handle_charger_type(info, chg_type);
383
384 sprintf(env_name_str, "IRQ=%s", "CHARGER_TYPE");
385 sprintf(env_state_str, "STATE=%d", chg_type);
386 break;
387 case MAX8997_MUICIRQ_OVP:
388 ovp = status[2] & STATUS3_OVP_MASK;
389 ovp >>= STATUS3_OVP_SHIFT;
390 sprintf(env_name_str, "IRQ=%s", "OVER-VOLTAGE");
391 sprintf(env_state_str, "STATE=%d", ovp);
392 break; 341 break;
393 default: 342 default:
343 dev_info(info->dev, "misc interrupt: %s occurred\n",
344 muic_irqs[irq_type].name);
394 break; 345 break;
395 } 346 }
396 347
397 kobject_uevent_env(&info->dev->kobj, KOBJ_CHANGE, envp);
398
399 mutex_unlock(&info->mutex); 348 mutex_unlock(&info->mutex);
400 349
401 return; 350 return;
@@ -438,74 +387,6 @@ static void max8997_muic_detect_dev(struct max8997_muic_info *info)
438 max8997_muic_handle_charger_type(info, chg_type); 387 max8997_muic_handle_charger_type(info, chg_type);
439} 388}
440 389
441static ssize_t max8997_muic_show_manualsw(struct device *dev,
442 struct device_attribute *attr, char *buf)
443{
444 struct max8997_muic_info *info = dev_get_drvdata(dev);
445 int ret;
446 u8 value, manual_switch;
447
448 ret = max8997_read_reg(info->muic, MAX8997_MUIC_REG_CONTROL1, &value);
449 if (ret) {
450 dev_err(info->dev, "failed to read muic register\n");
451 return sprintf(buf, "UNKNOWN\n");
452 }
453
454 manual_switch = value & (COMN1SW_MASK | COMP2SW_MASK);
455
456 switch (manual_switch) {
457 case MAX8997_SW_USB:
458 return sprintf(buf, "USB\n");
459 case MAX8997_SW_AUDIO:
460 return sprintf(buf, "AUDIO\n");
461 case MAX8997_SW_UART:
462 return sprintf(buf, "UART\n");
463 default:
464 return sprintf(buf, "OPEN\n");
465 }
466}
467
468static ssize_t max8997_muic_store_manualsw(struct device *dev,
469 struct device_attribute *attr,
470 const char *buf, size_t count)
471{
472 struct max8997_muic_info *info = dev_get_drvdata(dev);
473 int ret;
474 u8 manual_switch;
475
476 if (!strncmp(buf, "USB", 3)) {
477 manual_switch = MAX8997_SW_USB;
478 } else if (!strncmp(buf, "AUDIO", 5)) {
479 manual_switch = MAX8997_SW_AUDIO;
480 } else if (!strncmp(buf, "UART", 4)) {
481 manual_switch = MAX8997_SW_UART;
482 } else if (!strncmp(buf, "OPEN", 4)) {
483 manual_switch = MAX8997_SW_OPEN;
484 } else {
485 dev_err(info->dev, "invalid parameter\n");
486 goto out;
487 }
488
489 ret = max8997_update_reg(info->muic, MAX8997_MUIC_REG_CONTROL1,
490 manual_switch, SW_MASK);
491 if (ret)
492 dev_err(info->dev, "failed to update muic register\n");
493out:
494 return count;
495}
496
497static DEVICE_ATTR(switch, S_IRUGO | S_IWUSR,
498 max8997_muic_show_manualsw, max8997_muic_store_manualsw);
499
500static struct attribute *max8997_muic_attributes[] = {
501 &dev_attr_switch.attr,
502 NULL
503};
504
505static const struct attribute_group max8997_muic_group = {
506 .attrs = max8997_muic_attributes,
507};
508
509static void max8997_initialize_device(struct max8997_muic_info *info) 390static void max8997_initialize_device(struct max8997_muic_info *info)
510{ 391{
511 struct max8997_muic_platform_data *mdata = info->muic_pdata; 392 struct max8997_muic_platform_data *mdata = info->muic_pdata;
@@ -545,13 +426,6 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
545 platform_set_drvdata(pdev, info); 426 platform_set_drvdata(pdev, info);
546 mutex_init(&info->mutex); 427 mutex_init(&info->mutex);
547 428
548 ret = sysfs_create_group(&pdev->dev.kobj, &max8997_muic_group);
549 if (ret) {
550 dev_err(&pdev->dev,
551 "failed to create max8997 muic attribute group\n");
552 goto err_sysfs;
553 }
554
555 INIT_WORK(&info->irq_work, max8997_muic_irq_work); 429 INIT_WORK(&info->irq_work, max8997_muic_irq_work);
556 430
557 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 431 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
@@ -583,8 +457,6 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
583 return ret; 457 return ret;
584 458
585err_irq: 459err_irq:
586 sysfs_remove_group(&pdev->dev.kobj, &max8997_muic_group);
587err_sysfs:
588err_pdata: 460err_pdata:
589 kfree(info); 461 kfree(info);
590err_kfree: 462err_kfree:
@@ -598,10 +470,9 @@ static int __devexit max8997_muic_remove(struct platform_device *pdev)
598 dev_get_platdata(info->iodev->dev); 470 dev_get_platdata(info->iodev->dev);
599 int i; 471 int i;
600 472
601 sysfs_remove_group(&pdev->dev.kobj, &max8997_muic_group);
602
603 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) 473 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
604 free_irq(pdata->irq_base + muic_irqs[i].irq, info); 474 free_irq(pdata->irq_base + muic_irqs[i].irq, info);
475 cancel_work_sync(&info->irq_work);
605 476
606 kfree(info); 477 kfree(info);
607 478