static int cx_remove_device(struct device * dev, void * data) { struct cx_dev *cx_dev = to_cx_dev(dev); device_remove_file(dev, &dev_attr_cxdev_control); cx_device_unregister(cx_dev); return 0; }
static ssize_t store_cxdev_control(struct device *dev, const char *buf, size_t count) { int n; struct cx_dev *cx_dev = to_cx_dev(dev); if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (count <= 0) return 0; n = simple_strtoul(buf, NULL, 0); switch (n) { case 1: tio_corelet_reset(cx_dev->cx_id.nasid, TIOCX_CORELET); tiocx_reload(cx_dev); break; case 2: tiocx_reload(cx_dev); break; case 3: tio_corelet_reset(cx_dev->cx_id.nasid, TIOCX_CORELET); break; default: break; } return count; }
/** * cx_driver_remove - Remove driver from device struct. * @dev: device */ static int cx_driver_remove(struct device *dev) { struct cx_dev *cx_dev = to_cx_dev(dev); struct cx_drv *cx_drv = cx_dev->driver; if (cx_drv->remove) cx_drv->remove(cx_dev); cx_dev->driver = NULL; return 0; }
static ssize_t show_cxdev_control(struct device *dev, char *buf) { struct cx_dev *cx_dev = to_cx_dev(dev); return sprintf(buf, "0x%x 0x%x 0x%x 0x%x\n", cx_dev->cx_id.nasid, cx_dev->cx_id.part_num, cx_dev->cx_id.mfg_num, cx_dev->bt); }
static ssize_t show_cxdev_control(struct device *dev, struct device_attribute *attr, char *buf) { struct cx_dev *cx_dev = to_cx_dev(dev); return sprintf(buf, "0x%x 0x%x 0x%x %d\n", cx_dev->cx_id.nasid, cx_dev->cx_id.part_num, cx_dev->cx_id.mfg_num, tiocx_btchar_get(cx_dev->cx_id.nasid)); }
/** * tiocx_match - Try to match driver id list with device. * @dev: device pointer * @drv: driver pointer * * Returns 1 if match, 0 otherwise. */ static int tiocx_match(struct device *dev, struct device_driver *drv) { struct cx_dev *cx_dev = to_cx_dev(dev); struct cx_drv *cx_drv = to_cx_driver(drv); const struct cx_device_id *ids = cx_drv->id_table; if (!ids) return 0; while (ids->part_num) { if (ids->part_num == cx_dev->cx_id.part_num) return 1; ids++; } return 0; }
/** * cx_device_probe - Look for matching device. * Call driver probe routine if found. * @cx_driver: driver table (cx_drv struct) from driver * @cx_device: part/mfg id for the device */ static int cx_device_probe(struct device *dev) { const struct cx_device_id *id; struct cx_drv *cx_drv = to_cx_driver(dev->driver); struct cx_dev *cx_dev = to_cx_dev(dev); int error = 0; if (!cx_dev->driver && cx_drv->probe) { id = cx_device_match(cx_drv->id_table, cx_dev); if (id) { if ((error = cx_drv->probe(cx_dev, id)) < 0) return error; else cx_dev->driver = cx_drv; } } return error; }
static void tiocx_bus_release(struct device *dev) { kfree(to_cx_dev(dev)); }