本文整理汇总了C++中i2c_put_adapter函数的典型用法代码示例。如果您正苦于以下问题:C++ i2c_put_adapter函数的具体用法?C++ i2c_put_adapter怎么用?C++ i2c_put_adapter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2c_put_adapter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: knxjif_init_i2c
int __init knxjif_init_i2c(void)
{
struct i2c_adapter *adapter;
int res;
adapter = i2c_get_adapter(i2c_bus);
if (!adapter) {
pr_warn("knxjif: i2c_get_adapter(%d) failed\n", i2c_bus);
goto fail;
}
#ifdef USE_ACC_IRQ
res = gpio_request(gpio_line, NAME);
if (0 > res) {
pr_warn("knxjif: request gpio failed\n");
goto fail2;
}
res = gpio_direction_input(gpio_line);
if (0 > res) {
pr_warn("knxjif: gpio direction input failed\n");
goto fail2;
}
knxjif_board_info.irq = gpio_to_irq(gpio_line);
#endif // #ifdef USE_ACC_IRQ
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35)
knxjif_i2c_client = i2c_new_probed_device(adapter,
&knxjif_board_info,
knxjif_addr_list,
__knxjif_probe_i2c);
#else
knxjif_i2c_client = i2c_new_probed_device(adapter,
&knxjif_board_info,
knxjif_addr_list);
#endif
if (!knxjif_i2c_client) {
pr_warn("knxjif: i2c_new_probed_device() failed\n");
goto fail1;
}
i2c_put_adapter(adapter);
return 0;
fail2:
#ifdef USE_ACC_IRQ
gpio_free(gpio_line);
#endif
fail1:
i2c_put_adapter(adapter);
fail:
return -1;
}
示例2: adv7180_write
/*
* adv7180_write
*/
static int __init adv7180_write(int i2c_adapt, int i2c_addr, int reg, int val)
{
struct i2c_adapter *adap;
struct i2c_msg msg[1];
unsigned char data[2];
int err;
adap = i2c_get_adapter(i2c_adapt);
if (!adap) {
printk(KERN_WARNING "%s: failed to get i2c adapter\n", __FUNCTION__);
return -ENODEV;
}
msg->addr = i2c_addr;
msg->flags = 0;
msg->len = 2;
msg->buf = data;
data[0] = reg;
data[1] = val;
err = i2c_transfer(adap, msg, 1);
i2c_put_adapter(adap);
if (err >= 0) {
return 0;
}
return err;
}
示例3: i2c_reads
static int i2c_reads(int id, int addr, char *buf, int bytes)
{
struct i2c_adapter *adap;
struct i2c_msg msg[2];
int ret;
char reg = buf[0];
if ((id < 0) || (addr < 0)) {
printk("%s: Please set i2c id and addr.\n",__func__);
return -EINVAL;
}
adap = i2c_get_adapter(id);
if (!adap)
return -EINVAL;
msg[0].addr = addr;
msg[0].flags = 0;
msg[0].len = 1;
msg[0].buf = ®
msg[0].scl_rate = 100 * 1000;
msg[0].udelay = 5;
msg[1].addr = addr;
msg[1].flags = I2C_M_RD;
msg[1].len = bytes;
msg[1].buf = buf;
msg[1].scl_rate = 100 * 1000;
msg[1].udelay = 5;
ret = i2c_transfer(adap, msg, 2);
i2c_put_adapter(adap);
return (ret == 1) ? bytes: ret;
}
示例4: smsi2c_unregister
void smsi2c_unregister(void)
{
//need to save smsdev and check for null
if (g_smsi2c_device) {
#ifdef SMS_RK_TS
/*********************
* stop rk ts interface
* smsi2c_ts_feed(void *, NULL, NULL);
************************/
rk29_hsadc_stop_transmit();
rk_ts_callback_setup(NULL, NULL, NULL);
#endif
#if 1 //wood, ++, @20140916
free_irq(gpio_to_irq(host_i2c_intr_pin), g_smsi2c_device);
gpio_free(host_i2c_intr_pin);
#endif
if (g_smsi2c_device->coredev) {
//need to save smsdev and check for null
smscore_unregister_device(g_smsi2c_device->coredev);
g_smsi2c_device->coredev = NULL;
}
i2c_unregister_device(g_smsi2c_device->client);
i2c_put_adapter(g_smsi2c_device->adap);
kfree(g_smsi2c_device);
g_smsi2c_device = NULL;
}
}
示例5: ip7500iap_init_onboard_video
/*
* ip7500iap_init_onboard_video
*/
static int __init ip7500iap_init_onboard_video(void)
{
struct i2c_adapter *adap;
/*
* If we are autodetect then bring up the display now
*/
#ifdef CONFIG_DISPLAY_AUTODETECT
/*
* Use the VFB device for the onboard display
*/
platform_device_register(&ip7500iap_vfb_device);
#endif
platform_device_register(&ip7500iap_backlight_device);
adap = i2c_get_adapter(0);
if (!adap) {
printk(KERN_WARNING "%s: Failed to get i2c adapter\n", __FUNCTION__);
return -ENODEV;
}
printk(KERN_INFO "%s: registering touch screen controller resources\n", __FUNCTION__);
i2c_new_device(adap, &ip7500iap_touch_i2c_board_info);
i2c_put_adapter(adap);
return 0;
}
示例6: wmt_vid_i2c_init
int wmt_vid_i2c_init( short dev_id)
{
struct i2c_board_info *wmt_vid_i2c_bi = &wmt_vid_i2c_board_info;
int ret =0;
adapter = i2c_get_adapter(WMT_VID_I2C_CHANNEL);
if (adapter == NULL) {
printk("can not get i2c adapter, client address error");
return -ENODEV;
}
wmt_vid_i2c_bi->addr = dev_id;
client = i2c_new_device(adapter, wmt_vid_i2c_bi);
if ( client == NULL) {
printk("allocate i2c client failed");
return -ENOMEM;
}
i2c_put_adapter(adapter);
ret = i2c_add_driver(&wmt_vid_i2c_driver);
if (ret) {
printk("i2c_add_driver fail");
}
return ret;
}
示例7: i2c_flash_open
static int i2c_flash_open(struct inode *inode, struct file *file)
{
adap = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
adap = i2c_get_adapter(ADAPT_NUMBR);
if (!adap)
return -ENODEV;
/* This creates an anonymous i2c_client, which may later be
* pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE.
*
* This client is ** NEVER REGISTERED ** with the driver model
* or I2C core code!! It just holds private copies of addressing
* information and maybe a PEC flag.
*/
client = kzalloc(sizeof(*client), GFP_KERNEL);
if (!client) {
i2c_put_adapter(adap);
return -ENOMEM;
}
snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
client->adapter = adap;
//set the slave addr
client->addr = SLAVE_ADDRE;
//file->private_data = client;
printk("\n%s opening\n", DEVICE_NAME);
return 0;
}
示例8: i2cdev_open
static int i2cdev_open(struct inode *inode, struct file *file)
{
unsigned int minor = iminor(inode);
struct i2c_client *client;
struct i2c_adapter *adap;
struct i2c_dev *i2c_dev;
i2c_dev = i2c_dev_get_by_minor(minor);
if (!i2c_dev)
return -ENODEV;
adap = i2c_get_adapter(i2c_dev->adap->nr);
if (!adap)
return -ENODEV;
client = kmalloc(sizeof(*client), GFP_KERNEL);
if (!client) {
i2c_put_adapter(adap);
return -ENOMEM;
}
memcpy(client, &i2cdev_client_template, sizeof(*client));
/* registered with adapter, passed as client to user */
client->adapter = adap;
file->private_data = client;
return 0;
}
示例9: i2c_get_adapter
/*
* Sensor subdevice helper functions
*/
static struct v4l2_subdev *fimc_md_register_sensor(struct fimc_md *fmd,
struct fimc_sensor_info *s_info)
{
struct i2c_adapter *adapter;
struct v4l2_subdev *sd = NULL;
if (!s_info || !fmd)
return NULL;
adapter = i2c_get_adapter(s_info->pdata.i2c_bus_num);
if (!adapter) {
v4l2_warn(&fmd->v4l2_dev,
"Failed to get I2C adapter %d, deferring probe\n",
s_info->pdata.i2c_bus_num);
return ERR_PTR(-EPROBE_DEFER);
}
sd = v4l2_i2c_new_subdev_board(&fmd->v4l2_dev, adapter,
s_info->pdata.board_info, NULL);
if (IS_ERR_OR_NULL(sd)) {
i2c_put_adapter(adapter);
v4l2_warn(&fmd->v4l2_dev,
"Failed to acquire subdev %s, deferring probe\n",
s_info->pdata.board_info->type);
return ERR_PTR(-EPROBE_DEFER);
}
v4l2_set_subdev_hostdata(sd, s_info);
sd->grp_id = SENSOR_GROUP_ID;
v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice %s\n",
s_info->pdata.board_info->type);
return sd;
}
示例10: minnow_module_exit
static void __exit minnow_module_exit(void)
{
i2c_unregister_device(client);
i2c_put_adapter(adap);
pr_info("exited\n");
}
示例11: i2c_get_adapter
/*
* Sensor subdevice helper functions
*/
static struct v4l2_subdev *fimc_md_register_sensor(struct fimc_md *fmd,
struct fimc_sensor_info *s_info)
{
struct i2c_adapter *adapter;
struct v4l2_subdev *sd = NULL;
if (!s_info || !fmd)
return NULL;
adapter = i2c_get_adapter(s_info->pdata->i2c_bus_num);
if (!adapter)
return NULL;
sd = v4l2_i2c_new_subdev_board(&fmd->v4l2_dev, adapter,
s_info->pdata->board_info, NULL);
if (IS_ERR_OR_NULL(sd)) {
i2c_put_adapter(adapter);
v4l2_err(&fmd->v4l2_dev, "Failed to acquire subdev\n");
return NULL;
}
v4l2_set_subdev_hostdata(sd, s_info);
sd->grp_id = SENSOR_GROUP_ID;
v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice %s\n",
s_info->pdata->board_info->type);
return sd;
}
示例12: tegra_camera_disable
static void tegra_camera_disable(struct nvhost_device *ndev)
{
struct i2c_adapter *adapter;
gpio_set_value_cansleep(TEGRA_CAMERA_GPIO_PMU, 0);
gpio_set_value(TEGRA_CAMERA_GPIO_VI_GP3, 0);
gpio_set_value(TEGRA_CAMERA_GPIO_CAM_PWR_EN, 0);
gpio_free(TEGRA_CAMERA_GPIO_PMU);
gpio_free(TEGRA_CAMERA_GPIO_VI_GP3);
gpio_free(TEGRA_CAMERA_GPIO_CAM_PWR_EN);
adapter = i2c_get_adapter(TEGRA_CAMERA_I2C_ADAPTER_ID);
BUG_ON(!adapter);
i2c_unregister_device(port_switch);
i2c_unregister_device(port_expander);
i2c_put_adapter(adapter);
BUG_ON(!regulator);
regulator_disable(regulator);
regulator_put(regulator);
regulator = NULL;
/* Turn off relevant clocks. */
clk_disable(clk_vi);
clk_disable(clk_vi_sensor);
clk_disable(clk_csi);
clk_disable(clk_isp);
clk_disable(clk_csus);
}
示例13: zpad80_pmu_dev_init
static int __init zpad80_pmu_dev_init(void)
{
struct i2c_adapter *adap;
struct i2c_client *client;
int busnum = PMU_I2C_BUSNUM;
int i;
adap = i2c_get_adapter(busnum);
if (!adap) {
pr_err("failed to get adapter i2c%d\n", busnum);
return -1;
}
client = i2c_new_device(adap, &zpad80_pmu_board_info);
if (!client) {
pr_err("failed to register pmu to i2c%d\n", busnum);
return -1;
}
i2c_put_adapter(adap);
for (i = 0; i < ARRAY_SIZE(fixed_regulator_devices); i++)
fixed_regulator_devices[i]->id = i;
return platform_add_devices(fixed_regulator_devices,
ARRAY_SIZE(fixed_regulator_devices));
}
示例14: tviu800_init_onboard_video
/*
* tviu800_init_onboard_video
*/
static int __init tviu800_init_onboard_video(void)
{
struct i2c_adapter *adap;
/*
* Use the VFB device for the onboard display
*/
platform_device_register(&tviu800_vfb_device);
platform_device_register(&tviu800_backlight_device);
/* turn on LCD power */
tviu800_lcdpower_data.vgh_gpio = GPIO_RC_24;
platform_device_register(&tviu800_lcdpower_device);
adap = i2c_get_adapter(0);
if (!adap) {
printk(KERN_WARNING "%s: Failed to get i2c adapter\n", __FUNCTION__);
return -ENODEV;
}
printk(KERN_INFO "%s: registering touch screen controller resources\n", __FUNCTION__);
i2c_new_device(adap, &tviu800_touch_i2c_board_info);
i2c_put_adapter(adap);
return 0;
}
示例15: ct36x_ts_init
static int __init ct36x_ts_init(void)
{
struct i2c_adapter *adapter;
struct i2c_client *client;
printk("VTL ct36x TouchScreen driver, <[email protected]>.\n");
printk("Patched by Astralix of crewrktablets.arctablets.com.\n");
// Init Platform data
ct36x_ts.i2c_bus = CT36X_TS_I2C_BUS;
ct36x_ts.i2c_address = CT36X_TS_I2C_ADDRESS;
adapter = i2c_get_adapter(ct36x_ts.i2c_bus);
if ( !adapter ) {
printk("Unable to get i2c adapter on bus %d.\n", ct36x_ts.i2c_bus);
return -ENODEV;
}
client = i2c_new_device(adapter, i2c_board_info);
i2c_put_adapter(adapter);
if (!client) {
printk("Unable to create i2c device on bus %d.\n", ct36x_ts.i2c_bus);
return -ENODEV;
}
ct36x_ts.client = client;
i2c_set_clientdata(client, &ct36x_ts);
return i2c_add_driver(&ct36x_ts_driver);
}