Beispiel #1
0
int ddcmon_detach_client(struct i2c_client *client)
{
	int err;

	i2c_deregister_entry(((struct ddcmon_data *) (client->data))->
				 sysctl_id);
	if ((err = i2c_detach_client(client))) {
		printk
		    ("ddcmon.o: Client deregistration failed, client not detached.\n");
		return err;
	}
	kfree(client);
	return 0;
}
Beispiel #2
0
int i2c_adcm2650_detach(struct i2c_client *client)
{
	int err;
    	
	/* Try to detach the client from i2c space */
    	if ((err = i2c_detach_client(client))) {
      		printk("adcm2650.o: Client deregistration failed, client not detached.\n");
	      	return err;
    	}

    	kfree(client); /* Frees client data too, if allocated at the same time */
    	g_client = NULL;
    	return 0;
}
static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
					     u8 addr, int ds1775,
					     const char *loc)
{
	struct wf_lm75_sensor *lm;
	int rc;

	DBG("wf_lm75: creating  %s device at address 0x%02x\n",
	    ds1775 ? "ds1775" : "lm75", addr);

	lm = kzalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
	if (lm == NULL)
		return NULL;

	/* Usual rant about sensor names not beeing very consistent in
	 * the device-tree, oh well ...
	 * Add more entries below as you deal with more setups
	 */
	if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
		lm->sens.name = "hd-temp";
	else
		goto fail;

	lm->inited = 0;
	lm->sens.ops = &wf_lm75_ops;
	lm->ds1775 = ds1775;
	lm->i2c.addr = (addr >> 1) & 0x7f;
	lm->i2c.adapter = adapter;
	lm->i2c.driver = &wf_lm75_driver;
	strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1);

	rc = i2c_attach_client(&lm->i2c);
	if (rc) {
		printk(KERN_ERR "windfarm: failed to attach %s %s to i2c,"
		       " err %d\n", ds1775 ? "ds1775" : "lm75",
		       lm->i2c.name, rc);
		goto fail;
	}

	if (wf_register_sensor(&lm->sens)) {
		i2c_detach_client(&lm->i2c);
		goto fail;
	}

	return lm;
 fail:
	kfree(lm);
	return NULL;
}
static int i2c_acc_kr3dm_detach_client(struct i2c_client *client)
{
	int err;

  	/* Try to detach the client from i2c space */
	if ((err = i2c_detach_client(client))) {
        return err;
	}
#ifdef DEBUG
	printk("[KR3DM] i2c_detach_client\n");
#endif
	kfree(client); /* Frees client data too, if allocated at the same time */
	g_client = NULL;
	return 0;
}
Beispiel #5
0
static int pcf8563_detach(struct i2c_client *client)
{
	int err;
	struct rtc_device *rtc = i2c_get_clientdata(client);

	if (rtc)
		rtc_device_unregister(rtc);

	if ((err = i2c_detach_client(client)))
		return err;

	kfree(client);

	return 0;
}
Beispiel #6
0
static int smsc47b397_detach_client(struct i2c_client *client)
{
	struct smsc47b397_data *data = i2c_get_clientdata(client);
	int err;

	hwmon_device_unregister(data->class_dev);

	if ((err = i2c_detach_client(client)))
		return err;

	release_region(client->addr, SMSC_EXTENT);
	kfree(data);

	return 0;
}
static int ovcamchip_detach(struct i2c_client *c)
{
	struct ovcamchip *ov = i2c_get_clientdata(c);
	int rc;

	rc = ov->sops->free(c);
	if (rc < 0)
		return rc;

	i2c_detach_client(c);

	kfree(ov);
	kfree(c);
	return 0;
}
Beispiel #8
0
static int max1619_detach_client(struct i2c_client *client)
{
	int err;

	i2c_deregister_entry(((struct max1619_data *)
		(client->data))->sysctl_id);
	if ((err = i2c_detach_client(client))) {
		printk(KERN_ERR "max1619.o: Client deregistration failed, "
		       "client not detached.\n");
		return err;
	}

	kfree(client->data);
	return 0;
}
Beispiel #9
0
static int ds1374_detach(struct i2c_client *client)
{
	int ret;
	struct ds1374 *ds1374 = i2c_get_clientdata(client);

	rtc_device_unregister(ds1374->rtc);

	ret = i2c_detach_client(client);
	if (ret)
		return ret;

	kfree(i2c_get_clientdata(client));

	return 0;
}
Beispiel #10
0
static int irrtc_detach_client(struct i2c_client * client)
{
    int ret = 0;

    if ((ret = i2c_detach_client(client)) != 0)
    {
        dbg("%s Unable to detach client.\n", pname);
        goto out;
    }

    kfree(client);

out:
    return ret;
}
Beispiel #11
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;
}
static int AMI8563_detach(struct i2c_client *client)
{
	struct AMI8563 *pAMI8563 = container_of(client, struct AMI8563, client);
	struct rtc_device *rtc = i2c_get_clientdata(client);

 	pmic_callback_unregister(PMIC_EVENT_EXTON, AMI8563_alarm_event_handler);
	
	if (rtc)
		rtc_device_unregister(rtc);
	
	i2c_detach_client(client);
	
	kfree(pAMI8563);
	
	return 0;
}
Beispiel #13
0
int mtp008_detach_client(struct i2c_client *client)
{
	int err;

	i2c_deregister_entry(
		((struct mtp008_data *) (client->data))->sysctl_id);

	if ((err = i2c_detach_client(client))) {
		printk("mtp008.o: Deregistration failed, "
		       "client not detached.\n");
		return err;
	}
	kfree(client);

	return 0;
}
Beispiel #14
0
static int
saa7111_detach_client (struct i2c_client *client)
{
    struct saa7111 *decoder = i2c_get_clientdata(client);
    int err;

    err = i2c_detach_client(client);
    if (err) {
        return err;
    }

    kfree(decoder);
    kfree(client);

    return 0;
}
Beispiel #15
0
static int
bt856_detach_client (struct i2c_client *client)
{
	struct bt856 *encoder = i2c_get_clientdata(client);
	int err;

	err = i2c_detach_client(client);
	if (err) {
		return err;
	}

	kfree(encoder);
	kfree(client);

	return 0;
}
Beispiel #16
0
int sis5595_detach_client(struct i2c_client *client)
{
	int err;

	i2c_deregister_entry(((struct sis5595_data *) (client->data))->
				 sysctl_id);

	if ((err = i2c_detach_client(client))) {
		printk
		    ("sis5595.o: Client deregistration failed, client not detached.\n");
		return err;
	}

	release_region(client->addr, SIS5595_EXTENT);
	kfree(client);

	return 0;
}
Beispiel #17
0
static int
saa7185_detach_client (struct i2c_client *client)
{
	struct saa7185 *encoder = i2c_get_clientdata(client);
	int err;

	err = i2c_detach_client(client);
	if (err) {
		return err;
	}

	saa7185_write(client, 0x61, (encoder->reg[0x61]) | 0x40);	/* SW: output off is active */
	//saa7185_write(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */

	kfree(encoder);
	kfree(client);

	return 0;
}
Beispiel #18
0
static int tvp5150_detach_client(struct i2c_client *c)
{
    struct tvp5150 *decoder = i2c_get_clientdata(c);
    int err;

    tvp5150_dbg(1,
        "tvp5150.c: removing tvp5150 adapter on address 0x%x\n",
        c->addr << 1);

    err = i2c_detach_client(c);
    if (err) {
        return err;
    }

    kfree(decoder);
    kfree(c);

    return 0;
}
Beispiel #19
0
static int
detach_client(struct i2c_client *client)
{
	int err;

	if (client->addr == 9) {
		cancel_delayed_work(&battery_work);
		flush_scheduled_work();

#       	ifdef CONFIG_POWER_SUPPLY
			power_supply_unregister(&battery_info);
#       	endif
	}

	if ((err = i2c_detach_client(client))) {
		return err;
	}

	return 0;
}
Beispiel #20
0
static int ltc3577_detach( struct i2c_client *c )
{
#if defined CONFIG_CPU_FREQ && (defined CONFIG_S3C24XX_DVS_CPUFREQ || defined S3C24XX_DFS_CPUFREQ)
    struct ltc3577_i2c_driver *driver=(struct ltc3577_i2c_driver *) container_of( c, struct ltc3577_i2c_driver, client );
#endif

    /* First unregister the I2C client's members. */
    if( IO_HaveUsbBusPowered() )
    {
        if( remove_usb_state_change_listener( ltc3577_state_change_listener, NULL ) != 0 )
            printk( KERN_ERR "LTC3577: Couldn't unregister USBMODE change state listener!\n" );
    }

#if defined CONFIG_CPU_FREQ && (defined CONFIG_S3C24XX_DVS_CPUFREQ || defined S3C24XX_DFS_CPUFREQ)
    /* Unregister CPU frequency scaling. */
    cpufreq_unregister_notifier( &driver->freq_transition, CPUFREQ_TRANSITION_NOTIFIER );
    cpufreq_unregister_notifier( &driver->freq_policy, CPUFREQ_POLICY_NOTIFIER );
#endif

    /* Now remove the I2C client. */
    i2c_detach_client(c);
    return 0;
}
Beispiel #21
0
/* This function is called by i2c_detect */
int ltc1710_detect(struct i2c_adapter *adapter, int address,
		   unsigned short flags, int kind)
{
	int i;
	struct i2c_client *new_client;
	struct ltc1710_data *data;
	int err = 0;
	const char *type_name, *client_name;

	/* Make sure we aren't probing the ISA bus!! This is just a safety check
	   at this moment; i2c_detect really won't call us. */
#ifdef DEBUG
	if (i2c_is_isa_adapter(adapter)) {
		printk
		    ("ltc1710.o: ltc1710_detect called for an ISA bus adapter?!?\n");
		return 0;
	}
#endif

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
		goto ERROR0;

	/* OK. For now, we presume we have a valid client. We now create the
	   client structure, even though we cannot fill it completely yet.
	   But it allows us to access ltc1710_{read,write}_value. */
	if (!(new_client = kmalloc(sizeof(struct i2c_client) +
				   sizeof(struct ltc1710_data),
				   GFP_KERNEL))) {
		err = -ENOMEM;
		goto ERROR0;
	}

	data = (struct ltc1710_data *) (new_client + 1);
	new_client->addr = address;
	new_client->data = data;
	new_client->adapter = adapter;
	new_client->driver = &ltc1710_driver;
	new_client->flags = 0;

	/* Now, we would do the remaining detection. But the LTC1710 is plainly
	   impossible to detect! Stupid chip. */

	/* Determine the chip type - only one kind supported! */
	if (kind <= 0)
		kind = ltc1710;

	if (kind == ltc1710) {
		type_name = "ltc1710";
		client_name = "LTC1710 chip";
	} else {
#ifdef DEBUG
		printk("ltc1710.o: Internal error: unknown kind (%d)?!?",
		       kind);
#endif
		goto ERROR1;
	}

	/* Fill in the remaining client fields and put it into the global list */
	strcpy(new_client->name, client_name);

	new_client->id = ltc1710_id++;
	data->valid = 0;
	init_MUTEX(&data->update_lock);

	/* Tell the I2C layer a new client has arrived */
	if ((err = i2c_attach_client(new_client)))
		goto ERROR3;

	/* Register a new directory entry with module sensors */
	if ((i = i2c_register_entry(new_client, type_name,
					ltc1710_dir_table_template,
					THIS_MODULE)) < 0) {
		err = i;
		goto ERROR4;
	}
	data->sysctl_id = i;

	return 0;

/* OK, this is not exactly good programming practice, usually. But it is
   very code-efficient in this case. */

      ERROR4:
	i2c_detach_client(new_client);
      ERROR3:
      ERROR1:
	kfree(new_client);
      ERROR0:
	return err;
}
Beispiel #22
0
static int lp8720_detach_client(struct i2c_client *client)
{
	i2c_detach_client(client);
	return 0;
}
Beispiel #23
0
/*
 * Initialize the I2C interface of the CS4270
 *
 * This function is called for whenever the I2C subsystem finds a device
 * at a particular address.
 *
 * Note: snd_soc_new_pcms() must be called before this function can be called,
 * because of snd_ctl_add().
 */
