本文整理汇总了C++中i2c_put_adapter函数的典型用法代码示例。如果您正苦于以下问题:C++ i2c_put_adapter函数的具体用法?C++ i2c_put_adapter怎么用?C++ i2c_put_adapter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2c_put_adapter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:gozhev,项目名称:ins,代码行数:57,代码来源:knxjif.c
示例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;
}
开发者ID:patrick-ken,项目名称:MyNet_N900,代码行数:28,代码来源:adv7180.c
示例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;
}
开发者ID:chengdongdong,项目名称:codes,代码行数:33,代码来源:i2c-test.c
示例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;
}
}
开发者ID:iuncuim,项目名称:A476_V1B_5.1_kernel,代码行数:29,代码来源:smsi2c.c
示例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;
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:33,代码来源:board-ip7500iap.c
示例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;
}
开发者ID:josh64x2,项目名称:apc-rock,代码行数:28,代码来源:wmt-vid.c
示例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;
}
开发者ID:TWood67,项目名称:CSE438,代码行数:31,代码来源:i2c_flash.c
示例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;
}
开发者ID:ena30,项目名称:snake-os,代码行数:28,代码来源:i2c-dev.c
示例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;
}
开发者ID:AllenDou,项目名称:linux,代码行数:35,代码来源:fimc-mdevice.c
示例10: minnow_module_exit
static void __exit minnow_module_exit(void)
{
i2c_unregister_device(client);
i2c_put_adapter(adap);
pr_info("exited\n");
}
开发者ID:Rashed97,项目名称:mcp9808,代码行数:7,代码来源:minnow.c
示例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;
}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:29,代码来源:fimc-mdevice.c
示例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);
}
开发者ID:Kernelhacker,项目名称:2.6.38.3-Adam,代码行数:30,代码来源:board-seaboard-sensors.c
示例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));
}
开发者ID:piet-delaney,项目名称:KERNEL-NPM801,代码行数:27,代码来源:zpad80-regulator.c
示例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;
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:32,代码来源:board-tviu800.c
示例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);
}
开发者ID:Root2Technologies,项目名称:rk3x_kernel_3.0.36,代码行数:30,代码来源:ct36x_i2c_ts.c
示例16: xeno_i2c_init
/* Initializing i2c driver from the kernel space */
int xeno_i2c_init(void) {
unsigned int minor = 0;
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;
return 0;
}
开发者ID:ozwin,项目名称:iem-space-invader,代码行数:28,代码来源:xeno-i2c.c
示例17: wm8731_i2c_register
/*
* FIXME: This is a temporary bodge to avoid cross-tree merge issues.
* New drivers should register the wm8731 I2C device in the machine
* setup code (under arch/arm for ARM systems).
*/
static int wm8731_i2c_register(void)
{
struct i2c_board_info info;
struct i2c_adapter *adapter;
struct i2c_client *client;
alsa_dbg("%s() \n", __func__);
memset(&info, 0, sizeof(struct i2c_board_info));
info.addr = 0x1a;
strlcpy(info.type, "wm8731", I2C_NAME_SIZE);
adapter = i2c_get_adapter(0);
if (!adapter)
{
printk(KERN_ERR "can't get i2c adapter 0\n");
return -ENODEV;
}
client = i2c_new_device(adapter, &info);
i2c_put_adapter(adapter);
if (!client)
{
printk(KERN_ERR "can't add i2c device at 0x%x\n", (unsigned int)info.addr);
return -ENODEV;
}
return 0;
}
开发者ID:AmesianX,项目名称:telechips-linux,代码行数:34,代码来源:tcc_board_wm8731.c
示例18: HC548_attach_adapter
int HC548_attach_adapter(void)
{
struct i2c_board_info info;
struct i2c_client *client;
struct i2c_adapter *adapter;
int ret1;
pr_pos_info();
adapter = i2c_get_adapter(I2C_BUS_NUM);
if(adapter == NULL)
{
pr_red_info("HC548 I2C get adapter %d failed\n", I2C_BUS_NUM);
ret1 = -ENODEV;
goto out_exit;
}
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "HC548", I2C_NAME_SIZE);
info.addr = HC548_SLAVE_ADDR;
client = i2c_new_device(adapter, &info);
if(client == NULL)
{
pr_red_info("HC548 I2C new device failed\n");
ret1 = -ENODEV;
goto out_put_adapter;
}
return 0;
out_put_adapter:
i2c_put_adapter(adapter);
out_exit:
return ret1;
}
开发者ID:advx9600,项目名称:kernel-4.4-RuiEr,代码行数:35,代码来源:hc8600.c
示例19: i2c_writes
static int i2c_writes(int id, int addr, char *buf, int bytes)
{
struct i2c_adapter *adap;
struct i2c_msg msg;
int ret;
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.addr = addr;
msg.flags = 0;
msg.len = bytes;
msg.buf = buf;
msg.scl_rate = 100 * 1000;
msg.udelay = 5;
ret = i2c_transfer(adap, &msg, 1);
i2c_put_adapter(adap);
return (ret == 1) ? bytes: ret;
}
开发者ID:chengdongdong,项目名称:codes,代码行数:25,代码来源:i2c-test.c
示例20: sx1_i2c_read_byte
/* Read from I2C device */
int sx1_i2c_read_byte(u8 devaddr, u8 regoffset, u8 *value)
{
struct i2c_adapter *adap;
int err;
struct i2c_msg msg[1];
unsigned char data[2];
adap = i2c_get_adapter(0);
if (!adap)
return -ENODEV;
msg->addr = devaddr; /* I2C address of chip */
msg->flags = 0;
msg->len = 1;
msg->buf = data;
data[0] = regoffset; /* register num */
err = i2c_transfer(adap, msg, 1);
msg->addr = devaddr; /* I2C address */
msg->flags = I2C_M_RD;
msg->len = 1;
msg->buf = data;
err = i2c_transfer(adap, msg, 1);
*value = data[0];
i2c_put_adapter(adap);
if (err >= 0)
return 0;
return err;
}
开发者ID:4atty,项目名称:linux,代码行数:31,代码来源:board-sx1.c
注:本文中的i2c_put_adapter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论