void wm831x_device_exit(struct wm831x *wm831x) { wm831x_otp_exit(wm831x); mfd_remove_devices(wm831x->dev); free_irq(wm831x_irq(wm831x, WM831X_IRQ_AUXADC_DATA), wm831x); wm831x_irq_exit(wm831x); }
static int wm831x_aldo_remove(struct platform_device *pdev) { struct wm831x_ldo *ldo = platform_get_drvdata(pdev); free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")), ldo); regulator_unregister(ldo->regulator); return 0; }
static __devexit int wm831x_isink_remove(struct platform_device *pdev) { struct wm831x_isink *isink = platform_get_drvdata(pdev); platform_set_drvdata(pdev, NULL); free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); regulator_unregister(isink->regulator); return 0; }
static int wm831x_rtc_probe(struct platform_device *pdev) { struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); struct wm831x_rtc *wm831x_rtc; int alm_irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "ALM")); int ret = 0; wm831x_rtc = devm_kzalloc(&pdev->dev, sizeof(*wm831x_rtc), GFP_KERNEL); if (wm831x_rtc == NULL) return -ENOMEM; platform_set_drvdata(pdev, wm831x_rtc); wm831x_rtc->wm831x = wm831x; ret = wm831x_reg_read(wm831x, WM831X_RTC_CONTROL); if (ret < 0) { dev_err(&pdev->dev, "Failed to read RTC control: %d\n", ret); return ret; } if (ret & WM831X_RTC_ALM_ENA) wm831x_rtc->alarm_enabled = 1; device_init_wakeup(&pdev->dev, 1); wm831x_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(wm831x_rtc->rtc)) return PTR_ERR(wm831x_rtc->rtc); wm831x_rtc->rtc->ops = &wm831x_rtc_ops; wm831x_rtc->rtc->range_max = U32_MAX; ret = rtc_register_device(wm831x_rtc->rtc); if (ret) return ret; ret = devm_request_threaded_irq(&pdev->dev, alm_irq, NULL, wm831x_alm_irq, IRQF_TRIGGER_RISING, "RTC alarm", wm831x_rtc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n", alm_irq, ret); } wm831x_rtc_add_randomness(wm831x); return 0; }
static int wm831x_isink_probe(struct platform_device *pdev) { struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); struct wm831x_isink *isink; int id = pdev->id % ARRAY_SIZE(pdata->isink); struct regulator_config config = { }; struct resource *res; int ret, irq; dev_dbg(&pdev->dev, "Probing ISINK%d\n", id + 1); if (pdata == NULL || pdata->isink[id] == NULL) return -ENODEV; isink = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_isink), GFP_KERNEL); if (isink == NULL) { dev_err(&pdev->dev, "Unable to allocate private data\n"); return -ENOMEM; } isink->wm831x = wm831x; res = platform_get_resource(pdev, IORESOURCE_REG, 0); if (res == NULL) { dev_err(&pdev->dev, "No REG resource\n"); ret = -EINVAL; goto err; } isink->reg = res->start; /* For current parts this is correct; probably need to revisit * in future. */ snprintf(isink->name, sizeof(isink->name), "ISINK%d", id + 1); isink->desc.name = isink->name; isink->desc.id = id; isink->desc.ops = &wm831x_isink_ops; isink->desc.type = REGULATOR_CURRENT; isink->desc.owner = THIS_MODULE; config.dev = pdev->dev.parent; config.init_data = pdata->isink[id]; config.driver_data = isink; isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, &config); if (IS_ERR(isink->regulator)) { ret = PTR_ERR(isink->regulator); dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", id + 1, ret); goto err; } irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, wm831x_isink_irq, IRQF_TRIGGER_RISING, isink->name, isink); if (ret != 0) { dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", irq, ret); goto err; } platform_set_drvdata(pdev, isink); return 0; err: return ret; }
static int wm831x_aldo_probe(struct platform_device *pdev) { struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); struct wm831x_pdata *pdata = wm831x->dev->platform_data; struct regulator_config config = { }; int id; struct wm831x_ldo *ldo; struct resource *res; int ret, irq; if (pdata && pdata->wm831x_num) id = (pdata->wm831x_num * 10) + 1; else id = 0; id = pdev->id - id; dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1); ldo = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_ldo), GFP_KERNEL); if (ldo == NULL) { dev_err(&pdev->dev, "Unable to allocate private data\n"); return -ENOMEM; } ldo->wm831x = wm831x; res = platform_get_resource(pdev, IORESOURCE_REG, 0); if (res == NULL) { dev_err(&pdev->dev, "No REG resource\n"); ret = -EINVAL; goto err; } ldo->base = res->start; snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); ldo->desc.name = ldo->name; snprintf(ldo->supply_name, sizeof(ldo->supply_name), "LDO%dVDD", id + 1); ldo->desc.supply_name = ldo->supply_name; ldo->desc.id = id; ldo->desc.type = REGULATOR_VOLTAGE; ldo->desc.n_voltages = WM831X_ALDO_MAX_SELECTOR + 1; ldo->desc.ops = &wm831x_aldo_ops; ldo->desc.owner = THIS_MODULE; ldo->desc.vsel_reg = ldo->base + WM831X_LDO_ON_CONTROL; ldo->desc.vsel_mask = WM831X_LDO7_ON_VSEL_MASK; ldo->desc.enable_reg = WM831X_LDO_ENABLE; ldo->desc.enable_mask = 1 << id; ldo->desc.bypass_reg = ldo->base; ldo->desc.bypass_mask = WM831X_LDO7_SWI; config.dev = pdev->dev.parent; if (pdata) config.init_data = pdata->ldo[id]; config.driver_data = ldo; config.regmap = wm831x->regmap; ldo->regulator = regulator_register(&ldo->desc, &config); if (IS_ERR(ldo->regulator)) { ret = PTR_ERR(ldo->regulator); dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", id + 1, ret); goto err; } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, IRQF_TRIGGER_RISING, ldo->name, ldo); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); goto err_regulator; } platform_set_drvdata(pdev, ldo); return 0; err_regulator: regulator_unregister(ldo->regulator); err: return ret; }