static int cs4270_i2c_probe(struct i2c_adapter *adapter, int addr, int kind)
{
	struct snd_soc_device *socdev = cs4270_socdev;
	struct snd_soc_codec *codec = socdev->codec;
	struct i2c_client *i2c_client = NULL;
	int i;
	int ret = 0;

	/* Probing all possible addresses has one drawback: if there are
	   multiple CS4270s on the bus, then you cannot specify which
	   socdev is matched with which CS4270.  For now, we just reject
	   this I2C device if the socdev already has one attached. */
	if (codec->control_data)
		return -ENODEV;

	/* Note: codec_dai->codec is NULL here */

	i2c_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
	if (!i2c_client) {
		printk(KERN_ERR "cs4270: could not allocate I2C client\n");
		return -ENOMEM;
	}

	codec->reg_cache = kzalloc(CS4270_NUMREGS, GFP_KERNEL);
	if (!codec->reg_cache) {
		printk(KERN_ERR "cs4270: could not allocate register cache\n");
		ret = -ENOMEM;
		goto error;
	}

	i2c_set_clientdata(i2c_client, codec);
	strcpy(i2c_client->name, "CS4270");

	i2c_client->driver = &cs4270_i2c_driver;
	i2c_client->adapter = adapter;
	i2c_client->addr = addr;

	/* Verify that we have a CS4270 */

	ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID);
	if (ret < 0) {
		printk(KERN_ERR "cs4270: failed to read I2C\n");
		goto error;
	}
	/* The top four bits of the chip ID should be 1100. */
	if ((ret & 0xF0) != 0xC0) {
		/* The device at this address is not a CS4270 codec */
		ret = -ENODEV;
		goto error;
	}

	printk(KERN_INFO "cs4270: found device at I2C address %X\n", addr);
	printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF);

	/* Tell the I2C layer a new client has arrived */

	ret = i2c_attach_client(i2c_client);
	if (ret) {
		printk(KERN_ERR "cs4270: could not attach codec, "
			"I2C address %x, error code %i\n", addr, ret);
		goto error;
	}

	codec->control_data = i2c_client;
	codec->read = cs4270_read_reg_cache;
	codec->write = cs4270_i2c_write;
	codec->reg_cache_size = CS4270_NUMREGS;

	/* The I2C interface is set up, so pre-fill our register cache */

	ret = cs4270_fill_cache(codec);
	if (ret < 0) {
		printk(KERN_ERR "cs4270: failed to fill register cache\n");
		goto error;
	}

	/* Add the non-DAPM controls */

	for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) {
		struct snd_kcontrol *kctrl =
		snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);

		ret = snd_ctl_add(codec->card, kctrl);
		if (ret < 0)
			goto error;
	}

	return 0;

