Lines Matching refs:mux_chip
52 struct mux_chip *mux_chip = to_mux_chip(dev); in mux_chip_release() local
54 ida_simple_remove(&mux_ida, mux_chip->id); in mux_chip_release()
55 kfree(mux_chip); in mux_chip_release()
79 struct mux_chip *mux_chip_alloc(struct device *dev, in mux_chip_alloc()
82 struct mux_chip *mux_chip; in mux_chip_alloc() local
88 mux_chip = kzalloc(sizeof(*mux_chip) + in mux_chip_alloc()
89 controllers * sizeof(*mux_chip->mux) + in mux_chip_alloc()
91 if (!mux_chip) in mux_chip_alloc()
94 mux_chip->mux = (struct mux_control *)(mux_chip + 1); in mux_chip_alloc()
95 mux_chip->dev.class = &mux_class; in mux_chip_alloc()
96 mux_chip->dev.type = &mux_type; in mux_chip_alloc()
97 mux_chip->dev.parent = dev; in mux_chip_alloc()
98 mux_chip->dev.of_node = dev->of_node; in mux_chip_alloc()
99 dev_set_drvdata(&mux_chip->dev, mux_chip); in mux_chip_alloc()
101 mux_chip->id = ida_simple_get(&mux_ida, 0, 0, GFP_KERNEL); in mux_chip_alloc()
102 if (mux_chip->id < 0) { in mux_chip_alloc()
103 int err = mux_chip->id; in mux_chip_alloc()
106 kfree(mux_chip); in mux_chip_alloc()
109 dev_set_name(&mux_chip->dev, "muxchip%d", mux_chip->id); in mux_chip_alloc()
111 mux_chip->controllers = controllers; in mux_chip_alloc()
113 struct mux_control *mux = &mux_chip->mux[i]; in mux_chip_alloc()
115 mux->chip = mux_chip; in mux_chip_alloc()
121 device_initialize(&mux_chip->dev); in mux_chip_alloc()
123 return mux_chip; in mux_chip_alloc()
147 int mux_chip_register(struct mux_chip *mux_chip) in mux_chip_register() argument
152 for (i = 0; i < mux_chip->controllers; ++i) { in mux_chip_register()
153 struct mux_control *mux = &mux_chip->mux[i]; in mux_chip_register()
160 dev_err(&mux_chip->dev, "unable to set idle state\n"); in mux_chip_register()
165 ret = device_add(&mux_chip->dev); in mux_chip_register()
167 dev_err(&mux_chip->dev, in mux_chip_register()
181 void mux_chip_unregister(struct mux_chip *mux_chip) in mux_chip_unregister() argument
183 device_del(&mux_chip->dev); in mux_chip_unregister()
193 void mux_chip_free(struct mux_chip *mux_chip) in mux_chip_free() argument
195 if (!mux_chip) in mux_chip_free()
198 put_device(&mux_chip->dev); in mux_chip_free()
204 struct mux_chip *mux_chip = *(struct mux_chip **)res; in devm_mux_chip_release() local
206 mux_chip_free(mux_chip); in devm_mux_chip_release()
219 struct mux_chip *devm_mux_chip_alloc(struct device *dev, in devm_mux_chip_alloc()
223 struct mux_chip **ptr, *mux_chip; in devm_mux_chip_alloc() local
229 mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv); in devm_mux_chip_alloc()
230 if (IS_ERR(mux_chip)) { in devm_mux_chip_alloc()
232 return mux_chip; in devm_mux_chip_alloc()
235 *ptr = mux_chip; in devm_mux_chip_alloc()
238 return mux_chip; in devm_mux_chip_alloc()
244 struct mux_chip *mux_chip = *(struct mux_chip **)res; in devm_mux_chip_reg_release() local
246 mux_chip_unregister(mux_chip); in devm_mux_chip_reg_release()
259 struct mux_chip *mux_chip) in devm_mux_chip_register() argument
261 struct mux_chip **ptr; in devm_mux_chip_register()
268 res = mux_chip_register(mux_chip); in devm_mux_chip_register()
274 *ptr = mux_chip; in devm_mux_chip_register()
409 static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) in of_find_mux_chip_by_node()
429 struct mux_chip *mux_chip; in mux_control_get() local
453 mux_chip = of_find_mux_chip_by_node(args.np); in mux_control_get()
455 if (!mux_chip) in mux_control_get()
459 (!args.args_count && (mux_chip->controllers > 1))) { in mux_control_get()
462 put_device(&mux_chip->dev); in mux_control_get()
470 if (controller >= mux_chip->controllers) { in mux_control_get()
473 put_device(&mux_chip->dev); in mux_control_get()
477 return &mux_chip->mux[controller]; in mux_control_get()