/* * drivers/w1/slaves/w1_bq27000.c * * Copyright (C) 2007 Texas Instruments, Inc. * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any * kind, whether express or implied. * */ #include #include #include #include #include #include #include #include "../w1.h" #include "../w1_int.h" #include "../w1_family.h" #define HDQ_CMD_READ (0) #define HDQ_CMD_WRITE (1<<7) static int F_ID; static int w1_bq27000_read(struct device *dev, unsigned int reg) { u8 val; struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev); mutex_lock(&sl->master->bus_mutex); w1_write_8(sl->master, HDQ_CMD_READ | reg); val = w1_read_8(sl->master); mutex_unlock(&sl->master->bus_mutex); return val; } static struct bq27xxx_platform_data bq27000_battery_info = { .read = w1_bq27000_read, .name = "bq27000-battery", .chip = BQ27000, }; static int w1_bq27000_add_slave(struct w1_slave *sl) { int ret; struct platform_device *pdev; pdev = platform_device_alloc("bq27000-battery", -1); if (!pdev) { ret = -ENOMEM; return ret; } ret = platform_device_add_data(pdev, &bq27000_battery_info, sizeof(bq27000_battery_info)); if (ret) goto pdev_add_failed; pdev->dev.parent = &sl->dev; ret = platform_device_add(pdev); if (ret) goto pdev_add_failed; dev_set_drvdata(&sl->dev, pdev); goto success; pdev_add_failed: platform_device_put(pdev); success: return ret; } static void w1_bq27000_remove_slave(struct w1_slave *sl) { struct platform_device *pdev = dev_get_drvdata(&sl->dev); platform_device_unregister(pdev); } static struct w1_family_ops w1_bq27000_fops = { .add_slave = w1_bq27000_add_slave, .remove_slave = w1_bq27000_remove_slave, }; static struct w1_family w1_bq27000_family = { .fid = W1_FAMILY_BQ27000, .fops = &w1_bq27000_fops, }; static int __init w1_bq27000_init(void) { if (F_ID) w1_bq27000_family.fid = F_ID; return w1_register_family(&w1_bq27000_family); } static void __exit w1_bq27000_exit(void) { w1_unregister_family(&w1_bq27000_family); } module_init(w1_bq27000_init); module_exit(w1_bq27000_exit); module_param(F_ID, int, S_IRUSR); MODULE_PARM_DESC(F_ID, "1-wire slave FID for BQ device"); MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_BQ27000)); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Texas Instruments Ltd"); MODULE_DESCRIPTION("HDQ/1-wire slave driver bq27000 battery monitor chip"); hor
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-30 15:47:19 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-30 15:47:19 -0800
commitf9a42e0d58cf0fe3d902e63d4582f2ea4cd2bb8b (patch)
tree4078d3ae27d4ebb85bdcd4d84e9b9a4d059f22bb /net/sctp/output.c
parent751321b3dd5040dc5be19bd23f985e80c914621a (diff)
parent54791b276b4000b307339f269d3bf7db877d536f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Pull sparc fixes from David Miller: "Several small bug fixes and tidies, along with a fix for non-resumable memory errors triggered by userspace" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: sparc64: Handle PIO & MEM non-resumable errors. sparc64: Zero pages on allocation for mondo and error queues. sparc: Fixed typo in sstate.c. Replaced panicing with panicking sparc: use symbolic names for tsb indexing
Diffstat (limited to 'net/sctp/output.c')