Skip to content

Commit 03db178

Browse files
andy-shevvinodkoul
authored andcommitted
phy: ti: tusb1210: Use temporary variable for struct device
Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240209160334.2304230-2-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 553be28 commit 03db178

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

drivers/phy/ti/phy-tusb1210.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum tusb1210_chg_det_state {
5252
};
5353

5454
struct tusb1210 {
55-
struct ulpi *ulpi;
55+
struct device *dev;
5656
struct phy *phy;
5757
struct gpio_desc *gpio_reset;
5858
struct gpio_desc *gpio_cs;
@@ -71,26 +71,27 @@ struct tusb1210 {
7171

7272
static int tusb1210_ulpi_write(struct tusb1210 *tusb, u8 reg, u8 val)
7373
{
74+
struct device *dev = tusb->dev;
7475
int ret;
7576

76-
ret = ulpi_write(tusb->ulpi, reg, val);
77+
ret = ulpi_write(to_ulpi_dev(dev), reg, val);
7778
if (ret)
78-
dev_err(&tusb->ulpi->dev, "error %d writing val 0x%02x to reg 0x%02x\n",
79-
ret, val, reg);
79+
dev_err(dev, "error %d writing val 0x%02x to reg 0x%02x\n", ret, val, reg);
8080

8181
return ret;
8282
}
8383

8484
static int tusb1210_ulpi_read(struct tusb1210 *tusb, u8 reg, u8 *val)
8585
{
86+
struct device *dev = tusb->dev;
8687
int ret;
8788

88-
ret = ulpi_read(tusb->ulpi, reg);
89+
ret = ulpi_read(to_ulpi_dev(dev), reg);
8990
if (ret >= 0) {
9091
*val = ret;
9192
ret = 0;
9293
} else {
93-
dev_err(&tusb->ulpi->dev, "error %d reading reg 0x%02x\n", ret, reg);
94+
dev_err(dev, "error %d reading reg 0x%02x\n", ret, reg);
9495
}
9596

9697
return ret;
@@ -178,7 +179,7 @@ static void tusb1210_reset(struct tusb1210 *tusb)
178179
static void tusb1210_chg_det_set_type(struct tusb1210 *tusb,
179180
enum power_supply_usb_type type)
180181
{
181-
dev_dbg(&tusb->ulpi->dev, "charger type: %d\n", type);
182+
dev_dbg(tusb->dev, "charger type: %d\n", type);
182183
tusb->chg_type = type;
183184
tusb->chg_det_retries = 0;
184185
power_supply_changed(tusb->psy);
@@ -189,7 +190,7 @@ static void tusb1210_chg_det_set_state(struct tusb1210 *tusb,
189190
int delay_ms)
190191
{
191192
if (delay_ms)
192-
dev_dbg(&tusb->ulpi->dev, "chg_det new state %s in %d ms\n",
193+
dev_dbg(tusb->dev, "chg_det new state %s in %d ms\n",
193194
tusb1210_chg_det_states[new_state], delay_ms);
194195

195196
tusb->chg_det_state = new_state;
@@ -253,17 +254,17 @@ static void tusb1210_chg_det_work(struct work_struct *work)
253254
int ret;
254255
u8 val;
255256

256-
dev_dbg(&tusb->ulpi->dev, "chg_det state %s vbus_present %d\n",
257+
dev_dbg(tusb->dev, "chg_det state %s vbus_present %d\n",
257258
tusb1210_chg_det_states[tusb->chg_det_state], vbus_present);
258259

259260
switch (tusb->chg_det_state) {
260261
case TUSB1210_CHG_DET_CONNECTING:
261262
tusb->chg_type = POWER_SUPPLY_USB_TYPE_UNKNOWN;
262263
tusb->chg_det_retries = 0;
263264
/* Power on USB controller for ulpi_read()/_write() */
264-
ret = pm_runtime_resume_and_get(tusb->ulpi->dev.parent);
265+
ret = pm_runtime_resume_and_get(tusb->dev->parent);
265266
if (ret < 0) {
266-
dev_err(&tusb->ulpi->dev, "error %d runtime-resuming\n", ret);
267+
dev_err(tusb->dev, "error %d runtime-resuming\n", ret);
267268
/* Should never happen, skip charger detection */
268269
tusb1210_chg_det_set_state(tusb, TUSB1210_CHG_DET_CONNECTED, 0);
269270
return;
@@ -332,7 +333,7 @@ static void tusb1210_chg_det_work(struct work_struct *work)
332333

333334
mutex_unlock(&tusb->phy->mutex);
334335

335-
pm_runtime_put(tusb->ulpi->dev.parent);
336+
pm_runtime_put(tusb->dev->parent);
336337
tusb1210_chg_det_set_state(tusb, TUSB1210_CHG_DET_CONNECTED, 0);
337338
break;
338339
case TUSB1210_CHG_DET_CONNECTED:
@@ -428,13 +429,14 @@ static const struct power_supply_desc tusb1210_psy_desc = {
428429
static void tusb1210_probe_charger_detect(struct tusb1210 *tusb)
429430
{
430431
struct power_supply_config psy_cfg = { .drv_data = tusb };
431-
struct device *dev = &tusb->ulpi->dev;
432+
struct device *dev = tusb->dev;
433+
struct ulpi *ulpi = to_ulpi_dev(dev);
432434
int ret;
433435

434436
if (!device_property_read_bool(dev->parent, "linux,phy_charger_detect"))
435437
return;
436438

437-
if (tusb->ulpi->id.product != 0x1508) {
439+
if (ulpi->id.product != 0x1508) {
438440
dev_err(dev, "error charger detection is only supported on the TUSB1211\n");
439441
return;
440442
}
@@ -485,25 +487,24 @@ static const struct phy_ops phy_ops = {
485487

486488
static int tusb1210_probe(struct ulpi *ulpi)
487489
{
490+
struct device *dev = &ulpi->dev;
488491
struct tusb1210 *tusb;
489492
u8 val, reg;
490493
int ret;
491494

492-
tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL);
495+
tusb = devm_kzalloc(dev, sizeof(*tusb), GFP_KERNEL);
493496
if (!tusb)
494497
return -ENOMEM;
495498

496-
tusb->ulpi = ulpi;
499+
tusb->dev = dev;
497500

498-
tusb->gpio_reset = devm_gpiod_get_optional(&ulpi->dev, "reset",
499-
GPIOD_OUT_LOW);
501+
tusb->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
500502
if (IS_ERR(tusb->gpio_reset))
501503
return PTR_ERR(tusb->gpio_reset);
502504

503505
gpiod_set_value_cansleep(tusb->gpio_reset, 1);
504506

505-
tusb->gpio_cs = devm_gpiod_get_optional(&ulpi->dev, "cs",
506-
GPIOD_OUT_LOW);
507+
tusb->gpio_cs = devm_gpiod_get_optional(dev, "cs", GPIOD_OUT_LOW);
507508
if (IS_ERR(tusb->gpio_cs))
508509
return PTR_ERR(tusb->gpio_cs);
509510

@@ -519,15 +520,15 @@ static int tusb1210_probe(struct ulpi *ulpi)
519520
return ret;
520521

521522
/* High speed output drive strength configuration */
522-
if (!device_property_read_u8(&ulpi->dev, "ihstx", &val))
523+
if (!device_property_read_u8(dev, "ihstx", &val))
523524
u8p_replace_bits(&reg, val, (u8)TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK);
524525

525526
/* High speed output impedance configuration */
526-
if (!device_property_read_u8(&ulpi->dev, "zhsdrv", &val))
527+
if (!device_property_read_u8(dev, "zhsdrv", &val))
527528
u8p_replace_bits(&reg, val, (u8)TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK);
528529

529530
/* DP/DM swap control */
530-
if (!device_property_read_u8(&ulpi->dev, "datapolarity", &val))
531+
if (!device_property_read_u8(dev, "datapolarity", &val))
531532
u8p_replace_bits(&reg, val, (u8)TUSB1210_VENDOR_SPECIFIC2_DP_MASK);
532533

533534
ret = tusb1210_ulpi_write(tusb, TUSB1210_VENDOR_SPECIFIC2, reg);

0 commit comments

Comments
 (0)