Lines Matching refs:mux_chip

67 	struct mux_chip *mux_chip = to_mux_chip(dev);  in mux_chip_release()  local
69 ida_simple_remove(&mux_ida, mux_chip->id); in mux_chip_release()
70 kfree(mux_chip); in mux_chip_release()
94 struct mux_chip *mux_chip_alloc(struct device *dev, in mux_chip_alloc()
97 struct mux_chip *mux_chip; in mux_chip_alloc() local
103 mux_chip = kzalloc(sizeof(*mux_chip) + in mux_chip_alloc()
104 controllers * sizeof(*mux_chip->mux) + in mux_chip_alloc()
106 if (!mux_chip) in mux_chip_alloc()
109 mux_chip->mux = (struct mux_control *)(mux_chip + 1); in mux_chip_alloc()
110 mux_chip->dev.class = &mux_class; in mux_chip_alloc()
111 mux_chip->dev.type = &mux_type; in mux_chip_alloc()
112 mux_chip->dev.parent = dev; in mux_chip_alloc()
113 mux_chip->dev.of_node = dev->of_node; in mux_chip_alloc()
114 dev_set_drvdata(&mux_chip->dev, mux_chip); in mux_chip_alloc()
116 mux_chip->id = ida_simple_get(&mux_ida, 0, 0, GFP_KERNEL); in mux_chip_alloc()
117 if (mux_chip->id < 0) { in mux_chip_alloc()
118 int err = mux_chip->id; in mux_chip_alloc()
121 kfree(mux_chip); in mux_chip_alloc()
124 dev_set_name(&mux_chip->dev, "muxchip%d", mux_chip->id); in mux_chip_alloc()
126 mux_chip->controllers = controllers; in mux_chip_alloc()
128 struct mux_control *mux = &mux_chip->mux[i]; in mux_chip_alloc()
130 mux->chip = mux_chip; in mux_chip_alloc()
137 device_initialize(&mux_chip->dev); in mux_chip_alloc()
139 return mux_chip; in mux_chip_alloc()
165 int mux_chip_register(struct mux_chip *mux_chip) in mux_chip_register() argument
170 for (i = 0; i < mux_chip->controllers; ++i) { in mux_chip_register()
171 struct mux_control *mux = &mux_chip->mux[i]; in mux_chip_register()
178 dev_err(&mux_chip->dev, "unable to set idle state\n"); in mux_chip_register()
183 ret = device_add(&mux_chip->dev); in mux_chip_register()
185 dev_err(&mux_chip->dev, in mux_chip_register()
199 void mux_chip_unregister(struct mux_chip *mux_chip) in mux_chip_unregister() argument
201 device_del(&mux_chip->dev); in mux_chip_unregister()
211 void mux_chip_free(struct mux_chip *mux_chip) in mux_chip_free() argument
213 if (!mux_chip) in mux_chip_free()
216 put_device(&mux_chip->dev); in mux_chip_free()
222 struct mux_chip *mux_chip = *(struct mux_chip **)res; in devm_mux_chip_release() local
224 mux_chip_free(mux_chip); in devm_mux_chip_release()
237 struct mux_chip *devm_mux_chip_alloc(struct device *dev, in devm_mux_chip_alloc()
241 struct mux_chip **ptr, *mux_chip; in devm_mux_chip_alloc() local
247 mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv); in devm_mux_chip_alloc()
248 if (IS_ERR(mux_chip)) { in devm_mux_chip_alloc()
250 return mux_chip; in devm_mux_chip_alloc()
253 *ptr = mux_chip; in devm_mux_chip_alloc()
256 return mux_chip; in devm_mux_chip_alloc()
262 struct mux_chip *mux_chip = *(struct mux_chip **)res; in devm_mux_chip_reg_release() local
264 mux_chip_unregister(mux_chip); in devm_mux_chip_reg_release()
277 struct mux_chip *mux_chip) in devm_mux_chip_register() argument
279 struct mux_chip **ptr; in devm_mux_chip_register()
286 res = mux_chip_register(mux_chip); in devm_mux_chip_register()
292 *ptr = mux_chip; in devm_mux_chip_register()
513 static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) in of_find_mux_chip_by_node()
536 struct mux_chip *mux_chip; in mux_get() local
569 mux_chip = of_find_mux_chip_by_node(args.np); in mux_get()
571 if (!mux_chip) in mux_get()
577 (args.args_count < 2 && mux_chip->controllers > 1)) { in mux_get()
580 put_device(&mux_chip->dev); in mux_get()
593 (!args.args_count && mux_chip->controllers > 1)) { in mux_get()
596 put_device(&mux_chip->dev); in mux_get()
604 if (controller >= mux_chip->controllers) { in mux_get()
607 put_device(&mux_chip->dev); in mux_get()
611 return &mux_chip->mux[controller]; in mux_get()