Lines Matching refs:mux_chip
65 struct mux_chip *mux_chip = to_mux_chip(dev); in mux_chip_release() local
67 ida_simple_remove(&mux_ida, mux_chip->id); in mux_chip_release()
68 kfree(mux_chip); in mux_chip_release()
92 struct mux_chip *mux_chip_alloc(struct device *dev, in mux_chip_alloc()
95 struct mux_chip *mux_chip; in mux_chip_alloc() local
101 mux_chip = kzalloc(sizeof(*mux_chip) + in mux_chip_alloc()
102 controllers * sizeof(*mux_chip->mux) + in mux_chip_alloc()
104 if (!mux_chip) in mux_chip_alloc()
107 mux_chip->mux = (struct mux_control *)(mux_chip + 1); in mux_chip_alloc()
108 mux_chip->dev.class = &mux_class; in mux_chip_alloc()
109 mux_chip->dev.type = &mux_type; in mux_chip_alloc()
110 mux_chip->dev.parent = dev; in mux_chip_alloc()
111 mux_chip->dev.of_node = dev->of_node; in mux_chip_alloc()
112 dev_set_drvdata(&mux_chip->dev, mux_chip); in mux_chip_alloc()
114 mux_chip->id = ida_simple_get(&mux_ida, 0, 0, GFP_KERNEL); in mux_chip_alloc()
115 if (mux_chip->id < 0) { in mux_chip_alloc()
116 int err = mux_chip->id; in mux_chip_alloc()
119 kfree(mux_chip); in mux_chip_alloc()
122 dev_set_name(&mux_chip->dev, "muxchip%d", mux_chip->id); in mux_chip_alloc()
124 mux_chip->controllers = controllers; in mux_chip_alloc()
126 struct mux_control *mux = &mux_chip->mux[i]; in mux_chip_alloc()
128 mux->chip = mux_chip; in mux_chip_alloc()
135 device_initialize(&mux_chip->dev); in mux_chip_alloc()
137 return mux_chip; in mux_chip_alloc()
163 int mux_chip_register(struct mux_chip *mux_chip) in mux_chip_register() argument
168 for (i = 0; i < mux_chip->controllers; ++i) { in mux_chip_register()
169 struct mux_control *mux = &mux_chip->mux[i]; in mux_chip_register()
176 dev_err(&mux_chip->dev, "unable to set idle state\n"); in mux_chip_register()
181 ret = device_add(&mux_chip->dev); in mux_chip_register()
183 dev_err(&mux_chip->dev, in mux_chip_register()
197 void mux_chip_unregister(struct mux_chip *mux_chip) in mux_chip_unregister() argument
199 device_del(&mux_chip->dev); in mux_chip_unregister()
209 void mux_chip_free(struct mux_chip *mux_chip) in mux_chip_free() argument
211 if (!mux_chip) in mux_chip_free()
214 put_device(&mux_chip->dev); in mux_chip_free()
220 struct mux_chip *mux_chip = *(struct mux_chip **)res; in devm_mux_chip_release() local
222 mux_chip_free(mux_chip); in devm_mux_chip_release()
235 struct mux_chip *devm_mux_chip_alloc(struct device *dev, in devm_mux_chip_alloc()
239 struct mux_chip **ptr, *mux_chip; in devm_mux_chip_alloc() local
245 mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv); in devm_mux_chip_alloc()
246 if (IS_ERR(mux_chip)) { in devm_mux_chip_alloc()
248 return mux_chip; in devm_mux_chip_alloc()
251 *ptr = mux_chip; in devm_mux_chip_alloc()
254 return mux_chip; in devm_mux_chip_alloc()
260 struct mux_chip *mux_chip = *(struct mux_chip **)res; in devm_mux_chip_reg_release() local
262 mux_chip_unregister(mux_chip); in devm_mux_chip_reg_release()
275 struct mux_chip *mux_chip) in devm_mux_chip_register() argument
277 struct mux_chip **ptr; in devm_mux_chip_register()
284 res = mux_chip_register(mux_chip); in devm_mux_chip_register()
290 *ptr = mux_chip; in devm_mux_chip_register()
511 static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) in of_find_mux_chip_by_node()
534 struct mux_chip *mux_chip; in mux_get() local
567 mux_chip = of_find_mux_chip_by_node(args.np); in mux_get()
569 if (!mux_chip) in mux_get()
575 (args.args_count < 2 && mux_chip->controllers > 1)) { in mux_get()
578 put_device(&mux_chip->dev); in mux_get()
591 (!args.args_count && mux_chip->controllers > 1)) { in mux_get()
594 put_device(&mux_chip->dev); in mux_get()
602 if (controller >= mux_chip->controllers) { in mux_get()
605 put_device(&mux_chip->dev); in mux_get()
609 return &mux_chip->mux[controller]; in mux_get()