Пример #1
0
/*
 *****************************************************************************
 *
 *	Driver Interface
 *
 *****************************************************************************
 */
static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind)
{
	struct i2c_client *client;
	int rc;

	client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
	if (!client)
		return -ENOMEM;

	strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE);
	client->addr = addr;
	client->adapter = adap;
	client->driver = &ds1374_driver;

	ds1374_workqueue = create_singlethread_workqueue("ds1374");

	if ((rc = i2c_attach_client(client)) != 0) {
		kfree(client);
		return rc;
	}

	save_client = client;

	ds1374_check_rtc_status();

	return 0;
}
Пример #2
0
static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind)
{
	struct i2c_client *client;
	int rc;

	client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
	if (!client)
		return -ENOMEM;

	memset(client, 0, sizeof(struct i2c_client));
	strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE);
	client->flags = I2C_DF_NOTIFY;
	client->addr = addr;
	client->adapter = adap;
	client->driver = &ds1374_driver;

	if ((rc = i2c_attach_client(client)) != 0) {
		kfree(client);
		return rc;
	}

	INIT_WORK(&set_rtc_time_task,
			(void (*)(void *))&ds1374_set_tlet, &new_time);

	save_client = client;

	ds1374_check_rtc_status();

#ifdef CONFIG_RMI_PHOENIX
	rtc_get_time = ds1374_get_rtc_time;
	rtc_set_time = ds1374_set_rtc_time;
#endif
	return 0;
}
Пример #3
0
static int ds1374_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct ds1374 *ds1374;
	int ret;

	ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL);
	if (!ds1374)
		return -ENOMEM;

	ds1374->client = client;
	i2c_set_clientdata(client, ds1374);

	INIT_WORK(&ds1374->work, ds1374_work);
	mutex_init(&ds1374->mutex);

	ret = ds1374_check_rtc_status(client);
	if (ret)
		goto out_free;

	if (client->irq > 0) {
		ret = request_irq(client->irq, ds1374_irq, 0,
		                  "ds1374", client);
		if (ret) {
			dev_err(&client->dev, "unable to request IRQ\n");
			goto out_free;
		}

		device_set_wakeup_capable(&client->dev, 1);
	}

	ds1374->rtc = rtc_device_register(client->name, &client->dev,
	                                  &ds1374_rtc_ops, THIS_MODULE);
	if (IS_ERR(ds1374->rtc)) {
		ret = PTR_ERR(ds1374->rtc);
		dev_err(&client->dev, "unable to register the class device\n");
		goto out_irq;
	}

	return 0;

out_irq:
	if (client->irq > 0)
		free_irq(client->irq, client);

out_free:
	i2c_set_clientdata(client, NULL);
	kfree(ds1374);
	return ret;
}
Пример #4
0
static int ds1374_probe(struct i2c_adapter *adapter, int address, int kind)
{
	struct ds1374 *ds1374;
	struct i2c_client *client;
	int ret;

	ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL);
	if (!ds1374)
		return -ENOMEM;

	client = &ds1374->client;
	client->addr = address;
	client->adapter = adapter;
	client->driver = &ds1374_driver;
	client->flags = 0;
	strlcpy(client->name, "ds1374", I2C_NAME_SIZE);

	i2c_set_clientdata(client, ds1374);

	mutex_init(&ds1374->mutex);

	ret = i2c_attach_client(client);
	if (ret)
		goto attach_failed;

	ret = ds1374_check_rtc_status(client);
	if (ret)
		goto status_failed;

	ds1374->rtc = rtc_device_register(client->name, &client->dev,
	                                  &ds1374_rtc_ops, THIS_MODULE);
	if (IS_ERR(ds1374->rtc)) {
		ret = PTR_ERR(ds1374->rtc);
		dev_err(&client->dev, "unable to register the class device\n");
		goto rtc_register_failed;
	}

	return 0;

rtc_register_failed:
status_failed:
	i2c_detach_client(client);
attach_failed:
	i2c_set_clientdata(client, NULL);
	kfree(ds1374);
	printk(KERN_ERR "ds1374: failed to probe\n");
	return ret;
}