| 146 | } |
| 147 | |
| 148 | static rt_err_t gpio_led_probe(struct rt_platform_device *pdev) |
| 149 | { |
| 150 | rt_bool_t pinctrl_apply = RT_FALSE; |
| 151 | struct rt_ofw_node *led_np, *np = pdev->parent.ofw_node; |
| 152 | |
| 153 | if (rt_ofw_prop_read_bool(np, "pinctrl-0")) |
| 154 | { |
| 155 | pinctrl_apply = RT_TRUE; |
| 156 | rt_pin_ctrl_confs_apply_by_name(&pdev->parent, RT_NULL); |
| 157 | } |
| 158 | |
| 159 | rt_ofw_foreach_available_child_node(np, led_np) |
| 160 | { |
| 161 | rt_err_t err = ofw_append_gpio_led(led_np); |
| 162 | |
| 163 | if (err == -RT_ENOMEM) |
| 164 | { |
| 165 | rt_ofw_node_put(led_np); |
| 166 | |
| 167 | return err; |
| 168 | } |
| 169 | else if (err) |
| 170 | { |
| 171 | LOG_E("%s: create LED fail", rt_ofw_node_full_name(led_np)); |
| 172 | continue; |
| 173 | } |
| 174 | |
| 175 | if (!pinctrl_apply) |
| 176 | { |
| 177 | struct rt_device dev_tmp; |
| 178 | |
| 179 | dev_tmp.ofw_node = led_np; |
| 180 | rt_pin_ctrl_confs_apply_by_name(&dev_tmp, RT_NULL); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return RT_EOK; |
| 185 | } |
| 186 | |
| 187 | static rt_err_t gpio_led_remove(struct rt_platform_device *pdev) |
| 188 | { |
nothing calls this directly
no test coverage detected