error:
	if (codec->control_data) {
		i2c_detach_client(i2c_client);
		codec->control_data = NULL;
	}

	kfree(codec->reg_cache);
	codec->reg_cache = NULL;
	codec->reg_cache_size = 0;

	kfree(i2c_client);

	return ret;
}
static int AMI8563_probe(struct i2c_adapter *adapter, int address, int kind)
{
	struct AMI8563 *pAMI8563 = NULL;
	struct i2c_client *client = NULL;
	struct rtc_device *rtc = NULL;
	u8 value = 0;
	int err = 0;
	
	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
		err = -ENODEV;
		goto exit;
	}

	if(address != AMI8563_ADDR) {
		err = -EIO;
		goto exit;
	}

	if (!(pAMI8563 = kzalloc(sizeof(struct AMI8563), GFP_KERNEL))) {
		err = -ENOMEM;
		goto exit;
	}
	
	pAMI8563->alarm_status_power_on = 0;	
	client = &pAMI8563->client;
	client->addr = address;
	client->driver = &AMI8563_driver;
	client->adapter = adapter;
	strlcpy(client->name, AMI8563_driver.driver.name, I2C_NAME_SIZE);

	/* detect chip and check the alarm status*/
	err = i2c_ami8563_read(client, AMI8563_REG_ST2);
	if (err<0) {		
		goto exit_kfree;
	} else if (err&0x08) {
		ami8563_info("Power up as alarm on\n");
		pAMI8563->alarm_status_power_on = 1;
	}

	value = i2c_ami8563_read(client, AMI8563_REG_YR);
	ami8563_info("current year %d\n", value);
	value = bcd2bin(value);
