Skip to contentSkip to conversation

iio: magn: ak8975: fix unnecessary casting between char* and const char*

PATCH Superseded Irina Tirdea 2 participants 2 messages Sep 2, 2014 – Sep 6, 2014 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: magn: ak8975: fix unnecessary casting between char* and const char*

Use const char* instead of casting const char* to char*.

---
 drivers/iio/magnetometer/ak8975.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/magnetometer/ak8975.c +4 -4
index a235792..61edc66 100644
@@ -477,7 +477,7 @@ static const struct acpi_device_id ak_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
 
-static char *ak8975_match_acpi_device(struct device *dev,
+static const char *ak8975_match_acpi_device(struct device *dev,
 				enum asahi_compass_chipset *chipset)
 {
 	const struct acpi_device_id *id;
@@ -487,7 +487,7 @@ static char *ak8975_match_acpi_device(struct device *dev,
 		return NULL;
 	*chipset = (int)id->driver_data;
 
-	return (char *)dev_name(dev);
+	return dev_name(dev);
 }
 
 static int ak8975_probe(struct i2c_client *client,
@@ -497,7 +497,7 @@ static int ak8975_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	int eoc_gpio;
 	int err;
-	char *name = NULL;
+	const char *name = NULL;
 
 	/* Grab and set up the supplied GPIO. */
 	if (client->dev.platform_data)
@@ -539,7 +539,7 @@ static int ak8975_probe(struct i2c_client *client,
 	if (id) {
 		data->chipset =
 			(enum asahi_compass_chipset)(id->driver_data);
-		name = (char *) id->name;
+		name = id->name;
 	} else if (ACPI_HANDLE(&client->dev))
 		name = ak8975_match_acpi_device(&client->dev, &data->chipset);
 	else
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 12 lines · Irina Tirdea

Use const char* instead of casting const char* to char*.

---
 drivers/iio/magnetometer/ak8975.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/magnetometer/ak8975.c +0 -0
index a235792..61edc66 100644

drivers/iio/magnetometer/ak8975.c static const struct acpi_device_id ak_acpi_match[] = { · line 481

Quoted 6 lines
drivers/iio/magnetometer/ak8975.c +1 -1
@@ -477,7 +477,7 @@ static const struct acpi_device_id ak_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
 
-static char *ak8975_match_acpi_device(struct device *dev,
+static const char *ak8975_match_acpi_device(struct device *dev,
 				enum asahi_compass_chipset *chipset)

This second line should also be indented properly, it will exactly fit 80 characters.

Quoted 29 lines
drivers/iio/magnetometer/ak8975.c +3 -3
 {
 	const struct acpi_device_id *id;
@@ -487,7 +487,7 @@ static char *ak8975_match_acpi_device(struct device *dev,
 		return NULL;
 	*chipset = (int)id->driver_data;
 
-	return (char *)dev_name(dev);
+	return dev_name(dev);
 }
 
 static int ak8975_probe(struct i2c_client *client,
@@ -497,7 +497,7 @@ static int ak8975_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	int eoc_gpio;
 	int err;
-	char *name = NULL;
+	const char *name = NULL;
 
 	/* Grab and set up the supplied GPIO. */
 	if (client->dev.platform_data)
@@ -539,7 +539,7 @@ static int ak8975_probe(struct i2c_client *client,
 	if (id) {
 		data->chipset =
 			(enum asahi_compass_chipset)(id->driver_data);
-		name = (char *) id->name;
+		name = id->name;
 	} else if (ACPI_HANDLE(&client->dev))
 		name = ak8975_match_acpi_device(&client->dev, &data->chipset);
 	else