cregit-Linux how code gets into the kernel

Release 4.11 drivers/staging/iio/addac/adt7316-i2c.c

/*
 * I2C bus driver for ADT7316/7/8 ADT7516/7/9 digital temperature
 * sensor, ADC and DAC
 *
 * Copyright 2010 Analog Devices Inc.
 *
 * Licensed under the GPL-2 or later.
 */

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/module.h>

#include "adt7316.h"

/*
 * adt7316 register access by I2C
 */

static int adt7316_i2c_read(void *client, u8 reg, u8 *data) { struct i2c_client *cl = client; int ret; ret = i2c_smbus_write_byte(cl, reg); if (ret < 0) { dev_err(&cl->dev, "I2C fail to select reg\n"); return ret; } ret = i2c_smbus_read_byte(client); if (ret < 0) { dev_err(&cl->dev, "I2C read error\n"); return ret; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sonic Zhang88100.00%1100.00%
Total88100.00%1100.00%


static int adt7316_i2c_write(void *client, u8 reg, u8 data) { struct i2c_client *cl = client; int ret = 0; ret = i2c_smbus_write_byte_data(cl, reg, data); if (ret < 0) dev_err(&cl->dev, "I2C write error\n"); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Sonic Zhang58100.00%1100.00%
Total58100.00%1100.00%


static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) { struct i2c_client *cl = client; int i, ret = 0; if (count > ADT7316_REG_MAX_ADDR) count = ADT7316_REG_MAX_ADDR; for (i = 0; i < count; i++) { ret = adt7316_i2c_read(cl, reg, &data[i]); if (ret < 0) { dev_err(&cl->dev, "I2C multi read error\n"); return ret; } } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sonic Zhang98100.00%1100.00%
Total98100.00%1100.00%


static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) { struct i2c_client *cl = client; int i, ret = 0; if (count > ADT7316_REG_MAX_ADDR) count = ADT7316_REG_MAX_ADDR; for (i = 0; i < count; i++) { ret = adt7316_i2c_write(cl, reg, data[i]); if (ret < 0) { dev_err(&cl->dev, "I2C multi write error\n"); return ret; } } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sonic Zhang97100.00%1100.00%
Total97100.00%1100.00%

/* * device probe and remove */
static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adt7316_bus bus = { .client = client, .irq = client->irq, .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(&client->dev, &bus, id->name); }

Contributors

PersonTokensPropCommitsCommitProp
Sonic Zhang76100.00%1100.00%
Total76100.00%1100.00%

static const struct i2c_device_id adt7316_i2c_id[] = { { "adt7316", 0 }, { "adt7317", 0 }, { "adt7318", 0 }, { "adt7516", 0 }, { "adt7517", 0 }, { "adt7519", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", .pm = ADT7316_PM_OPS, }, .probe = adt7316_i2c_probe, .id_table = adt7316_i2c_id, }; module_i2c_driver(adt7316_driver); MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>"); MODULE_DESCRIPTION("I2C bus driver for Analog Devices ADT7316/7/9 and ADT7516/7/8 digital temperature sensor, ADC and DAC"); MODULE_LICENSE("GPL v2");

Overall Contributors

PersonTokensPropCommitsCommitProp
Sonic Zhang53698.53%120.00%
Lars-Peter Clausen40.74%240.00%
Paul Gortmaker30.55%120.00%
Ebru Akagunduz10.18%120.00%
Total544100.00%5100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.