#define CURRENT_YEAR (9) // 2009
	if (value>30 || value<CURRENT_YEAR) {
		ami8563_err("Detect invalid year %d, reset to default\n", value+2000);
		i2c_ami8563_write(client, AMI8563_REG_YR, bin2bcd(CURRENT_YEAR));
	}

	if ((err = i2c_attach_client(client)))
		goto exit_kfree;

	rtc = rtc_device_register(AMI8563_driver.driver.name, &client->dev,
				&AMI8563_rtc_ops, THIS_MODULE);
	if (IS_ERR(rtc)) {
		err = PTR_ERR(rtc);
		goto exit_detach;
	}

	i2c_set_clientdata(client, rtc);
	g_client = client;

	/*Clear AF,enable AIE*/
	//micco_enable_rtc_alarm_irq(0);
	value = i2c_ami8563_read(client, AMI8563_REG_ST2);
	value &= ~0x1<<3;
	value |= 0x1<<1;
	i2c_ami8563_write(client, AMI8563_REG_ST2, value);
	micco_enable_rtc_alarm_irq(1);
		
	//err = pmic_callback_register(PMIC_EVENT_EXTON, AMI8563_alarm_event_handler);
	
	AMI8563_sync_pxa3xx_rtc(client);

	register_reboot_notifier(&ami_sys_reboot_nb); /* for enter into recovery mode */
