From 51b0ce387b43ba8ed532e6f9f215d891e1899e0a Mon Sep 17 00:00:00 2001 From: Tal Shorer Date: Tue, 16 Aug 2016 19:04:46 +0300 Subject: usb: ulpi: move setting of ulpi->dev parent up in ulpi_register() Once ulpi operations use the parent device directly, this will be needed during the operations used in ulpi_register() itself, so set the parent field before calling any ulpi operations. Acked-by: Heikki Krogerus Signed-off-by: Tal Shorer Signed-off-by: Felipe Balbi --- drivers/usb/common/ulpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/common') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 01c0c0477a9e..d1f419c7cddb 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -156,6 +156,8 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi) { int ret; + ulpi->dev.parent = dev; /* needed early for ops */ + /* Test the interface */ ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); if (ret < 0) @@ -174,7 +176,6 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi) ulpi->id.product = ulpi_read(ulpi, ULPI_PRODUCT_ID_LOW); ulpi->id.product |= ulpi_read(ulpi, ULPI_PRODUCT_ID_HIGH) << 8; - ulpi->dev.parent = dev; ulpi->dev.bus = &ulpi_bus; ulpi->dev.type = &ulpi_dev_type; dev_set_name(&ulpi->dev, "%s.ulpi", dev_name(dev)); -- cgit v1.2.3 From 6691402313ddda232e6a401af8841b5fe676a62f Mon Sep 17 00:00:00 2001 From: Tal Shorer Date: Tue, 16 Aug 2016 19:04:47 +0300 Subject: usb: ulpi: add new api functions, {read|write}_dev() Add these two new api callbacks to struct ulpi_ops. These are different than read, write in that they pass the parent device directly instead of via the ops argument. They are intended to replace the old api functions. If the new api callbacks are missing, revert to calling the old ones as before. Acked-by: Heikki Krogerus Signed-off-by: Tal Shorer Signed-off-by: Felipe Balbi --- drivers/usb/common/ulpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/usb/common') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index d1f419c7cddb..a877ddbbe826 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -21,13 +21,17 @@ int ulpi_read(struct ulpi *ulpi, u8 addr) { - return ulpi->ops->read(ulpi->ops, addr); + if (!ulpi->ops->read_dev) + return ulpi->ops->read(ulpi->ops, addr); + return ulpi->ops->read_dev(ulpi->dev.parent, addr); } EXPORT_SYMBOL_GPL(ulpi_read); int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) { - return ulpi->ops->write(ulpi->ops, addr, val); + if (!ulpi->ops->write_dev) + return ulpi->ops->write(ulpi->ops, addr, val); + return ulpi->ops->write_dev(ulpi->dev.parent, addr, val); } EXPORT_SYMBOL_GPL(ulpi_write); -- cgit v1.2.3 From 5c42f38795645834a7c23998bd74d35a37bff078 Mon Sep 17 00:00:00 2001 From: Tal Shorer Date: Tue, 16 Aug 2016 19:04:49 +0300 Subject: usb: ulpi: remove calls to old api callbacks Now that all users use the new api callbacks, remove the old api callbacks and force new interface drivers to use the new api. Acked-by: Heikki Krogerus Signed-off-by: Tal Shorer Signed-off-by: Felipe Balbi --- drivers/usb/common/ulpi.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/usb/common') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index a877ddbbe826..43142c3d94d7 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -21,16 +21,12 @@ int ulpi_read(struct ulpi *ulpi, u8 addr) { - if (!ulpi->ops->read_dev) - return ulpi->ops->read(ulpi->ops, addr); return ulpi->ops->read_dev(ulpi->dev.parent, addr); } EXPORT_SYMBOL_GPL(ulpi_read); int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) { - if (!ulpi->ops->write_dev) - return ulpi->ops->write(ulpi->ops, addr, val); return ulpi->ops->write_dev(ulpi->dev.parent, addr, val); } EXPORT_SYMBOL_GPL(ulpi_write); -- cgit v1.2.3 From e6f74849784ccf275226d5d3ddfb96c71fa90383 Mon Sep 17 00:00:00 2001 From: Tal Shorer Date: Tue, 16 Aug 2016 19:04:50 +0300 Subject: usb: ulpi: rename operations {read|write}_dev to simply {read|write} With the removal of the old {read|write} operations, we can now safely rename the new api operations {read|write}_dev to use the shorter and clearer names {read|write}, respectively. Acked-by: Heikki Krogerus Signed-off-by: Tal Shorer Signed-off-by: Felipe Balbi --- drivers/usb/common/ulpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/common') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 43142c3d94d7..fdaed7c26c12 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -21,13 +21,13 @@ int ulpi_read(struct ulpi *ulpi, u8 addr) { - return ulpi->ops->read_dev(ulpi->dev.parent, addr); + return ulpi->ops->read(ulpi->dev.parent, addr); } EXPORT_SYMBOL_GPL(ulpi_read); int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) { - return ulpi->ops->write_dev(ulpi->dev.parent, addr, val); + return ulpi->ops->write(ulpi->dev.parent, addr, val); } EXPORT_SYMBOL_GPL(ulpi_write); -- cgit v1.2.3 From 042b0f31b2a87799a9c832f71474c5be3517e139 Mon Sep 17 00:00:00 2001 From: Tal Shorer Date: Tue, 16 Aug 2016 19:04:51 +0300 Subject: usb: ulpi: remove "dev" field from struct ulpi_ops Operations now use ulpi->dev.parent directly instead of via the ulpi_ops struct, making this field unused. Remove it. Acked-by: Heikki Krogerus Signed-off-by: Tal Shorer Signed-off-by: Felipe Balbi --- drivers/usb/common/ulpi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb/common') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index fdaed7c26c12..0439e9638813 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -212,7 +212,6 @@ struct ulpi *ulpi_register_interface(struct device *dev, struct ulpi_ops *ops) return ERR_PTR(-ENOMEM); ulpi->ops = ops; - ops->dev = dev; ret = ulpi_register(dev, ulpi); if (ret) { -- cgit v1.2.3 From b9454f90c9432e1a70389c26c34e972090efcec6 Mon Sep 17 00:00:00 2001 From: Tal Shorer Date: Tue, 16 Aug 2016 19:04:52 +0300 Subject: usb: ulpi: make ops struct constant None of the core ulpi functions perform any changes to the operations struct, and logically as a struct that contains function pointers there's no reason it shouldn't be constant. Acked-by: Heikki Krogerus Signed-off-by: Tal Shorer Signed-off-by: Felipe Balbi --- drivers/usb/common/ulpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/common') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 0439e9638813..d4ff6df859eb 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -202,7 +202,8 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi) * Allocates and registers a ULPI device and an interface for it. Called from * the USB controller that provides the ULPI interface. */ -struct ulpi *ulpi_register_interface(struct device *dev, struct ulpi_ops *ops) +struct ulpi *ulpi_register_interface(struct device *dev, + const struct ulpi_ops *ops) { struct ulpi *ulpi; int ret; -- cgit v1.2.3