本文整理汇总了C++中platform_set_drvdata函数的典型用法代码示例。如果您正苦于以下问题:C++ platform_set_drvdata函数的具体用法?C++ platform_set_drvdata怎么用?C++ platform_set_drvdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了platform_set_drvdata函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: omap_pwm_led_probe
static int omap_pwm_led_probe(struct platform_device *pdev)
{
struct omap_pwm_led_platform_data *pdata = pdev->dev.platform_data;
struct omap_pwm_led *led;
int ret;
led = kzalloc(sizeof(struct omap_pwm_led), GFP_KERNEL);
if (led == NULL) {
dev_err(&pdev->dev, "No memory for device\n");
return -ENOMEM;
}
platform_set_drvdata(pdev, led);
led->cdev.brightness_set = omap_pwm_led_set;
led->cdev.default_trigger = NULL;
led->cdev.name = pdata->name;
led->pdata = pdata;
dev_info(&pdev->dev, "OMAP PWM LED (%s) at GP timer %d/%d\n",
pdata->name, pdata->intensity_timer, pdata->blink_timer);
/* register our new led device */
ret = led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0) {
dev_err(&pdev->dev, "led_classdev_register failed\n");
goto error_classdev;
}
/* get related dm timers */
led->intensity_timer = omap_dm_timer_request_specific(pdata->intensity_timer);
if (led->intensity_timer == NULL) {
dev_err(&pdev->dev, "failed to request intensity pwm timer\n");
ret = -ENODEV;
goto error_intensity;
}
omap_dm_timer_disable(led->intensity_timer);
if (pdata->blink_timer != 0) {
led->blink_timer = omap_dm_timer_request_specific(pdata->blink_timer);
if (led->blink_timer == NULL) {
dev_err(&pdev->dev, "failed to request blinking pwm timer\n");
ret = -ENODEV;
goto error_blink;
}
omap_dm_timer_disable(led->blink_timer);
class_device_create_file(led->cdev.class_dev,
&class_device_attr_on_period);
class_device_create_file(led->cdev.class_dev,
&class_device_attr_off_period);
}
return 0;
error_blink:
omap_dm_timer_free(led->intensity_timer);
error_intensity:
led_classdev_unregister(&led->cdev);
error_classdev:
kfree(led);
return ret;
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:62,代码来源:leds-omap-pwm.c
示例2: wm831x_boostp_probe
static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
struct wm831x_dcdc *dcdc;
struct resource *res;
int ret, irq;
dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
if (pdata == NULL || pdata->dcdc[id] == NULL)
return -ENODEV;
dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
if (dcdc == NULL) {
dev_err(&pdev->dev, "Unable to allocate private data\n");
return -ENOMEM;
}
dcdc->wm831x = wm831x;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (res == NULL) {
dev_err(&pdev->dev, "No I/O resource\n");
ret = -EINVAL;
goto err;
}
dcdc->base = res->start;
snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
dcdc->desc.name = dcdc->name;
dcdc->desc.id = id;
dcdc->desc.type = REGULATOR_VOLTAGE;
dcdc->desc.ops = &wm831x_boostp_ops;
dcdc->desc.owner = THIS_MODULE;
dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev,
pdata->dcdc[id], dcdc, NULL);
if (IS_ERR(dcdc->regulator)) {
ret = PTR_ERR(dcdc->regulator);
dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
id + 1, ret);
goto err;
}
irq = platform_get_irq_byname(pdev, "UV");
ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
IRQF_TRIGGER_RISING, dcdc->name,
dcdc);
if (ret != 0) {
dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
irq, ret);
goto err_regulator;
}
platform_set_drvdata(pdev, dcdc);
return 0;
err_regulator:
regulator_unregister(dcdc->regulator);
err:
kfree(dcdc);
return ret;
}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:66,代码来源:wm831x-dcdc.c
示例3: pmic8058_tm_probe
static int __devinit pmic8058_tm_probe(struct platform_device *pdev)
{
struct pm8058_tm_device *tmdev;
struct pm8058_chip *pm_chip;
unsigned int irq;
int rc;
pm_chip = dev_get_drvdata(pdev->dev.parent);
if (pm_chip == NULL) {
pr_err("%s: no driver data passed in.\n", __func__);
return -EFAULT;
}
irq = platform_get_irq(pdev, 0);
if (!irq) {
pr_err("%s: no IRQ passed in.\n", __func__);
return -EFAULT;
}
tmdev = kzalloc(sizeof *tmdev, GFP_KERNEL);
if (tmdev == NULL) {
pr_err("%s: kzalloc() failed.\n", __func__);
return -ENOMEM;
}
rc = adc_channel_open(PM8058_TEMP_ADC_CH, &(tmdev->adc_handle));
if (rc < 0) {
pr_err("%s: adc_channel_open() failed.\n", __func__);
kfree(tmdev);
return rc;
}
tmdev->pm_chip = pm_chip;
tmdev->tz_dev = thermal_zone_device_register("pm8058_tz",
PM8058_TRIP_NUM, tmdev,
&pm8058_thermal_zone_ops,
0, 0, 0, 0);
if (tmdev->tz_dev == NULL) {
pr_err("%s: thermal_zone_device_register() failed.\n",
__func__);
adc_channel_close(tmdev->adc_handle);
kfree(tmdev);
return -ENODEV;
}
rc = pm8058_tm_init_reg(tmdev);
pm8058_tm_shutdown_override(tmdev->pm_chip, SOFTWARE_OVERRIDE_DISABLED);
if (rc < 0) {
thermal_zone_device_unregister(tmdev->tz_dev);
adc_channel_close(tmdev->adc_handle);
kfree(tmdev);
return rc;
}
/* start in HW control, switch to SW control when user changes mode */
tmdev->mode = THERMAL_DEVICE_DISABLED;
thermal_zone_device_update(tmdev->tz_dev);
platform_set_drvdata(pdev, tmdev);
rc = request_threaded_irq(irq, NULL, pm8058_tm_isr,
IRQF_TRIGGER_RISING | IRQF_DISABLED,
"pm8058-tm-irq", tmdev);
if (rc < 0) {
pr_err("%s: request_irq(%d) FAIL: %d\n", __func__, irq, rc);
thermal_zone_device_unregister(tmdev->tz_dev);
platform_set_drvdata(pdev, tmdev->pm_chip);
adc_channel_close(tmdev->adc_handle);
kfree(tmdev);
return rc;
}
tmdev->irq = irq;
pr_notice("%s: OK\n", __func__);
return 0;
}
开发者ID:HONO,项目名称:Bell_V20f_kernel_mod,代码行数:76,代码来源:pmic8058-tm.c
示例4: bcl_remove
static int bcl_remove(struct platform_device *pdev)
{
remove_bcl_sysfs(gbcl);
platform_set_drvdata(pdev, NULL);
return 0;
}
开发者ID:mordiford,项目名称:msm-3.10-mirror,代码行数:6,代码来源:battery_current_limit.c
示例5: minivosc_probe
static int minivosc_probe(struct platform_device *devptr)
#endif
{
struct snd_card *card;
struct minivosc_device *mydev;
int ret;
int nr_subdevs; // how many capture substreams we want
struct snd_pcm *pcm;
int dev = devptr->id; // from aloop-kernel.c
dbg("%s: probe", __func__);
// no need to kzalloc minivosc_device separately, if the sizeof is included here
ret = snd_card_create(index[dev], id[dev],
THIS_MODULE, sizeof(struct minivosc_device), &card);
if (ret < 0)
goto __nodev;
mydev = card->private_data;
mydev->card = card;
// MUST have mutex_init here - else crash on mutex_lock!!
mutex_init(&mydev->cable_lock);
dbg2("-- mydev %p", mydev);
sprintf(card->driver, "my_driver-%s", SND_MINIVOSC_DRIVER);
sprintf(card->shortname, "MySoundCard Audio %s", SND_MINIVOSC_DRIVER);
sprintf(card->longname, "%s", card->shortname);
snd_card_set_dev(card, &devptr->dev); // present in dummy, not in aloop though
ret = snd_device_new(card, SNDRV_DEV_LOWLEVEL, mydev, &dev_ops);
if (ret < 0)
goto __nodev;
nr_subdevs = 1; // how many capture substreams we want
// * we want 0 playback, and 1 capture substreams (4th and 5th arg) ..
ret = snd_pcm_new(card, card->driver, 0, 0, nr_subdevs, &pcm);
if (ret < 0)
goto __nodev;
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &minivosc_pcm_ops); // in both aloop-kernel.c and dummy.c, after snd_pcm_new...
pcm->private_data = mydev; //here it should be dev/card struct (the one containing struct snd_card *card) - this DOES NOT end up in substream->private_data
pcm->info_flags = 0;
strcpy(pcm->name, card->shortname);
/*
trid to add this - but it crashes here:
//mydev->substream->private_data = mydev;
Well, first time real substream comes in, is in _open - so
that has to be handled there.. That is: at this point, mydev->substream is null,
and we first have a chance to set it ... in _open!
*/
ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL),
MAX_BUFFER, MAX_BUFFER); // in both aloop-kernel.c and dummy.c, after snd_pcm_set_ops...
if (ret < 0)
goto __nodev;
// * will use the snd_card_register form from aloop-kernel.c/dummy.c here..
ret = snd_card_register(card);
if (ret == 0) // or... (!ret)
{
platform_set_drvdata(devptr, card);
return 0; // success
}
__nodev: // as in aloop/dummy...
dbg("__nodev reached!!");
snd_card_free(card); // this will autocall .dev_free (= minivosc_pcm_dev_free)
return ret;
}
开发者ID:stadaki,项目名称:alsa-minivosc-src,代码行数:88,代码来源:minivosc.c
示例6: sgiwd93_probe
static int __devinit sgiwd93_probe(struct platform_device *pdev)
{
struct sgiwd93_platform_data *pd = pdev->dev.platform_data;
unsigned char *wdregs = pd->wdregs;
struct hpc3_scsiregs *hregs = pd->hregs;
struct ip22_hostdata *hdata;
struct Scsi_Host *host;
wd33c93_regs regs;
unsigned int unit = pd->unit;
unsigned int irq = pd->irq;
int err;
host = scsi_host_alloc(&sgiwd93_template, sizeof(struct ip22_hostdata));
if (!host) {
err = -ENOMEM;
goto out;
}
host->base = (unsigned long) hregs;
host->irq = irq;
hdata = host_to_hostdata(host);
hdata->dev = &pdev->dev;
hdata->cpu = dma_alloc_noncoherent(&pdev->dev, HPC_DMA_SIZE,
&hdata->dma, GFP_KERNEL);
if (!hdata->cpu) {
printk(KERN_WARNING "sgiwd93: Could not allocate memory for "
"host %d buffer.\n", unit);
err = -ENOMEM;
goto out_put;
}
init_hpc_chain(hdata);
regs.SASR = wdregs + 3;
regs.SCMD = wdregs + 7;
hdata->wh.no_sync = 0;
hdata->wh.fast = 1;
hdata->wh.dma_mode = CTRL_BURST;
wd33c93_init(host, regs, dma_setup, dma_stop, WD33C93_FS_MHZ(20));
err = request_irq(irq, sgiwd93_intr, 0, "SGI WD93", host);
if (err) {
printk(KERN_WARNING "sgiwd93: Could not register irq %d "
"for host %d.\n", irq, unit);
goto out_free;
}
platform_set_drvdata(pdev, host);
err = scsi_add_host(host, NULL);
if (err)
goto out_irq;
scsi_scan_host(host);
return 0;
out_irq:
free_irq(irq, host);
out_free:
dma_free_noncoherent(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma);
out_put:
scsi_host_put(host);
out:
return err;
}
开发者ID:andi34,项目名称:Dhollmen_Kernel,代码行数:70,代码来源:sgiwd93.c
示例7: tvenc_probe
static int tvenc_probe(struct platform_device *pdev)
{
struct msm_fb_data_type *mfd;
struct platform_device *mdp_dev = NULL;
struct msm_fb_panel_data *pdata = NULL;
int rc;
if (pdev->id == 0) {
tvenc_base = ioremap(pdev->resource[0].start,
pdev->resource[0].end -
pdev->resource[0].start + 1);
if (!tvenc_base) {
pr_err("tvenc_base ioremap failed!\n");
return -ENOMEM;
}
tvenc_pdata = pdev->dev.platform_data;
tvenc_resource_initialized = 1;
return 0;
}
if (!tvenc_resource_initialized)
return -EPERM;
mfd = platform_get_drvdata(pdev);
if (!mfd)
return -ENODEV;
if (mfd->key != MFD_KEY)
return -EINVAL;
if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST)
return -ENOMEM;
if (tvenc_base == NULL)
return -ENOMEM;
mdp_dev = platform_device_alloc("mdp", pdev->id);
if (!mdp_dev)
return -ENOMEM;
/*
* link to the latest pdev
*/
mfd->pdev = mdp_dev;
mfd->dest = DISPLAY_TV;
/*
* alloc panel device data
*/
if (platform_device_add_data
(mdp_dev, pdev->dev.platform_data,
sizeof(struct msm_fb_panel_data))) {
pr_err("tvenc_probe: platform_device_add_data failed!\n");
platform_device_put(mdp_dev);
return -ENOMEM;
}
/*
* data chain
*/
pdata = mdp_dev->dev.platform_data;
pdata->on = tvenc_on;
pdata->off = tvenc_off;
pdata->next = pdev;
/*
* get/set panel specific fb info
*/
mfd->panel_info = pdata->panel_info;
#ifdef CONFIG_FB_MSM_MDP40
mfd->fb_imgType = MDP_RGB_565; /* base layer */
#else
mfd->fb_imgType = MDP_YCRYCB_H2V1;
#endif
#ifdef CONFIG_MSM_BUS_SCALING
if (!tvenc_bus_scale_handle && tvenc_pdata &&
tvenc_pdata->bus_scale_table) {
tvenc_bus_scale_handle =
msm_bus_scale_register_client(
tvenc_pdata->bus_scale_table);
if (!tvenc_bus_scale_handle) {
printk(KERN_ERR "%s not able to get bus scale\n",
__func__);
}
}
#else
mfd->ebi1_clk = clk_get(NULL, "ebi1_tv_clk");
if (IS_ERR(mfd->ebi1_clk)) {
rc = PTR_ERR(mfd->ebi1_clk);
goto tvenc_probe_err;
}
clk_set_rate(mfd->ebi1_clk, MSM_SYSTEM_BUS_RATE);
#endif
/*
* set driver data
*/
platform_set_drvdata(mdp_dev, mfd);
//.........这里部分代码省略.........
开发者ID:argakon,项目名称:lge-kernel-msm7x27-ICS-JB,代码行数:101,代码来源:tvenc.c
示例8: attiny_probe
static int __devinit attiny_probe(struct platform_device *pdev)
{
int result = 0;
struct attiny_platform_data * attiny_data = NULL;
struct input_dev *idev = NULL;
attiny_data = (struct attiny_platform_data *)pdev->dev.platform_data;
if (!attiny_data || (!attiny_data->enable) || (attiny_data->irq < 0)) {
dev_err(&pdev->dev, "get platform data failed!\n");
return -ENODATA;
}
attiny_private_data = kzalloc(sizeof(struct attiny_private), GFP_KERNEL);
if (!attiny_private_data) {
dev_err(&pdev->dev, "allocate memory failed!\n");
return -ENOMEM;
}
attiny_private_data->platform_data = attiny_data;
mutex_init(&attiny_private_data->mutex);
attiny_private_data->state = ATTI_OFF;
platform_set_drvdata(pdev, attiny_private_data);
idev = input_allocate_device();
if (!idev) {
dev_err(&pdev->dev, "allocate input device failed!\n");
result = -ENOMEM;
goto err_allocate_input;
}
idev->name = ATTINY_NAME;
idev->id.bustype = BUS_VIRTUAL;
__set_bit(EV_ABS, idev->evbit);
input_set_abs_params(idev, ABS_DISTANCE, 0, 1, 0, 0);
result = input_register_device(idev);
if (result) {
dev_err(&pdev->dev, "register input device failed!\n");
goto err_register_input;
}
attiny_private_data->idev = idev;
result = request_irq(attiny_data->irq, attiny_handler, IRQ_TYPE_EDGE_BOTH, "attiny_irq", attiny_private_data);
if (result) {
dev_err(&pdev->dev, "request_irq failed\n");
goto err_request_irq;
}
disable_irq(attiny_data->irq);
result = device_create_file(&idev->dev, &dev_attr_enable);
if(result ) {
dev_err(&pdev->dev, "create device file failed\n");
goto err_create_file;
}
return result;
err_create_file:
free_irq(attiny_data->irq, attiny_private_data);
err_request_irq:
input_unregister_device(idev);
goto err_allocate_input;
err_register_input:
input_free_device(idev);
err_allocate_input:
platform_set_drvdata(pdev, NULL);
mutex_destroy(&attiny_private_data->mutex);
kfree(attiny_private_data);
return result;
}
开发者ID:brinlyaus,项目名称:P810D02_ZTE_T792_KitKat_3.4,代码行数:68,代码来源:attiny44a.c
示例9: snd_smdk_remove
static int __devexit snd_smdk_remove(struct platform_device *pdev)
{
snd_soc_unregister_card(&smdk_pcm);
platform_set_drvdata(pdev, NULL);
return 0;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:6,代码来源:smdk_wm8580pcm.c
示例10: tps65910_rtc_probe
static int tps65910_rtc_probe(struct platform_device *pdev)
{
struct tps65910 *tps65910 = NULL;
struct tps65910_rtc *tps_rtc = NULL;
int ret;
int irq;
u32 rtc_reg;
tps65910 = dev_get_drvdata(pdev->dev.parent);
tps_rtc = devm_kzalloc(&pdev->dev, sizeof(struct tps65910_rtc),
GFP_KERNEL);
if (!tps_rtc)
return -ENOMEM;
/* Clear pending interrupts */
ret = regmap_read(tps65910->regmap, TPS65910_RTC_STATUS, &rtc_reg);
if (ret < 0)
return ret;
ret = regmap_write(tps65910->regmap, TPS65910_RTC_STATUS, rtc_reg);
if (ret < 0)
return ret;
dev_dbg(&pdev->dev, "Enabling rtc-tps65910.\n");
/* Enable RTC digital power domain */
ret = regmap_update_bits(tps65910->regmap, TPS65910_DEVCTRL,
DEVCTRL_RTC_PWDN_MASK, 0 << DEVCTRL_RTC_PWDN_SHIFT);
if (ret < 0)
return ret;
rtc_reg = TPS65910_RTC_CTRL_STOP_RTC;
ret = regmap_write(tps65910->regmap, TPS65910_RTC_CTRL, rtc_reg);
if (ret < 0)
return ret;
irq = platform_get_irq(pdev, 0);
if (irq <= 0) {
dev_warn(&pdev->dev, "Wake up is not possible as irq = %d\n",
irq);
return ret;
}
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
tps65910_rtc_interrupt, IRQF_TRIGGER_LOW | IRQF_EARLY_RESUME,
dev_name(&pdev->dev), &pdev->dev);
if (ret < 0) {
dev_err(&pdev->dev, "IRQ is not free.\n");
return ret;
}
tps_rtc->irq = irq;
device_set_wakeup_capable(&pdev->dev, 1);
tps_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
&tps65910_rtc_ops, THIS_MODULE);
if (IS_ERR(tps_rtc->rtc)) {
ret = PTR_ERR(tps_rtc->rtc);
dev_err(&pdev->dev, "RTC device register: err %d\n", ret);
return ret;
}
platform_set_drvdata(pdev, tps_rtc);
return 0;
}
开发者ID:AiWinters,项目名称:linux,代码行数:66,代码来源:rtc-tps65910.c
示例11: em_gio_probe
static int __devinit em_gio_probe(struct platform_device *pdev)
{
struct gpio_em_config *pdata = pdev->dev.platform_data;
struct em_gio_priv *p;
struct resource *io[2], *irq[2];
struct gpio_chip *gpio_chip;
struct irq_chip *irq_chip;
const char *name = dev_name(&pdev->dev);
int ret;
p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) {
dev_err(&pdev->dev, "failed to allocate driver data\n");
ret = -ENOMEM;
goto err0;
}
p->pdev = pdev;
platform_set_drvdata(pdev, p);
spin_lock_init(&p->sense_lock);
io[0] = platform_get_resource(pdev, IORESOURCE_MEM, 0);
io[1] = platform_get_resource(pdev, IORESOURCE_MEM, 1);
irq[0] = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
irq[1] = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
if (!io[0] || !io[1] || !irq[0] || !irq[1] || !pdata) {
dev_err(&pdev->dev, "missing IRQ, IOMEM or configuration\n");
ret = -EINVAL;
goto err1;
}
p->base0 = ioremap_nocache(io[0]->start, resource_size(io[0]));
if (!p->base0) {
dev_err(&pdev->dev, "failed to remap low I/O memory\n");
ret = -ENXIO;
goto err1;
}
p->base1 = ioremap_nocache(io[1]->start, resource_size(io[1]));
if (!p->base1) {
dev_err(&pdev->dev, "failed to remap high I/O memory\n");
ret = -ENXIO;
goto err2;
}
gpio_chip = &p->gpio_chip;
gpio_chip->direction_input = em_gio_direction_input;
gpio_chip->get = em_gio_get;
gpio_chip->direction_output = em_gio_direction_output;
gpio_chip->set = em_gio_set;
gpio_chip->to_irq = em_gio_to_irq;
gpio_chip->label = name;
gpio_chip->owner = THIS_MODULE;
gpio_chip->base = pdata->gpio_base;
gpio_chip->ngpio = pdata->number_of_pins;
irq_chip = &p->irq_chip;
irq_chip->name = name;
irq_chip->irq_mask = em_gio_irq_disable;
irq_chip->irq_unmask = em_gio_irq_enable;
irq_chip->irq_enable = em_gio_irq_enable;
irq_chip->irq_disable = em_gio_irq_disable;
irq_chip->irq_set_type = em_gio_irq_set_type;
irq_chip->flags = IRQCHIP_SKIP_SET_WAKE;
ret = em_gio_irq_domain_init(p);
if (ret) {
dev_err(&pdev->dev, "cannot initialize irq domain\n");
goto err3;
}
if (request_irq(irq[0]->start, em_gio_irq_handler, 0, name, p)) {
dev_err(&pdev->dev, "failed to request low IRQ\n");
ret = -ENOENT;
goto err4;
}
if (request_irq(irq[1]->start, em_gio_irq_handler, 0, name, p)) {
dev_err(&pdev->dev, "failed to request high IRQ\n");
ret = -ENOENT;
goto err5;
}
ret = gpiochip_add(gpio_chip);
if (ret) {
dev_err(&pdev->dev, "failed to add GPIO controller\n");
goto err6;
}
return 0;
err6:
free_irq(irq[1]->start, pdev);
err5:
free_irq(irq[0]->start, pdev);
err4:
em_gio_irq_domain_cleanup(p);
err3:
iounmap(p->base1);
err2:
//.........这里部分代码省略.........
开发者ID:AllenWeb,项目名称:linux,代码行数:101,代码来源:gpio-em.c
示例12: n810_soc_init
static int __init n810_soc_init(void)
{
int err;
struct device *dev;
if (!of_have_populated_dt() ||
(!of_machine_is_compatible("nokia,n810") &&
!of_machine_is_compatible("nokia,n810-wimax")))
return -ENODEV;
n810_snd_device = platform_device_alloc("soc-audio", -1);
if (!n810_snd_device)
return -ENOMEM;
platform_set_drvdata(n810_snd_device, &snd_soc_n810);
err = platform_device_add(n810_snd_device);
if (err)
goto err1;
dev = &n810_snd_device->dev;
sys_clkout2_src = clk_get(dev, "sys_clkout2_src");
if (IS_ERR(sys_clkout2_src)) {
dev_err(dev, "Could not get sys_clkout2_src clock\n");
err = PTR_ERR(sys_clkout2_src);
goto err2;
}
sys_clkout2 = clk_get(dev, "sys_clkout2");
if (IS_ERR(sys_clkout2)) {
dev_err(dev, "Could not get sys_clkout2\n");
err = PTR_ERR(sys_clkout2);
goto err3;
}
/*
* Configure 12 MHz output on SYS_CLKOUT2. Therefore we must use
* 96 MHz as its parent in order to get 12 MHz
*/
func96m_clk = clk_get(dev, "func_96m_ck");
if (IS_ERR(func96m_clk)) {
dev_err(dev, "Could not get func 96M clock\n");
err = PTR_ERR(func96m_clk);
goto err4;
}
clk_set_parent(sys_clkout2_src, func96m_clk);
clk_set_rate(sys_clkout2, 12000000);
if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) ||
(gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) {
err = -EINVAL;
goto err4;
}
gpio_direction_output(N810_HEADSET_AMP_GPIO, 0);
gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);
return 0;
err4:
clk_put(sys_clkout2);
err3:
clk_put(sys_clkout2_src);
err2:
platform_device_del(n810_snd_device);
err1:
platform_device_put(n810_snd_device);
return err;
}
开发者ID:19Dan01,项目名称:linux,代码行数:67,代码来源:n810.c
示例13: omap_usb2_probe
static int omap_usb2_probe(struct platform_device *pdev)
{
struct omap_usb *phy;
struct phy *generic_phy;
struct phy_provider *phy_provider;
struct usb_otg *otg;
struct device_node *node = pdev->dev.of_node;
struct device_node *control_node;
struct platform_device *control_pdev;
if (!node)
return -EINVAL;
phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n");
return -ENOMEM;
}
otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL);
if (!otg) {
dev_err(&pdev->dev, "unable to allocate memory for USB OTG\n");
return -ENOMEM;
}
phy->dev = &pdev->dev;
phy->phy.dev = phy->dev;
phy->phy.label = "omap-usb2";
phy->phy.set_suspend = omap_usb2_suspend;
phy->phy.otg = otg;
phy->phy.type = USB_PHY_TYPE_USB2;
control_node = of_parse_phandle(node, "ctrl-module", 0);
if (!control_node) {
dev_err(&pdev->dev, "Failed to get control device phandle\n");
return -EINVAL;
}
control_pdev = of_find_device_by_node(control_node);
if (!control_pdev) {
dev_err(&pdev->dev, "Failed to get control device\n");
return -EINVAL;
}
phy->control_dev = &control_pdev->dev;
phy->is_suspended = 1;
omap_control_usb_phy_power(phy->control_dev, 0);
otg->set_host = omap_usb_set_host;
otg->set_peripheral = omap_usb_set_peripheral;
otg->set_vbus = omap_usb_set_vbus;
otg->start_srp = omap_usb_start_srp;
otg->phy = &phy->phy;
platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);
generic_phy = devm_phy_create(phy->dev, &ops, NULL);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);
phy_set_drvdata(generic_phy, phy);
phy_provider = devm_of_phy_provider_register(phy->dev,
of_phy_simple_xlate);
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
if (IS_ERR(phy->wkupclk)) {
dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
return PTR_ERR(phy->wkupclk);
}
clk_prepare(phy->wkupclk);
phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m");
if (IS_ERR(phy->optclk))
dev_vdbg(&pdev->dev, "unable to get refclk960m\n");
else
clk_prepare(phy->optclk);
usb_add_phy_dev(&phy->phy);
return 0;
}
开发者ID:IDM350,项目名称:linux,代码行数:87,代码来源:phy-omap-usb2.c
示例14: serial_omap_probe
//.........这里部分代码省略.........
if (gpio_is_valid(omap_up_info->DTR_gpio) &&
omap_up_info->DTR_present) {
up->DTR_gpio = omap_up_info->DTR_gpio;
up->DTR_inverted = omap_up_info->DTR_inverted;
} else
up->DTR_gpio = -EINVAL;
up->DTR_active = 0;
up->dev = &pdev->dev;
up->port.dev = &pdev->dev;
up->port.type = PORT_OMAP;
up->port.iotype = UPIO_MEM;
up->port.irq = uartirq;
up->wakeirq = wakeirq;
if (!up->wakeirq)
dev_info(up->port.dev, "no wakeirq for uart%d\n",
up->port.line);
up->port.regshift = 2;
up->port.fifosize = 64;
up->port.ops = &serial_omap_pops;
if (pdev->dev.of_node)
up->port.line = of_alias_get_id(pdev->dev.of_node, "serial");
else
up->port.line = pdev->id;
if (up->port.line < 0) {
dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
up->port.line);
ret = -ENODEV;
goto err_port_line;
}
ret = serial_omap_probe_rs485(up, pdev->dev.of_node);
if (ret < 0)
goto err_rs485;
sprintf(up->name, "OMAP UART%d", up->port.line);
up->port.mapbase = mem->start;
up->port.membase = devm_ioremap(&pdev->dev, mem->start,
resource_size(mem));
if (!up->port.membase) {
dev_err(&pdev->dev, "can't ioremap UART\n");
ret = -ENOMEM;
goto err_ioremap;
}
up->port.flags = omap_up_info->flags;
up->port.uartclk = omap_up_info->uartclk;
if (!up->port.uartclk) {
up->port.uartclk = DEFAULT_CLK_SPEED;
dev_warn(&pdev->dev,
"No clock speed specified: using default: %d\n",
DEFAULT_CLK_SPEED);
}
up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
up->calc_latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
pm_qos_add_request(&up->pm_qos_request,
PM_QOS_CPU_DMA_LATENCY, up->latency);
serial_omap_uart_wq = create_singlethread_workqueue(up->name);
INIT_WORK(&up->qos_work, serial_omap_uart_qos_work);
platform_set_drvdata(pdev, up);
if (omap_up_info->autosuspend_timeout == 0)
omap_up_info->autosuspend_timeout = -1;
device_init_wakeup(up->dev, true);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_autosuspend_delay(&pdev->dev,
omap_up_info->autosuspend_timeout);
pm_runtime_irq_safe(&pdev->dev);
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);
omap_serial_fill_features_erratas(up);
ui[up->port.line] = up;
serial_omap_add_console_port(up);
ret = uart_add_one_port(&serial_omap_reg, &up->port);
if (ret != 0)
goto err_add_port;
pm_runtime_mark_last_busy(up->dev);
pm_runtime_put_autosuspend(up->dev);
return 0;
err_add_port:
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
err_ioremap:
err_rs485:
err_port_line:
dev_err(&pdev->dev, "[UART%d]: failure [%s]: %d\n",
pdev->id, __func__, ret);
return ret;
}
开发者ID:mobilehunter,项目名称:trafficsqueezer-org,代码行数:101,代码来源:omap-serial.c
示例15: s3c_rtc_probe
static int s3c_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;
struct resource *res;
int ret;
pr_debug("%s: probe=%p\n", __func__, pdev);
/* find the IRQs */
s3c_rtc_tickno = platform_get_irq(pdev, 1);
if (s3c_rtc_tickno < 0) {
dev_err(&pdev->dev, "no irq for rtc tick\n");
return -ENOENT;
}
s3c_rtc_alarmno = platform_get_irq(pdev, 0);
if (s3c_rtc_alarmno < 0) {
dev_err(&pdev->dev, "no irq for alarm\n");
return -ENOENT;
}
pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n",
s3c_rtc_tickno, s3c_rtc_alarmno);
/* get the memory region */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(&pdev->dev, "failed to get memory region resource\n");
return -ENOENT;
}
s3c_rtc_mem = request_mem_region(res->start,
res->end-res->start+1,
pdev->name);
if (s3c_rtc_mem == NULL) {
dev_err(&pdev->dev, "failed to reserve memory region\n");
ret = -ENOENT;
goto err_nores;
}
s3c_rtc_base = ioremap(res->start, res->end - res->start + 1);
if (s3c_rtc_base == NULL) {
dev_err(&pdev->dev, "failed ioremap()\n");
ret = -EINVAL;
goto err_nomap;
}
/* check to see if everything is setup correctly */
s3c_rtc_enable(pdev, 1);
pr_debug("s3c2410_rtc: RTCCON=%02x\n",
readb(s3c_rtc_base + S3C2410_RTCCON));
s3c_rtc_setfreq(s3c_rtc_freq);
/* register RTC and exit */
rtc = rtc_device_register("s3c", &pdev->dev, &s3c_rtcops,
THIS_MODULE);
if (IS_ERR(rtc)) {
dev_err(&pdev->dev, "cannot attach rtc\n");
ret = PTR_ERR(rtc);
goto err_nortc;
}
rtc->max_user_freq = 128;
platform_set_drvdata(pdev, rtc);
return 0;
err_nortc:
s3c_rtc_enable(pdev, 0);
iounmap(s3c_rtc_base);
err_nomap:
release_resource(s3c_rtc_mem);
err_nores:
return ret;
}
开发者ID:sserg31,项目名称:sca3_main,代码行数:85,代码来源:rtc-s3c.c
示例16: gpio_event_probe
static int __init gpio_event_probe(struct platform_device *pdev)
{
int err;
struct gpio_event *ip;
struct gpio_event_platform_data *event_info;
int dev_count = 1;
int i;
int registered = 0;
event_info = pdev->dev.platform_data;
if (event_info == NULL) {
pr_err("gpio_event_probe: No pdata\n");
return -ENODEV;
}
if ((!event_info->name && !event_info->names[0]) ||
!event_info->info || !event_info->info_count) {
pr_err("gpio_event_probe: Incomplete pdata\n");
return -ENODEV;
}
if (!event_info->name)
while (event_info->names[dev_count])
dev_count++;
ip = kzalloc(sizeof(*ip) +
sizeof(ip->state[0]) * event_info->info_count +
sizeof(*ip->input_devs) +
sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL);
if (ip == NULL) {
err = -ENOMEM;
pr_err("gpio_event_probe: Failed to allocate private data\n");
goto err_kp_alloc_failed;
}
ip->input_devs = (void*)&ip->state[event_info->info_count];
platform_set_drvdata(pdev, ip);
for (i = 0; i < dev_count; i++) {
struct input_dev *input_dev = input_allocate_device();
if (input_dev == NULL) {
err = -ENOMEM;
pr_err("gpio_event_probe: "
"Failed to allocate input device\n");
goto err_input_dev_alloc_failed;
}
input_set_drvdata(input_dev, ip);
input_dev->name = event_info->name ?
event_info->name : event_info->names[i];
input_dev->event = gpio_input_event;
ip->input_devs->dev[i] = input_dev;
}
ip->input_devs->count = dev_count;
ip->info = event_info;
if (event_info->power) {
#ifdef CONFIG_HAS_EARLYSUSPEND
ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
ip->early_suspend.suspend = gpio_event_suspend;
ip->early_suspend.resume = gpio_event_resume;
register_early_suspend(&ip->early_suspend);
#endif
ip->info->power(ip->info, 1);
}
err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT);
if (err)
goto err_call_all_func_failed;
for (i = 0; i < dev_count; i++) {
err = input_register_device(ip->input_devs->dev[i]);
if (err) {
pr_err("gpio_event_probe: Unable to register %s "
"input device\n", ip->input_devs->dev[i]->name);
goto err_input_register_device_failed;
}
registered++;
}
#if (defined(CONFIG_MACH_EUROPA) || defined(CONFIG_MACH_CALLISTO)|| defined(CONFIG_MACH_COOPER) || defined(CONFIG_MACH_BENI) || defined(CONFIG_MACH_TASS) || defined(CONFIG_MACH_LUCAS))
/* sys fs */
key_class = class_create(THIS_MODULE, "key");
if (IS_ERR(key_class))
pr_err("Failed to create class(key)!\n");
key_dev = device_create(key_class, NULL, 0, NULL, "key");
if (IS_ERR(key_dev))
pr_err("Failed to create device(key)!\n");
if (device_create_file(key_dev, &dev_attr_key) < 0)
pr_err("Failed to create device file(%s)!\n", dev_attr_key.attr.name);
/* sys fs */
#endif
#ifndef CONFIG_MACH_LUCAS
//for landscape UI (temporary patch)
for (i = 0; i < registered; i++)
{
input_report_switch(ip->input_devs->dev[i], SW_LID, 1);
input_sync(ip->input_devs->dev[i]);
}
#endif
return 0;
err_input_register_device_failed:
//.........这里部分代码省略.........
开发者ID:rgshah3,项目名称:galaxy-fit,代码行数:101,代码来源:gpio_event.c
示例17: s2mps11_pmic_probe
static int s2mps11_pmic_probe(struct platform_device *pdev)
{
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct sec_platform_data *pdata = NULL;
struct of_regulator_match *rdata = NULL;
struct regulator_config config = { };
struct s2mps11_info *s2mps11;
int i, ret = 0;
const struct regulator_desc *regulators;
s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info),
GFP_KERNEL);
if (!s2mps11)
return -ENOMEM;
s2mps11->dev_type = platform_get_device_id(pdev)->driver_data;
switch (s2mps11->dev_type) {
case S2MPS11X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
regulators = s2mps11_regulators;
break;
case S2MPS13X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
regulators = s2mps13_regulators;
break;
case S2MPS14X:
s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
regulators = s2mps14_regulators;
break;
case S2MPU02:
s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
regulators = s2mpu02_regulators;
break;
default:
dev_err(&pdev->dev, "Invalid device type: %u\n",
s2mps11->dev_type);
return -EINVAL;
};
s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev,
sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num,
GFP_KERNEL);
if (!s2mps11->ext_control_gpio)
return -ENOMEM;
/*
* 0 is a valid GPIO so initialize all GPIO-s to negative value
* to indicate that external control won't be used for this regulator.
*/
for (i = 0; i < s2mps11->rdev_num; i++)
s2mps11->ext_control_gpio[i] = -EINVAL;
if (!iodev->dev->of_node) {
if (iodev->pdata) {
pdata = iodev->pdata;
goto common_reg;
} else {
dev_err(pdev->dev.parent,
"Platform data or DT node not supplied\n");
return -ENODEV;
}
}
rdata = kzalloc(sizeof(*rdata) * s2mps11->rdev_num, GFP_KERNEL);
if (!rdata)
return -ENOMEM;
for (i = 0; i < s2mps11->rdev_num; i++)
rdata[i].name = regulators[i].name;
ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11);
if (ret)
goto out;
common_reg:
platform_set_drvdata(pdev, s2mps11);
config.dev = &pdev->dev;
config.regmap = iodev->regmap_pmic;
config.driver_data = s2mps11;
config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
config.ena_gpio_initialized = true;
for (i = 0; i < s2mps11->rdev_num; i++) {
struct regulator_dev *regulator;
if (pdata) {
config.init_data = pdata->regulators[i].initdata;
config.of_node = pdata->regulators[i].reg_node;
} else {
config.init_data = rdata[i].init_data;
config.of_node = rdata[i].of_node;
}
config.ena_gpio = s2mps11->ext_control_gpio[i];
regulator = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
if (IS_ERR(regulator)) {
ret = PTR_ERR(regulator);
dev_err(&pdev->dev, "regulator init failed for %d\n",
i);
goto out;
//.........这里部分代码省略.........
开发者ID:383530895,项目名称:linux,代码行数:101,代码来源:s2mps11.c
示例18: ubicom32_spi_gpio_probe
/*
* ubicom32_spi_gpio_probe
*/
static int ubicom32_spi_gpio_probe(struct platform_device *dev)
{
struct ubicom32_spi_gpio_platform_data *pdata;
struct spi_master *master;
struct ubicom32_spi_gpio *usg;
int ret;
master = spi_alloc_master(&dev->dev, sizeof(struct ubicom32_spi_gpio));
if (master == NULL) {
dev_err(&dev->dev, "failed to allocate spi master\n");
ret = -ENOMEM;
goto err;
}
usg = (struct ubicom32_spi_gpio *)spi_master_get_devdata(master);
platform_set_drvdata(dev, usg);
/*
* Copy in the platform data
*/
pdata = dev->dev.platform_data;
usg->pdata = dev->dev.platform_data;
/*
* Request the GPIO lines
*/
ret = gpio_request(pdata->pin_mosi, "spi-mosi");
if (ret) {
dev_err(&dev->dev, "Failed to allocate spi-mosi GPIO\n");
goto err;
}
ret = gpio_request(pdata->pin_miso, "spi-miso");
if (ret) {
dev_err(&dev->dev, "Failed to allocate spi-miso GPIO\n");
goto err_nomiso;
}
ret = gpio_request(pdata->pin_clk, "spi-clk");
if (ret) {
dev_err(&dev->dev, "Failed to allocate spi-clk GPIO\n");
goto err_noclk;
}
/*
* Setup spi-bitbang adaptor
*/
usg->bitbang.flags |= SPI_CS_HIGH;
usg->bitbang.master = spi_master_get(master);
usg->bitbang.master->bus_num = pdata->bus_num;
usg->bitbang.master->num_chipselect = pdata->num_chipselect;
usg->bitbang.chipselect = ubicom32_spi_gpio_chipselect;
usg->bitbang.txrx_word[SPI_MODE_0] = ubicom32_spi_gpio_txrx_mode0;
usg->bitbang.txrx_word[SPI_MODE_1] = ubicom32_spi_gpio_txrx_mode1;
usg->bitbang.txrx_word[SPI_MODE_2] = ubicom32_spi_gpio_txrx_mode2;
usg->bitbang.txrx_word[SPI_MODE_3] = ubicom32_spi_gpio_txrx_mode3;
/*
* Setup the GPIO pins
*/
gpio_direction_output(pdata->pin_clk, pdata->clk_default);
gpio_direction_output(pdata->pin_mosi, 0);
gpio_direction_input(pdata->pin_miso);
/*
* Ready to go
*/
ret = spi_bitbang_start(&usg->bitbang);
if (ret) {
goto err_no_bitbang;
}
return 0;
err_no_bitbang:
spi_master_put(usg->bitbang.master);
gpio_free(pdata->pin_clk);
err_noclk:
gpio_free(pdata->pin_miso);
err_nomiso:
gpio_free(pdata->pin_mosi);
err:
return ret;
}
开发者ID:7LK,项目名称:McWRT,代码行数:93,代码来源:spi_ubicom32_gpio.c
示例19: k3v2_gpio_key_probe
|
请发表评论