@@ -1200,6 +1200,27 @@ static inline const struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
1200
1200
return (const struct s3c64xx_spi_port_config * )platform_get_device_id (pdev )-> driver_data ;
1201
1201
}
1202
1202
1203
+ static int s3c64xx_spi_set_port_id (struct platform_device * pdev ,
1204
+ struct s3c64xx_spi_driver_data * sdd )
1205
+ {
1206
+ int ret ;
1207
+
1208
+ if (pdev -> dev .of_node ) {
1209
+ ret = of_alias_get_id (pdev -> dev .of_node , "spi" );
1210
+ if (ret < 0 )
1211
+ return dev_err_probe (& pdev -> dev , ret ,
1212
+ "Failed to get alias id\n" );
1213
+ sdd -> port_id = ret ;
1214
+ } else {
1215
+ if (pdev -> id < 0 )
1216
+ return dev_err_probe (& pdev -> dev , - EINVAL ,
1217
+ "Negative platform ID is not allowed\n" );
1218
+ sdd -> port_id = pdev -> id ;
1219
+ }
1220
+
1221
+ return 0 ;
1222
+ }
1223
+
1203
1224
static void s3c64xx_spi_set_fifomask (struct s3c64xx_spi_driver_data * sdd )
1204
1225
{
1205
1226
const struct s3c64xx_spi_port_config * port_conf = sdd -> port_conf ;
@@ -1252,18 +1273,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1252
1273
sdd -> host = host ;
1253
1274
sdd -> cntrlr_info = sci ;
1254
1275
sdd -> pdev = pdev ;
1255
- if (pdev -> dev .of_node ) {
1256
- ret = of_alias_get_id (pdev -> dev .of_node , "spi" );
1257
- if (ret < 0 )
1258
- return dev_err_probe (& pdev -> dev , ret ,
1259
- "Failed to get alias id\n" );
1260
- sdd -> port_id = ret ;
1261
- } else {
1262
- if (pdev -> id < 0 )
1263
- return dev_err_probe (& pdev -> dev , - EINVAL ,
1264
- "Negative platform ID is not allowed\n" );
1265
- sdd -> port_id = pdev -> id ;
1266
- }
1276
+
1277
+ ret = s3c64xx_spi_set_port_id (pdev , sdd );
1278
+ if (ret )
1279
+ return ret ;
1267
1280
1268
1281
if (sdd -> port_conf -> fifo_depth )
1269
1282
sdd -> fifo_depth = sdd -> port_conf -> fifo_depth ;
0 commit comments