#ifdef CONFIG_YUHUA_MISC_DEV	
	set_rtc_detect(1);
#endif
	
	printk("Rtc ami8563 drv register succ\n");
	return 0;

exit_detach:
	i2c_detach_client(client);
exit_kfree:
	kfree(pAMI8563);
exit:
	ami8563_err("err %d\n", err);
	return err;
}
Beispiel #25
0
static int detach(struct i2c_client *client)
{
    int ret = i2c_detach_client(client);
    kfree(client);
    return ret;
}
Beispiel #26
0
/* This function is called by i2c_detect */
int ddcmon_detect(struct i2c_adapter *adapter, int address,
		  unsigned short flags, int kind)
{
	int i, cs;
	struct i2c_client *new_client;
	struct ddcmon_data *data;
	int err = 0;
	const char *type_name, *client_name;

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		    goto ERROR0;

	/* OK. For now, we presume we have a valid client. We now create the
	   client structure, even though we cannot fill it completely yet.
	   But it allows us to access ddcmon_{read,write}_value. */
	if (!(new_client = kmalloc(sizeof(struct i2c_client) +
				   sizeof(struct ddcmon_data),
				   GFP_KERNEL))) {
		err = -ENOMEM;
		goto ERROR0;
	}

	data = (struct ddcmon_data *) (new_client + 1);
	new_client->addr = address;
	new_client->data = data;
	new_client->adapter = adapter;
	new_client->driver = &ddcmon_driver;
	new_client->flags = 0;

	/* Now, we do the remaining detection. */
	/* Verify the first 8 locations 0x00FFFFFFFFFFFF00 */
	/* Allow force and force_ddcmon arguments */
	if(kind < 0)
	{
		for(i = 0; i < 8; i++) {
			cs = i2c_smbus_read_byte_data(new_client, i);
			if(i == 0 || i == 7) {
				if(cs != 0)
					goto ERROR1;
			} else if(cs != 0xff)
				goto ERROR1;
		}
	}

	type_name = "ddcmon";
	client_name = "DDC Monitor";

	/* Fill in the remaining client fields and put it in the global list */
	strcpy(new_client->name, client_name);

	new_client->id = ddcmon_id++;
	data->valid = 0;
	init_MUTEX(&data->update_lock);

	/* Tell the I2C layer a new client has arrived */
	if ((err = i2c_attach_client(new_client)))
		goto ERROR3;

	/* Register a new directory entry with module sensors */
	if ((i = i2c_register_entry(new_client, type_name,
					ddcmon_dir_table_template,
					THIS_MODULE)) < 0) {
		err = i;
		goto ERROR4;
	}
	data->sysctl_id = i;

	return 0;

      ERROR4:
	i2c_detach_client(new_client);
      ERROR3:
      ERROR1:
	kfree(new_client);
      ERROR0:
	return err;
}
static void snd_ak4641_i2c_detach(struct snd_ak4641 *ak)
{
	i2c_detach_client(&ak->i2c_client);
}
Beispiel #28
0
static int max9877_i2c_detach(struct i2c_client *client)
{
//	FI
    i2c_detach_client(client);
    return 0;
}
Beispiel #29
0
int mtp008_detect(struct i2c_adapter *adapter, int address,
		  unsigned short flags, int kind)
{
	const char *type_name = "";
	const char *client_name = "";
	int is_isa, err, sysid;
	struct i2c_client *new_client;
	struct mtp008_data *data;

	err = 0;

	is_isa = i2c_is_isa_adapter(adapter);
	if (is_isa ||
	    !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		goto ERROR0;

	/*
	 * We presume we have a valid client.  We now create the client
	 * structure, even though we cannot fill it completely yet.  But it
	 * allows us to use mtp008_(read|write)_value().
	 */
	if (!(new_client = kmalloc(sizeof(struct i2c_client) +
				   sizeof(struct mtp008_data),
				   GFP_KERNEL))) {
		err = -ENOMEM;
		goto ERROR0;
	}
	data = (struct mtp008_data *) (new_client + 1);
	new_client->addr = address;
	new_client->data = data;
	new_client->adapter = adapter;
	new_client->driver = &mtp008_driver;
	new_client->flags = 0;

	/*
	 * Remaining detection.
	 */
	if (kind < 0) {
		if (mtp008_read_value(new_client, MTP008_REG_CHIPID) != 0xac)
			goto ERROR1;
	}
	/*
	 * Fill in the remaining client fields and put it into the global list.
	 */
	type_name = "mtp008";
	client_name = "MTP008 chip";
	strcpy(new_client->name, client_name);
	data->type = kind;

	new_client->id = mtp008_id++;
	data->valid = 0;
	init_MUTEX(&data->update_lock);

	/*
	 * Tell the I2C layer that a new client has arrived.
	 */
	if ((err = i2c_attach_client(new_client)))
		goto ERROR1;

	/*
	 * Register a new directory entry with the sensors module.
	 */
	if ((sysid = i2c_register_entry(new_client, type_name,
					    mtp008_dir_table_template,
					    THIS_MODULE)) < 0) {
		err = sysid;
		goto ERROR2;
	}
	data->sysctl_id = sysid;

	/*
	 * Initialize the MTP008 chip.
	 */
	mtp008_init_client(new_client);

	return 0;

	/*
	 * Error handling.  Bad programming practise but very code efficient.
	 */
      ERROR2:
	i2c_detach_client(new_client);
      ERROR1:
	kfree(new_client);

      ERROR0:
	return err;
}
Beispiel #30
0
static int sensor_detach(struct i2c_client *client)
{
	i2c_detach_client(client);
	s3c_camif_unregister_sensor(client);
	return 0;
}