Lines Matching defs:mux_chip

65 	struct mux_chip *mux_chip = to_mux_chip(dev);
67 ida_free(&mux_ida, mux_chip->id);
68 kfree(mux_chip);
84 * the number of valid mux states in the mux_chip->mux[N].states members and
85 * the desired idle state in the returned mux_chip->mux[N].idle_state members.
87 * provide a pointer to the operations struct in the mux_chip->ops member
92 struct mux_chip *mux_chip_alloc(struct device *dev,
95 struct mux_chip *mux_chip;
101 mux_chip = kzalloc(sizeof(*mux_chip) +
102 controllers * sizeof(*mux_chip->mux) +
104 if (!mux_chip)
107 mux_chip->mux = (struct mux_control *)(mux_chip + 1);
108 mux_chip->dev.class = &mux_class;
109 mux_chip->dev.type = &mux_type;
110 mux_chip->dev.parent = dev;
111 mux_chip->dev.of_node = dev->of_node;
112 dev_set_drvdata(&mux_chip->dev, mux_chip);
114 mux_chip->id = ida_alloc(&mux_ida, GFP_KERNEL);
115 if (mux_chip->id < 0) {
116 int err = mux_chip->id;
119 kfree(mux_chip);
122 dev_set_name(&mux_chip->dev, "muxchip%d", mux_chip->id);
124 mux_chip->controllers = controllers;
126 struct mux_control *mux = &mux_chip->mux[i];
128 mux->chip = mux_chip;
135 device_initialize(&mux_chip->dev);
137 return mux_chip;
155 * @mux_chip: The mux-chip to register.
163 int mux_chip_register(struct mux_chip *mux_chip)
168 for (i = 0; i < mux_chip->controllers; ++i) {
169 struct mux_control *mux = &mux_chip->mux[i];
176 dev_err(&mux_chip->dev, "unable to set idle state\n");
181 ret = device_add(&mux_chip->dev);
183 dev_err(&mux_chip->dev,
191 * @mux_chip: The mux-chip to unregister.
197 void mux_chip_unregister(struct mux_chip *mux_chip)
199 device_del(&mux_chip->dev);
205 * @mux_chip: The mux-chip to free.
209 void mux_chip_free(struct mux_chip *mux_chip)
211 if (!mux_chip)
214 put_device(&mux_chip->dev);
220 struct mux_chip *mux_chip = *(struct mux_chip **)res;
222 mux_chip_free(mux_chip);
235 struct mux_chip *devm_mux_chip_alloc(struct device *dev,
239 struct mux_chip **ptr, *mux_chip;
245 mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv);
246 if (IS_ERR(mux_chip)) {
248 return mux_chip;
251 *ptr = mux_chip;
254 return mux_chip;
260 struct mux_chip *mux_chip = *(struct mux_chip **)res;
262 mux_chip_unregister(mux_chip);
268 * @mux_chip: The mux-chip to register.
275 struct mux_chip *mux_chip)
277 struct mux_chip **ptr;
284 res = mux_chip_register(mux_chip);
290 *ptr = mux_chip;
510 /* Note this function returns a reference to the mux_chip dev. */
511 static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np)
534 struct mux_chip *mux_chip;
567 mux_chip = of_find_mux_chip_by_node(args.np);
569 if (!mux_chip)
575 (args.args_count < 2 && mux_chip->controllers > 1)) {
578 put_device(&mux_chip->dev);
591 (!args.args_count && mux_chip->controllers > 1)) {
594 put_device(&mux_chip->dev);
602 if (controller >= mux_chip->controllers) {
605 put_device(&mux_chip->dev);
609 return &mux_chip->mux[controller];