| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Samsung SATA SerDes(PHY) driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Samsung Electronics Co., Ltd. |
|---|
| 5 | 6 | * Authors: Girish K S <ks.giri@samsung.com> |
|---|
| 6 | 7 | * Yuvaraj Kumar C D <yuvaraj.cd@samsung.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | |
|---|
| 13 | 10 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 193 | 190 | return -EINVAL; |
|---|
| 194 | 191 | |
|---|
| 195 | 192 | sata_phy->client = of_find_i2c_device_by_node(node); |
|---|
| 193 | + of_node_put(node); |
|---|
| 196 | 194 | if (!sata_phy->client) |
|---|
| 197 | 195 | return -EPROBE_DEFER; |
|---|
| 198 | 196 | |
|---|
| .. | .. |
|---|
| 201 | 199 | sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl"); |
|---|
| 202 | 200 | if (IS_ERR(sata_phy->phyclk)) { |
|---|
| 203 | 201 | dev_err(dev, "failed to get clk for PHY\n"); |
|---|
| 204 | | - return PTR_ERR(sata_phy->phyclk); |
|---|
| 202 | + ret = PTR_ERR(sata_phy->phyclk); |
|---|
| 203 | + goto put_dev; |
|---|
| 205 | 204 | } |
|---|
| 206 | 205 | |
|---|
| 207 | 206 | ret = clk_prepare_enable(sata_phy->phyclk); |
|---|
| 208 | 207 | if (ret < 0) { |
|---|
| 209 | 208 | dev_err(dev, "failed to enable source clk\n"); |
|---|
| 210 | | - return ret; |
|---|
| 209 | + goto put_dev; |
|---|
| 211 | 210 | } |
|---|
| 212 | 211 | |
|---|
| 213 | 212 | sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops); |
|---|
| 214 | 213 | if (IS_ERR(sata_phy->phy)) { |
|---|
| 215 | | - clk_disable_unprepare(sata_phy->phyclk); |
|---|
| 216 | 214 | dev_err(dev, "failed to create PHY\n"); |
|---|
| 217 | | - return PTR_ERR(sata_phy->phy); |
|---|
| 215 | + ret = PTR_ERR(sata_phy->phy); |
|---|
| 216 | + goto clk_disable; |
|---|
| 218 | 217 | } |
|---|
| 219 | 218 | |
|---|
| 220 | 219 | phy_set_drvdata(sata_phy->phy, sata_phy); |
|---|
| .. | .. |
|---|
| 222 | 221 | phy_provider = devm_of_phy_provider_register(dev, |
|---|
| 223 | 222 | of_phy_simple_xlate); |
|---|
| 224 | 223 | if (IS_ERR(phy_provider)) { |
|---|
| 225 | | - clk_disable_unprepare(sata_phy->phyclk); |
|---|
| 226 | | - return PTR_ERR(phy_provider); |
|---|
| 224 | + ret = PTR_ERR(phy_provider); |
|---|
| 225 | + goto clk_disable; |
|---|
| 227 | 226 | } |
|---|
| 228 | 227 | |
|---|
| 229 | 228 | return 0; |
|---|
| 229 | + |
|---|
| 230 | +clk_disable: |
|---|
| 231 | + clk_disable_unprepare(sata_phy->phyclk); |
|---|
| 232 | +put_dev: |
|---|
| 233 | + put_device(&sata_phy->client->dev); |
|---|
| 234 | + |
|---|
| 235 | + return ret; |
|---|
| 230 | 236 | } |
|---|
| 231 | 237 | |
|---|
| 232 | 238 | static const struct of_device_id exynos_sata_phy_of_match[] = { |
|---|
| .. | .. |
|---|
| 240 | 246 | .driver = { |
|---|
| 241 | 247 | .of_match_table = exynos_sata_phy_of_match, |
|---|
| 242 | 248 | .name = "samsung,sata-phy", |
|---|
| 249 | + .suppress_bind_attrs = true, |
|---|
| 243 | 250 | } |
|---|
| 244 | 251 | }; |
|---|
| 245 | 252 | module_platform_driver(exynos_sata_phy_driver); |
|---|